import { o as YAMLReferenceError, T as Type, g as YAMLSemanticError, _ as _createForOfIteratorHelper, e as _defineProperty, j as _inherits, k as _createSuper, c as _classCallCheck, p as _assertThisInitialized, b as _createClass, a as _typeof, l as _get, m as _getPrototypeOf } from './PlainValue-ff5147c6.js'; import { j as resolveString, b as binaryOptions, c as stringifyString, h as resolveSeq, P as Pair, d as YAMLMap, Y as YAMLSeq, t as toJSON, S as Scalar, l as findPair, g as resolveMap, k as stringifyNumber } from './resolveSeq-04825f30.js'; /* global atob, btoa, Buffer */ var binary = { identify: function identify(value) { return value instanceof Uint8Array; }, // Buffer inherits from Uint8Array default: false, tag: 'tag:yaml.org,2002:binary', /** * Returns a Buffer in node and an Uint8Array in browsers * * To use the resulting buffer as an image, you'll want to do something like: * * const blob = new Blob([buffer], { type: 'image/jpeg' }) * document.querySelector('#photo').src = URL.createObjectURL(blob) */ resolve: function resolve(doc, node) { var src = resolveString(doc, node); if (typeof Buffer === 'function') { return Buffer.from(src, 'base64'); } else if (typeof atob === 'function') { // On IE 11, atob() can't handle newlines var str = atob(src.replace(/[\n\r]/g, '')); var buffer = new Uint8Array(str.length); for (var i = 0; i < str.length; ++i) { buffer[i] = str.charCodeAt(i); } return buffer; } else { var msg = 'This environment does not support reading binary tags; either Buffer or atob is required'; doc.errors.push(new YAMLReferenceError(node, msg)); return null; } }, options: binaryOptions, stringify: function stringify(_ref, ctx, onComment, onChompKeep) { var comment = _ref.comment, type = _ref.type, value = _ref.value; var src; if (typeof Buffer === 'function') { src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64'); } else if (typeof btoa === 'function') { var s = ''; for (var i = 0; i < value.length; ++i) { s += String.fromCharCode(value[i]); } src = btoa(s); } else { throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required'); } if (!type) type = binaryOptions.defaultType; if (type === Type.QUOTE_DOUBLE) { value = src; } else { var lineWidth = binaryOptions.lineWidth; var n = Math.ceil(src.length / lineWidth); var lines = new Array(n); for (var _i = 0, o = 0; _i < n; ++_i, o += lineWidth) { lines[_i] = src.substr(o, lineWidth); } value = lines.join(type === Type.BLOCK_LITERAL ? '\n' : ' '); } return stringifyString({ comment: comment, type: type, value: value }, ctx, onComment, onChompKeep); } }; function parsePairs(doc, cst) { var seq = resolveSeq(doc, cst); for (var i = 0; i < seq.items.length; ++i) { var item = seq.items[i]; if (item instanceof Pair) continue;else if (item instanceof YAMLMap) { if (item.items.length > 1) { var msg = 'Each pair must have its own sequence indicator'; throw new YAMLSemanticError(cst, msg); } var pair = item.items[0] || new Pair(); if (item.commentBefore) pair.commentBefore = pair.commentBefore ? "".concat(item.commentBefore, "\n").concat(pair.commentBefore) : item.commentBefore; if (item.comment) pair.comment = pair.comment ? "".concat(item.comment, "\n").concat(pair.comment) : item.comment; item = pair; } seq.items[i] = item instanceof Pair ? item : new Pair(item); } return seq; } function createPairs(schema, iterable, ctx) { var pairs = new YAMLSeq(schema); pairs.tag = 'tag:yaml.org,2002:pairs'; var _iterator = _createForOfIteratorHelper(iterable), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var it = _step.value; var key = void 0, value = void 0; if (Array.isArray(it)) { if (it.length === 2) { key = it[0]; value = it[1]; } else throw new TypeError("Expected [key, value] tuple: ".concat(it)); } else if (it && it instanceof Object) { var keys = Object.keys(it); if (keys.length === 1) { key = keys[0]; value = it[key]; } else throw new TypeError("Expected { key: value } tuple: ".concat(it)); } else { key = it; } var pair = schema.createPair(key, value, ctx); pairs.items.push(pair); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } return pairs; } var pairs = { default: false, tag: 'tag:yaml.org,2002:pairs', resolve: parsePairs, createNode: createPairs }; var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) { _inherits(YAMLOMap, _YAMLSeq); var _super = _createSuper(YAMLOMap); function YAMLOMap() { var _this; _classCallCheck(this, YAMLOMap); _this = _super.call(this); _defineProperty(_assertThisInitialized(_this), "add", YAMLMap.prototype.add.bind(_assertThisInitialized(_this))); _defineProperty(_assertThisInitialized(_this), "delete", YAMLMap.prototype.delete.bind(_assertThisInitialized(_this))); _defineProperty(_assertThisInitialized(_this), "get", YAMLMap.prototype.get.bind(_assertThisInitialized(_this))); _defineProperty(_assertThisInitialized(_this), "has", YAMLMap.prototype.has.bind(_assertThisInitialized(_this))); _defineProperty(_assertThisInitialized(_this), "set", YAMLMap.prototype.set.bind(_assertThisInitialized(_this))); _this.tag = YAMLOMap.tag; return _this; } _createClass(YAMLOMap, [{ key: "toJSON", value: function toJSON$1(_, ctx) { var map = new Map(); if (ctx && ctx.onCreate) ctx.onCreate(map); var _iterator = _createForOfIteratorHelper(this.items), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var pair = _step.value; var key = void 0, value = void 0; if (pair instanceof Pair) { key = toJSON(pair.key, '', ctx); value = toJSON(pair.value, key, ctx); } else { key = toJSON(pair, '', ctx); } if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys'); map.set(key, value); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } return map; } }]); return YAMLOMap; }(YAMLSeq); _defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap'); function parseOMap(doc, cst) { var pairs = parsePairs(doc, cst); var seenKeys = []; var _iterator2 = _createForOfIteratorHelper(pairs.items), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var key = _step2.value.key; if (key instanceof Scalar) { if (seenKeys.includes(key.value)) { var msg = 'Ordered maps must not include duplicate keys'; throw new YAMLSemanticError(cst, msg); } else { seenKeys.push(key.value); } } } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } return Object.assign(new YAMLOMap(), pairs); } function createOMap(schema, iterable, ctx) { var pairs = createPairs(schema, iterable, ctx); var omap = new YAMLOMap(); omap.items = pairs.items; return omap; } var omap = { identify: function identify(value) { return value instanceof Map; }, nodeClass: YAMLOMap, default: false, tag: 'tag:yaml.org,2002:omap', resolve: parseOMap, createNode: createOMap }; var YAMLSet = /*#__PURE__*/function (_YAMLMap) { _inherits(YAMLSet, _YAMLMap); var _super = _createSuper(YAMLSet); function YAMLSet() { var _this; _classCallCheck(this, YAMLSet); _this = _super.call(this); _this.tag = YAMLSet.tag; return _this; } _createClass(YAMLSet, [{ key: "add", value: function add(key) { var pair = key instanceof Pair ? key : new Pair(key); var prev = findPair(this.items, pair.key); if (!prev) this.items.push(pair); } }, { key: "get", value: function get(key, keepPair) { var pair = findPair(this.items, key); return !keepPair && pair instanceof Pair ? pair.key instanceof Scalar ? pair.key.value : pair.key : pair; } }, { key: "set", value: function set(key, value) { if (typeof value !== 'boolean') throw new Error("Expected boolean value for set(key, value) in a YAML set, not ".concat(_typeof(value))); var prev = findPair(this.items, key); if (prev && !value) { this.items.splice(this.items.indexOf(prev), 1); } else if (!prev && value) { this.items.push(new Pair(key)); } } }, { key: "toJSON", value: function toJSON(_, ctx) { return _get(_getPrototypeOf(YAMLSet.prototype), "toJSON", this).call(this, _, ctx, Set); } }, { key: "toString", value: function toString(ctx, onComment, onChompKeep) { if (!ctx) return JSON.stringify(this); if (this.hasAllNullValues()) return _get(_getPrototypeOf(YAMLSet.prototype), "toString", this).call(this, ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values'); } }]); return YAMLSet; }(YAMLMap); _defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set'); function parseSet(doc, cst) { var map = resolveMap(doc, cst); if (!map.hasAllNullValues()) throw new YAMLSemanticError(cst, 'Set items must all have null values'); return Object.assign(new YAMLSet(), map); } function createSet(schema, iterable, ctx) { var set = new YAMLSet(); var _iterator = _createForOfIteratorHelper(iterable), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var value = _step.value; set.items.push(schema.createPair(value, null, ctx)); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } return set; } var set = { identify: function identify(value) { return value instanceof Set; }, nodeClass: YAMLSet, default: false, tag: 'tag:yaml.org,2002:set', resolve: parseSet, createNode: createSet }; var parseSexagesimal = function parseSexagesimal(sign, parts) { var n = parts.split(':').reduce(function (n, p) { return n * 60 + Number(p); }, 0); return sign === '-' ? -n : n; }; // hhhh:mm:ss.sss var stringifySexagesimal = function stringifySexagesimal(_ref) { var value = _ref.value; if (isNaN(value) || !isFinite(value)) return stringifyNumber(value); var sign = ''; if (value < 0) { sign = '-'; value = Math.abs(value); } var parts = [value % 60]; // seconds, including ms if (value < 60) { parts.unshift(0); // at least one : is required } else { value = Math.round((value - parts[0]) / 60); parts.unshift(value % 60); // minutes if (value >= 60) { value = Math.round((value - parts[0]) / 60); parts.unshift(value); // hours } } return sign + parts.map(function (n) { return n < 10 ? '0' + String(n) : String(n); }).join(':').replace(/000000\d*$/, '') // % 60 may introduce error ; }; var intTime = { identify: function identify(value) { return typeof value === 'number'; }, default: true, tag: 'tag:yaml.org,2002:int', format: 'TIME', test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/, resolve: function resolve(str, sign, parts) { return parseSexagesimal(sign, parts.replace(/_/g, '')); }, stringify: stringifySexagesimal }; var floatTime = { identify: function identify(value) { return typeof value === 'number'; }, default: true, tag: 'tag:yaml.org,2002:float', format: 'TIME', test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/, resolve: function resolve(str, sign, parts) { return parseSexagesimal(sign, parts.replace(/_/g, '')); }, stringify: stringifySexagesimal }; var timestamp = { identify: function identify(value) { return value instanceof Date; }, default: true, tag: 'tag:yaml.org,2002:timestamp', // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part // may be omitted altogether, resulting in a date format. In such a case, the time part is // assumed to be 00:00:00Z (start of day, UTC). test: RegExp('^(?:' + '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})' + // YYYY-Mm-Dd '(?:(?:t|T|[ \\t]+)' + // t | T | whitespace '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)' + // Hh:Mm:Ss(.ss)? '(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30 ')?' + ')$'), resolve: function resolve(str, year, month, day, hour, minute, second, millisec, tz) { if (millisec) millisec = (millisec + '00').substr(1, 3); var date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec || 0); if (tz && tz !== 'Z') { var d = parseSexagesimal(tz[0], tz.slice(1)); if (Math.abs(d) < 30) d *= 60; date -= 60000 * d; } return new Date(date); }, stringify: function stringify(_ref2) { var value = _ref2.value; return value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, ''); } }; /* global console, process, YAML_SILENCE_DEPRECATION_WARNINGS, YAML_SILENCE_WARNINGS */ function shouldWarn(deprecation) { var env = typeof process !== 'undefined' && process.env || {}; if (deprecation) { if (typeof YAML_SILENCE_DEPRECATION_WARNINGS !== 'undefined') return !YAML_SILENCE_DEPRECATION_WARNINGS; return !env.YAML_SILENCE_DEPRECATION_WARNINGS; } if (typeof YAML_SILENCE_WARNINGS !== 'undefined') return !YAML_SILENCE_WARNINGS; return !env.YAML_SILENCE_WARNINGS; } function warn(warning, type) { if (shouldWarn(false)) { var emit = typeof process !== 'undefined' && process.emitWarning; // This will throw in Jest if `warning` is an Error instance due to // https://github.com/facebook/jest/issues/2549 if (emit) emit(warning, type);else { // eslint-disable-next-line no-console console.warn(type ? "".concat(type, ": ").concat(warning) : warning); } } } function warnFileDeprecation(filename) { if (shouldWarn(true)) { var path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/'); warn("The endpoint 'yaml/".concat(path, "' will be removed in a future release."), 'DeprecationWarning'); } } var warned = {}; function warnOptionDeprecation(name, alternative) { if (!warned[name] && shouldWarn(true)) { warned[name] = true; var msg = "The option '".concat(name, "' will be removed in a future release"); msg += alternative ? ", use '".concat(alternative, "' instead.") : '.'; warn(msg, 'DeprecationWarning'); } } export { warnOptionDeprecation as a, binary as b, warnFileDeprecation as c, floatTime as f, intTime as i, omap as o, pairs as p, set as s, timestamp as t, warn as w };