massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / prettier / third-party.js
1 'use strict';
2
3 var require$$0$3 = require('os');
4 var require$$0$1 = require('path');
5 var require$$1$1 = require('module');
6 var require$$1 = require('fs');
7 var require$$0$2 = require('util');
8
9 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
11 var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
12 var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
13 var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
14 var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
15 var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
16
17 var dist$2 = {};
18
19 var Explorer$1 = {};
20
21 var ExplorerBase$1 = {};
22
23 var loaders$1 = {};
24
25 var resolveFrom$2 = {exports: {}};
26
27 const path$1 = require$$0__default["default"];
28 const Module = require$$1__default$1["default"];
29 const fs$1 = require$$1__default["default"];
30
31 const resolveFrom$1 = (fromDir, moduleId, silent) => {
32   if (typeof fromDir !== 'string') {
33     throw new TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof fromDir}\``);
34   }
35
36   if (typeof moduleId !== 'string') {
37     throw new TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof moduleId}\``);
38   }
39
40   try {
41     fromDir = fs$1.realpathSync(fromDir);
42   } catch (err) {
43     if (err.code === 'ENOENT') {
44       fromDir = path$1.resolve(fromDir);
45     } else if (silent) {
46       return null;
47     } else {
48       throw err;
49     }
50   }
51
52   const fromFile = path$1.join(fromDir, 'noop.js');
53
54   const resolveFileName = () => Module._resolveFilename(moduleId, {
55     id: fromFile,
56     filename: fromFile,
57     paths: Module._nodeModulePaths(fromDir)
58   });
59
60   if (silent) {
61     try {
62       return resolveFileName();
63     } catch (err) {
64       return null;
65     }
66   }
67
68   return resolveFileName();
69 };
70
71 resolveFrom$2.exports = (fromDir, moduleId) => resolveFrom$1(fromDir, moduleId);
72
73 resolveFrom$2.exports.silent = (fromDir, moduleId) => resolveFrom$1(fromDir, moduleId, true);
74
75 var callsites$1 = {exports: {}};
76
77 const callsites = () => {
78   const _prepareStackTrace = Error.prepareStackTrace;
79
80   Error.prepareStackTrace = (_, stack) => stack;
81
82   const stack = new Error().stack.slice(1);
83   Error.prepareStackTrace = _prepareStackTrace;
84   return stack;
85 };
86
87 callsites$1.exports = callsites; // TODO: Remove this for the next major release
88
89 callsites$1.exports.default = callsites;
90
91 const path = require$$0__default["default"];
92 const resolveFrom = resolveFrom$2.exports;
93
94 var importFresh$1 = moduleId => {
95   if (typeof moduleId !== 'string') {
96     throw new TypeError('Expected a string');
97   }
98
99   const parentPath = __filename;
100   const cwd = parentPath ? path.dirname(parentPath) : __dirname;
101   const filePath = resolveFrom(cwd, moduleId);
102   const oldModule = require.cache[filePath]; // Delete itself from module parent
103
104   if (oldModule && oldModule.parent) {
105     let i = oldModule.parent.children.length;
106
107     while (i--) {
108       if (oldModule.parent.children[i].id === filePath) {
109         oldModule.parent.children.splice(i, 1);
110       }
111     }
112   }
113
114   delete require.cache[filePath]; // Delete module from cache
115
116   const parent = require.cache[parentPath]; // If `filePath` and `parentPath` are the same, cache will already be deleted so we won't get a memory leak in next step
117
118   return parent === undefined ? require(filePath) : parent.require(filePath); // In case cache doesn't have parent, fall back to normal require
119 };
120
121 var isArrayish$1 = function isArrayish(obj) {
122   if (!obj) {
123     return false;
124   }
125
126   return obj instanceof Array || Array.isArray(obj) || obj.length >= 0 && obj.splice instanceof Function;
127 };
128
129 var util = require$$0__default$1["default"];
130 var isArrayish = isArrayish$1;
131
132 var errorEx$1 = function errorEx(name, properties) {
133   if (!name || name.constructor !== String) {
134     properties = name || {};
135     name = Error.name;
136   }
137
138   var errorExError = function ErrorEXError(message) {
139     if (!this) {
140       return new ErrorEXError(message);
141     }
142
143     message = message instanceof Error ? message.message : message || this.message;
144     Error.call(this, message);
145     Error.captureStackTrace(this, errorExError);
146     this.name = name;
147     Object.defineProperty(this, 'message', {
148       configurable: true,
149       enumerable: false,
150       get: function () {
151         var newMessage = message.split(/\r?\n/g);
152
153         for (var key in properties) {
154           if (!properties.hasOwnProperty(key)) {
155             continue;
156           }
157
158           var modifier = properties[key];
159
160           if ('message' in modifier) {
161             newMessage = modifier.message(this[key], newMessage) || newMessage;
162
163             if (!isArrayish(newMessage)) {
164               newMessage = [newMessage];
165             }
166           }
167         }
168
169         return newMessage.join('\n');
170       },
171       set: function (v) {
172         message = v;
173       }
174     });
175     var overwrittenStack = null;
176     var stackDescriptor = Object.getOwnPropertyDescriptor(this, 'stack');
177     var stackGetter = stackDescriptor.get;
178     var stackValue = stackDescriptor.value;
179     delete stackDescriptor.value;
180     delete stackDescriptor.writable;
181
182     stackDescriptor.set = function (newstack) {
183       overwrittenStack = newstack;
184     };
185
186     stackDescriptor.get = function () {
187       var stack = (overwrittenStack || (stackGetter ? stackGetter.call(this) : stackValue)).split(/\r?\n+/g); // starting in Node 7, the stack builder caches the message.
188       // just replace it.
189
190       if (!overwrittenStack) {
191         stack[0] = this.name + ': ' + this.message;
192       }
193
194       var lineCount = 1;
195
196       for (var key in properties) {
197         if (!properties.hasOwnProperty(key)) {
198           continue;
199         }
200
201         var modifier = properties[key];
202
203         if ('line' in modifier) {
204           var line = modifier.line(this[key]);
205
206           if (line) {
207             stack.splice(lineCount++, 0, '    ' + line);
208           }
209         }
210
211         if ('stack' in modifier) {
212           modifier.stack(this[key], stack);
213         }
214       }
215
216       return stack.join('\n');
217     };
218
219     Object.defineProperty(this, 'stack', stackDescriptor);
220   };
221
222   if (Object.setPrototypeOf) {
223     Object.setPrototypeOf(errorExError.prototype, Error.prototype);
224     Object.setPrototypeOf(errorExError, Error);
225   } else {
226     util.inherits(errorExError, Error);
227   }
228
229   return errorExError;
230 };
231
232 errorEx$1.append = function (str, def) {
233   return {
234     message: function (v, message) {
235       v = v || def;
236
237       if (v) {
238         message[0] += ' ' + str.replace('%s', v.toString());
239       }
240
241       return message;
242     }
243   };
244 };
245
246 errorEx$1.line = function (str, def) {
247   return {
248     line: function (v) {
249       v = v || def;
250
251       if (v) {
252         return str.replace('%s', v.toString());
253       }
254
255       return null;
256     }
257   };
258 };
259
260 var errorEx_1 = errorEx$1;
261
262 const hexify = char => {
263   const h = char.charCodeAt(0).toString(16).toUpperCase();
264   return '0x' + (h.length % 2 ? '0' : '') + h;
265 };
266
267 const parseError = (e, txt, context) => {
268   if (!txt) {
269     return {
270       message: e.message + ' while parsing empty string',
271       position: 0
272     };
273   }
274
275   const badToken = e.message.match(/^Unexpected token (.) .*position\s+(\d+)/i);
276   const errIdx = badToken ? +badToken[2] : e.message.match(/^Unexpected end of JSON.*/i) ? txt.length - 1 : null;
277   const msg = badToken ? e.message.replace(/^Unexpected token ./, `Unexpected token ${JSON.stringify(badToken[1])} (${hexify(badToken[1])})`) : e.message;
278
279   if (errIdx !== null && errIdx !== undefined) {
280     const start = errIdx <= context ? 0 : errIdx - context;
281     const end = errIdx + context >= txt.length ? txt.length : errIdx + context;
282     const slice = (start === 0 ? '' : '...') + txt.slice(start, end) + (end === txt.length ? '' : '...');
283     const near = txt === slice ? '' : 'near ';
284     return {
285       message: msg + ` while parsing ${near}${JSON.stringify(slice)}`,
286       position: errIdx
287     };
288   } else {
289     return {
290       message: msg + ` while parsing '${txt.slice(0, context * 2)}'`,
291       position: 0
292     };
293   }
294 };
295
296 class JSONParseError extends SyntaxError {
297   constructor(er, txt, context, caller) {
298     context = context || 20;
299     const metadata = parseError(er, txt, context);
300     super(metadata.message);
301     Object.assign(this, metadata);
302     this.code = 'EJSONPARSE';
303     this.systemError = er;
304     Error.captureStackTrace(this, caller || this.constructor);
305   }
306
307   get name() {
308     return this.constructor.name;
309   }
310
311   set name(n) {}
312
313   get [Symbol.toStringTag]() {
314     return this.constructor.name;
315   }
316
317 }
318
319 const kIndent = Symbol.for('indent');
320 const kNewline = Symbol.for('newline'); // only respect indentation if we got a line break, otherwise squash it
321 // things other than objects and arrays aren't indented, so ignore those
322 // Important: in both of these regexps, the $1 capture group is the newline
323 // or undefined, and the $2 capture group is the indent, or undefined.
324
325 const formatRE = /^\s*[{\[]((?:\r?\n)+)([\s\t]*)/;
326 const emptyRE = /^(?:\{\}|\[\])((?:\r?\n)+)?$/;
327
328 const parseJson$2 = (txt, reviver, context) => {
329   const parseText = stripBOM(txt);
330   context = context || 20;
331
332   try {
333     // get the indentation so that we can save it back nicely
334     // if the file starts with {" then we have an indent of '', ie, none
335     // otherwise, pick the indentation of the next line after the first \n
336     // If the pattern doesn't match, then it means no indentation.
337     // JSON.stringify ignores symbols, so this is reasonably safe.
338     // if the string is '{}' or '[]', then use the default 2-space indent.
339     const [, newline = '\n', indent = '  '] = parseText.match(emptyRE) || parseText.match(formatRE) || [, '', ''];
340     const result = JSON.parse(parseText, reviver);
341
342     if (result && typeof result === 'object') {
343       result[kNewline] = newline;
344       result[kIndent] = indent;
345     }
346
347     return result;
348   } catch (e) {
349     if (typeof txt !== 'string' && !Buffer.isBuffer(txt)) {
350       const isEmptyArray = Array.isArray(txt) && txt.length === 0;
351       throw Object.assign(new TypeError(`Cannot parse ${isEmptyArray ? 'an empty array' : String(txt)}`), {
352         code: 'EJSONPARSE',
353         systemError: e
354       });
355     }
356
357     throw new JSONParseError(e, parseText, context, parseJson$2);
358   }
359 }; // Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
360 // because the buffer-to-string conversion in `fs.readFileSync()`
361 // translates it to FEFF, the UTF-16 BOM.
362
363
364 const stripBOM = txt => String(txt).replace(/^\uFEFF/, '');
365
366 var jsonParseEvenBetterErrors = parseJson$2;
367 parseJson$2.JSONParseError = JSONParseError;
368
369 parseJson$2.noExceptions = (txt, reviver) => {
370   try {
371     return JSON.parse(stripBOM(txt), reviver);
372   } catch (e) {}
373 };
374
375 var dist$1 = {};
376
377 (function (exports) {
378
379   var LF = '\n';
380   var CR = '\r';
381
382   var LinesAndColumns = function () {
383     function LinesAndColumns(string) {
384       this.string = string;
385       var offsets = [0];
386
387       for (var offset = 0; offset < string.length;) {
388         switch (string[offset]) {
389           case LF:
390             offset += LF.length;
391             offsets.push(offset);
392             break;
393
394           case CR:
395             offset += CR.length;
396
397             if (string[offset] === LF) {
398               offset += LF.length;
399             }
400
401             offsets.push(offset);
402             break;
403
404           default:
405             offset++;
406             break;
407         }
408       }
409
410       this.offsets = offsets;
411     }
412
413     LinesAndColumns.prototype.locationForIndex = function (index) {
414       if (index < 0 || index > this.string.length) {
415         return null;
416       }
417
418       var line = 0;
419       var offsets = this.offsets;
420
421       while (offsets[line + 1] <= index) {
422         line++;
423       }
424
425       var column = index - offsets[line];
426       return {
427         line: line,
428         column: column
429       };
430     };
431
432     LinesAndColumns.prototype.indexForLocation = function (location) {
433       var line = location.line,
434           column = location.column;
435
436       if (line < 0 || line >= this.offsets.length) {
437         return null;
438       }
439
440       if (column < 0 || column > this.lengthOfLine(line)) {
441         return null;
442       }
443
444       return this.offsets[line] + column;
445     };
446
447     LinesAndColumns.prototype.lengthOfLine = function (line) {
448       var offset = this.offsets[line];
449       var nextOffset = line === this.offsets.length - 1 ? this.string.length : this.offsets[line + 1];
450       return nextOffset - offset;
451     };
452
453     return LinesAndColumns;
454   }();
455
456   exports.__esModule = true;
457   exports["default"] = LinesAndColumns;
458 })(dist$1);
459
460 var lib$2 = {};
461
462 var lib$1 = {};
463
464 var jsTokens = {};
465
466 // License: MIT. (See LICENSE.)
467
468 Object.defineProperty(jsTokens, "__esModule", {
469   value: true
470 }); // This regex comes from regex.coffee, and is inserted here by generate-index.js
471 // (run `npm run build`).
472
473 jsTokens.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g;
474
475 jsTokens.matchToToken = function (match) {
476   var token = {
477     type: "invalid",
478     value: match[0],
479     closed: undefined
480   };
481   if (match[1]) token.type = "string", token.closed = !!(match[3] || match[4]);else if (match[5]) token.type = "comment";else if (match[6]) token.type = "comment", token.closed = !!match[7];else if (match[8]) token.type = "regex";else if (match[9]) token.type = "number";else if (match[10]) token.type = "name";else if (match[11]) token.type = "punctuator";else if (match[12]) token.type = "whitespace";
482   return token;
483 };
484
485 var lib = {};
486
487 var identifier = {};
488
489 Object.defineProperty(identifier, "__esModule", {
490   value: true
491 });
492 identifier.isIdentifierStart = isIdentifierStart;
493 identifier.isIdentifierChar = isIdentifierChar;
494 identifier.isIdentifierName = isIdentifierName;
495 let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
496 let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
497 const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
498 const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
499 nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
500 const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 190, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1070, 4050, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 46, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 482, 44, 11, 6, 17, 0, 322, 29, 19, 43, 1269, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4152, 8, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938];
501 const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 357, 0, 62, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
502
503 function isInAstralSet(code, set) {
504   let pos = 0x10000;
505
506   for (let i = 0, length = set.length; i < length; i += 2) {
507     pos += set[i];
508     if (pos > code) return false;
509     pos += set[i + 1];
510     if (pos >= code) return true;
511   }
512
513   return false;
514 }
515
516 function isIdentifierStart(code) {
517   if (code < 65) return code === 36;
518   if (code <= 90) return true;
519   if (code < 97) return code === 95;
520   if (code <= 122) return true;
521
522   if (code <= 0xffff) {
523     return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
524   }
525
526   return isInAstralSet(code, astralIdentifierStartCodes);
527 }
528
529 function isIdentifierChar(code) {
530   if (code < 48) return code === 36;
531   if (code < 58) return true;
532   if (code < 65) return false;
533   if (code <= 90) return true;
534   if (code < 97) return code === 95;
535   if (code <= 122) return true;
536
537   if (code <= 0xffff) {
538     return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
539   }
540
541   return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
542 }
543
544 function isIdentifierName(name) {
545   let isFirst = true;
546
547   for (let i = 0; i < name.length; i++) {
548     let cp = name.charCodeAt(i);
549
550     if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) {
551       const trail = name.charCodeAt(++i);
552
553       if ((trail & 0xfc00) === 0xdc00) {
554         cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
555       }
556     }
557
558     if (isFirst) {
559       isFirst = false;
560
561       if (!isIdentifierStart(cp)) {
562         return false;
563       }
564     } else if (!isIdentifierChar(cp)) {
565       return false;
566     }
567   }
568
569   return !isFirst;
570 }
571
572 var keyword = {};
573
574 Object.defineProperty(keyword, "__esModule", {
575   value: true
576 });
577 keyword.isReservedWord = isReservedWord;
578 keyword.isStrictReservedWord = isStrictReservedWord;
579 keyword.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
580 keyword.isStrictBindReservedWord = isStrictBindReservedWord;
581 keyword.isKeyword = isKeyword;
582 const reservedWords = {
583   keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
584   strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
585   strictBind: ["eval", "arguments"]
586 };
587 const keywords = new Set(reservedWords.keyword);
588 const reservedWordsStrictSet = new Set(reservedWords.strict);
589 const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
590
591 function isReservedWord(word, inModule) {
592   return inModule && word === "await" || word === "enum";
593 }
594
595 function isStrictReservedWord(word, inModule) {
596   return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
597 }
598
599 function isStrictBindOnlyReservedWord(word) {
600   return reservedWordsStrictBindSet.has(word);
601 }
602
603 function isStrictBindReservedWord(word, inModule) {
604   return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
605 }
606
607 function isKeyword(word) {
608   return keywords.has(word);
609 }
610
611 (function (exports) {
612
613   Object.defineProperty(exports, "__esModule", {
614     value: true
615   });
616   Object.defineProperty(exports, "isIdentifierName", {
617     enumerable: true,
618     get: function () {
619       return _identifier.isIdentifierName;
620     }
621   });
622   Object.defineProperty(exports, "isIdentifierChar", {
623     enumerable: true,
624     get: function () {
625       return _identifier.isIdentifierChar;
626     }
627   });
628   Object.defineProperty(exports, "isIdentifierStart", {
629     enumerable: true,
630     get: function () {
631       return _identifier.isIdentifierStart;
632     }
633   });
634   Object.defineProperty(exports, "isReservedWord", {
635     enumerable: true,
636     get: function () {
637       return _keyword.isReservedWord;
638     }
639   });
640   Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
641     enumerable: true,
642     get: function () {
643       return _keyword.isStrictBindOnlyReservedWord;
644     }
645   });
646   Object.defineProperty(exports, "isStrictBindReservedWord", {
647     enumerable: true,
648     get: function () {
649       return _keyword.isStrictBindReservedWord;
650     }
651   });
652   Object.defineProperty(exports, "isStrictReservedWord", {
653     enumerable: true,
654     get: function () {
655       return _keyword.isStrictReservedWord;
656     }
657   });
658   Object.defineProperty(exports, "isKeyword", {
659     enumerable: true,
660     get: function () {
661       return _keyword.isKeyword;
662     }
663   });
664   var _identifier = identifier;
665   var _keyword = keyword;
666 })(lib);
667
668 var chalk = {exports: {}};
669
670 var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
671
672 var escapeStringRegexp = function (str) {
673   if (typeof str !== 'string') {
674     throw new TypeError('Expected a string');
675   }
676
677   return str.replace(matchOperatorsRe, '\\$&');
678 };
679
680 var ansiStyles = {exports: {}};
681
682 var conversions$2 = {exports: {}};
683
684 var colorName = {
685   "aliceblue": [240, 248, 255],
686   "antiquewhite": [250, 235, 215],
687   "aqua": [0, 255, 255],
688   "aquamarine": [127, 255, 212],
689   "azure": [240, 255, 255],
690   "beige": [245, 245, 220],
691   "bisque": [255, 228, 196],
692   "black": [0, 0, 0],
693   "blanchedalmond": [255, 235, 205],
694   "blue": [0, 0, 255],
695   "blueviolet": [138, 43, 226],
696   "brown": [165, 42, 42],
697   "burlywood": [222, 184, 135],
698   "cadetblue": [95, 158, 160],
699   "chartreuse": [127, 255, 0],
700   "chocolate": [210, 105, 30],
701   "coral": [255, 127, 80],
702   "cornflowerblue": [100, 149, 237],
703   "cornsilk": [255, 248, 220],
704   "crimson": [220, 20, 60],
705   "cyan": [0, 255, 255],
706   "darkblue": [0, 0, 139],
707   "darkcyan": [0, 139, 139],
708   "darkgoldenrod": [184, 134, 11],
709   "darkgray": [169, 169, 169],
710   "darkgreen": [0, 100, 0],
711   "darkgrey": [169, 169, 169],
712   "darkkhaki": [189, 183, 107],
713   "darkmagenta": [139, 0, 139],
714   "darkolivegreen": [85, 107, 47],
715   "darkorange": [255, 140, 0],
716   "darkorchid": [153, 50, 204],
717   "darkred": [139, 0, 0],
718   "darksalmon": [233, 150, 122],
719   "darkseagreen": [143, 188, 143],
720   "darkslateblue": [72, 61, 139],
721   "darkslategray": [47, 79, 79],
722   "darkslategrey": [47, 79, 79],
723   "darkturquoise": [0, 206, 209],
724   "darkviolet": [148, 0, 211],
725   "deeppink": [255, 20, 147],
726   "deepskyblue": [0, 191, 255],
727   "dimgray": [105, 105, 105],
728   "dimgrey": [105, 105, 105],
729   "dodgerblue": [30, 144, 255],
730   "firebrick": [178, 34, 34],
731   "floralwhite": [255, 250, 240],
732   "forestgreen": [34, 139, 34],
733   "fuchsia": [255, 0, 255],
734   "gainsboro": [220, 220, 220],
735   "ghostwhite": [248, 248, 255],
736   "gold": [255, 215, 0],
737   "goldenrod": [218, 165, 32],
738   "gray": [128, 128, 128],
739   "green": [0, 128, 0],
740   "greenyellow": [173, 255, 47],
741   "grey": [128, 128, 128],
742   "honeydew": [240, 255, 240],
743   "hotpink": [255, 105, 180],
744   "indianred": [205, 92, 92],
745   "indigo": [75, 0, 130],
746   "ivory": [255, 255, 240],
747   "khaki": [240, 230, 140],
748   "lavender": [230, 230, 250],
749   "lavenderblush": [255, 240, 245],
750   "lawngreen": [124, 252, 0],
751   "lemonchiffon": [255, 250, 205],
752   "lightblue": [173, 216, 230],
753   "lightcoral": [240, 128, 128],
754   "lightcyan": [224, 255, 255],
755   "lightgoldenrodyellow": [250, 250, 210],
756   "lightgray": [211, 211, 211],
757   "lightgreen": [144, 238, 144],
758   "lightgrey": [211, 211, 211],
759   "lightpink": [255, 182, 193],
760   "lightsalmon": [255, 160, 122],
761   "lightseagreen": [32, 178, 170],
762   "lightskyblue": [135, 206, 250],
763   "lightslategray": [119, 136, 153],
764   "lightslategrey": [119, 136, 153],
765   "lightsteelblue": [176, 196, 222],
766   "lightyellow": [255, 255, 224],
767   "lime": [0, 255, 0],
768   "limegreen": [50, 205, 50],
769   "linen": [250, 240, 230],
770   "magenta": [255, 0, 255],
771   "maroon": [128, 0, 0],
772   "mediumaquamarine": [102, 205, 170],
773   "mediumblue": [0, 0, 205],
774   "mediumorchid": [186, 85, 211],
775   "mediumpurple": [147, 112, 219],
776   "mediumseagreen": [60, 179, 113],
777   "mediumslateblue": [123, 104, 238],
778   "mediumspringgreen": [0, 250, 154],
779   "mediumturquoise": [72, 209, 204],
780   "mediumvioletred": [199, 21, 133],
781   "midnightblue": [25, 25, 112],
782   "mintcream": [245, 255, 250],
783   "mistyrose": [255, 228, 225],
784   "moccasin": [255, 228, 181],
785   "navajowhite": [255, 222, 173],
786   "navy": [0, 0, 128],
787   "oldlace": [253, 245, 230],
788   "olive": [128, 128, 0],
789   "olivedrab": [107, 142, 35],
790   "orange": [255, 165, 0],
791   "orangered": [255, 69, 0],
792   "orchid": [218, 112, 214],
793   "palegoldenrod": [238, 232, 170],
794   "palegreen": [152, 251, 152],
795   "paleturquoise": [175, 238, 238],
796   "palevioletred": [219, 112, 147],
797   "papayawhip": [255, 239, 213],
798   "peachpuff": [255, 218, 185],
799   "peru": [205, 133, 63],
800   "pink": [255, 192, 203],
801   "plum": [221, 160, 221],
802   "powderblue": [176, 224, 230],
803   "purple": [128, 0, 128],
804   "rebeccapurple": [102, 51, 153],
805   "red": [255, 0, 0],
806   "rosybrown": [188, 143, 143],
807   "royalblue": [65, 105, 225],
808   "saddlebrown": [139, 69, 19],
809   "salmon": [250, 128, 114],
810   "sandybrown": [244, 164, 96],
811   "seagreen": [46, 139, 87],
812   "seashell": [255, 245, 238],
813   "sienna": [160, 82, 45],
814   "silver": [192, 192, 192],
815   "skyblue": [135, 206, 235],
816   "slateblue": [106, 90, 205],
817   "slategray": [112, 128, 144],
818   "slategrey": [112, 128, 144],
819   "snow": [255, 250, 250],
820   "springgreen": [0, 255, 127],
821   "steelblue": [70, 130, 180],
822   "tan": [210, 180, 140],
823   "teal": [0, 128, 128],
824   "thistle": [216, 191, 216],
825   "tomato": [255, 99, 71],
826   "turquoise": [64, 224, 208],
827   "violet": [238, 130, 238],
828   "wheat": [245, 222, 179],
829   "white": [255, 255, 255],
830   "whitesmoke": [245, 245, 245],
831   "yellow": [255, 255, 0],
832   "yellowgreen": [154, 205, 50]
833 };
834
835 /* MIT license */
836 var cssKeywords = colorName; // NOTE: conversions should only return primitive values (i.e. arrays, or
837 //       values that give correct `typeof` results).
838 //       do not use box values types (i.e. Number(), String(), etc.)
839
840 var reverseKeywords = {};
841
842 for (var key in cssKeywords) {
843   if (cssKeywords.hasOwnProperty(key)) {
844     reverseKeywords[cssKeywords[key]] = key;
845   }
846 }
847
848 var convert$1 = conversions$2.exports = {
849   rgb: {
850     channels: 3,
851     labels: 'rgb'
852   },
853   hsl: {
854     channels: 3,
855     labels: 'hsl'
856   },
857   hsv: {
858     channels: 3,
859     labels: 'hsv'
860   },
861   hwb: {
862     channels: 3,
863     labels: 'hwb'
864   },
865   cmyk: {
866     channels: 4,
867     labels: 'cmyk'
868   },
869   xyz: {
870     channels: 3,
871     labels: 'xyz'
872   },
873   lab: {
874     channels: 3,
875     labels: 'lab'
876   },
877   lch: {
878     channels: 3,
879     labels: 'lch'
880   },
881   hex: {
882     channels: 1,
883     labels: ['hex']
884   },
885   keyword: {
886     channels: 1,
887     labels: ['keyword']
888   },
889   ansi16: {
890     channels: 1,
891     labels: ['ansi16']
892   },
893   ansi256: {
894     channels: 1,
895     labels: ['ansi256']
896   },
897   hcg: {
898     channels: 3,
899     labels: ['h', 'c', 'g']
900   },
901   apple: {
902     channels: 3,
903     labels: ['r16', 'g16', 'b16']
904   },
905   gray: {
906     channels: 1,
907     labels: ['gray']
908   }
909 }; // hide .channels and .labels properties
910
911 for (var model in convert$1) {
912   if (convert$1.hasOwnProperty(model)) {
913     if (!('channels' in convert$1[model])) {
914       throw new Error('missing channels property: ' + model);
915     }
916
917     if (!('labels' in convert$1[model])) {
918       throw new Error('missing channel labels property: ' + model);
919     }
920
921     if (convert$1[model].labels.length !== convert$1[model].channels) {
922       throw new Error('channel and label counts mismatch: ' + model);
923     }
924
925     var channels = convert$1[model].channels;
926     var labels = convert$1[model].labels;
927     delete convert$1[model].channels;
928     delete convert$1[model].labels;
929     Object.defineProperty(convert$1[model], 'channels', {
930       value: channels
931     });
932     Object.defineProperty(convert$1[model], 'labels', {
933       value: labels
934     });
935   }
936 }
937
938 convert$1.rgb.hsl = function (rgb) {
939   var r = rgb[0] / 255;
940   var g = rgb[1] / 255;
941   var b = rgb[2] / 255;
942   var min = Math.min(r, g, b);
943   var max = Math.max(r, g, b);
944   var delta = max - min;
945   var h;
946   var s;
947   var l;
948
949   if (max === min) {
950     h = 0;
951   } else if (r === max) {
952     h = (g - b) / delta;
953   } else if (g === max) {
954     h = 2 + (b - r) / delta;
955   } else if (b === max) {
956     h = 4 + (r - g) / delta;
957   }
958
959   h = Math.min(h * 60, 360);
960
961   if (h < 0) {
962     h += 360;
963   }
964
965   l = (min + max) / 2;
966
967   if (max === min) {
968     s = 0;
969   } else if (l <= 0.5) {
970     s = delta / (max + min);
971   } else {
972     s = delta / (2 - max - min);
973   }
974
975   return [h, s * 100, l * 100];
976 };
977
978 convert$1.rgb.hsv = function (rgb) {
979   var rdif;
980   var gdif;
981   var bdif;
982   var h;
983   var s;
984   var r = rgb[0] / 255;
985   var g = rgb[1] / 255;
986   var b = rgb[2] / 255;
987   var v = Math.max(r, g, b);
988   var diff = v - Math.min(r, g, b);
989
990   var diffc = function (c) {
991     return (v - c) / 6 / diff + 1 / 2;
992   };
993
994   if (diff === 0) {
995     h = s = 0;
996   } else {
997     s = diff / v;
998     rdif = diffc(r);
999     gdif = diffc(g);
1000     bdif = diffc(b);
1001
1002     if (r === v) {
1003       h = bdif - gdif;
1004     } else if (g === v) {
1005       h = 1 / 3 + rdif - bdif;
1006     } else if (b === v) {
1007       h = 2 / 3 + gdif - rdif;
1008     }
1009
1010     if (h < 0) {
1011       h += 1;
1012     } else if (h > 1) {
1013       h -= 1;
1014     }
1015   }
1016
1017   return [h * 360, s * 100, v * 100];
1018 };
1019
1020 convert$1.rgb.hwb = function (rgb) {
1021   var r = rgb[0];
1022   var g = rgb[1];
1023   var b = rgb[2];
1024   var h = convert$1.rgb.hsl(rgb)[0];
1025   var w = 1 / 255 * Math.min(r, Math.min(g, b));
1026   b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
1027   return [h, w * 100, b * 100];
1028 };
1029
1030 convert$1.rgb.cmyk = function (rgb) {
1031   var r = rgb[0] / 255;
1032   var g = rgb[1] / 255;
1033   var b = rgb[2] / 255;
1034   var c;
1035   var m;
1036   var y;
1037   var k;
1038   k = Math.min(1 - r, 1 - g, 1 - b);
1039   c = (1 - r - k) / (1 - k) || 0;
1040   m = (1 - g - k) / (1 - k) || 0;
1041   y = (1 - b - k) / (1 - k) || 0;
1042   return [c * 100, m * 100, y * 100, k * 100];
1043 };
1044 /**
1045  * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
1046  * */
1047
1048
1049 function comparativeDistance(x, y) {
1050   return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
1051 }
1052
1053 convert$1.rgb.keyword = function (rgb) {
1054   var reversed = reverseKeywords[rgb];
1055
1056   if (reversed) {
1057     return reversed;
1058   }
1059
1060   var currentClosestDistance = Infinity;
1061   var currentClosestKeyword;
1062
1063   for (var keyword in cssKeywords) {
1064     if (cssKeywords.hasOwnProperty(keyword)) {
1065       var value = cssKeywords[keyword]; // Compute comparative distance
1066
1067       var distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
1068
1069       if (distance < currentClosestDistance) {
1070         currentClosestDistance = distance;
1071         currentClosestKeyword = keyword;
1072       }
1073     }
1074   }
1075
1076   return currentClosestKeyword;
1077 };
1078
1079 convert$1.keyword.rgb = function (keyword) {
1080   return cssKeywords[keyword];
1081 };
1082
1083 convert$1.rgb.xyz = function (rgb) {
1084   var r = rgb[0] / 255;
1085   var g = rgb[1] / 255;
1086   var b = rgb[2] / 255; // assume sRGB
1087
1088   r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
1089   g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
1090   b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
1091   var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
1092   var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
1093   var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
1094   return [x * 100, y * 100, z * 100];
1095 };
1096
1097 convert$1.rgb.lab = function (rgb) {
1098   var xyz = convert$1.rgb.xyz(rgb);
1099   var x = xyz[0];
1100   var y = xyz[1];
1101   var z = xyz[2];
1102   var l;
1103   var a;
1104   var b;
1105   x /= 95.047;
1106   y /= 100;
1107   z /= 108.883;
1108   x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
1109   y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
1110   z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
1111   l = 116 * y - 16;
1112   a = 500 * (x - y);
1113   b = 200 * (y - z);
1114   return [l, a, b];
1115 };
1116
1117 convert$1.hsl.rgb = function (hsl) {
1118   var h = hsl[0] / 360;
1119   var s = hsl[1] / 100;
1120   var l = hsl[2] / 100;
1121   var t1;
1122   var t2;
1123   var t3;
1124   var rgb;
1125   var val;
1126
1127   if (s === 0) {
1128     val = l * 255;
1129     return [val, val, val];
1130   }
1131
1132   if (l < 0.5) {
1133     t2 = l * (1 + s);
1134   } else {
1135     t2 = l + s - l * s;
1136   }
1137
1138   t1 = 2 * l - t2;
1139   rgb = [0, 0, 0];
1140
1141   for (var i = 0; i < 3; i++) {
1142     t3 = h + 1 / 3 * -(i - 1);
1143
1144     if (t3 < 0) {
1145       t3++;
1146     }
1147
1148     if (t3 > 1) {
1149       t3--;
1150     }
1151
1152     if (6 * t3 < 1) {
1153       val = t1 + (t2 - t1) * 6 * t3;
1154     } else if (2 * t3 < 1) {
1155       val = t2;
1156     } else if (3 * t3 < 2) {
1157       val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
1158     } else {
1159       val = t1;
1160     }
1161
1162     rgb[i] = val * 255;
1163   }
1164
1165   return rgb;
1166 };
1167
1168 convert$1.hsl.hsv = function (hsl) {
1169   var h = hsl[0];
1170   var s = hsl[1] / 100;
1171   var l = hsl[2] / 100;
1172   var smin = s;
1173   var lmin = Math.max(l, 0.01);
1174   var sv;
1175   var v;
1176   l *= 2;
1177   s *= l <= 1 ? l : 2 - l;
1178   smin *= lmin <= 1 ? lmin : 2 - lmin;
1179   v = (l + s) / 2;
1180   sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
1181   return [h, sv * 100, v * 100];
1182 };
1183
1184 convert$1.hsv.rgb = function (hsv) {
1185   var h = hsv[0] / 60;
1186   var s = hsv[1] / 100;
1187   var v = hsv[2] / 100;
1188   var hi = Math.floor(h) % 6;
1189   var f = h - Math.floor(h);
1190   var p = 255 * v * (1 - s);
1191   var q = 255 * v * (1 - s * f);
1192   var t = 255 * v * (1 - s * (1 - f));
1193   v *= 255;
1194
1195   switch (hi) {
1196     case 0:
1197       return [v, t, p];
1198
1199     case 1:
1200       return [q, v, p];
1201
1202     case 2:
1203       return [p, v, t];
1204
1205     case 3:
1206       return [p, q, v];
1207
1208     case 4:
1209       return [t, p, v];
1210
1211     case 5:
1212       return [v, p, q];
1213   }
1214 };
1215
1216 convert$1.hsv.hsl = function (hsv) {
1217   var h = hsv[0];
1218   var s = hsv[1] / 100;
1219   var v = hsv[2] / 100;
1220   var vmin = Math.max(v, 0.01);
1221   var lmin;
1222   var sl;
1223   var l;
1224   l = (2 - s) * v;
1225   lmin = (2 - s) * vmin;
1226   sl = s * vmin;
1227   sl /= lmin <= 1 ? lmin : 2 - lmin;
1228   sl = sl || 0;
1229   l /= 2;
1230   return [h, sl * 100, l * 100];
1231 }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
1232
1233
1234 convert$1.hwb.rgb = function (hwb) {
1235   var h = hwb[0] / 360;
1236   var wh = hwb[1] / 100;
1237   var bl = hwb[2] / 100;
1238   var ratio = wh + bl;
1239   var i;
1240   var v;
1241   var f;
1242   var n; // wh + bl cant be > 1
1243
1244   if (ratio > 1) {
1245     wh /= ratio;
1246     bl /= ratio;
1247   }
1248
1249   i = Math.floor(6 * h);
1250   v = 1 - bl;
1251   f = 6 * h - i;
1252
1253   if ((i & 0x01) !== 0) {
1254     f = 1 - f;
1255   }
1256
1257   n = wh + f * (v - wh); // linear interpolation
1258
1259   var r;
1260   var g;
1261   var b;
1262
1263   switch (i) {
1264     default:
1265     case 6:
1266     case 0:
1267       r = v;
1268       g = n;
1269       b = wh;
1270       break;
1271
1272     case 1:
1273       r = n;
1274       g = v;
1275       b = wh;
1276       break;
1277
1278     case 2:
1279       r = wh;
1280       g = v;
1281       b = n;
1282       break;
1283
1284     case 3:
1285       r = wh;
1286       g = n;
1287       b = v;
1288       break;
1289
1290     case 4:
1291       r = n;
1292       g = wh;
1293       b = v;
1294       break;
1295
1296     case 5:
1297       r = v;
1298       g = wh;
1299       b = n;
1300       break;
1301   }
1302
1303   return [r * 255, g * 255, b * 255];
1304 };
1305
1306 convert$1.cmyk.rgb = function (cmyk) {
1307   var c = cmyk[0] / 100;
1308   var m = cmyk[1] / 100;
1309   var y = cmyk[2] / 100;
1310   var k = cmyk[3] / 100;
1311   var r;
1312   var g;
1313   var b;
1314   r = 1 - Math.min(1, c * (1 - k) + k);
1315   g = 1 - Math.min(1, m * (1 - k) + k);
1316   b = 1 - Math.min(1, y * (1 - k) + k);
1317   return [r * 255, g * 255, b * 255];
1318 };
1319
1320 convert$1.xyz.rgb = function (xyz) {
1321   var x = xyz[0] / 100;
1322   var y = xyz[1] / 100;
1323   var z = xyz[2] / 100;
1324   var r;
1325   var g;
1326   var b;
1327   r = x * 3.2406 + y * -1.5372 + z * -0.4986;
1328   g = x * -0.9689 + y * 1.8758 + z * 0.0415;
1329   b = x * 0.0557 + y * -0.2040 + z * 1.0570; // assume sRGB
1330
1331   r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
1332   g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
1333   b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
1334   r = Math.min(Math.max(0, r), 1);
1335   g = Math.min(Math.max(0, g), 1);
1336   b = Math.min(Math.max(0, b), 1);
1337   return [r * 255, g * 255, b * 255];
1338 };
1339
1340 convert$1.xyz.lab = function (xyz) {
1341   var x = xyz[0];
1342   var y = xyz[1];
1343   var z = xyz[2];
1344   var l;
1345   var a;
1346   var b;
1347   x /= 95.047;
1348   y /= 100;
1349   z /= 108.883;
1350   x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
1351   y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
1352   z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
1353   l = 116 * y - 16;
1354   a = 500 * (x - y);
1355   b = 200 * (y - z);
1356   return [l, a, b];
1357 };
1358
1359 convert$1.lab.xyz = function (lab) {
1360   var l = lab[0];
1361   var a = lab[1];
1362   var b = lab[2];
1363   var x;
1364   var y;
1365   var z;
1366   y = (l + 16) / 116;
1367   x = a / 500 + y;
1368   z = y - b / 200;
1369   var y2 = Math.pow(y, 3);
1370   var x2 = Math.pow(x, 3);
1371   var z2 = Math.pow(z, 3);
1372   y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
1373   x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
1374   z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
1375   x *= 95.047;
1376   y *= 100;
1377   z *= 108.883;
1378   return [x, y, z];
1379 };
1380
1381 convert$1.lab.lch = function (lab) {
1382   var l = lab[0];
1383   var a = lab[1];
1384   var b = lab[2];
1385   var hr;
1386   var h;
1387   var c;
1388   hr = Math.atan2(b, a);
1389   h = hr * 360 / 2 / Math.PI;
1390
1391   if (h < 0) {
1392     h += 360;
1393   }
1394
1395   c = Math.sqrt(a * a + b * b);
1396   return [l, c, h];
1397 };
1398
1399 convert$1.lch.lab = function (lch) {
1400   var l = lch[0];
1401   var c = lch[1];
1402   var h = lch[2];
1403   var a;
1404   var b;
1405   var hr;
1406   hr = h / 360 * 2 * Math.PI;
1407   a = c * Math.cos(hr);
1408   b = c * Math.sin(hr);
1409   return [l, a, b];
1410 };
1411
1412 convert$1.rgb.ansi16 = function (args) {
1413   var r = args[0];
1414   var g = args[1];
1415   var b = args[2];
1416   var value = 1 in arguments ? arguments[1] : convert$1.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
1417
1418   value = Math.round(value / 50);
1419
1420   if (value === 0) {
1421     return 30;
1422   }
1423
1424   var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
1425
1426   if (value === 2) {
1427     ansi += 60;
1428   }
1429
1430   return ansi;
1431 };
1432
1433 convert$1.hsv.ansi16 = function (args) {
1434   // optimization here; we already know the value and don't need to get
1435   // it converted for us.
1436   return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
1437 };
1438
1439 convert$1.rgb.ansi256 = function (args) {
1440   var r = args[0];
1441   var g = args[1];
1442   var b = args[2]; // we use the extended greyscale palette here, with the exception of
1443   // black and white. normal palette only has 4 greyscale shades.
1444
1445   if (r === g && g === b) {
1446     if (r < 8) {
1447       return 16;
1448     }
1449
1450     if (r > 248) {
1451       return 231;
1452     }
1453
1454     return Math.round((r - 8) / 247 * 24) + 232;
1455   }
1456
1457   var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
1458   return ansi;
1459 };
1460
1461 convert$1.ansi16.rgb = function (args) {
1462   var color = args % 10; // handle greyscale
1463
1464   if (color === 0 || color === 7) {
1465     if (args > 50) {
1466       color += 3.5;
1467     }
1468
1469     color = color / 10.5 * 255;
1470     return [color, color, color];
1471   }
1472
1473   var mult = (~~(args > 50) + 1) * 0.5;
1474   var r = (color & 1) * mult * 255;
1475   var g = (color >> 1 & 1) * mult * 255;
1476   var b = (color >> 2 & 1) * mult * 255;
1477   return [r, g, b];
1478 };
1479
1480 convert$1.ansi256.rgb = function (args) {
1481   // handle greyscale
1482   if (args >= 232) {
1483     var c = (args - 232) * 10 + 8;
1484     return [c, c, c];
1485   }
1486
1487   args -= 16;
1488   var rem;
1489   var r = Math.floor(args / 36) / 5 * 255;
1490   var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
1491   var b = rem % 6 / 5 * 255;
1492   return [r, g, b];
1493 };
1494
1495 convert$1.rgb.hex = function (args) {
1496   var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
1497   var string = integer.toString(16).toUpperCase();
1498   return '000000'.substring(string.length) + string;
1499 };
1500
1501 convert$1.hex.rgb = function (args) {
1502   var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
1503
1504   if (!match) {
1505     return [0, 0, 0];
1506   }
1507
1508   var colorString = match[0];
1509
1510   if (match[0].length === 3) {
1511     colorString = colorString.split('').map(function (char) {
1512       return char + char;
1513     }).join('');
1514   }
1515
1516   var integer = parseInt(colorString, 16);
1517   var r = integer >> 16 & 0xFF;
1518   var g = integer >> 8 & 0xFF;
1519   var b = integer & 0xFF;
1520   return [r, g, b];
1521 };
1522
1523 convert$1.rgb.hcg = function (rgb) {
1524   var r = rgb[0] / 255;
1525   var g = rgb[1] / 255;
1526   var b = rgb[2] / 255;
1527   var max = Math.max(Math.max(r, g), b);
1528   var min = Math.min(Math.min(r, g), b);
1529   var chroma = max - min;
1530   var grayscale;
1531   var hue;
1532
1533   if (chroma < 1) {
1534     grayscale = min / (1 - chroma);
1535   } else {
1536     grayscale = 0;
1537   }
1538
1539   if (chroma <= 0) {
1540     hue = 0;
1541   } else if (max === r) {
1542     hue = (g - b) / chroma % 6;
1543   } else if (max === g) {
1544     hue = 2 + (b - r) / chroma;
1545   } else {
1546     hue = 4 + (r - g) / chroma + 4;
1547   }
1548
1549   hue /= 6;
1550   hue %= 1;
1551   return [hue * 360, chroma * 100, grayscale * 100];
1552 };
1553
1554 convert$1.hsl.hcg = function (hsl) {
1555   var s = hsl[1] / 100;
1556   var l = hsl[2] / 100;
1557   var c = 1;
1558   var f = 0;
1559
1560   if (l < 0.5) {
1561     c = 2.0 * s * l;
1562   } else {
1563     c = 2.0 * s * (1.0 - l);
1564   }
1565
1566   if (c < 1.0) {
1567     f = (l - 0.5 * c) / (1.0 - c);
1568   }
1569
1570   return [hsl[0], c * 100, f * 100];
1571 };
1572
1573 convert$1.hsv.hcg = function (hsv) {
1574   var s = hsv[1] / 100;
1575   var v = hsv[2] / 100;
1576   var c = s * v;
1577   var f = 0;
1578
1579   if (c < 1.0) {
1580     f = (v - c) / (1 - c);
1581   }
1582
1583   return [hsv[0], c * 100, f * 100];
1584 };
1585
1586 convert$1.hcg.rgb = function (hcg) {
1587   var h = hcg[0] / 360;
1588   var c = hcg[1] / 100;
1589   var g = hcg[2] / 100;
1590
1591   if (c === 0.0) {
1592     return [g * 255, g * 255, g * 255];
1593   }
1594
1595   var pure = [0, 0, 0];
1596   var hi = h % 1 * 6;
1597   var v = hi % 1;
1598   var w = 1 - v;
1599   var mg = 0;
1600
1601   switch (Math.floor(hi)) {
1602     case 0:
1603       pure[0] = 1;
1604       pure[1] = v;
1605       pure[2] = 0;
1606       break;
1607
1608     case 1:
1609       pure[0] = w;
1610       pure[1] = 1;
1611       pure[2] = 0;
1612       break;
1613
1614     case 2:
1615       pure[0] = 0;
1616       pure[1] = 1;
1617       pure[2] = v;
1618       break;
1619
1620     case 3:
1621       pure[0] = 0;
1622       pure[1] = w;
1623       pure[2] = 1;
1624       break;
1625
1626     case 4:
1627       pure[0] = v;
1628       pure[1] = 0;
1629       pure[2] = 1;
1630       break;
1631
1632     default:
1633       pure[0] = 1;
1634       pure[1] = 0;
1635       pure[2] = w;
1636   }
1637
1638   mg = (1.0 - c) * g;
1639   return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
1640 };
1641
1642 convert$1.hcg.hsv = function (hcg) {
1643   var c = hcg[1] / 100;
1644   var g = hcg[2] / 100;
1645   var v = c + g * (1.0 - c);
1646   var f = 0;
1647
1648   if (v > 0.0) {
1649     f = c / v;
1650   }
1651
1652   return [hcg[0], f * 100, v * 100];
1653 };
1654
1655 convert$1.hcg.hsl = function (hcg) {
1656   var c = hcg[1] / 100;
1657   var g = hcg[2] / 100;
1658   var l = g * (1.0 - c) + 0.5 * c;
1659   var s = 0;
1660
1661   if (l > 0.0 && l < 0.5) {
1662     s = c / (2 * l);
1663   } else if (l >= 0.5 && l < 1.0) {
1664     s = c / (2 * (1 - l));
1665   }
1666
1667   return [hcg[0], s * 100, l * 100];
1668 };
1669
1670 convert$1.hcg.hwb = function (hcg) {
1671   var c = hcg[1] / 100;
1672   var g = hcg[2] / 100;
1673   var v = c + g * (1.0 - c);
1674   return [hcg[0], (v - c) * 100, (1 - v) * 100];
1675 };
1676
1677 convert$1.hwb.hcg = function (hwb) {
1678   var w = hwb[1] / 100;
1679   var b = hwb[2] / 100;
1680   var v = 1 - b;
1681   var c = v - w;
1682   var g = 0;
1683
1684   if (c < 1) {
1685     g = (v - c) / (1 - c);
1686   }
1687
1688   return [hwb[0], c * 100, g * 100];
1689 };
1690
1691 convert$1.apple.rgb = function (apple) {
1692   return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
1693 };
1694
1695 convert$1.rgb.apple = function (rgb) {
1696   return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
1697 };
1698
1699 convert$1.gray.rgb = function (args) {
1700   return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
1701 };
1702
1703 convert$1.gray.hsl = convert$1.gray.hsv = function (args) {
1704   return [0, 0, args[0]];
1705 };
1706
1707 convert$1.gray.hwb = function (gray) {
1708   return [0, 100, gray[0]];
1709 };
1710
1711 convert$1.gray.cmyk = function (gray) {
1712   return [0, 0, 0, gray[0]];
1713 };
1714
1715 convert$1.gray.lab = function (gray) {
1716   return [gray[0], 0, 0];
1717 };
1718
1719 convert$1.gray.hex = function (gray) {
1720   var val = Math.round(gray[0] / 100 * 255) & 0xFF;
1721   var integer = (val << 16) + (val << 8) + val;
1722   var string = integer.toString(16).toUpperCase();
1723   return '000000'.substring(string.length) + string;
1724 };
1725
1726 convert$1.rgb.gray = function (rgb) {
1727   var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1728   return [val / 255 * 100];
1729 };
1730
1731 var conversions$1 = conversions$2.exports;
1732 /*
1733         this function routes a model to all other models.
1734
1735         all functions that are routed have a property `.conversion` attached
1736         to the returned synthetic function. This property is an array
1737         of strings, each with the steps in between the 'from' and 'to'
1738         color models (inclusive).
1739
1740         conversions that are not possible simply are not included.
1741 */
1742
1743 function buildGraph() {
1744   var graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3
1745
1746   var models = Object.keys(conversions$1);
1747
1748   for (var len = models.length, i = 0; i < len; i++) {
1749     graph[models[i]] = {
1750       // http://jsperf.com/1-vs-infinity
1751       // micro-opt, but this is simple.
1752       distance: -1,
1753       parent: null
1754     };
1755   }
1756
1757   return graph;
1758 } // https://en.wikipedia.org/wiki/Breadth-first_search
1759
1760
1761 function deriveBFS(fromModel) {
1762   var graph = buildGraph();
1763   var queue = [fromModel]; // unshift -> queue -> pop
1764
1765   graph[fromModel].distance = 0;
1766
1767   while (queue.length) {
1768     var current = queue.pop();
1769     var adjacents = Object.keys(conversions$1[current]);
1770
1771     for (var len = adjacents.length, i = 0; i < len; i++) {
1772       var adjacent = adjacents[i];
1773       var node = graph[adjacent];
1774
1775       if (node.distance === -1) {
1776         node.distance = graph[current].distance + 1;
1777         node.parent = current;
1778         queue.unshift(adjacent);
1779       }
1780     }
1781   }
1782
1783   return graph;
1784 }
1785
1786 function link(from, to) {
1787   return function (args) {
1788     return to(from(args));
1789   };
1790 }
1791
1792 function wrapConversion(toModel, graph) {
1793   var path = [graph[toModel].parent, toModel];
1794   var fn = conversions$1[graph[toModel].parent][toModel];
1795   var cur = graph[toModel].parent;
1796
1797   while (graph[cur].parent) {
1798     path.unshift(graph[cur].parent);
1799     fn = link(conversions$1[graph[cur].parent][cur], fn);
1800     cur = graph[cur].parent;
1801   }
1802
1803   fn.conversion = path;
1804   return fn;
1805 }
1806
1807 var route$1 = function (fromModel) {
1808   var graph = deriveBFS(fromModel);
1809   var conversion = {};
1810   var models = Object.keys(graph);
1811
1812   for (var len = models.length, i = 0; i < len; i++) {
1813     var toModel = models[i];
1814     var node = graph[toModel];
1815
1816     if (node.parent === null) {
1817       // no possible conversion, or this node is the source model.
1818       continue;
1819     }
1820
1821     conversion[toModel] = wrapConversion(toModel, graph);
1822   }
1823
1824   return conversion;
1825 };
1826
1827 var conversions = conversions$2.exports;
1828 var route = route$1;
1829 var convert = {};
1830 var models = Object.keys(conversions);
1831
1832 function wrapRaw(fn) {
1833   var wrappedFn = function (args) {
1834     if (args === undefined || args === null) {
1835       return args;
1836     }
1837
1838     if (arguments.length > 1) {
1839       args = Array.prototype.slice.call(arguments);
1840     }
1841
1842     return fn(args);
1843   }; // preserve .conversion property if there is one
1844
1845
1846   if ('conversion' in fn) {
1847     wrappedFn.conversion = fn.conversion;
1848   }
1849
1850   return wrappedFn;
1851 }
1852
1853 function wrapRounded(fn) {
1854   var wrappedFn = function (args) {
1855     if (args === undefined || args === null) {
1856       return args;
1857     }
1858
1859     if (arguments.length > 1) {
1860       args = Array.prototype.slice.call(arguments);
1861     }
1862
1863     var result = fn(args); // we're assuming the result is an array here.
1864     // see notice in conversions.js; don't use box types
1865     // in conversion functions.
1866
1867     if (typeof result === 'object') {
1868       for (var len = result.length, i = 0; i < len; i++) {
1869         result[i] = Math.round(result[i]);
1870       }
1871     }
1872
1873     return result;
1874   }; // preserve .conversion property if there is one
1875
1876
1877   if ('conversion' in fn) {
1878     wrappedFn.conversion = fn.conversion;
1879   }
1880
1881   return wrappedFn;
1882 }
1883
1884 models.forEach(function (fromModel) {
1885   convert[fromModel] = {};
1886   Object.defineProperty(convert[fromModel], 'channels', {
1887     value: conversions[fromModel].channels
1888   });
1889   Object.defineProperty(convert[fromModel], 'labels', {
1890     value: conversions[fromModel].labels
1891   });
1892   var routes = route(fromModel);
1893   var routeModels = Object.keys(routes);
1894   routeModels.forEach(function (toModel) {
1895     var fn = routes[toModel];
1896     convert[fromModel][toModel] = wrapRounded(fn);
1897     convert[fromModel][toModel].raw = wrapRaw(fn);
1898   });
1899 });
1900 var colorConvert = convert;
1901
1902 (function (module) {
1903
1904   const colorConvert$1 = colorConvert;
1905
1906   const wrapAnsi16 = (fn, offset) => function () {
1907     const code = fn.apply(colorConvert$1, arguments);
1908     return `\u001B[${code + offset}m`;
1909   };
1910
1911   const wrapAnsi256 = (fn, offset) => function () {
1912     const code = fn.apply(colorConvert$1, arguments);
1913     return `\u001B[${38 + offset};5;${code}m`;
1914   };
1915
1916   const wrapAnsi16m = (fn, offset) => function () {
1917     const rgb = fn.apply(colorConvert$1, arguments);
1918     return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
1919   };
1920
1921   function assembleStyles() {
1922     const codes = new Map();
1923     const styles = {
1924       modifier: {
1925         reset: [0, 0],
1926         // 21 isn't widely supported and 22 does the same thing
1927         bold: [1, 22],
1928         dim: [2, 22],
1929         italic: [3, 23],
1930         underline: [4, 24],
1931         inverse: [7, 27],
1932         hidden: [8, 28],
1933         strikethrough: [9, 29]
1934       },
1935       color: {
1936         black: [30, 39],
1937         red: [31, 39],
1938         green: [32, 39],
1939         yellow: [33, 39],
1940         blue: [34, 39],
1941         magenta: [35, 39],
1942         cyan: [36, 39],
1943         white: [37, 39],
1944         gray: [90, 39],
1945         // Bright color
1946         redBright: [91, 39],
1947         greenBright: [92, 39],
1948         yellowBright: [93, 39],
1949         blueBright: [94, 39],
1950         magentaBright: [95, 39],
1951         cyanBright: [96, 39],
1952         whiteBright: [97, 39]
1953       },
1954       bgColor: {
1955         bgBlack: [40, 49],
1956         bgRed: [41, 49],
1957         bgGreen: [42, 49],
1958         bgYellow: [43, 49],
1959         bgBlue: [44, 49],
1960         bgMagenta: [45, 49],
1961         bgCyan: [46, 49],
1962         bgWhite: [47, 49],
1963         // Bright color
1964         bgBlackBright: [100, 49],
1965         bgRedBright: [101, 49],
1966         bgGreenBright: [102, 49],
1967         bgYellowBright: [103, 49],
1968         bgBlueBright: [104, 49],
1969         bgMagentaBright: [105, 49],
1970         bgCyanBright: [106, 49],
1971         bgWhiteBright: [107, 49]
1972       }
1973     }; // Fix humans
1974
1975     styles.color.grey = styles.color.gray;
1976
1977     for (const groupName of Object.keys(styles)) {
1978       const group = styles[groupName];
1979
1980       for (const styleName of Object.keys(group)) {
1981         const style = group[styleName];
1982         styles[styleName] = {
1983           open: `\u001B[${style[0]}m`,
1984           close: `\u001B[${style[1]}m`
1985         };
1986         group[styleName] = styles[styleName];
1987         codes.set(style[0], style[1]);
1988       }
1989
1990       Object.defineProperty(styles, groupName, {
1991         value: group,
1992         enumerable: false
1993       });
1994       Object.defineProperty(styles, 'codes', {
1995         value: codes,
1996         enumerable: false
1997       });
1998     }
1999
2000     const ansi2ansi = n => n;
2001
2002     const rgb2rgb = (r, g, b) => [r, g, b];
2003
2004     styles.color.close = '\u001B[39m';
2005     styles.bgColor.close = '\u001B[49m';
2006     styles.color.ansi = {
2007       ansi: wrapAnsi16(ansi2ansi, 0)
2008     };
2009     styles.color.ansi256 = {
2010       ansi256: wrapAnsi256(ansi2ansi, 0)
2011     };
2012     styles.color.ansi16m = {
2013       rgb: wrapAnsi16m(rgb2rgb, 0)
2014     };
2015     styles.bgColor.ansi = {
2016       ansi: wrapAnsi16(ansi2ansi, 10)
2017     };
2018     styles.bgColor.ansi256 = {
2019       ansi256: wrapAnsi256(ansi2ansi, 10)
2020     };
2021     styles.bgColor.ansi16m = {
2022       rgb: wrapAnsi16m(rgb2rgb, 10)
2023     };
2024
2025     for (let key of Object.keys(colorConvert$1)) {
2026       if (typeof colorConvert$1[key] !== 'object') {
2027         continue;
2028       }
2029
2030       const suite = colorConvert$1[key];
2031
2032       if (key === 'ansi16') {
2033         key = 'ansi';
2034       }
2035
2036       if ('ansi16' in suite) {
2037         styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
2038         styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
2039       }
2040
2041       if ('ansi256' in suite) {
2042         styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
2043         styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
2044       }
2045
2046       if ('rgb' in suite) {
2047         styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
2048         styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
2049       }
2050     }
2051
2052     return styles;
2053   } // Make the export immutable
2054
2055
2056   Object.defineProperty(module, 'exports', {
2057     enumerable: true,
2058     get: assembleStyles
2059   });
2060 })(ansiStyles);
2061
2062 var hasFlag$1 = (flag, argv) => {
2063   argv = argv || process.argv;
2064   const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
2065   const pos = argv.indexOf(prefix + flag);
2066   const terminatorPos = argv.indexOf('--');
2067   return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
2068 };
2069
2070 const os = require$$0__default$2["default"];
2071 const hasFlag = hasFlag$1;
2072 const env = process.env;
2073 let forceColor;
2074
2075 if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
2076   forceColor = false;
2077 } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
2078   forceColor = true;
2079 }
2080
2081 if ('FORCE_COLOR' in env) {
2082   forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
2083 }
2084
2085 function translateLevel(level) {
2086   if (level === 0) {
2087     return false;
2088   }
2089
2090   return {
2091     level,
2092     hasBasic: true,
2093     has256: level >= 2,
2094     has16m: level >= 3
2095   };
2096 }
2097
2098 function supportsColor(stream) {
2099   if (forceColor === false) {
2100     return 0;
2101   }
2102
2103   if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
2104     return 3;
2105   }
2106
2107   if (hasFlag('color=256')) {
2108     return 2;
2109   }
2110
2111   if (stream && !stream.isTTY && forceColor !== true) {
2112     return 0;
2113   }
2114
2115   const min = forceColor ? 1 : 0;
2116
2117   if (process.platform === 'win32') {
2118     // Node.js 7.5.0 is the first version of Node.js to include a patch to
2119     // libuv that enables 256 color output on Windows. Anything earlier and it
2120     // won't work. However, here we target Node.js 8 at minimum as it is an LTS
2121     // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
2122     // release that supports 256 colors. Windows 10 build 14931 is the first release
2123     // that supports 16m/TrueColor.
2124     const osRelease = os.release().split('.');
2125
2126     if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
2127       return Number(osRelease[2]) >= 14931 ? 3 : 2;
2128     }
2129
2130     return 1;
2131   }
2132
2133   if ('CI' in env) {
2134     if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
2135       return 1;
2136     }
2137
2138     return min;
2139   }
2140
2141   if ('TEAMCITY_VERSION' in env) {
2142     return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
2143   }
2144
2145   if (env.COLORTERM === 'truecolor') {
2146     return 3;
2147   }
2148
2149   if ('TERM_PROGRAM' in env) {
2150     const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
2151
2152     switch (env.TERM_PROGRAM) {
2153       case 'iTerm.app':
2154         return version >= 3 ? 3 : 2;
2155
2156       case 'Apple_Terminal':
2157         return 2;
2158       // No default
2159     }
2160   }
2161
2162   if (/-256(color)?$/i.test(env.TERM)) {
2163     return 2;
2164   }
2165
2166   if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
2167     return 1;
2168   }
2169
2170   if ('COLORTERM' in env) {
2171     return 1;
2172   }
2173
2174   if (env.TERM === 'dumb') {
2175     return min;
2176   }
2177
2178   return min;
2179 }
2180
2181 function getSupportLevel(stream) {
2182   const level = supportsColor(stream);
2183   return translateLevel(level);
2184 }
2185
2186 var supportsColor_1 = {
2187   supportsColor: getSupportLevel,
2188   stdout: getSupportLevel(process.stdout),
2189   stderr: getSupportLevel(process.stderr)
2190 };
2191
2192 const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
2193 const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
2194 const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
2195 const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
2196 const ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
2197
2198 function unescape(c) {
2199   if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
2200     return String.fromCharCode(parseInt(c.slice(1), 16));
2201   }
2202
2203   return ESCAPES.get(c) || c;
2204 }
2205
2206 function parseArguments(name, args) {
2207   const results = [];
2208   const chunks = args.trim().split(/\s*,\s*/g);
2209   let matches;
2210
2211   for (const chunk of chunks) {
2212     if (!isNaN(chunk)) {
2213       results.push(Number(chunk));
2214     } else if (matches = chunk.match(STRING_REGEX)) {
2215       results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
2216     } else {
2217       throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
2218     }
2219   }
2220
2221   return results;
2222 }
2223
2224 function parseStyle(style) {
2225   STYLE_REGEX.lastIndex = 0;
2226   const results = [];
2227   let matches;
2228
2229   while ((matches = STYLE_REGEX.exec(style)) !== null) {
2230     const name = matches[1];
2231
2232     if (matches[2]) {
2233       const args = parseArguments(name, matches[2]);
2234       results.push([name].concat(args));
2235     } else {
2236       results.push([name]);
2237     }
2238   }
2239
2240   return results;
2241 }
2242
2243 function buildStyle(chalk, styles) {
2244   const enabled = {};
2245
2246   for (const layer of styles) {
2247     for (const style of layer.styles) {
2248       enabled[style[0]] = layer.inverse ? null : style.slice(1);
2249     }
2250   }
2251
2252   let current = chalk;
2253
2254   for (const styleName of Object.keys(enabled)) {
2255     if (Array.isArray(enabled[styleName])) {
2256       if (!(styleName in current)) {
2257         throw new Error(`Unknown Chalk style: ${styleName}`);
2258       }
2259
2260       if (enabled[styleName].length > 0) {
2261         current = current[styleName].apply(current, enabled[styleName]);
2262       } else {
2263         current = current[styleName];
2264       }
2265     }
2266   }
2267
2268   return current;
2269 }
2270
2271 var templates = (chalk, tmp) => {
2272   const styles = [];
2273   const chunks = [];
2274   let chunk = []; // eslint-disable-next-line max-params
2275
2276   tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
2277     if (escapeChar) {
2278       chunk.push(unescape(escapeChar));
2279     } else if (style) {
2280       const str = chunk.join('');
2281       chunk = [];
2282       chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
2283       styles.push({
2284         inverse,
2285         styles: parseStyle(style)
2286       });
2287     } else if (close) {
2288       if (styles.length === 0) {
2289         throw new Error('Found extraneous } in Chalk template literal');
2290       }
2291
2292       chunks.push(buildStyle(chalk, styles)(chunk.join('')));
2293       chunk = [];
2294       styles.pop();
2295     } else {
2296       chunk.push(chr);
2297     }
2298   });
2299   chunks.push(chunk.join(''));
2300
2301   if (styles.length > 0) {
2302     const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
2303     throw new Error(errMsg);
2304   }
2305
2306   return chunks.join('');
2307 };
2308
2309 (function (module) {
2310
2311   const escapeStringRegexp$1 = escapeStringRegexp;
2312   const ansiStyles$1 = ansiStyles.exports;
2313   const stdoutColor = supportsColor_1.stdout;
2314   const template = templates;
2315   const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` â†’ `ansiStyles.color[name]` mapping
2316
2317   const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
2318
2319   const skipModels = new Set(['gray']);
2320   const styles = Object.create(null);
2321
2322   function applyOptions(obj, options) {
2323     options = options || {}; // Detect level if not set manually
2324
2325     const scLevel = stdoutColor ? stdoutColor.level : 0;
2326     obj.level = options.level === undefined ? scLevel : options.level;
2327     obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
2328   }
2329
2330   function Chalk(options) {
2331     // We check for this.template here since calling `chalk.constructor()`
2332     // by itself will have a `this` of a previously constructed chalk object
2333     if (!this || !(this instanceof Chalk) || this.template) {
2334       const chalk = {};
2335       applyOptions(chalk, options);
2336
2337       chalk.template = function () {
2338         const args = [].slice.call(arguments);
2339         return chalkTag.apply(null, [chalk.template].concat(args));
2340       };
2341
2342       Object.setPrototypeOf(chalk, Chalk.prototype);
2343       Object.setPrototypeOf(chalk.template, chalk);
2344       chalk.template.constructor = Chalk;
2345       return chalk.template;
2346     }
2347
2348     applyOptions(this, options);
2349   } // Use bright blue on Windows as the normal blue color is illegible
2350
2351
2352   if (isSimpleWindowsTerm) {
2353     ansiStyles$1.blue.open = '\u001B[94m';
2354   }
2355
2356   for (const key of Object.keys(ansiStyles$1)) {
2357     ansiStyles$1[key].closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$1[key].close), 'g');
2358     styles[key] = {
2359       get() {
2360         const codes = ansiStyles$1[key];
2361         return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
2362       }
2363
2364     };
2365   }
2366
2367   styles.visible = {
2368     get() {
2369       return build.call(this, this._styles || [], true, 'visible');
2370     }
2371
2372   };
2373   ansiStyles$1.color.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$1.color.close), 'g');
2374
2375   for (const model of Object.keys(ansiStyles$1.color.ansi)) {
2376     if (skipModels.has(model)) {
2377       continue;
2378     }
2379
2380     styles[model] = {
2381       get() {
2382         const level = this.level;
2383         return function () {
2384           const open = ansiStyles$1.color[levelMapping[level]][model].apply(null, arguments);
2385           const codes = {
2386             open,
2387             close: ansiStyles$1.color.close,
2388             closeRe: ansiStyles$1.color.closeRe
2389           };
2390           return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
2391         };
2392       }
2393
2394     };
2395   }
2396
2397   ansiStyles$1.bgColor.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$1.bgColor.close), 'g');
2398
2399   for (const model of Object.keys(ansiStyles$1.bgColor.ansi)) {
2400     if (skipModels.has(model)) {
2401       continue;
2402     }
2403
2404     const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
2405     styles[bgModel] = {
2406       get() {
2407         const level = this.level;
2408         return function () {
2409           const open = ansiStyles$1.bgColor[levelMapping[level]][model].apply(null, arguments);
2410           const codes = {
2411             open,
2412             close: ansiStyles$1.bgColor.close,
2413             closeRe: ansiStyles$1.bgColor.closeRe
2414           };
2415           return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
2416         };
2417       }
2418
2419     };
2420   }
2421
2422   const proto = Object.defineProperties(() => {}, styles);
2423
2424   function build(_styles, _empty, key) {
2425     const builder = function () {
2426       return applyStyle.apply(builder, arguments);
2427     };
2428
2429     builder._styles = _styles;
2430     builder._empty = _empty;
2431     const self = this;
2432     Object.defineProperty(builder, 'level', {
2433       enumerable: true,
2434
2435       get() {
2436         return self.level;
2437       },
2438
2439       set(level) {
2440         self.level = level;
2441       }
2442
2443     });
2444     Object.defineProperty(builder, 'enabled', {
2445       enumerable: true,
2446
2447       get() {
2448         return self.enabled;
2449       },
2450
2451       set(enabled) {
2452         self.enabled = enabled;
2453       }
2454
2455     }); // See below for fix regarding invisible grey/dim combination on Windows
2456
2457     builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
2458     // no way to create a function with a different prototype
2459
2460     builder.__proto__ = proto; // eslint-disable-line no-proto
2461
2462     return builder;
2463   }
2464
2465   function applyStyle() {
2466     // Support varags, but simply cast to string in case there's only one arg
2467     const args = arguments;
2468     const argsLen = args.length;
2469     let str = String(arguments[0]);
2470
2471     if (argsLen === 0) {
2472       return '';
2473     }
2474
2475     if (argsLen > 1) {
2476       // Don't slice `arguments`, it prevents V8 optimizations
2477       for (let a = 1; a < argsLen; a++) {
2478         str += ' ' + args[a];
2479       }
2480     }
2481
2482     if (!this.enabled || this.level <= 0 || !str) {
2483       return this._empty ? '' : str;
2484     } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
2485     // see https://github.com/chalk/chalk/issues/58
2486     // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
2487
2488
2489     const originalDim = ansiStyles$1.dim.open;
2490
2491     if (isSimpleWindowsTerm && this.hasGrey) {
2492       ansiStyles$1.dim.open = '';
2493     }
2494
2495     for (const code of this._styles.slice().reverse()) {
2496       // Replace any instances already present with a re-opening code
2497       // otherwise only the part of the string until said closing code
2498       // will be colored, and the rest will simply be 'plain'.
2499       str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
2500       // after next line to fix a bleed issue on macOS
2501       // https://github.com/chalk/chalk/pull/92
2502
2503       str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
2504     } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
2505
2506
2507     ansiStyles$1.dim.open = originalDim;
2508     return str;
2509   }
2510
2511   function chalkTag(chalk, strings) {
2512     if (!Array.isArray(strings)) {
2513       // If chalk() was called by itself or with a string,
2514       // return the string itself as a string.
2515       return [].slice.call(arguments, 1).join(' ');
2516     }
2517
2518     const args = [].slice.call(arguments, 2);
2519     const parts = [strings.raw[0]];
2520
2521     for (let i = 1; i < strings.length; i++) {
2522       parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
2523       parts.push(String(strings.raw[i]));
2524     }
2525
2526     return template(chalk, parts.join(''));
2527   }
2528
2529   Object.defineProperties(Chalk.prototype, styles);
2530   module.exports = Chalk(); // eslint-disable-line new-cap
2531
2532   module.exports.supportsColor = stdoutColor;
2533   module.exports.default = module.exports; // For TypeScript
2534 })(chalk);
2535
2536 Object.defineProperty(lib$1, "__esModule", {
2537   value: true
2538 });
2539
2540 lib$1.default = highlight;
2541
2542 lib$1.getChalk = getChalk;
2543 lib$1.shouldHighlight = shouldHighlight;
2544 var _jsTokens = jsTokens;
2545 var _helperValidatorIdentifier = lib;
2546 var _chalk = chalk.exports;
2547 const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
2548
2549 function getDefs$1(chalk) {
2550   return {
2551     keyword: chalk.cyan,
2552     capitalized: chalk.yellow,
2553     jsxIdentifier: chalk.yellow,
2554     punctuator: chalk.yellow,
2555     number: chalk.magenta,
2556     string: chalk.green,
2557     regex: chalk.magenta,
2558     comment: chalk.grey,
2559     invalid: chalk.white.bgRed.bold
2560   };
2561 }
2562
2563 const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
2564 const BRACKET = /^[()[\]{}]$/;
2565 let tokenize;
2566 {
2567   const JSX_TAG = /^[a-z][\w-]*$/i;
2568
2569   const getTokenType = function (token, offset, text) {
2570     if (token.type === "name") {
2571       if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) {
2572         return "keyword";
2573       }
2574
2575       if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
2576         return "jsxIdentifier";
2577       }
2578
2579       if (token.value[0] !== token.value[0].toLowerCase()) {
2580         return "capitalized";
2581       }
2582     }
2583
2584     if (token.type === "punctuator" && BRACKET.test(token.value)) {
2585       return "bracket";
2586     }
2587
2588     if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
2589       return "punctuator";
2590     }
2591
2592     return token.type;
2593   };
2594
2595   tokenize = function* (text) {
2596     let match;
2597
2598     while (match = _jsTokens.default.exec(text)) {
2599       const token = _jsTokens.matchToToken(match);
2600
2601       yield {
2602         type: getTokenType(token, match.index, text),
2603         value: token.value
2604       };
2605     }
2606   };
2607 }
2608
2609 function highlightTokens(defs, text) {
2610   let highlighted = "";
2611
2612   for (const {
2613     type,
2614     value
2615   } of tokenize(text)) {
2616     const colorize = defs[type];
2617
2618     if (colorize) {
2619       highlighted += value.split(NEWLINE$1).map(str => colorize(str)).join("\n");
2620     } else {
2621       highlighted += value;
2622     }
2623   }
2624
2625   return highlighted;
2626 }
2627
2628 function shouldHighlight(options) {
2629   return !!_chalk.supportsColor || options.forceColor;
2630 }
2631
2632 function getChalk(options) {
2633   return options.forceColor ? new _chalk.constructor({
2634     enabled: true,
2635     level: 1
2636   }) : _chalk;
2637 }
2638
2639 function highlight(code, options = {}) {
2640   if (shouldHighlight(options)) {
2641     const chalk = getChalk(options);
2642     const defs = getDefs$1(chalk);
2643     return highlightTokens(defs, code);
2644   } else {
2645     return code;
2646   }
2647 }
2648
2649 Object.defineProperty(lib$2, "__esModule", {
2650   value: true
2651 });
2652 lib$2.codeFrameColumns = codeFrameColumns$1;
2653 lib$2.default = _default;
2654 var _highlight = lib$1;
2655 let deprecationWarningShown = false;
2656
2657 function getDefs(chalk) {
2658   return {
2659     gutter: chalk.grey,
2660     marker: chalk.red.bold,
2661     message: chalk.red.bold
2662   };
2663 }
2664
2665 const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
2666
2667 function getMarkerLines(loc, source, opts) {
2668   const startLoc = Object.assign({
2669     column: 0,
2670     line: -1
2671   }, loc.start);
2672   const endLoc = Object.assign({}, startLoc, loc.end);
2673   const {
2674     linesAbove = 2,
2675     linesBelow = 3
2676   } = opts || {};
2677   const startLine = startLoc.line;
2678   const startColumn = startLoc.column;
2679   const endLine = endLoc.line;
2680   const endColumn = endLoc.column;
2681   let start = Math.max(startLine - (linesAbove + 1), 0);
2682   let end = Math.min(source.length, endLine + linesBelow);
2683
2684   if (startLine === -1) {
2685     start = 0;
2686   }
2687
2688   if (endLine === -1) {
2689     end = source.length;
2690   }
2691
2692   const lineDiff = endLine - startLine;
2693   const markerLines = {};
2694
2695   if (lineDiff) {
2696     for (let i = 0; i <= lineDiff; i++) {
2697       const lineNumber = i + startLine;
2698
2699       if (!startColumn) {
2700         markerLines[lineNumber] = true;
2701       } else if (i === 0) {
2702         const sourceLength = source[lineNumber - 1].length;
2703         markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
2704       } else if (i === lineDiff) {
2705         markerLines[lineNumber] = [0, endColumn];
2706       } else {
2707         const sourceLength = source[lineNumber - i].length;
2708         markerLines[lineNumber] = [0, sourceLength];
2709       }
2710     }
2711   } else {
2712     if (startColumn === endColumn) {
2713       if (startColumn) {
2714         markerLines[startLine] = [startColumn, 0];
2715       } else {
2716         markerLines[startLine] = true;
2717       }
2718     } else {
2719       markerLines[startLine] = [startColumn, endColumn - startColumn];
2720     }
2721   }
2722
2723   return {
2724     start,
2725     end,
2726     markerLines
2727   };
2728 }
2729
2730 function codeFrameColumns$1(rawLines, loc, opts = {}) {
2731   const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts);
2732   const chalk = (0, _highlight.getChalk)(opts);
2733   const defs = getDefs(chalk);
2734
2735   const maybeHighlight = (chalkFn, string) => {
2736     return highlighted ? chalkFn(string) : string;
2737   };
2738
2739   const lines = rawLines.split(NEWLINE);
2740   const {
2741     start,
2742     end,
2743     markerLines
2744   } = getMarkerLines(loc, lines, opts);
2745   const hasColumns = loc.start && typeof loc.start.column === "number";
2746   const numberMaxWidth = String(end).length;
2747   const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines;
2748   let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
2749     const number = start + 1 + index;
2750     const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
2751     const gutter = ` ${paddedNumber} |`;
2752     const hasMarker = markerLines[number];
2753     const lastMarkerLine = !markerLines[number + 1];
2754
2755     if (hasMarker) {
2756       let markerLine = "";
2757
2758       if (Array.isArray(hasMarker)) {
2759         const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
2760         const numberOfMarkers = hasMarker[1] || 1;
2761         markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), " ", markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
2762
2763         if (lastMarkerLine && opts.message) {
2764           markerLine += " " + maybeHighlight(defs.message, opts.message);
2765         }
2766       }
2767
2768       return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
2769     } else {
2770       return ` ${maybeHighlight(defs.gutter, gutter)}${line.length > 0 ? ` ${line}` : ""}`;
2771     }
2772   }).join("\n");
2773
2774   if (opts.message && !hasColumns) {
2775     frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
2776   }
2777
2778   if (highlighted) {
2779     return chalk.reset(frame);
2780   } else {
2781     return frame;
2782   }
2783 }
2784
2785 function _default(rawLines, lineNumber, colNumber, opts = {}) {
2786   if (!deprecationWarningShown) {
2787     deprecationWarningShown = true;
2788     const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
2789
2790     if (process.emitWarning) {
2791       process.emitWarning(message, "DeprecationWarning");
2792     } else {
2793       const deprecationError = new Error(message);
2794       deprecationError.name = "DeprecationWarning";
2795       console.warn(new Error(message));
2796     }
2797   }
2798
2799   colNumber = Math.max(colNumber, 0);
2800   const location = {
2801     start: {
2802       column: colNumber,
2803       line: lineNumber
2804     }
2805   };
2806   return codeFrameColumns$1(rawLines, location, opts);
2807 }
2808
2809 const errorEx = errorEx_1;
2810 const fallback = jsonParseEvenBetterErrors;
2811 const {
2812   default: LinesAndColumns
2813 } = dist$1;
2814 const {
2815   codeFrameColumns
2816 } = lib$2;
2817 const JSONError = errorEx('JSONError', {
2818   fileName: errorEx.append('in %s'),
2819   codeFrame: errorEx.append('\n\n%s\n')
2820 });
2821
2822 const parseJson$1 = (string, reviver, filename) => {
2823   if (typeof reviver === 'string') {
2824     filename = reviver;
2825     reviver = null;
2826   }
2827
2828   try {
2829     try {
2830       return JSON.parse(string, reviver);
2831     } catch (error) {
2832       fallback(string, reviver);
2833       throw error;
2834     }
2835   } catch (error) {
2836     error.message = error.message.replace(/\n/g, '');
2837     const indexMatch = error.message.match(/in JSON at position (\d+) while parsing/);
2838     const jsonError = new JSONError(error);
2839
2840     if (filename) {
2841       jsonError.fileName = filename;
2842     }
2843
2844     if (indexMatch && indexMatch.length > 0) {
2845       const lines = new LinesAndColumns(string);
2846       const index = Number(indexMatch[1]);
2847       const location = lines.locationForIndex(index);
2848       const codeFrame = codeFrameColumns(string, {
2849         start: {
2850           line: location.line + 1,
2851           column: location.column + 1
2852         }
2853       }, {
2854         highlightCode: true
2855       });
2856       jsonError.codeFrame = codeFrame;
2857     }
2858
2859     throw jsonError;
2860   }
2861 };
2862
2863 parseJson$1.JSONError = JSONError;
2864 var parseJson_1 = parseJson$1;
2865
2866 var dist = {};
2867
2868 var parseCst$1 = {};
2869
2870 var PlainValueEc8e588e = {};
2871
2872 const Char = {
2873   ANCHOR: '&',
2874   COMMENT: '#',
2875   TAG: '!',
2876   DIRECTIVES_END: '-',
2877   DOCUMENT_END: '.'
2878 };
2879 const Type = {
2880   ALIAS: 'ALIAS',
2881   BLANK_LINE: 'BLANK_LINE',
2882   BLOCK_FOLDED: 'BLOCK_FOLDED',
2883   BLOCK_LITERAL: 'BLOCK_LITERAL',
2884   COMMENT: 'COMMENT',
2885   DIRECTIVE: 'DIRECTIVE',
2886   DOCUMENT: 'DOCUMENT',
2887   FLOW_MAP: 'FLOW_MAP',
2888   FLOW_SEQ: 'FLOW_SEQ',
2889   MAP: 'MAP',
2890   MAP_KEY: 'MAP_KEY',
2891   MAP_VALUE: 'MAP_VALUE',
2892   PLAIN: 'PLAIN',
2893   QUOTE_DOUBLE: 'QUOTE_DOUBLE',
2894   QUOTE_SINGLE: 'QUOTE_SINGLE',
2895   SEQ: 'SEQ',
2896   SEQ_ITEM: 'SEQ_ITEM'
2897 };
2898 const defaultTagPrefix = 'tag:yaml.org,2002:';
2899 const defaultTags = {
2900   MAP: 'tag:yaml.org,2002:map',
2901   SEQ: 'tag:yaml.org,2002:seq',
2902   STR: 'tag:yaml.org,2002:str'
2903 };
2904
2905 function findLineStarts(src) {
2906   const ls = [0];
2907   let offset = src.indexOf('\n');
2908
2909   while (offset !== -1) {
2910     offset += 1;
2911     ls.push(offset);
2912     offset = src.indexOf('\n', offset);
2913   }
2914
2915   return ls;
2916 }
2917
2918 function getSrcInfo(cst) {
2919   let lineStarts, src;
2920
2921   if (typeof cst === 'string') {
2922     lineStarts = findLineStarts(cst);
2923     src = cst;
2924   } else {
2925     if (Array.isArray(cst)) cst = cst[0];
2926
2927     if (cst && cst.context) {
2928       if (!cst.lineStarts) cst.lineStarts = findLineStarts(cst.context.src);
2929       lineStarts = cst.lineStarts;
2930       src = cst.context.src;
2931     }
2932   }
2933
2934   return {
2935     lineStarts,
2936     src
2937   };
2938 }
2939 /**
2940  * @typedef {Object} LinePos - One-indexed position in the source
2941  * @property {number} line
2942  * @property {number} col
2943  */
2944
2945 /**
2946  * Determine the line/col position matching a character offset.
2947  *
2948  * Accepts a source string or a CST document as the second parameter. With
2949  * the latter, starting indices for lines are cached in the document as
2950  * `lineStarts: number[]`.
2951  *
2952  * Returns a one-indexed `{ line, col }` location if found, or
2953  * `undefined` otherwise.
2954  *
2955  * @param {number} offset
2956  * @param {string|Document|Document[]} cst
2957  * @returns {?LinePos}
2958  */
2959
2960
2961 function getLinePos(offset, cst) {
2962   if (typeof offset !== 'number' || offset < 0) return null;
2963   const {
2964     lineStarts,
2965     src
2966   } = getSrcInfo(cst);
2967   if (!lineStarts || !src || offset > src.length) return null;
2968
2969   for (let i = 0; i < lineStarts.length; ++i) {
2970     const start = lineStarts[i];
2971
2972     if (offset < start) {
2973       return {
2974         line: i,
2975         col: offset - lineStarts[i - 1] + 1
2976       };
2977     }
2978
2979     if (offset === start) return {
2980       line: i + 1,
2981       col: 1
2982     };
2983   }
2984
2985   const line = lineStarts.length;
2986   return {
2987     line,
2988     col: offset - lineStarts[line - 1] + 1
2989   };
2990 }
2991 /**
2992  * Get a specified line from the source.
2993  *
2994  * Accepts a source string or a CST document as the second parameter. With
2995  * the latter, starting indices for lines are cached in the document as
2996  * `lineStarts: number[]`.
2997  *
2998  * Returns the line as a string if found, or `null` otherwise.
2999  *
3000  * @param {number} line One-indexed line number
3001  * @param {string|Document|Document[]} cst
3002  * @returns {?string}
3003  */
3004
3005
3006 function getLine(line, cst) {
3007   const {
3008     lineStarts,
3009     src
3010   } = getSrcInfo(cst);
3011   if (!lineStarts || !(line >= 1) || line > lineStarts.length) return null;
3012   const start = lineStarts[line - 1];
3013   let end = lineStarts[line]; // undefined for last line; that's ok for slice()
3014
3015   while (end && end > start && src[end - 1] === '\n') --end;
3016
3017   return src.slice(start, end);
3018 }
3019 /**
3020  * Pretty-print the starting line from the source indicated by the range `pos`
3021  *
3022  * Trims output to `maxWidth` chars while keeping the starting column visible,
3023  * using `…` at either end to indicate dropped characters.
3024  *
3025  * Returns a two-line string (or `null`) with `\n` as separator; the second line
3026  * will hold appropriately indented `^` marks indicating the column range.
3027  *
3028  * @param {Object} pos
3029  * @param {LinePos} pos.start
3030  * @param {LinePos} [pos.end]
3031  * @param {string|Document|Document[]*} cst
3032  * @param {number} [maxWidth=80]
3033  * @returns {?string}
3034  */
3035
3036
3037 function getPrettyContext({
3038   start,
3039   end
3040 }, cst, maxWidth = 80) {
3041   let src = getLine(start.line, cst);
3042   if (!src) return null;
3043   let {
3044     col
3045   } = start;
3046
3047   if (src.length > maxWidth) {
3048     if (col <= maxWidth - 10) {
3049       src = src.substr(0, maxWidth - 1) + '…';
3050     } else {
3051       const halfWidth = Math.round(maxWidth / 2);
3052       if (src.length > col + halfWidth) src = src.substr(0, col + halfWidth - 1) + '…';
3053       col -= src.length - maxWidth;
3054       src = '…' + src.substr(1 - maxWidth);
3055     }
3056   }
3057
3058   let errLen = 1;
3059   let errEnd = '';
3060
3061   if (end) {
3062     if (end.line === start.line && col + (end.col - start.col) <= maxWidth + 1) {
3063       errLen = end.col - start.col;
3064     } else {
3065       errLen = Math.min(src.length + 1, maxWidth) - col;
3066       errEnd = '…';
3067     }
3068   }
3069
3070   const offset = col > 1 ? ' '.repeat(col - 1) : '';
3071   const err = '^'.repeat(errLen);
3072   return `${src}\n${offset}${err}${errEnd}`;
3073 }
3074
3075 class Range {
3076   static copy(orig) {
3077     return new Range(orig.start, orig.end);
3078   }
3079
3080   constructor(start, end) {
3081     this.start = start;
3082     this.end = end || start;
3083   }
3084
3085   isEmpty() {
3086     return typeof this.start !== 'number' || !this.end || this.end <= this.start;
3087   }
3088   /**
3089    * Set `origStart` and `origEnd` to point to the original source range for
3090    * this node, which may differ due to dropped CR characters.
3091    *
3092    * @param {number[]} cr - Positions of dropped CR characters
3093    * @param {number} offset - Starting index of `cr` from the last call
3094    * @returns {number} - The next offset, matching the one found for `origStart`
3095    */
3096
3097
3098   setOrigRange(cr, offset) {
3099     const {
3100       start,
3101       end
3102     } = this;
3103
3104     if (cr.length === 0 || end <= cr[0]) {
3105       this.origStart = start;
3106       this.origEnd = end;
3107       return offset;
3108     }
3109
3110     let i = offset;
3111
3112     while (i < cr.length) {
3113       if (cr[i] > start) break;else ++i;
3114     }
3115
3116     this.origStart = start + i;
3117     const nextOffset = i;
3118
3119     while (i < cr.length) {
3120       // if end was at \n, it should now be at \r
3121       if (cr[i] >= end) break;else ++i;
3122     }
3123
3124     this.origEnd = end + i;
3125     return nextOffset;
3126   }
3127
3128 }
3129 /** Root class of all nodes */
3130
3131
3132 class Node$1 {
3133   static addStringTerminator(src, offset, str) {
3134     if (str[str.length - 1] === '\n') return str;
3135     const next = Node$1.endOfWhiteSpace(src, offset);
3136     return next >= src.length || src[next] === '\n' ? str + '\n' : str;
3137   } // ^(---|...)
3138
3139
3140   static atDocumentBoundary(src, offset, sep) {
3141     const ch0 = src[offset];
3142     if (!ch0) return true;
3143     const prev = src[offset - 1];
3144     if (prev && prev !== '\n') return false;
3145
3146     if (sep) {
3147       if (ch0 !== sep) return false;
3148     } else {
3149       if (ch0 !== Char.DIRECTIVES_END && ch0 !== Char.DOCUMENT_END) return false;
3150     }
3151
3152     const ch1 = src[offset + 1];
3153     const ch2 = src[offset + 2];
3154     if (ch1 !== ch0 || ch2 !== ch0) return false;
3155     const ch3 = src[offset + 3];
3156     return !ch3 || ch3 === '\n' || ch3 === '\t' || ch3 === ' ';
3157   }
3158
3159   static endOfIdentifier(src, offset) {
3160     let ch = src[offset];
3161     const isVerbatim = ch === '<';
3162     const notOk = isVerbatim ? ['\n', '\t', ' ', '>'] : ['\n', '\t', ' ', '[', ']', '{', '}', ','];
3163
3164     while (ch && notOk.indexOf(ch) === -1) ch = src[offset += 1];
3165
3166     if (isVerbatim && ch === '>') offset += 1;
3167     return offset;
3168   }
3169
3170   static endOfIndent(src, offset) {
3171     let ch = src[offset];
3172
3173     while (ch === ' ') ch = src[offset += 1];
3174
3175     return offset;
3176   }
3177
3178   static endOfLine(src, offset) {
3179     let ch = src[offset];
3180
3181     while (ch && ch !== '\n') ch = src[offset += 1];
3182
3183     return offset;
3184   }
3185
3186   static endOfWhiteSpace(src, offset) {
3187     let ch = src[offset];
3188
3189     while (ch === '\t' || ch === ' ') ch = src[offset += 1];
3190
3191     return offset;
3192   }
3193
3194   static startOfLine(src, offset) {
3195     let ch = src[offset - 1];
3196     if (ch === '\n') return offset;
3197
3198     while (ch && ch !== '\n') ch = src[offset -= 1];
3199
3200     return offset + 1;
3201   }
3202   /**
3203    * End of indentation, or null if the line's indent level is not more
3204    * than `indent`
3205    *
3206    * @param {string} src
3207    * @param {number} indent
3208    * @param {number} lineStart
3209    * @returns {?number}
3210    */
3211
3212
3213   static endOfBlockIndent(src, indent, lineStart) {
3214     const inEnd = Node$1.endOfIndent(src, lineStart);
3215
3216     if (inEnd > lineStart + indent) {
3217       return inEnd;
3218     } else {
3219       const wsEnd = Node$1.endOfWhiteSpace(src, inEnd);
3220       const ch = src[wsEnd];
3221       if (!ch || ch === '\n') return wsEnd;
3222     }
3223
3224     return null;
3225   }
3226
3227   static atBlank(src, offset, endAsBlank) {
3228     const ch = src[offset];
3229     return ch === '\n' || ch === '\t' || ch === ' ' || endAsBlank && !ch;
3230   }
3231
3232   static nextNodeIsIndented(ch, indentDiff, indicatorAsIndent) {
3233     if (!ch || indentDiff < 0) return false;
3234     if (indentDiff > 0) return true;
3235     return indicatorAsIndent && ch === '-';
3236   } // should be at line or string end, or at next non-whitespace char
3237
3238
3239   static normalizeOffset(src, offset) {
3240     const ch = src[offset];
3241     return !ch ? offset : ch !== '\n' && src[offset - 1] === '\n' ? offset - 1 : Node$1.endOfWhiteSpace(src, offset);
3242   } // fold single newline into space, multiple newlines to N - 1 newlines
3243   // presumes src[offset] === '\n'
3244
3245
3246   static foldNewline(src, offset, indent) {
3247     let inCount = 0;
3248     let error = false;
3249     let fold = '';
3250     let ch = src[offset + 1];
3251
3252     while (ch === ' ' || ch === '\t' || ch === '\n') {
3253       switch (ch) {
3254         case '\n':
3255           inCount = 0;
3256           offset += 1;
3257           fold += '\n';
3258           break;
3259
3260         case '\t':
3261           if (inCount <= indent) error = true;
3262           offset = Node$1.endOfWhiteSpace(src, offset + 2) - 1;
3263           break;
3264
3265         case ' ':
3266           inCount += 1;
3267           offset += 1;
3268           break;
3269       }
3270
3271       ch = src[offset + 1];
3272     }
3273
3274     if (!fold) fold = ' ';
3275     if (ch && inCount <= indent) error = true;
3276     return {
3277       fold,
3278       offset,
3279       error
3280     };
3281   }
3282
3283   constructor(type, props, context) {
3284     Object.defineProperty(this, 'context', {
3285       value: context || null,
3286       writable: true
3287     });
3288     this.error = null;
3289     this.range = null;
3290     this.valueRange = null;
3291     this.props = props || [];
3292     this.type = type;
3293     this.value = null;
3294   }
3295
3296   getPropValue(idx, key, skipKey) {
3297     if (!this.context) return null;
3298     const {
3299       src
3300     } = this.context;
3301     const prop = this.props[idx];
3302     return prop && src[prop.start] === key ? src.slice(prop.start + (skipKey ? 1 : 0), prop.end) : null;
3303   }
3304
3305   get anchor() {
3306     for (let i = 0; i < this.props.length; ++i) {
3307       const anchor = this.getPropValue(i, Char.ANCHOR, true);
3308       if (anchor != null) return anchor;
3309     }
3310
3311     return null;
3312   }
3313
3314   get comment() {
3315     const comments = [];
3316
3317     for (let i = 0; i < this.props.length; ++i) {
3318       const comment = this.getPropValue(i, Char.COMMENT, true);
3319       if (comment != null) comments.push(comment);
3320     }
3321
3322     return comments.length > 0 ? comments.join('\n') : null;
3323   }
3324
3325   commentHasRequiredWhitespace(start) {
3326     const {
3327       src
3328     } = this.context;
3329     if (this.header && start === this.header.end) return false;
3330     if (!this.valueRange) return false;
3331     const {
3332       end
3333     } = this.valueRange;
3334     return start !== end || Node$1.atBlank(src, end - 1);
3335   }
3336
3337   get hasComment() {
3338     if (this.context) {
3339       const {
3340         src
3341       } = this.context;
3342
3343       for (let i = 0; i < this.props.length; ++i) {
3344         if (src[this.props[i].start] === Char.COMMENT) return true;
3345       }
3346     }
3347
3348     return false;
3349   }
3350
3351   get hasProps() {
3352     if (this.context) {
3353       const {
3354         src
3355       } = this.context;
3356
3357       for (let i = 0; i < this.props.length; ++i) {
3358         if (src[this.props[i].start] !== Char.COMMENT) return true;
3359       }
3360     }
3361
3362     return false;
3363   }
3364
3365   get includesTrailingLines() {
3366     return false;
3367   }
3368
3369   get jsonLike() {
3370     const jsonLikeTypes = [Type.FLOW_MAP, Type.FLOW_SEQ, Type.QUOTE_DOUBLE, Type.QUOTE_SINGLE];
3371     return jsonLikeTypes.indexOf(this.type) !== -1;
3372   }
3373
3374   get rangeAsLinePos() {
3375     if (!this.range || !this.context) return undefined;
3376     const start = getLinePos(this.range.start, this.context.root);
3377     if (!start) return undefined;
3378     const end = getLinePos(this.range.end, this.context.root);
3379     return {
3380       start,
3381       end
3382     };
3383   }
3384
3385   get rawValue() {
3386     if (!this.valueRange || !this.context) return null;
3387     const {
3388       start,
3389       end
3390     } = this.valueRange;
3391     return this.context.src.slice(start, end);
3392   }
3393
3394   get tag() {
3395     for (let i = 0; i < this.props.length; ++i) {
3396       const tag = this.getPropValue(i, Char.TAG, false);
3397
3398       if (tag != null) {
3399         if (tag[1] === '<') {
3400           return {
3401             verbatim: tag.slice(2, -1)
3402           };
3403         } else {
3404           // eslint-disable-next-line no-unused-vars
3405           const [_, handle, suffix] = tag.match(/^(.*!)([^!]*)$/);
3406           return {
3407             handle,
3408             suffix
3409           };
3410         }
3411       }
3412     }
3413
3414     return null;
3415   }
3416
3417   get valueRangeContainsNewline() {
3418     if (!this.valueRange || !this.context) return false;
3419     const {
3420       start,
3421       end
3422     } = this.valueRange;
3423     const {
3424       src
3425     } = this.context;
3426
3427     for (let i = start; i < end; ++i) {
3428       if (src[i] === '\n') return true;
3429     }
3430
3431     return false;
3432   }
3433
3434   parseComment(start) {
3435     const {
3436       src
3437     } = this.context;
3438
3439     if (src[start] === Char.COMMENT) {
3440       const end = Node$1.endOfLine(src, start + 1);
3441       const commentRange = new Range(start, end);
3442       this.props.push(commentRange);
3443       return end;
3444     }
3445
3446     return start;
3447   }
3448   /**
3449    * Populates the `origStart` and `origEnd` values of all ranges for this
3450    * node. Extended by child classes to handle descendant nodes.
3451    *
3452    * @param {number[]} cr - Positions of dropped CR characters
3453    * @param {number} offset - Starting index of `cr` from the last call
3454    * @returns {number} - The next offset, matching the one found for `origStart`
3455    */
3456
3457
3458   setOrigRanges(cr, offset) {
3459     if (this.range) offset = this.range.setOrigRange(cr, offset);
3460     if (this.valueRange) this.valueRange.setOrigRange(cr, offset);
3461     this.props.forEach(prop => prop.setOrigRange(cr, offset));
3462     return offset;
3463   }
3464
3465   toString() {
3466     const {
3467       context: {
3468         src
3469       },
3470       range,
3471       value
3472     } = this;
3473     if (value != null) return value;
3474     const str = src.slice(range.start, range.end);
3475     return Node$1.addStringTerminator(src, range.end, str);
3476   }
3477
3478 }
3479
3480 class YAMLError extends Error {
3481   constructor(name, source, message) {
3482     if (!message || !(source instanceof Node$1)) throw new Error(`Invalid arguments for new ${name}`);
3483     super();
3484     this.name = name;
3485     this.message = message;
3486     this.source = source;
3487   }
3488
3489   makePretty() {
3490     if (!this.source) return;
3491     this.nodeType = this.source.type;
3492     const cst = this.source.context && this.source.context.root;
3493
3494     if (typeof this.offset === 'number') {
3495       this.range = new Range(this.offset, this.offset + 1);
3496       const start = cst && getLinePos(this.offset, cst);
3497
3498       if (start) {
3499         const end = {
3500           line: start.line,
3501           col: start.col + 1
3502         };
3503         this.linePos = {
3504           start,
3505           end
3506         };
3507       }
3508
3509       delete this.offset;
3510     } else {
3511       this.range = this.source.range;
3512       this.linePos = this.source.rangeAsLinePos;
3513     }
3514
3515     if (this.linePos) {
3516       const {
3517         line,
3518         col
3519       } = this.linePos.start;
3520       this.message += ` at line ${line}, column ${col}`;
3521       const ctx = cst && getPrettyContext(this.linePos, cst);
3522       if (ctx) this.message += `:\n\n${ctx}\n`;
3523     }
3524
3525     delete this.source;
3526   }
3527
3528 }
3529
3530 class YAMLReferenceError extends YAMLError {
3531   constructor(source, message) {
3532     super('YAMLReferenceError', source, message);
3533   }
3534
3535 }
3536
3537 class YAMLSemanticError extends YAMLError {
3538   constructor(source, message) {
3539     super('YAMLSemanticError', source, message);
3540   }
3541
3542 }
3543
3544 class YAMLSyntaxError extends YAMLError {
3545   constructor(source, message) {
3546     super('YAMLSyntaxError', source, message);
3547   }
3548
3549 }
3550
3551 class YAMLWarning extends YAMLError {
3552   constructor(source, message) {
3553     super('YAMLWarning', source, message);
3554   }
3555
3556 }
3557
3558 function _defineProperty(obj, key, value) {
3559   if (key in obj) {
3560     Object.defineProperty(obj, key, {
3561       value: value,
3562       enumerable: true,
3563       configurable: true,
3564       writable: true
3565     });
3566   } else {
3567     obj[key] = value;
3568   }
3569
3570   return obj;
3571 }
3572
3573 class PlainValue$6 extends Node$1 {
3574   static endOfLine(src, start, inFlow) {
3575     let ch = src[start];
3576     let offset = start;
3577
3578     while (ch && ch !== '\n') {
3579       if (inFlow && (ch === '[' || ch === ']' || ch === '{' || ch === '}' || ch === ',')) break;
3580       const next = src[offset + 1];
3581       if (ch === ':' && (!next || next === '\n' || next === '\t' || next === ' ' || inFlow && next === ',')) break;
3582       if ((ch === ' ' || ch === '\t') && next === '#') break;
3583       offset += 1;
3584       ch = next;
3585     }
3586
3587     return offset;
3588   }
3589
3590   get strValue() {
3591     if (!this.valueRange || !this.context) return null;
3592     let {
3593       start,
3594       end
3595     } = this.valueRange;
3596     const {
3597       src
3598     } = this.context;
3599     let ch = src[end - 1];
3600
3601     while (start < end && (ch === '\n' || ch === '\t' || ch === ' ')) ch = src[--end - 1];
3602
3603     let str = '';
3604
3605     for (let i = start; i < end; ++i) {
3606       const ch = src[i];
3607
3608       if (ch === '\n') {
3609         const {
3610           fold,
3611           offset
3612         } = Node$1.foldNewline(src, i, -1);
3613         str += fold;
3614         i = offset;
3615       } else if (ch === ' ' || ch === '\t') {
3616         // trim trailing whitespace
3617         const wsStart = i;
3618         let next = src[i + 1];
3619
3620         while (i < end && (next === ' ' || next === '\t')) {
3621           i += 1;
3622           next = src[i + 1];
3623         }
3624
3625         if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch;
3626       } else {
3627         str += ch;
3628       }
3629     }
3630
3631     const ch0 = src[start];
3632
3633     switch (ch0) {
3634       case '\t':
3635         {
3636           const msg = 'Plain value cannot start with a tab character';
3637           const errors = [new YAMLSemanticError(this, msg)];
3638           return {
3639             errors,
3640             str
3641           };
3642         }
3643
3644       case '@':
3645       case '`':
3646         {
3647           const msg = `Plain value cannot start with reserved character ${ch0}`;
3648           const errors = [new YAMLSemanticError(this, msg)];
3649           return {
3650             errors,
3651             str
3652           };
3653         }
3654
3655       default:
3656         return str;
3657     }
3658   }
3659
3660   parseBlockValue(start) {
3661     const {
3662       indent,
3663       inFlow,
3664       src
3665     } = this.context;
3666     let offset = start;
3667     let valueEnd = start;
3668
3669     for (let ch = src[offset]; ch === '\n'; ch = src[offset]) {
3670       if (Node$1.atDocumentBoundary(src, offset + 1)) break;
3671       const end = Node$1.endOfBlockIndent(src, indent, offset + 1);
3672       if (end === null || src[end] === '#') break;
3673
3674       if (src[end] === '\n') {
3675         offset = end;
3676       } else {
3677         valueEnd = PlainValue$6.endOfLine(src, end, inFlow);
3678         offset = valueEnd;
3679       }
3680     }
3681
3682     if (this.valueRange.isEmpty()) this.valueRange.start = start;
3683     this.valueRange.end = valueEnd;
3684     return valueEnd;
3685   }
3686   /**
3687    * Parses a plain value from the source
3688    *
3689    * Accepted forms are:
3690    * ```
3691    * #comment
3692    *
3693    * first line
3694    *
3695    * first line #comment
3696    *
3697    * first line
3698    * block
3699    * lines
3700    *
3701    * #comment
3702    * block
3703    * lines
3704    * ```
3705    * where block lines are empty or have an indent level greater than `indent`.
3706    *
3707    * @param {ParseContext} context
3708    * @param {number} start - Index of first character
3709    * @returns {number} - Index of the character after this scalar, may be `\n`
3710    */
3711
3712
3713   parse(context, start) {
3714     this.context = context;
3715     const {
3716       inFlow,
3717       src
3718     } = context;
3719     let offset = start;
3720     const ch = src[offset];
3721
3722     if (ch && ch !== '#' && ch !== '\n') {
3723       offset = PlainValue$6.endOfLine(src, start, inFlow);
3724     }
3725
3726     this.valueRange = new Range(start, offset);
3727     offset = Node$1.endOfWhiteSpace(src, offset);
3728     offset = this.parseComment(offset);
3729
3730     if (!this.hasComment || this.valueRange.isEmpty()) {
3731       offset = this.parseBlockValue(offset);
3732     }
3733
3734     return offset;
3735   }
3736
3737 }
3738
3739 PlainValueEc8e588e.Char = Char;
3740 PlainValueEc8e588e.Node = Node$1;
3741 PlainValueEc8e588e.PlainValue = PlainValue$6;
3742 PlainValueEc8e588e.Range = Range;
3743 PlainValueEc8e588e.Type = Type;
3744 PlainValueEc8e588e.YAMLError = YAMLError;
3745 PlainValueEc8e588e.YAMLReferenceError = YAMLReferenceError;
3746 PlainValueEc8e588e.YAMLSemanticError = YAMLSemanticError;
3747 PlainValueEc8e588e.YAMLSyntaxError = YAMLSyntaxError;
3748 PlainValueEc8e588e.YAMLWarning = YAMLWarning;
3749
3750 PlainValueEc8e588e._defineProperty = _defineProperty;
3751
3752 PlainValueEc8e588e.defaultTagPrefix = defaultTagPrefix;
3753 PlainValueEc8e588e.defaultTags = defaultTags;
3754
3755 var PlainValue$5 = PlainValueEc8e588e;
3756
3757 class BlankLine extends PlainValue$5.Node {
3758   constructor() {
3759     super(PlainValue$5.Type.BLANK_LINE);
3760   }
3761   /* istanbul ignore next */
3762
3763
3764   get includesTrailingLines() {
3765     // This is never called from anywhere, but if it were,
3766     // this is the value it should return.
3767     return true;
3768   }
3769   /**
3770    * Parses a blank line from the source
3771    *
3772    * @param {ParseContext} context
3773    * @param {number} start - Index of first \n character
3774    * @returns {number} - Index of the character after this
3775    */
3776
3777
3778   parse(context, start) {
3779     this.context = context;
3780     this.range = new PlainValue$5.Range(start, start + 1);
3781     return start + 1;
3782   }
3783
3784 }
3785
3786 class CollectionItem extends PlainValue$5.Node {
3787   constructor(type, props) {
3788     super(type, props);
3789     this.node = null;
3790   }
3791
3792   get includesTrailingLines() {
3793     return !!this.node && this.node.includesTrailingLines;
3794   }
3795   /**
3796    * @param {ParseContext} context
3797    * @param {number} start - Index of first character
3798    * @returns {number} - Index of the character after this
3799    */
3800
3801
3802   parse(context, start) {
3803     this.context = context;
3804     const {
3805       parseNode,
3806       src
3807     } = context;
3808     let {
3809       atLineStart,
3810       lineStart
3811     } = context;
3812     if (!atLineStart && this.type === PlainValue$5.Type.SEQ_ITEM) this.error = new PlainValue$5.YAMLSemanticError(this, 'Sequence items must not have preceding content on the same line');
3813     const indent = atLineStart ? start - lineStart : context.indent;
3814     let offset = PlainValue$5.Node.endOfWhiteSpace(src, start + 1);
3815     let ch = src[offset];
3816     const inlineComment = ch === '#';
3817     const comments = [];
3818     let blankLine = null;
3819
3820     while (ch === '\n' || ch === '#') {
3821       if (ch === '#') {
3822         const end = PlainValue$5.Node.endOfLine(src, offset + 1);
3823         comments.push(new PlainValue$5.Range(offset, end));
3824         offset = end;
3825       } else {
3826         atLineStart = true;
3827         lineStart = offset + 1;
3828         const wsEnd = PlainValue$5.Node.endOfWhiteSpace(src, lineStart);
3829
3830         if (src[wsEnd] === '\n' && comments.length === 0) {
3831           blankLine = new BlankLine();
3832           lineStart = blankLine.parse({
3833             src
3834           }, lineStart);
3835         }
3836
3837         offset = PlainValue$5.Node.endOfIndent(src, lineStart);
3838       }
3839
3840       ch = src[offset];
3841     }
3842
3843     if (PlainValue$5.Node.nextNodeIsIndented(ch, offset - (lineStart + indent), this.type !== PlainValue$5.Type.SEQ_ITEM)) {
3844       this.node = parseNode({
3845         atLineStart,
3846         inCollection: false,
3847         indent,
3848         lineStart,
3849         parent: this
3850       }, offset);
3851     } else if (ch && lineStart > start + 1) {
3852       offset = lineStart - 1;
3853     }
3854
3855     if (this.node) {
3856       if (blankLine) {
3857         // Only blank lines preceding non-empty nodes are captured. Note that
3858         // this means that collection item range start indices do not always
3859         // increase monotonically. -- eemeli/yaml#126
3860         const items = context.parent.items || context.parent.contents;
3861         if (items) items.push(blankLine);
3862       }
3863
3864       if (comments.length) Array.prototype.push.apply(this.props, comments);
3865       offset = this.node.range.end;
3866     } else {
3867       if (inlineComment) {
3868         const c = comments[0];
3869         this.props.push(c);
3870         offset = c.end;
3871       } else {
3872         offset = PlainValue$5.Node.endOfLine(src, start + 1);
3873       }
3874     }
3875
3876     const end = this.node ? this.node.valueRange.end : offset;
3877     this.valueRange = new PlainValue$5.Range(start, end);
3878     return offset;
3879   }
3880
3881   setOrigRanges(cr, offset) {
3882     offset = super.setOrigRanges(cr, offset);
3883     return this.node ? this.node.setOrigRanges(cr, offset) : offset;
3884   }
3885
3886   toString() {
3887     const {
3888       context: {
3889         src
3890       },
3891       node,
3892       range,
3893       value
3894     } = this;
3895     if (value != null) return value;
3896     const str = node ? src.slice(range.start, node.range.start) + String(node) : src.slice(range.start, range.end);
3897     return PlainValue$5.Node.addStringTerminator(src, range.end, str);
3898   }
3899
3900 }
3901
3902 class Comment extends PlainValue$5.Node {
3903   constructor() {
3904     super(PlainValue$5.Type.COMMENT);
3905   }
3906   /**
3907    * Parses a comment line from the source
3908    *
3909    * @param {ParseContext} context
3910    * @param {number} start - Index of first character
3911    * @returns {number} - Index of the character after this scalar
3912    */
3913
3914
3915   parse(context, start) {
3916     this.context = context;
3917     const offset = this.parseComment(start);
3918     this.range = new PlainValue$5.Range(start, offset);
3919     return offset;
3920   }
3921
3922 }
3923
3924 function grabCollectionEndComments(node) {
3925   let cnode = node;
3926
3927   while (cnode instanceof CollectionItem) cnode = cnode.node;
3928
3929   if (!(cnode instanceof Collection$1)) return null;
3930   const len = cnode.items.length;
3931   let ci = -1;
3932
3933   for (let i = len - 1; i >= 0; --i) {
3934     const n = cnode.items[i];
3935
3936     if (n.type === PlainValue$5.Type.COMMENT) {
3937       // Keep sufficiently indented comments with preceding node
3938       const {
3939         indent,
3940         lineStart
3941       } = n.context;
3942       if (indent > 0 && n.range.start >= lineStart + indent) break;
3943       ci = i;
3944     } else if (n.type === PlainValue$5.Type.BLANK_LINE) ci = i;else break;
3945   }
3946
3947   if (ci === -1) return null;
3948   const ca = cnode.items.splice(ci, len - ci);
3949   const prevEnd = ca[0].range.start;
3950
3951   while (true) {
3952     cnode.range.end = prevEnd;
3953     if (cnode.valueRange && cnode.valueRange.end > prevEnd) cnode.valueRange.end = prevEnd;
3954     if (cnode === node) break;
3955     cnode = cnode.context.parent;
3956   }
3957
3958   return ca;
3959 }
3960
3961 class Collection$1 extends PlainValue$5.Node {
3962   static nextContentHasIndent(src, offset, indent) {
3963     const lineStart = PlainValue$5.Node.endOfLine(src, offset) + 1;
3964     offset = PlainValue$5.Node.endOfWhiteSpace(src, lineStart);
3965     const ch = src[offset];
3966     if (!ch) return false;
3967     if (offset >= lineStart + indent) return true;
3968     if (ch !== '#' && ch !== '\n') return false;
3969     return Collection$1.nextContentHasIndent(src, offset, indent);
3970   }
3971
3972   constructor(firstItem) {
3973     super(firstItem.type === PlainValue$5.Type.SEQ_ITEM ? PlainValue$5.Type.SEQ : PlainValue$5.Type.MAP);
3974
3975     for (let i = firstItem.props.length - 1; i >= 0; --i) {
3976       if (firstItem.props[i].start < firstItem.context.lineStart) {
3977         // props on previous line are assumed by the collection
3978         this.props = firstItem.props.slice(0, i + 1);
3979         firstItem.props = firstItem.props.slice(i + 1);
3980         const itemRange = firstItem.props[0] || firstItem.valueRange;
3981         firstItem.range.start = itemRange.start;
3982         break;
3983       }
3984     }
3985
3986     this.items = [firstItem];
3987     const ec = grabCollectionEndComments(firstItem);
3988     if (ec) Array.prototype.push.apply(this.items, ec);
3989   }
3990
3991   get includesTrailingLines() {
3992     return this.items.length > 0;
3993   }
3994   /**
3995    * @param {ParseContext} context
3996    * @param {number} start - Index of first character
3997    * @returns {number} - Index of the character after this
3998    */
3999
4000
4001   parse(context, start) {
4002     this.context = context;
4003     const {
4004       parseNode,
4005       src
4006     } = context; // It's easier to recalculate lineStart here rather than tracking down the
4007     // last context from which to read it -- eemeli/yaml#2
4008
4009     let lineStart = PlainValue$5.Node.startOfLine(src, start);
4010     const firstItem = this.items[0]; // First-item context needs to be correct for later comment handling
4011     // -- eemeli/yaml#17
4012
4013     firstItem.context.parent = this;
4014     this.valueRange = PlainValue$5.Range.copy(firstItem.valueRange);
4015     const indent = firstItem.range.start - firstItem.context.lineStart;
4016     let offset = start;
4017     offset = PlainValue$5.Node.normalizeOffset(src, offset);
4018     let ch = src[offset];
4019     let atLineStart = PlainValue$5.Node.endOfWhiteSpace(src, lineStart) === offset;
4020     let prevIncludesTrailingLines = false;
4021
4022     while (ch) {
4023       while (ch === '\n' || ch === '#') {
4024         if (atLineStart && ch === '\n' && !prevIncludesTrailingLines) {
4025           const blankLine = new BlankLine();
4026           offset = blankLine.parse({
4027             src
4028           }, offset);
4029           this.valueRange.end = offset;
4030
4031           if (offset >= src.length) {
4032             ch = null;
4033             break;
4034           }
4035
4036           this.items.push(blankLine);
4037           offset -= 1; // blankLine.parse() consumes terminal newline
4038         } else if (ch === '#') {
4039           if (offset < lineStart + indent && !Collection$1.nextContentHasIndent(src, offset, indent)) {
4040             return offset;
4041           }
4042
4043           const comment = new Comment();
4044           offset = comment.parse({
4045             indent,
4046             lineStart,
4047             src
4048           }, offset);
4049           this.items.push(comment);
4050           this.valueRange.end = offset;
4051
4052           if (offset >= src.length) {
4053             ch = null;
4054             break;
4055           }
4056         }
4057
4058         lineStart = offset + 1;
4059         offset = PlainValue$5.Node.endOfIndent(src, lineStart);
4060
4061         if (PlainValue$5.Node.atBlank(src, offset)) {
4062           const wsEnd = PlainValue$5.Node.endOfWhiteSpace(src, offset);
4063           const next = src[wsEnd];
4064
4065           if (!next || next === '\n' || next === '#') {
4066             offset = wsEnd;
4067           }
4068         }
4069
4070         ch = src[offset];
4071         atLineStart = true;
4072       }
4073
4074       if (!ch) {
4075         break;
4076       }
4077
4078       if (offset !== lineStart + indent && (atLineStart || ch !== ':')) {
4079         if (offset < lineStart + indent) {
4080           if (lineStart > start) offset = lineStart;
4081           break;
4082         } else if (!this.error) {
4083           const msg = 'All collection items must start at the same column';
4084           this.error = new PlainValue$5.YAMLSyntaxError(this, msg);
4085         }
4086       }
4087
4088       if (firstItem.type === PlainValue$5.Type.SEQ_ITEM) {
4089         if (ch !== '-') {
4090           if (lineStart > start) offset = lineStart;
4091           break;
4092         }
4093       } else if (ch === '-' && !this.error) {
4094         // map key may start with -, as long as it's followed by a non-whitespace char
4095         const next = src[offset + 1];
4096
4097         if (!next || next === '\n' || next === '\t' || next === ' ') {
4098           const msg = 'A collection cannot be both a mapping and a sequence';
4099           this.error = new PlainValue$5.YAMLSyntaxError(this, msg);
4100         }
4101       }
4102
4103       const node = parseNode({
4104         atLineStart,
4105         inCollection: true,
4106         indent,
4107         lineStart,
4108         parent: this
4109       }, offset);
4110       if (!node) return offset; // at next document start
4111
4112       this.items.push(node);
4113       this.valueRange.end = node.valueRange.end;
4114       offset = PlainValue$5.Node.normalizeOffset(src, node.range.end);
4115       ch = src[offset];
4116       atLineStart = false;
4117       prevIncludesTrailingLines = node.includesTrailingLines; // Need to reset lineStart and atLineStart here if preceding node's range
4118       // has advanced to check the current line's indentation level
4119       // -- eemeli/yaml#10 & eemeli/yaml#38
4120
4121       if (ch) {
4122         let ls = offset - 1;
4123         let prev = src[ls];
4124
4125         while (prev === ' ' || prev === '\t') prev = src[--ls];
4126
4127         if (prev === '\n') {
4128           lineStart = ls + 1;
4129           atLineStart = true;
4130         }
4131       }
4132
4133       const ec = grabCollectionEndComments(node);
4134       if (ec) Array.prototype.push.apply(this.items, ec);
4135     }
4136
4137     return offset;
4138   }
4139
4140   setOrigRanges(cr, offset) {
4141     offset = super.setOrigRanges(cr, offset);
4142     this.items.forEach(node => {
4143       offset = node.setOrigRanges(cr, offset);
4144     });
4145     return offset;
4146   }
4147
4148   toString() {
4149     const {
4150       context: {
4151         src
4152       },
4153       items,
4154       range,
4155       value
4156     } = this;
4157     if (value != null) return value;
4158     let str = src.slice(range.start, items[0].range.start) + String(items[0]);
4159
4160     for (let i = 1; i < items.length; ++i) {
4161       const item = items[i];
4162       const {
4163         atLineStart,
4164         indent
4165       } = item.context;
4166       if (atLineStart) for (let i = 0; i < indent; ++i) str += ' ';
4167       str += String(item);
4168     }
4169
4170     return PlainValue$5.Node.addStringTerminator(src, range.end, str);
4171   }
4172
4173 }
4174
4175 class Directive extends PlainValue$5.Node {
4176   constructor() {
4177     super(PlainValue$5.Type.DIRECTIVE);
4178     this.name = null;
4179   }
4180
4181   get parameters() {
4182     const raw = this.rawValue;
4183     return raw ? raw.trim().split(/[ \t]+/) : [];
4184   }
4185
4186   parseName(start) {
4187     const {
4188       src
4189     } = this.context;
4190     let offset = start;
4191     let ch = src[offset];
4192
4193     while (ch && ch !== '\n' && ch !== '\t' && ch !== ' ') ch = src[offset += 1];
4194
4195     this.name = src.slice(start, offset);
4196     return offset;
4197   }
4198
4199   parseParameters(start) {
4200     const {
4201       src
4202     } = this.context;
4203     let offset = start;
4204     let ch = src[offset];
4205
4206     while (ch && ch !== '\n' && ch !== '#') ch = src[offset += 1];
4207
4208     this.valueRange = new PlainValue$5.Range(start, offset);
4209     return offset;
4210   }
4211
4212   parse(context, start) {
4213     this.context = context;
4214     let offset = this.parseName(start + 1);
4215     offset = this.parseParameters(offset);
4216     offset = this.parseComment(offset);
4217     this.range = new PlainValue$5.Range(start, offset);
4218     return offset;
4219   }
4220
4221 }
4222
4223 class Document$3 extends PlainValue$5.Node {
4224   static startCommentOrEndBlankLine(src, start) {
4225     const offset = PlainValue$5.Node.endOfWhiteSpace(src, start);
4226     const ch = src[offset];
4227     return ch === '#' || ch === '\n' ? offset : start;
4228   }
4229
4230   constructor() {
4231     super(PlainValue$5.Type.DOCUMENT);
4232     this.directives = null;
4233     this.contents = null;
4234     this.directivesEndMarker = null;
4235     this.documentEndMarker = null;
4236   }
4237
4238   parseDirectives(start) {
4239     const {
4240       src
4241     } = this.context;
4242     this.directives = [];
4243     let atLineStart = true;
4244     let hasDirectives = false;
4245     let offset = start;
4246
4247     while (!PlainValue$5.Node.atDocumentBoundary(src, offset, PlainValue$5.Char.DIRECTIVES_END)) {
4248       offset = Document$3.startCommentOrEndBlankLine(src, offset);
4249
4250       switch (src[offset]) {
4251         case '\n':
4252           if (atLineStart) {
4253             const blankLine = new BlankLine();
4254             offset = blankLine.parse({
4255               src
4256             }, offset);
4257
4258             if (offset < src.length) {
4259               this.directives.push(blankLine);
4260             }
4261           } else {
4262             offset += 1;
4263             atLineStart = true;
4264           }
4265
4266           break;
4267
4268         case '#':
4269           {
4270             const comment = new Comment();
4271             offset = comment.parse({
4272               src
4273             }, offset);
4274             this.directives.push(comment);
4275             atLineStart = false;
4276           }
4277           break;
4278
4279         case '%':
4280           {
4281             const directive = new Directive();
4282             offset = directive.parse({
4283               parent: this,
4284               src
4285             }, offset);
4286             this.directives.push(directive);
4287             hasDirectives = true;
4288             atLineStart = false;
4289           }
4290           break;
4291
4292         default:
4293           if (hasDirectives) {
4294             this.error = new PlainValue$5.YAMLSemanticError(this, 'Missing directives-end indicator line');
4295           } else if (this.directives.length > 0) {
4296             this.contents = this.directives;
4297             this.directives = [];
4298           }
4299
4300           return offset;
4301       }
4302     }
4303
4304     if (src[offset]) {
4305       this.directivesEndMarker = new PlainValue$5.Range(offset, offset + 3);
4306       return offset + 3;
4307     }
4308
4309     if (hasDirectives) {
4310       this.error = new PlainValue$5.YAMLSemanticError(this, 'Missing directives-end indicator line');
4311     } else if (this.directives.length > 0) {
4312       this.contents = this.directives;
4313       this.directives = [];
4314     }
4315
4316     return offset;
4317   }
4318
4319   parseContents(start) {
4320     const {
4321       parseNode,
4322       src
4323     } = this.context;
4324     if (!this.contents) this.contents = [];
4325     let lineStart = start;
4326
4327     while (src[lineStart - 1] === '-') lineStart -= 1;
4328
4329     let offset = PlainValue$5.Node.endOfWhiteSpace(src, start);
4330     let atLineStart = lineStart === start;
4331     this.valueRange = new PlainValue$5.Range(offset);
4332
4333     while (!PlainValue$5.Node.atDocumentBoundary(src, offset, PlainValue$5.Char.DOCUMENT_END)) {
4334       switch (src[offset]) {
4335         case '\n':
4336           if (atLineStart) {
4337             const blankLine = new BlankLine();
4338             offset = blankLine.parse({
4339               src
4340             }, offset);
4341
4342             if (offset < src.length) {
4343               this.contents.push(blankLine);
4344             }
4345           } else {
4346             offset += 1;
4347             atLineStart = true;
4348           }
4349
4350           lineStart = offset;
4351           break;
4352
4353         case '#':
4354           {
4355             const comment = new Comment();
4356             offset = comment.parse({
4357               src
4358             }, offset);
4359             this.contents.push(comment);
4360             atLineStart = false;
4361           }
4362           break;
4363
4364         default:
4365           {
4366             const iEnd = PlainValue$5.Node.endOfIndent(src, offset);
4367             const context = {
4368               atLineStart,
4369               indent: -1,
4370               inFlow: false,
4371               inCollection: false,
4372               lineStart,
4373               parent: this
4374             };
4375             const node = parseNode(context, iEnd);
4376             if (!node) return this.valueRange.end = iEnd; // at next document start
4377
4378             this.contents.push(node);
4379             offset = node.range.end;
4380             atLineStart = false;
4381             const ec = grabCollectionEndComments(node);
4382             if (ec) Array.prototype.push.apply(this.contents, ec);
4383           }
4384       }
4385
4386       offset = Document$3.startCommentOrEndBlankLine(src, offset);
4387     }
4388
4389     this.valueRange.end = offset;
4390
4391     if (src[offset]) {
4392       this.documentEndMarker = new PlainValue$5.Range(offset, offset + 3);
4393       offset += 3;
4394
4395       if (src[offset]) {
4396         offset = PlainValue$5.Node.endOfWhiteSpace(src, offset);
4397
4398         if (src[offset] === '#') {
4399           const comment = new Comment();
4400           offset = comment.parse({
4401             src
4402           }, offset);
4403           this.contents.push(comment);
4404         }
4405
4406         switch (src[offset]) {
4407           case '\n':
4408             offset += 1;
4409             break;
4410
4411           case undefined:
4412             break;
4413
4414           default:
4415             this.error = new PlainValue$5.YAMLSyntaxError(this, 'Document end marker line cannot have a non-comment suffix');
4416         }
4417       }
4418     }
4419
4420     return offset;
4421   }
4422   /**
4423    * @param {ParseContext} context
4424    * @param {number} start - Index of first character
4425    * @returns {number} - Index of the character after this
4426    */
4427
4428
4429   parse(context, start) {
4430     context.root = this;
4431     this.context = context;
4432     const {
4433       src
4434     } = context;
4435     let offset = src.charCodeAt(start) === 0xfeff ? start + 1 : start; // skip BOM
4436
4437     offset = this.parseDirectives(offset);
4438     offset = this.parseContents(offset);
4439     return offset;
4440   }
4441
4442   setOrigRanges(cr, offset) {
4443     offset = super.setOrigRanges(cr, offset);
4444     this.directives.forEach(node => {
4445       offset = node.setOrigRanges(cr, offset);
4446     });
4447     if (this.directivesEndMarker) offset = this.directivesEndMarker.setOrigRange(cr, offset);
4448     this.contents.forEach(node => {
4449       offset = node.setOrigRanges(cr, offset);
4450     });
4451     if (this.documentEndMarker) offset = this.documentEndMarker.setOrigRange(cr, offset);
4452     return offset;
4453   }
4454
4455   toString() {
4456     const {
4457       contents,
4458       directives,
4459       value
4460     } = this;
4461     if (value != null) return value;
4462     let str = directives.join('');
4463
4464     if (contents.length > 0) {
4465       if (directives.length > 0 || contents[0].type === PlainValue$5.Type.COMMENT) str += '---\n';
4466       str += contents.join('');
4467     }
4468
4469     if (str[str.length - 1] !== '\n') str += '\n';
4470     return str;
4471   }
4472
4473 }
4474
4475 class Alias$1 extends PlainValue$5.Node {
4476   /**
4477    * Parses an *alias from the source
4478    *
4479    * @param {ParseContext} context
4480    * @param {number} start - Index of first character
4481    * @returns {number} - Index of the character after this scalar
4482    */
4483   parse(context, start) {
4484     this.context = context;
4485     const {
4486       src
4487     } = context;
4488     let offset = PlainValue$5.Node.endOfIdentifier(src, start + 1);
4489     this.valueRange = new PlainValue$5.Range(start + 1, offset);
4490     offset = PlainValue$5.Node.endOfWhiteSpace(src, offset);
4491     offset = this.parseComment(offset);
4492     return offset;
4493   }
4494
4495 }
4496
4497 const Chomp = {
4498   CLIP: 'CLIP',
4499   KEEP: 'KEEP',
4500   STRIP: 'STRIP'
4501 };
4502
4503 class BlockValue extends PlainValue$5.Node {
4504   constructor(type, props) {
4505     super(type, props);
4506     this.blockIndent = null;
4507     this.chomping = Chomp.CLIP;
4508     this.header = null;
4509   }
4510
4511   get includesTrailingLines() {
4512     return this.chomping === Chomp.KEEP;
4513   }
4514
4515   get strValue() {
4516     if (!this.valueRange || !this.context) return null;
4517     let {
4518       start,
4519       end
4520     } = this.valueRange;
4521     const {
4522       indent,
4523       src
4524     } = this.context;
4525     if (this.valueRange.isEmpty()) return '';
4526     let lastNewLine = null;
4527     let ch = src[end - 1];
4528
4529     while (ch === '\n' || ch === '\t' || ch === ' ') {
4530       end -= 1;
4531
4532       if (end <= start) {
4533         if (this.chomping === Chomp.KEEP) break;else return ''; // probably never happens
4534       }
4535
4536       if (ch === '\n') lastNewLine = end;
4537       ch = src[end - 1];
4538     }
4539
4540     let keepStart = end + 1;
4541
4542     if (lastNewLine) {
4543       if (this.chomping === Chomp.KEEP) {
4544         keepStart = lastNewLine;
4545         end = this.valueRange.end;
4546       } else {
4547         end = lastNewLine;
4548       }
4549     }
4550
4551     const bi = indent + this.blockIndent;
4552     const folded = this.type === PlainValue$5.Type.BLOCK_FOLDED;
4553     let atStart = true;
4554     let str = '';
4555     let sep = '';
4556     let prevMoreIndented = false;
4557
4558     for (let i = start; i < end; ++i) {
4559       for (let j = 0; j < bi; ++j) {
4560         if (src[i] !== ' ') break;
4561         i += 1;
4562       }
4563
4564       const ch = src[i];
4565
4566       if (ch === '\n') {
4567         if (sep === '\n') str += '\n';else sep = '\n';
4568       } else {
4569         const lineEnd = PlainValue$5.Node.endOfLine(src, i);
4570         const line = src.slice(i, lineEnd);
4571         i = lineEnd;
4572
4573         if (folded && (ch === ' ' || ch === '\t') && i < keepStart) {
4574           if (sep === ' ') sep = '\n';else if (!prevMoreIndented && !atStart && sep === '\n') sep = '\n\n';
4575           str += sep + line; //+ ((lineEnd < end && src[lineEnd]) || '')
4576
4577           sep = lineEnd < end && src[lineEnd] || '';
4578           prevMoreIndented = true;
4579         } else {
4580           str += sep + line;
4581           sep = folded && i < keepStart ? ' ' : '\n';
4582           prevMoreIndented = false;
4583         }
4584
4585         if (atStart && line !== '') atStart = false;
4586       }
4587     }
4588
4589     return this.chomping === Chomp.STRIP ? str : str + '\n';
4590   }
4591
4592   parseBlockHeader(start) {
4593     const {
4594       src
4595     } = this.context;
4596     let offset = start + 1;
4597     let bi = '';
4598
4599     while (true) {
4600       const ch = src[offset];
4601
4602       switch (ch) {
4603         case '-':
4604           this.chomping = Chomp.STRIP;
4605           break;
4606
4607         case '+':
4608           this.chomping = Chomp.KEEP;
4609           break;
4610
4611         case '0':
4612         case '1':
4613         case '2':
4614         case '3':
4615         case '4':
4616         case '5':
4617         case '6':
4618         case '7':
4619         case '8':
4620         case '9':
4621           bi += ch;
4622           break;
4623
4624         default:
4625           this.blockIndent = Number(bi) || null;
4626           this.header = new PlainValue$5.Range(start, offset);
4627           return offset;
4628       }
4629
4630       offset += 1;
4631     }
4632   }
4633
4634   parseBlockValue(start) {
4635     const {
4636       indent,
4637       src
4638     } = this.context;
4639     const explicit = !!this.blockIndent;
4640     let offset = start;
4641     let valueEnd = start;
4642     let minBlockIndent = 1;
4643
4644     for (let ch = src[offset]; ch === '\n'; ch = src[offset]) {
4645       offset += 1;
4646       if (PlainValue$5.Node.atDocumentBoundary(src, offset)) break;
4647       const end = PlainValue$5.Node.endOfBlockIndent(src, indent, offset); // should not include tab?
4648
4649       if (end === null) break;
4650       const ch = src[end];
4651       const lineIndent = end - (offset + indent);
4652
4653       if (!this.blockIndent) {
4654         // no explicit block indent, none yet detected
4655         if (src[end] !== '\n') {
4656           // first line with non-whitespace content
4657           if (lineIndent < minBlockIndent) {
4658             const msg = 'Block scalars with more-indented leading empty lines must use an explicit indentation indicator';
4659             this.error = new PlainValue$5.YAMLSemanticError(this, msg);
4660           }
4661
4662           this.blockIndent = lineIndent;
4663         } else if (lineIndent > minBlockIndent) {
4664           // empty line with more whitespace
4665           minBlockIndent = lineIndent;
4666         }
4667       } else if (ch && ch !== '\n' && lineIndent < this.blockIndent) {
4668         if (src[end] === '#') break;
4669
4670         if (!this.error) {
4671           const src = explicit ? 'explicit indentation indicator' : 'first line';
4672           const msg = `Block scalars must not be less indented than their ${src}`;
4673           this.error = new PlainValue$5.YAMLSemanticError(this, msg);
4674         }
4675       }
4676
4677       if (src[end] === '\n') {
4678         offset = end;
4679       } else {
4680         offset = valueEnd = PlainValue$5.Node.endOfLine(src, end);
4681       }
4682     }
4683
4684     if (this.chomping !== Chomp.KEEP) {
4685       offset = src[valueEnd] ? valueEnd + 1 : valueEnd;
4686     }
4687
4688     this.valueRange = new PlainValue$5.Range(start + 1, offset);
4689     return offset;
4690   }
4691   /**
4692    * Parses a block value from the source
4693    *
4694    * Accepted forms are:
4695    * ```
4696    * BS
4697    * block
4698    * lines
4699    *
4700    * BS #comment
4701    * block
4702    * lines
4703    * ```
4704    * where the block style BS matches the regexp `[|>][-+1-9]*` and block lines
4705    * are empty or have an indent level greater than `indent`.
4706    *
4707    * @param {ParseContext} context
4708    * @param {number} start - Index of first character
4709    * @returns {number} - Index of the character after this block
4710    */
4711
4712
4713   parse(context, start) {
4714     this.context = context;
4715     const {
4716       src
4717     } = context;
4718     let offset = this.parseBlockHeader(start);
4719     offset = PlainValue$5.Node.endOfWhiteSpace(src, offset);
4720     offset = this.parseComment(offset);
4721     offset = this.parseBlockValue(offset);
4722     return offset;
4723   }
4724
4725   setOrigRanges(cr, offset) {
4726     offset = super.setOrigRanges(cr, offset);
4727     return this.header ? this.header.setOrigRange(cr, offset) : offset;
4728   }
4729
4730 }
4731
4732 class FlowCollection extends PlainValue$5.Node {
4733   constructor(type, props) {
4734     super(type, props);
4735     this.items = null;
4736   }
4737
4738   prevNodeIsJsonLike(idx = this.items.length) {
4739     const node = this.items[idx - 1];
4740     return !!node && (node.jsonLike || node.type === PlainValue$5.Type.COMMENT && this.prevNodeIsJsonLike(idx - 1));
4741   }
4742   /**
4743    * @param {ParseContext} context
4744    * @param {number} start - Index of first character
4745    * @returns {number} - Index of the character after this
4746    */
4747
4748
4749   parse(context, start) {
4750     this.context = context;
4751     const {
4752       parseNode,
4753       src
4754     } = context;
4755     let {
4756       indent,
4757       lineStart
4758     } = context;
4759     let char = src[start]; // { or [
4760
4761     this.items = [{
4762       char,
4763       offset: start
4764     }];
4765     let offset = PlainValue$5.Node.endOfWhiteSpace(src, start + 1);
4766     char = src[offset];
4767
4768     while (char && char !== ']' && char !== '}') {
4769       switch (char) {
4770         case '\n':
4771           {
4772             lineStart = offset + 1;
4773             const wsEnd = PlainValue$5.Node.endOfWhiteSpace(src, lineStart);
4774
4775             if (src[wsEnd] === '\n') {
4776               const blankLine = new BlankLine();
4777               lineStart = blankLine.parse({
4778                 src
4779               }, lineStart);
4780               this.items.push(blankLine);
4781             }
4782
4783             offset = PlainValue$5.Node.endOfIndent(src, lineStart);
4784
4785             if (offset <= lineStart + indent) {
4786               char = src[offset];
4787
4788               if (offset < lineStart + indent || char !== ']' && char !== '}') {
4789                 const msg = 'Insufficient indentation in flow collection';
4790                 this.error = new PlainValue$5.YAMLSemanticError(this, msg);
4791               }
4792             }
4793           }
4794           break;
4795
4796         case ',':
4797           {
4798             this.items.push({
4799               char,
4800               offset
4801             });
4802             offset += 1;
4803           }
4804           break;
4805
4806         case '#':
4807           {
4808             const comment = new Comment();
4809             offset = comment.parse({
4810               src
4811             }, offset);
4812             this.items.push(comment);
4813           }
4814           break;
4815
4816         case '?':
4817         case ':':
4818           {
4819             const next = src[offset + 1];
4820
4821             if (next === '\n' || next === '\t' || next === ' ' || next === ',' || // in-flow : after JSON-like key does not need to be followed by whitespace
4822             char === ':' && this.prevNodeIsJsonLike()) {
4823               this.items.push({
4824                 char,
4825                 offset
4826               });
4827               offset += 1;
4828               break;
4829             }
4830           }
4831         // fallthrough
4832
4833         default:
4834           {
4835             const node = parseNode({
4836               atLineStart: false,
4837               inCollection: false,
4838               inFlow: true,
4839               indent: -1,
4840               lineStart,
4841               parent: this
4842             }, offset);
4843
4844             if (!node) {
4845               // at next document start
4846               this.valueRange = new PlainValue$5.Range(start, offset);
4847               return offset;
4848             }
4849
4850             this.items.push(node);
4851             offset = PlainValue$5.Node.normalizeOffset(src, node.range.end);
4852           }
4853       }
4854
4855       offset = PlainValue$5.Node.endOfWhiteSpace(src, offset);
4856       char = src[offset];
4857     }
4858
4859     this.valueRange = new PlainValue$5.Range(start, offset + 1);
4860
4861     if (char) {
4862       this.items.push({
4863         char,
4864         offset
4865       });
4866       offset = PlainValue$5.Node.endOfWhiteSpace(src, offset + 1);
4867       offset = this.parseComment(offset);
4868     }
4869
4870     return offset;
4871   }
4872
4873   setOrigRanges(cr, offset) {
4874     offset = super.setOrigRanges(cr, offset);
4875     this.items.forEach(node => {
4876       if (node instanceof PlainValue$5.Node) {
4877         offset = node.setOrigRanges(cr, offset);
4878       } else if (cr.length === 0) {
4879         node.origOffset = node.offset;
4880       } else {
4881         let i = offset;
4882
4883         while (i < cr.length) {
4884           if (cr[i] > node.offset) break;else ++i;
4885         }
4886
4887         node.origOffset = node.offset + i;
4888         offset = i;
4889       }
4890     });
4891     return offset;
4892   }
4893
4894   toString() {
4895     const {
4896       context: {
4897         src
4898       },
4899       items,
4900       range,
4901       value
4902     } = this;
4903     if (value != null) return value;
4904     const nodes = items.filter(item => item instanceof PlainValue$5.Node);
4905     let str = '';
4906     let prevEnd = range.start;
4907     nodes.forEach(node => {
4908       const prefix = src.slice(prevEnd, node.range.start);
4909       prevEnd = node.range.end;
4910       str += prefix + String(node);
4911
4912       if (str[str.length - 1] === '\n' && src[prevEnd - 1] !== '\n' && src[prevEnd] === '\n') {
4913         // Comment range does not include the terminal newline, but its
4914         // stringified value does. Without this fix, newlines at comment ends
4915         // get duplicated.
4916         prevEnd += 1;
4917       }
4918     });
4919     str += src.slice(prevEnd, range.end);
4920     return PlainValue$5.Node.addStringTerminator(src, range.end, str);
4921   }
4922
4923 }
4924
4925 class QuoteDouble extends PlainValue$5.Node {
4926   static endOfQuote(src, offset) {
4927     let ch = src[offset];
4928
4929     while (ch && ch !== '"') {
4930       offset += ch === '\\' ? 2 : 1;
4931       ch = src[offset];
4932     }
4933
4934     return offset + 1;
4935   }
4936   /**
4937    * @returns {string | { str: string, errors: YAMLSyntaxError[] }}
4938    */
4939
4940
4941   get strValue() {
4942     if (!this.valueRange || !this.context) return null;
4943     const errors = [];
4944     const {
4945       start,
4946       end
4947     } = this.valueRange;
4948     const {
4949       indent,
4950       src
4951     } = this.context;
4952     if (src[end - 1] !== '"') errors.push(new PlainValue$5.YAMLSyntaxError(this, 'Missing closing "quote')); // Using String#replace is too painful with escaped newlines preceded by
4953     // escaped backslashes; also, this should be faster.
4954
4955     let str = '';
4956
4957     for (let i = start + 1; i < end - 1; ++i) {
4958       const ch = src[i];
4959
4960       if (ch === '\n') {
4961         if (PlainValue$5.Node.atDocumentBoundary(src, i + 1)) errors.push(new PlainValue$5.YAMLSemanticError(this, 'Document boundary indicators are not allowed within string values'));
4962         const {
4963           fold,
4964           offset,
4965           error
4966         } = PlainValue$5.Node.foldNewline(src, i, indent);
4967         str += fold;
4968         i = offset;
4969         if (error) errors.push(new PlainValue$5.YAMLSemanticError(this, 'Multi-line double-quoted string needs to be sufficiently indented'));
4970       } else if (ch === '\\') {
4971         i += 1;
4972
4973         switch (src[i]) {
4974           case '0':
4975             str += '\0';
4976             break;
4977           // null character
4978
4979           case 'a':
4980             str += '\x07';
4981             break;
4982           // bell character
4983
4984           case 'b':
4985             str += '\b';
4986             break;
4987           // backspace
4988
4989           case 'e':
4990             str += '\x1b';
4991             break;
4992           // escape character
4993
4994           case 'f':
4995             str += '\f';
4996             break;
4997           // form feed
4998
4999           case 'n':
5000             str += '\n';
5001             break;
5002           // line feed
5003
5004           case 'r':
5005             str += '\r';
5006             break;
5007           // carriage return
5008
5009           case 't':
5010             str += '\t';
5011             break;
5012           // horizontal tab
5013
5014           case 'v':
5015             str += '\v';
5016             break;
5017           // vertical tab
5018
5019           case 'N':
5020             str += '\u0085';
5021             break;
5022           // Unicode next line
5023
5024           case '_':
5025             str += '\u00a0';
5026             break;
5027           // Unicode non-breaking space
5028
5029           case 'L':
5030             str += '\u2028';
5031             break;
5032           // Unicode line separator
5033
5034           case 'P':
5035             str += '\u2029';
5036             break;
5037           // Unicode paragraph separator
5038
5039           case ' ':
5040             str += ' ';
5041             break;
5042
5043           case '"':
5044             str += '"';
5045             break;
5046
5047           case '/':
5048             str += '/';
5049             break;
5050
5051           case '\\':
5052             str += '\\';
5053             break;
5054
5055           case '\t':
5056             str += '\t';
5057             break;
5058
5059           case 'x':
5060             str += this.parseCharCode(i + 1, 2, errors);
5061             i += 2;
5062             break;
5063
5064           case 'u':
5065             str += this.parseCharCode(i + 1, 4, errors);
5066             i += 4;
5067             break;
5068
5069           case 'U':
5070             str += this.parseCharCode(i + 1, 8, errors);
5071             i += 8;
5072             break;
5073
5074           case '\n':
5075             // skip escaped newlines, but still trim the following line
5076             while (src[i + 1] === ' ' || src[i + 1] === '\t') i += 1;
5077
5078             break;
5079
5080           default:
5081             errors.push(new PlainValue$5.YAMLSyntaxError(this, `Invalid escape sequence ${src.substr(i - 1, 2)}`));
5082             str += '\\' + src[i];
5083         }
5084       } else if (ch === ' ' || ch === '\t') {
5085         // trim trailing whitespace
5086         const wsStart = i;
5087         let next = src[i + 1];
5088
5089         while (next === ' ' || next === '\t') {
5090           i += 1;
5091           next = src[i + 1];
5092         }
5093
5094         if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch;
5095       } else {
5096         str += ch;
5097       }
5098     }
5099
5100     return errors.length > 0 ? {
5101       errors,
5102       str
5103     } : str;
5104   }
5105
5106   parseCharCode(offset, length, errors) {
5107     const {
5108       src
5109     } = this.context;
5110     const cc = src.substr(offset, length);
5111     const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
5112     const code = ok ? parseInt(cc, 16) : NaN;
5113
5114     if (isNaN(code)) {
5115       errors.push(new PlainValue$5.YAMLSyntaxError(this, `Invalid escape sequence ${src.substr(offset - 2, length + 2)}`));
5116       return src.substr(offset - 2, length + 2);
5117     }
5118
5119     return String.fromCodePoint(code);
5120   }
5121   /**
5122    * Parses a "double quoted" value from the source
5123    *
5124    * @param {ParseContext} context
5125    * @param {number} start - Index of first character
5126    * @returns {number} - Index of the character after this scalar
5127    */
5128
5129
5130   parse(context, start) {
5131     this.context = context;
5132     const {
5133       src
5134     } = context;
5135     let offset = QuoteDouble.endOfQuote(src, start + 1);
5136     this.valueRange = new PlainValue$5.Range(start, offset);
5137     offset = PlainValue$5.Node.endOfWhiteSpace(src, offset);
5138     offset = this.parseComment(offset);
5139     return offset;
5140   }
5141
5142 }
5143
5144 class QuoteSingle extends PlainValue$5.Node {
5145   static endOfQuote(src, offset) {
5146     let ch = src[offset];
5147
5148     while (ch) {
5149       if (ch === "'") {
5150         if (src[offset + 1] !== "'") break;
5151         ch = src[offset += 2];
5152       } else {
5153         ch = src[offset += 1];
5154       }
5155     }
5156
5157     return offset + 1;
5158   }
5159   /**
5160    * @returns {string | { str: string, errors: YAMLSyntaxError[] }}
5161    */
5162
5163
5164   get strValue() {
5165     if (!this.valueRange || !this.context) return null;
5166     const errors = [];
5167     const {
5168       start,
5169       end
5170     } = this.valueRange;
5171     const {
5172       indent,
5173       src
5174     } = this.context;
5175     if (src[end - 1] !== "'") errors.push(new PlainValue$5.YAMLSyntaxError(this, "Missing closing 'quote"));
5176     let str = '';
5177
5178     for (let i = start + 1; i < end - 1; ++i) {
5179       const ch = src[i];
5180
5181       if (ch === '\n') {
5182         if (PlainValue$5.Node.atDocumentBoundary(src, i + 1)) errors.push(new PlainValue$5.YAMLSemanticError(this, 'Document boundary indicators are not allowed within string values'));
5183         const {
5184           fold,
5185           offset,
5186           error
5187         } = PlainValue$5.Node.foldNewline(src, i, indent);
5188         str += fold;
5189         i = offset;
5190         if (error) errors.push(new PlainValue$5.YAMLSemanticError(this, 'Multi-line single-quoted string needs to be sufficiently indented'));
5191       } else if (ch === "'") {
5192         str += ch;
5193         i += 1;
5194         if (src[i] !== "'") errors.push(new PlainValue$5.YAMLSyntaxError(this, 'Unescaped single quote? This should not happen.'));
5195       } else if (ch === ' ' || ch === '\t') {
5196         // trim trailing whitespace
5197         const wsStart = i;
5198         let next = src[i + 1];
5199
5200         while (next === ' ' || next === '\t') {
5201           i += 1;
5202           next = src[i + 1];
5203         }
5204
5205         if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch;
5206       } else {
5207         str += ch;
5208       }
5209     }
5210
5211     return errors.length > 0 ? {
5212       errors,
5213       str
5214     } : str;
5215   }
5216   /**
5217    * Parses a 'single quoted' value from the source
5218    *
5219    * @param {ParseContext} context
5220    * @param {number} start - Index of first character
5221    * @returns {number} - Index of the character after this scalar
5222    */
5223
5224
5225   parse(context, start) {
5226     this.context = context;
5227     const {
5228       src
5229     } = context;
5230     let offset = QuoteSingle.endOfQuote(src, start + 1);
5231     this.valueRange = new PlainValue$5.Range(start, offset);
5232     offset = PlainValue$5.Node.endOfWhiteSpace(src, offset);
5233     offset = this.parseComment(offset);
5234     return offset;
5235   }
5236
5237 }
5238
5239 function createNewNode(type, props) {
5240   switch (type) {
5241     case PlainValue$5.Type.ALIAS:
5242       return new Alias$1(type, props);
5243
5244     case PlainValue$5.Type.BLOCK_FOLDED:
5245     case PlainValue$5.Type.BLOCK_LITERAL:
5246       return new BlockValue(type, props);
5247
5248     case PlainValue$5.Type.FLOW_MAP:
5249     case PlainValue$5.Type.FLOW_SEQ:
5250       return new FlowCollection(type, props);
5251
5252     case PlainValue$5.Type.MAP_KEY:
5253     case PlainValue$5.Type.MAP_VALUE:
5254     case PlainValue$5.Type.SEQ_ITEM:
5255       return new CollectionItem(type, props);
5256
5257     case PlainValue$5.Type.COMMENT:
5258     case PlainValue$5.Type.PLAIN:
5259       return new PlainValue$5.PlainValue(type, props);
5260
5261     case PlainValue$5.Type.QUOTE_DOUBLE:
5262       return new QuoteDouble(type, props);
5263
5264     case PlainValue$5.Type.QUOTE_SINGLE:
5265       return new QuoteSingle(type, props);
5266
5267     /* istanbul ignore next */
5268
5269     default:
5270       return null;
5271     // should never happen
5272   }
5273 }
5274 /**
5275  * @param {boolean} atLineStart - Node starts at beginning of line
5276  * @param {boolean} inFlow - true if currently in a flow context
5277  * @param {boolean} inCollection - true if currently in a collection context
5278  * @param {number} indent - Current level of indentation
5279  * @param {number} lineStart - Start of the current line
5280  * @param {Node} parent - The parent of the node
5281  * @param {string} src - Source of the YAML document
5282  */
5283
5284
5285 class ParseContext {
5286   static parseType(src, offset, inFlow) {
5287     switch (src[offset]) {
5288       case '*':
5289         return PlainValue$5.Type.ALIAS;
5290
5291       case '>':
5292         return PlainValue$5.Type.BLOCK_FOLDED;
5293
5294       case '|':
5295         return PlainValue$5.Type.BLOCK_LITERAL;
5296
5297       case '{':
5298         return PlainValue$5.Type.FLOW_MAP;
5299
5300       case '[':
5301         return PlainValue$5.Type.FLOW_SEQ;
5302
5303       case '?':
5304         return !inFlow && PlainValue$5.Node.atBlank(src, offset + 1, true) ? PlainValue$5.Type.MAP_KEY : PlainValue$5.Type.PLAIN;
5305
5306       case ':':
5307         return !inFlow && PlainValue$5.Node.atBlank(src, offset + 1, true) ? PlainValue$5.Type.MAP_VALUE : PlainValue$5.Type.PLAIN;
5308
5309       case '-':
5310         return !inFlow && PlainValue$5.Node.atBlank(src, offset + 1, true) ? PlainValue$5.Type.SEQ_ITEM : PlainValue$5.Type.PLAIN;
5311
5312       case '"':
5313         return PlainValue$5.Type.QUOTE_DOUBLE;
5314
5315       case "'":
5316         return PlainValue$5.Type.QUOTE_SINGLE;
5317
5318       default:
5319         return PlainValue$5.Type.PLAIN;
5320     }
5321   }
5322
5323   constructor(orig = {}, {
5324     atLineStart,
5325     inCollection,
5326     inFlow,
5327     indent,
5328     lineStart,
5329     parent
5330   } = {}) {
5331     PlainValue$5._defineProperty(this, "parseNode", (overlay, start) => {
5332       if (PlainValue$5.Node.atDocumentBoundary(this.src, start)) return null;
5333       const context = new ParseContext(this, overlay);
5334       const {
5335         props,
5336         type,
5337         valueStart
5338       } = context.parseProps(start);
5339       const node = createNewNode(type, props);
5340       let offset = node.parse(context, valueStart);
5341       node.range = new PlainValue$5.Range(start, offset);
5342       /* istanbul ignore if */
5343
5344       if (offset <= start) {
5345         // This should never happen, but if it does, let's make sure to at least
5346         // step one character forward to avoid a busy loop.
5347         node.error = new Error(`Node#parse consumed no characters`);
5348         node.error.parseEnd = offset;
5349         node.error.source = node;
5350         node.range.end = start + 1;
5351       }
5352
5353       if (context.nodeStartsCollection(node)) {
5354         if (!node.error && !context.atLineStart && context.parent.type === PlainValue$5.Type.DOCUMENT) {
5355           node.error = new PlainValue$5.YAMLSyntaxError(node, 'Block collection must not have preceding content here (e.g. directives-end indicator)');
5356         }
5357
5358         const collection = new Collection$1(node);
5359         offset = collection.parse(new ParseContext(context), offset);
5360         collection.range = new PlainValue$5.Range(start, offset);
5361         return collection;
5362       }
5363
5364       return node;
5365     });
5366
5367     this.atLineStart = atLineStart != null ? atLineStart : orig.atLineStart || false;
5368     this.inCollection = inCollection != null ? inCollection : orig.inCollection || false;
5369     this.inFlow = inFlow != null ? inFlow : orig.inFlow || false;
5370     this.indent = indent != null ? indent : orig.indent;
5371     this.lineStart = lineStart != null ? lineStart : orig.lineStart;
5372     this.parent = parent != null ? parent : orig.parent || {};
5373     this.root = orig.root;
5374     this.src = orig.src;
5375   }
5376
5377   nodeStartsCollection(node) {
5378     const {
5379       inCollection,
5380       inFlow,
5381       src
5382     } = this;
5383     if (inCollection || inFlow) return false;
5384     if (node instanceof CollectionItem) return true; // check for implicit key
5385
5386     let offset = node.range.end;
5387     if (src[offset] === '\n' || src[offset - 1] === '\n') return false;
5388     offset = PlainValue$5.Node.endOfWhiteSpace(src, offset);
5389     return src[offset] === ':';
5390   } // Anchor and tag are before type, which determines the node implementation
5391   // class; hence this intermediate step.
5392
5393
5394   parseProps(offset) {
5395     const {
5396       inFlow,
5397       parent,
5398       src
5399     } = this;
5400     const props = [];
5401     let lineHasProps = false;
5402     offset = this.atLineStart ? PlainValue$5.Node.endOfIndent(src, offset) : PlainValue$5.Node.endOfWhiteSpace(src, offset);
5403     let ch = src[offset];
5404
5405     while (ch === PlainValue$5.Char.ANCHOR || ch === PlainValue$5.Char.COMMENT || ch === PlainValue$5.Char.TAG || ch === '\n') {
5406       if (ch === '\n') {
5407         let inEnd = offset;
5408         let lineStart;
5409
5410         do {
5411           lineStart = inEnd + 1;
5412           inEnd = PlainValue$5.Node.endOfIndent(src, lineStart);
5413         } while (src[inEnd] === '\n');
5414
5415         const indentDiff = inEnd - (lineStart + this.indent);
5416         const noIndicatorAsIndent = parent.type === PlainValue$5.Type.SEQ_ITEM && parent.context.atLineStart;
5417         if (src[inEnd] !== '#' && !PlainValue$5.Node.nextNodeIsIndented(src[inEnd], indentDiff, !noIndicatorAsIndent)) break;
5418         this.atLineStart = true;
5419         this.lineStart = lineStart;
5420         lineHasProps = false;
5421         offset = inEnd;
5422       } else if (ch === PlainValue$5.Char.COMMENT) {
5423         const end = PlainValue$5.Node.endOfLine(src, offset + 1);
5424         props.push(new PlainValue$5.Range(offset, end));
5425         offset = end;
5426       } else {
5427         let end = PlainValue$5.Node.endOfIdentifier(src, offset + 1);
5428
5429         if (ch === PlainValue$5.Char.TAG && src[end] === ',' && /^[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+,\d\d\d\d(-\d\d){0,2}\/\S/.test(src.slice(offset + 1, end + 13))) {
5430           // Let's presume we're dealing with a YAML 1.0 domain tag here, rather
5431           // than an empty but 'foo.bar' private-tagged node in a flow collection
5432           // followed without whitespace by a plain string starting with a year
5433           // or date divided by something.
5434           end = PlainValue$5.Node.endOfIdentifier(src, end + 5);
5435         }
5436
5437         props.push(new PlainValue$5.Range(offset, end));
5438         lineHasProps = true;
5439         offset = PlainValue$5.Node.endOfWhiteSpace(src, end);
5440       }
5441
5442       ch = src[offset];
5443     } // '- &a : b' has an anchor on an empty node
5444
5445
5446     if (lineHasProps && ch === ':' && PlainValue$5.Node.atBlank(src, offset + 1, true)) offset -= 1;
5447     const type = ParseContext.parseType(src, offset, inFlow);
5448     return {
5449       props,
5450       type,
5451       valueStart: offset
5452     };
5453   }
5454   /**
5455    * Parses a node from the source
5456    * @param {ParseContext} overlay
5457    * @param {number} start - Index of first non-whitespace character for the node
5458    * @returns {?Node} - null if at a document boundary
5459    */
5460
5461
5462 } // Published as 'yaml/parse-cst'
5463
5464
5465 function parse$1(src) {
5466   const cr = [];
5467
5468   if (src.indexOf('\r') !== -1) {
5469     src = src.replace(/\r\n?/g, (match, offset) => {
5470       if (match.length > 1) cr.push(offset);
5471       return '\n';
5472     });
5473   }
5474
5475   const documents = [];
5476   let offset = 0;
5477
5478   do {
5479     const doc = new Document$3();
5480     const context = new ParseContext({
5481       src
5482     });
5483     offset = doc.parse(context, offset);
5484     documents.push(doc);
5485   } while (offset < src.length);
5486
5487   documents.setOrigRanges = () => {
5488     if (cr.length === 0) return false;
5489
5490     for (let i = 1; i < cr.length; ++i) cr[i] -= i;
5491
5492     let crOffset = 0;
5493
5494     for (let i = 0; i < documents.length; ++i) {
5495       crOffset = documents[i].setOrigRanges(cr, crOffset);
5496     }
5497
5498     cr.splice(0, cr.length);
5499     return true;
5500   };
5501
5502   documents.toString = () => documents.join('...\n');
5503
5504   return documents;
5505 }
5506
5507 parseCst$1.parse = parse$1;
5508
5509 var Document9b4560a1 = {};
5510
5511 var resolveSeqD03cb037 = {};
5512
5513 var PlainValue$4 = PlainValueEc8e588e;
5514
5515 function addCommentBefore(str, indent, comment) {
5516   if (!comment) return str;
5517   const cc = comment.replace(/[\s\S]^/gm, `$&${indent}#`);
5518   return `#${cc}\n${indent}${str}`;
5519 }
5520
5521 function addComment(str, indent, comment) {
5522   return !comment ? str : comment.indexOf('\n') === -1 ? `${str} #${comment}` : `${str}\n` + comment.replace(/^/gm, `${indent || ''}#`);
5523 }
5524
5525 class Node {}
5526
5527 function toJSON(value, arg, ctx) {
5528   if (Array.isArray(value)) return value.map((v, i) => toJSON(v, String(i), ctx));
5529
5530   if (value && typeof value.toJSON === 'function') {
5531     const anchor = ctx && ctx.anchors && ctx.anchors.get(value);
5532     if (anchor) ctx.onCreate = res => {
5533       anchor.res = res;
5534       delete ctx.onCreate;
5535     };
5536     const res = value.toJSON(arg, ctx);
5537     if (anchor && ctx.onCreate) ctx.onCreate(res);
5538     return res;
5539   }
5540
5541   if ((!ctx || !ctx.keep) && typeof value === 'bigint') return Number(value);
5542   return value;
5543 }
5544
5545 class Scalar extends Node {
5546   constructor(value) {
5547     super();
5548     this.value = value;
5549   }
5550
5551   toJSON(arg, ctx) {
5552     return ctx && ctx.keep ? this.value : toJSON(this.value, arg, ctx);
5553   }
5554
5555   toString() {
5556     return String(this.value);
5557   }
5558
5559 }
5560
5561 function collectionFromPath(schema, path, value) {
5562   let v = value;
5563
5564   for (let i = path.length - 1; i >= 0; --i) {
5565     const k = path[i];
5566
5567     if (Number.isInteger(k) && k >= 0) {
5568       const a = [];
5569       a[k] = v;
5570       v = a;
5571     } else {
5572       const o = {};
5573       Object.defineProperty(o, k, {
5574         value: v,
5575         writable: true,
5576         enumerable: true,
5577         configurable: true
5578       });
5579       v = o;
5580     }
5581   }
5582
5583   return schema.createNode(v, false);
5584 } // null, undefined, or an empty non-string iterable (e.g. [])
5585
5586
5587 const isEmptyPath = path => path == null || typeof path === 'object' && path[Symbol.iterator]().next().done;
5588
5589 class Collection extends Node {
5590   constructor(schema) {
5591     super();
5592
5593     PlainValue$4._defineProperty(this, "items", []);
5594
5595     this.schema = schema;
5596   }
5597
5598   addIn(path, value) {
5599     if (isEmptyPath(path)) this.add(value);else {
5600       const [key, ...rest] = path;
5601       const node = this.get(key, true);
5602       if (node instanceof Collection) node.addIn(rest, value);else if (node === undefined && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
5603     }
5604   }
5605
5606   deleteIn([key, ...rest]) {
5607     if (rest.length === 0) return this.delete(key);
5608     const node = this.get(key, true);
5609     if (node instanceof Collection) return node.deleteIn(rest);else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
5610   }
5611
5612   getIn([key, ...rest], keepScalar) {
5613     const node = this.get(key, true);
5614     if (rest.length === 0) return !keepScalar && node instanceof Scalar ? node.value : node;else return node instanceof Collection ? node.getIn(rest, keepScalar) : undefined;
5615   }
5616
5617   hasAllNullValues() {
5618     return this.items.every(node => {
5619       if (!node || node.type !== 'PAIR') return false;
5620       const n = node.value;
5621       return n == null || n instanceof Scalar && n.value == null && !n.commentBefore && !n.comment && !n.tag;
5622     });
5623   }
5624
5625   hasIn([key, ...rest]) {
5626     if (rest.length === 0) return this.has(key);
5627     const node = this.get(key, true);
5628     return node instanceof Collection ? node.hasIn(rest) : false;
5629   }
5630
5631   setIn([key, ...rest], value) {
5632     if (rest.length === 0) {
5633       this.set(key, value);
5634     } else {
5635       const node = this.get(key, true);
5636       if (node instanceof Collection) node.setIn(rest, value);else if (node === undefined && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
5637     }
5638   } // overridden in implementations
5639
5640   /* istanbul ignore next */
5641
5642
5643   toJSON() {
5644     return null;
5645   }
5646
5647   toString(ctx, {
5648     blockItem,
5649     flowChars,
5650     isMap,
5651     itemIndent
5652   }, onComment, onChompKeep) {
5653     const {
5654       indent,
5655       indentStep,
5656       stringify
5657     } = ctx;
5658     const inFlow = this.type === PlainValue$4.Type.FLOW_MAP || this.type === PlainValue$4.Type.FLOW_SEQ || ctx.inFlow;
5659     if (inFlow) itemIndent += indentStep;
5660     const allNullValues = isMap && this.hasAllNullValues();
5661     ctx = Object.assign({}, ctx, {
5662       allNullValues,
5663       indent: itemIndent,
5664       inFlow,
5665       type: null
5666     });
5667     let chompKeep = false;
5668     let hasItemWithNewLine = false;
5669     const nodes = this.items.reduce((nodes, item, i) => {
5670       let comment;
5671
5672       if (item) {
5673         if (!chompKeep && item.spaceBefore) nodes.push({
5674           type: 'comment',
5675           str: ''
5676         });
5677         if (item.commentBefore) item.commentBefore.match(/^.*$/gm).forEach(line => {
5678           nodes.push({
5679             type: 'comment',
5680             str: `#${line}`
5681           });
5682         });
5683         if (item.comment) comment = item.comment;
5684         if (inFlow && (!chompKeep && item.spaceBefore || item.commentBefore || item.comment || item.key && (item.key.commentBefore || item.key.comment) || item.value && (item.value.commentBefore || item.value.comment))) hasItemWithNewLine = true;
5685       }
5686
5687       chompKeep = false;
5688       let str = stringify(item, ctx, () => comment = null, () => chompKeep = true);
5689       if (inFlow && !hasItemWithNewLine && str.includes('\n')) hasItemWithNewLine = true;
5690       if (inFlow && i < this.items.length - 1) str += ',';
5691       str = addComment(str, itemIndent, comment);
5692       if (chompKeep && (comment || inFlow)) chompKeep = false;
5693       nodes.push({
5694         type: 'item',
5695         str
5696       });
5697       return nodes;
5698     }, []);
5699     let str;
5700
5701     if (nodes.length === 0) {
5702       str = flowChars.start + flowChars.end;
5703     } else if (inFlow) {
5704       const {
5705         start,
5706         end
5707       } = flowChars;
5708       const strings = nodes.map(n => n.str);
5709
5710       if (hasItemWithNewLine || strings.reduce((sum, str) => sum + str.length + 2, 2) > Collection.maxFlowStringSingleLineLength) {
5711         str = start;
5712
5713         for (const s of strings) {
5714           str += s ? `\n${indentStep}${indent}${s}` : '\n';
5715         }
5716
5717         str += `\n${indent}${end}`;
5718       } else {
5719         str = `${start} ${strings.join(' ')} ${end}`;
5720       }
5721     } else {
5722       const strings = nodes.map(blockItem);
5723       str = strings.shift();
5724
5725       for (const s of strings) str += s ? `\n${indent}${s}` : '\n';
5726     }
5727
5728     if (this.comment) {
5729       str += '\n' + this.comment.replace(/^/gm, `${indent}#`);
5730       if (onComment) onComment();
5731     } else if (chompKeep && onChompKeep) onChompKeep();
5732
5733     return str;
5734   }
5735
5736 }
5737
5738 PlainValue$4._defineProperty(Collection, "maxFlowStringSingleLineLength", 60);
5739
5740 function asItemIndex(key) {
5741   let idx = key instanceof Scalar ? key.value : key;
5742   if (idx && typeof idx === 'string') idx = Number(idx);
5743   return Number.isInteger(idx) && idx >= 0 ? idx : null;
5744 }
5745
5746 class YAMLSeq extends Collection {
5747   add(value) {
5748     this.items.push(value);
5749   }
5750
5751   delete(key) {
5752     const idx = asItemIndex(key);
5753     if (typeof idx !== 'number') return false;
5754     const del = this.items.splice(idx, 1);
5755     return del.length > 0;
5756   }
5757
5758   get(key, keepScalar) {
5759     const idx = asItemIndex(key);
5760     if (typeof idx !== 'number') return undefined;
5761     const it = this.items[idx];
5762     return !keepScalar && it instanceof Scalar ? it.value : it;
5763   }
5764
5765   has(key) {
5766     const idx = asItemIndex(key);
5767     return typeof idx === 'number' && idx < this.items.length;
5768   }
5769
5770   set(key, value) {
5771     const idx = asItemIndex(key);
5772     if (typeof idx !== 'number') throw new Error(`Expected a valid index, not ${key}.`);
5773     this.items[idx] = value;
5774   }
5775
5776   toJSON(_, ctx) {
5777     const seq = [];
5778     if (ctx && ctx.onCreate) ctx.onCreate(seq);
5779     let i = 0;
5780
5781     for (const item of this.items) seq.push(toJSON(item, String(i++), ctx));
5782
5783     return seq;
5784   }
5785
5786   toString(ctx, onComment, onChompKeep) {
5787     if (!ctx) return JSON.stringify(this);
5788     return super.toString(ctx, {
5789       blockItem: n => n.type === 'comment' ? n.str : `- ${n.str}`,
5790       flowChars: {
5791         start: '[',
5792         end: ']'
5793       },
5794       isMap: false,
5795       itemIndent: (ctx.indent || '') + '  '
5796     }, onComment, onChompKeep);
5797   }
5798
5799 }
5800
5801 const stringifyKey = (key, jsKey, ctx) => {
5802   if (jsKey === null) return '';
5803   if (typeof jsKey !== 'object') return String(jsKey);
5804   if (key instanceof Node && ctx && ctx.doc) return key.toString({
5805     anchors: Object.create(null),
5806     doc: ctx.doc,
5807     indent: '',
5808     indentStep: ctx.indentStep,
5809     inFlow: true,
5810     inStringifyKey: true,
5811     stringify: ctx.stringify
5812   });
5813   return JSON.stringify(jsKey);
5814 };
5815
5816 class Pair extends Node {
5817   constructor(key, value = null) {
5818     super();
5819     this.key = key;
5820     this.value = value;
5821     this.type = Pair.Type.PAIR;
5822   }
5823
5824   get commentBefore() {
5825     return this.key instanceof Node ? this.key.commentBefore : undefined;
5826   }
5827
5828   set commentBefore(cb) {
5829     if (this.key == null) this.key = new Scalar(null);
5830     if (this.key instanceof Node) this.key.commentBefore = cb;else {
5831       const msg = 'Pair.commentBefore is an alias for Pair.key.commentBefore. To set it, the key must be a Node.';
5832       throw new Error(msg);
5833     }
5834   }
5835
5836   addToJSMap(ctx, map) {
5837     const key = toJSON(this.key, '', ctx);
5838
5839     if (map instanceof Map) {
5840       const value = toJSON(this.value, key, ctx);
5841       map.set(key, value);
5842     } else if (map instanceof Set) {
5843       map.add(key);
5844     } else {
5845       const stringKey = stringifyKey(this.key, key, ctx);
5846       const value = toJSON(this.value, stringKey, ctx);
5847       if (stringKey in map) Object.defineProperty(map, stringKey, {
5848         value,
5849         writable: true,
5850         enumerable: true,
5851         configurable: true
5852       });else map[stringKey] = value;
5853     }
5854
5855     return map;
5856   }
5857
5858   toJSON(_, ctx) {
5859     const pair = ctx && ctx.mapAsMap ? new Map() : {};
5860     return this.addToJSMap(ctx, pair);
5861   }
5862
5863   toString(ctx, onComment, onChompKeep) {
5864     if (!ctx || !ctx.doc) return JSON.stringify(this);
5865     const {
5866       indent: indentSize,
5867       indentSeq,
5868       simpleKeys
5869     } = ctx.doc.options;
5870     let {
5871       key,
5872       value
5873     } = this;
5874     let keyComment = key instanceof Node && key.comment;
5875
5876     if (simpleKeys) {
5877       if (keyComment) {
5878         throw new Error('With simple keys, key nodes cannot have comments');
5879       }
5880
5881       if (key instanceof Collection) {
5882         const msg = 'With simple keys, collection cannot be used as a key value';
5883         throw new Error(msg);
5884       }
5885     }
5886
5887     let explicitKey = !simpleKeys && (!key || keyComment || (key instanceof Node ? key instanceof Collection || key.type === PlainValue$4.Type.BLOCK_FOLDED || key.type === PlainValue$4.Type.BLOCK_LITERAL : typeof key === 'object'));
5888     const {
5889       doc,
5890       indent,
5891       indentStep,
5892       stringify
5893     } = ctx;
5894     ctx = Object.assign({}, ctx, {
5895       implicitKey: !explicitKey,
5896       indent: indent + indentStep
5897     });
5898     let chompKeep = false;
5899     let str = stringify(key, ctx, () => keyComment = null, () => chompKeep = true);
5900     str = addComment(str, ctx.indent, keyComment);
5901
5902     if (!explicitKey && str.length > 1024) {
5903       if (simpleKeys) throw new Error('With simple keys, single line scalar must not span more than 1024 characters');
5904       explicitKey = true;
5905     }
5906
5907     if (ctx.allNullValues && !simpleKeys) {
5908       if (this.comment) {
5909         str = addComment(str, ctx.indent, this.comment);
5910         if (onComment) onComment();
5911       } else if (chompKeep && !keyComment && onChompKeep) onChompKeep();
5912
5913       return ctx.inFlow && !explicitKey ? str : `? ${str}`;
5914     }
5915
5916     str = explicitKey ? `? ${str}\n${indent}:` : `${str}:`;
5917
5918     if (this.comment) {
5919       // expected (but not strictly required) to be a single-line comment
5920       str = addComment(str, ctx.indent, this.comment);
5921       if (onComment) onComment();
5922     }
5923
5924     let vcb = '';
5925     let valueComment = null;
5926
5927     if (value instanceof Node) {
5928       if (value.spaceBefore) vcb = '\n';
5929
5930       if (value.commentBefore) {
5931         const cs = value.commentBefore.replace(/^/gm, `${ctx.indent}#`);
5932         vcb += `\n${cs}`;
5933       }
5934
5935       valueComment = value.comment;
5936     } else if (value && typeof value === 'object') {
5937       value = doc.schema.createNode(value, true);
5938     }
5939
5940     ctx.implicitKey = false;
5941     if (!explicitKey && !this.comment && value instanceof Scalar) ctx.indentAtStart = str.length + 1;
5942     chompKeep = false;
5943
5944     if (!indentSeq && indentSize >= 2 && !ctx.inFlow && !explicitKey && value instanceof YAMLSeq && value.type !== PlainValue$4.Type.FLOW_SEQ && !value.tag && !doc.anchors.getName(value)) {
5945       // If indentSeq === false, consider '- ' as part of indentation where possible
5946       ctx.indent = ctx.indent.substr(2);
5947     }
5948
5949     const valueStr = stringify(value, ctx, () => valueComment = null, () => chompKeep = true);
5950     let ws = ' ';
5951
5952     if (vcb || this.comment) {
5953       ws = `${vcb}\n${ctx.indent}`;
5954     } else if (!explicitKey && value instanceof Collection) {
5955       const flow = valueStr[0] === '[' || valueStr[0] === '{';
5956       if (!flow || valueStr.includes('\n')) ws = `\n${ctx.indent}`;
5957     } else if (valueStr[0] === '\n') ws = '';
5958
5959     if (chompKeep && !valueComment && onChompKeep) onChompKeep();
5960     return addComment(str + ws + valueStr, ctx.indent, valueComment);
5961   }
5962
5963 }
5964
5965 PlainValue$4._defineProperty(Pair, "Type", {
5966   PAIR: 'PAIR',
5967   MERGE_PAIR: 'MERGE_PAIR'
5968 });
5969
5970 const getAliasCount = (node, anchors) => {
5971   if (node instanceof Alias) {
5972     const anchor = anchors.get(node.source);
5973     return anchor.count * anchor.aliasCount;
5974   } else if (node instanceof Collection) {
5975     let count = 0;
5976
5977     for (const item of node.items) {
5978       const c = getAliasCount(item, anchors);
5979       if (c > count) count = c;
5980     }
5981
5982     return count;
5983   } else if (node instanceof Pair) {
5984     const kc = getAliasCount(node.key, anchors);
5985     const vc = getAliasCount(node.value, anchors);
5986     return Math.max(kc, vc);
5987   }
5988
5989   return 1;
5990 };
5991
5992 class Alias extends Node {
5993   static stringify({
5994     range,
5995     source
5996   }, {
5997     anchors,
5998     doc,
5999     implicitKey,
6000     inStringifyKey
6001   }) {
6002     let anchor = Object.keys(anchors).find(a => anchors[a] === source);
6003     if (!anchor && inStringifyKey) anchor = doc.anchors.getName(source) || doc.anchors.newName();
6004     if (anchor) return `*${anchor}${implicitKey ? ' ' : ''}`;
6005     const msg = doc.anchors.getName(source) ? 'Alias node must be after source node' : 'Source node not found for alias node';
6006     throw new Error(`${msg} [${range}]`);
6007   }
6008
6009   constructor(source) {
6010     super();
6011     this.source = source;
6012     this.type = PlainValue$4.Type.ALIAS;
6013   }
6014
6015   set tag(t) {
6016     throw new Error('Alias nodes cannot have tags');
6017   }
6018
6019   toJSON(arg, ctx) {
6020     if (!ctx) return toJSON(this.source, arg, ctx);
6021     const {
6022       anchors,
6023       maxAliasCount
6024     } = ctx;
6025     const anchor = anchors.get(this.source);
6026     /* istanbul ignore if */
6027
6028     if (!anchor || anchor.res === undefined) {
6029       const msg = 'This should not happen: Alias anchor was not resolved?';
6030       if (this.cstNode) throw new PlainValue$4.YAMLReferenceError(this.cstNode, msg);else throw new ReferenceError(msg);
6031     }
6032
6033     if (maxAliasCount >= 0) {
6034       anchor.count += 1;
6035       if (anchor.aliasCount === 0) anchor.aliasCount = getAliasCount(this.source, anchors);
6036
6037       if (anchor.count * anchor.aliasCount > maxAliasCount) {
6038         const msg = 'Excessive alias count indicates a resource exhaustion attack';
6039         if (this.cstNode) throw new PlainValue$4.YAMLReferenceError(this.cstNode, msg);else throw new ReferenceError(msg);
6040       }
6041     }
6042
6043     return anchor.res;
6044   } // Only called when stringifying an alias mapping key while constructing
6045   // Object output.
6046
6047
6048   toString(ctx) {
6049     return Alias.stringify(this, ctx);
6050   }
6051
6052 }
6053
6054 PlainValue$4._defineProperty(Alias, "default", true);
6055
6056 function findPair(items, key) {
6057   const k = key instanceof Scalar ? key.value : key;
6058
6059   for (const it of items) {
6060     if (it instanceof Pair) {
6061       if (it.key === key || it.key === k) return it;
6062       if (it.key && it.key.value === k) return it;
6063     }
6064   }
6065
6066   return undefined;
6067 }
6068
6069 class YAMLMap extends Collection {
6070   add(pair, overwrite) {
6071     if (!pair) pair = new Pair(pair);else if (!(pair instanceof Pair)) pair = new Pair(pair.key || pair, pair.value);
6072     const prev = findPair(this.items, pair.key);
6073     const sortEntries = this.schema && this.schema.sortMapEntries;
6074
6075     if (prev) {
6076       if (overwrite) prev.value = pair.value;else throw new Error(`Key ${pair.key} already set`);
6077     } else if (sortEntries) {
6078       const i = this.items.findIndex(item => sortEntries(pair, item) < 0);
6079       if (i === -1) this.items.push(pair);else this.items.splice(i, 0, pair);
6080     } else {
6081       this.items.push(pair);
6082     }
6083   }
6084
6085   delete(key) {
6086     const it = findPair(this.items, key);
6087     if (!it) return false;
6088     const del = this.items.splice(this.items.indexOf(it), 1);
6089     return del.length > 0;
6090   }
6091
6092   get(key, keepScalar) {
6093     const it = findPair(this.items, key);
6094     const node = it && it.value;
6095     return !keepScalar && node instanceof Scalar ? node.value : node;
6096   }
6097
6098   has(key) {
6099     return !!findPair(this.items, key);
6100   }
6101
6102   set(key, value) {
6103     this.add(new Pair(key, value), true);
6104   }
6105   /**
6106    * @param {*} arg ignored
6107    * @param {*} ctx Conversion context, originally set in Document#toJSON()
6108    * @param {Class} Type If set, forces the returned collection type
6109    * @returns {*} Instance of Type, Map, or Object
6110    */
6111
6112
6113   toJSON(_, ctx, Type) {
6114     const map = Type ? new Type() : ctx && ctx.mapAsMap ? new Map() : {};
6115     if (ctx && ctx.onCreate) ctx.onCreate(map);
6116
6117     for (const item of this.items) item.addToJSMap(ctx, map);
6118
6119     return map;
6120   }
6121
6122   toString(ctx, onComment, onChompKeep) {
6123     if (!ctx) return JSON.stringify(this);
6124
6125     for (const item of this.items) {
6126       if (!(item instanceof Pair)) throw new Error(`Map items must all be pairs; found ${JSON.stringify(item)} instead`);
6127     }
6128
6129     return super.toString(ctx, {
6130       blockItem: n => n.str,
6131       flowChars: {
6132         start: '{',
6133         end: '}'
6134       },
6135       isMap: true,
6136       itemIndent: ctx.indent || ''
6137     }, onComment, onChompKeep);
6138   }
6139
6140 }
6141
6142 const MERGE_KEY = '<<';
6143
6144 class Merge extends Pair {
6145   constructor(pair) {
6146     if (pair instanceof Pair) {
6147       let seq = pair.value;
6148
6149       if (!(seq instanceof YAMLSeq)) {
6150         seq = new YAMLSeq();
6151         seq.items.push(pair.value);
6152         seq.range = pair.value.range;
6153       }
6154
6155       super(pair.key, seq);
6156       this.range = pair.range;
6157     } else {
6158       super(new Scalar(MERGE_KEY), new YAMLSeq());
6159     }
6160
6161     this.type = Pair.Type.MERGE_PAIR;
6162   } // If the value associated with a merge key is a single mapping node, each of
6163   // its key/value pairs is inserted into the current mapping, unless the key
6164   // already exists in it. If the value associated with the merge key is a
6165   // sequence, then this sequence is expected to contain mapping nodes and each
6166   // of these nodes is merged in turn according to its order in the sequence.
6167   // Keys in mapping nodes earlier in the sequence override keys specified in
6168   // later mapping nodes. -- http://yaml.org/type/merge.html
6169
6170
6171   addToJSMap(ctx, map) {
6172     for (const {
6173       source
6174     } of this.value.items) {
6175       if (!(source instanceof YAMLMap)) throw new Error('Merge sources must be maps');
6176       const srcMap = source.toJSON(null, ctx, Map);
6177
6178       for (const [key, value] of srcMap) {
6179         if (map instanceof Map) {
6180           if (!map.has(key)) map.set(key, value);
6181         } else if (map instanceof Set) {
6182           map.add(key);
6183         } else if (!Object.prototype.hasOwnProperty.call(map, key)) {
6184           Object.defineProperty(map, key, {
6185             value,
6186             writable: true,
6187             enumerable: true,
6188             configurable: true
6189           });
6190         }
6191       }
6192     }
6193
6194     return map;
6195   }
6196
6197   toString(ctx, onComment) {
6198     const seq = this.value;
6199     if (seq.items.length > 1) return super.toString(ctx, onComment);
6200     this.value = seq.items[0];
6201     const str = super.toString(ctx, onComment);
6202     this.value = seq;
6203     return str;
6204   }
6205
6206 }
6207
6208 const binaryOptions = {
6209   defaultType: PlainValue$4.Type.BLOCK_LITERAL,
6210   lineWidth: 76
6211 };
6212 const boolOptions = {
6213   trueStr: 'true',
6214   falseStr: 'false'
6215 };
6216 const intOptions = {
6217   asBigInt: false
6218 };
6219 const nullOptions = {
6220   nullStr: 'null'
6221 };
6222 const strOptions = {
6223   defaultType: PlainValue$4.Type.PLAIN,
6224   doubleQuoted: {
6225     jsonEncoding: false,
6226     minMultiLineLength: 40
6227   },
6228   fold: {
6229     lineWidth: 80,
6230     minContentWidth: 20
6231   }
6232 };
6233
6234 function resolveScalar(str, tags, scalarFallback) {
6235   for (const {
6236     format,
6237     test,
6238     resolve
6239   } of tags) {
6240     if (test) {
6241       const match = str.match(test);
6242
6243       if (match) {
6244         let res = resolve.apply(null, match);
6245         if (!(res instanceof Scalar)) res = new Scalar(res);
6246         if (format) res.format = format;
6247         return res;
6248       }
6249     }
6250   }
6251
6252   if (scalarFallback) str = scalarFallback(str);
6253   return new Scalar(str);
6254 }
6255
6256 const FOLD_FLOW = 'flow';
6257 const FOLD_BLOCK = 'block';
6258 const FOLD_QUOTED = 'quoted'; // presumes i+1 is at the start of a line
6259 // returns index of last newline in more-indented block
6260
6261 const consumeMoreIndentedLines = (text, i) => {
6262   let ch = text[i + 1];
6263
6264   while (ch === ' ' || ch === '\t') {
6265     do {
6266       ch = text[i += 1];
6267     } while (ch && ch !== '\n');
6268
6269     ch = text[i + 1];
6270   }
6271
6272   return i;
6273 };
6274 /**
6275  * Tries to keep input at up to `lineWidth` characters, splitting only on spaces
6276  * not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are
6277  * terminated with `\n` and started with `indent`.
6278  *
6279  * @param {string} text
6280  * @param {string} indent
6281  * @param {string} [mode='flow'] `'block'` prevents more-indented lines
6282  *   from being folded; `'quoted'` allows for `\` escapes, including escaped
6283  *   newlines
6284  * @param {Object} options
6285  * @param {number} [options.indentAtStart] Accounts for leading contents on
6286  *   the first line, defaulting to `indent.length`
6287  * @param {number} [options.lineWidth=80]
6288  * @param {number} [options.minContentWidth=20] Allow highly indented lines to
6289  *   stretch the line width or indent content from the start
6290  * @param {function} options.onFold Called once if the text is folded
6291  * @param {function} options.onFold Called once if any line of text exceeds
6292  *   lineWidth characters
6293  */
6294
6295
6296 function foldFlowLines(text, indent, mode, {
6297   indentAtStart,
6298   lineWidth = 80,
6299   minContentWidth = 20,
6300   onFold,
6301   onOverflow
6302 }) {
6303   if (!lineWidth || lineWidth < 0) return text;
6304   const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
6305   if (text.length <= endStep) return text;
6306   const folds = [];
6307   const escapedFolds = {};
6308   let end = lineWidth - indent.length;
6309
6310   if (typeof indentAtStart === 'number') {
6311     if (indentAtStart > lineWidth - Math.max(2, minContentWidth)) folds.push(0);else end = lineWidth - indentAtStart;
6312   }
6313
6314   let split = undefined;
6315   let prev = undefined;
6316   let overflow = false;
6317   let i = -1;
6318   let escStart = -1;
6319   let escEnd = -1;
6320
6321   if (mode === FOLD_BLOCK) {
6322     i = consumeMoreIndentedLines(text, i);
6323     if (i !== -1) end = i + endStep;
6324   }
6325
6326   for (let ch; ch = text[i += 1];) {
6327     if (mode === FOLD_QUOTED && ch === '\\') {
6328       escStart = i;
6329
6330       switch (text[i + 1]) {
6331         case 'x':
6332           i += 3;
6333           break;
6334
6335         case 'u':
6336           i += 5;
6337           break;
6338
6339         case 'U':
6340           i += 9;
6341           break;
6342
6343         default:
6344           i += 1;
6345       }
6346
6347       escEnd = i;
6348     }
6349
6350     if (ch === '\n') {
6351       if (mode === FOLD_BLOCK) i = consumeMoreIndentedLines(text, i);
6352       end = i + endStep;
6353       split = undefined;
6354     } else {
6355       if (ch === ' ' && prev && prev !== ' ' && prev !== '\n' && prev !== '\t') {
6356         // space surrounded by non-space can be replaced with newline + indent
6357         const next = text[i + 1];
6358         if (next && next !== ' ' && next !== '\n' && next !== '\t') split = i;
6359       }
6360
6361       if (i >= end) {
6362         if (split) {
6363           folds.push(split);
6364           end = split + endStep;
6365           split = undefined;
6366         } else if (mode === FOLD_QUOTED) {
6367           // white-space collected at end may stretch past lineWidth
6368           while (prev === ' ' || prev === '\t') {
6369             prev = ch;
6370             ch = text[i += 1];
6371             overflow = true;
6372           } // Account for newline escape, but don't break preceding escape
6373
6374
6375           const j = i > escEnd + 1 ? i - 2 : escStart - 1; // Bail out if lineWidth & minContentWidth are shorter than an escape string
6376
6377           if (escapedFolds[j]) return text;
6378           folds.push(j);
6379           escapedFolds[j] = true;
6380           end = j + endStep;
6381           split = undefined;
6382         } else {
6383           overflow = true;
6384         }
6385       }
6386     }
6387
6388     prev = ch;
6389   }
6390
6391   if (overflow && onOverflow) onOverflow();
6392   if (folds.length === 0) return text;
6393   if (onFold) onFold();
6394   let res = text.slice(0, folds[0]);
6395
6396   for (let i = 0; i < folds.length; ++i) {
6397     const fold = folds[i];
6398     const end = folds[i + 1] || text.length;
6399     if (fold === 0) res = `\n${indent}${text.slice(0, end)}`;else {
6400       if (mode === FOLD_QUOTED && escapedFolds[fold]) res += `${text[fold]}\\`;
6401       res += `\n${indent}${text.slice(fold + 1, end)}`;
6402     }
6403   }
6404
6405   return res;
6406 }
6407
6408 const getFoldOptions = ({
6409   indentAtStart
6410 }) => indentAtStart ? Object.assign({
6411   indentAtStart
6412 }, strOptions.fold) : strOptions.fold; // Also checks for lines starting with %, as parsing the output as YAML 1.1 will
6413 // presume that's starting a new document.
6414
6415
6416 const containsDocumentMarker = str => /^(%|---|\.\.\.)/m.test(str);
6417
6418 function lineLengthOverLimit(str, lineWidth, indentLength) {
6419   if (!lineWidth || lineWidth < 0) return false;
6420   const limit = lineWidth - indentLength;
6421   const strLen = str.length;
6422   if (strLen <= limit) return false;
6423
6424   for (let i = 0, start = 0; i < strLen; ++i) {
6425     if (str[i] === '\n') {
6426       if (i - start > limit) return true;
6427       start = i + 1;
6428       if (strLen - start <= limit) return false;
6429     }
6430   }
6431
6432   return true;
6433 }
6434
6435 function doubleQuotedString(value, ctx) {
6436   const {
6437     implicitKey
6438   } = ctx;
6439   const {
6440     jsonEncoding,
6441     minMultiLineLength
6442   } = strOptions.doubleQuoted;
6443   const json = JSON.stringify(value);
6444   if (jsonEncoding) return json;
6445   const indent = ctx.indent || (containsDocumentMarker(value) ? '  ' : '');
6446   let str = '';
6447   let start = 0;
6448
6449   for (let i = 0, ch = json[i]; ch; ch = json[++i]) {
6450     if (ch === ' ' && json[i + 1] === '\\' && json[i + 2] === 'n') {
6451       // space before newline needs to be escaped to not be folded
6452       str += json.slice(start, i) + '\\ ';
6453       i += 1;
6454       start = i;
6455       ch = '\\';
6456     }
6457
6458     if (ch === '\\') switch (json[i + 1]) {
6459       case 'u':
6460         {
6461           str += json.slice(start, i);
6462           const code = json.substr(i + 2, 4);
6463
6464           switch (code) {
6465             case '0000':
6466               str += '\\0';
6467               break;
6468
6469             case '0007':
6470               str += '\\a';
6471               break;
6472
6473             case '000b':
6474               str += '\\v';
6475               break;
6476
6477             case '001b':
6478               str += '\\e';
6479               break;
6480
6481             case '0085':
6482               str += '\\N';
6483               break;
6484
6485             case '00a0':
6486               str += '\\_';
6487               break;
6488
6489             case '2028':
6490               str += '\\L';
6491               break;
6492
6493             case '2029':
6494               str += '\\P';
6495               break;
6496
6497             default:
6498               if (code.substr(0, 2) === '00') str += '\\x' + code.substr(2);else str += json.substr(i, 6);
6499           }
6500
6501           i += 5;
6502           start = i + 1;
6503         }
6504         break;
6505
6506       case 'n':
6507         if (implicitKey || json[i + 2] === '"' || json.length < minMultiLineLength) {
6508           i += 1;
6509         } else {
6510           // folding will eat first newline
6511           str += json.slice(start, i) + '\n\n';
6512
6513           while (json[i + 2] === '\\' && json[i + 3] === 'n' && json[i + 4] !== '"') {
6514             str += '\n';
6515             i += 2;
6516           }
6517
6518           str += indent; // space after newline needs to be escaped to not be folded
6519
6520           if (json[i + 2] === ' ') str += '\\';
6521           i += 1;
6522           start = i + 1;
6523         }
6524
6525         break;
6526
6527       default:
6528         i += 1;
6529     }
6530   }
6531
6532   str = start ? str + json.slice(start) : json;
6533   return implicitKey ? str : foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx));
6534 }
6535
6536 function singleQuotedString(value, ctx) {
6537   if (ctx.implicitKey) {
6538     if (/\n/.test(value)) return doubleQuotedString(value, ctx);
6539   } else {
6540     // single quoted string can't have leading or trailing whitespace around newline
6541     if (/[ \t]\n|\n[ \t]/.test(value)) return doubleQuotedString(value, ctx);
6542   }
6543
6544   const indent = ctx.indent || (containsDocumentMarker(value) ? '  ' : '');
6545   const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
6546   return ctx.implicitKey ? res : foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx));
6547 }
6548
6549 function blockString({
6550   comment,
6551   type,
6552   value
6553 }, ctx, onComment, onChompKeep) {
6554   // 1. Block can't end in whitespace unless the last line is non-empty.
6555   // 2. Strings consisting of only whitespace are best rendered explicitly.
6556   if (/\n[\t ]+$/.test(value) || /^\s*$/.test(value)) {
6557     return doubleQuotedString(value, ctx);
6558   }
6559
6560   const indent = ctx.indent || (ctx.forceBlockIndent || containsDocumentMarker(value) ? '  ' : '');
6561   const indentSize = indent ? '2' : '1'; // root is at -1
6562
6563   const literal = type === PlainValue$4.Type.BLOCK_FOLDED ? false : type === PlainValue$4.Type.BLOCK_LITERAL ? true : !lineLengthOverLimit(value, strOptions.fold.lineWidth, indent.length);
6564   let header = literal ? '|' : '>';
6565   if (!value) return header + '\n';
6566   let wsStart = '';
6567   let wsEnd = '';
6568   value = value.replace(/[\n\t ]*$/, ws => {
6569     const n = ws.indexOf('\n');
6570
6571     if (n === -1) {
6572       header += '-'; // strip
6573     } else if (value === ws || n !== ws.length - 1) {
6574       header += '+'; // keep
6575
6576       if (onChompKeep) onChompKeep();
6577     }
6578
6579     wsEnd = ws.replace(/\n$/, '');
6580     return '';
6581   }).replace(/^[\n ]*/, ws => {
6582     if (ws.indexOf(' ') !== -1) header += indentSize;
6583     const m = ws.match(/ +$/);
6584
6585     if (m) {
6586       wsStart = ws.slice(0, -m[0].length);
6587       return m[0];
6588     } else {
6589       wsStart = ws;
6590       return '';
6591     }
6592   });
6593   if (wsEnd) wsEnd = wsEnd.replace(/\n+(?!\n|$)/g, `$&${indent}`);
6594   if (wsStart) wsStart = wsStart.replace(/\n+/g, `$&${indent}`);
6595
6596   if (comment) {
6597     header += ' #' + comment.replace(/ ?[\r\n]+/g, ' ');
6598     if (onComment) onComment();
6599   }
6600
6601   if (!value) return `${header}${indentSize}\n${indent}${wsEnd}`;
6602
6603   if (literal) {
6604     value = value.replace(/\n+/g, `$&${indent}`);
6605     return `${header}\n${indent}${wsStart}${value}${wsEnd}`;
6606   }
6607
6608   value = value.replace(/\n+/g, '\n$&').replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
6609   //         ^ ind.line  ^ empty     ^ capture next empty lines only at end of indent
6610   .replace(/\n+/g, `$&${indent}`);
6611   const body = foldFlowLines(`${wsStart}${value}${wsEnd}`, indent, FOLD_BLOCK, strOptions.fold);
6612   return `${header}\n${indent}${body}`;
6613 }
6614
6615 function plainString(item, ctx, onComment, onChompKeep) {
6616   const {
6617     comment,
6618     type,
6619     value
6620   } = item;
6621   const {
6622     actualString,
6623     implicitKey,
6624     indent,
6625     inFlow
6626   } = ctx;
6627
6628   if (implicitKey && /[\n[\]{},]/.test(value) || inFlow && /[[\]{},]/.test(value)) {
6629     return doubleQuotedString(value, ctx);
6630   }
6631
6632   if (!value || /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
6633     // not allowed:
6634     // - empty string, '-' or '?'
6635     // - start with an indicator character (except [?:-]) or /[?-] /
6636     // - '\n ', ': ' or ' \n' anywhere
6637     // - '#' not preceded by a non-space char
6638     // - end with ' ' or ':'
6639     return implicitKey || inFlow || value.indexOf('\n') === -1 ? value.indexOf('"') !== -1 && value.indexOf("'") === -1 ? singleQuotedString(value, ctx) : doubleQuotedString(value, ctx) : blockString(item, ctx, onComment, onChompKeep);
6640   }
6641
6642   if (!implicitKey && !inFlow && type !== PlainValue$4.Type.PLAIN && value.indexOf('\n') !== -1) {
6643     // Where allowed & type not set explicitly, prefer block style for multiline strings
6644     return blockString(item, ctx, onComment, onChompKeep);
6645   }
6646
6647   if (indent === '' && containsDocumentMarker(value)) {
6648     ctx.forceBlockIndent = true;
6649     return blockString(item, ctx, onComment, onChompKeep);
6650   }
6651
6652   const str = value.replace(/\n+/g, `$&\n${indent}`); // Verify that output will be parsed as a string, as e.g. plain numbers and
6653   // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
6654   // and others in v1.1.
6655
6656   if (actualString) {
6657     const {
6658       tags
6659     } = ctx.doc.schema;
6660     const resolved = resolveScalar(str, tags, tags.scalarFallback).value;
6661     if (typeof resolved !== 'string') return doubleQuotedString(value, ctx);
6662   }
6663
6664   const body = implicitKey ? str : foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx));
6665
6666   if (comment && !inFlow && (body.indexOf('\n') !== -1 || comment.indexOf('\n') !== -1)) {
6667     if (onComment) onComment();
6668     return addCommentBefore(body, indent, comment);
6669   }
6670
6671   return body;
6672 }
6673
6674 function stringifyString(item, ctx, onComment, onChompKeep) {
6675   const {
6676     defaultType
6677   } = strOptions;
6678   const {
6679     implicitKey,
6680     inFlow
6681   } = ctx;
6682   let {
6683     type,
6684     value
6685   } = item;
6686
6687   if (typeof value !== 'string') {
6688     value = String(value);
6689     item = Object.assign({}, item, {
6690       value
6691     });
6692   }
6693
6694   const _stringify = _type => {
6695     switch (_type) {
6696       case PlainValue$4.Type.BLOCK_FOLDED:
6697       case PlainValue$4.Type.BLOCK_LITERAL:
6698         return blockString(item, ctx, onComment, onChompKeep);
6699
6700       case PlainValue$4.Type.QUOTE_DOUBLE:
6701         return doubleQuotedString(value, ctx);
6702
6703       case PlainValue$4.Type.QUOTE_SINGLE:
6704         return singleQuotedString(value, ctx);
6705
6706       case PlainValue$4.Type.PLAIN:
6707         return plainString(item, ctx, onComment, onChompKeep);
6708
6709       default:
6710         return null;
6711     }
6712   };
6713
6714   if (type !== PlainValue$4.Type.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f]/.test(value)) {
6715     // force double quotes on control characters
6716     type = PlainValue$4.Type.QUOTE_DOUBLE;
6717   } else if ((implicitKey || inFlow) && (type === PlainValue$4.Type.BLOCK_FOLDED || type === PlainValue$4.Type.BLOCK_LITERAL)) {
6718     // should not happen; blocks are not valid inside flow containers
6719     type = PlainValue$4.Type.QUOTE_DOUBLE;
6720   }
6721
6722   let res = _stringify(type);
6723
6724   if (res === null) {
6725     res = _stringify(defaultType);
6726     if (res === null) throw new Error(`Unsupported default string type ${defaultType}`);
6727   }
6728
6729   return res;
6730 }
6731
6732 function stringifyNumber({
6733   format,
6734   minFractionDigits,
6735   tag,
6736   value
6737 }) {
6738   if (typeof value === 'bigint') return String(value);
6739   if (!isFinite(value)) return isNaN(value) ? '.nan' : value < 0 ? '-.inf' : '.inf';
6740   let n = JSON.stringify(value);
6741
6742   if (!format && minFractionDigits && (!tag || tag === 'tag:yaml.org,2002:float') && /^\d/.test(n)) {
6743     let i = n.indexOf('.');
6744
6745     if (i < 0) {
6746       i = n.length;
6747       n += '.';
6748     }
6749
6750     let d = minFractionDigits - (n.length - i - 1);
6751
6752     while (d-- > 0) n += '0';
6753   }
6754
6755   return n;
6756 }
6757
6758 function checkFlowCollectionEnd(errors, cst) {
6759   let char, name;
6760
6761   switch (cst.type) {
6762     case PlainValue$4.Type.FLOW_MAP:
6763       char = '}';
6764       name = 'flow map';
6765       break;
6766
6767     case PlainValue$4.Type.FLOW_SEQ:
6768       char = ']';
6769       name = 'flow sequence';
6770       break;
6771
6772     default:
6773       errors.push(new PlainValue$4.YAMLSemanticError(cst, 'Not a flow collection!?'));
6774       return;
6775   }
6776
6777   let lastItem;
6778
6779   for (let i = cst.items.length - 1; i >= 0; --i) {
6780     const item = cst.items[i];
6781
6782     if (!item || item.type !== PlainValue$4.Type.COMMENT) {
6783       lastItem = item;
6784       break;
6785     }
6786   }
6787
6788   if (lastItem && lastItem.char !== char) {
6789     const msg = `Expected ${name} to end with ${char}`;
6790     let err;
6791
6792     if (typeof lastItem.offset === 'number') {
6793       err = new PlainValue$4.YAMLSemanticError(cst, msg);
6794       err.offset = lastItem.offset + 1;
6795     } else {
6796       err = new PlainValue$4.YAMLSemanticError(lastItem, msg);
6797       if (lastItem.range && lastItem.range.end) err.offset = lastItem.range.end - lastItem.range.start;
6798     }
6799
6800     errors.push(err);
6801   }
6802 }
6803
6804 function checkFlowCommentSpace(errors, comment) {
6805   const prev = comment.context.src[comment.range.start - 1];
6806
6807   if (prev !== '\n' && prev !== '\t' && prev !== ' ') {
6808     const msg = 'Comments must be separated from other tokens by white space characters';
6809     errors.push(new PlainValue$4.YAMLSemanticError(comment, msg));
6810   }
6811 }
6812
6813 function getLongKeyError(source, key) {
6814   const sk = String(key);
6815   const k = sk.substr(0, 8) + '...' + sk.substr(-8);
6816   return new PlainValue$4.YAMLSemanticError(source, `The "${k}" key is too long`);
6817 }
6818
6819 function resolveComments(collection, comments) {
6820   for (const {
6821     afterKey,
6822     before,
6823     comment
6824   } of comments) {
6825     let item = collection.items[before];
6826
6827     if (!item) {
6828       if (comment !== undefined) {
6829         if (collection.comment) collection.comment += '\n' + comment;else collection.comment = comment;
6830       }
6831     } else {
6832       if (afterKey && item.value) item = item.value;
6833
6834       if (comment === undefined) {
6835         if (afterKey || !item.commentBefore) item.spaceBefore = true;
6836       } else {
6837         if (item.commentBefore) item.commentBefore += '\n' + comment;else item.commentBefore = comment;
6838       }
6839     }
6840   }
6841 } // on error, will return { str: string, errors: Error[] }
6842
6843
6844 function resolveString(doc, node) {
6845   const res = node.strValue;
6846   if (!res) return '';
6847   if (typeof res === 'string') return res;
6848   res.errors.forEach(error => {
6849     if (!error.source) error.source = node;
6850     doc.errors.push(error);
6851   });
6852   return res.str;
6853 }
6854
6855 function resolveTagHandle(doc, node) {
6856   const {
6857     handle,
6858     suffix
6859   } = node.tag;
6860   let prefix = doc.tagPrefixes.find(p => p.handle === handle);
6861
6862   if (!prefix) {
6863     const dtp = doc.getDefaults().tagPrefixes;
6864     if (dtp) prefix = dtp.find(p => p.handle === handle);
6865     if (!prefix) throw new PlainValue$4.YAMLSemanticError(node, `The ${handle} tag handle is non-default and was not declared.`);
6866   }
6867
6868   if (!suffix) throw new PlainValue$4.YAMLSemanticError(node, `The ${handle} tag has no suffix.`);
6869
6870   if (handle === '!' && (doc.version || doc.options.version) === '1.0') {
6871     if (suffix[0] === '^') {
6872       doc.warnings.push(new PlainValue$4.YAMLWarning(node, 'YAML 1.0 ^ tag expansion is not supported'));
6873       return suffix;
6874     }
6875
6876     if (/[:/]/.test(suffix)) {
6877       // word/foo -> tag:word.yaml.org,2002:foo
6878       const vocab = suffix.match(/^([a-z0-9-]+)\/(.*)/i);
6879       return vocab ? `tag:${vocab[1]}.yaml.org,2002:${vocab[2]}` : `tag:${suffix}`;
6880     }
6881   }
6882
6883   return prefix.prefix + decodeURIComponent(suffix);
6884 }
6885
6886 function resolveTagName(doc, node) {
6887   const {
6888     tag,
6889     type
6890   } = node;
6891   let nonSpecific = false;
6892
6893   if (tag) {
6894     const {
6895       handle,
6896       suffix,
6897       verbatim
6898     } = tag;
6899
6900     if (verbatim) {
6901       if (verbatim !== '!' && verbatim !== '!!') return verbatim;
6902       const msg = `Verbatim tags aren't resolved, so ${verbatim} is invalid.`;
6903       doc.errors.push(new PlainValue$4.YAMLSemanticError(node, msg));
6904     } else if (handle === '!' && !suffix) {
6905       nonSpecific = true;
6906     } else {
6907       try {
6908         return resolveTagHandle(doc, node);
6909       } catch (error) {
6910         doc.errors.push(error);
6911       }
6912     }
6913   }
6914
6915   switch (type) {
6916     case PlainValue$4.Type.BLOCK_FOLDED:
6917     case PlainValue$4.Type.BLOCK_LITERAL:
6918     case PlainValue$4.Type.QUOTE_DOUBLE:
6919     case PlainValue$4.Type.QUOTE_SINGLE:
6920       return PlainValue$4.defaultTags.STR;
6921
6922     case PlainValue$4.Type.FLOW_MAP:
6923     case PlainValue$4.Type.MAP:
6924       return PlainValue$4.defaultTags.MAP;
6925
6926     case PlainValue$4.Type.FLOW_SEQ:
6927     case PlainValue$4.Type.SEQ:
6928       return PlainValue$4.defaultTags.SEQ;
6929
6930     case PlainValue$4.Type.PLAIN:
6931       return nonSpecific ? PlainValue$4.defaultTags.STR : null;
6932
6933     default:
6934       return null;
6935   }
6936 }
6937
6938 function resolveByTagName(doc, node, tagName) {
6939   const {
6940     tags
6941   } = doc.schema;
6942   const matchWithTest = [];
6943
6944   for (const tag of tags) {
6945     if (tag.tag === tagName) {
6946       if (tag.test) matchWithTest.push(tag);else {
6947         const res = tag.resolve(doc, node);
6948         return res instanceof Collection ? res : new Scalar(res);
6949       }
6950     }
6951   }
6952
6953   const str = resolveString(doc, node);
6954   if (typeof str === 'string' && matchWithTest.length > 0) return resolveScalar(str, matchWithTest, tags.scalarFallback);
6955   return null;
6956 }
6957
6958 function getFallbackTagName({
6959   type
6960 }) {
6961   switch (type) {
6962     case PlainValue$4.Type.FLOW_MAP:
6963     case PlainValue$4.Type.MAP:
6964       return PlainValue$4.defaultTags.MAP;
6965
6966     case PlainValue$4.Type.FLOW_SEQ:
6967     case PlainValue$4.Type.SEQ:
6968       return PlainValue$4.defaultTags.SEQ;
6969
6970     default:
6971       return PlainValue$4.defaultTags.STR;
6972   }
6973 }
6974
6975 function resolveTag(doc, node, tagName) {
6976   try {
6977     const res = resolveByTagName(doc, node, tagName);
6978
6979     if (res) {
6980       if (tagName && node.tag) res.tag = tagName;
6981       return res;
6982     }
6983   } catch (error) {
6984     /* istanbul ignore if */
6985     if (!error.source) error.source = node;
6986     doc.errors.push(error);
6987     return null;
6988   }
6989
6990   try {
6991     const fallback = getFallbackTagName(node);
6992     if (!fallback) throw new Error(`The tag ${tagName} is unavailable`);
6993     const msg = `The tag ${tagName} is unavailable, falling back to ${fallback}`;
6994     doc.warnings.push(new PlainValue$4.YAMLWarning(node, msg));
6995     const res = resolveByTagName(doc, node, fallback);
6996     res.tag = tagName;
6997     return res;
6998   } catch (error) {
6999     const refError = new PlainValue$4.YAMLReferenceError(node, error.message);
7000     refError.stack = error.stack;
7001     doc.errors.push(refError);
7002     return null;
7003   }
7004 }
7005
7006 const isCollectionItem = node => {
7007   if (!node) return false;
7008   const {
7009     type
7010   } = node;
7011   return type === PlainValue$4.Type.MAP_KEY || type === PlainValue$4.Type.MAP_VALUE || type === PlainValue$4.Type.SEQ_ITEM;
7012 };
7013
7014 function resolveNodeProps(errors, node) {
7015   const comments = {
7016     before: [],
7017     after: []
7018   };
7019   let hasAnchor = false;
7020   let hasTag = false;
7021   const props = isCollectionItem(node.context.parent) ? node.context.parent.props.concat(node.props) : node.props;
7022
7023   for (const {
7024     start,
7025     end
7026   } of props) {
7027     switch (node.context.src[start]) {
7028       case PlainValue$4.Char.COMMENT:
7029         {
7030           if (!node.commentHasRequiredWhitespace(start)) {
7031             const msg = 'Comments must be separated from other tokens by white space characters';
7032             errors.push(new PlainValue$4.YAMLSemanticError(node, msg));
7033           }
7034
7035           const {
7036             header,
7037             valueRange
7038           } = node;
7039           const cc = valueRange && (start > valueRange.start || header && start > header.start) ? comments.after : comments.before;
7040           cc.push(node.context.src.slice(start + 1, end));
7041           break;
7042         }
7043       // Actual anchor & tag resolution is handled by schema, here we just complain
7044
7045       case PlainValue$4.Char.ANCHOR:
7046         if (hasAnchor) {
7047           const msg = 'A node can have at most one anchor';
7048           errors.push(new PlainValue$4.YAMLSemanticError(node, msg));
7049         }
7050
7051         hasAnchor = true;
7052         break;
7053
7054       case PlainValue$4.Char.TAG:
7055         if (hasTag) {
7056           const msg = 'A node can have at most one tag';
7057           errors.push(new PlainValue$4.YAMLSemanticError(node, msg));
7058         }
7059
7060         hasTag = true;
7061         break;
7062     }
7063   }
7064
7065   return {
7066     comments,
7067     hasAnchor,
7068     hasTag
7069   };
7070 }
7071
7072 function resolveNodeValue(doc, node) {
7073   const {
7074     anchors,
7075     errors,
7076     schema
7077   } = doc;
7078
7079   if (node.type === PlainValue$4.Type.ALIAS) {
7080     const name = node.rawValue;
7081     const src = anchors.getNode(name);
7082
7083     if (!src) {
7084       const msg = `Aliased anchor not found: ${name}`;
7085       errors.push(new PlainValue$4.YAMLReferenceError(node, msg));
7086       return null;
7087     } // Lazy resolution for circular references
7088
7089
7090     const res = new Alias(src);
7091
7092     anchors._cstAliases.push(res);
7093
7094     return res;
7095   }
7096
7097   const tagName = resolveTagName(doc, node);
7098   if (tagName) return resolveTag(doc, node, tagName);
7099
7100   if (node.type !== PlainValue$4.Type.PLAIN) {
7101     const msg = `Failed to resolve ${node.type} node here`;
7102     errors.push(new PlainValue$4.YAMLSyntaxError(node, msg));
7103     return null;
7104   }
7105
7106   try {
7107     const str = resolveString(doc, node);
7108     return resolveScalar(str, schema.tags, schema.tags.scalarFallback);
7109   } catch (error) {
7110     if (!error.source) error.source = node;
7111     errors.push(error);
7112     return null;
7113   }
7114 } // sets node.resolved on success
7115
7116
7117 function resolveNode(doc, node) {
7118   if (!node) return null;
7119   if (node.error) doc.errors.push(node.error);
7120   const {
7121     comments,
7122     hasAnchor,
7123     hasTag
7124   } = resolveNodeProps(doc.errors, node);
7125
7126   if (hasAnchor) {
7127     const {
7128       anchors
7129     } = doc;
7130     const name = node.anchor;
7131     const prev = anchors.getNode(name); // At this point, aliases for any preceding node with the same anchor
7132     // name have already been resolved, so it may safely be renamed.
7133
7134     if (prev) anchors.map[anchors.newName(name)] = prev; // During parsing, we need to store the CST node in anchors.map as
7135     // anchors need to be available during resolution to allow for
7136     // circular references.
7137
7138     anchors.map[name] = node;
7139   }
7140
7141   if (node.type === PlainValue$4.Type.ALIAS && (hasAnchor || hasTag)) {
7142     const msg = 'An alias node must not specify any properties';
7143     doc.errors.push(new PlainValue$4.YAMLSemanticError(node, msg));
7144   }
7145
7146   const res = resolveNodeValue(doc, node);
7147
7148   if (res) {
7149     res.range = [node.range.start, node.range.end];
7150     if (doc.options.keepCstNodes) res.cstNode = node;
7151     if (doc.options.keepNodeTypes) res.type = node.type;
7152     const cb = comments.before.join('\n');
7153
7154     if (cb) {
7155       res.commentBefore = res.commentBefore ? `${res.commentBefore}\n${cb}` : cb;
7156     }
7157
7158     const ca = comments.after.join('\n');
7159     if (ca) res.comment = res.comment ? `${res.comment}\n${ca}` : ca;
7160   }
7161
7162   return node.resolved = res;
7163 }
7164
7165 function resolveMap(doc, cst) {
7166   if (cst.type !== PlainValue$4.Type.MAP && cst.type !== PlainValue$4.Type.FLOW_MAP) {
7167     const msg = `A ${cst.type} node cannot be resolved as a mapping`;
7168     doc.errors.push(new PlainValue$4.YAMLSyntaxError(cst, msg));
7169     return null;
7170   }
7171
7172   const {
7173     comments,
7174     items
7175   } = cst.type === PlainValue$4.Type.FLOW_MAP ? resolveFlowMapItems(doc, cst) : resolveBlockMapItems(doc, cst);
7176   const map = new YAMLMap();
7177   map.items = items;
7178   resolveComments(map, comments);
7179   let hasCollectionKey = false;
7180
7181   for (let i = 0; i < items.length; ++i) {
7182     const {
7183       key: iKey
7184     } = items[i];
7185     if (iKey instanceof Collection) hasCollectionKey = true;
7186
7187     if (doc.schema.merge && iKey && iKey.value === MERGE_KEY) {
7188       items[i] = new Merge(items[i]);
7189       const sources = items[i].value.items;
7190       let error = null;
7191       sources.some(node => {
7192         if (node instanceof Alias) {
7193           // During parsing, alias sources are CST nodes; to account for
7194           // circular references their resolved values can't be used here.
7195           const {
7196             type
7197           } = node.source;
7198           if (type === PlainValue$4.Type.MAP || type === PlainValue$4.Type.FLOW_MAP) return false;
7199           return error = 'Merge nodes aliases can only point to maps';
7200         }
7201
7202         return error = 'Merge nodes can only have Alias nodes as values';
7203       });
7204       if (error) doc.errors.push(new PlainValue$4.YAMLSemanticError(cst, error));
7205     } else {
7206       for (let j = i + 1; j < items.length; ++j) {
7207         const {
7208           key: jKey
7209         } = items[j];
7210
7211         if (iKey === jKey || iKey && jKey && Object.prototype.hasOwnProperty.call(iKey, 'value') && iKey.value === jKey.value) {
7212           const msg = `Map keys must be unique; "${iKey}" is repeated`;
7213           doc.errors.push(new PlainValue$4.YAMLSemanticError(cst, msg));
7214           break;
7215         }
7216       }
7217     }
7218   }
7219
7220   if (hasCollectionKey && !doc.options.mapAsMap) {
7221     const warn = 'Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.';
7222     doc.warnings.push(new PlainValue$4.YAMLWarning(cst, warn));
7223   }
7224
7225   cst.resolved = map;
7226   return map;
7227 }
7228
7229 const valueHasPairComment = ({
7230   context: {
7231     lineStart,
7232     node,
7233     src
7234   },
7235   props
7236 }) => {
7237   if (props.length === 0) return false;
7238   const {
7239     start
7240   } = props[0];
7241   if (node && start > node.valueRange.start) return false;
7242   if (src[start] !== PlainValue$4.Char.COMMENT) return false;
7243
7244   for (let i = lineStart; i < start; ++i) if (src[i] === '\n') return false;
7245
7246   return true;
7247 };
7248
7249 function resolvePairComment(item, pair) {
7250   if (!valueHasPairComment(item)) return;
7251   const comment = item.getPropValue(0, PlainValue$4.Char.COMMENT, true);
7252   let found = false;
7253   const cb = pair.value.commentBefore;
7254
7255   if (cb && cb.startsWith(comment)) {
7256     pair.value.commentBefore = cb.substr(comment.length + 1);
7257     found = true;
7258   } else {
7259     const cc = pair.value.comment;
7260
7261     if (!item.node && cc && cc.startsWith(comment)) {
7262       pair.value.comment = cc.substr(comment.length + 1);
7263       found = true;
7264     }
7265   }
7266
7267   if (found) pair.comment = comment;
7268 }
7269
7270 function resolveBlockMapItems(doc, cst) {
7271   const comments = [];
7272   const items = [];
7273   let key = undefined;
7274   let keyStart = null;
7275
7276   for (let i = 0; i < cst.items.length; ++i) {
7277     const item = cst.items[i];
7278
7279     switch (item.type) {
7280       case PlainValue$4.Type.BLANK_LINE:
7281         comments.push({
7282           afterKey: !!key,
7283           before: items.length
7284         });
7285         break;
7286
7287       case PlainValue$4.Type.COMMENT:
7288         comments.push({
7289           afterKey: !!key,
7290           before: items.length,
7291           comment: item.comment
7292         });
7293         break;
7294
7295       case PlainValue$4.Type.MAP_KEY:
7296         if (key !== undefined) items.push(new Pair(key));
7297         if (item.error) doc.errors.push(item.error);
7298         key = resolveNode(doc, item.node);
7299         keyStart = null;
7300         break;
7301
7302       case PlainValue$4.Type.MAP_VALUE:
7303         {
7304           if (key === undefined) key = null;
7305           if (item.error) doc.errors.push(item.error);
7306
7307           if (!item.context.atLineStart && item.node && item.node.type === PlainValue$4.Type.MAP && !item.node.context.atLineStart) {
7308             const msg = 'Nested mappings are not allowed in compact mappings';
7309             doc.errors.push(new PlainValue$4.YAMLSemanticError(item.node, msg));
7310           }
7311
7312           let valueNode = item.node;
7313
7314           if (!valueNode && item.props.length > 0) {
7315             // Comments on an empty mapping value need to be preserved, so we
7316             // need to construct a minimal empty node here to use instead of the
7317             // missing `item.node`. -- eemeli/yaml#19
7318             valueNode = new PlainValue$4.PlainValue(PlainValue$4.Type.PLAIN, []);
7319             valueNode.context = {
7320               parent: item,
7321               src: item.context.src
7322             };
7323             const pos = item.range.start + 1;
7324             valueNode.range = {
7325               start: pos,
7326               end: pos
7327             };
7328             valueNode.valueRange = {
7329               start: pos,
7330               end: pos
7331             };
7332
7333             if (typeof item.range.origStart === 'number') {
7334               const origPos = item.range.origStart + 1;
7335               valueNode.range.origStart = valueNode.range.origEnd = origPos;
7336               valueNode.valueRange.origStart = valueNode.valueRange.origEnd = origPos;
7337             }
7338           }
7339
7340           const pair = new Pair(key, resolveNode(doc, valueNode));
7341           resolvePairComment(item, pair);
7342           items.push(pair);
7343
7344           if (key && typeof keyStart === 'number') {
7345             if (item.range.start > keyStart + 1024) doc.errors.push(getLongKeyError(cst, key));
7346           }
7347
7348           key = undefined;
7349           keyStart = null;
7350         }
7351         break;
7352
7353       default:
7354         if (key !== undefined) items.push(new Pair(key));
7355         key = resolveNode(doc, item);
7356         keyStart = item.range.start;
7357         if (item.error) doc.errors.push(item.error);
7358
7359         next: for (let j = i + 1;; ++j) {
7360           const nextItem = cst.items[j];
7361
7362           switch (nextItem && nextItem.type) {
7363             case PlainValue$4.Type.BLANK_LINE:
7364             case PlainValue$4.Type.COMMENT:
7365               continue next;
7366
7367             case PlainValue$4.Type.MAP_VALUE:
7368               break next;
7369
7370             default:
7371               {
7372                 const msg = 'Implicit map keys need to be followed by map values';
7373                 doc.errors.push(new PlainValue$4.YAMLSemanticError(item, msg));
7374                 break next;
7375               }
7376           }
7377         }
7378
7379         if (item.valueRangeContainsNewline) {
7380           const msg = 'Implicit map keys need to be on a single line';
7381           doc.errors.push(new PlainValue$4.YAMLSemanticError(item, msg));
7382         }
7383
7384     }
7385   }
7386
7387   if (key !== undefined) items.push(new Pair(key));
7388   return {
7389     comments,
7390     items
7391   };
7392 }
7393
7394 function resolveFlowMapItems(doc, cst) {
7395   const comments = [];
7396   const items = [];
7397   let key = undefined;
7398   let explicitKey = false;
7399   let next = '{';
7400
7401   for (let i = 0; i < cst.items.length; ++i) {
7402     const item = cst.items[i];
7403
7404     if (typeof item.char === 'string') {
7405       const {
7406         char,
7407         offset
7408       } = item;
7409
7410       if (char === '?' && key === undefined && !explicitKey) {
7411         explicitKey = true;
7412         next = ':';
7413         continue;
7414       }
7415
7416       if (char === ':') {
7417         if (key === undefined) key = null;
7418
7419         if (next === ':') {
7420           next = ',';
7421           continue;
7422         }
7423       } else {
7424         if (explicitKey) {
7425           if (key === undefined && char !== ',') key = null;
7426           explicitKey = false;
7427         }
7428
7429         if (key !== undefined) {
7430           items.push(new Pair(key));
7431           key = undefined;
7432
7433           if (char === ',') {
7434             next = ':';
7435             continue;
7436           }
7437         }
7438       }
7439
7440       if (char === '}') {
7441         if (i === cst.items.length - 1) continue;
7442       } else if (char === next) {
7443         next = ':';
7444         continue;
7445       }
7446
7447       const msg = `Flow map contains an unexpected ${char}`;
7448       const err = new PlainValue$4.YAMLSyntaxError(cst, msg);
7449       err.offset = offset;
7450       doc.errors.push(err);
7451     } else if (item.type === PlainValue$4.Type.BLANK_LINE) {
7452       comments.push({
7453         afterKey: !!key,
7454         before: items.length
7455       });
7456     } else if (item.type === PlainValue$4.Type.COMMENT) {
7457       checkFlowCommentSpace(doc.errors, item);
7458       comments.push({
7459         afterKey: !!key,
7460         before: items.length,
7461         comment: item.comment
7462       });
7463     } else if (key === undefined) {
7464       if (next === ',') doc.errors.push(new PlainValue$4.YAMLSemanticError(item, 'Separator , missing in flow map'));
7465       key = resolveNode(doc, item);
7466     } else {
7467       if (next !== ',') doc.errors.push(new PlainValue$4.YAMLSemanticError(item, 'Indicator : missing in flow map entry'));
7468       items.push(new Pair(key, resolveNode(doc, item)));
7469       key = undefined;
7470       explicitKey = false;
7471     }
7472   }
7473
7474   checkFlowCollectionEnd(doc.errors, cst);
7475   if (key !== undefined) items.push(new Pair(key));
7476   return {
7477     comments,
7478     items
7479   };
7480 }
7481
7482 function resolveSeq$3(doc, cst) {
7483   if (cst.type !== PlainValue$4.Type.SEQ && cst.type !== PlainValue$4.Type.FLOW_SEQ) {
7484     const msg = `A ${cst.type} node cannot be resolved as a sequence`;
7485     doc.errors.push(new PlainValue$4.YAMLSyntaxError(cst, msg));
7486     return null;
7487   }
7488
7489   const {
7490     comments,
7491     items
7492   } = cst.type === PlainValue$4.Type.FLOW_SEQ ? resolveFlowSeqItems(doc, cst) : resolveBlockSeqItems(doc, cst);
7493   const seq = new YAMLSeq();
7494   seq.items = items;
7495   resolveComments(seq, comments);
7496
7497   if (!doc.options.mapAsMap && items.some(it => it instanceof Pair && it.key instanceof Collection)) {
7498     const warn = 'Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.';
7499     doc.warnings.push(new PlainValue$4.YAMLWarning(cst, warn));
7500   }
7501
7502   cst.resolved = seq;
7503   return seq;
7504 }
7505
7506 function resolveBlockSeqItems(doc, cst) {
7507   const comments = [];
7508   const items = [];
7509
7510   for (let i = 0; i < cst.items.length; ++i) {
7511     const item = cst.items[i];
7512
7513     switch (item.type) {
7514       case PlainValue$4.Type.BLANK_LINE:
7515         comments.push({
7516           before: items.length
7517         });
7518         break;
7519
7520       case PlainValue$4.Type.COMMENT:
7521         comments.push({
7522           comment: item.comment,
7523           before: items.length
7524         });
7525         break;
7526
7527       case PlainValue$4.Type.SEQ_ITEM:
7528         if (item.error) doc.errors.push(item.error);
7529         items.push(resolveNode(doc, item.node));
7530
7531         if (item.hasProps) {
7532           const msg = 'Sequence items cannot have tags or anchors before the - indicator';
7533           doc.errors.push(new PlainValue$4.YAMLSemanticError(item, msg));
7534         }
7535
7536         break;
7537
7538       default:
7539         if (item.error) doc.errors.push(item.error);
7540         doc.errors.push(new PlainValue$4.YAMLSyntaxError(item, `Unexpected ${item.type} node in sequence`));
7541     }
7542   }
7543
7544   return {
7545     comments,
7546     items
7547   };
7548 }
7549
7550 function resolveFlowSeqItems(doc, cst) {
7551   const comments = [];
7552   const items = [];
7553   let explicitKey = false;
7554   let key = undefined;
7555   let keyStart = null;
7556   let next = '[';
7557   let prevItem = null;
7558
7559   for (let i = 0; i < cst.items.length; ++i) {
7560     const item = cst.items[i];
7561
7562     if (typeof item.char === 'string') {
7563       const {
7564         char,
7565         offset
7566       } = item;
7567
7568       if (char !== ':' && (explicitKey || key !== undefined)) {
7569         if (explicitKey && key === undefined) key = next ? items.pop() : null;
7570         items.push(new Pair(key));
7571         explicitKey = false;
7572         key = undefined;
7573         keyStart = null;
7574       }
7575
7576       if (char === next) {
7577         next = null;
7578       } else if (!next && char === '?') {
7579         explicitKey = true;
7580       } else if (next !== '[' && char === ':' && key === undefined) {
7581         if (next === ',') {
7582           key = items.pop();
7583
7584           if (key instanceof Pair) {
7585             const msg = 'Chaining flow sequence pairs is invalid';
7586             const err = new PlainValue$4.YAMLSemanticError(cst, msg);
7587             err.offset = offset;
7588             doc.errors.push(err);
7589           }
7590
7591           if (!explicitKey && typeof keyStart === 'number') {
7592             const keyEnd = item.range ? item.range.start : item.offset;
7593             if (keyEnd > keyStart + 1024) doc.errors.push(getLongKeyError(cst, key));
7594             const {
7595               src
7596             } = prevItem.context;
7597
7598             for (let i = keyStart; i < keyEnd; ++i) if (src[i] === '\n') {
7599               const msg = 'Implicit keys of flow sequence pairs need to be on a single line';
7600               doc.errors.push(new PlainValue$4.YAMLSemanticError(prevItem, msg));
7601               break;
7602             }
7603           }
7604         } else {
7605           key = null;
7606         }
7607
7608         keyStart = null;
7609         explicitKey = false;
7610         next = null;
7611       } else if (next === '[' || char !== ']' || i < cst.items.length - 1) {
7612         const msg = `Flow sequence contains an unexpected ${char}`;
7613         const err = new PlainValue$4.YAMLSyntaxError(cst, msg);
7614         err.offset = offset;
7615         doc.errors.push(err);
7616       }
7617     } else if (item.type === PlainValue$4.Type.BLANK_LINE) {
7618       comments.push({
7619         before: items.length
7620       });
7621     } else if (item.type === PlainValue$4.Type.COMMENT) {
7622       checkFlowCommentSpace(doc.errors, item);
7623       comments.push({
7624         comment: item.comment,
7625         before: items.length
7626       });
7627     } else {
7628       if (next) {
7629         const msg = `Expected a ${next} in flow sequence`;
7630         doc.errors.push(new PlainValue$4.YAMLSemanticError(item, msg));
7631       }
7632
7633       const value = resolveNode(doc, item);
7634
7635       if (key === undefined) {
7636         items.push(value);
7637         prevItem = item;
7638       } else {
7639         items.push(new Pair(key, value));
7640         key = undefined;
7641       }
7642
7643       keyStart = item.range.start;
7644       next = ',';
7645     }
7646   }
7647
7648   checkFlowCollectionEnd(doc.errors, cst);
7649   if (key !== undefined) items.push(new Pair(key));
7650   return {
7651     comments,
7652     items
7653   };
7654 }
7655
7656 resolveSeqD03cb037.Alias = Alias;
7657 resolveSeqD03cb037.Collection = Collection;
7658 resolveSeqD03cb037.Merge = Merge;
7659 resolveSeqD03cb037.Node = Node;
7660 resolveSeqD03cb037.Pair = Pair;
7661 resolveSeqD03cb037.Scalar = Scalar;
7662 resolveSeqD03cb037.YAMLMap = YAMLMap;
7663 resolveSeqD03cb037.YAMLSeq = YAMLSeq;
7664 resolveSeqD03cb037.addComment = addComment;
7665 resolveSeqD03cb037.binaryOptions = binaryOptions;
7666 resolveSeqD03cb037.boolOptions = boolOptions;
7667 resolveSeqD03cb037.findPair = findPair;
7668 resolveSeqD03cb037.intOptions = intOptions;
7669 resolveSeqD03cb037.isEmptyPath = isEmptyPath;
7670 resolveSeqD03cb037.nullOptions = nullOptions;
7671 resolveSeqD03cb037.resolveMap = resolveMap;
7672 resolveSeqD03cb037.resolveNode = resolveNode;
7673 resolveSeqD03cb037.resolveSeq = resolveSeq$3;
7674 resolveSeqD03cb037.resolveString = resolveString;
7675 resolveSeqD03cb037.strOptions = strOptions;
7676 resolveSeqD03cb037.stringifyNumber = stringifyNumber;
7677 resolveSeqD03cb037.stringifyString = stringifyString;
7678 resolveSeqD03cb037.toJSON = toJSON;
7679
7680 var check = function (it) {
7681   return it && it.Math == Math && it;
7682 };
7683
7684 // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
7685 var global$m =
7686   // eslint-disable-next-line es/no-global-this -- safe
7687   check(typeof globalThis == 'object' && globalThis) ||
7688   check(typeof window == 'object' && window) ||
7689   // eslint-disable-next-line no-restricted-globals -- safe
7690   check(typeof self == 'object' && self) ||
7691   check(typeof global$m == 'object' && global$m) ||
7692   // eslint-disable-next-line no-new-func -- fallback
7693   (function () { return this; })() || Function('return this')();
7694
7695 var objectGetOwnPropertyDescriptor = {};
7696
7697 var fails$7 = function (exec) {
7698   try {
7699     return !!exec();
7700   } catch (error) {
7701     return true;
7702   }
7703 };
7704
7705 var fails$6 = fails$7;
7706
7707 // Detect IE8's incomplete defineProperty implementation
7708 var descriptors = !fails$6(function () {
7709   // eslint-disable-next-line es/no-object-defineproperty -- required for testing
7710   return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
7711 });
7712
7713 var call$4 = Function.prototype.call;
7714
7715 var functionCall = call$4.bind ? call$4.bind(call$4) : function () {
7716   return call$4.apply(call$4, arguments);
7717 };
7718
7719 var objectPropertyIsEnumerable = {};
7720
7721 var $propertyIsEnumerable = {}.propertyIsEnumerable;
7722 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
7723 var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
7724
7725 // Nashorn ~ JDK8 bug
7726 var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
7727
7728 // `Object.prototype.propertyIsEnumerable` method implementation
7729 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
7730 objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
7731   var descriptor = getOwnPropertyDescriptor$1(this, V);
7732   return !!descriptor && descriptor.enumerable;
7733 } : $propertyIsEnumerable;
7734
7735 var createPropertyDescriptor$2 = function (bitmap, value) {
7736   return {
7737     enumerable: !(bitmap & 1),
7738     configurable: !(bitmap & 2),
7739     writable: !(bitmap & 4),
7740     value: value
7741   };
7742 };
7743
7744 var FunctionPrototype$1 = Function.prototype;
7745 var bind = FunctionPrototype$1.bind;
7746 var call$3 = FunctionPrototype$1.call;
7747 var callBind = bind && bind.bind(call$3);
7748
7749 var functionUncurryThis = bind ? function (fn) {
7750   return fn && callBind(call$3, fn);
7751 } : function (fn) {
7752   return fn && function () {
7753     return call$3.apply(fn, arguments);
7754   };
7755 };
7756
7757 var uncurryThis$a = functionUncurryThis;
7758
7759 var toString$3 = uncurryThis$a({}.toString);
7760 var stringSlice = uncurryThis$a(''.slice);
7761
7762 var classofRaw$1 = function (it) {
7763   return stringSlice(toString$3(it), 8, -1);
7764 };
7765
7766 var global$l = global$m;
7767 var uncurryThis$9 = functionUncurryThis;
7768 var fails$5 = fails$7;
7769 var classof$2 = classofRaw$1;
7770
7771 var Object$4 = global$l.Object;
7772 var split = uncurryThis$9(''.split);
7773
7774 // fallback for non-array-like ES3 and non-enumerable old V8 strings
7775 var indexedObject = fails$5(function () {
7776   // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
7777   // eslint-disable-next-line no-prototype-builtins -- safe
7778   return !Object$4('z').propertyIsEnumerable(0);
7779 }) ? function (it) {
7780   return classof$2(it) == 'String' ? split(it, '') : Object$4(it);
7781 } : Object$4;
7782
7783 var global$k = global$m;
7784
7785 var TypeError$7 = global$k.TypeError;
7786
7787 // `RequireObjectCoercible` abstract operation
7788 // https://tc39.es/ecma262/#sec-requireobjectcoercible
7789 var requireObjectCoercible$2 = function (it) {
7790   if (it == undefined) throw TypeError$7("Can't call method on " + it);
7791   return it;
7792 };
7793
7794 // toObject with fallback for non-array-like ES3 strings
7795 var IndexedObject = indexedObject;
7796 var requireObjectCoercible$1 = requireObjectCoercible$2;
7797
7798 var toIndexedObject$3 = function (it) {
7799   return IndexedObject(requireObjectCoercible$1(it));
7800 };
7801
7802 // `IsCallable` abstract operation
7803 // https://tc39.es/ecma262/#sec-iscallable
7804 var isCallable$a = function (argument) {
7805   return typeof argument == 'function';
7806 };
7807
7808 var isCallable$9 = isCallable$a;
7809
7810 var isObject$5 = function (it) {
7811   return typeof it == 'object' ? it !== null : isCallable$9(it);
7812 };
7813
7814 var global$j = global$m;
7815 var isCallable$8 = isCallable$a;
7816
7817 var aFunction = function (argument) {
7818   return isCallable$8(argument) ? argument : undefined;
7819 };
7820
7821 var getBuiltIn$3 = function (namespace, method) {
7822   return arguments.length < 2 ? aFunction(global$j[namespace]) : global$j[namespace] && global$j[namespace][method];
7823 };
7824
7825 var uncurryThis$8 = functionUncurryThis;
7826
7827 var objectIsPrototypeOf = uncurryThis$8({}.isPrototypeOf);
7828
7829 var getBuiltIn$2 = getBuiltIn$3;
7830
7831 var engineUserAgent = getBuiltIn$2('navigator', 'userAgent') || '';
7832
7833 var global$i = global$m;
7834 var userAgent$2 = engineUserAgent;
7835
7836 var process$1 = global$i.process;
7837 var Deno = global$i.Deno;
7838 var versions = process$1 && process$1.versions || Deno && Deno.version;
7839 var v8 = versions && versions.v8;
7840 var match, version;
7841
7842 if (v8) {
7843   match = v8.split('.');
7844   // in old Chrome, versions of V8 isn't V8 = Chrome / 10
7845   // but their correct versions are not interesting for us
7846   version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
7847 }
7848
7849 // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
7850 // so check `userAgent` even if `.v8` exists, but 0
7851 if (!version && userAgent$2) {
7852   match = userAgent$2.match(/Edge\/(\d+)/);
7853   if (!match || match[1] >= 74) {
7854     match = userAgent$2.match(/Chrome\/(\d+)/);
7855     if (match) version = +match[1];
7856   }
7857 }
7858
7859 var engineV8Version = version;
7860
7861 /* eslint-disable es/no-symbol -- required for testing */
7862
7863 var V8_VERSION = engineV8Version;
7864 var fails$4 = fails$7;
7865
7866 // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
7867 var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$4(function () {
7868   var symbol = Symbol();
7869   // Chrome 38 Symbol has incorrect toString conversion
7870   // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
7871   return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
7872     // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
7873     !Symbol.sham && V8_VERSION && V8_VERSION < 41;
7874 });
7875
7876 /* eslint-disable es/no-symbol -- required for testing */
7877
7878 var NATIVE_SYMBOL$1 = nativeSymbol;
7879
7880 var useSymbolAsUid = NATIVE_SYMBOL$1
7881   && !Symbol.sham
7882   && typeof Symbol.iterator == 'symbol';
7883
7884 var global$h = global$m;
7885 var getBuiltIn$1 = getBuiltIn$3;
7886 var isCallable$7 = isCallable$a;
7887 var isPrototypeOf = objectIsPrototypeOf;
7888 var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
7889
7890 var Object$3 = global$h.Object;
7891
7892 var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
7893   return typeof it == 'symbol';
7894 } : function (it) {
7895   var $Symbol = getBuiltIn$1('Symbol');
7896   return isCallable$7($Symbol) && isPrototypeOf($Symbol.prototype, Object$3(it));
7897 };
7898
7899 var global$g = global$m;
7900
7901 var String$3 = global$g.String;
7902
7903 var tryToString$1 = function (argument) {
7904   try {
7905     return String$3(argument);
7906   } catch (error) {
7907     return 'Object';
7908   }
7909 };
7910
7911 var global$f = global$m;
7912 var isCallable$6 = isCallable$a;
7913 var tryToString = tryToString$1;
7914
7915 var TypeError$6 = global$f.TypeError;
7916
7917 // `Assert: IsCallable(argument) is true`
7918 var aCallable$2 = function (argument) {
7919   if (isCallable$6(argument)) return argument;
7920   throw TypeError$6(tryToString(argument) + ' is not a function');
7921 };
7922
7923 var aCallable$1 = aCallable$2;
7924
7925 // `GetMethod` abstract operation
7926 // https://tc39.es/ecma262/#sec-getmethod
7927 var getMethod$1 = function (V, P) {
7928   var func = V[P];
7929   return func == null ? undefined : aCallable$1(func);
7930 };
7931
7932 var global$e = global$m;
7933 var call$2 = functionCall;
7934 var isCallable$5 = isCallable$a;
7935 var isObject$4 = isObject$5;
7936
7937 var TypeError$5 = global$e.TypeError;
7938
7939 // `OrdinaryToPrimitive` abstract operation
7940 // https://tc39.es/ecma262/#sec-ordinarytoprimitive
7941 var ordinaryToPrimitive$1 = function (input, pref) {
7942   var fn, val;
7943   if (pref === 'string' && isCallable$5(fn = input.toString) && !isObject$4(val = call$2(fn, input))) return val;
7944   if (isCallable$5(fn = input.valueOf) && !isObject$4(val = call$2(fn, input))) return val;
7945   if (pref !== 'string' && isCallable$5(fn = input.toString) && !isObject$4(val = call$2(fn, input))) return val;
7946   throw TypeError$5("Can't convert object to primitive value");
7947 };
7948
7949 var shared$3 = {exports: {}};
7950
7951 var global$d = global$m;
7952
7953 // eslint-disable-next-line es/no-object-defineproperty -- safe
7954 var defineProperty = Object.defineProperty;
7955
7956 var setGlobal$3 = function (key, value) {
7957   try {
7958     defineProperty(global$d, key, { value: value, configurable: true, writable: true });
7959   } catch (error) {
7960     global$d[key] = value;
7961   } return value;
7962 };
7963
7964 var global$c = global$m;
7965 var setGlobal$2 = setGlobal$3;
7966
7967 var SHARED = '__core-js_shared__';
7968 var store$3 = global$c[SHARED] || setGlobal$2(SHARED, {});
7969
7970 var sharedStore = store$3;
7971
7972 var store$2 = sharedStore;
7973
7974 (shared$3.exports = function (key, value) {
7975   return store$2[key] || (store$2[key] = value !== undefined ? value : {});
7976 })('versions', []).push({
7977   version: '3.19.1',
7978   mode: 'global',
7979   copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
7980 });
7981
7982 var global$b = global$m;
7983 var requireObjectCoercible = requireObjectCoercible$2;
7984
7985 var Object$2 = global$b.Object;
7986
7987 // `ToObject` abstract operation
7988 // https://tc39.es/ecma262/#sec-toobject
7989 var toObject$2 = function (argument) {
7990   return Object$2(requireObjectCoercible(argument));
7991 };
7992
7993 var uncurryThis$7 = functionUncurryThis;
7994 var toObject$1 = toObject$2;
7995
7996 var hasOwnProperty = uncurryThis$7({}.hasOwnProperty);
7997
7998 // `HasOwnProperty` abstract operation
7999 // https://tc39.es/ecma262/#sec-hasownproperty
8000 var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
8001   return hasOwnProperty(toObject$1(it), key);
8002 };
8003
8004 var uncurryThis$6 = functionUncurryThis;
8005
8006 var id = 0;
8007 var postfix = Math.random();
8008 var toString$2 = uncurryThis$6(1.0.toString);
8009
8010 var uid$2 = function (key) {
8011   return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$2(++id + postfix, 36);
8012 };
8013
8014 var global$a = global$m;
8015 var shared$2 = shared$3.exports;
8016 var hasOwn$6 = hasOwnProperty_1;
8017 var uid$1 = uid$2;
8018 var NATIVE_SYMBOL = nativeSymbol;
8019 var USE_SYMBOL_AS_UID = useSymbolAsUid;
8020
8021 var WellKnownSymbolsStore = shared$2('wks');
8022 var Symbol$1 = global$a.Symbol;
8023 var symbolFor = Symbol$1 && Symbol$1['for'];
8024 var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
8025
8026 var wellKnownSymbol$3 = function (name) {
8027   if (!hasOwn$6(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
8028     var description = 'Symbol.' + name;
8029     if (NATIVE_SYMBOL && hasOwn$6(Symbol$1, name)) {
8030       WellKnownSymbolsStore[name] = Symbol$1[name];
8031     } else if (USE_SYMBOL_AS_UID && symbolFor) {
8032       WellKnownSymbolsStore[name] = symbolFor(description);
8033     } else {
8034       WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
8035     }
8036   } return WellKnownSymbolsStore[name];
8037 };
8038
8039 var global$9 = global$m;
8040 var call$1 = functionCall;
8041 var isObject$3 = isObject$5;
8042 var isSymbol$1 = isSymbol$2;
8043 var getMethod = getMethod$1;
8044 var ordinaryToPrimitive = ordinaryToPrimitive$1;
8045 var wellKnownSymbol$2 = wellKnownSymbol$3;
8046
8047 var TypeError$4 = global$9.TypeError;
8048 var TO_PRIMITIVE = wellKnownSymbol$2('toPrimitive');
8049
8050 // `ToPrimitive` abstract operation
8051 // https://tc39.es/ecma262/#sec-toprimitive
8052 var toPrimitive$1 = function (input, pref) {
8053   if (!isObject$3(input) || isSymbol$1(input)) return input;
8054   var exoticToPrim = getMethod(input, TO_PRIMITIVE);
8055   var result;
8056   if (exoticToPrim) {
8057     if (pref === undefined) pref = 'default';
8058     result = call$1(exoticToPrim, input, pref);
8059     if (!isObject$3(result) || isSymbol$1(result)) return result;
8060     throw TypeError$4("Can't convert object to primitive value");
8061   }
8062   if (pref === undefined) pref = 'number';
8063   return ordinaryToPrimitive(input, pref);
8064 };
8065
8066 var toPrimitive = toPrimitive$1;
8067 var isSymbol = isSymbol$2;
8068
8069 // `ToPropertyKey` abstract operation
8070 // https://tc39.es/ecma262/#sec-topropertykey
8071 var toPropertyKey$2 = function (argument) {
8072   var key = toPrimitive(argument, 'string');
8073   return isSymbol(key) ? key : key + '';
8074 };
8075
8076 var global$8 = global$m;
8077 var isObject$2 = isObject$5;
8078
8079 var document = global$8.document;
8080 // typeof document.createElement is 'object' in old IE
8081 var EXISTS$1 = isObject$2(document) && isObject$2(document.createElement);
8082
8083 var documentCreateElement = function (it) {
8084   return EXISTS$1 ? document.createElement(it) : {};
8085 };
8086
8087 var DESCRIPTORS$4 = descriptors;
8088 var fails$3 = fails$7;
8089 var createElement = documentCreateElement;
8090
8091 // Thank's IE8 for his funny defineProperty
8092 var ie8DomDefine = !DESCRIPTORS$4 && !fails$3(function () {
8093   // eslint-disable-next-line es/no-object-defineproperty -- requied for testing
8094   return Object.defineProperty(createElement('div'), 'a', {
8095     get: function () { return 7; }
8096   }).a != 7;
8097 });
8098
8099 var DESCRIPTORS$3 = descriptors;
8100 var call = functionCall;
8101 var propertyIsEnumerableModule = objectPropertyIsEnumerable;
8102 var createPropertyDescriptor$1 = createPropertyDescriptor$2;
8103 var toIndexedObject$2 = toIndexedObject$3;
8104 var toPropertyKey$1 = toPropertyKey$2;
8105 var hasOwn$5 = hasOwnProperty_1;
8106 var IE8_DOM_DEFINE$1 = ie8DomDefine;
8107
8108 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
8109 var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
8110
8111 // `Object.getOwnPropertyDescriptor` method
8112 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
8113 objectGetOwnPropertyDescriptor.f = DESCRIPTORS$3 ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
8114   O = toIndexedObject$2(O);
8115   P = toPropertyKey$1(P);
8116   if (IE8_DOM_DEFINE$1) try {
8117     return $getOwnPropertyDescriptor(O, P);
8118   } catch (error) { /* empty */ }
8119   if (hasOwn$5(O, P)) return createPropertyDescriptor$1(!call(propertyIsEnumerableModule.f, O, P), O[P]);
8120 };
8121
8122 var objectDefineProperty = {};
8123
8124 var global$7 = global$m;
8125 var isObject$1 = isObject$5;
8126
8127 var String$2 = global$7.String;
8128 var TypeError$3 = global$7.TypeError;
8129
8130 // `Assert: Type(argument) is Object`
8131 var anObject$2 = function (argument) {
8132   if (isObject$1(argument)) return argument;
8133   throw TypeError$3(String$2(argument) + ' is not an object');
8134 };
8135
8136 var global$6 = global$m;
8137 var DESCRIPTORS$2 = descriptors;
8138 var IE8_DOM_DEFINE = ie8DomDefine;
8139 var anObject$1 = anObject$2;
8140 var toPropertyKey = toPropertyKey$2;
8141
8142 var TypeError$2 = global$6.TypeError;
8143 // eslint-disable-next-line es/no-object-defineproperty -- safe
8144 var $defineProperty = Object.defineProperty;
8145
8146 // `Object.defineProperty` method
8147 // https://tc39.es/ecma262/#sec-object.defineproperty
8148 objectDefineProperty.f = DESCRIPTORS$2 ? $defineProperty : function defineProperty(O, P, Attributes) {
8149   anObject$1(O);
8150   P = toPropertyKey(P);
8151   anObject$1(Attributes);
8152   if (IE8_DOM_DEFINE) try {
8153     return $defineProperty(O, P, Attributes);
8154   } catch (error) { /* empty */ }
8155   if ('get' in Attributes || 'set' in Attributes) throw TypeError$2('Accessors not supported');
8156   if ('value' in Attributes) O[P] = Attributes.value;
8157   return O;
8158 };
8159
8160 var DESCRIPTORS$1 = descriptors;
8161 var definePropertyModule$1 = objectDefineProperty;
8162 var createPropertyDescriptor = createPropertyDescriptor$2;
8163
8164 var createNonEnumerableProperty$3 = DESCRIPTORS$1 ? function (object, key, value) {
8165   return definePropertyModule$1.f(object, key, createPropertyDescriptor(1, value));
8166 } : function (object, key, value) {
8167   object[key] = value;
8168   return object;
8169 };
8170
8171 var redefine$1 = {exports: {}};
8172
8173 var uncurryThis$5 = functionUncurryThis;
8174 var isCallable$4 = isCallable$a;
8175 var store$1 = sharedStore;
8176
8177 var functionToString = uncurryThis$5(Function.toString);
8178
8179 // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
8180 if (!isCallable$4(store$1.inspectSource)) {
8181   store$1.inspectSource = function (it) {
8182     return functionToString(it);
8183   };
8184 }
8185
8186 var inspectSource$2 = store$1.inspectSource;
8187
8188 var global$5 = global$m;
8189 var isCallable$3 = isCallable$a;
8190 var inspectSource$1 = inspectSource$2;
8191
8192 var WeakMap$1 = global$5.WeakMap;
8193
8194 var nativeWeakMap = isCallable$3(WeakMap$1) && /native code/.test(inspectSource$1(WeakMap$1));
8195
8196 var shared$1 = shared$3.exports;
8197 var uid = uid$2;
8198
8199 var keys = shared$1('keys');
8200
8201 var sharedKey$1 = function (key) {
8202   return keys[key] || (keys[key] = uid(key));
8203 };
8204
8205 var hiddenKeys$3 = {};
8206
8207 var NATIVE_WEAK_MAP = nativeWeakMap;
8208 var global$4 = global$m;
8209 var uncurryThis$4 = functionUncurryThis;
8210 var isObject = isObject$5;
8211 var createNonEnumerableProperty$2 = createNonEnumerableProperty$3;
8212 var hasOwn$4 = hasOwnProperty_1;
8213 var shared = sharedStore;
8214 var sharedKey = sharedKey$1;
8215 var hiddenKeys$2 = hiddenKeys$3;
8216
8217 var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
8218 var TypeError$1 = global$4.TypeError;
8219 var WeakMap = global$4.WeakMap;
8220 var set$1, get, has;
8221
8222 var enforce = function (it) {
8223   return has(it) ? get(it) : set$1(it, {});
8224 };
8225
8226 var getterFor = function (TYPE) {
8227   return function (it) {
8228     var state;
8229     if (!isObject(it) || (state = get(it)).type !== TYPE) {
8230       throw TypeError$1('Incompatible receiver, ' + TYPE + ' required');
8231     } return state;
8232   };
8233 };
8234
8235 if (NATIVE_WEAK_MAP || shared.state) {
8236   var store = shared.state || (shared.state = new WeakMap());
8237   var wmget = uncurryThis$4(store.get);
8238   var wmhas = uncurryThis$4(store.has);
8239   var wmset = uncurryThis$4(store.set);
8240   set$1 = function (it, metadata) {
8241     if (wmhas(store, it)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
8242     metadata.facade = it;
8243     wmset(store, it, metadata);
8244     return metadata;
8245   };
8246   get = function (it) {
8247     return wmget(store, it) || {};
8248   };
8249   has = function (it) {
8250     return wmhas(store, it);
8251   };
8252 } else {
8253   var STATE = sharedKey('state');
8254   hiddenKeys$2[STATE] = true;
8255   set$1 = function (it, metadata) {
8256     if (hasOwn$4(it, STATE)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
8257     metadata.facade = it;
8258     createNonEnumerableProperty$2(it, STATE, metadata);
8259     return metadata;
8260   };
8261   get = function (it) {
8262     return hasOwn$4(it, STATE) ? it[STATE] : {};
8263   };
8264   has = function (it) {
8265     return hasOwn$4(it, STATE);
8266   };
8267 }
8268
8269 var internalState = {
8270   set: set$1,
8271   get: get,
8272   has: has,
8273   enforce: enforce,
8274   getterFor: getterFor
8275 };
8276
8277 var DESCRIPTORS = descriptors;
8278 var hasOwn$3 = hasOwnProperty_1;
8279
8280 var FunctionPrototype = Function.prototype;
8281 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
8282 var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
8283
8284 var EXISTS = hasOwn$3(FunctionPrototype, 'name');
8285 // additional protection from minified / mangled / dropped function names
8286 var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
8287 var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
8288
8289 var functionName = {
8290   EXISTS: EXISTS,
8291   PROPER: PROPER,
8292   CONFIGURABLE: CONFIGURABLE
8293 };
8294
8295 var global$3 = global$m;
8296 var isCallable$2 = isCallable$a;
8297 var hasOwn$2 = hasOwnProperty_1;
8298 var createNonEnumerableProperty$1 = createNonEnumerableProperty$3;
8299 var setGlobal$1 = setGlobal$3;
8300 var inspectSource = inspectSource$2;
8301 var InternalStateModule = internalState;
8302 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
8303
8304 var getInternalState = InternalStateModule.get;
8305 var enforceInternalState = InternalStateModule.enforce;
8306 var TEMPLATE = String(String).split('String');
8307
8308 (redefine$1.exports = function (O, key, value, options) {
8309   var unsafe = options ? !!options.unsafe : false;
8310   var simple = options ? !!options.enumerable : false;
8311   var noTargetGet = options ? !!options.noTargetGet : false;
8312   var name = options && options.name !== undefined ? options.name : key;
8313   var state;
8314   if (isCallable$2(value)) {
8315     if (String(name).slice(0, 7) === 'Symbol(') {
8316       name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
8317     }
8318     if (!hasOwn$2(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
8319       createNonEnumerableProperty$1(value, 'name', name);
8320     }
8321     state = enforceInternalState(value);
8322     if (!state.source) {
8323       state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
8324     }
8325   }
8326   if (O === global$3) {
8327     if (simple) O[key] = value;
8328     else setGlobal$1(key, value);
8329     return;
8330   } else if (!unsafe) {
8331     delete O[key];
8332   } else if (!noTargetGet && O[key]) {
8333     simple = true;
8334   }
8335   if (simple) O[key] = value;
8336   else createNonEnumerableProperty$1(O, key, value);
8337 // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
8338 })(Function.prototype, 'toString', function toString() {
8339   return isCallable$2(this) && getInternalState(this).source || inspectSource(this);
8340 });
8341
8342 var objectGetOwnPropertyNames = {};
8343
8344 var ceil = Math.ceil;
8345 var floor$1 = Math.floor;
8346
8347 // `ToIntegerOrInfinity` abstract operation
8348 // https://tc39.es/ecma262/#sec-tointegerorinfinity
8349 var toIntegerOrInfinity$2 = function (argument) {
8350   var number = +argument;
8351   // eslint-disable-next-line no-self-compare -- safe
8352   return number !== number || number === 0 ? 0 : (number > 0 ? floor$1 : ceil)(number);
8353 };
8354
8355 var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
8356
8357 var max = Math.max;
8358 var min$1 = Math.min;
8359
8360 // Helper for a popular repeating case of the spec:
8361 // Let integer be ? ToInteger(index).
8362 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
8363 var toAbsoluteIndex$1 = function (index, length) {
8364   var integer = toIntegerOrInfinity$1(index);
8365   return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
8366 };
8367
8368 var toIntegerOrInfinity = toIntegerOrInfinity$2;
8369
8370 var min = Math.min;
8371
8372 // `ToLength` abstract operation
8373 // https://tc39.es/ecma262/#sec-tolength
8374 var toLength$1 = function (argument) {
8375   return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
8376 };
8377
8378 var toLength = toLength$1;
8379
8380 // `LengthOfArrayLike` abstract operation
8381 // https://tc39.es/ecma262/#sec-lengthofarraylike
8382 var lengthOfArrayLike$2 = function (obj) {
8383   return toLength(obj.length);
8384 };
8385
8386 var toIndexedObject$1 = toIndexedObject$3;
8387 var toAbsoluteIndex = toAbsoluteIndex$1;
8388 var lengthOfArrayLike$1 = lengthOfArrayLike$2;
8389
8390 // `Array.prototype.{ indexOf, includes }` methods implementation
8391 var createMethod = function (IS_INCLUDES) {
8392   return function ($this, el, fromIndex) {
8393     var O = toIndexedObject$1($this);
8394     var length = lengthOfArrayLike$1(O);
8395     var index = toAbsoluteIndex(fromIndex, length);
8396     var value;
8397     // Array#includes uses SameValueZero equality algorithm
8398     // eslint-disable-next-line no-self-compare -- NaN check
8399     if (IS_INCLUDES && el != el) while (length > index) {
8400       value = O[index++];
8401       // eslint-disable-next-line no-self-compare -- NaN check
8402       if (value != value) return true;
8403     // Array#indexOf ignores holes, Array#includes - not
8404     } else for (;length > index; index++) {
8405       if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
8406     } return !IS_INCLUDES && -1;
8407   };
8408 };
8409
8410 var arrayIncludes = {
8411   // `Array.prototype.includes` method
8412   // https://tc39.es/ecma262/#sec-array.prototype.includes
8413   includes: createMethod(true),
8414   // `Array.prototype.indexOf` method
8415   // https://tc39.es/ecma262/#sec-array.prototype.indexof
8416   indexOf: createMethod(false)
8417 };
8418
8419 var uncurryThis$3 = functionUncurryThis;
8420 var hasOwn$1 = hasOwnProperty_1;
8421 var toIndexedObject = toIndexedObject$3;
8422 var indexOf = arrayIncludes.indexOf;
8423 var hiddenKeys$1 = hiddenKeys$3;
8424
8425 var push$1 = uncurryThis$3([].push);
8426
8427 var objectKeysInternal = function (object, names) {
8428   var O = toIndexedObject(object);
8429   var i = 0;
8430   var result = [];
8431   var key;
8432   for (key in O) !hasOwn$1(hiddenKeys$1, key) && hasOwn$1(O, key) && push$1(result, key);
8433   // Don't enum bug & hidden keys
8434   while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
8435     ~indexOf(result, key) || push$1(result, key);
8436   }
8437   return result;
8438 };
8439
8440 // IE8- don't enum bug keys
8441 var enumBugKeys$1 = [
8442   'constructor',
8443   'hasOwnProperty',
8444   'isPrototypeOf',
8445   'propertyIsEnumerable',
8446   'toLocaleString',
8447   'toString',
8448   'valueOf'
8449 ];
8450
8451 var internalObjectKeys = objectKeysInternal;
8452 var enumBugKeys = enumBugKeys$1;
8453
8454 var hiddenKeys = enumBugKeys.concat('length', 'prototype');
8455
8456 // `Object.getOwnPropertyNames` method
8457 // https://tc39.es/ecma262/#sec-object.getownpropertynames
8458 // eslint-disable-next-line es/no-object-getownpropertynames -- safe
8459 objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
8460   return internalObjectKeys(O, hiddenKeys);
8461 };
8462
8463 var objectGetOwnPropertySymbols = {};
8464
8465 // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
8466 objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
8467
8468 var getBuiltIn = getBuiltIn$3;
8469 var uncurryThis$2 = functionUncurryThis;
8470 var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
8471 var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
8472 var anObject = anObject$2;
8473
8474 var concat = uncurryThis$2([].concat);
8475
8476 // all object keys, includes non-enumerable and symbols
8477 var ownKeys$1 = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
8478   var keys = getOwnPropertyNamesModule.f(anObject(it));
8479   var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
8480   return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
8481 };
8482
8483 var hasOwn = hasOwnProperty_1;
8484 var ownKeys = ownKeys$1;
8485 var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
8486 var definePropertyModule = objectDefineProperty;
8487
8488 var copyConstructorProperties$1 = function (target, source) {
8489   var keys = ownKeys(source);
8490   var defineProperty = definePropertyModule.f;
8491   var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
8492   for (var i = 0; i < keys.length; i++) {
8493     var key = keys[i];
8494     if (!hasOwn(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
8495   }
8496 };
8497
8498 var fails$2 = fails$7;
8499 var isCallable$1 = isCallable$a;
8500
8501 var replacement = /#|\.prototype\./;
8502
8503 var isForced$1 = function (feature, detection) {
8504   var value = data[normalize(feature)];
8505   return value == POLYFILL ? true
8506     : value == NATIVE ? false
8507     : isCallable$1(detection) ? fails$2(detection)
8508     : !!detection;
8509 };
8510
8511 var normalize = isForced$1.normalize = function (string) {
8512   return String(string).replace(replacement, '.').toLowerCase();
8513 };
8514
8515 var data = isForced$1.data = {};
8516 var NATIVE = isForced$1.NATIVE = 'N';
8517 var POLYFILL = isForced$1.POLYFILL = 'P';
8518
8519 var isForced_1 = isForced$1;
8520
8521 var global$2 = global$m;
8522 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
8523 var createNonEnumerableProperty = createNonEnumerableProperty$3;
8524 var redefine = redefine$1.exports;
8525 var setGlobal = setGlobal$3;
8526 var copyConstructorProperties = copyConstructorProperties$1;
8527 var isForced = isForced_1;
8528
8529 /*
8530   options.target      - name of the target object
8531   options.global      - target is the global object
8532   options.stat        - export as static methods of target
8533   options.proto       - export as prototype methods of target
8534   options.real        - real prototype method for the `pure` version
8535   options.forced      - export even if the native feature is available
8536   options.bind        - bind methods to the target, required for the `pure` version
8537   options.wrap        - wrap constructors to preventing global pollution, required for the `pure` version
8538   options.unsafe      - use the simple assignment of property instead of delete + defineProperty
8539   options.sham        - add a flag to not completely full polyfills
8540   options.enumerable  - export as enumerable property
8541   options.noTargetGet - prevent calling a getter on target
8542   options.name        - the .name of the function if it does not match the key
8543 */
8544 var _export = function (options, source) {
8545   var TARGET = options.target;
8546   var GLOBAL = options.global;
8547   var STATIC = options.stat;
8548   var FORCED, target, key, targetProperty, sourceProperty, descriptor;
8549   if (GLOBAL) {
8550     target = global$2;
8551   } else if (STATIC) {
8552     target = global$2[TARGET] || setGlobal(TARGET, {});
8553   } else {
8554     target = (global$2[TARGET] || {}).prototype;
8555   }
8556   if (target) for (key in source) {
8557     sourceProperty = source[key];
8558     if (options.noTargetGet) {
8559       descriptor = getOwnPropertyDescriptor(target, key);
8560       targetProperty = descriptor && descriptor.value;
8561     } else targetProperty = target[key];
8562     FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
8563     // contained in target
8564     if (!FORCED && targetProperty !== undefined) {
8565       if (typeof sourceProperty == typeof targetProperty) continue;
8566       copyConstructorProperties(sourceProperty, targetProperty);
8567     }
8568     // add a flag to not completely full polyfills
8569     if (options.sham || (targetProperty && targetProperty.sham)) {
8570       createNonEnumerableProperty(sourceProperty, 'sham', true);
8571     }
8572     // extend global
8573     redefine(target, key, sourceProperty, options);
8574   }
8575 };
8576
8577 var wellKnownSymbol$1 = wellKnownSymbol$3;
8578
8579 var TO_STRING_TAG$1 = wellKnownSymbol$1('toStringTag');
8580 var test$1 = {};
8581
8582 test$1[TO_STRING_TAG$1] = 'z';
8583
8584 var toStringTagSupport = String(test$1) === '[object z]';
8585
8586 var global$1 = global$m;
8587 var TO_STRING_TAG_SUPPORT = toStringTagSupport;
8588 var isCallable = isCallable$a;
8589 var classofRaw = classofRaw$1;
8590 var wellKnownSymbol = wellKnownSymbol$3;
8591
8592 var TO_STRING_TAG = wellKnownSymbol('toStringTag');
8593 var Object$1 = global$1.Object;
8594
8595 // ES3 wrong here
8596 var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
8597
8598 // fallback for IE11 Script Access Denied error
8599 var tryGet = function (it, key) {
8600   try {
8601     return it[key];
8602   } catch (error) { /* empty */ }
8603 };
8604
8605 // getting tag from ES6+ `Object.prototype.toString`
8606 var classof$1 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
8607   var O, tag, result;
8608   return it === undefined ? 'Undefined' : it === null ? 'Null'
8609     // @@toStringTag case
8610     : typeof (tag = tryGet(O = Object$1(it), TO_STRING_TAG)) == 'string' ? tag
8611     // builtinTag case
8612     : CORRECT_ARGUMENTS ? classofRaw(O)
8613     // ES3 arguments fallback
8614     : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
8615 };
8616
8617 var global = global$m;
8618 var classof = classof$1;
8619
8620 var String$1 = global.String;
8621
8622 var toString$1 = function (argument) {
8623   if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
8624   return String$1(argument);
8625 };
8626
8627 var uncurryThis$1 = functionUncurryThis;
8628
8629 var arraySlice$1 = uncurryThis$1([].slice);
8630
8631 var arraySlice = arraySlice$1;
8632
8633 var floor = Math.floor;
8634
8635 var mergeSort = function (array, comparefn) {
8636   var length = array.length;
8637   var middle = floor(length / 2);
8638   return length < 8 ? insertionSort(array, comparefn) : merge(
8639     array,
8640     mergeSort(arraySlice(array, 0, middle), comparefn),
8641     mergeSort(arraySlice(array, middle), comparefn),
8642     comparefn
8643   );
8644 };
8645
8646 var insertionSort = function (array, comparefn) {
8647   var length = array.length;
8648   var i = 1;
8649   var element, j;
8650
8651   while (i < length) {
8652     j = i;
8653     element = array[i];
8654     while (j && comparefn(array[j - 1], element) > 0) {
8655       array[j] = array[--j];
8656     }
8657     if (j !== i++) array[j] = element;
8658   } return array;
8659 };
8660
8661 var merge = function (array, left, right, comparefn) {
8662   var llength = left.length;
8663   var rlength = right.length;
8664   var lindex = 0;
8665   var rindex = 0;
8666
8667   while (lindex < llength || rindex < rlength) {
8668     array[lindex + rindex] = (lindex < llength && rindex < rlength)
8669       ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
8670       : lindex < llength ? left[lindex++] : right[rindex++];
8671   } return array;
8672 };
8673
8674 var arraySort = mergeSort;
8675
8676 var fails$1 = fails$7;
8677
8678 var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
8679   var method = [][METHOD_NAME];
8680   return !!method && fails$1(function () {
8681     // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
8682     method.call(null, argument || function () { throw 1; }, 1);
8683   });
8684 };
8685
8686 var userAgent$1 = engineUserAgent;
8687
8688 var firefox = userAgent$1.match(/firefox\/(\d+)/i);
8689
8690 var engineFfVersion = !!firefox && +firefox[1];
8691
8692 var UA = engineUserAgent;
8693
8694 var engineIsIeOrEdge = /MSIE|Trident/.test(UA);
8695
8696 var userAgent = engineUserAgent;
8697
8698 var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
8699
8700 var engineWebkitVersion = !!webkit && +webkit[1];
8701
8702 var $ = _export;
8703 var uncurryThis = functionUncurryThis;
8704 var aCallable = aCallable$2;
8705 var toObject = toObject$2;
8706 var lengthOfArrayLike = lengthOfArrayLike$2;
8707 var toString = toString$1;
8708 var fails = fails$7;
8709 var internalSort = arraySort;
8710 var arrayMethodIsStrict = arrayMethodIsStrict$1;
8711 var FF = engineFfVersion;
8712 var IE_OR_EDGE = engineIsIeOrEdge;
8713 var V8 = engineV8Version;
8714 var WEBKIT = engineWebkitVersion;
8715
8716 var test = [];
8717 var un$Sort = uncurryThis(test.sort);
8718 var push = uncurryThis(test.push);
8719
8720 // IE8-
8721 var FAILS_ON_UNDEFINED = fails(function () {
8722   test.sort(undefined);
8723 });
8724 // V8 bug
8725 var FAILS_ON_NULL = fails(function () {
8726   test.sort(null);
8727 });
8728 // Old WebKit
8729 var STRICT_METHOD = arrayMethodIsStrict('sort');
8730
8731 var STABLE_SORT = !fails(function () {
8732   // feature detection can be too slow, so check engines versions
8733   if (V8) return V8 < 70;
8734   if (FF && FF > 3) return;
8735   if (IE_OR_EDGE) return true;
8736   if (WEBKIT) return WEBKIT < 603;
8737
8738   var result = '';
8739   var code, chr, value, index;
8740
8741   // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
8742   for (code = 65; code < 76; code++) {
8743     chr = String.fromCharCode(code);
8744
8745     switch (code) {
8746       case 66: case 69: case 70: case 72: value = 3; break;
8747       case 68: case 71: value = 4; break;
8748       default: value = 2;
8749     }
8750
8751     for (index = 0; index < 47; index++) {
8752       test.push({ k: chr + index, v: value });
8753     }
8754   }
8755
8756   test.sort(function (a, b) { return b.v - a.v; });
8757
8758   for (index = 0; index < test.length; index++) {
8759     chr = test[index].k.charAt(0);
8760     if (result.charAt(result.length - 1) !== chr) result += chr;
8761   }
8762
8763   return result !== 'DGBEFHACIJK';
8764 });
8765
8766 var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
8767
8768 var getSortCompare = function (comparefn) {
8769   return function (x, y) {
8770     if (y === undefined) return -1;
8771     if (x === undefined) return 1;
8772     if (comparefn !== undefined) return +comparefn(x, y) || 0;
8773     return toString(x) > toString(y) ? 1 : -1;
8774   };
8775 };
8776
8777 // `Array.prototype.sort` method
8778 // https://tc39.es/ecma262/#sec-array.prototype.sort
8779 $({ target: 'Array', proto: true, forced: FORCED }, {
8780   sort: function sort(comparefn) {
8781     if (comparefn !== undefined) aCallable(comparefn);
8782
8783     var array = toObject(this);
8784
8785     if (STABLE_SORT) return comparefn === undefined ? un$Sort(array) : un$Sort(array, comparefn);
8786
8787     var items = [];
8788     var arrayLength = lengthOfArrayLike(array);
8789     var itemsLength, index;
8790
8791     for (index = 0; index < arrayLength; index++) {
8792       if (index in array) push(items, array[index]);
8793     }
8794
8795     internalSort(items, getSortCompare(comparefn));
8796
8797     itemsLength = items.length;
8798     index = 0;
8799
8800     while (index < itemsLength) array[index] = items[index++];
8801     while (index < arrayLength) delete array[index++];
8802
8803     return array;
8804   }
8805 });
8806
8807 var Schema88e323a7 = {};
8808
8809 var warnings1000a372 = {};
8810
8811 var PlainValue$3 = PlainValueEc8e588e;
8812 var resolveSeq$2 = resolveSeqD03cb037;
8813 /* global atob, btoa, Buffer */
8814
8815 const binary = {
8816   identify: value => value instanceof Uint8Array,
8817   // Buffer inherits from Uint8Array
8818   default: false,
8819   tag: 'tag:yaml.org,2002:binary',
8820
8821   /**
8822    * Returns a Buffer in node and an Uint8Array in browsers
8823    *
8824    * To use the resulting buffer as an image, you'll want to do something like:
8825    *
8826    *   const blob = new Blob([buffer], { type: 'image/jpeg' })
8827    *   document.querySelector('#photo').src = URL.createObjectURL(blob)
8828    */
8829   resolve: (doc, node) => {
8830     const src = resolveSeq$2.resolveString(doc, node);
8831
8832     if (typeof Buffer === 'function') {
8833       return Buffer.from(src, 'base64');
8834     } else if (typeof atob === 'function') {
8835       // On IE 11, atob() can't handle newlines
8836       const str = atob(src.replace(/[\n\r]/g, ''));
8837       const buffer = new Uint8Array(str.length);
8838
8839       for (let i = 0; i < str.length; ++i) buffer[i] = str.charCodeAt(i);
8840
8841       return buffer;
8842     } else {
8843       const msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
8844       doc.errors.push(new PlainValue$3.YAMLReferenceError(node, msg));
8845       return null;
8846     }
8847   },
8848   options: resolveSeq$2.binaryOptions,
8849   stringify: ({
8850     comment,
8851     type,
8852     value
8853   }, ctx, onComment, onChompKeep) => {
8854     let src;
8855
8856     if (typeof Buffer === 'function') {
8857       src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64');
8858     } else if (typeof btoa === 'function') {
8859       let s = '';
8860
8861       for (let i = 0; i < value.length; ++i) s += String.fromCharCode(value[i]);
8862
8863       src = btoa(s);
8864     } else {
8865       throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
8866     }
8867
8868     if (!type) type = resolveSeq$2.binaryOptions.defaultType;
8869
8870     if (type === PlainValue$3.Type.QUOTE_DOUBLE) {
8871       value = src;
8872     } else {
8873       const {
8874         lineWidth
8875       } = resolveSeq$2.binaryOptions;
8876       const n = Math.ceil(src.length / lineWidth);
8877       const lines = new Array(n);
8878
8879       for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
8880         lines[i] = src.substr(o, lineWidth);
8881       }
8882
8883       value = lines.join(type === PlainValue$3.Type.BLOCK_LITERAL ? '\n' : ' ');
8884     }
8885
8886     return resolveSeq$2.stringifyString({
8887       comment,
8888       type,
8889       value
8890     }, ctx, onComment, onChompKeep);
8891   }
8892 };
8893
8894 function parsePairs(doc, cst) {
8895   const seq = resolveSeq$2.resolveSeq(doc, cst);
8896
8897   for (let i = 0; i < seq.items.length; ++i) {
8898     let item = seq.items[i];
8899     if (item instanceof resolveSeq$2.Pair) continue;else if (item instanceof resolveSeq$2.YAMLMap) {
8900       if (item.items.length > 1) {
8901         const msg = 'Each pair must have its own sequence indicator';
8902         throw new PlainValue$3.YAMLSemanticError(cst, msg);
8903       }
8904
8905       const pair = item.items[0] || new resolveSeq$2.Pair();
8906       if (item.commentBefore) pair.commentBefore = pair.commentBefore ? `${item.commentBefore}\n${pair.commentBefore}` : item.commentBefore;
8907       if (item.comment) pair.comment = pair.comment ? `${item.comment}\n${pair.comment}` : item.comment;
8908       item = pair;
8909     }
8910     seq.items[i] = item instanceof resolveSeq$2.Pair ? item : new resolveSeq$2.Pair(item);
8911   }
8912
8913   return seq;
8914 }
8915
8916 function createPairs(schema, iterable, ctx) {
8917   const pairs = new resolveSeq$2.YAMLSeq(schema);
8918   pairs.tag = 'tag:yaml.org,2002:pairs';
8919
8920   for (const it of iterable) {
8921     let key, value;
8922
8923     if (Array.isArray(it)) {
8924       if (it.length === 2) {
8925         key = it[0];
8926         value = it[1];
8927       } else throw new TypeError(`Expected [key, value] tuple: ${it}`);
8928     } else if (it && it instanceof Object) {
8929       const keys = Object.keys(it);
8930
8931       if (keys.length === 1) {
8932         key = keys[0];
8933         value = it[key];
8934       } else throw new TypeError(`Expected { key: value } tuple: ${it}`);
8935     } else {
8936       key = it;
8937     }
8938
8939     const pair = schema.createPair(key, value, ctx);
8940     pairs.items.push(pair);
8941   }
8942
8943   return pairs;
8944 }
8945
8946 const pairs = {
8947   default: false,
8948   tag: 'tag:yaml.org,2002:pairs',
8949   resolve: parsePairs,
8950   createNode: createPairs
8951 };
8952
8953 class YAMLOMap extends resolveSeq$2.YAMLSeq {
8954   constructor() {
8955     super();
8956
8957     PlainValue$3._defineProperty(this, "add", resolveSeq$2.YAMLMap.prototype.add.bind(this));
8958
8959     PlainValue$3._defineProperty(this, "delete", resolveSeq$2.YAMLMap.prototype.delete.bind(this));
8960
8961     PlainValue$3._defineProperty(this, "get", resolveSeq$2.YAMLMap.prototype.get.bind(this));
8962
8963     PlainValue$3._defineProperty(this, "has", resolveSeq$2.YAMLMap.prototype.has.bind(this));
8964
8965     PlainValue$3._defineProperty(this, "set", resolveSeq$2.YAMLMap.prototype.set.bind(this));
8966
8967     this.tag = YAMLOMap.tag;
8968   }
8969
8970   toJSON(_, ctx) {
8971     const map = new Map();
8972     if (ctx && ctx.onCreate) ctx.onCreate(map);
8973
8974     for (const pair of this.items) {
8975       let key, value;
8976
8977       if (pair instanceof resolveSeq$2.Pair) {
8978         key = resolveSeq$2.toJSON(pair.key, '', ctx);
8979         value = resolveSeq$2.toJSON(pair.value, key, ctx);
8980       } else {
8981         key = resolveSeq$2.toJSON(pair, '', ctx);
8982       }
8983
8984       if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys');
8985       map.set(key, value);
8986     }
8987
8988     return map;
8989   }
8990
8991 }
8992
8993 PlainValue$3._defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
8994
8995 function parseOMap(doc, cst) {
8996   const pairs = parsePairs(doc, cst);
8997   const seenKeys = [];
8998
8999   for (const {
9000     key
9001   } of pairs.items) {
9002     if (key instanceof resolveSeq$2.Scalar) {
9003       if (seenKeys.includes(key.value)) {
9004         const msg = 'Ordered maps must not include duplicate keys';
9005         throw new PlainValue$3.YAMLSemanticError(cst, msg);
9006       } else {
9007         seenKeys.push(key.value);
9008       }
9009     }
9010   }
9011
9012   return Object.assign(new YAMLOMap(), pairs);
9013 }
9014
9015 function createOMap(schema, iterable, ctx) {
9016   const pairs = createPairs(schema, iterable, ctx);
9017   const omap = new YAMLOMap();
9018   omap.items = pairs.items;
9019   return omap;
9020 }
9021
9022 const omap = {
9023   identify: value => value instanceof Map,
9024   nodeClass: YAMLOMap,
9025   default: false,
9026   tag: 'tag:yaml.org,2002:omap',
9027   resolve: parseOMap,
9028   createNode: createOMap
9029 };
9030
9031 class YAMLSet extends resolveSeq$2.YAMLMap {
9032   constructor() {
9033     super();
9034     this.tag = YAMLSet.tag;
9035   }
9036
9037   add(key) {
9038     const pair = key instanceof resolveSeq$2.Pair ? key : new resolveSeq$2.Pair(key);
9039     const prev = resolveSeq$2.findPair(this.items, pair.key);
9040     if (!prev) this.items.push(pair);
9041   }
9042
9043   get(key, keepPair) {
9044     const pair = resolveSeq$2.findPair(this.items, key);
9045     return !keepPair && pair instanceof resolveSeq$2.Pair ? pair.key instanceof resolveSeq$2.Scalar ? pair.key.value : pair.key : pair;
9046   }
9047
9048   set(key, value) {
9049     if (typeof value !== 'boolean') throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value}`);
9050     const prev = resolveSeq$2.findPair(this.items, key);
9051
9052     if (prev && !value) {
9053       this.items.splice(this.items.indexOf(prev), 1);
9054     } else if (!prev && value) {
9055       this.items.push(new resolveSeq$2.Pair(key));
9056     }
9057   }
9058
9059   toJSON(_, ctx) {
9060     return super.toJSON(_, ctx, Set);
9061   }
9062
9063   toString(ctx, onComment, onChompKeep) {
9064     if (!ctx) return JSON.stringify(this);
9065     if (this.hasAllNullValues()) return super.toString(ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values');
9066   }
9067
9068 }
9069
9070 PlainValue$3._defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set');
9071
9072 function parseSet(doc, cst) {
9073   const map = resolveSeq$2.resolveMap(doc, cst);
9074   if (!map.hasAllNullValues()) throw new PlainValue$3.YAMLSemanticError(cst, 'Set items must all have null values');
9075   return Object.assign(new YAMLSet(), map);
9076 }
9077
9078 function createSet(schema, iterable, ctx) {
9079   const set = new YAMLSet();
9080
9081   for (const value of iterable) set.items.push(schema.createPair(value, null, ctx));
9082
9083   return set;
9084 }
9085
9086 const set = {
9087   identify: value => value instanceof Set,
9088   nodeClass: YAMLSet,
9089   default: false,
9090   tag: 'tag:yaml.org,2002:set',
9091   resolve: parseSet,
9092   createNode: createSet
9093 };
9094
9095 const parseSexagesimal = (sign, parts) => {
9096   const n = parts.split(':').reduce((n, p) => n * 60 + Number(p), 0);
9097   return sign === '-' ? -n : n;
9098 }; // hhhh:mm:ss.sss
9099
9100
9101 const stringifySexagesimal = ({
9102   value
9103 }) => {
9104   if (isNaN(value) || !isFinite(value)) return resolveSeq$2.stringifyNumber(value);
9105   let sign = '';
9106
9107   if (value < 0) {
9108     sign = '-';
9109     value = Math.abs(value);
9110   }
9111
9112   const parts = [value % 60]; // seconds, including ms
9113
9114   if (value < 60) {
9115     parts.unshift(0); // at least one : is required
9116   } else {
9117     value = Math.round((value - parts[0]) / 60);
9118     parts.unshift(value % 60); // minutes
9119
9120     if (value >= 60) {
9121       value = Math.round((value - parts[0]) / 60);
9122       parts.unshift(value); // hours
9123     }
9124   }
9125
9126   return sign + parts.map(n => n < 10 ? '0' + String(n) : String(n)).join(':').replace(/000000\d*$/, '') // % 60 may introduce error
9127   ;
9128 };
9129
9130 const intTime = {
9131   identify: value => typeof value === 'number',
9132   default: true,
9133   tag: 'tag:yaml.org,2002:int',
9134   format: 'TIME',
9135   test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/,
9136   resolve: (str, sign, parts) => parseSexagesimal(sign, parts.replace(/_/g, '')),
9137   stringify: stringifySexagesimal
9138 };
9139 const floatTime = {
9140   identify: value => typeof value === 'number',
9141   default: true,
9142   tag: 'tag:yaml.org,2002:float',
9143   format: 'TIME',
9144   test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/,
9145   resolve: (str, sign, parts) => parseSexagesimal(sign, parts.replace(/_/g, '')),
9146   stringify: stringifySexagesimal
9147 };
9148 const timestamp = {
9149   identify: value => value instanceof Date,
9150   default: true,
9151   tag: 'tag:yaml.org,2002:timestamp',
9152   // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
9153   // may be omitted altogether, resulting in a date format. In such a case, the time part is
9154   // assumed to be 00:00:00Z (start of day, UTC).
9155   test: RegExp('^(?:' + '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})' + // YYYY-Mm-Dd
9156   '(?:(?:t|T|[ \\t]+)' + // t | T | whitespace
9157   '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)' + // Hh:Mm:Ss(.ss)?
9158   '(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30
9159   ')?' + ')$'),
9160   resolve: (str, year, month, day, hour, minute, second, millisec, tz) => {
9161     if (millisec) millisec = (millisec + '00').substr(1, 3);
9162     let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec || 0);
9163
9164     if (tz && tz !== 'Z') {
9165       let d = parseSexagesimal(tz[0], tz.slice(1));
9166       if (Math.abs(d) < 30) d *= 60;
9167       date -= 60000 * d;
9168     }
9169
9170     return new Date(date);
9171   },
9172   stringify: ({
9173     value
9174   }) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
9175 };
9176 /* global console, process, YAML_SILENCE_DEPRECATION_WARNINGS, YAML_SILENCE_WARNINGS */
9177
9178 function shouldWarn(deprecation) {
9179   const env = typeof process !== 'undefined' && process.env || {};
9180
9181   if (deprecation) {
9182     if (typeof YAML_SILENCE_DEPRECATION_WARNINGS !== 'undefined') return !YAML_SILENCE_DEPRECATION_WARNINGS;
9183     return !env.YAML_SILENCE_DEPRECATION_WARNINGS;
9184   }
9185
9186   if (typeof YAML_SILENCE_WARNINGS !== 'undefined') return !YAML_SILENCE_WARNINGS;
9187   return !env.YAML_SILENCE_WARNINGS;
9188 }
9189
9190 function warn(warning, type) {
9191   if (shouldWarn(false)) {
9192     const emit = typeof process !== 'undefined' && process.emitWarning; // This will throw in Jest if `warning` is an Error instance due to
9193     // https://github.com/facebook/jest/issues/2549
9194
9195     if (emit) emit(warning, type);else {
9196       // eslint-disable-next-line no-console
9197       console.warn(type ? `${type}: ${warning}` : warning);
9198     }
9199   }
9200 }
9201
9202 function warnFileDeprecation(filename) {
9203   if (shouldWarn(true)) {
9204     const path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/');
9205     warn(`The endpoint 'yaml/${path}' will be removed in a future release.`, 'DeprecationWarning');
9206   }
9207 }
9208
9209 const warned = {};
9210
9211 function warnOptionDeprecation(name, alternative) {
9212   if (!warned[name] && shouldWarn(true)) {
9213     warned[name] = true;
9214     let msg = `The option '${name}' will be removed in a future release`;
9215     msg += alternative ? `, use '${alternative}' instead.` : '.';
9216     warn(msg, 'DeprecationWarning');
9217   }
9218 }
9219
9220 warnings1000a372.binary = binary;
9221 warnings1000a372.floatTime = floatTime;
9222 warnings1000a372.intTime = intTime;
9223 warnings1000a372.omap = omap;
9224 warnings1000a372.pairs = pairs;
9225 warnings1000a372.set = set;
9226 warnings1000a372.timestamp = timestamp;
9227 warnings1000a372.warn = warn;
9228 warnings1000a372.warnFileDeprecation = warnFileDeprecation;
9229 warnings1000a372.warnOptionDeprecation = warnOptionDeprecation;
9230
9231 var PlainValue$2 = PlainValueEc8e588e;
9232 var resolveSeq$1 = resolveSeqD03cb037;
9233 var warnings$1 = warnings1000a372;
9234
9235 function createMap(schema, obj, ctx) {
9236   const map = new resolveSeq$1.YAMLMap(schema);
9237
9238   if (obj instanceof Map) {
9239     for (const [key, value] of obj) map.items.push(schema.createPair(key, value, ctx));
9240   } else if (obj && typeof obj === 'object') {
9241     for (const key of Object.keys(obj)) map.items.push(schema.createPair(key, obj[key], ctx));
9242   }
9243
9244   if (typeof schema.sortMapEntries === 'function') {
9245     map.items.sort(schema.sortMapEntries);
9246   }
9247
9248   return map;
9249 }
9250
9251 const map = {
9252   createNode: createMap,
9253   default: true,
9254   nodeClass: resolveSeq$1.YAMLMap,
9255   tag: 'tag:yaml.org,2002:map',
9256   resolve: resolveSeq$1.resolveMap
9257 };
9258
9259 function createSeq(schema, obj, ctx) {
9260   const seq = new resolveSeq$1.YAMLSeq(schema);
9261
9262   if (obj && obj[Symbol.iterator]) {
9263     for (const it of obj) {
9264       const v = schema.createNode(it, ctx.wrapScalars, null, ctx);
9265       seq.items.push(v);
9266     }
9267   }
9268
9269   return seq;
9270 }
9271
9272 const seq = {
9273   createNode: createSeq,
9274   default: true,
9275   nodeClass: resolveSeq$1.YAMLSeq,
9276   tag: 'tag:yaml.org,2002:seq',
9277   resolve: resolveSeq$1.resolveSeq
9278 };
9279 const string = {
9280   identify: value => typeof value === 'string',
9281   default: true,
9282   tag: 'tag:yaml.org,2002:str',
9283   resolve: resolveSeq$1.resolveString,
9284
9285   stringify(item, ctx, onComment, onChompKeep) {
9286     ctx = Object.assign({
9287       actualString: true
9288     }, ctx);
9289     return resolveSeq$1.stringifyString(item, ctx, onComment, onChompKeep);
9290   },
9291
9292   options: resolveSeq$1.strOptions
9293 };
9294 const failsafe = [map, seq, string];
9295 /* global BigInt */
9296
9297 const intIdentify$2 = value => typeof value === 'bigint' || Number.isInteger(value);
9298
9299 const intResolve$1 = (src, part, radix) => resolveSeq$1.intOptions.asBigInt ? BigInt(src) : parseInt(part, radix);
9300
9301 function intStringify$1(node, radix, prefix) {
9302   const {
9303     value
9304   } = node;
9305   if (intIdentify$2(value) && value >= 0) return prefix + value.toString(radix);
9306   return resolveSeq$1.stringifyNumber(node);
9307 }
9308
9309 const nullObj = {
9310   identify: value => value == null,
9311   createNode: (schema, value, ctx) => ctx.wrapScalars ? new resolveSeq$1.Scalar(null) : null,
9312   default: true,
9313   tag: 'tag:yaml.org,2002:null',
9314   test: /^(?:~|[Nn]ull|NULL)?$/,
9315   resolve: () => null,
9316   options: resolveSeq$1.nullOptions,
9317   stringify: () => resolveSeq$1.nullOptions.nullStr
9318 };
9319 const boolObj = {
9320   identify: value => typeof value === 'boolean',
9321   default: true,
9322   tag: 'tag:yaml.org,2002:bool',
9323   test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
9324   resolve: str => str[0] === 't' || str[0] === 'T',
9325   options: resolveSeq$1.boolOptions,
9326   stringify: ({
9327     value
9328   }) => value ? resolveSeq$1.boolOptions.trueStr : resolveSeq$1.boolOptions.falseStr
9329 };
9330 const octObj = {
9331   identify: value => intIdentify$2(value) && value >= 0,
9332   default: true,
9333   tag: 'tag:yaml.org,2002:int',
9334   format: 'OCT',
9335   test: /^0o([0-7]+)$/,
9336   resolve: (str, oct) => intResolve$1(str, oct, 8),
9337   options: resolveSeq$1.intOptions,
9338   stringify: node => intStringify$1(node, 8, '0o')
9339 };
9340 const intObj = {
9341   identify: intIdentify$2,
9342   default: true,
9343   tag: 'tag:yaml.org,2002:int',
9344   test: /^[-+]?[0-9]+$/,
9345   resolve: str => intResolve$1(str, str, 10),
9346   options: resolveSeq$1.intOptions,
9347   stringify: resolveSeq$1.stringifyNumber
9348 };
9349 const hexObj = {
9350   identify: value => intIdentify$2(value) && value >= 0,
9351   default: true,
9352   tag: 'tag:yaml.org,2002:int',
9353   format: 'HEX',
9354   test: /^0x([0-9a-fA-F]+)$/,
9355   resolve: (str, hex) => intResolve$1(str, hex, 16),
9356   options: resolveSeq$1.intOptions,
9357   stringify: node => intStringify$1(node, 16, '0x')
9358 };
9359 const nanObj = {
9360   identify: value => typeof value === 'number',
9361   default: true,
9362   tag: 'tag:yaml.org,2002:float',
9363   test: /^(?:[-+]?\.inf|(\.nan))$/i,
9364   resolve: (str, nan) => nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
9365   stringify: resolveSeq$1.stringifyNumber
9366 };
9367 const expObj = {
9368   identify: value => typeof value === 'number',
9369   default: true,
9370   tag: 'tag:yaml.org,2002:float',
9371   format: 'EXP',
9372   test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
9373   resolve: str => parseFloat(str),
9374   stringify: ({
9375     value
9376   }) => Number(value).toExponential()
9377 };
9378 const floatObj = {
9379   identify: value => typeof value === 'number',
9380   default: true,
9381   tag: 'tag:yaml.org,2002:float',
9382   test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,
9383
9384   resolve(str, frac1, frac2) {
9385     const frac = frac1 || frac2;
9386     const node = new resolveSeq$1.Scalar(parseFloat(str));
9387     if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length;
9388     return node;
9389   },
9390
9391   stringify: resolveSeq$1.stringifyNumber
9392 };
9393 const core = failsafe.concat([nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj]);
9394 /* global BigInt */
9395
9396 const intIdentify$1 = value => typeof value === 'bigint' || Number.isInteger(value);
9397
9398 const stringifyJSON = ({
9399   value
9400 }) => JSON.stringify(value);
9401
9402 const json = [map, seq, {
9403   identify: value => typeof value === 'string',
9404   default: true,
9405   tag: 'tag:yaml.org,2002:str',
9406   resolve: resolveSeq$1.resolveString,
9407   stringify: stringifyJSON
9408 }, {
9409   identify: value => value == null,
9410   createNode: (schema, value, ctx) => ctx.wrapScalars ? new resolveSeq$1.Scalar(null) : null,
9411   default: true,
9412   tag: 'tag:yaml.org,2002:null',
9413   test: /^null$/,
9414   resolve: () => null,
9415   stringify: stringifyJSON
9416 }, {
9417   identify: value => typeof value === 'boolean',
9418   default: true,
9419   tag: 'tag:yaml.org,2002:bool',
9420   test: /^true|false$/,
9421   resolve: str => str === 'true',
9422   stringify: stringifyJSON
9423 }, {
9424   identify: intIdentify$1,
9425   default: true,
9426   tag: 'tag:yaml.org,2002:int',
9427   test: /^-?(?:0|[1-9][0-9]*)$/,
9428   resolve: str => resolveSeq$1.intOptions.asBigInt ? BigInt(str) : parseInt(str, 10),
9429   stringify: ({
9430     value
9431   }) => intIdentify$1(value) ? value.toString() : JSON.stringify(value)
9432 }, {
9433   identify: value => typeof value === 'number',
9434   default: true,
9435   tag: 'tag:yaml.org,2002:float',
9436   test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
9437   resolve: str => parseFloat(str),
9438   stringify: stringifyJSON
9439 }];
9440
9441 json.scalarFallback = str => {
9442   throw new SyntaxError(`Unresolved plain scalar ${JSON.stringify(str)}`);
9443 };
9444 /* global BigInt */
9445
9446
9447 const boolStringify = ({
9448   value
9449 }) => value ? resolveSeq$1.boolOptions.trueStr : resolveSeq$1.boolOptions.falseStr;
9450
9451 const intIdentify = value => typeof value === 'bigint' || Number.isInteger(value);
9452
9453 function intResolve(sign, src, radix) {
9454   let str = src.replace(/_/g, '');
9455
9456   if (resolveSeq$1.intOptions.asBigInt) {
9457     switch (radix) {
9458       case 2:
9459         str = `0b${str}`;
9460         break;
9461
9462       case 8:
9463         str = `0o${str}`;
9464         break;
9465
9466       case 16:
9467         str = `0x${str}`;
9468         break;
9469     }
9470
9471     const n = BigInt(str);
9472     return sign === '-' ? BigInt(-1) * n : n;
9473   }
9474
9475   const n = parseInt(str, radix);
9476   return sign === '-' ? -1 * n : n;
9477 }
9478
9479 function intStringify(node, radix, prefix) {
9480   const {
9481     value
9482   } = node;
9483
9484   if (intIdentify(value)) {
9485     const str = value.toString(radix);
9486     return value < 0 ? '-' + prefix + str.substr(1) : prefix + str;
9487   }
9488
9489   return resolveSeq$1.stringifyNumber(node);
9490 }
9491
9492 const yaml11 = failsafe.concat([{
9493   identify: value => value == null,
9494   createNode: (schema, value, ctx) => ctx.wrapScalars ? new resolveSeq$1.Scalar(null) : null,
9495   default: true,
9496   tag: 'tag:yaml.org,2002:null',
9497   test: /^(?:~|[Nn]ull|NULL)?$/,
9498   resolve: () => null,
9499   options: resolveSeq$1.nullOptions,
9500   stringify: () => resolveSeq$1.nullOptions.nullStr
9501 }, {
9502   identify: value => typeof value === 'boolean',
9503   default: true,
9504   tag: 'tag:yaml.org,2002:bool',
9505   test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
9506   resolve: () => true,
9507   options: resolveSeq$1.boolOptions,
9508   stringify: boolStringify
9509 }, {
9510   identify: value => typeof value === 'boolean',
9511   default: true,
9512   tag: 'tag:yaml.org,2002:bool',
9513   test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
9514   resolve: () => false,
9515   options: resolveSeq$1.boolOptions,
9516   stringify: boolStringify
9517 }, {
9518   identify: intIdentify,
9519   default: true,
9520   tag: 'tag:yaml.org,2002:int',
9521   format: 'BIN',
9522   test: /^([-+]?)0b([0-1_]+)$/,
9523   resolve: (str, sign, bin) => intResolve(sign, bin, 2),
9524   stringify: node => intStringify(node, 2, '0b')
9525 }, {
9526   identify: intIdentify,
9527   default: true,
9528   tag: 'tag:yaml.org,2002:int',
9529   format: 'OCT',
9530   test: /^([-+]?)0([0-7_]+)$/,
9531   resolve: (str, sign, oct) => intResolve(sign, oct, 8),
9532   stringify: node => intStringify(node, 8, '0')
9533 }, {
9534   identify: intIdentify,
9535   default: true,
9536   tag: 'tag:yaml.org,2002:int',
9537   test: /^([-+]?)([0-9][0-9_]*)$/,
9538   resolve: (str, sign, abs) => intResolve(sign, abs, 10),
9539   stringify: resolveSeq$1.stringifyNumber
9540 }, {
9541   identify: intIdentify,
9542   default: true,
9543   tag: 'tag:yaml.org,2002:int',
9544   format: 'HEX',
9545   test: /^([-+]?)0x([0-9a-fA-F_]+)$/,
9546   resolve: (str, sign, hex) => intResolve(sign, hex, 16),
9547   stringify: node => intStringify(node, 16, '0x')
9548 }, {
9549   identify: value => typeof value === 'number',
9550   default: true,
9551   tag: 'tag:yaml.org,2002:float',
9552   test: /^(?:[-+]?\.inf|(\.nan))$/i,
9553   resolve: (str, nan) => nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
9554   stringify: resolveSeq$1.stringifyNumber
9555 }, {
9556   identify: value => typeof value === 'number',
9557   default: true,
9558   tag: 'tag:yaml.org,2002:float',
9559   format: 'EXP',
9560   test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,
9561   resolve: str => parseFloat(str.replace(/_/g, '')),
9562   stringify: ({
9563     value
9564   }) => Number(value).toExponential()
9565 }, {
9566   identify: value => typeof value === 'number',
9567   default: true,
9568   tag: 'tag:yaml.org,2002:float',
9569   test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,
9570
9571   resolve(str, frac) {
9572     const node = new resolveSeq$1.Scalar(parseFloat(str.replace(/_/g, '')));
9573
9574     if (frac) {
9575       const f = frac.replace(/_/g, '');
9576       if (f[f.length - 1] === '0') node.minFractionDigits = f.length;
9577     }
9578
9579     return node;
9580   },
9581
9582   stringify: resolveSeq$1.stringifyNumber
9583 }], warnings$1.binary, warnings$1.omap, warnings$1.pairs, warnings$1.set, warnings$1.intTime, warnings$1.floatTime, warnings$1.timestamp);
9584 const schemas = {
9585   core,
9586   failsafe,
9587   json,
9588   yaml11
9589 };
9590 const tags = {
9591   binary: warnings$1.binary,
9592   bool: boolObj,
9593   float: floatObj,
9594   floatExp: expObj,
9595   floatNaN: nanObj,
9596   floatTime: warnings$1.floatTime,
9597   int: intObj,
9598   intHex: hexObj,
9599   intOct: octObj,
9600   intTime: warnings$1.intTime,
9601   map,
9602   null: nullObj,
9603   omap: warnings$1.omap,
9604   pairs: warnings$1.pairs,
9605   seq,
9606   set: warnings$1.set,
9607   timestamp: warnings$1.timestamp
9608 };
9609
9610 function findTagObject(value, tagName, tags) {
9611   if (tagName) {
9612     const match = tags.filter(t => t.tag === tagName);
9613     const tagObj = match.find(t => !t.format) || match[0];
9614     if (!tagObj) throw new Error(`Tag ${tagName} not found`);
9615     return tagObj;
9616   } // TODO: deprecate/remove class check
9617
9618
9619   return tags.find(t => (t.identify && t.identify(value) || t.class && value instanceof t.class) && !t.format);
9620 }
9621
9622 function createNode$1(value, tagName, ctx) {
9623   if (value instanceof resolveSeq$1.Node) return value;
9624   const {
9625     defaultPrefix,
9626     onTagObj,
9627     prevObjects,
9628     schema,
9629     wrapScalars
9630   } = ctx;
9631   if (tagName && tagName.startsWith('!!')) tagName = defaultPrefix + tagName.slice(2);
9632   let tagObj = findTagObject(value, tagName, schema.tags);
9633
9634   if (!tagObj) {
9635     if (typeof value.toJSON === 'function') value = value.toJSON();
9636     if (!value || typeof value !== 'object') return wrapScalars ? new resolveSeq$1.Scalar(value) : value;
9637     tagObj = value instanceof Map ? map : value[Symbol.iterator] ? seq : map;
9638   }
9639
9640   if (onTagObj) {
9641     onTagObj(tagObj);
9642     delete ctx.onTagObj;
9643   } // Detect duplicate references to the same object & use Alias nodes for all
9644   // after first. The `obj` wrapper allows for circular references to resolve.
9645
9646
9647   const obj = {
9648     value: undefined,
9649     node: undefined
9650   };
9651
9652   if (value && typeof value === 'object' && prevObjects) {
9653     const prev = prevObjects.get(value);
9654
9655     if (prev) {
9656       const alias = new resolveSeq$1.Alias(prev); // leaves source dirty; must be cleaned by caller
9657
9658       ctx.aliasNodes.push(alias); // defined along with prevObjects
9659
9660       return alias;
9661     }
9662
9663     obj.value = value;
9664     prevObjects.set(value, obj);
9665   }
9666
9667   obj.node = tagObj.createNode ? tagObj.createNode(ctx.schema, value, ctx) : wrapScalars ? new resolveSeq$1.Scalar(value) : value;
9668   if (tagName && obj.node instanceof resolveSeq$1.Node) obj.node.tag = tagName;
9669   return obj.node;
9670 }
9671
9672 function getSchemaTags(schemas, knownTags, customTags, schemaId) {
9673   let tags = schemas[schemaId.replace(/\W/g, '')]; // 'yaml-1.1' -> 'yaml11'
9674
9675   if (!tags) {
9676     const keys = Object.keys(schemas).map(key => JSON.stringify(key)).join(', ');
9677     throw new Error(`Unknown schema "${schemaId}"; use one of ${keys}`);
9678   }
9679
9680   if (Array.isArray(customTags)) {
9681     for (const tag of customTags) tags = tags.concat(tag);
9682   } else if (typeof customTags === 'function') {
9683     tags = customTags(tags.slice());
9684   }
9685
9686   for (let i = 0; i < tags.length; ++i) {
9687     const tag = tags[i];
9688
9689     if (typeof tag === 'string') {
9690       const tagObj = knownTags[tag];
9691
9692       if (!tagObj) {
9693         const keys = Object.keys(knownTags).map(key => JSON.stringify(key)).join(', ');
9694         throw new Error(`Unknown custom tag "${tag}"; use one of ${keys}`);
9695       }
9696
9697       tags[i] = tagObj;
9698     }
9699   }
9700
9701   return tags;
9702 }
9703
9704 const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
9705
9706 class Schema$2 {
9707   // TODO: remove in v2
9708   // TODO: remove in v2
9709   constructor({
9710     customTags,
9711     merge,
9712     schema,
9713     sortMapEntries,
9714     tags: deprecatedCustomTags
9715   }) {
9716     this.merge = !!merge;
9717     this.name = schema;
9718     this.sortMapEntries = sortMapEntries === true ? sortMapEntriesByKey : sortMapEntries || null;
9719     if (!customTags && deprecatedCustomTags) warnings$1.warnOptionDeprecation('tags', 'customTags');
9720     this.tags = getSchemaTags(schemas, tags, customTags || deprecatedCustomTags, schema);
9721   }
9722
9723   createNode(value, wrapScalars, tagName, ctx) {
9724     const baseCtx = {
9725       defaultPrefix: Schema$2.defaultPrefix,
9726       schema: this,
9727       wrapScalars
9728     };
9729     const createCtx = ctx ? Object.assign(ctx, baseCtx) : baseCtx;
9730     return createNode$1(value, tagName, createCtx);
9731   }
9732
9733   createPair(key, value, ctx) {
9734     if (!ctx) ctx = {
9735       wrapScalars: true
9736     };
9737     const k = this.createNode(key, ctx.wrapScalars, null, ctx);
9738     const v = this.createNode(value, ctx.wrapScalars, null, ctx);
9739     return new resolveSeq$1.Pair(k, v);
9740   }
9741
9742 }
9743
9744 PlainValue$2._defineProperty(Schema$2, "defaultPrefix", PlainValue$2.defaultTagPrefix);
9745
9746 PlainValue$2._defineProperty(Schema$2, "defaultTags", PlainValue$2.defaultTags);
9747
9748 Schema88e323a7.Schema = Schema$2;
9749
9750 var PlainValue$1 = PlainValueEc8e588e;
9751 var resolveSeq = resolveSeqD03cb037;
9752 var Schema$1 = Schema88e323a7;
9753 const defaultOptions = {
9754   anchorPrefix: 'a',
9755   customTags: null,
9756   indent: 2,
9757   indentSeq: true,
9758   keepCstNodes: false,
9759   keepNodeTypes: true,
9760   keepBlobsInJSON: true,
9761   mapAsMap: false,
9762   maxAliasCount: 100,
9763   prettyErrors: false,
9764   // TODO Set true in v2
9765   simpleKeys: false,
9766   version: '1.2'
9767 };
9768 const scalarOptions = {
9769   get binary() {
9770     return resolveSeq.binaryOptions;
9771   },
9772
9773   set binary(opt) {
9774     Object.assign(resolveSeq.binaryOptions, opt);
9775   },
9776
9777   get bool() {
9778     return resolveSeq.boolOptions;
9779   },
9780
9781   set bool(opt) {
9782     Object.assign(resolveSeq.boolOptions, opt);
9783   },
9784
9785   get int() {
9786     return resolveSeq.intOptions;
9787   },
9788
9789   set int(opt) {
9790     Object.assign(resolveSeq.intOptions, opt);
9791   },
9792
9793   get null() {
9794     return resolveSeq.nullOptions;
9795   },
9796
9797   set null(opt) {
9798     Object.assign(resolveSeq.nullOptions, opt);
9799   },
9800
9801   get str() {
9802     return resolveSeq.strOptions;
9803   },
9804
9805   set str(opt) {
9806     Object.assign(resolveSeq.strOptions, opt);
9807   }
9808
9809 };
9810 const documentOptions = {
9811   '1.0': {
9812     schema: 'yaml-1.1',
9813     merge: true,
9814     tagPrefixes: [{
9815       handle: '!',
9816       prefix: PlainValue$1.defaultTagPrefix
9817     }, {
9818       handle: '!!',
9819       prefix: 'tag:private.yaml.org,2002:'
9820     }]
9821   },
9822   1.1: {
9823     schema: 'yaml-1.1',
9824     merge: true,
9825     tagPrefixes: [{
9826       handle: '!',
9827       prefix: '!'
9828     }, {
9829       handle: '!!',
9830       prefix: PlainValue$1.defaultTagPrefix
9831     }]
9832   },
9833   1.2: {
9834     schema: 'core',
9835     merge: false,
9836     tagPrefixes: [{
9837       handle: '!',
9838       prefix: '!'
9839     }, {
9840       handle: '!!',
9841       prefix: PlainValue$1.defaultTagPrefix
9842     }]
9843   }
9844 };
9845
9846 function stringifyTag(doc, tag) {
9847   if ((doc.version || doc.options.version) === '1.0') {
9848     const priv = tag.match(/^tag:private\.yaml\.org,2002:([^:/]+)$/);
9849     if (priv) return '!' + priv[1];
9850     const vocab = tag.match(/^tag:([a-zA-Z0-9-]+)\.yaml\.org,2002:(.*)/);
9851     return vocab ? `!${vocab[1]}/${vocab[2]}` : `!${tag.replace(/^tag:/, '')}`;
9852   }
9853
9854   let p = doc.tagPrefixes.find(p => tag.indexOf(p.prefix) === 0);
9855
9856   if (!p) {
9857     const dtp = doc.getDefaults().tagPrefixes;
9858     p = dtp && dtp.find(p => tag.indexOf(p.prefix) === 0);
9859   }
9860
9861   if (!p) return tag[0] === '!' ? tag : `!<${tag}>`;
9862   const suffix = tag.substr(p.prefix.length).replace(/[!,[\]{}]/g, ch => ({
9863     '!': '%21',
9864     ',': '%2C',
9865     '[': '%5B',
9866     ']': '%5D',
9867     '{': '%7B',
9868     '}': '%7D'
9869   })[ch]);
9870   return p.handle + suffix;
9871 }
9872
9873 function getTagObject(tags, item) {
9874   if (item instanceof resolveSeq.Alias) return resolveSeq.Alias;
9875
9876   if (item.tag) {
9877     const match = tags.filter(t => t.tag === item.tag);
9878     if (match.length > 0) return match.find(t => t.format === item.format) || match[0];
9879   }
9880
9881   let tagObj, obj;
9882
9883   if (item instanceof resolveSeq.Scalar) {
9884     obj = item.value; // TODO: deprecate/remove class check
9885
9886     const match = tags.filter(t => t.identify && t.identify(obj) || t.class && obj instanceof t.class);
9887     tagObj = match.find(t => t.format === item.format) || match.find(t => !t.format);
9888   } else {
9889     obj = item;
9890     tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
9891   }
9892
9893   if (!tagObj) {
9894     const name = obj && obj.constructor ? obj.constructor.name : typeof obj;
9895     throw new Error(`Tag not resolved for ${name} value`);
9896   }
9897
9898   return tagObj;
9899 } // needs to be called before value stringifier to allow for circular anchor refs
9900
9901
9902 function stringifyProps(node, tagObj, {
9903   anchors,
9904   doc
9905 }) {
9906   const props = [];
9907   const anchor = doc.anchors.getName(node);
9908
9909   if (anchor) {
9910     anchors[anchor] = node;
9911     props.push(`&${anchor}`);
9912   }
9913
9914   if (node.tag) {
9915     props.push(stringifyTag(doc, node.tag));
9916   } else if (!tagObj.default) {
9917     props.push(stringifyTag(doc, tagObj.tag));
9918   }
9919
9920   return props.join(' ');
9921 }
9922
9923 function stringify$1(item, ctx, onComment, onChompKeep) {
9924   const {
9925     anchors,
9926     schema
9927   } = ctx.doc;
9928   let tagObj;
9929
9930   if (!(item instanceof resolveSeq.Node)) {
9931     const createCtx = {
9932       aliasNodes: [],
9933       onTagObj: o => tagObj = o,
9934       prevObjects: new Map()
9935     };
9936     item = schema.createNode(item, true, null, createCtx);
9937
9938     for (const alias of createCtx.aliasNodes) {
9939       alias.source = alias.source.node;
9940       let name = anchors.getName(alias.source);
9941
9942       if (!name) {
9943         name = anchors.newName();
9944         anchors.map[name] = alias.source;
9945       }
9946     }
9947   }
9948
9949   if (item instanceof resolveSeq.Pair) return item.toString(ctx, onComment, onChompKeep);
9950   if (!tagObj) tagObj = getTagObject(schema.tags, item);
9951   const props = stringifyProps(item, tagObj, ctx);
9952   if (props.length > 0) ctx.indentAtStart = (ctx.indentAtStart || 0) + props.length + 1;
9953   const str = typeof tagObj.stringify === 'function' ? tagObj.stringify(item, ctx, onComment, onChompKeep) : item instanceof resolveSeq.Scalar ? resolveSeq.stringifyString(item, ctx, onComment, onChompKeep) : item.toString(ctx, onComment, onChompKeep);
9954   if (!props) return str;
9955   return item instanceof resolveSeq.Scalar || str[0] === '{' || str[0] === '[' ? `${props} ${str}` : `${props}\n${ctx.indent}${str}`;
9956 }
9957
9958 class Anchors {
9959   static validAnchorNode(node) {
9960     return node instanceof resolveSeq.Scalar || node instanceof resolveSeq.YAMLSeq || node instanceof resolveSeq.YAMLMap;
9961   }
9962
9963   constructor(prefix) {
9964     PlainValue$1._defineProperty(this, "map", Object.create(null));
9965
9966     this.prefix = prefix;
9967   }
9968
9969   createAlias(node, name) {
9970     this.setAnchor(node, name);
9971     return new resolveSeq.Alias(node);
9972   }
9973
9974   createMergePair(...sources) {
9975     const merge = new resolveSeq.Merge();
9976     merge.value.items = sources.map(s => {
9977       if (s instanceof resolveSeq.Alias) {
9978         if (s.source instanceof resolveSeq.YAMLMap) return s;
9979       } else if (s instanceof resolveSeq.YAMLMap) {
9980         return this.createAlias(s);
9981       }
9982
9983       throw new Error('Merge sources must be Map nodes or their Aliases');
9984     });
9985     return merge;
9986   }
9987
9988   getName(node) {
9989     const {
9990       map
9991     } = this;
9992     return Object.keys(map).find(a => map[a] === node);
9993   }
9994
9995   getNames() {
9996     return Object.keys(this.map);
9997   }
9998
9999   getNode(name) {
10000     return this.map[name];
10001   }
10002
10003   newName(prefix) {
10004     if (!prefix) prefix = this.prefix;
10005     const names = Object.keys(this.map);
10006
10007     for (let i = 1; true; ++i) {
10008       const name = `${prefix}${i}`;
10009       if (!names.includes(name)) return name;
10010     }
10011   } // During parsing, map & aliases contain CST nodes
10012
10013
10014   resolveNodes() {
10015     const {
10016       map,
10017       _cstAliases
10018     } = this;
10019     Object.keys(map).forEach(a => {
10020       map[a] = map[a].resolved;
10021     });
10022
10023     _cstAliases.forEach(a => {
10024       a.source = a.source.resolved;
10025     });
10026
10027     delete this._cstAliases;
10028   }
10029
10030   setAnchor(node, name) {
10031     if (node != null && !Anchors.validAnchorNode(node)) {
10032       throw new Error('Anchors may only be set for Scalar, Seq and Map nodes');
10033     }
10034
10035     if (name && /[\x00-\x19\s,[\]{}]/.test(name)) {
10036       throw new Error('Anchor names must not contain whitespace or control characters');
10037     }
10038
10039     const {
10040       map
10041     } = this;
10042     const prev = node && Object.keys(map).find(a => map[a] === node);
10043
10044     if (prev) {
10045       if (!name) {
10046         return prev;
10047       } else if (prev !== name) {
10048         delete map[prev];
10049         map[name] = node;
10050       }
10051     } else {
10052       if (!name) {
10053         if (!node) return null;
10054         name = this.newName();
10055       }
10056
10057       map[name] = node;
10058     }
10059
10060     return name;
10061   }
10062
10063 }
10064
10065 const visit = (node, tags) => {
10066   if (node && typeof node === 'object') {
10067     const {
10068       tag
10069     } = node;
10070
10071     if (node instanceof resolveSeq.Collection) {
10072       if (tag) tags[tag] = true;
10073       node.items.forEach(n => visit(n, tags));
10074     } else if (node instanceof resolveSeq.Pair) {
10075       visit(node.key, tags);
10076       visit(node.value, tags);
10077     } else if (node instanceof resolveSeq.Scalar) {
10078       if (tag) tags[tag] = true;
10079     }
10080   }
10081
10082   return tags;
10083 };
10084
10085 const listTagNames = node => Object.keys(visit(node, {}));
10086
10087 function parseContents(doc, contents) {
10088   const comments = {
10089     before: [],
10090     after: []
10091   };
10092   let body = undefined;
10093   let spaceBefore = false;
10094
10095   for (const node of contents) {
10096     if (node.valueRange) {
10097       if (body !== undefined) {
10098         const msg = 'Document contains trailing content not separated by a ... or --- line';
10099         doc.errors.push(new PlainValue$1.YAMLSyntaxError(node, msg));
10100         break;
10101       }
10102
10103       const res = resolveSeq.resolveNode(doc, node);
10104
10105       if (spaceBefore) {
10106         res.spaceBefore = true;
10107         spaceBefore = false;
10108       }
10109
10110       body = res;
10111     } else if (node.comment !== null) {
10112       const cc = body === undefined ? comments.before : comments.after;
10113       cc.push(node.comment);
10114     } else if (node.type === PlainValue$1.Type.BLANK_LINE) {
10115       spaceBefore = true;
10116
10117       if (body === undefined && comments.before.length > 0 && !doc.commentBefore) {
10118         // space-separated comments at start are parsed as document comments
10119         doc.commentBefore = comments.before.join('\n');
10120         comments.before = [];
10121       }
10122     }
10123   }
10124
10125   doc.contents = body || null;
10126
10127   if (!body) {
10128     doc.comment = comments.before.concat(comments.after).join('\n') || null;
10129   } else {
10130     const cb = comments.before.join('\n');
10131
10132     if (cb) {
10133       const cbNode = body instanceof resolveSeq.Collection && body.items[0] ? body.items[0] : body;
10134       cbNode.commentBefore = cbNode.commentBefore ? `${cb}\n${cbNode.commentBefore}` : cb;
10135     }
10136
10137     doc.comment = comments.after.join('\n') || null;
10138   }
10139 }
10140
10141 function resolveTagDirective({
10142   tagPrefixes
10143 }, directive) {
10144   const [handle, prefix] = directive.parameters;
10145
10146   if (!handle || !prefix) {
10147     const msg = 'Insufficient parameters given for %TAG directive';
10148     throw new PlainValue$1.YAMLSemanticError(directive, msg);
10149   }
10150
10151   if (tagPrefixes.some(p => p.handle === handle)) {
10152     const msg = 'The %TAG directive must only be given at most once per handle in the same document.';
10153     throw new PlainValue$1.YAMLSemanticError(directive, msg);
10154   }
10155
10156   return {
10157     handle,
10158     prefix
10159   };
10160 }
10161
10162 function resolveYamlDirective(doc, directive) {
10163   let [version] = directive.parameters;
10164   if (directive.name === 'YAML:1.0') version = '1.0';
10165
10166   if (!version) {
10167     const msg = 'Insufficient parameters given for %YAML directive';
10168     throw new PlainValue$1.YAMLSemanticError(directive, msg);
10169   }
10170
10171   if (!documentOptions[version]) {
10172     const v0 = doc.version || doc.options.version;
10173     const msg = `Document will be parsed as YAML ${v0} rather than YAML ${version}`;
10174     doc.warnings.push(new PlainValue$1.YAMLWarning(directive, msg));
10175   }
10176
10177   return version;
10178 }
10179
10180 function parseDirectives(doc, directives, prevDoc) {
10181   const directiveComments = [];
10182   let hasDirectives = false;
10183
10184   for (const directive of directives) {
10185     const {
10186       comment,
10187       name
10188     } = directive;
10189
10190     switch (name) {
10191       case 'TAG':
10192         try {
10193           doc.tagPrefixes.push(resolveTagDirective(doc, directive));
10194         } catch (error) {
10195           doc.errors.push(error);
10196         }
10197
10198         hasDirectives = true;
10199         break;
10200
10201       case 'YAML':
10202       case 'YAML:1.0':
10203         if (doc.version) {
10204           const msg = 'The %YAML directive must only be given at most once per document.';
10205           doc.errors.push(new PlainValue$1.YAMLSemanticError(directive, msg));
10206         }
10207
10208         try {
10209           doc.version = resolveYamlDirective(doc, directive);
10210         } catch (error) {
10211           doc.errors.push(error);
10212         }
10213
10214         hasDirectives = true;
10215         break;
10216
10217       default:
10218         if (name) {
10219           const msg = `YAML only supports %TAG and %YAML directives, and not %${name}`;
10220           doc.warnings.push(new PlainValue$1.YAMLWarning(directive, msg));
10221         }
10222
10223     }
10224
10225     if (comment) directiveComments.push(comment);
10226   }
10227
10228   if (prevDoc && !hasDirectives && '1.1' === (doc.version || prevDoc.version || doc.options.version)) {
10229     const copyTagPrefix = ({
10230       handle,
10231       prefix
10232     }) => ({
10233       handle,
10234       prefix
10235     });
10236
10237     doc.tagPrefixes = prevDoc.tagPrefixes.map(copyTagPrefix);
10238     doc.version = prevDoc.version;
10239   }
10240
10241   doc.commentBefore = directiveComments.join('\n') || null;
10242 }
10243
10244 function assertCollection(contents) {
10245   if (contents instanceof resolveSeq.Collection) return true;
10246   throw new Error('Expected a YAML collection as document contents');
10247 }
10248
10249 class Document$2 {
10250   constructor(options) {
10251     this.anchors = new Anchors(options.anchorPrefix);
10252     this.commentBefore = null;
10253     this.comment = null;
10254     this.contents = null;
10255     this.directivesEndMarker = null;
10256     this.errors = [];
10257     this.options = options;
10258     this.schema = null;
10259     this.tagPrefixes = [];
10260     this.version = null;
10261     this.warnings = [];
10262   }
10263
10264   add(value) {
10265     assertCollection(this.contents);
10266     return this.contents.add(value);
10267   }
10268
10269   addIn(path, value) {
10270     assertCollection(this.contents);
10271     this.contents.addIn(path, value);
10272   }
10273
10274   delete(key) {
10275     assertCollection(this.contents);
10276     return this.contents.delete(key);
10277   }
10278
10279   deleteIn(path) {
10280     if (resolveSeq.isEmptyPath(path)) {
10281       if (this.contents == null) return false;
10282       this.contents = null;
10283       return true;
10284     }
10285
10286     assertCollection(this.contents);
10287     return this.contents.deleteIn(path);
10288   }
10289
10290   getDefaults() {
10291     return Document$2.defaults[this.version] || Document$2.defaults[this.options.version] || {};
10292   }
10293
10294   get(key, keepScalar) {
10295     return this.contents instanceof resolveSeq.Collection ? this.contents.get(key, keepScalar) : undefined;
10296   }
10297
10298   getIn(path, keepScalar) {
10299     if (resolveSeq.isEmptyPath(path)) return !keepScalar && this.contents instanceof resolveSeq.Scalar ? this.contents.value : this.contents;
10300     return this.contents instanceof resolveSeq.Collection ? this.contents.getIn(path, keepScalar) : undefined;
10301   }
10302
10303   has(key) {
10304     return this.contents instanceof resolveSeq.Collection ? this.contents.has(key) : false;
10305   }
10306
10307   hasIn(path) {
10308     if (resolveSeq.isEmptyPath(path)) return this.contents !== undefined;
10309     return this.contents instanceof resolveSeq.Collection ? this.contents.hasIn(path) : false;
10310   }
10311
10312   set(key, value) {
10313     assertCollection(this.contents);
10314     this.contents.set(key, value);
10315   }
10316
10317   setIn(path, value) {
10318     if (resolveSeq.isEmptyPath(path)) this.contents = value;else {
10319       assertCollection(this.contents);
10320       this.contents.setIn(path, value);
10321     }
10322   }
10323
10324   setSchema(id, customTags) {
10325     if (!id && !customTags && this.schema) return;
10326     if (typeof id === 'number') id = id.toFixed(1);
10327
10328     if (id === '1.0' || id === '1.1' || id === '1.2') {
10329       if (this.version) this.version = id;else this.options.version = id;
10330       delete this.options.schema;
10331     } else if (id && typeof id === 'string') {
10332       this.options.schema = id;
10333     }
10334
10335     if (Array.isArray(customTags)) this.options.customTags = customTags;
10336     const opt = Object.assign({}, this.getDefaults(), this.options);
10337     this.schema = new Schema$1.Schema(opt);
10338   }
10339
10340   parse(node, prevDoc) {
10341     if (this.options.keepCstNodes) this.cstNode = node;
10342     if (this.options.keepNodeTypes) this.type = 'DOCUMENT';
10343     const {
10344       directives = [],
10345       contents = [],
10346       directivesEndMarker,
10347       error,
10348       valueRange
10349     } = node;
10350
10351     if (error) {
10352       if (!error.source) error.source = this;
10353       this.errors.push(error);
10354     }
10355
10356     parseDirectives(this, directives, prevDoc);
10357     if (directivesEndMarker) this.directivesEndMarker = true;
10358     this.range = valueRange ? [valueRange.start, valueRange.end] : null;
10359     this.setSchema();
10360     this.anchors._cstAliases = [];
10361     parseContents(this, contents);
10362     this.anchors.resolveNodes();
10363
10364     if (this.options.prettyErrors) {
10365       for (const error of this.errors) if (error instanceof PlainValue$1.YAMLError) error.makePretty();
10366
10367       for (const warn of this.warnings) if (warn instanceof PlainValue$1.YAMLError) warn.makePretty();
10368     }
10369
10370     return this;
10371   }
10372
10373   listNonDefaultTags() {
10374     return listTagNames(this.contents).filter(t => t.indexOf(Schema$1.Schema.defaultPrefix) !== 0);
10375   }
10376
10377   setTagPrefix(handle, prefix) {
10378     if (handle[0] !== '!' || handle[handle.length - 1] !== '!') throw new Error('Handle must start and end with !');
10379
10380     if (prefix) {
10381       const prev = this.tagPrefixes.find(p => p.handle === handle);
10382       if (prev) prev.prefix = prefix;else this.tagPrefixes.push({
10383         handle,
10384         prefix
10385       });
10386     } else {
10387       this.tagPrefixes = this.tagPrefixes.filter(p => p.handle !== handle);
10388     }
10389   }
10390
10391   toJSON(arg, onAnchor) {
10392     const {
10393       keepBlobsInJSON,
10394       mapAsMap,
10395       maxAliasCount
10396     } = this.options;
10397     const keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof resolveSeq.Scalar));
10398     const ctx = {
10399       doc: this,
10400       indentStep: '  ',
10401       keep,
10402       mapAsMap: keep && !!mapAsMap,
10403       maxAliasCount,
10404       stringify: stringify$1 // Requiring directly in Pair would create circular dependencies
10405
10406     };
10407     const anchorNames = Object.keys(this.anchors.map);
10408     if (anchorNames.length > 0) ctx.anchors = new Map(anchorNames.map(name => [this.anchors.map[name], {
10409       alias: [],
10410       aliasCount: 0,
10411       count: 1
10412     }]));
10413     const res = resolveSeq.toJSON(this.contents, arg, ctx);
10414     if (typeof onAnchor === 'function' && ctx.anchors) for (const {
10415       count,
10416       res
10417     } of ctx.anchors.values()) onAnchor(res, count);
10418     return res;
10419   }
10420
10421   toString() {
10422     if (this.errors.length > 0) throw new Error('Document with errors cannot be stringified');
10423     const indentSize = this.options.indent;
10424
10425     if (!Number.isInteger(indentSize) || indentSize <= 0) {
10426       const s = JSON.stringify(indentSize);
10427       throw new Error(`"indent" option must be a positive integer, not ${s}`);
10428     }
10429
10430     this.setSchema();
10431     const lines = [];
10432     let hasDirectives = false;
10433
10434     if (this.version) {
10435       let vd = '%YAML 1.2';
10436
10437       if (this.schema.name === 'yaml-1.1') {
10438         if (this.version === '1.0') vd = '%YAML:1.0';else if (this.version === '1.1') vd = '%YAML 1.1';
10439       }
10440
10441       lines.push(vd);
10442       hasDirectives = true;
10443     }
10444
10445     const tagNames = this.listNonDefaultTags();
10446     this.tagPrefixes.forEach(({
10447       handle,
10448       prefix
10449     }) => {
10450       if (tagNames.some(t => t.indexOf(prefix) === 0)) {
10451         lines.push(`%TAG ${handle} ${prefix}`);
10452         hasDirectives = true;
10453       }
10454     });
10455     if (hasDirectives || this.directivesEndMarker) lines.push('---');
10456
10457     if (this.commentBefore) {
10458       if (hasDirectives || !this.directivesEndMarker) lines.unshift('');
10459       lines.unshift(this.commentBefore.replace(/^/gm, '#'));
10460     }
10461
10462     const ctx = {
10463       anchors: Object.create(null),
10464       doc: this,
10465       indent: '',
10466       indentStep: ' '.repeat(indentSize),
10467       stringify: stringify$1 // Requiring directly in nodes would create circular dependencies
10468
10469     };
10470     let chompKeep = false;
10471     let contentComment = null;
10472
10473     if (this.contents) {
10474       if (this.contents instanceof resolveSeq.Node) {
10475         if (this.contents.spaceBefore && (hasDirectives || this.directivesEndMarker)) lines.push('');
10476         if (this.contents.commentBefore) lines.push(this.contents.commentBefore.replace(/^/gm, '#')); // top-level block scalars need to be indented if followed by a comment
10477
10478         ctx.forceBlockIndent = !!this.comment;
10479         contentComment = this.contents.comment;
10480       }
10481
10482       const onChompKeep = contentComment ? null : () => chompKeep = true;
10483       const body = stringify$1(this.contents, ctx, () => contentComment = null, onChompKeep);
10484       lines.push(resolveSeq.addComment(body, '', contentComment));
10485     } else if (this.contents !== undefined) {
10486       lines.push(stringify$1(this.contents, ctx));
10487     }
10488
10489     if (this.comment) {
10490       if ((!chompKeep || contentComment) && lines[lines.length - 1] !== '') lines.push('');
10491       lines.push(this.comment.replace(/^/gm, '#'));
10492     }
10493
10494     return lines.join('\n') + '\n';
10495   }
10496
10497 }
10498
10499 PlainValue$1._defineProperty(Document$2, "defaults", documentOptions);
10500
10501 Document9b4560a1.Document = Document$2;
10502 Document9b4560a1.defaultOptions = defaultOptions;
10503 Document9b4560a1.scalarOptions = scalarOptions;
10504
10505 var parseCst = parseCst$1;
10506 var Document$1 = Document9b4560a1;
10507 var Schema = Schema88e323a7;
10508 var PlainValue = PlainValueEc8e588e;
10509 var warnings = warnings1000a372;
10510
10511 function createNode(value, wrapScalars = true, tag) {
10512   if (tag === undefined && typeof wrapScalars === 'string') {
10513     tag = wrapScalars;
10514     wrapScalars = true;
10515   }
10516
10517   const options = Object.assign({}, Document$1.Document.defaults[Document$1.defaultOptions.version], Document$1.defaultOptions);
10518   const schema = new Schema.Schema(options);
10519   return schema.createNode(value, wrapScalars, tag);
10520 }
10521
10522 class Document extends Document$1.Document {
10523   constructor(options) {
10524     super(Object.assign({}, Document$1.defaultOptions, options));
10525   }
10526
10527 }
10528
10529 function parseAllDocuments(src, options) {
10530   const stream = [];
10531   let prev;
10532
10533   for (const cstDoc of parseCst.parse(src)) {
10534     const doc = new Document(options);
10535     doc.parse(cstDoc, prev);
10536     stream.push(doc);
10537     prev = doc;
10538   }
10539
10540   return stream;
10541 }
10542
10543 function parseDocument(src, options) {
10544   const cst = parseCst.parse(src);
10545   const doc = new Document(options).parse(cst[0]);
10546
10547   if (cst.length > 1) {
10548     const errMsg = 'Source contains multiple documents; please use YAML.parseAllDocuments()';
10549     doc.errors.unshift(new PlainValue.YAMLSemanticError(cst[1], errMsg));
10550   }
10551
10552   return doc;
10553 }
10554
10555 function parse(src, options) {
10556   const doc = parseDocument(src, options);
10557   doc.warnings.forEach(warning => warnings.warn(warning));
10558   if (doc.errors.length > 0) throw doc.errors[0];
10559   return doc.toJSON();
10560 }
10561
10562 function stringify(value, options) {
10563   const doc = new Document(options);
10564   doc.contents = value;
10565   return String(doc);
10566 }
10567
10568 const YAML = {
10569   createNode,
10570   defaultOptions: Document$1.defaultOptions,
10571   Document,
10572   parse,
10573   parseAllDocuments,
10574   parseCST: parseCst.parse,
10575   parseDocument,
10576   scalarOptions: Document$1.scalarOptions,
10577   stringify
10578 };
10579 dist.YAML = YAML;
10580
10581 var yaml$1 = dist.YAML;
10582
10583 Object.defineProperty(loaders$1, "__esModule", {
10584   value: true
10585 });
10586 loaders$1.loaders = void 0;
10587 /* eslint-disable @typescript-eslint/no-require-imports */
10588
10589 let importFresh;
10590
10591 const loadJs = function loadJs(filepath) {
10592   if (importFresh === undefined) {
10593     importFresh = importFresh$1;
10594   }
10595
10596   const result = importFresh(filepath);
10597   return result;
10598 };
10599
10600 let parseJson;
10601
10602 const loadJson = function loadJson(filepath, content) {
10603   if (parseJson === undefined) {
10604     parseJson = parseJson_1;
10605   }
10606
10607   try {
10608     const result = parseJson(content);
10609     return result;
10610   } catch (error) {
10611     error.message = `JSON Error in ${filepath}:\n${error.message}`;
10612     throw error;
10613   }
10614 };
10615
10616 let yaml;
10617
10618 const loadYaml = function loadYaml(filepath, content) {
10619   if (yaml === undefined) {
10620     yaml = yaml$1;
10621   }
10622
10623   try {
10624     const result = yaml.parse(content, {
10625       prettyErrors: true
10626     });
10627     return result;
10628   } catch (error) {
10629     error.message = `YAML Error in ${filepath}:\n${error.message}`;
10630     throw error;
10631   }
10632 };
10633
10634 const loaders = {
10635   loadJs,
10636   loadJson,
10637   loadYaml
10638 };
10639 loaders$1.loaders = loaders;
10640
10641 var getPropertyByPath$1 = {};
10642
10643 Object.defineProperty(getPropertyByPath$1, "__esModule", {
10644   value: true
10645 });
10646 getPropertyByPath$1.getPropertyByPath = getPropertyByPath; // Resolves property names or property paths defined with period-delimited
10647 // strings or arrays of strings. Property names that are found on the source
10648 // object are used directly (even if they include a period).
10649 // Nested property names that include periods, within a path, are only
10650 // understood in array paths.
10651
10652 function getPropertyByPath(source, path) {
10653   if (typeof path === 'string' && Object.prototype.hasOwnProperty.call(source, path)) {
10654     return source[path];
10655   }
10656
10657   const parsedPath = typeof path === 'string' ? path.split('.') : path; // eslint-disable-next-line @typescript-eslint/no-explicit-any
10658
10659   return parsedPath.reduce((previous, key) => {
10660     if (previous === undefined) {
10661       return previous;
10662     }
10663
10664     return previous[key];
10665   }, source);
10666 }
10667
10668 Object.defineProperty(ExplorerBase$1, "__esModule", {
10669   value: true
10670 });
10671 ExplorerBase$1.getExtensionDescription = getExtensionDescription;
10672 ExplorerBase$1.ExplorerBase = void 0;
10673
10674 var _path$3 = _interopRequireDefault$5(require$$0__default["default"]);
10675
10676 var _loaders$1 = loaders$1;
10677 var _getPropertyByPath = getPropertyByPath$1;
10678
10679 function _interopRequireDefault$5(obj) {
10680   return obj && obj.__esModule ? obj : {
10681     default: obj
10682   };
10683 }
10684
10685 class ExplorerBase {
10686   constructor(options) {
10687     if (options.cache === true) {
10688       this.loadCache = new Map();
10689       this.searchCache = new Map();
10690     }
10691
10692     this.config = options;
10693     this.validateConfig();
10694   }
10695
10696   clearLoadCache() {
10697     if (this.loadCache) {
10698       this.loadCache.clear();
10699     }
10700   }
10701
10702   clearSearchCache() {
10703     if (this.searchCache) {
10704       this.searchCache.clear();
10705     }
10706   }
10707
10708   clearCaches() {
10709     this.clearLoadCache();
10710     this.clearSearchCache();
10711   }
10712
10713   validateConfig() {
10714     const config = this.config;
10715     config.searchPlaces.forEach(place => {
10716       const loaderKey = _path$3.default.extname(place) || 'noExt';
10717       const loader = config.loaders[loaderKey];
10718
10719       if (!loader) {
10720         throw new Error(`No loader specified for ${getExtensionDescription(place)}, so searchPlaces item "${place}" is invalid`);
10721       }
10722
10723       if (typeof loader !== 'function') {
10724         throw new Error(`loader for ${getExtensionDescription(place)} is not a function (type provided: "${typeof loader}"), so searchPlaces item "${place}" is invalid`);
10725       }
10726     });
10727   }
10728
10729   shouldSearchStopWithResult(result) {
10730     if (result === null) return false;
10731     if (result.isEmpty && this.config.ignoreEmptySearchPlaces) return false;
10732     return true;
10733   }
10734
10735   nextDirectoryToSearch(currentDir, currentResult) {
10736     if (this.shouldSearchStopWithResult(currentResult)) {
10737       return null;
10738     }
10739
10740     const nextDir = nextDirUp(currentDir);
10741
10742     if (nextDir === currentDir || currentDir === this.config.stopDir) {
10743       return null;
10744     }
10745
10746     return nextDir;
10747   }
10748
10749   loadPackageProp(filepath, content) {
10750     const parsedContent = _loaders$1.loaders.loadJson(filepath, content);
10751
10752     const packagePropValue = (0, _getPropertyByPath.getPropertyByPath)(parsedContent, this.config.packageProp);
10753     return packagePropValue || null;
10754   }
10755
10756   getLoaderEntryForFile(filepath) {
10757     if (_path$3.default.basename(filepath) === 'package.json') {
10758       const loader = this.loadPackageProp.bind(this);
10759       return loader;
10760     }
10761
10762     const loaderKey = _path$3.default.extname(filepath) || 'noExt';
10763     const loader = this.config.loaders[loaderKey];
10764
10765     if (!loader) {
10766       throw new Error(`No loader specified for ${getExtensionDescription(filepath)}`);
10767     }
10768
10769     return loader;
10770   }
10771
10772   loadedContentToCosmiconfigResult(filepath, loadedContent) {
10773     if (loadedContent === null) {
10774       return null;
10775     }
10776
10777     if (loadedContent === undefined) {
10778       return {
10779         filepath,
10780         config: undefined,
10781         isEmpty: true
10782       };
10783     }
10784
10785     return {
10786       config: loadedContent,
10787       filepath
10788     };
10789   }
10790
10791   validateFilePath(filepath) {
10792     if (!filepath) {
10793       throw new Error('load must pass a non-empty string');
10794     }
10795   }
10796
10797 }
10798
10799 ExplorerBase$1.ExplorerBase = ExplorerBase;
10800
10801 function nextDirUp(dir) {
10802   return _path$3.default.dirname(dir);
10803 }
10804
10805 function getExtensionDescription(filepath) {
10806   const ext = _path$3.default.extname(filepath);
10807
10808   return ext ? `extension "${ext}"` : 'files without extensions';
10809 }
10810
10811 var readFile$1 = {};
10812
10813 Object.defineProperty(readFile$1, "__esModule", {
10814   value: true
10815 });
10816 readFile$1.readFile = readFile;
10817 readFile$1.readFileSync = readFileSync;
10818
10819 var _fs = _interopRequireDefault$4(require$$1__default["default"]);
10820
10821 function _interopRequireDefault$4(obj) {
10822   return obj && obj.__esModule ? obj : {
10823     default: obj
10824   };
10825 }
10826
10827 async function fsReadFileAsync(pathname, encoding) {
10828   return new Promise((resolve, reject) => {
10829     _fs.default.readFile(pathname, encoding, (error, contents) => {
10830       if (error) {
10831         reject(error);
10832         return;
10833       }
10834
10835       resolve(contents);
10836     });
10837   });
10838 }
10839
10840 async function readFile(filepath, options = {}) {
10841   const throwNotFound = options.throwNotFound === true;
10842
10843   try {
10844     const content = await fsReadFileAsync(filepath, 'utf8');
10845     return content;
10846   } catch (error) {
10847     if (throwNotFound === false && (error.code === 'ENOENT' || error.code === 'EISDIR')) {
10848       return null;
10849     }
10850
10851     throw error;
10852   }
10853 }
10854
10855 function readFileSync(filepath, options = {}) {
10856   const throwNotFound = options.throwNotFound === true;
10857
10858   try {
10859     const content = _fs.default.readFileSync(filepath, 'utf8');
10860
10861     return content;
10862   } catch (error) {
10863     if (throwNotFound === false && (error.code === 'ENOENT' || error.code === 'EISDIR')) {
10864       return null;
10865     }
10866
10867     throw error;
10868   }
10869 }
10870
10871 var cacheWrapper$1 = {};
10872
10873 Object.defineProperty(cacheWrapper$1, "__esModule", {
10874   value: true
10875 });
10876 cacheWrapper$1.cacheWrapper = cacheWrapper;
10877 cacheWrapper$1.cacheWrapperSync = cacheWrapperSync;
10878
10879 async function cacheWrapper(cache, key, fn) {
10880   const cached = cache.get(key);
10881
10882   if (cached !== undefined) {
10883     return cached;
10884   }
10885
10886   const result = await fn();
10887   cache.set(key, result);
10888   return result;
10889 }
10890
10891 function cacheWrapperSync(cache, key, fn) {
10892   const cached = cache.get(key);
10893
10894   if (cached !== undefined) {
10895     return cached;
10896   }
10897
10898   const result = fn();
10899   cache.set(key, result);
10900   return result;
10901 }
10902
10903 var getDirectory$1 = {};
10904
10905 var pathType = {};
10906
10907 const {
10908   promisify
10909 } = require$$0__default$1["default"];
10910 const fs = require$$1__default["default"];
10911
10912 async function isType(fsStatType, statsMethodName, filePath) {
10913   if (typeof filePath !== 'string') {
10914     throw new TypeError(`Expected a string, got ${typeof filePath}`);
10915   }
10916
10917   try {
10918     const stats = await promisify(fs[fsStatType])(filePath);
10919     return stats[statsMethodName]();
10920   } catch (error) {
10921     if (error.code === 'ENOENT') {
10922       return false;
10923     }
10924
10925     throw error;
10926   }
10927 }
10928
10929 function isTypeSync(fsStatType, statsMethodName, filePath) {
10930   if (typeof filePath !== 'string') {
10931     throw new TypeError(`Expected a string, got ${typeof filePath}`);
10932   }
10933
10934   try {
10935     return fs[fsStatType](filePath)[statsMethodName]();
10936   } catch (error) {
10937     if (error.code === 'ENOENT') {
10938       return false;
10939     }
10940
10941     throw error;
10942   }
10943 }
10944
10945 pathType.isFile = isType.bind(null, 'stat', 'isFile');
10946 pathType.isDirectory = isType.bind(null, 'stat', 'isDirectory');
10947 pathType.isSymlink = isType.bind(null, 'lstat', 'isSymbolicLink');
10948 pathType.isFileSync = isTypeSync.bind(null, 'statSync', 'isFile');
10949 pathType.isDirectorySync = isTypeSync.bind(null, 'statSync', 'isDirectory');
10950 pathType.isSymlinkSync = isTypeSync.bind(null, 'lstatSync', 'isSymbolicLink');
10951
10952 Object.defineProperty(getDirectory$1, "__esModule", {
10953   value: true
10954 });
10955 getDirectory$1.getDirectory = getDirectory;
10956 getDirectory$1.getDirectorySync = getDirectorySync;
10957
10958 var _path$2 = _interopRequireDefault$3(require$$0__default["default"]);
10959
10960 var _pathType = pathType;
10961
10962 function _interopRequireDefault$3(obj) {
10963   return obj && obj.__esModule ? obj : {
10964     default: obj
10965   };
10966 }
10967
10968 async function getDirectory(filepath) {
10969   const filePathIsDirectory = await (0, _pathType.isDirectory)(filepath);
10970
10971   if (filePathIsDirectory === true) {
10972     return filepath;
10973   }
10974
10975   const directory = _path$2.default.dirname(filepath);
10976
10977   return directory;
10978 }
10979
10980 function getDirectorySync(filepath) {
10981   const filePathIsDirectory = (0, _pathType.isDirectorySync)(filepath);
10982
10983   if (filePathIsDirectory === true) {
10984     return filepath;
10985   }
10986
10987   const directory = _path$2.default.dirname(filepath);
10988
10989   return directory;
10990 }
10991
10992 Object.defineProperty(Explorer$1, "__esModule", {
10993   value: true
10994 });
10995 Explorer$1.Explorer = void 0;
10996
10997 var _path$1 = _interopRequireDefault$2(require$$0__default["default"]);
10998
10999 var _ExplorerBase$1 = ExplorerBase$1;
11000 var _readFile$1 = readFile$1;
11001 var _cacheWrapper$1 = cacheWrapper$1;
11002 var _getDirectory$1 = getDirectory$1;
11003
11004 function _interopRequireDefault$2(obj) {
11005   return obj && obj.__esModule ? obj : {
11006     default: obj
11007   };
11008 }
11009
11010 class Explorer extends _ExplorerBase$1.ExplorerBase {
11011   constructor(options) {
11012     super(options);
11013   }
11014
11015   async search(searchFrom = process.cwd()) {
11016     const startDirectory = await (0, _getDirectory$1.getDirectory)(searchFrom);
11017     const result = await this.searchFromDirectory(startDirectory);
11018     return result;
11019   }
11020
11021   async searchFromDirectory(dir) {
11022     const absoluteDir = _path$1.default.resolve(process.cwd(), dir);
11023
11024     const run = async () => {
11025       const result = await this.searchDirectory(absoluteDir);
11026       const nextDir = this.nextDirectoryToSearch(absoluteDir, result);
11027
11028       if (nextDir) {
11029         return this.searchFromDirectory(nextDir);
11030       }
11031
11032       const transformResult = await this.config.transform(result);
11033       return transformResult;
11034     };
11035
11036     if (this.searchCache) {
11037       return (0, _cacheWrapper$1.cacheWrapper)(this.searchCache, absoluteDir, run);
11038     }
11039
11040     return run();
11041   }
11042
11043   async searchDirectory(dir) {
11044     for await (const place of this.config.searchPlaces) {
11045       const placeResult = await this.loadSearchPlace(dir, place);
11046
11047       if (this.shouldSearchStopWithResult(placeResult) === true) {
11048         return placeResult;
11049       }
11050     } // config not found
11051
11052
11053     return null;
11054   }
11055
11056   async loadSearchPlace(dir, place) {
11057     const filepath = _path$1.default.join(dir, place);
11058
11059     const fileContents = await (0, _readFile$1.readFile)(filepath);
11060     const result = await this.createCosmiconfigResult(filepath, fileContents);
11061     return result;
11062   }
11063
11064   async loadFileContent(filepath, content) {
11065     if (content === null) {
11066       return null;
11067     }
11068
11069     if (content.trim() === '') {
11070       return undefined;
11071     }
11072
11073     const loader = this.getLoaderEntryForFile(filepath);
11074     const loaderResult = await loader(filepath, content);
11075     return loaderResult;
11076   }
11077
11078   async createCosmiconfigResult(filepath, content) {
11079     const fileContent = await this.loadFileContent(filepath, content);
11080     const result = this.loadedContentToCosmiconfigResult(filepath, fileContent);
11081     return result;
11082   }
11083
11084   async load(filepath) {
11085     this.validateFilePath(filepath);
11086
11087     const absoluteFilePath = _path$1.default.resolve(process.cwd(), filepath);
11088
11089     const runLoad = async () => {
11090       const fileContents = await (0, _readFile$1.readFile)(absoluteFilePath, {
11091         throwNotFound: true
11092       });
11093       const result = await this.createCosmiconfigResult(absoluteFilePath, fileContents);
11094       const transformResult = await this.config.transform(result);
11095       return transformResult;
11096     };
11097
11098     if (this.loadCache) {
11099       return (0, _cacheWrapper$1.cacheWrapper)(this.loadCache, absoluteFilePath, runLoad);
11100     }
11101
11102     return runLoad();
11103   }
11104
11105 }
11106
11107 Explorer$1.Explorer = Explorer;
11108
11109 var ExplorerSync$1 = {};
11110
11111 Object.defineProperty(ExplorerSync$1, "__esModule", {
11112   value: true
11113 });
11114 ExplorerSync$1.ExplorerSync = void 0;
11115
11116 var _path = _interopRequireDefault$1(require$$0__default["default"]);
11117
11118 var _ExplorerBase = ExplorerBase$1;
11119 var _readFile = readFile$1;
11120 var _cacheWrapper = cacheWrapper$1;
11121 var _getDirectory = getDirectory$1;
11122
11123 function _interopRequireDefault$1(obj) {
11124   return obj && obj.__esModule ? obj : {
11125     default: obj
11126   };
11127 }
11128
11129 class ExplorerSync extends _ExplorerBase.ExplorerBase {
11130   constructor(options) {
11131     super(options);
11132   }
11133
11134   searchSync(searchFrom = process.cwd()) {
11135     const startDirectory = (0, _getDirectory.getDirectorySync)(searchFrom);
11136     const result = this.searchFromDirectorySync(startDirectory);
11137     return result;
11138   }
11139
11140   searchFromDirectorySync(dir) {
11141     const absoluteDir = _path.default.resolve(process.cwd(), dir);
11142
11143     const run = () => {
11144       const result = this.searchDirectorySync(absoluteDir);
11145       const nextDir = this.nextDirectoryToSearch(absoluteDir, result);
11146
11147       if (nextDir) {
11148         return this.searchFromDirectorySync(nextDir);
11149       }
11150
11151       const transformResult = this.config.transform(result);
11152       return transformResult;
11153     };
11154
11155     if (this.searchCache) {
11156       return (0, _cacheWrapper.cacheWrapperSync)(this.searchCache, absoluteDir, run);
11157     }
11158
11159     return run();
11160   }
11161
11162   searchDirectorySync(dir) {
11163     for (const place of this.config.searchPlaces) {
11164       const placeResult = this.loadSearchPlaceSync(dir, place);
11165
11166       if (this.shouldSearchStopWithResult(placeResult) === true) {
11167         return placeResult;
11168       }
11169     } // config not found
11170
11171
11172     return null;
11173   }
11174
11175   loadSearchPlaceSync(dir, place) {
11176     const filepath = _path.default.join(dir, place);
11177
11178     const content = (0, _readFile.readFileSync)(filepath);
11179     const result = this.createCosmiconfigResultSync(filepath, content);
11180     return result;
11181   }
11182
11183   loadFileContentSync(filepath, content) {
11184     if (content === null) {
11185       return null;
11186     }
11187
11188     if (content.trim() === '') {
11189       return undefined;
11190     }
11191
11192     const loader = this.getLoaderEntryForFile(filepath);
11193     const loaderResult = loader(filepath, content);
11194     return loaderResult;
11195   }
11196
11197   createCosmiconfigResultSync(filepath, content) {
11198     const fileContent = this.loadFileContentSync(filepath, content);
11199     const result = this.loadedContentToCosmiconfigResult(filepath, fileContent);
11200     return result;
11201   }
11202
11203   loadSync(filepath) {
11204     this.validateFilePath(filepath);
11205
11206     const absoluteFilePath = _path.default.resolve(process.cwd(), filepath);
11207
11208     const runLoadSync = () => {
11209       const content = (0, _readFile.readFileSync)(absoluteFilePath, {
11210         throwNotFound: true
11211       });
11212       const cosmiconfigResult = this.createCosmiconfigResultSync(absoluteFilePath, content);
11213       const transformResult = this.config.transform(cosmiconfigResult);
11214       return transformResult;
11215     };
11216
11217     if (this.loadCache) {
11218       return (0, _cacheWrapper.cacheWrapperSync)(this.loadCache, absoluteFilePath, runLoadSync);
11219     }
11220
11221     return runLoadSync();
11222   }
11223
11224 }
11225
11226 ExplorerSync$1.ExplorerSync = ExplorerSync;
11227
11228 var types = {};
11229
11230 Object.defineProperty(types, "__esModule", {
11231   value: true
11232 });
11233
11234 Object.defineProperty(dist$2, "__esModule", {
11235   value: true
11236 });
11237 dist$2.cosmiconfig = cosmiconfig;
11238 dist$2.cosmiconfigSync = cosmiconfigSync;
11239 dist$2.defaultLoaders = void 0;
11240
11241 var _os = _interopRequireDefault(require$$0__default$2["default"]);
11242
11243 var _Explorer = Explorer$1;
11244 var _ExplorerSync = ExplorerSync$1;
11245 var _loaders = loaders$1;
11246
11247 function _interopRequireDefault(obj) {
11248   return obj && obj.__esModule ? obj : {
11249     default: obj
11250   };
11251 }
11252 /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
11253 // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
11254
11255
11256 function cosmiconfig(moduleName, options = {}) {
11257   const normalizedOptions = normalizeOptions(moduleName, options);
11258   const explorer = new _Explorer.Explorer(normalizedOptions);
11259   return {
11260     search: explorer.search.bind(explorer),
11261     load: explorer.load.bind(explorer),
11262     clearLoadCache: explorer.clearLoadCache.bind(explorer),
11263     clearSearchCache: explorer.clearSearchCache.bind(explorer),
11264     clearCaches: explorer.clearCaches.bind(explorer)
11265   };
11266 } // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
11267
11268
11269 function cosmiconfigSync(moduleName, options = {}) {
11270   const normalizedOptions = normalizeOptions(moduleName, options);
11271   const explorerSync = new _ExplorerSync.ExplorerSync(normalizedOptions);
11272   return {
11273     search: explorerSync.searchSync.bind(explorerSync),
11274     load: explorerSync.loadSync.bind(explorerSync),
11275     clearLoadCache: explorerSync.clearLoadCache.bind(explorerSync),
11276     clearSearchCache: explorerSync.clearSearchCache.bind(explorerSync),
11277     clearCaches: explorerSync.clearCaches.bind(explorerSync)
11278   };
11279 } // do not allow mutation of default loaders. Make sure it is set inside options
11280
11281
11282 const defaultLoaders = Object.freeze({
11283   '.cjs': _loaders.loaders.loadJs,
11284   '.js': _loaders.loaders.loadJs,
11285   '.json': _loaders.loaders.loadJson,
11286   '.yaml': _loaders.loaders.loadYaml,
11287   '.yml': _loaders.loaders.loadYaml,
11288   noExt: _loaders.loaders.loadYaml
11289 });
11290 dist$2.defaultLoaders = defaultLoaders;
11291
11292 const identity = function identity(x) {
11293   return x;
11294 };
11295
11296 function normalizeOptions(moduleName, options) {
11297   const defaults = {
11298     packageProp: moduleName,
11299     searchPlaces: ['package.json', `.${moduleName}rc`, `.${moduleName}rc.json`, `.${moduleName}rc.yaml`, `.${moduleName}rc.yml`, `.${moduleName}rc.js`, `.${moduleName}rc.cjs`, `${moduleName}.config.js`, `${moduleName}.config.cjs`],
11300     ignoreEmptySearchPlaces: true,
11301     stopDir: _os.default.homedir(),
11302     cache: true,
11303     transform: identity,
11304     loaders: defaultLoaders
11305   };
11306   const normalizedOptions = Object.assign(Object.assign(Object.assign({}, defaults), options), {}, {
11307     loaders: Object.assign(Object.assign({}, defaults.loaders), options.loaders)
11308   });
11309   return normalizedOptions;
11310 }
11311
11312 var findParentDir = {exports: {}};
11313
11314 (function (module, exports) {
11315
11316   var path = require$$0__default["default"],
11317       fs = require$$1__default["default"],
11318       exists = fs.exists || path.exists,
11319       existsSync = fs.existsSync || path.existsSync;
11320
11321   function splitPath(path) {
11322     var parts = path.split(/(\/|\\)/);
11323     if (!parts.length) return parts; // when path starts with a slash, the first part is empty string
11324
11325     return !parts[0].length ? parts.slice(1) : parts;
11326   }
11327
11328   exports = module.exports = function (currentFullPath, clue, cb) {
11329     function testDir(parts) {
11330       if (parts.length === 0) return cb(null, null);
11331       var p = parts.join('');
11332       exists(path.join(p, clue), function (itdoes) {
11333         if (itdoes) return cb(null, p);
11334         testDir(parts.slice(0, -1));
11335       });
11336     }
11337
11338     testDir(splitPath(currentFullPath));
11339   };
11340
11341   exports.sync = function (currentFullPath, clue) {
11342     function testDir(parts) {
11343       if (parts.length === 0) return null;
11344       var p = parts.join('');
11345       var itdoes = existsSync(path.join(p, clue));
11346       return itdoes ? p : testDir(parts.slice(0, -1));
11347     }
11348
11349     return testDir(splitPath(currentFullPath));
11350   };
11351 })(findParentDir, findParentDir.exports);
11352
11353 var getStdin = {exports: {}};
11354
11355 const {
11356   stdin
11357 } = process;
11358
11359 getStdin.exports = async () => {
11360   let result = '';
11361
11362   if (stdin.isTTY) {
11363     return result;
11364   }
11365
11366   stdin.setEncoding('utf8');
11367
11368   for await (const chunk of stdin) {
11369     result += chunk;
11370   }
11371
11372   return result;
11373 };
11374
11375 getStdin.exports.buffer = async () => {
11376   const result = [];
11377   let length = 0;
11378
11379   if (stdin.isTTY) {
11380     return Buffer.concat([]);
11381   }
11382
11383   for await (const chunk of stdin) {
11384     result.push(chunk);
11385     length += chunk.length;
11386   }
11387
11388   return Buffer.concat(result, length);
11389 };
11390
11391 var ciInfo = {};
11392
11393 var require$$0 = [
11394         {
11395                 name: "AppVeyor",
11396                 constant: "APPVEYOR",
11397                 env: "APPVEYOR",
11398                 pr: "APPVEYOR_PULL_REQUEST_NUMBER"
11399         },
11400         {
11401                 name: "Azure Pipelines",
11402                 constant: "AZURE_PIPELINES",
11403                 env: "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI",
11404                 pr: "SYSTEM_PULLREQUEST_PULLREQUESTID"
11405         },
11406         {
11407                 name: "Appcircle",
11408                 constant: "APPCIRCLE",
11409                 env: "AC_APPCIRCLE"
11410         },
11411         {
11412                 name: "Bamboo",
11413                 constant: "BAMBOO",
11414                 env: "bamboo_planKey"
11415         },
11416         {
11417                 name: "Bitbucket Pipelines",
11418                 constant: "BITBUCKET",
11419                 env: "BITBUCKET_COMMIT",
11420                 pr: "BITBUCKET_PR_ID"
11421         },
11422         {
11423                 name: "Bitrise",
11424                 constant: "BITRISE",
11425                 env: "BITRISE_IO",
11426                 pr: "BITRISE_PULL_REQUEST"
11427         },
11428         {
11429                 name: "Buddy",
11430                 constant: "BUDDY",
11431                 env: "BUDDY_WORKSPACE_ID",
11432                 pr: "BUDDY_EXECUTION_PULL_REQUEST_ID"
11433         },
11434         {
11435                 name: "Buildkite",
11436                 constant: "BUILDKITE",
11437                 env: "BUILDKITE",
11438                 pr: {
11439                         env: "BUILDKITE_PULL_REQUEST",
11440                         ne: "false"
11441                 }
11442         },
11443         {
11444                 name: "CircleCI",
11445                 constant: "CIRCLE",
11446                 env: "CIRCLECI",
11447                 pr: "CIRCLE_PULL_REQUEST"
11448         },
11449         {
11450                 name: "Cirrus CI",
11451                 constant: "CIRRUS",
11452                 env: "CIRRUS_CI",
11453                 pr: "CIRRUS_PR"
11454         },
11455         {
11456                 name: "AWS CodeBuild",
11457                 constant: "CODEBUILD",
11458                 env: "CODEBUILD_BUILD_ARN"
11459         },
11460         {
11461                 name: "Codefresh",
11462                 constant: "CODEFRESH",
11463                 env: "CF_BUILD_ID",
11464                 pr: {
11465                         any: [
11466                                 "CF_PULL_REQUEST_NUMBER",
11467                                 "CF_PULL_REQUEST_ID"
11468                         ]
11469                 }
11470         },
11471         {
11472                 name: "Codeship",
11473                 constant: "CODESHIP",
11474                 env: {
11475                         CI_NAME: "codeship"
11476                 }
11477         },
11478         {
11479                 name: "Drone",
11480                 constant: "DRONE",
11481                 env: "DRONE",
11482                 pr: {
11483                         DRONE_BUILD_EVENT: "pull_request"
11484                 }
11485         },
11486         {
11487                 name: "dsari",
11488                 constant: "DSARI",
11489                 env: "DSARI"
11490         },
11491         {
11492                 name: "GitHub Actions",
11493                 constant: "GITHUB_ACTIONS",
11494                 env: "GITHUB_ACTIONS",
11495                 pr: {
11496                         GITHUB_EVENT_NAME: "pull_request"
11497                 }
11498         },
11499         {
11500                 name: "GitLab CI",
11501                 constant: "GITLAB",
11502                 env: "GITLAB_CI",
11503                 pr: "CI_MERGE_REQUEST_ID"
11504         },
11505         {
11506                 name: "GoCD",
11507                 constant: "GOCD",
11508                 env: "GO_PIPELINE_LABEL"
11509         },
11510         {
11511                 name: "LayerCI",
11512                 constant: "LAYERCI",
11513                 env: "LAYERCI",
11514                 pr: "LAYERCI_PULL_REQUEST"
11515         },
11516         {
11517                 name: "Hudson",
11518                 constant: "HUDSON",
11519                 env: "HUDSON_URL"
11520         },
11521         {
11522                 name: "Jenkins",
11523                 constant: "JENKINS",
11524                 env: [
11525                         "JENKINS_URL",
11526                         "BUILD_ID"
11527                 ],
11528                 pr: {
11529                         any: [
11530                                 "ghprbPullId",
11531                                 "CHANGE_ID"
11532                         ]
11533                 }
11534         },
11535         {
11536                 name: "Magnum CI",
11537                 constant: "MAGNUM",
11538                 env: "MAGNUM"
11539         },
11540         {
11541                 name: "Netlify CI",
11542                 constant: "NETLIFY",
11543                 env: "NETLIFY",
11544                 pr: {
11545                         env: "PULL_REQUEST",
11546                         ne: "false"
11547                 }
11548         },
11549         {
11550                 name: "Nevercode",
11551                 constant: "NEVERCODE",
11552                 env: "NEVERCODE",
11553                 pr: {
11554                         env: "NEVERCODE_PULL_REQUEST",
11555                         ne: "false"
11556                 }
11557         },
11558         {
11559                 name: "Render",
11560                 constant: "RENDER",
11561                 env: "RENDER",
11562                 pr: {
11563                         IS_PULL_REQUEST: "true"
11564                 }
11565         },
11566         {
11567                 name: "Sail CI",
11568                 constant: "SAIL",
11569                 env: "SAILCI",
11570                 pr: "SAIL_PULL_REQUEST_NUMBER"
11571         },
11572         {
11573                 name: "Semaphore",
11574                 constant: "SEMAPHORE",
11575                 env: "SEMAPHORE",
11576                 pr: "PULL_REQUEST_NUMBER"
11577         },
11578         {
11579                 name: "Screwdriver",
11580                 constant: "SCREWDRIVER",
11581                 env: "SCREWDRIVER",
11582                 pr: {
11583                         env: "SD_PULL_REQUEST",
11584                         ne: "false"
11585                 }
11586         },
11587         {
11588                 name: "Shippable",
11589                 constant: "SHIPPABLE",
11590                 env: "SHIPPABLE",
11591                 pr: {
11592                         IS_PULL_REQUEST: "true"
11593                 }
11594         },
11595         {
11596                 name: "Solano CI",
11597                 constant: "SOLANO",
11598                 env: "TDDIUM",
11599                 pr: "TDDIUM_PR_ID"
11600         },
11601         {
11602                 name: "Strider CD",
11603                 constant: "STRIDER",
11604                 env: "STRIDER"
11605         },
11606         {
11607                 name: "TaskCluster",
11608                 constant: "TASKCLUSTER",
11609                 env: [
11610                         "TASK_ID",
11611                         "RUN_ID"
11612                 ]
11613         },
11614         {
11615                 name: "TeamCity",
11616                 constant: "TEAMCITY",
11617                 env: "TEAMCITY_VERSION"
11618         },
11619         {
11620                 name: "Travis CI",
11621                 constant: "TRAVIS",
11622                 env: "TRAVIS",
11623                 pr: {
11624                         env: "TRAVIS_PULL_REQUEST",
11625                         ne: "false"
11626                 }
11627         },
11628         {
11629                 name: "Vercel",
11630                 constant: "VERCEL",
11631                 env: "NOW_BUILDER"
11632         },
11633         {
11634                 name: "Visual Studio App Center",
11635                 constant: "APPCENTER",
11636                 env: "APPCENTER_BUILD_ID"
11637         }
11638 ];
11639
11640 (function (exports) {
11641
11642   const vendors = require$$0;
11643   const env = process.env; // Used for testing only
11644
11645   Object.defineProperty(exports, '_vendors', {
11646     value: vendors.map(function (v) {
11647       return v.constant;
11648     })
11649   });
11650   exports.name = null;
11651   exports.isPR = null;
11652   vendors.forEach(function (vendor) {
11653     const envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env];
11654     const isCI = envs.every(function (obj) {
11655       return checkEnv(obj);
11656     });
11657     exports[vendor.constant] = isCI;
11658
11659     if (isCI) {
11660       exports.name = vendor.name;
11661
11662       switch (typeof vendor.pr) {
11663         case 'string':
11664           // "pr": "CIRRUS_PR"
11665           exports.isPR = !!env[vendor.pr];
11666           break;
11667
11668         case 'object':
11669           if ('env' in vendor.pr) {
11670             // "pr": { "env": "BUILDKITE_PULL_REQUEST", "ne": "false" }
11671             exports.isPR = vendor.pr.env in env && env[vendor.pr.env] !== vendor.pr.ne;
11672           } else if ('any' in vendor.pr) {
11673             // "pr": { "any": ["ghprbPullId", "CHANGE_ID"] }
11674             exports.isPR = vendor.pr.any.some(function (key) {
11675               return !!env[key];
11676             });
11677           } else {
11678             // "pr": { "DRONE_BUILD_EVENT": "pull_request" }
11679             exports.isPR = checkEnv(vendor.pr);
11680           }
11681
11682           break;
11683
11684         default:
11685           // PR detection not supported for this vendor
11686           exports.isPR = null;
11687       }
11688     }
11689   });
11690   exports.isCI = !!(env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari
11691   env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
11692   env.BUILD_NUMBER || // Jenkins, TeamCity
11693   env.RUN_ID || // TaskCluster, dsari
11694   exports.name || false);
11695
11696   function checkEnv(obj) {
11697     if (typeof obj === 'string') return !!env[obj];
11698     return Object.keys(obj).every(function (k) {
11699       return env[k] === obj[k];
11700     });
11701   }
11702 })(ciInfo);
11703
11704 var thirdParty = {
11705   cosmiconfig: dist$2.cosmiconfig,
11706   cosmiconfigSync: dist$2.cosmiconfigSync,
11707   findParentDir: findParentDir.exports.sync,
11708   getStdin: getStdin.exports,
11709   isCI: () => ciInfo.isCI
11710 };
11711
11712 module.exports = thirdParty;