3 var require$$0$6 = require('fs');
4 var require$$0$8 = require('path');
5 var require$$0$7 = require('os');
6 var require$$1$3 = require('tty');
7 var require$$0$9 = require('assert');
8 var require$$0$a = require('util');
9 var require$$0$b = require('stream');
10 var require$$0$c = require('events');
12 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14 var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
15 var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8);
16 var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
17 var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
18 var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$9);
19 var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$a);
20 var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$b);
21 var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$c);
23 function getDefaultExportFromNamespaceIfPresent (n) {
24 return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
27 var require$$0$5 = require("./package.json");
33 /*istanbul ignore start*/
37 Object.defineProperty(exports, "__esModule", {
40 exports["default"] = Diff;
41 /*istanbul ignore end*/
46 /*istanbul ignore start*/
48 /*istanbul ignore end*/
49 diff: function diff(oldString, newString) {
50 /*istanbul ignore start*/
52 /*istanbul ignore end*/
53 options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
54 var callback = options.callback;
56 if (typeof options === 'function') {
61 this.options = options;
64 function done(value) {
66 setTimeout(function () {
67 callback(undefined, value);
73 } // Allow subclasses to massage the input prior to running
76 oldString = this.castInput(oldString);
77 newString = this.castInput(newString);
78 oldString = this.removeEmpty(this.tokenize(oldString));
79 newString = this.removeEmpty(this.tokenize(newString));
80 var newLen = newString.length,
81 oldLen = oldString.length;
83 var maxEditLength = newLen + oldLen;
87 }]; // Seed editLength = 0, i.e. the content starts with the same values
89 var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
91 if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
92 // Identity per the equality and tokenizer
94 value: this.join(newString),
95 count: newString.length
97 } // Main worker method. checks all permutations of a given edit length for acceptance.
100 function execEditLength() {
101 for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
103 /*istanbul ignore start*/
105 /*istanbul ignore end*/
108 var addPath = bestPath[diagonalPath - 1],
109 removePath = bestPath[diagonalPath + 1],
110 _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
113 // No one else is going to attempt to use this value, clear it
114 bestPath[diagonalPath - 1] = undefined;
117 var canAdd = addPath && addPath.newPos + 1 < newLen,
118 canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
120 if (!canAdd && !canRemove) {
121 // If this path is a terminal then prune
122 bestPath[diagonalPath] = undefined;
124 } // Select the diagonal that we want to branch from. We select the prior
125 // path whose position in the new string is the farthest from the origin
126 // and does not pass the bounds of the diff graph
129 if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
130 basePath = clonePath(removePath);
131 self.pushComponent(basePath.components, undefined, true);
133 basePath = addPath; // No need to clone, we've pulled it from the list
136 self.pushComponent(basePath.components, true, undefined);
139 _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
141 if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
142 return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
144 // Otherwise track this path as a potential candidate and continue.
145 bestPath[diagonalPath] = basePath;
150 } // Performs the length of edit iteration. Is a bit fugly as this has to support the
151 // sync and async mode which is never fun. Loops over execEditLength until a value
157 setTimeout(function () {
158 // This should not happen, but we want to be safe.
160 /* istanbul ignore next */
161 if (editLength > maxEditLength) {
165 if (!execEditLength()) {
171 while (editLength <= maxEditLength) {
172 var ret = execEditLength();
181 /*istanbul ignore start*/
183 /*istanbul ignore end*/
184 pushComponent: function pushComponent(components, added, removed) {
185 var last = components[components.length - 1];
187 if (last && last.added === added && last.removed === removed) {
188 // We need to clone here as the component clone operation is just
189 // as shallow array clone
190 components[components.length - 1] = {
191 count: last.count + 1,
204 /*istanbul ignore start*/
206 /*istanbul ignore end*/
207 extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
208 var newLen = newString.length,
209 oldLen = oldString.length,
210 newPos = basePath.newPos,
211 oldPos = newPos - diagonalPath,
214 while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
221 basePath.components.push({
226 basePath.newPos = newPos;
230 /*istanbul ignore start*/
232 /*istanbul ignore end*/
233 equals: function equals(left, right) {
234 if (this.options.comparator) {
235 return this.options.comparator(left, right);
237 return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
241 /*istanbul ignore start*/
243 /*istanbul ignore end*/
244 removeEmpty: function removeEmpty(array) {
247 for (var i = 0; i < array.length; i++) {
256 /*istanbul ignore start*/
258 /*istanbul ignore end*/
259 castInput: function castInput(value) {
263 /*istanbul ignore start*/
265 /*istanbul ignore end*/
266 tokenize: function tokenize(value) {
267 return value.split('');
270 /*istanbul ignore start*/
272 /*istanbul ignore end*/
273 join: function join(chars) {
274 return chars.join('');
278 function buildValues(diff, components, newString, oldString, useLongestToken) {
279 var componentPos = 0,
280 componentLen = components.length,
284 for (; componentPos < componentLen; componentPos++) {
285 var component = components[componentPos];
287 if (!component.removed) {
288 if (!component.added && useLongestToken) {
289 var value = newString.slice(newPos, newPos + component.count);
290 value = value.map(function (value, i) {
291 var oldValue = oldString[oldPos + i];
292 return oldValue.length > value.length ? oldValue : value;
294 component.value = diff.join(value);
296 component.value = diff.join(newString.slice(newPos, newPos + component.count));
299 newPos += component.count; // Common case
301 if (!component.added) {
302 oldPos += component.count;
305 component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
306 oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
307 // The diffing algorithm is tied to add then remove output and this is the simplest
308 // route to get the desired output with minimal overhead.
310 if (componentPos && components[componentPos - 1].added) {
311 var tmp = components[componentPos - 1];
312 components[componentPos - 1] = components[componentPos];
313 components[componentPos] = tmp;
316 } // Special case handle for when one terminal is ignored (i.e. whitespace).
317 // For this case we merge the terminal into the prior string and drop the change.
318 // This is only available for string mode.
321 var lastComponent = components[componentLen - 1];
323 if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
324 components[componentLen - 2].value += lastComponent.value;
331 function clonePath(path) {
334 components: path.components.slice(0)
341 /*istanbul ignore start*/
343 Object.defineProperty(character, "__esModule", {
346 character.diffChars = diffChars;
347 character.characterDiff = void 0;
348 /*istanbul ignore end*/
351 /*istanbul ignore start*/
352 _base$6 = _interopRequireDefault$8(base$1)
353 /*istanbul ignore end*/
355 /*istanbul ignore start*/
358 function _interopRequireDefault$8(obj) {
359 return obj && obj.__esModule ? obj : {
363 /*istanbul ignore end*/
366 var characterDiff = new
367 /*istanbul ignore start*/
369 /*istanbul ignore end*/
371 /*istanbul ignore start*/
373 /*istanbul ignore end*/
375 /*istanbul ignore start*/
377 character.characterDiff = characterDiff;
378 /*istanbul ignore end*/
380 function diffChars(oldStr, newStr, options) {
381 return characterDiff.diff(oldStr, newStr, options);
388 /*istanbul ignore start*/
390 Object.defineProperty(params, "__esModule", {
393 params.generateOptions = generateOptions;
394 /*istanbul ignore end*/
396 function generateOptions(options, defaults) {
397 if (typeof options === 'function') {
398 defaults.callback = options;
399 } else if (options) {
400 for (var name in options) {
401 /* istanbul ignore else */
402 if (options.hasOwnProperty(name)) {
403 defaults[name] = options[name];
411 /*istanbul ignore start*/
413 Object.defineProperty(word, "__esModule", {
416 word.diffWords = diffWords;
417 word.diffWordsWithSpace = diffWordsWithSpace;
418 word.wordDiff = void 0;
419 /*istanbul ignore end*/
422 /*istanbul ignore start*/
423 _base$5 = _interopRequireDefault$7(base$1)
424 /*istanbul ignore end*/
428 /*istanbul ignore start*/
430 /*istanbul ignore end*/
432 /*istanbul ignore start*/
434 function _interopRequireDefault$7(obj) {
435 return obj && obj.__esModule ? obj : {
439 /*istanbul ignore end*/
440 // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
442 // Ranges and exceptions:
443 // Latin-1 Supplement, 0080–00FF
444 // - U+00D7 × Multiplication sign
445 // - U+00F7 ÷ Division sign
446 // Latin Extended-A, 0100–017F
447 // Latin Extended-B, 0180–024F
448 // IPA Extensions, 0250–02AF
449 // Spacing Modifier Letters, 02B0–02FF
450 // - U+02C7 ˇ ˇ Caron
451 // - U+02D8 ˘ ˘ Breve
452 // - U+02D9 ˙ ˙ Dot Above
453 // - U+02DA ˚ ˚ Ring Above
454 // - U+02DB ˛ ˛ Ogonek
455 // - U+02DC ˜ ˜ Small Tilde
456 // - U+02DD ˝ ˝ Double Acute Accent
457 // Latin Extended Additional, 1E00–1EFF
460 var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
461 var reWhitespace = /\S/;
463 /*istanbul ignore start*/
465 /*istanbul ignore end*/
467 /*istanbul ignore start*/
469 /*istanbul ignore end*/
471 /*istanbul ignore start*/
473 word.wordDiff = wordDiff;
474 /*istanbul ignore end*/
476 wordDiff.equals = function (left, right) {
477 if (this.options.ignoreCase) {
478 left = left.toLowerCase();
479 right = right.toLowerCase();
482 return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
485 wordDiff.tokenize = function (value) {
486 // All whitespace symbols except newline group into one token, each newline - in separate token
487 var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
489 for (var i = 0; i < tokens.length - 1; i++) {
490 // If we have an empty string in the next field and we have only word chars before and after, merge
491 if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
492 tokens[i] += tokens[i + 2];
493 tokens.splice(i + 1, 2);
501 function diffWords(oldStr, newStr, options) {
503 /*istanbul ignore start*/
504 (/*istanbul ignore end*/
506 /*istanbul ignore start*/
508 /*istanbul ignore end*/
510 /*istanbul ignore start*/
512 /*istanbul ignore end*/
514 ignoreWhitespace: true
516 return wordDiff.diff(oldStr, newStr, options);
519 function diffWordsWithSpace(oldStr, newStr, options) {
520 return wordDiff.diff(oldStr, newStr, options);
525 /*istanbul ignore start*/
527 Object.defineProperty(line$B, "__esModule", {
530 line$B.diffLines = diffLines;
531 line$B.diffTrimmedLines = diffTrimmedLines;
532 line$B.lineDiff = void 0;
533 /*istanbul ignore end*/
536 /*istanbul ignore start*/
537 _base$4 = _interopRequireDefault$6(base$1)
538 /*istanbul ignore end*/
542 /*istanbul ignore start*/
544 /*istanbul ignore end*/
546 /*istanbul ignore start*/
548 function _interopRequireDefault$6(obj) {
549 return obj && obj.__esModule ? obj : {
553 /*istanbul ignore end*/
557 /*istanbul ignore start*/
559 /*istanbul ignore end*/
561 /*istanbul ignore start*/
563 /*istanbul ignore end*/
565 /*istanbul ignore start*/
567 line$B.lineDiff = lineDiff;
568 /*istanbul ignore end*/
570 lineDiff.tokenize = function (value) {
572 linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
574 if (!linesAndNewlines[linesAndNewlines.length - 1]) {
575 linesAndNewlines.pop();
576 } // Merge the content and line separators into single tokens
579 for (var i = 0; i < linesAndNewlines.length; i++) {
580 var line = linesAndNewlines[i];
582 if (i % 2 && !this.options.newlineIsToken) {
583 retLines[retLines.length - 1] += line;
585 if (this.options.ignoreWhitespace) {
596 function diffLines(oldStr, newStr, callback) {
597 return lineDiff.diff(oldStr, newStr, callback);
600 function diffTrimmedLines(oldStr, newStr, callback) {
602 /*istanbul ignore start*/
603 (/*istanbul ignore end*/
605 /*istanbul ignore start*/
607 /*istanbul ignore end*/
609 /*istanbul ignore start*/
611 /*istanbul ignore end*/
613 ignoreWhitespace: true
615 return lineDiff.diff(oldStr, newStr, options);
620 /*istanbul ignore start*/
622 Object.defineProperty(sentence, "__esModule", {
625 sentence.diffSentences = diffSentences;
626 sentence.sentenceDiff = void 0;
627 /*istanbul ignore end*/
630 /*istanbul ignore start*/
631 _base$3 = _interopRequireDefault$5(base$1)
632 /*istanbul ignore end*/
634 /*istanbul ignore start*/
637 function _interopRequireDefault$5(obj) {
638 return obj && obj.__esModule ? obj : {
642 /*istanbul ignore end*/
645 var sentenceDiff = new
646 /*istanbul ignore start*/
648 /*istanbul ignore end*/
650 /*istanbul ignore start*/
652 /*istanbul ignore end*/
654 /*istanbul ignore start*/
656 sentence.sentenceDiff = sentenceDiff;
657 /*istanbul ignore end*/
659 sentenceDiff.tokenize = function (value) {
660 return value.split(/(\S.+?[.!?])(?=\s+|$)/);
663 function diffSentences(oldStr, newStr, callback) {
664 return sentenceDiff.diff(oldStr, newStr, callback);
669 /*istanbul ignore start*/
671 Object.defineProperty(css$1, "__esModule", {
674 css$1.diffCss = diffCss;
675 css$1.cssDiff = void 0;
676 /*istanbul ignore end*/
679 /*istanbul ignore start*/
680 _base$2 = _interopRequireDefault$4(base$1)
681 /*istanbul ignore end*/
683 /*istanbul ignore start*/
686 function _interopRequireDefault$4(obj) {
687 return obj && obj.__esModule ? obj : {
691 /*istanbul ignore end*/
695 /*istanbul ignore start*/
697 /*istanbul ignore end*/
699 /*istanbul ignore start*/
701 /*istanbul ignore end*/
703 /*istanbul ignore start*/
705 css$1.cssDiff = cssDiff;
706 /*istanbul ignore end*/
708 cssDiff.tokenize = function (value) {
709 return value.split(/([{}:;,]|\s+)/);
712 function diffCss(oldStr, newStr, callback) {
713 return cssDiff.diff(oldStr, newStr, callback);
716 var check = function (it) {
717 return it && it.Math == Math && it;
720 // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
722 // eslint-disable-next-line es/no-global-this -- safe
723 check(typeof globalThis == 'object' && globalThis) ||
724 check(typeof window == 'object' && window) ||
725 // eslint-disable-next-line no-restricted-globals -- safe
726 check(typeof self == 'object' && self) ||
727 check(typeof global$s == 'object' && global$s) ||
728 // eslint-disable-next-line no-new-func -- fallback
729 (function () { return this; })() || Function('return this')();
731 var objectGetOwnPropertyDescriptor = {};
733 var fails$8 = function (exec) {
741 var fails$7 = fails$8;
743 // Detect IE8's incomplete defineProperty implementation
744 var descriptors$1 = !fails$7(function () {
745 // eslint-disable-next-line es/no-object-defineproperty -- required for testing
746 return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
749 var call$7 = Function.prototype.call;
751 var functionCall = call$7.bind ? call$7.bind(call$7) : function () {
752 return call$7.apply(call$7, arguments);
755 var objectPropertyIsEnumerable = {};
757 var $propertyIsEnumerable = {}.propertyIsEnumerable;
758 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
759 var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
761 // Nashorn ~ JDK8 bug
762 var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
764 // `Object.prototype.propertyIsEnumerable` method implementation
765 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
766 objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
767 var descriptor = getOwnPropertyDescriptor$1(this, V);
768 return !!descriptor && descriptor.enumerable;
769 } : $propertyIsEnumerable;
771 var createPropertyDescriptor$3 = function (bitmap, value) {
773 enumerable: !(bitmap & 1),
774 configurable: !(bitmap & 2),
775 writable: !(bitmap & 4),
780 var FunctionPrototype$1 = Function.prototype;
781 var bind$4 = FunctionPrototype$1.bind;
782 var call$6 = FunctionPrototype$1.call;
783 var callBind = bind$4 && bind$4.bind(call$6);
785 var functionUncurryThis = bind$4 ? function (fn) {
786 return fn && callBind(call$6, fn);
788 return fn && function () {
789 return call$6.apply(fn, arguments);
793 var uncurryThis$c = functionUncurryThis;
795 var toString$5 = uncurryThis$c({}.toString);
796 var stringSlice = uncurryThis$c(''.slice);
798 var classofRaw$1 = function (it) {
799 return stringSlice(toString$5(it), 8, -1);
802 var global$r = global$s;
803 var uncurryThis$b = functionUncurryThis;
804 var fails$6 = fails$8;
805 var classof$5 = classofRaw$1;
807 var Object$4 = global$r.Object;
808 var split = uncurryThis$b(''.split);
810 // fallback for non-array-like ES3 and non-enumerable old V8 strings
811 var indexedObject = fails$6(function () {
812 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
813 // eslint-disable-next-line no-prototype-builtins -- safe
814 return !Object$4('z').propertyIsEnumerable(0);
816 return classof$5(it) == 'String' ? split(it, '') : Object$4(it);
819 var global$q = global$s;
821 var TypeError$a = global$q.TypeError;
823 // `RequireObjectCoercible` abstract operation
824 // https://tc39.es/ecma262/#sec-requireobjectcoercible
825 var requireObjectCoercible$2 = function (it) {
826 if (it == undefined) throw TypeError$a("Can't call method on " + it);
830 // toObject with fallback for non-array-like ES3 strings
831 var IndexedObject = indexedObject;
832 var requireObjectCoercible$1 = requireObjectCoercible$2;
834 var toIndexedObject$4 = function (it) {
835 return IndexedObject(requireObjectCoercible$1(it));
838 // `IsCallable` abstract operation
839 // https://tc39.es/ecma262/#sec-iscallable
840 var isCallable$b = function (argument) {
841 return typeof argument == 'function';
844 var isCallable$a = isCallable$b;
846 var isObject$c = function (it) {
847 return typeof it == 'object' ? it !== null : isCallable$a(it);
850 var global$p = global$s;
851 var isCallable$9 = isCallable$b;
853 var aFunction = function (argument) {
854 return isCallable$9(argument) ? argument : undefined;
857 var getBuiltIn$5 = function (namespace, method) {
858 return arguments.length < 2 ? aFunction(global$p[namespace]) : global$p[namespace] && global$p[namespace][method];
861 var uncurryThis$a = functionUncurryThis;
863 var objectIsPrototypeOf = uncurryThis$a({}.isPrototypeOf);
865 var getBuiltIn$4 = getBuiltIn$5;
867 var engineUserAgent = getBuiltIn$4('navigator', 'userAgent') || '';
869 var global$o = global$s;
870 var userAgent$2 = engineUserAgent;
872 var process$3 = global$o.process;
873 var Deno = global$o.Deno;
874 var versions = process$3 && process$3.versions || Deno && Deno.version;
875 var v8$2 = versions && versions.v8;
876 var match$1, version$2;
879 match$1 = v8$2.split('.');
880 // in old Chrome, versions of V8 isn't V8 = Chrome / 10
881 // but their correct versions are not interesting for us
882 version$2 = match$1[0] > 0 && match$1[0] < 4 ? 1 : +(match$1[0] + match$1[1]);
885 // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
886 // so check `userAgent` even if `.v8` exists, but 0
887 if (!version$2 && userAgent$2) {
888 match$1 = userAgent$2.match(/Edge\/(\d+)/);
889 if (!match$1 || match$1[1] >= 74) {
890 match$1 = userAgent$2.match(/Chrome\/(\d+)/);
891 if (match$1) version$2 = +match$1[1];
895 var engineV8Version = version$2;
897 /* eslint-disable es/no-symbol -- required for testing */
899 var V8_VERSION = engineV8Version;
900 var fails$5 = fails$8;
902 // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
903 var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$5(function () {
904 var symbol = Symbol();
905 // Chrome 38 Symbol has incorrect toString conversion
906 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
907 return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
908 // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
909 !Symbol.sham && V8_VERSION && V8_VERSION < 41;
912 /* eslint-disable es/no-symbol -- required for testing */
914 var NATIVE_SYMBOL$1 = nativeSymbol;
916 var useSymbolAsUid = NATIVE_SYMBOL$1
918 && typeof Symbol.iterator == 'symbol';
920 var global$n = global$s;
921 var getBuiltIn$3 = getBuiltIn$5;
922 var isCallable$8 = isCallable$b;
923 var isPrototypeOf$1 = objectIsPrototypeOf;
924 var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
926 var Object$3 = global$n.Object;
928 var isSymbol$6 = USE_SYMBOL_AS_UID$1 ? function (it) {
929 return typeof it == 'symbol';
931 var $Symbol = getBuiltIn$3('Symbol');
932 return isCallable$8($Symbol) && isPrototypeOf$1($Symbol.prototype, Object$3(it));
935 var global$m = global$s;
937 var String$3 = global$m.String;
939 var tryToString$3 = function (argument) {
941 return String$3(argument);
947 var global$l = global$s;
948 var isCallable$7 = isCallable$b;
949 var tryToString$2 = tryToString$3;
951 var TypeError$9 = global$l.TypeError;
953 // `Assert: IsCallable(argument) is true`
954 var aCallable$5 = function (argument) {
955 if (isCallable$7(argument)) return argument;
956 throw TypeError$9(tryToString$2(argument) + ' is not a function');
959 var aCallable$4 = aCallable$5;
961 // `GetMethod` abstract operation
962 // https://tc39.es/ecma262/#sec-getmethod
963 var getMethod$3 = function (V, P) {
965 return func == null ? undefined : aCallable$4(func);
968 var global$k = global$s;
969 var call$5 = functionCall;
970 var isCallable$6 = isCallable$b;
971 var isObject$b = isObject$c;
973 var TypeError$8 = global$k.TypeError;
975 // `OrdinaryToPrimitive` abstract operation
976 // https://tc39.es/ecma262/#sec-ordinarytoprimitive
977 var ordinaryToPrimitive$1 = function (input, pref) {
979 if (pref === 'string' && isCallable$6(fn = input.toString) && !isObject$b(val = call$5(fn, input))) return val;
980 if (isCallable$6(fn = input.valueOf) && !isObject$b(val = call$5(fn, input))) return val;
981 if (pref !== 'string' && isCallable$6(fn = input.toString) && !isObject$b(val = call$5(fn, input))) return val;
982 throw TypeError$8("Can't convert object to primitive value");
985 var shared$3 = {exports: {}};
987 var global$j = global$s;
989 // eslint-disable-next-line es/no-object-defineproperty -- safe
990 var defineProperty$1 = Object.defineProperty;
992 var setGlobal$3 = function (key, value) {
994 defineProperty$1(global$j, key, { value: value, configurable: true, writable: true });
996 global$j[key] = value;
1000 var global$i = global$s;
1001 var setGlobal$2 = setGlobal$3;
1003 var SHARED = '__core-js_shared__';
1004 var store$3 = global$i[SHARED] || setGlobal$2(SHARED, {});
1006 var sharedStore = store$3;
1008 var store$2 = sharedStore;
1010 (shared$3.exports = function (key, value) {
1011 return store$2[key] || (store$2[key] = value !== undefined ? value : {});
1012 })('versions', []).push({
1015 copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
1018 var global$h = global$s;
1019 var requireObjectCoercible = requireObjectCoercible$2;
1021 var Object$2 = global$h.Object;
1023 // `ToObject` abstract operation
1024 // https://tc39.es/ecma262/#sec-toobject
1025 var toObject$4 = function (argument) {
1026 return Object$2(requireObjectCoercible(argument));
1029 var uncurryThis$9 = functionUncurryThis;
1030 var toObject$3 = toObject$4;
1032 var hasOwnProperty$b = uncurryThis$9({}.hasOwnProperty);
1034 // `HasOwnProperty` abstract operation
1035 // https://tc39.es/ecma262/#sec-hasownproperty
1036 var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
1037 return hasOwnProperty$b(toObject$3(it), key);
1040 var uncurryThis$8 = functionUncurryThis;
1043 var postfix = Math.random();
1044 var toString$4 = uncurryThis$8(1.0.toString);
1046 var uid$3 = function (key) {
1047 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$4(++id + postfix, 36);
1050 var global$g = global$s;
1051 var shared$2 = shared$3.exports;
1052 var hasOwn$6 = hasOwnProperty_1;
1054 var NATIVE_SYMBOL = nativeSymbol;
1055 var USE_SYMBOL_AS_UID = useSymbolAsUid;
1057 var WellKnownSymbolsStore = shared$2('wks');
1058 var Symbol$6 = global$g.Symbol;
1059 var symbolFor = Symbol$6 && Symbol$6['for'];
1060 var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$6 : Symbol$6 && Symbol$6.withoutSetter || uid$2;
1062 var wellKnownSymbol$7 = function (name) {
1063 if (!hasOwn$6(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
1064 var description = 'Symbol.' + name;
1065 if (NATIVE_SYMBOL && hasOwn$6(Symbol$6, name)) {
1066 WellKnownSymbolsStore[name] = Symbol$6[name];
1067 } else if (USE_SYMBOL_AS_UID && symbolFor) {
1068 WellKnownSymbolsStore[name] = symbolFor(description);
1070 WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
1072 } return WellKnownSymbolsStore[name];
1075 var global$f = global$s;
1076 var call$4 = functionCall;
1077 var isObject$a = isObject$c;
1078 var isSymbol$5 = isSymbol$6;
1079 var getMethod$2 = getMethod$3;
1080 var ordinaryToPrimitive = ordinaryToPrimitive$1;
1081 var wellKnownSymbol$6 = wellKnownSymbol$7;
1083 var TypeError$7 = global$f.TypeError;
1084 var TO_PRIMITIVE = wellKnownSymbol$6('toPrimitive');
1086 // `ToPrimitive` abstract operation
1087 // https://tc39.es/ecma262/#sec-toprimitive
1088 var toPrimitive$1 = function (input, pref) {
1089 if (!isObject$a(input) || isSymbol$5(input)) return input;
1090 var exoticToPrim = getMethod$2(input, TO_PRIMITIVE);
1093 if (pref === undefined) pref = 'default';
1094 result = call$4(exoticToPrim, input, pref);
1095 if (!isObject$a(result) || isSymbol$5(result)) return result;
1096 throw TypeError$7("Can't convert object to primitive value");
1098 if (pref === undefined) pref = 'number';
1099 return ordinaryToPrimitive(input, pref);
1102 var toPrimitive = toPrimitive$1;
1103 var isSymbol$4 = isSymbol$6;
1105 // `ToPropertyKey` abstract operation
1106 // https://tc39.es/ecma262/#sec-topropertykey
1107 var toPropertyKey$3 = function (argument) {
1108 var key = toPrimitive(argument, 'string');
1109 return isSymbol$4(key) ? key : key + '';
1112 var global$e = global$s;
1113 var isObject$9 = isObject$c;
1115 var document$1 = global$e.document;
1116 // typeof document.createElement is 'object' in old IE
1117 var EXISTS$1 = isObject$9(document$1) && isObject$9(document$1.createElement);
1119 var documentCreateElement$1 = function (it) {
1120 return EXISTS$1 ? document$1.createElement(it) : {};
1123 var DESCRIPTORS$5 = descriptors$1;
1124 var fails$4 = fails$8;
1125 var createElement = documentCreateElement$1;
1127 // Thank's IE8 for his funny defineProperty
1128 var ie8DomDefine = !DESCRIPTORS$5 && !fails$4(function () {
1129 // eslint-disable-next-line es/no-object-defineproperty -- requied for testing
1130 return Object.defineProperty(createElement('div'), 'a', {
1131 get: function () { return 7; }
1135 var DESCRIPTORS$4 = descriptors$1;
1136 var call$3 = functionCall;
1137 var propertyIsEnumerableModule = objectPropertyIsEnumerable;
1138 var createPropertyDescriptor$2 = createPropertyDescriptor$3;
1139 var toIndexedObject$3 = toIndexedObject$4;
1140 var toPropertyKey$2 = toPropertyKey$3;
1141 var hasOwn$5 = hasOwnProperty_1;
1142 var IE8_DOM_DEFINE$1 = ie8DomDefine;
1144 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1145 var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1147 // `Object.getOwnPropertyDescriptor` method
1148 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
1149 objectGetOwnPropertyDescriptor.f = DESCRIPTORS$4 ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
1150 O = toIndexedObject$3(O);
1151 P = toPropertyKey$2(P);
1152 if (IE8_DOM_DEFINE$1) try {
1153 return $getOwnPropertyDescriptor(O, P);
1154 } catch (error) { /* empty */ }
1155 if (hasOwn$5(O, P)) return createPropertyDescriptor$2(!call$3(propertyIsEnumerableModule.f, O, P), O[P]);
1158 var objectDefineProperty = {};
1160 var global$d = global$s;
1161 var isObject$8 = isObject$c;
1163 var String$2 = global$d.String;
1164 var TypeError$6 = global$d.TypeError;
1166 // `Assert: Type(argument) is Object`
1167 var anObject$7 = function (argument) {
1168 if (isObject$8(argument)) return argument;
1169 throw TypeError$6(String$2(argument) + ' is not an object');
1172 var global$c = global$s;
1173 var DESCRIPTORS$3 = descriptors$1;
1174 var IE8_DOM_DEFINE = ie8DomDefine;
1175 var anObject$6 = anObject$7;
1176 var toPropertyKey$1 = toPropertyKey$3;
1178 var TypeError$5 = global$c.TypeError;
1179 // eslint-disable-next-line es/no-object-defineproperty -- safe
1180 var $defineProperty = Object.defineProperty;
1182 // `Object.defineProperty` method
1183 // https://tc39.es/ecma262/#sec-object.defineproperty
1184 objectDefineProperty.f = DESCRIPTORS$3 ? $defineProperty : function defineProperty(O, P, Attributes) {
1186 P = toPropertyKey$1(P);
1187 anObject$6(Attributes);
1188 if (IE8_DOM_DEFINE) try {
1189 return $defineProperty(O, P, Attributes);
1190 } catch (error) { /* empty */ }
1191 if ('get' in Attributes || 'set' in Attributes) throw TypeError$5('Accessors not supported');
1192 if ('value' in Attributes) O[P] = Attributes.value;
1196 var DESCRIPTORS$2 = descriptors$1;
1197 var definePropertyModule$4 = objectDefineProperty;
1198 var createPropertyDescriptor$1 = createPropertyDescriptor$3;
1200 var createNonEnumerableProperty$3 = DESCRIPTORS$2 ? function (object, key, value) {
1201 return definePropertyModule$4.f(object, key, createPropertyDescriptor$1(1, value));
1202 } : function (object, key, value) {
1203 object[key] = value;
1207 var redefine$1 = {exports: {}};
1209 var uncurryThis$7 = functionUncurryThis;
1210 var isCallable$5 = isCallable$b;
1211 var store$1 = sharedStore;
1213 var functionToString = uncurryThis$7(Function.toString);
1215 // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
1216 if (!isCallable$5(store$1.inspectSource)) {
1217 store$1.inspectSource = function (it) {
1218 return functionToString(it);
1222 var inspectSource$3 = store$1.inspectSource;
1224 var global$b = global$s;
1225 var isCallable$4 = isCallable$b;
1226 var inspectSource$2 = inspectSource$3;
1228 var WeakMap$4 = global$b.WeakMap;
1230 var nativeWeakMap = isCallable$4(WeakMap$4) && /native code/.test(inspectSource$2(WeakMap$4));
1232 var shared$1 = shared$3.exports;
1235 var keys$4 = shared$1('keys');
1237 var sharedKey$2 = function (key) {
1238 return keys$4[key] || (keys$4[key] = uid$1(key));
1241 var hiddenKeys$4 = {};
1243 var NATIVE_WEAK_MAP = nativeWeakMap;
1244 var global$a = global$s;
1245 var uncurryThis$6 = functionUncurryThis;
1246 var isObject$7 = isObject$c;
1247 var createNonEnumerableProperty$2 = createNonEnumerableProperty$3;
1248 var hasOwn$4 = hasOwnProperty_1;
1249 var shared = sharedStore;
1250 var sharedKey$1 = sharedKey$2;
1251 var hiddenKeys$3 = hiddenKeys$4;
1253 var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
1254 var TypeError$4 = global$a.TypeError;
1255 var WeakMap$3 = global$a.WeakMap;
1256 var set$1, get$3, has$1;
1258 var enforce = function (it) {
1259 return has$1(it) ? get$3(it) : set$1(it, {});
1262 var getterFor = function (TYPE) {
1263 return function (it) {
1265 if (!isObject$7(it) || (state = get$3(it)).type !== TYPE) {
1266 throw TypeError$4('Incompatible receiver, ' + TYPE + ' required');
1271 if (NATIVE_WEAK_MAP || shared.state) {
1272 var store = shared.state || (shared.state = new WeakMap$3());
1273 var wmget = uncurryThis$6(store.get);
1274 var wmhas = uncurryThis$6(store.has);
1275 var wmset = uncurryThis$6(store.set);
1276 set$1 = function (it, metadata) {
1277 if (wmhas(store, it)) throw new TypeError$4(OBJECT_ALREADY_INITIALIZED);
1278 metadata.facade = it;
1279 wmset(store, it, metadata);
1282 get$3 = function (it) {
1283 return wmget(store, it) || {};
1285 has$1 = function (it) {
1286 return wmhas(store, it);
1289 var STATE = sharedKey$1('state');
1290 hiddenKeys$3[STATE] = true;
1291 set$1 = function (it, metadata) {
1292 if (hasOwn$4(it, STATE)) throw new TypeError$4(OBJECT_ALREADY_INITIALIZED);
1293 metadata.facade = it;
1294 createNonEnumerableProperty$2(it, STATE, metadata);
1297 get$3 = function (it) {
1298 return hasOwn$4(it, STATE) ? it[STATE] : {};
1300 has$1 = function (it) {
1301 return hasOwn$4(it, STATE);
1305 var internalState = {
1310 getterFor: getterFor
1313 var DESCRIPTORS$1 = descriptors$1;
1314 var hasOwn$3 = hasOwnProperty_1;
1316 var FunctionPrototype = Function.prototype;
1317 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1318 var getDescriptor = DESCRIPTORS$1 && Object.getOwnPropertyDescriptor;
1320 var EXISTS = hasOwn$3(FunctionPrototype, 'name');
1321 // additional protection from minified / mangled / dropped function names
1322 var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
1323 var CONFIGURABLE = EXISTS && (!DESCRIPTORS$1 || (DESCRIPTORS$1 && getDescriptor(FunctionPrototype, 'name').configurable));
1325 var functionName = {
1328 CONFIGURABLE: CONFIGURABLE
1331 var global$9 = global$s;
1332 var isCallable$3 = isCallable$b;
1333 var hasOwn$2 = hasOwnProperty_1;
1334 var createNonEnumerableProperty$1 = createNonEnumerableProperty$3;
1335 var setGlobal$1 = setGlobal$3;
1336 var inspectSource$1 = inspectSource$3;
1337 var InternalStateModule = internalState;
1338 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
1340 var getInternalState = InternalStateModule.get;
1341 var enforceInternalState = InternalStateModule.enforce;
1342 var TEMPLATE = String(String).split('String');
1344 (redefine$1.exports = function (O, key, value, options) {
1345 var unsafe = options ? !!options.unsafe : false;
1346 var simple = options ? !!options.enumerable : false;
1347 var noTargetGet = options ? !!options.noTargetGet : false;
1348 var name = options && options.name !== undefined ? options.name : key;
1350 if (isCallable$3(value)) {
1351 if (String(name).slice(0, 7) === 'Symbol(') {
1352 name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
1354 if (!hasOwn$2(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
1355 createNonEnumerableProperty$1(value, 'name', name);
1357 state = enforceInternalState(value);
1358 if (!state.source) {
1359 state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
1362 if (O === global$9) {
1363 if (simple) O[key] = value;
1364 else setGlobal$1(key, value);
1366 } else if (!unsafe) {
1368 } else if (!noTargetGet && O[key]) {
1371 if (simple) O[key] = value;
1372 else createNonEnumerableProperty$1(O, key, value);
1373 // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
1374 })(Function.prototype, 'toString', function toString() {
1375 return isCallable$3(this) && getInternalState(this).source || inspectSource$1(this);
1378 var objectGetOwnPropertyNames = {};
1380 var ceil = Math.ceil;
1381 var floor$1 = Math.floor;
1383 // `ToIntegerOrInfinity` abstract operation
1384 // https://tc39.es/ecma262/#sec-tointegerorinfinity
1385 var toIntegerOrInfinity$3 = function (argument) {
1386 var number = +argument;
1387 // eslint-disable-next-line no-self-compare -- safe
1388 return number !== number || number === 0 ? 0 : (number > 0 ? floor$1 : ceil)(number);
1391 var toIntegerOrInfinity$2 = toIntegerOrInfinity$3;
1394 var min$1 = Math.min;
1396 // Helper for a popular repeating case of the spec:
1397 // Let integer be ? ToInteger(index).
1398 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
1399 var toAbsoluteIndex$1 = function (index, length) {
1400 var integer = toIntegerOrInfinity$2(index);
1401 return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
1404 var toIntegerOrInfinity$1 = toIntegerOrInfinity$3;
1408 // `ToLength` abstract operation
1409 // https://tc39.es/ecma262/#sec-tolength
1410 var toLength$1 = function (argument) {
1411 return argument > 0 ? min(toIntegerOrInfinity$1(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
1414 var toLength = toLength$1;
1416 // `LengthOfArrayLike` abstract operation
1417 // https://tc39.es/ecma262/#sec-lengthofarraylike
1418 var lengthOfArrayLike$6 = function (obj) {
1419 return toLength(obj.length);
1422 var toIndexedObject$2 = toIndexedObject$4;
1423 var toAbsoluteIndex = toAbsoluteIndex$1;
1424 var lengthOfArrayLike$5 = lengthOfArrayLike$6;
1426 // `Array.prototype.{ indexOf, includes }` methods implementation
1427 var createMethod = function (IS_INCLUDES) {
1428 return function ($this, el, fromIndex) {
1429 var O = toIndexedObject$2($this);
1430 var length = lengthOfArrayLike$5(O);
1431 var index = toAbsoluteIndex(fromIndex, length);
1433 // Array#includes uses SameValueZero equality algorithm
1434 // eslint-disable-next-line no-self-compare -- NaN check
1435 if (IS_INCLUDES && el != el) while (length > index) {
1437 // eslint-disable-next-line no-self-compare -- NaN check
1438 if (value != value) return true;
1439 // Array#indexOf ignores holes, Array#includes - not
1440 } else for (;length > index; index++) {
1441 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
1442 } return !IS_INCLUDES && -1;
1446 var arrayIncludes$2 = {
1447 // `Array.prototype.includes` method
1448 // https://tc39.es/ecma262/#sec-array.prototype.includes
1449 includes: createMethod(true),
1450 // `Array.prototype.indexOf` method
1451 // https://tc39.es/ecma262/#sec-array.prototype.indexof
1452 indexOf: createMethod(false)
1455 var uncurryThis$5 = functionUncurryThis;
1456 var hasOwn$1 = hasOwnProperty_1;
1457 var toIndexedObject$1 = toIndexedObject$4;
1458 var indexOf = arrayIncludes$2.indexOf;
1459 var hiddenKeys$2 = hiddenKeys$4;
1461 var push$3 = uncurryThis$5([].push);
1463 var objectKeysInternal = function (object, names) {
1464 var O = toIndexedObject$1(object);
1468 for (key in O) !hasOwn$1(hiddenKeys$2, key) && hasOwn$1(O, key) && push$3(result, key);
1469 // Don't enum bug & hidden keys
1470 while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
1471 ~indexOf(result, key) || push$3(result, key);
1476 // IE8- don't enum bug keys
1477 var enumBugKeys$3 = [
1481 'propertyIsEnumerable',
1487 var internalObjectKeys$1 = objectKeysInternal;
1488 var enumBugKeys$2 = enumBugKeys$3;
1490 var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
1492 // `Object.getOwnPropertyNames` method
1493 // https://tc39.es/ecma262/#sec-object.getownpropertynames
1494 // eslint-disable-next-line es/no-object-getownpropertynames -- safe
1495 objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
1496 return internalObjectKeys$1(O, hiddenKeys$1);
1499 var objectGetOwnPropertySymbols = {};
1501 // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
1502 objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
1504 var getBuiltIn$2 = getBuiltIn$5;
1505 var uncurryThis$4 = functionUncurryThis;
1506 var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
1507 var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
1508 var anObject$5 = anObject$7;
1510 var concat = uncurryThis$4([].concat);
1512 // all object keys, includes non-enumerable and symbols
1513 var ownKeys$1 = getBuiltIn$2('Reflect', 'ownKeys') || function ownKeys(it) {
1514 var keys = getOwnPropertyNamesModule.f(anObject$5(it));
1515 var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
1516 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
1519 var hasOwn = hasOwnProperty_1;
1520 var ownKeys = ownKeys$1;
1521 var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
1522 var definePropertyModule$3 = objectDefineProperty;
1524 var copyConstructorProperties$1 = function (target, source) {
1525 var keys = ownKeys(source);
1526 var defineProperty = definePropertyModule$3.f;
1527 var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
1528 for (var i = 0; i < keys.length; i++) {
1530 if (!hasOwn(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
1534 var fails$3 = fails$8;
1535 var isCallable$2 = isCallable$b;
1537 var replacement = /#|\.prototype\./;
1539 var isForced$1 = function (feature, detection) {
1540 var value = data$3[normalize$3(feature)];
1541 return value == POLYFILL ? true
1542 : value == NATIVE ? false
1543 : isCallable$2(detection) ? fails$3(detection)
1547 var normalize$3 = isForced$1.normalize = function (string) {
1548 return String(string).replace(replacement, '.').toLowerCase();
1551 var data$3 = isForced$1.data = {};
1552 var NATIVE = isForced$1.NATIVE = 'N';
1553 var POLYFILL = isForced$1.POLYFILL = 'P';
1555 var isForced_1 = isForced$1;
1557 var global$8 = global$s;
1558 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
1559 var createNonEnumerableProperty = createNonEnumerableProperty$3;
1560 var redefine = redefine$1.exports;
1561 var setGlobal = setGlobal$3;
1562 var copyConstructorProperties = copyConstructorProperties$1;
1563 var isForced = isForced_1;
1566 options.target - name of the target object
1567 options.global - target is the global object
1568 options.stat - export as static methods of target
1569 options.proto - export as prototype methods of target
1570 options.real - real prototype method for the `pure` version
1571 options.forced - export even if the native feature is available
1572 options.bind - bind methods to the target, required for the `pure` version
1573 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
1574 options.unsafe - use the simple assignment of property instead of delete + defineProperty
1575 options.sham - add a flag to not completely full polyfills
1576 options.enumerable - export as enumerable property
1577 options.noTargetGet - prevent calling a getter on target
1578 options.name - the .name of the function if it does not match the key
1580 var _export = function (options, source) {
1581 var TARGET = options.target;
1582 var GLOBAL = options.global;
1583 var STATIC = options.stat;
1584 var FORCED, target, key, targetProperty, sourceProperty, descriptor;
1587 } else if (STATIC) {
1588 target = global$8[TARGET] || setGlobal(TARGET, {});
1590 target = (global$8[TARGET] || {}).prototype;
1592 if (target) for (key in source) {
1593 sourceProperty = source[key];
1594 if (options.noTargetGet) {
1595 descriptor = getOwnPropertyDescriptor(target, key);
1596 targetProperty = descriptor && descriptor.value;
1597 } else targetProperty = target[key];
1598 FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
1599 // contained in target
1600 if (!FORCED && targetProperty !== undefined) {
1601 if (typeof sourceProperty == typeof targetProperty) continue;
1602 copyConstructorProperties(sourceProperty, targetProperty);
1604 // add a flag to not completely full polyfills
1605 if (options.sham || (targetProperty && targetProperty.sham)) {
1606 createNonEnumerableProperty(sourceProperty, 'sham', true);
1609 redefine(target, key, sourceProperty, options);
1613 var wellKnownSymbol$5 = wellKnownSymbol$7;
1615 var TO_STRING_TAG$1 = wellKnownSymbol$5('toStringTag');
1618 test$1[TO_STRING_TAG$1] = 'z';
1620 var toStringTagSupport = String(test$1) === '[object z]';
1622 var global$7 = global$s;
1623 var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1624 var isCallable$1 = isCallable$b;
1625 var classofRaw = classofRaw$1;
1626 var wellKnownSymbol$4 = wellKnownSymbol$7;
1628 var TO_STRING_TAG = wellKnownSymbol$4('toStringTag');
1629 var Object$1 = global$7.Object;
1632 var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
1634 // fallback for IE11 Script Access Denied error
1635 var tryGet = function (it, key) {
1638 } catch (error) { /* empty */ }
1641 // getting tag from ES6+ `Object.prototype.toString`
1642 var classof$4 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
1644 return it === undefined ? 'Undefined' : it === null ? 'Null'
1645 // @@toStringTag case
1646 : typeof (tag = tryGet(O = Object$1(it), TO_STRING_TAG)) == 'string' ? tag
1648 : CORRECT_ARGUMENTS ? classofRaw(O)
1649 // ES3 arguments fallback
1650 : (result = classofRaw(O)) == 'Object' && isCallable$1(O.callee) ? 'Arguments' : result;
1653 var global$6 = global$s;
1654 var classof$3 = classof$4;
1656 var String$1 = global$6.String;
1658 var toString$3 = function (argument) {
1659 if (classof$3(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
1660 return String$1(argument);
1663 var uncurryThis$3 = functionUncurryThis;
1665 var arraySlice$1 = uncurryThis$3([].slice);
1667 var arraySlice = arraySlice$1;
1669 var floor = Math.floor;
1671 var mergeSort = function (array, comparefn) {
1672 var length = array.length;
1673 var middle = floor(length / 2);
1674 return length < 8 ? insertionSort(array, comparefn) : merge$3(
1676 mergeSort(arraySlice(array, 0, middle), comparefn),
1677 mergeSort(arraySlice(array, middle), comparefn),
1682 var insertionSort = function (array, comparefn) {
1683 var length = array.length;
1687 while (i < length) {
1690 while (j && comparefn(array[j - 1], element) > 0) {
1691 array[j] = array[--j];
1693 if (j !== i++) array[j] = element;
1697 var merge$3 = function (array, left, right, comparefn) {
1698 var llength = left.length;
1699 var rlength = right.length;
1703 while (lindex < llength || rindex < rlength) {
1704 array[lindex + rindex] = (lindex < llength && rindex < rlength)
1705 ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
1706 : lindex < llength ? left[lindex++] : right[rindex++];
1710 var arraySort = mergeSort;
1712 var fails$2 = fails$8;
1714 var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
1715 var method = [][METHOD_NAME];
1716 return !!method && fails$2(function () {
1717 // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
1718 method.call(null, argument || function () { throw 1; }, 1);
1722 var userAgent$1 = engineUserAgent;
1724 var firefox = userAgent$1.match(/firefox\/(\d+)/i);
1726 var engineFfVersion = !!firefox && +firefox[1];
1728 var UA = engineUserAgent;
1730 var engineIsIeOrEdge = /MSIE|Trident/.test(UA);
1732 var userAgent = engineUserAgent;
1734 var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
1736 var engineWebkitVersion = !!webkit && +webkit[1];
1739 var uncurryThis$2 = functionUncurryThis;
1740 var aCallable$3 = aCallable$5;
1741 var toObject$2 = toObject$4;
1742 var lengthOfArrayLike$4 = lengthOfArrayLike$6;
1743 var toString$2 = toString$3;
1744 var fails$1 = fails$8;
1745 var internalSort = arraySort;
1746 var arrayMethodIsStrict = arrayMethodIsStrict$1;
1747 var FF = engineFfVersion;
1748 var IE_OR_EDGE = engineIsIeOrEdge;
1749 var V8 = engineV8Version;
1750 var WEBKIT = engineWebkitVersion;
1753 var un$Sort = uncurryThis$2(test.sort);
1754 var push$2 = uncurryThis$2(test.push);
1757 var FAILS_ON_UNDEFINED = fails$1(function () {
1758 test.sort(undefined);
1761 var FAILS_ON_NULL = fails$1(function () {
1765 var STRICT_METHOD = arrayMethodIsStrict('sort');
1767 var STABLE_SORT = !fails$1(function () {
1768 // feature detection can be too slow, so check engines versions
1769 if (V8) return V8 < 70;
1770 if (FF && FF > 3) return;
1771 if (IE_OR_EDGE) return true;
1772 if (WEBKIT) return WEBKIT < 603;
1775 var code, chr, value, index;
1777 // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
1778 for (code = 65; code < 76; code++) {
1779 chr = String.fromCharCode(code);
1782 case 66: case 69: case 70: case 72: value = 3; break;
1783 case 68: case 71: value = 4; break;
1787 for (index = 0; index < 47; index++) {
1788 test.push({ k: chr + index, v: value });
1792 test.sort(function (a, b) { return b.v - a.v; });
1794 for (index = 0; index < test.length; index++) {
1795 chr = test[index].k.charAt(0);
1796 if (result.charAt(result.length - 1) !== chr) result += chr;
1799 return result !== 'DGBEFHACIJK';
1802 var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
1804 var getSortCompare = function (comparefn) {
1805 return function (x, y) {
1806 if (y === undefined) return -1;
1807 if (x === undefined) return 1;
1808 if (comparefn !== undefined) return +comparefn(x, y) || 0;
1809 return toString$2(x) > toString$2(y) ? 1 : -1;
1813 // `Array.prototype.sort` method
1814 // https://tc39.es/ecma262/#sec-array.prototype.sort
1815 $$3({ target: 'Array', proto: true, forced: FORCED }, {
1816 sort: function sort(comparefn) {
1817 if (comparefn !== undefined) aCallable$3(comparefn);
1819 var array = toObject$2(this);
1821 if (STABLE_SORT) return comparefn === undefined ? un$Sort(array) : un$Sort(array, comparefn);
1824 var arrayLength = lengthOfArrayLike$4(array);
1825 var itemsLength, index;
1827 for (index = 0; index < arrayLength; index++) {
1828 if (index in array) push$2(items, array[index]);
1831 internalSort(items, getSortCompare(comparefn));
1833 itemsLength = items.length;
1836 while (index < itemsLength) array[index] = items[index++];
1837 while (index < arrayLength) delete array[index++];
1845 Object.defineProperty(json, "__esModule", {
1848 json.diffJson = diffJson;
1849 json.canonicalize = canonicalize;
1850 json.jsonDiff = void 0;
1851 /*istanbul ignore end*/
1854 /*istanbul ignore start*/
1855 _base$1 = _interopRequireDefault$3(base$1)
1856 /*istanbul ignore end*/
1860 /*istanbul ignore start*/
1862 /*istanbul ignore end*/
1864 /*istanbul ignore start*/
1866 function _interopRequireDefault$3(obj) {
1867 return obj && obj.__esModule ? obj : {
1872 function _typeof(obj) {
1873 "@babel/helpers - typeof";
1875 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
1876 _typeof = function _typeof(obj) {
1880 _typeof = function _typeof(obj) {
1881 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1885 return _typeof(obj);
1887 /*istanbul ignore end*/
1890 var objectPrototypeToString = Object.prototype.toString;
1892 /*istanbul ignore start*/
1894 /*istanbul ignore end*/
1896 /*istanbul ignore start*/
1898 /*istanbul ignore end*/
1899 ](); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
1900 // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
1902 /*istanbul ignore start*/
1904 json.jsonDiff = jsonDiff;
1905 /*istanbul ignore end*/
1907 jsonDiff.useLongestToken = true;
1909 /*istanbul ignore start*/
1911 /*istanbul ignore end*/
1913 /*istanbul ignore start*/
1915 /*istanbul ignore end*/
1918 jsonDiff.castInput = function (value) {
1919 /*istanbul ignore start*/
1921 /*istanbul ignore end*/
1923 undefinedReplacement = _this$options.undefinedReplacement,
1924 _this$options$stringi = _this$options.stringifyReplacer,
1925 stringifyReplacer = _this$options$stringi === void 0 ? function (k, v)
1926 /*istanbul ignore start*/
1929 /*istanbul ignore end*/
1930 typeof v === 'undefined' ? undefinedReplacement : v
1932 } : _this$options$stringi;
1933 return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
1936 jsonDiff.equals = function (left, right) {
1938 /*istanbul ignore start*/
1940 /*istanbul ignore end*/
1942 /*istanbul ignore start*/
1944 /*istanbul ignore end*/
1945 ].prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
1949 function diffJson(oldObj, newObj, options) {
1950 return jsonDiff.diff(oldObj, newObj, options);
1951 } // This function handles the presence of circular references by bailing out when encountering an
1952 // object that is already on the "stack" of items being processed. Accepts an optional replacer
1955 function canonicalize(obj, stack, replacementStack, replacer, key) {
1956 stack = stack || [];
1957 replacementStack = replacementStack || [];
1960 obj = replacer(key, obj);
1965 for (i = 0; i < stack.length; i += 1) {
1966 if (stack[i] === obj) {
1967 return replacementStack[i];
1971 var canonicalizedObj;
1973 if ('[object Array]' === objectPrototypeToString.call(obj)) {
1975 canonicalizedObj = new Array(obj.length);
1976 replacementStack.push(canonicalizedObj);
1978 for (i = 0; i < obj.length; i += 1) {
1979 canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
1983 replacementStack.pop();
1984 return canonicalizedObj;
1987 if (obj && obj.toJSON) {
1992 /*istanbul ignore start*/
1994 /*istanbul ignore end*/
1995 obj) === 'object' && obj !== null) {
1997 canonicalizedObj = {};
1998 replacementStack.push(canonicalizedObj);
2000 var sortedKeys = [],
2004 /* istanbul ignore else */
2005 if (obj.hasOwnProperty(_key)) {
2006 sortedKeys.push(_key);
2012 for (i = 0; i < sortedKeys.length; i += 1) {
2013 _key = sortedKeys[i];
2014 canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
2018 replacementStack.pop();
2020 canonicalizedObj = obj;
2023 return canonicalizedObj;
2028 /*istanbul ignore start*/
2030 Object.defineProperty(array$6, "__esModule", {
2033 array$6.diffArrays = diffArrays;
2034 array$6.arrayDiff = void 0;
2035 /*istanbul ignore end*/
2038 /*istanbul ignore start*/
2039 _base = _interopRequireDefault$2(base$1)
2040 /*istanbul ignore end*/
2042 /*istanbul ignore start*/
2045 function _interopRequireDefault$2(obj) {
2046 return obj && obj.__esModule ? obj : {
2050 /*istanbul ignore end*/
2054 /*istanbul ignore start*/
2056 /*istanbul ignore end*/
2058 /*istanbul ignore start*/
2060 /*istanbul ignore end*/
2062 /*istanbul ignore start*/
2064 array$6.arrayDiff = arrayDiff;
2065 /*istanbul ignore end*/
2067 arrayDiff.tokenize = function (value) {
2068 return value.slice();
2071 arrayDiff.join = arrayDiff.removeEmpty = function (value) {
2075 function diffArrays(oldArr, newArr, callback) {
2076 return arrayDiff.diff(oldArr, newArr, callback);
2083 /*istanbul ignore start*/
2085 Object.defineProperty(parse$e, "__esModule", {
2088 parse$e.parsePatch = parsePatch;
2089 /*istanbul ignore end*/
2091 function parsePatch(uniDiff) {
2092 /*istanbul ignore start*/
2094 /*istanbul ignore end*/
2095 options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2096 var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
2097 delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
2101 function parseIndex() {
2103 list.push(index); // Parse diff metadata
2105 while (i < diffstr.length) {
2106 var line = diffstr[i]; // File header found, end parsing diff metadata
2108 if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
2113 var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
2116 index.index = header[1];
2120 } // Parse file headers if they are defined. Unified diff requires them, but
2121 // there's no technical issues to have an isolated hunk without file header
2124 parseFileHeader(index);
2125 parseFileHeader(index); // Parse hunks
2129 while (i < diffstr.length) {
2130 var _line = diffstr[i];
2132 if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
2134 } else if (/^@@/.test(_line)) {
2135 index.hunks.push(parseHunk());
2136 } else if (_line && options.strict) {
2137 // Ignore unexpected content unless in strict mode
2138 throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
2143 } // Parses the --- and +++ headers, if none are found, no lines
2147 function parseFileHeader(index) {
2148 var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
2151 var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
2152 var data = fileHeader[2].split('\t', 2);
2153 var fileName = data[0].replace(/\\\\/g, '\\');
2155 if (/^".*"$/.test(fileName)) {
2156 fileName = fileName.substr(1, fileName.length - 2);
2159 index[keyPrefix + 'FileName'] = fileName;
2160 index[keyPrefix + 'Header'] = (data[1] || '').trim();
2164 // This assumes that we are at the start of a hunk.
2167 function parseHunk() {
2168 var chunkHeaderIndex = i,
2169 chunkHeaderLine = diffstr[i++],
2170 chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
2172 oldStart: +chunkHeader[1],
2173 oldLines: typeof chunkHeader[2] === 'undefined' ? 1 : +chunkHeader[2],
2174 newStart: +chunkHeader[3],
2175 newLines: typeof chunkHeader[4] === 'undefined' ? 1 : +chunkHeader[4],
2178 }; // Unified Diff Format quirk: If the chunk size is 0,
2179 // the first number is one lower than one would expect.
2180 // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
2182 if (hunk.oldLines === 0) {
2186 if (hunk.newLines === 0) {
2193 for (; i < diffstr.length; i++) {
2194 // Lines starting with '---' could be mistaken for the "remove line" operation
2195 // But they could be the header for the next file. Therefore prune such cases out.
2196 if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
2200 var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
2202 if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
2203 hunk.lines.push(diffstr[i]);
2204 hunk.linedelimiters.push(delimiters[i] || '\n');
2206 if (operation === '+') {
2208 } else if (operation === '-') {
2210 } else if (operation === ' ') {
2217 } // Handle the empty block count case
2220 if (!addCount && hunk.newLines === 1) {
2224 if (!removeCount && hunk.oldLines === 1) {
2226 } // Perform optional sanity checking
2229 if (options.strict) {
2230 if (addCount !== hunk.newLines) {
2231 throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
2234 if (removeCount !== hunk.oldLines) {
2235 throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
2242 while (i < diffstr.length) {
2249 var distanceIterator = {};
2251 /*istanbul ignore start*/
2253 (function (exports) {
2255 Object.defineProperty(exports, "__esModule", {
2258 exports["default"] = _default;
2259 /*istanbul ignore end*/
2260 // Iterator that traverses in the range of [min, max], stepping
2261 // by distance from a given start position. I.e. for [0, 4], with
2262 // start of 2, this will iterate 2, 3, 1, 4, 0.
2265 /*istanbul ignore start*/
2267 /*istanbul ignore end*/
2268 (start, minLine, maxLine) {
2269 var wantForward = true,
2270 backwardExhausted = false,
2271 forwardExhausted = false,
2273 return function iterator() {
2274 if (wantForward && !forwardExhausted) {
2275 if (backwardExhausted) {
2278 wantForward = false;
2279 } // Check if trying to fit beyond text length, and if not, check it fits
2280 // after offset location (or desired location on first iteration)
2283 if (start + localOffset <= maxLine) {
2287 forwardExhausted = true;
2290 if (!backwardExhausted) {
2291 if (!forwardExhausted) {
2293 } // Check if trying to fit before text beginning, and if not, check it fits
2294 // before offset location
2297 if (minLine <= start - localOffset) {
2298 return -localOffset++;
2301 backwardExhausted = true;
2303 } // We tried to fit hunk before text beginning and beyond text length, then
2304 // hunk can't fit on the text. Return undefined
2308 })(distanceIterator);
2310 /*istanbul ignore start*/
2312 Object.defineProperty(apply, "__esModule", {
2315 apply.applyPatch = applyPatch;
2316 apply.applyPatches = applyPatches;
2317 /*istanbul ignore end*/
2320 /*istanbul ignore start*/
2322 /*istanbul ignore end*/
2326 /*istanbul ignore start*/
2327 _distanceIterator = _interopRequireDefault$1(distanceIterator)
2328 /*istanbul ignore end*/
2330 /*istanbul ignore start*/
2333 function _interopRequireDefault$1(obj) {
2334 return obj && obj.__esModule ? obj : {
2338 /*istanbul ignore end*/
2341 function applyPatch(source, uniDiff) {
2342 /*istanbul ignore start*/
2344 /*istanbul ignore end*/
2345 options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2347 if (typeof uniDiff === 'string') {
2349 /*istanbul ignore start*/
2350 (/*istanbul ignore end*/
2352 /*istanbul ignore start*/
2354 /*istanbul ignore end*/
2356 /*istanbul ignore start*/
2358 /*istanbul ignore end*/
2362 if (Array.isArray(uniDiff)) {
2363 if (uniDiff.length > 1) {
2364 throw new Error('applyPatch only works with a single input.');
2367 uniDiff = uniDiff[0];
2368 } // Apply the diff to the input
2371 var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
2372 delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
2373 hunks = uniDiff.hunks,
2374 compareLine = options.compareLine || function (lineNumber, line, operation, patchContent)
2375 /*istanbul ignore start*/
2378 /*istanbul ignore end*/
2379 line === patchContent
2383 fuzzFactor = options.fuzzFactor || 0,
2389 * Checks if the hunk exactly fits on the provided location
2393 function hunkFits(hunk, toPos) {
2394 for (var j = 0; j < hunk.lines.length; j++) {
2395 var line = hunk.lines[j],
2396 operation = line.length > 0 ? line[0] : ' ',
2397 content = line.length > 0 ? line.substr(1) : line;
2399 if (operation === ' ' || operation === '-') {
2400 // Context sanity check
2401 if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
2404 if (errorCount > fuzzFactor) {
2414 } // Search best fit offsets for each hunk based on the previous ones
2417 for (var i = 0; i < hunks.length; i++) {
2418 var hunk = hunks[i],
2419 maxLine = lines.length - hunk.oldLines,
2421 toPos = offset + hunk.oldStart - 1;
2423 /*istanbul ignore start*/
2424 (/*istanbul ignore end*/
2426 /*istanbul ignore start*/
2427 0, _distanceIterator
2428 /*istanbul ignore end*/
2430 /*istanbul ignore start*/
2432 /*istanbul ignore end*/
2433 ])(toPos, minLine, maxLine);
2435 for (; localOffset !== undefined; localOffset = iterator()) {
2436 if (hunkFits(hunk, toPos + localOffset)) {
2437 hunk.offset = offset += localOffset;
2442 if (localOffset === undefined) {
2444 } // Set lower text limit to end of the current hunk, so next ones don't try
2445 // to fit over already patched text
2448 minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
2449 } // Apply patch hunks
2454 for (var _i = 0; _i < hunks.length; _i++) {
2455 var _hunk = hunks[_i],
2456 _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
2458 diffOffset += _hunk.newLines - _hunk.oldLines;
2460 for (var j = 0; j < _hunk.lines.length; j++) {
2461 var line = _hunk.lines[j],
2462 operation = line.length > 0 ? line[0] : ' ',
2463 content = line.length > 0 ? line.substr(1) : line,
2464 delimiter = _hunk.linedelimiters[j];
2466 if (operation === ' ') {
2468 } else if (operation === '-') {
2469 lines.splice(_toPos, 1);
2470 delimiters.splice(_toPos, 1);
2471 /* istanbul ignore else */
2472 } else if (operation === '+') {
2473 lines.splice(_toPos, 0, content);
2474 delimiters.splice(_toPos, 0, delimiter);
2476 } else if (operation === '\\') {
2477 var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
2479 if (previousOperation === '+') {
2481 } else if (previousOperation === '-') {
2486 } // Handle EOFNL insertion/removal
2490 while (!lines[lines.length - 1]) {
2494 } else if (addEOFNL) {
2496 delimiters.push('\n');
2499 for (var _k = 0; _k < lines.length - 1; _k++) {
2500 lines[_k] = lines[_k] + delimiters[_k];
2503 return lines.join('');
2504 } // Wrapper that supports multiple file patches via callbacks.
2507 function applyPatches(uniDiff, options) {
2508 if (typeof uniDiff === 'string') {
2510 /*istanbul ignore start*/
2511 (/*istanbul ignore end*/
2513 /*istanbul ignore start*/
2515 /*istanbul ignore end*/
2517 /*istanbul ignore start*/
2519 /*istanbul ignore end*/
2523 var currentIndex = 0;
2525 function processIndex() {
2526 var index = uniDiff[currentIndex++];
2529 return options.complete();
2532 options.loadFile(index, function (err, data) {
2534 return options.complete(err);
2537 var updatedContent = applyPatch(data, index, options);
2538 options.patched(index, updatedContent, function (err) {
2540 return options.complete(err);
2555 /*istanbul ignore start*/
2557 Object.defineProperty(create$1, "__esModule", {
2560 create$1.structuredPatch = structuredPatch;
2561 create$1.formatPatch = formatPatch;
2562 create$1.createTwoFilesPatch = createTwoFilesPatch;
2563 create$1.createPatch = createPatch;
2564 /*istanbul ignore end*/
2567 /*istanbul ignore start*/
2569 /*istanbul ignore end*/
2571 /*istanbul ignore start*/
2573 function _toConsumableArray$1(arr) {
2574 return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
2577 function _nonIterableSpread$1() {
2578 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2581 function _unsupportedIterableToArray$1(o, minLen) {
2583 if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
2584 var n = Object.prototype.toString.call(o).slice(8, -1);
2585 if (n === "Object" && o.constructor) n = o.constructor.name;
2586 if (n === "Map" || n === "Set") return Array.from(o);
2587 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
2590 function _iterableToArray$1(iter) {
2591 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
2594 function _arrayWithoutHoles$1(arr) {
2595 if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
2598 function _arrayLikeToArray$1(arr, len) {
2599 if (len == null || len > arr.length) len = arr.length;
2601 for (var i = 0, arr2 = new Array(len); i < len; i++) {
2607 /*istanbul ignore end*/
2610 function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
2615 if (typeof options.context === 'undefined') {
2616 options.context = 4;
2620 /*istanbul ignore start*/
2621 (/*istanbul ignore end*/
2623 /*istanbul ignore start*/
2625 /*istanbul ignore end*/
2627 /*istanbul ignore start*/
2629 /*istanbul ignore end*/
2630 )(oldStr, newStr, options);
2634 }); // Append an empty value to make cleanup easier
2636 function contextLines(lines) {
2637 return lines.map(function (entry) {
2643 var oldRangeStart = 0,
2648 /*istanbul ignore start*/
2650 var _loop = function _loop(
2651 /*istanbul ignore end*/
2653 var current = diff[i],
2654 lines = current.lines || current.value.replace(/\n$/, '').split('\n');
2655 current.lines = lines;
2657 if (current.added || current.removed) {
2658 /*istanbul ignore start*/
2660 /*istanbul ignore end*/
2661 // If we have previous context, start with that
2664 if (!oldRangeStart) {
2665 var prev = diff[i - 1];
2666 oldRangeStart = oldLine;
2667 newRangeStart = newLine;
2670 curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
2671 oldRangeStart -= curRange.length;
2672 newRangeStart -= curRange.length;
2674 } // Output our changes
2676 /*istanbul ignore start*/
2678 /*istanbul ignore end*/
2680 /*istanbul ignore start*/
2684 /*istanbul ignore end*/
2685 curRange).push.apply(
2686 /*istanbul ignore start*/
2688 /*istanbul ignore end*/
2690 /*istanbul ignore start*/
2691 _toConsumableArray$1(
2692 /*istanbul ignore end*/
2693 lines.map(function (entry) {
2694 return (current.added ? '+' : '-') + entry;
2695 }))); // Track the updated file position
2698 if (current.added) {
2699 newLine += lines.length;
2701 oldLine += lines.length;
2704 // Identical context lines. Track line changes
2705 if (oldRangeStart) {
2706 // Close out any changes that have been output (or join overlapping)
2707 if (lines.length <= options.context * 2 && i < diff.length - 2) {
2708 /*istanbul ignore start*/
2710 /*istanbul ignore end*/
2713 /*istanbul ignore start*/
2715 /*istanbul ignore end*/
2717 /*istanbul ignore start*/
2721 /*istanbul ignore end*/
2722 curRange).push.apply(
2723 /*istanbul ignore start*/
2725 /*istanbul ignore end*/
2727 /*istanbul ignore start*/
2728 _toConsumableArray$1(
2729 /*istanbul ignore end*/
2730 contextLines(lines)));
2732 /*istanbul ignore start*/
2734 /*istanbul ignore end*/
2735 // end the range and output
2738 var contextSize = Math.min(lines.length, options.context);
2739 /*istanbul ignore start*/
2741 /*istanbul ignore end*/
2743 /*istanbul ignore start*/
2746 /*istanbul ignore end*/
2747 curRange).push.apply(
2748 /*istanbul ignore start*/
2750 /*istanbul ignore end*/
2752 /*istanbul ignore start*/
2753 _toConsumableArray$1(
2754 /*istanbul ignore end*/
2755 contextLines(lines.slice(0, contextSize))));
2758 oldStart: oldRangeStart,
2759 oldLines: oldLine - oldRangeStart + contextSize,
2760 newStart: newRangeStart,
2761 newLines: newLine - newRangeStart + contextSize,
2765 if (i >= diff.length - 2 && lines.length <= options.context) {
2766 // EOF is inside this hunk
2767 var oldEOFNewline = /\n$/.test(oldStr);
2768 var newEOFNewline = /\n$/.test(newStr);
2769 var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
2771 if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) {
2772 // special case: old has no eol and no trailing context; no-nl can end up before adds
2773 // however, if the old file is empty, do not output the no-nl line
2774 curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
2777 if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
2778 curRange.push('\\ No newline at end of file');
2789 oldLine += lines.length;
2790 newLine += lines.length;
2794 for (var i = 0; i < diff.length; i++) {
2795 /*istanbul ignore start*/
2797 /*istanbul ignore end*/
2802 oldFileName: oldFileName,
2803 newFileName: newFileName,
2804 oldHeader: oldHeader,
2805 newHeader: newHeader,
2810 function formatPatch(diff) {
2813 if (diff.oldFileName == diff.newFileName) {
2814 ret.push('Index: ' + diff.oldFileName);
2817 ret.push('===================================================================');
2818 ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
2819 ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
2821 for (var i = 0; i < diff.hunks.length; i++) {
2822 var hunk = diff.hunks[i]; // Unified Diff Format quirk: If the chunk size is 0,
2823 // the first number is one lower than one would expect.
2824 // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
2826 if (hunk.oldLines === 0) {
2830 if (hunk.newLines === 0) {
2834 ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
2835 ret.push.apply(ret, hunk.lines);
2838 return ret.join('\n') + '\n';
2841 function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
2842 return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
2845 function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
2846 return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
2851 /*istanbul ignore start*/
2853 Object.defineProperty(array$5, "__esModule", {
2856 array$5.arrayEqual = arrayEqual;
2857 array$5.arrayStartsWith = arrayStartsWith;
2858 /*istanbul ignore end*/
2860 function arrayEqual(a, b) {
2861 if (a.length !== b.length) {
2865 return arrayStartsWith(a, b);
2868 function arrayStartsWith(array, start) {
2869 if (start.length > array.length) {
2873 for (var i = 0; i < start.length; i++) {
2874 if (start[i] !== array[i]) {
2882 /*istanbul ignore start*/
2884 Object.defineProperty(merge$2, "__esModule", {
2887 merge$2.calcLineCount = calcLineCount;
2888 merge$2.merge = merge$1;
2889 /*istanbul ignore end*/
2892 /*istanbul ignore start*/
2894 /*istanbul ignore end*/
2897 /*istanbul ignore start*/
2899 /*istanbul ignore end*/
2902 /*istanbul ignore start*/
2904 /*istanbul ignore end*/
2906 /*istanbul ignore start*/
2908 function _toConsumableArray(arr) {
2909 return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
2912 function _nonIterableSpread() {
2913 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2916 function _unsupportedIterableToArray(o, minLen) {
2918 if (typeof o === "string") return _arrayLikeToArray(o, minLen);
2919 var n = Object.prototype.toString.call(o).slice(8, -1);
2920 if (n === "Object" && o.constructor) n = o.constructor.name;
2921 if (n === "Map" || n === "Set") return Array.from(o);
2922 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
2925 function _iterableToArray(iter) {
2926 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
2929 function _arrayWithoutHoles(arr) {
2930 if (Array.isArray(arr)) return _arrayLikeToArray(arr);
2933 function _arrayLikeToArray(arr, len) {
2934 if (len == null || len > arr.length) len = arr.length;
2936 for (var i = 0, arr2 = new Array(len); i < len; i++) {
2942 /*istanbul ignore end*/
2945 function calcLineCount(hunk) {
2946 /*istanbul ignore start*/
2947 var _calcOldNewLineCount =
2948 /*istanbul ignore end*/
2949 calcOldNewLineCount(hunk.lines),
2950 oldLines = _calcOldNewLineCount.oldLines,
2951 newLines = _calcOldNewLineCount.newLines;
2953 if (oldLines !== undefined) {
2954 hunk.oldLines = oldLines;
2956 delete hunk.oldLines;
2959 if (newLines !== undefined) {
2960 hunk.newLines = newLines;
2962 delete hunk.newLines;
2966 function merge$1(mine, theirs, base) {
2967 mine = loadPatch(mine, base);
2968 theirs = loadPatch(theirs, base);
2969 var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning.
2970 // Leaving sanity checks on this to the API consumer that may know more about the
2971 // meaning in their own context.
2973 if (mine.index || theirs.index) {
2974 ret.index = mine.index || theirs.index;
2977 if (mine.newFileName || theirs.newFileName) {
2978 if (!fileNameChanged(mine)) {
2979 // No header or no change in ours, use theirs (and ours if theirs does not exist)
2980 ret.oldFileName = theirs.oldFileName || mine.oldFileName;
2981 ret.newFileName = theirs.newFileName || mine.newFileName;
2982 ret.oldHeader = theirs.oldHeader || mine.oldHeader;
2983 ret.newHeader = theirs.newHeader || mine.newHeader;
2984 } else if (!fileNameChanged(theirs)) {
2985 // No header or no change in theirs, use ours
2986 ret.oldFileName = mine.oldFileName;
2987 ret.newFileName = mine.newFileName;
2988 ret.oldHeader = mine.oldHeader;
2989 ret.newHeader = mine.newHeader;
2991 // Both changed... figure it out
2992 ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
2993 ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
2994 ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
2995 ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
3005 while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
3006 var mineCurrent = mine.hunks[mineIndex] || {
3009 theirsCurrent = theirs.hunks[theirsIndex] || {
3013 if (hunkBefore(mineCurrent, theirsCurrent)) {
3014 // This patch does not overlap with any of the others, yay.
3015 ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
3017 theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
3018 } else if (hunkBefore(theirsCurrent, mineCurrent)) {
3019 // This patch does not overlap with any of the others, yay.
3020 ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
3022 mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
3024 // Overlap, merge as best we can
3026 oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
3028 newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
3032 mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
3035 ret.hunks.push(mergedHunk);
3042 function loadPatch(param, base) {
3043 if (typeof param === 'string') {
3044 if (/^@@/m.test(param) || /^Index:/m.test(param)) {
3046 /*istanbul ignore start*/
3047 (/*istanbul ignore end*/
3049 /*istanbul ignore start*/
3051 /*istanbul ignore end*/
3053 /*istanbul ignore start*/
3055 /*istanbul ignore end*/
3061 throw new Error('Must provide a base reference or pass in a patch');
3065 /*istanbul ignore start*/
3066 (/*istanbul ignore end*/
3068 /*istanbul ignore start*/
3070 /*istanbul ignore end*/
3072 /*istanbul ignore start*/
3074 /*istanbul ignore end*/
3075 )(undefined, undefined, base, param)
3082 function fileNameChanged(patch) {
3083 return patch.newFileName && patch.newFileName !== patch.oldFileName;
3086 function selectField(index, mine, theirs) {
3087 if (mine === theirs) {
3090 index.conflict = true;
3098 function hunkBefore(test, check) {
3099 return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
3102 function cloneHunk(hunk, offset) {
3104 oldStart: hunk.oldStart,
3105 oldLines: hunk.oldLines,
3106 newStart: hunk.newStart + offset,
3107 newLines: hunk.newLines,
3112 function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
3113 // This will generally result in a conflicted hunk, but there are cases where the context
3114 // is the only overlap where we can successfully merge the content here.
3121 offset: theirOffset,
3124 }; // Handle any leading content
3126 insertLeading(hunk, mine, their);
3127 insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each.
3129 while (mine.index < mine.lines.length && their.index < their.lines.length) {
3130 var mineCurrent = mine.lines[mine.index],
3131 theirCurrent = their.lines[their.index];
3133 if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
3134 // Both modified ...
3135 mutualChange(hunk, mine, their);
3136 } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
3137 /*istanbul ignore start*/
3139 /*istanbul ignore end*/
3142 /*istanbul ignore start*/
3144 /*istanbul ignore end*/
3146 /*istanbul ignore start*/
3150 /*istanbul ignore end*/
3151 hunk.lines).push.apply(
3152 /*istanbul ignore start*/
3154 /*istanbul ignore end*/
3156 /*istanbul ignore start*/
3158 /*istanbul ignore end*/
3159 collectChange(mine)));
3160 } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
3161 /*istanbul ignore start*/
3163 /*istanbul ignore end*/
3166 /*istanbul ignore start*/
3168 /*istanbul ignore end*/
3170 /*istanbul ignore start*/
3174 /*istanbul ignore end*/
3175 hunk.lines).push.apply(
3176 /*istanbul ignore start*/
3178 /*istanbul ignore end*/
3180 /*istanbul ignore start*/
3182 /*istanbul ignore end*/
3183 collectChange(their)));
3184 } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
3185 // Mine removed or edited
3186 removal(hunk, mine, their);
3187 } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
3188 // Their removed or edited
3189 removal(hunk, their, mine, true);
3190 } else if (mineCurrent === theirCurrent) {
3192 hunk.lines.push(mineCurrent);
3197 conflict(hunk, collectChange(mine), collectChange(their));
3199 } // Now push anything that may be remaining
3202 insertTrailing(hunk, mine);
3203 insertTrailing(hunk, their);
3204 calcLineCount(hunk);
3207 function mutualChange(hunk, mine, their) {
3208 var myChanges = collectChange(mine),
3209 theirChanges = collectChange(their);
3211 if (allRemoves(myChanges) && allRemoves(theirChanges)) {
3212 // Special case for remove changes that are supersets of one another
3214 /*istanbul ignore start*/
3215 (/*istanbul ignore end*/
3217 /*istanbul ignore start*/
3219 /*istanbul ignore end*/
3221 /*istanbul ignore start*/
3223 /*istanbul ignore end*/
3224 )(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
3225 /*istanbul ignore start*/
3227 /*istanbul ignore end*/
3229 /*istanbul ignore start*/
3231 /*istanbul ignore end*/
3233 /*istanbul ignore start*/
3237 /*istanbul ignore end*/
3238 hunk.lines).push.apply(
3239 /*istanbul ignore start*/
3241 /*istanbul ignore end*/
3243 /*istanbul ignore start*/
3245 /*istanbul ignore end*/
3250 /*istanbul ignore start*/
3251 (/*istanbul ignore end*/
3253 /*istanbul ignore start*/
3255 /*istanbul ignore end*/
3257 /*istanbul ignore start*/
3259 /*istanbul ignore end*/
3260 )(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
3261 /*istanbul ignore start*/
3263 /*istanbul ignore end*/
3265 /*istanbul ignore start*/
3267 /*istanbul ignore end*/
3269 /*istanbul ignore start*/
3273 /*istanbul ignore end*/
3274 hunk.lines).push.apply(
3275 /*istanbul ignore start*/
3277 /*istanbul ignore end*/
3279 /*istanbul ignore start*/
3281 /*istanbul ignore end*/
3287 /*istanbul ignore start*/
3288 (/*istanbul ignore end*/
3290 /*istanbul ignore start*/
3292 /*istanbul ignore end*/
3294 /*istanbul ignore start*/
3296 /*istanbul ignore end*/
3297 )(myChanges, theirChanges)) {
3298 /*istanbul ignore start*/
3300 /*istanbul ignore end*/
3302 /*istanbul ignore start*/
3304 /*istanbul ignore end*/
3306 /*istanbul ignore start*/
3310 /*istanbul ignore end*/
3311 hunk.lines).push.apply(
3312 /*istanbul ignore start*/
3314 /*istanbul ignore end*/
3316 /*istanbul ignore start*/
3318 /*istanbul ignore end*/
3324 conflict(hunk, myChanges, theirChanges);
3327 function removal(hunk, mine, their, swap) {
3328 var myChanges = collectChange(mine),
3329 theirChanges = collectContext(their, myChanges);
3331 if (theirChanges.merged) {
3332 /*istanbul ignore start*/
3334 /*istanbul ignore end*/
3336 /*istanbul ignore start*/
3338 /*istanbul ignore end*/
3340 /*istanbul ignore start*/
3344 /*istanbul ignore end*/
3345 hunk.lines).push.apply(
3346 /*istanbul ignore start*/
3348 /*istanbul ignore end*/
3350 /*istanbul ignore start*/
3352 /*istanbul ignore end*/
3353 theirChanges.merged));
3355 conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
3359 function conflict(hunk, mine, their) {
3360 hunk.conflict = true;
3368 function insertLeading(hunk, insert, their) {
3369 while (insert.offset < their.offset && insert.index < insert.lines.length) {
3370 var line = insert.lines[insert.index++];
3371 hunk.lines.push(line);
3376 function insertTrailing(hunk, insert) {
3377 while (insert.index < insert.lines.length) {
3378 var line = insert.lines[insert.index++];
3379 hunk.lines.push(line);
3383 function collectChange(state) {
3385 operation = state.lines[state.index][0];
3387 while (state.index < state.lines.length) {
3388 var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
3390 if (operation === '-' && line[0] === '+') {
3394 if (operation === line[0]) {
3405 function collectContext(state, matchChanges) {
3409 contextChanges = false,
3412 while (matchIndex < matchChanges.length && state.index < state.lines.length) {
3413 var change = state.lines[state.index],
3414 match = matchChanges[matchIndex]; // Once we've hit our add, then we are done
3416 if (match[0] === '+') {
3420 contextChanges = contextChanges || change[0] !== ' ';
3422 matchIndex++; // Consume any additions in the other block as a conflict to attempt
3423 // to pull in the remaining context after this
3425 if (change[0] === '+') {
3428 while (change[0] === '+') {
3429 changes.push(change);
3430 change = state.lines[++state.index];
3434 if (match.substr(1) === change.substr(1)) {
3435 changes.push(change);
3442 if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
3450 while (matchIndex < matchChanges.length) {
3451 merged.push(matchChanges[matchIndex++]);
3460 function allRemoves(changes) {
3461 return changes.reduce(function (prev, change) {
3462 return prev && change[0] === '-';
3466 function skipRemoveSuperset(state, removeChanges, delta) {
3467 for (var i = 0; i < delta; i++) {
3468 var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
3470 if (state.lines[state.index + i] !== ' ' + changeContent) {
3475 state.index += delta;
3479 function calcOldNewLineCount(lines) {
3482 lines.forEach(function (line) {
3483 if (typeof line !== 'string') {
3484 var myCount = calcOldNewLineCount(line.mine);
3485 var theirCount = calcOldNewLineCount(line.theirs);
3487 if (oldLines !== undefined) {
3488 if (myCount.oldLines === theirCount.oldLines) {
3489 oldLines += myCount.oldLines;
3491 oldLines = undefined;
3495 if (newLines !== undefined) {
3496 if (myCount.newLines === theirCount.newLines) {
3497 newLines += myCount.newLines;
3499 newLines = undefined;
3503 if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
3507 if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
3520 /*istanbul ignore start*/
3522 Object.defineProperty(dmp, "__esModule", {
3525 dmp.convertChangesToDMP = convertChangesToDMP;
3526 /*istanbul ignore end*/
3527 // See: http://code.google.com/p/google-diff-match-patch/wiki/API
3529 function convertChangesToDMP(changes) {
3534 for (var i = 0; i < changes.length; i++) {
3535 change = changes[i];
3539 } else if (change.removed) {
3545 ret.push([operation, change.value]);
3553 /*istanbul ignore start*/
3555 Object.defineProperty(xml, "__esModule", {
3558 xml.convertChangesToXML = convertChangesToXML;
3559 /*istanbul ignore end*/
3561 function convertChangesToXML(changes) {
3564 for (var i = 0; i < changes.length; i++) {
3565 var change = changes[i];
3569 } else if (change.removed) {
3573 ret.push(escapeHTML(change.value));
3577 } else if (change.removed) {
3582 return ret.join('');
3585 function escapeHTML(s) {
3587 n = n.replace(/&/g, '&');
3588 n = n.replace(/</g, '<');
3589 n = n.replace(/>/g, '>');
3590 n = n.replace(/"/g, '"');
3594 /*istanbul ignore start*/
3596 (function (exports) {
3598 Object.defineProperty(exports, "__esModule", {
3601 Object.defineProperty(exports, "Diff", {
3603 get: function get() {
3604 return _base["default"];
3607 Object.defineProperty(exports, "diffChars", {
3609 get: function get() {
3610 return _character.diffChars;
3613 Object.defineProperty(exports, "diffWords", {
3615 get: function get() {
3616 return _word.diffWords;
3619 Object.defineProperty(exports, "diffWordsWithSpace", {
3621 get: function get() {
3622 return _word.diffWordsWithSpace;
3625 Object.defineProperty(exports, "diffLines", {
3627 get: function get() {
3628 return _line.diffLines;
3631 Object.defineProperty(exports, "diffTrimmedLines", {
3633 get: function get() {
3634 return _line.diffTrimmedLines;
3637 Object.defineProperty(exports, "diffSentences", {
3639 get: function get() {
3640 return _sentence.diffSentences;
3643 Object.defineProperty(exports, "diffCss", {
3645 get: function get() {
3646 return _css.diffCss;
3649 Object.defineProperty(exports, "diffJson", {
3651 get: function get() {
3652 return _json.diffJson;
3655 Object.defineProperty(exports, "canonicalize", {
3657 get: function get() {
3658 return _json.canonicalize;
3661 Object.defineProperty(exports, "diffArrays", {
3663 get: function get() {
3664 return _array.diffArrays;
3667 Object.defineProperty(exports, "applyPatch", {
3669 get: function get() {
3670 return _apply.applyPatch;
3673 Object.defineProperty(exports, "applyPatches", {
3675 get: function get() {
3676 return _apply.applyPatches;
3679 Object.defineProperty(exports, "parsePatch", {
3681 get: function get() {
3682 return _parse.parsePatch;
3685 Object.defineProperty(exports, "merge", {
3687 get: function get() {
3688 return _merge.merge;
3691 Object.defineProperty(exports, "structuredPatch", {
3693 get: function get() {
3694 return _create.structuredPatch;
3697 Object.defineProperty(exports, "createTwoFilesPatch", {
3699 get: function get() {
3700 return _create.createTwoFilesPatch;
3703 Object.defineProperty(exports, "createPatch", {
3705 get: function get() {
3706 return _create.createPatch;
3709 Object.defineProperty(exports, "convertChangesToDMP", {
3711 get: function get() {
3712 return _dmp.convertChangesToDMP;
3715 Object.defineProperty(exports, "convertChangesToXML", {
3717 get: function get() {
3718 return _xml.convertChangesToXML;
3721 /*istanbul ignore end*/
3724 /*istanbul ignore start*/
3725 _base = _interopRequireDefault(base$1)
3726 /*istanbul ignore end*/
3730 /*istanbul ignore start*/
3731 _character = character
3732 /*istanbul ignore end*/
3735 /*istanbul ignore start*/
3737 /*istanbul ignore end*/
3740 /*istanbul ignore start*/
3742 /*istanbul ignore end*/
3745 /*istanbul ignore start*/
3746 _sentence = sentence
3747 /*istanbul ignore end*/
3750 /*istanbul ignore start*/
3752 /*istanbul ignore end*/
3755 /*istanbul ignore start*/
3757 /*istanbul ignore end*/
3760 /*istanbul ignore start*/
3762 /*istanbul ignore end*/
3765 /*istanbul ignore start*/
3767 /*istanbul ignore end*/
3770 /*istanbul ignore start*/
3772 /*istanbul ignore end*/
3775 /*istanbul ignore start*/
3777 /*istanbul ignore end*/
3780 /*istanbul ignore start*/
3782 /*istanbul ignore end*/
3785 /*istanbul ignore start*/
3787 /*istanbul ignore end*/
3790 /*istanbul ignore start*/
3792 /*istanbul ignore end*/
3794 /*istanbul ignore start*/
3796 function _interopRequireDefault(obj) {
3797 return obj && obj.__esModule ? obj : {
3801 /*istanbul ignore end*/
3805 var require$$7$3 = require("./doc.js");
3807 var stringWidth$2 = {exports: {}};
3809 var ansiRegex$1 = ({
3812 const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
3813 return new RegExp(pattern, onlyFirst ? undefined : 'g');
3816 const ansiRegex = ansiRegex$1;
3818 var stripAnsi$1 = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
3820 var isFullwidthCodePoint$2 = {exports: {}};
3822 /* eslint-disable yoda */
3824 const isFullwidthCodePoint$1 = codePoint => {
3825 if (Number.isNaN(codePoint)) {
3827 } // Code points are derived from:
3828 // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
3831 if (codePoint >= 0x1100 && (codePoint <= 0x115F || // Hangul Jamo
3832 codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET
3833 codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET
3834 // CJK Radicals Supplement .. Enclosed CJK Letters and Months
3835 0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
3836 0x3250 <= codePoint && codePoint <= 0x4DBF || // CJK Unified Ideographs .. Yi Radicals
3837 0x4E00 <= codePoint && codePoint <= 0xA4C6 || // Hangul Jamo Extended-A
3838 0xA960 <= codePoint && codePoint <= 0xA97C || // Hangul Syllables
3839 0xAC00 <= codePoint && codePoint <= 0xD7A3 || // CJK Compatibility Ideographs
3840 0xF900 <= codePoint && codePoint <= 0xFAFF || // Vertical Forms
3841 0xFE10 <= codePoint && codePoint <= 0xFE19 || // CJK Compatibility Forms .. Small Form Variants
3842 0xFE30 <= codePoint && codePoint <= 0xFE6B || // Halfwidth and Fullwidth Forms
3843 0xFF01 <= codePoint && codePoint <= 0xFF60 || 0xFFE0 <= codePoint && codePoint <= 0xFFE6 || // Kana Supplement
3844 0x1B000 <= codePoint && codePoint <= 0x1B001 || // Enclosed Ideographic Supplement
3845 0x1F200 <= codePoint && codePoint <= 0x1F251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
3846 0x20000 <= codePoint && codePoint <= 0x3FFFD)) {
3853 isFullwidthCodePoint$2.exports = isFullwidthCodePoint$1;
3855 isFullwidthCodePoint$2.exports.default = isFullwidthCodePoint$1;
3857 var emojiRegex$1 = function () {
3858 // https://mths.be/emoji
3859 return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
3862 const stripAnsi = stripAnsi$1;
3863 const isFullwidthCodePoint = isFullwidthCodePoint$2.exports;
3864 const emojiRegex = emojiRegex$1;
3866 const stringWidth$1 = string => {
3867 if (typeof string !== 'string' || string.length === 0) {
3871 string = stripAnsi(string);
3873 if (string.length === 0) {
3877 string = string.replace(emojiRegex(), ' ');
3880 for (let i = 0; i < string.length; i++) {
3881 const code = string.codePointAt(i); // Ignore control characters
3883 if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
3885 } // Ignore combining characters
3888 if (code >= 0x300 && code <= 0x36F) {
3893 if (code > 0xFFFF) {
3897 width += isFullwidthCodePoint(code) ? 2 : 1;
3903 stringWidth$2.exports = stringWidth$1; // TODO: remove this in the next major version
3905 stringWidth$2.exports.default = stringWidth$1;
3907 var escapeStringRegexp$3 = string => {
3908 if (typeof string !== 'string') {
3909 throw new TypeError('Expected a string');
3910 } // Escape characters with special meaning either inside or outside character sets.
3911 // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
3914 return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
3917 const getLast$p = arr => arr[arr.length - 1];
3919 var getLast_1 = getLast$p;
3921 function _objectWithoutPropertiesLoose(source, excluded) {
3922 if (source == null) return {};
3924 var sourceKeys = Object.keys(source);
3927 for (i = 0; i < sourceKeys.length; i++) {
3928 key = sourceKeys[i];
3929 if (excluded.indexOf(key) >= 0) continue;
3930 target[key] = source[key];
3936 function _objectWithoutProperties(source, excluded) {
3937 if (source == null) return {};
3939 var target = _objectWithoutPropertiesLoose(source, excluded);
3943 if (Object.getOwnPropertySymbols) {
3944 var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
3946 for (i = 0; i < sourceSymbolKeys.length; i++) {
3947 key = sourceSymbolKeys[i];
3948 if (excluded.indexOf(key) >= 0) continue;
3949 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
3950 target[key] = source[key];
3957 var classof$2 = classofRaw$1;
3959 // `IsArray` abstract operation
3960 // https://tc39.es/ecma262/#sec-isarray
3961 // eslint-disable-next-line es/no-array-isarray -- safe
3962 var isArray$e = Array.isArray || function isArray(argument) {
3963 return classof$2(argument) == 'Array';
3966 var uncurryThis$1 = functionUncurryThis;
3967 var aCallable$2 = aCallable$5;
3969 var bind$3 = uncurryThis$1(uncurryThis$1.bind);
3971 // optional / simple context binding
3972 var functionBindContext = function (fn, that) {
3974 return that === undefined ? fn : bind$3 ? bind$3(fn, that) : function (/* ...args */) {
3975 return fn.apply(that, arguments);
3979 var global$5 = global$s;
3980 var isArray$d = isArray$e;
3981 var lengthOfArrayLike$3 = lengthOfArrayLike$6;
3982 var bind$2 = functionBindContext;
3984 var TypeError$3 = global$5.TypeError;
3986 // `FlattenIntoArray` abstract operation
3987 // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
3988 var flattenIntoArray$2 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
3989 var targetIndex = start;
3990 var sourceIndex = 0;
3991 var mapFn = mapper ? bind$2(mapper, thisArg) : false;
3992 var element, elementLen;
3994 while (sourceIndex < sourceLen) {
3995 if (sourceIndex in source) {
3996 element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
3998 if (depth > 0 && isArray$d(element)) {
3999 elementLen = lengthOfArrayLike$3(element);
4000 targetIndex = flattenIntoArray$2(target, original, element, elementLen, targetIndex, depth - 1) - 1;
4002 if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError$3('Exceed the acceptable array length');
4003 target[targetIndex] = element;
4013 var flattenIntoArray_1 = flattenIntoArray$2;
4015 var uncurryThis = functionUncurryThis;
4016 var fails = fails$8;
4017 var isCallable = isCallable$b;
4018 var classof$1 = classof$4;
4019 var getBuiltIn$1 = getBuiltIn$5;
4020 var inspectSource = inspectSource$3;
4022 var noop$3 = function () { /* empty */ };
4024 var construct = getBuiltIn$1('Reflect', 'construct');
4025 var constructorRegExp = /^\s*(?:class|function)\b/;
4026 var exec = uncurryThis(constructorRegExp.exec);
4027 var INCORRECT_TO_STRING = !constructorRegExp.exec(noop$3);
4029 var isConstructorModern = function (argument) {
4030 if (!isCallable(argument)) return false;
4032 construct(noop$3, empty, argument);
4039 var isConstructorLegacy = function (argument) {
4040 if (!isCallable(argument)) return false;
4041 switch (classof$1(argument)) {
4042 case 'AsyncFunction':
4043 case 'GeneratorFunction':
4044 case 'AsyncGeneratorFunction': return false;
4045 // we can't check .prototype since constructors produced by .bind haven't it
4046 } return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
4049 // `IsConstructor` abstract operation
4050 // https://tc39.es/ecma262/#sec-isconstructor
4051 var isConstructor$1 = !construct || fails(function () {
4053 return isConstructorModern(isConstructorModern.call)
4054 || !isConstructorModern(Object)
4055 || !isConstructorModern(function () { called = true; })
4057 }) ? isConstructorLegacy : isConstructorModern;
4059 var global$4 = global$s;
4060 var isArray$c = isArray$e;
4061 var isConstructor = isConstructor$1;
4062 var isObject$6 = isObject$c;
4063 var wellKnownSymbol$3 = wellKnownSymbol$7;
4065 var SPECIES = wellKnownSymbol$3('species');
4066 var Array$1 = global$4.Array;
4068 // a part of `ArraySpeciesCreate` abstract operation
4069 // https://tc39.es/ecma262/#sec-arrayspeciescreate
4070 var arraySpeciesConstructor$1 = function (originalArray) {
4072 if (isArray$c(originalArray)) {
4073 C = originalArray.constructor;
4074 // cross-realm fallback
4075 if (isConstructor(C) && (C === Array$1 || isArray$c(C.prototype))) C = undefined;
4076 else if (isObject$6(C)) {
4078 if (C === null) C = undefined;
4080 } return C === undefined ? Array$1 : C;
4083 var arraySpeciesConstructor = arraySpeciesConstructor$1;
4085 // `ArraySpeciesCreate` abstract operation
4086 // https://tc39.es/ecma262/#sec-arrayspeciescreate
4087 var arraySpeciesCreate$2 = function (originalArray, length) {
4088 return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
4092 var flattenIntoArray$1 = flattenIntoArray_1;
4093 var aCallable$1 = aCallable$5;
4094 var toObject$1 = toObject$4;
4095 var lengthOfArrayLike$2 = lengthOfArrayLike$6;
4096 var arraySpeciesCreate$1 = arraySpeciesCreate$2;
4098 // `Array.prototype.flatMap` method
4099 // https://tc39.es/ecma262/#sec-array.prototype.flatmap
4100 $$2({ target: 'Array', proto: true }, {
4101 flatMap: function flatMap(callbackfn /* , thisArg */) {
4102 var O = toObject$1(this);
4103 var sourceLen = lengthOfArrayLike$2(O);
4105 aCallable$1(callbackfn);
4106 A = arraySpeciesCreate$1(O, 0);
4107 A.length = flattenIntoArray$1(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
4114 var wellKnownSymbol$2 = wellKnownSymbol$7;
4115 var Iterators$1 = iterators;
4117 var ITERATOR$1 = wellKnownSymbol$2('iterator');
4118 var ArrayPrototype$1 = Array.prototype;
4120 // check on default Array iterator
4121 var isArrayIteratorMethod$1 = function (it) {
4122 return it !== undefined && (Iterators$1.Array === it || ArrayPrototype$1[ITERATOR$1] === it);
4125 var classof = classof$4;
4126 var getMethod$1 = getMethod$3;
4127 var Iterators = iterators;
4128 var wellKnownSymbol$1 = wellKnownSymbol$7;
4130 var ITERATOR = wellKnownSymbol$1('iterator');
4132 var getIteratorMethod$2 = function (it) {
4133 if (it != undefined) return getMethod$1(it, ITERATOR)
4134 || getMethod$1(it, '@@iterator')
4135 || Iterators[classof(it)];
4138 var global$3 = global$s;
4139 var call$2 = functionCall;
4140 var aCallable = aCallable$5;
4141 var anObject$4 = anObject$7;
4142 var tryToString$1 = tryToString$3;
4143 var getIteratorMethod$1 = getIteratorMethod$2;
4145 var TypeError$2 = global$3.TypeError;
4147 var getIterator$1 = function (argument, usingIterator) {
4148 var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
4149 if (aCallable(iteratorMethod)) return anObject$4(call$2(iteratorMethod, argument));
4150 throw TypeError$2(tryToString$1(argument) + ' is not iterable');
4153 var call$1 = functionCall;
4154 var anObject$3 = anObject$7;
4155 var getMethod = getMethod$3;
4157 var iteratorClose$1 = function (iterator, kind, value) {
4158 var innerResult, innerError;
4159 anObject$3(iterator);
4161 innerResult = getMethod(iterator, 'return');
4163 if (kind === 'throw') throw value;
4166 innerResult = call$1(innerResult, iterator);
4169 innerResult = error;
4171 if (kind === 'throw') throw value;
4172 if (innerError) throw innerResult;
4173 anObject$3(innerResult);
4177 var global$2 = global$s;
4178 var bind$1 = functionBindContext;
4179 var call = functionCall;
4180 var anObject$2 = anObject$7;
4181 var tryToString = tryToString$3;
4182 var isArrayIteratorMethod = isArrayIteratorMethod$1;
4183 var lengthOfArrayLike$1 = lengthOfArrayLike$6;
4184 var isPrototypeOf = objectIsPrototypeOf;
4185 var getIterator = getIterator$1;
4186 var getIteratorMethod = getIteratorMethod$2;
4187 var iteratorClose = iteratorClose$1;
4189 var TypeError$1 = global$2.TypeError;
4191 var Result = function (stopped, result) {
4192 this.stopped = stopped;
4193 this.result = result;
4196 var ResultPrototype = Result.prototype;
4198 var iterate$1 = function (iterable, unboundFunction, options) {
4199 var that = options && options.that;
4200 var AS_ENTRIES = !!(options && options.AS_ENTRIES);
4201 var IS_ITERATOR = !!(options && options.IS_ITERATOR);
4202 var INTERRUPTED = !!(options && options.INTERRUPTED);
4203 var fn = bind$1(unboundFunction, that);
4204 var iterator, iterFn, index, length, result, next, step;
4206 var stop = function (condition) {
4207 if (iterator) iteratorClose(iterator, 'normal', condition);
4208 return new Result(true, condition);
4211 var callFn = function (value) {
4214 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
4215 } return INTERRUPTED ? fn(value, stop) : fn(value);
4219 iterator = iterable;
4221 iterFn = getIteratorMethod(iterable);
4222 if (!iterFn) throw TypeError$1(tryToString(iterable) + ' is not iterable');
4223 // optimisation for array iterators
4224 if (isArrayIteratorMethod(iterFn)) {
4225 for (index = 0, length = lengthOfArrayLike$1(iterable); length > index; index++) {
4226 result = callFn(iterable[index]);
4227 if (result && isPrototypeOf(ResultPrototype, result)) return result;
4228 } return new Result(false);
4230 iterator = getIterator(iterable, iterFn);
4233 next = iterator.next;
4234 while (!(step = call(next, iterator)).done) {
4236 result = callFn(step.value);
4238 iteratorClose(iterator, 'throw', error);
4240 if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
4241 } return new Result(false);
4244 var toPropertyKey = toPropertyKey$3;
4245 var definePropertyModule$2 = objectDefineProperty;
4246 var createPropertyDescriptor = createPropertyDescriptor$3;
4248 var createProperty$1 = function (object, key, value) {
4249 var propertyKey = toPropertyKey(key);
4250 if (propertyKey in object) definePropertyModule$2.f(object, propertyKey, createPropertyDescriptor(0, value));
4251 else object[propertyKey] = value;
4255 var iterate = iterate$1;
4256 var createProperty = createProperty$1;
4258 // `Object.fromEntries` method
4259 // https://github.com/tc39/proposal-object-from-entries
4260 $$1({ target: 'Object', stat: true }, {
4261 fromEntries: function fromEntries(iterable) {
4263 iterate(iterable, function (k, v) {
4264 createProperty(obj, k, v);
4265 }, { AS_ENTRIES: true });
4270 const debug$1 = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
4271 var debug_1 = debug$1;
4273 // Not necessarily the package version of this code.
4275 const SEMVER_SPEC_VERSION = '2.0.0';
4276 const MAX_LENGTH$3 = 256;
4277 const MAX_SAFE_INTEGER$3 = Number.MAX_SAFE_INTEGER ||
4278 /* istanbul ignore next */
4279 9007199254740991; // Max safe segment length for coercion.
4281 const MAX_SAFE_COMPONENT_LENGTH = 16;
4283 SEMVER_SPEC_VERSION,
4284 MAX_LENGTH: MAX_LENGTH$3,
4285 MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$3,
4286 MAX_SAFE_COMPONENT_LENGTH
4289 var re$1 = {exports: {}};
4291 (function (module, exports) {
4293 MAX_SAFE_COMPONENT_LENGTH
4295 const debug = debug_1;
4296 exports = module.exports = {}; // The actual regexps go on exports.re
4298 const re = exports.re = [];
4299 const src = exports.src = [];
4300 const t = exports.t = {};
4303 const createToken = (name, value, isGlobal) => {
4305 debug(index, value);
4308 re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
4309 }; // The following Regular Expressions can be used for tokenizing,
4310 // validating, and parsing SemVer version strings.
4311 // ## Numeric Identifier
4312 // A single `0`, or a non-zero digit followed by zero or more digits.
4315 createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
4316 createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); // ## Non-numeric Identifier
4317 // Zero or more digits, followed by a letter or hyphen, and then zero or
4318 // more letters, digits, or hyphens.
4320 createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); // ## Main Version
4321 // Three dot-separated numeric identifiers.
4323 createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`);
4324 createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`); // ## Pre-release Version Identifier
4325 // A numeric identifier, or a non-numeric identifier.
4327 createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`);
4328 createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`); // ## Pre-release Version
4329 // Hyphen, followed by one or more dot-separated pre-release version
4332 createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
4333 createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); // ## Build Metadata Identifier
4334 // Any combination of digits, letters, or hyphens.
4336 createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); // ## Build Metadata
4337 // Plus sign, followed by one or more period-separated build metadata
4340 createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); // ## Full Version String
4341 // A main version, followed optionally by a pre-release version and
4343 // Note that the only major, minor, patch, and pre-release sections of
4344 // the version string are capturing groups. The build metadata is not a
4345 // capturing group, because it should not ever be used in version
4348 createToken('FULLPLAIN', `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
4349 createToken('FULL', `^${src[t.FULLPLAIN]}$`); // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
4350 // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
4351 // common in the npm registry.
4353 createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
4354 createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
4355 createToken('GTLT', '((?:<|>)?=?)'); // Something like "2.*" or "1.2.x".
4356 // Note that "x.x" is a valid xRange identifer, meaning "any version"
4357 // Only the first item is strictly required.
4359 createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
4360 createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
4361 createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`);
4362 createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
4363 createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
4364 createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); // Coercion.
4365 // Extract anything that could conceivably be a part of a valid semver
4367 createToken('COERCE', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:$|[^\\d])`);
4368 createToken('COERCERTL', src[t.COERCE], true); // Tilde ranges.
4369 // Meaning is "reasonably at or greater than"
4371 createToken('LONETILDE', '(?:~>?)');
4372 createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
4373 exports.tildeTrimReplace = '$1~';
4374 createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
4375 createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); // Caret ranges.
4376 // Meaning is "at least and backwards compatible with"
4378 createToken('LONECARET', '(?:\\^)');
4379 createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
4380 exports.caretTrimReplace = '$1^';
4381 createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
4382 createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); // A simple gt/lt/eq thing, or just "" to indicate "any version"
4384 createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
4385 createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); // An expression to strip any whitespace between the gtlt and the thing
4386 // it modifies, so that `> 1.2.3` ==> `>1.2.3`
4388 createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
4389 exports.comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
4390 // Note that these all use the loose form, because they'll be
4391 // checked against either the strict or loose comparator form
4394 createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`);
4395 createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`); // Star ranges basically just allow anything at all.
4397 createToken('STAR', '(<|>)?=?\\s*\\*'); // >=0.0.0 is like a star
4399 createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
4400 createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
4401 })(re$1, re$1.exports);
4403 // obj with keys in a consistent order.
4405 const opts$1 = ['includePrerelease', 'loose', 'rtl'];
4407 const parseOptions$1 = options => !options ? {} : typeof options !== 'object' ? {
4409 } : opts$1.filter(k => options[k]).reduce((options, k) => {
4414 var parseOptions_1 = parseOptions$1;
4416 const numeric$1 = /^[0-9]+$/;
4418 const compareIdentifiers$1 = (a, b) => {
4419 const anum = numeric$1.test(a);
4420 const bnum = numeric$1.test(b);
4427 return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
4430 const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
4433 compareIdentifiers: compareIdentifiers$1,
4437 const debug = debug_1;
4439 MAX_LENGTH: MAX_LENGTH$2,
4440 MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$2
4446 const parseOptions = parseOptions_1;
4452 constructor(version, options) {
4453 options = parseOptions(options);
4455 if (version instanceof SemVer$1) {
4456 if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
4459 version = version.version;
4461 } else if (typeof version !== 'string') {
4462 throw new TypeError(`Invalid Version: ${version}`);
4465 if (version.length > MAX_LENGTH$2) {
4466 throw new TypeError(`version is longer than ${MAX_LENGTH$2} characters`);
4469 debug('SemVer', version, options);
4470 this.options = options;
4471 this.loose = !!options.loose; // this isn't actually relevant for versions, but keep it so that we
4472 // don't run into trouble passing this.options around.
4474 this.includePrerelease = !!options.includePrerelease;
4475 const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
4478 throw new TypeError(`Invalid Version: ${version}`);
4481 this.raw = version; // these are actually numbers
4487 if (this.major > MAX_SAFE_INTEGER$2 || this.major < 0) {
4488 throw new TypeError('Invalid major version');
4491 if (this.minor > MAX_SAFE_INTEGER$2 || this.minor < 0) {
4492 throw new TypeError('Invalid minor version');
4495 if (this.patch > MAX_SAFE_INTEGER$2 || this.patch < 0) {
4496 throw new TypeError('Invalid patch version');
4497 } // numberify any prerelease numeric ids
4501 this.prerelease = [];
4503 this.prerelease = m[4].split('.').map(id => {
4504 if (/^[0-9]+$/.test(id)) {
4507 if (num >= 0 && num < MAX_SAFE_INTEGER$2) {
4516 this.build = m[5] ? m[5].split('.') : [];
4521 this.version = `${this.major}.${this.minor}.${this.patch}`;
4523 if (this.prerelease.length) {
4524 this.version += `-${this.prerelease.join('.')}`;
4527 return this.version;
4531 return this.version;
4535 debug('SemVer.compare', this.version, this.options, other);
4537 if (!(other instanceof SemVer$1)) {
4538 if (typeof other === 'string' && other === this.version) {
4542 other = new SemVer$1(other, this.options);
4545 if (other.version === this.version) {
4549 return this.compareMain(other) || this.comparePre(other);
4552 compareMain(other) {
4553 if (!(other instanceof SemVer$1)) {
4554 other = new SemVer$1(other, this.options);
4557 return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
4561 if (!(other instanceof SemVer$1)) {
4562 other = new SemVer$1(other, this.options);
4563 } // NOT having a prerelease is > having one
4566 if (this.prerelease.length && !other.prerelease.length) {
4568 } else if (!this.prerelease.length && other.prerelease.length) {
4570 } else if (!this.prerelease.length && !other.prerelease.length) {
4577 const a = this.prerelease[i];
4578 const b = other.prerelease[i];
4579 debug('prerelease compare', i, a, b);
4581 if (a === undefined && b === undefined) {
4583 } else if (b === undefined) {
4585 } else if (a === undefined) {
4587 } else if (a === b) {
4590 return compareIdentifiers(a, b);
4595 compareBuild(other) {
4596 if (!(other instanceof SemVer$1)) {
4597 other = new SemVer$1(other, this.options);
4603 const a = this.build[i];
4604 const b = other.build[i];
4605 debug('prerelease compare', i, a, b);
4607 if (a === undefined && b === undefined) {
4609 } else if (b === undefined) {
4611 } else if (a === undefined) {
4613 } else if (a === b) {
4616 return compareIdentifiers(a, b);
4619 } // preminor will bump the version up to the next minor release, and immediately
4620 // down to pre-release. premajor and prepatch work the same way.
4623 inc(release, identifier) {
4626 this.prerelease.length = 0;
4630 this.inc('pre', identifier);
4634 this.prerelease.length = 0;
4637 this.inc('pre', identifier);
4641 // If this is already a prerelease, it will bump to the next version
4642 // drop any prereleases that might already exist, since they are not
4643 // relevant at this point.
4644 this.prerelease.length = 0;
4645 this.inc('patch', identifier);
4646 this.inc('pre', identifier);
4648 // If the input is a non-prerelease version, this acts the same as
4652 if (this.prerelease.length === 0) {
4653 this.inc('patch', identifier);
4656 this.inc('pre', identifier);
4660 // If this is a pre-major version, bump up to the same major version.
4661 // Otherwise increment major.
4662 // 1.0.0-5 bumps to 1.0.0
4663 // 1.1.0 bumps to 2.0.0
4664 if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
4670 this.prerelease = [];
4674 // If this is a pre-minor version, bump up to the same minor version.
4675 // Otherwise increment minor.
4676 // 1.2.0-5 bumps to 1.2.0
4677 // 1.2.1 bumps to 1.3.0
4678 if (this.patch !== 0 || this.prerelease.length === 0) {
4683 this.prerelease = [];
4687 // If this is not a pre-release version, it will increment the patch.
4688 // If it is a pre-release it will bump up to the same patch version.
4689 // 1.2.0-5 patches to 1.2.0
4690 // 1.2.0 patches to 1.2.1
4691 if (this.prerelease.length === 0) {
4695 this.prerelease = [];
4697 // This probably shouldn't be used publicly.
4698 // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
4701 if (this.prerelease.length === 0) {
4702 this.prerelease = [0];
4704 let i = this.prerelease.length;
4707 if (typeof this.prerelease[i] === 'number') {
4708 this.prerelease[i]++;
4714 // didn't increment anything
4715 this.prerelease.push(0);
4720 // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
4721 // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
4722 if (this.prerelease[0] === identifier) {
4723 if (isNaN(this.prerelease[1])) {
4724 this.prerelease = [identifier, 0];
4727 this.prerelease = [identifier, 0];
4734 throw new Error(`invalid increment argument: ${release}`);
4738 this.raw = this.version;
4744 var semver$3 = SemVer$1;
4746 const SemVer = semver$3;
4748 const compare$3 = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
4750 var compare_1 = compare$3;
4752 const compare$2 = compare_1;
4754 const lt = (a, b, loose) => compare$2(a, b, loose) < 0;
4758 const compare$1 = compare_1;
4760 const gte$1 = (a, b, loose) => compare$1(a, b, loose) >= 0;
4764 var arrayify$1 = (object, keyName) => Object.entries(object).map(([key, value]) => Object.assign({
4768 var lib$5 = {exports: {}};
4770 (function (module, exports) {
4772 Object.defineProperty(exports, "__esModule", {
4775 exports.outdent = void 0; // In the absence of a WeakSet or WeakMap implementation, don't break, but don't cache either.
4780 for (var _i = 0; _i < arguments.length; _i++) {
4781 args[_i] = arguments[_i];
4785 function createWeakMap() {
4786 if (typeof WeakMap !== "undefined") {
4787 return new WeakMap();
4789 return fakeSetOrMap();
4793 * Creates and returns a no-op implementation of a WeakMap / WeakSet that never stores anything.
4797 function fakeSetOrMap() {
4807 } // Safe hasOwnProperty
4810 var hop = Object.prototype.hasOwnProperty;
4812 var has = function (obj, prop) {
4813 return hop.call(obj, prop);
4814 }; // Copy all own enumerable properties from source to target
4817 function extend(target, source) {
4818 for (var prop in source) {
4819 if (has(source, prop)) {
4820 target[prop] = source[prop];
4827 var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
4828 var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
4829 var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
4830 var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
4831 var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
4833 function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
4834 // If first interpolated value is a reference to outdent,
4835 // determine indentation level from the indentation of the interpolated value.
4836 var indentationLevel = 0;
4837 var match = strings[0].match(reDetectIndentation);
4840 indentationLevel = match[1].length;
4843 var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
4844 var reMatchIndent = new RegExp(reSource, "g");
4846 if (firstInterpolatedValueSetsIndentationLevel) {
4847 strings = strings.slice(1);
4850 var newline = options.newline,
4851 trimLeadingNewline = options.trimLeadingNewline,
4852 trimTrailingNewline = options.trimTrailingNewline;
4853 var normalizeNewlines = typeof newline === "string";
4854 var l = strings.length;
4855 var outdentedStrings = strings.map(function (v, i) {
4856 // Remove leading indentation from all lines
4857 v = v.replace(reMatchIndent, "$1"); // Trim a leading newline from the first string
4859 if (i === 0 && trimLeadingNewline) {
4860 v = v.replace(reLeadingNewline, "");
4861 } // Trim a trailing newline from the last string
4864 if (i === l - 1 && trimTrailingNewline) {
4865 v = v.replace(reTrailingNewline, "");
4866 } // Normalize newlines
4869 if (normalizeNewlines) {
4870 v = v.replace(/\r\n|\n|\r/g, function (_) {
4877 return outdentedStrings;
4880 function concatStringsAndValues(strings, values) {
4883 for (var i = 0, l = strings.length; i < l; i++) {
4894 function isTemplateStringsArray(v) {
4895 return has(v, "raw") && has(v, "length");
4898 * It is assumed that opts will not change. If this is a problem, clone your options object and pass the clone to
4905 function createInstance(options) {
4906 /** Cache of pre-processed template literal arrays */
4907 var arrayAutoIndentCache = createWeakMap();
4909 * Cache of pre-processed template literal arrays, where first interpolated value is a reference to outdent,
4910 * before interpolated values are injected.
4913 var arrayFirstInterpSetsIndentCache = createWeakMap();
4915 function outdent(stringsOrOptions) {
4918 for (var _i = 1; _i < arguments.length; _i++) {
4919 values[_i - 1] = arguments[_i];
4921 /* tslint:enable:no-shadowed-variable */
4924 if (isTemplateStringsArray(stringsOrOptions)) {
4925 var strings = stringsOrOptions; // Is first interpolated value a reference to outdent, alone on its own line, without any preceding non-whitespace?
4927 var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]); // Perform outdentation
4929 var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
4930 var renderedArray = cache.get(strings);
4932 if (!renderedArray) {
4933 renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
4934 cache.set(strings, renderedArray);
4936 /** If no interpolated values, skip concatenation step */
4939 if (values.length === 0) {
4940 return renderedArray[0];
4942 /** Concatenate string literals with interpolated values */
4945 var rendered = concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
4948 // Create and return a new instance of outdent with the given options
4949 return createInstance(extend(extend({}, options), stringsOrOptions || {}));
4953 var fullOutdent = extend(outdent, {
4954 string: function (str) {
4955 return _outdentArray([str], false, options)[0];
4961 var defaultOutdent = createInstance({
4962 trimLeadingNewline: true,
4963 trimTrailingNewline: true
4965 exports.outdent = defaultOutdent; // Named exports. Simple and preferred.
4966 // import outdent from 'outdent';
4968 exports.default = defaultOutdent;
4971 // In webpack harmony-modules environments, module.exports is read-only,
4972 // so we fail gracefully.
4974 module.exports = defaultOutdent;
4975 Object.defineProperty(defaultOutdent, "__esModule", {
4978 defaultOutdent.default = defaultOutdent;
4979 defaultOutdent.outdent = defaultOutdent;
4982 })(lib$5, lib$5.exports);
4987 const CATEGORY_CONFIG = "Config";
4988 const CATEGORY_EDITOR = "Editor";
4989 const CATEGORY_FORMAT = "Format";
4990 const CATEGORY_OTHER = "Other";
4991 const CATEGORY_OUTPUT = "Output";
4992 const CATEGORY_GLOBAL = "Global";
4993 const CATEGORY_SPECIAL = "Special";
4995 * @typedef {Object} OptionInfo
4996 * @property {string} [since] - available since version
4997 * @property {string} category
4998 * @property {'int' | 'boolean' | 'choice' | 'path'} type
4999 * @property {boolean} [array] - indicate it's an array of the specified type
5000 * @property {OptionValueInfo} [default]
5001 * @property {OptionRangeInfo} [range] - for type int
5002 * @property {string} description
5003 * @property {string} [deprecated] - deprecated since version
5004 * @property {OptionRedirectInfo} [redirect] - redirect deprecated option
5005 * @property {(value: any) => boolean} [exception]
5006 * @property {OptionChoiceInfo[]} [choices] - for type choice
5007 * @property {string} [cliName]
5008 * @property {string} [cliCategory]
5009 * @property {string} [cliDescription]
5011 * @typedef {number | boolean | string} OptionValue
5012 * @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo
5014 * @typedef {Object} OptionRedirectInfo
5015 * @property {string} option
5016 * @property {OptionValue} value
5018 * @typedef {Object} OptionRangeInfo
5019 * @property {number} start - recommended range start
5020 * @property {number} end - recommended range end
5021 * @property {number} step - recommended range step
5023 * @typedef {Object} OptionChoiceInfo
5024 * @property {boolean | string} value - boolean for the option that is originally boolean type
5025 * @property {string} description
5026 * @property {string} [since] - undefined if available since the first version of the option
5027 * @property {string} [deprecated] - deprecated since version
5028 * @property {OptionValueInfo} [redirect] - redirect deprecated value
5031 /** @type {{ [name: string]: OptionInfo }} */
5036 category: CATEGORY_SPECIAL,
5041 end: Number.POSITIVE_INFINITY,
5044 description: outdent`
5045 Print (to stderr) where a cursor at the given position would move to after formatting.
5046 This option cannot be used with --range-start and --range-end.
5048 cliCategory: CATEGORY_EDITOR
5052 category: CATEGORY_GLOBAL,
5061 description: "Which end of line characters to apply.",
5064 description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos"
5067 description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows"
5070 description: "Carriage Return character only (\\r), used very rarely"
5073 description: outdent`
5075 (mixed values within one file are normalised by looking at what's used after the first line)
5081 category: CATEGORY_SPECIAL,
5083 description: "Specify the input filepath. This will be used to do parser inference.",
5084 cliName: "stdin-filepath",
5085 cliCategory: CATEGORY_OTHER,
5086 cliDescription: "Path to the file to pretend that stdin comes from."
5090 category: CATEGORY_SPECIAL,
5093 description: "Insert @format pragma into file's first docblock comment.",
5094 cliCategory: CATEGORY_OTHER
5098 category: CATEGORY_GLOBAL,
5107 description: "Which parser to use.",
5108 exception: value => typeof value === "string" || typeof value === "function",
5115 description: "JavaScript"
5117 value: "babel-flow",
5123 description: "TypeScript"
5125 value: "typescript",
5127 description: "TypeScript"
5131 description: "JavaScript"
5135 description: "JavaScript"
5155 description: "JSON5"
5157 value: "json-stringify",
5159 description: "JSON.stringify"
5163 description: "GraphQL"
5167 description: "Markdown"
5183 description: "Ember / Handlebars"
5191 description: "Angular"
5195 description: "Lightning Web Components"
5205 category: CATEGORY_GLOBAL,
5206 description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
5207 exception: value => typeof value === "string" || typeof value === "object",
5209 cliCategory: CATEGORY_CONFIG
5218 category: CATEGORY_GLOBAL,
5219 description: outdent`
5220 Custom directory that contains prettier plugins in node_modules subdirectory.
5221 Overrides default behavior when plugins are searched relatively to the location of Prettier.
5222 Multiple values are accepted.
5224 exception: value => typeof value === "string" || typeof value === "object",
5225 cliName: "plugin-search-dir",
5226 cliCategory: CATEGORY_CONFIG
5230 category: CATEGORY_GLOBAL,
5233 description: "The line length where Prettier will try wrap.",
5236 end: Number.POSITIVE_INFINITY,
5242 category: CATEGORY_SPECIAL,
5244 default: Number.POSITIVE_INFINITY,
5247 end: Number.POSITIVE_INFINITY,
5250 description: outdent`
5251 Format code ending at a given character offset (exclusive).
5252 The range will extend forwards to the end of the selected statement.
5253 This option cannot be used with --cursor-offset.
5255 cliCategory: CATEGORY_EDITOR
5259 category: CATEGORY_SPECIAL,
5264 end: Number.POSITIVE_INFINITY,
5267 description: outdent`
5268 Format code starting at a given character offset.
5269 The range will extend backwards to the start of the first line containing the selected statement.
5270 This option cannot be used with --cursor-offset.
5272 cliCategory: CATEGORY_EDITOR
5276 category: CATEGORY_SPECIAL,
5279 description: outdent`
5280 Require either '@prettier' or '@format' to be present in the file's first docblock comment
5281 in order for it to be formatted.
5283 cliCategory: CATEGORY_OTHER
5287 category: CATEGORY_GLOBAL,
5289 description: "Number of spaces per indentation level.",
5292 end: Number.POSITIVE_INFINITY,
5298 category: CATEGORY_GLOBAL,
5301 description: "Indent with tabs instead of spaces."
5303 embeddedLanguageFormatting: {
5305 category: CATEGORY_GLOBAL,
5311 description: "Control how Prettier formats quoted code embedded in the file.",
5314 description: "Format embedded code if Prettier can automatically identify it."
5317 description: "Never automatically format embedded code."
5321 var coreOptions$1 = {
5332 const _excluded$3 = ["cliName", "cliCategory", "cliDescription"];
5339 const arrayify = arrayify$1;
5340 const currentVersion = require$$0$5.version;
5341 const coreOptions = coreOptions$1.options;
5343 * Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version
5344 * of this function created by `withPlugins`. Don't pass them here directly.
5345 * @param {object} param0
5346 * @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`.
5347 * @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`.
5348 * @param {boolean=} param0.showUnreleased
5349 * @param {boolean=} param0.showDeprecated
5350 * @param {boolean=} param0.showInternal
5353 function getSupportInfo$3({
5355 showUnreleased = false,
5356 showDeprecated = false,
5357 showInternal = false
5359 // pre-release version is smaller than the normal version in semver,
5360 // we need to treat it as the normal one so as to test new features.
5361 const version = currentVersion.split("-", 1)[0];
5362 const languages = plugins.flatMap(plugin => plugin.languages || []).filter(filterSince);
5363 const options = arrayify(Object.assign({}, ...plugins.map(({
5365 }) => options), coreOptions), "name").filter(option => filterSince(option) && filterDeprecated(option)).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1).map(mapInternal).map(option => {
5366 option = Object.assign({}, option);
5368 if (Array.isArray(option.default)) {
5369 option.default = option.default.length === 1 ? option.default[0].value : option.default.filter(filterSince).sort((info1, info2) => semver$2.compare(info2.since, info1.since))[0].value;
5372 if (Array.isArray(option.choices)) {
5373 option.choices = option.choices.filter(option => filterSince(option) && filterDeprecated(option));
5375 if (option.name === "parser") {
5376 collectParsersFromLanguages(option, languages, plugins);
5380 const pluginDefaults = Object.fromEntries(plugins.filter(plugin => plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined).map(plugin => [plugin.name, plugin.defaultOptions[option.name]]));
5381 return Object.assign(Object.assign({}, option), {}, {
5390 function filterSince(object) {
5391 return showUnreleased || !("since" in object) || object.since && semver$2.gte(version, object.since);
5394 function filterDeprecated(object) {
5395 return showDeprecated || !("deprecated" in object) || object.deprecated && semver$2.lt(version, object.deprecated);
5398 function mapInternal(object) {
5403 const newObject = _objectWithoutProperties(object, _excluded$3);
5409 function collectParsersFromLanguages(option, languages, plugins) {
5410 const existingValues = new Set(option.choices.map(choice => choice.value));
5412 for (const language of languages) {
5413 if (language.parsers) {
5414 for (const value of language.parsers) {
5415 if (!existingValues.has(value)) {
5416 existingValues.add(value);
5417 const plugin = plugins.find(plugin => plugin.parsers && plugin.parsers[value]);
5418 let description = language.name;
5420 if (plugin && plugin.name) {
5421 description += ` (plugin: ${plugin.name})`;
5424 option.choices.push({
5435 getSupportInfo: getSupportInfo$3
5438 const stringWidth = stringWidth$2.exports;
5439 const escapeStringRegexp$2 = escapeStringRegexp$3;
5440 const getLast$o = getLast_1;
5442 getSupportInfo: getSupportInfo$2
5444 const notAsciiRegex = /[^\x20-\x7F]/;
5446 const getPenultimate$1 = arr => arr[arr.length - 2];
5448 * @typedef {{backwards?: boolean}} SkipOptions
5452 * @param {string | RegExp} chars
5453 * @returns {(text: string, index: number | false, opts?: SkipOptions) => number | false}
5457 function skip$1(chars) {
5458 return (text, index, opts) => {
5459 const backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
5460 // to check for failures (did someone say monads?).
5462 /* istanbul ignore next */
5464 if (index === false) {
5473 while (cursor >= 0 && cursor < length) {
5474 const c = text.charAt(cursor);
5476 if (chars instanceof RegExp) {
5477 if (!chars.test(c)) {
5480 } else if (!chars.includes(c)) {
5484 backwards ? cursor-- : cursor++;
5487 if (cursor === -1 || cursor === length) {
5488 // If we reached the beginning or end of the file, return the
5489 // out-of-bounds cursor. It's up to the caller to handle this
5490 // correctly. We don't want to indicate `false` though if it
5491 // actually skipped valid characters.
5499 * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
5503 const skipWhitespace$2 = skip$1(/\s/);
5505 * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
5508 const skipSpaces$2 = skip$1(" \t");
5510 * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
5513 const skipToLineEnd$1 = skip$1(",; \t");
5515 * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
5518 const skipEverythingButNewLine$2 = skip$1(/[^\n\r]/);
5520 * @param {string} text
5521 * @param {number | false} index
5522 * @returns {number | false}
5525 function skipInlineComment$1(text, index) {
5526 /* istanbul ignore next */
5527 if (index === false) {
5531 if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
5532 for (let i = index + 2; i < text.length; ++i) {
5533 if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
5542 * @param {string} text
5543 * @param {number | false} index
5544 * @returns {number | false}
5548 function skipTrailingComment$1(text, index) {
5549 /* istanbul ignore next */
5550 if (index === false) {
5554 if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
5555 return skipEverythingButNewLine$2(text, index);
5559 } // This one doesn't use the above helper function because it wants to
5560 // test \r\n in order and `skip` doesn't support ordering and we only
5561 // want to skip one newline. It's simple to implement.
5564 * @param {string} text
5565 * @param {number | false} index
5566 * @param {SkipOptions=} opts
5567 * @returns {number | false}
5571 function skipNewline$2(text, index, opts) {
5572 const backwards = opts && opts.backwards;
5574 if (index === false) {
5578 const atIndex = text.charAt(index);
5581 // We already replace `\r\n` with `\n` before parsing
5583 /* istanbul ignore next */
5584 if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
5588 if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
5592 // We already replace `\r\n` with `\n` before parsing
5594 /* istanbul ignore next */
5595 if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
5599 if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
5607 * @param {string} text
5608 * @param {number} index
5609 * @param {SkipOptions=} opts
5610 * @returns {boolean}
5614 function hasNewline$a(text, index, opts = {}) {
5615 const idx = skipSpaces$2(text, opts.backwards ? index - 1 : index, opts);
5616 const idx2 = skipNewline$2(text, idx, opts);
5617 return idx !== idx2;
5620 * @param {string} text
5621 * @param {number} start
5622 * @param {number} end
5623 * @returns {boolean}
5627 function hasNewlineInRange$5(text, start, end) {
5628 for (let i = start; i < end; ++i) {
5629 if (text.charAt(i) === "\n") {
5635 } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty
5639 * @param {string} text
5641 * @param {(node: N) => number} locStart
5645 function isPreviousLineEmpty$3(text, node, locStart) {
5646 /** @type {number | false} */
5647 let idx = locStart(node) - 1;
5648 idx = skipSpaces$2(text, idx, {
5651 idx = skipNewline$2(text, idx, {
5654 idx = skipSpaces$2(text, idx, {
5657 const idx2 = skipNewline$2(text, idx, {
5660 return idx !== idx2;
5663 * @param {string} text
5664 * @param {number} index
5665 * @returns {boolean}
5669 function isNextLineEmptyAfterIndex$3(text, index) {
5670 /** @type {number | false} */
5672 /** @type {number | false} */
5676 while (idx !== oldIdx) {
5677 // We need to skip all the potential trailing inline comments
5679 idx = skipToLineEnd$1(text, idx);
5680 idx = skipInlineComment$1(text, idx);
5681 idx = skipSpaces$2(text, idx);
5684 idx = skipTrailingComment$1(text, idx);
5685 idx = skipNewline$2(text, idx);
5686 return idx !== false && hasNewline$a(text, idx);
5690 * @param {string} text
5692 * @param {(node: N) => number} locEnd
5693 * @returns {boolean}
5697 function isNextLineEmpty$e(text, node, locEnd) {
5698 return isNextLineEmptyAfterIndex$3(text, locEnd(node));
5701 * @param {string} text
5702 * @param {number} idx
5703 * @returns {number | false}
5707 function getNextNonSpaceNonCommentCharacterIndexWithStartIndex$1(text, idx) {
5708 /** @type {number | false} */
5710 /** @type {number | false} */
5714 while (nextIdx !== oldIdx) {
5716 nextIdx = skipSpaces$2(text, nextIdx);
5717 nextIdx = skipInlineComment$1(text, nextIdx);
5718 nextIdx = skipTrailingComment$1(text, nextIdx);
5719 nextIdx = skipNewline$2(text, nextIdx);
5726 * @param {string} text
5728 * @param {(node: N) => number} locEnd
5729 * @returns {number | false}
5733 function getNextNonSpaceNonCommentCharacterIndex$4(text, node, locEnd) {
5734 return getNextNonSpaceNonCommentCharacterIndexWithStartIndex$1(text, locEnd(node));
5738 * @param {string} text
5740 * @param {(node: N) => number} locEnd
5745 function getNextNonSpaceNonCommentCharacter$2(text, node, locEnd) {
5746 return text.charAt( // @ts-expect-error => TBD: can return false, should we define a fallback?
5747 getNextNonSpaceNonCommentCharacterIndex$4(text, node, locEnd));
5748 } // Not using, but it's public utils
5750 /* istanbul ignore next */
5753 * @param {string} text
5754 * @param {number} index
5755 * @param {SkipOptions=} opts
5756 * @returns {boolean}
5760 function hasSpaces$1(text, index, opts = {}) {
5761 const idx = skipSpaces$2(text, opts.backwards ? index - 1 : index, opts);
5762 return idx !== index;
5765 * @param {string} value
5766 * @param {number} tabWidth
5767 * @param {number=} startIndex
5772 function getAlignmentSize$2(value, tabWidth, startIndex = 0) {
5775 for (let i = startIndex; i < value.length; ++i) {
5776 if (value[i] === "\t") {
5777 // Tabs behave in a way that they are aligned to the nearest
5778 // multiple of tabWidth:
5779 // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4
5780 // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ...
5781 size = size + tabWidth - size % tabWidth;
5790 * @param {string} value
5791 * @param {number} tabWidth
5796 function getIndentSize$2(value, tabWidth) {
5797 const lastNewlineIndex = value.lastIndexOf("\n");
5799 if (lastNewlineIndex === -1) {
5803 return getAlignmentSize$2( // All the leading whitespaces
5804 value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0], tabWidth);
5807 * @typedef {'"' | "'"} Quote
5812 * @param {string} rawContent
5813 * @param {Quote} preferredQuote
5814 * @returns {{ quote: Quote, regex: RegExp, escaped: string }}
5818 function getPreferredQuote$2(rawContent, preferredQuote) {
5819 /** @type {{ quote: '"', regex: RegExp, escaped: """ }} */
5825 /** @type {{ quote: "'", regex: RegExp, escaped: "'" }} */
5832 const preferred = preferredQuote === "'" ? single : double;
5833 const alternate = preferred === single ? double : single;
5834 let result = preferred; // If `rawContent` contains at least one of the quote preferred for enclosing
5835 // the string, we might want to enclose with the alternate quote instead, to
5836 // minimize the number of escaped quotes.
5838 if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) {
5839 const numPreferredQuotes = (rawContent.match(preferred.regex) || []).length;
5840 const numAlternateQuotes = (rawContent.match(alternate.regex) || []).length;
5841 result = numPreferredQuotes > numAlternateQuotes ? alternate : preferred;
5847 function printString$4(raw, options) {
5848 // `rawContent` is the string exactly like it appeared in the input source
5849 // code, without its enclosing quotes.
5850 const rawContent = raw.slice(1, -1);
5851 /** @type {Quote} */
5853 const enclosingQuote = options.parser === "json" || options.parser === "json5" && options.quoteProps === "preserve" && !options.singleQuote ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote$2(rawContent, options.singleQuote ? "'" : '"').quote; // It might sound unnecessary to use `makeString` even if the string already
5854 // is enclosed with `enclosingQuote`, but it isn't. The string could contain
5855 // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes
5856 // sure that we consistently output the minimum amount of escaped quotes.
5858 return makeString$1(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.__embeddedInHtml));
5861 * @param {string} rawContent
5862 * @param {Quote} enclosingQuote
5863 * @param {boolean=} unescapeUnnecessaryEscapes
5868 function makeString$1(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
5869 const otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double).
5871 const regex = /\\(.)|(["'])/gs; // Escape and unescape single and double quotes as needed to be able to
5872 // enclose `rawContent` with `enclosingQuote`.
5874 const newContent = rawContent.replace(regex, (match, escaped, quote) => {
5875 // If we matched an escape, and the escaped character is a quote of the
5876 // other type than we intend to enclose the string with, there's no need for
5877 // it to be escaped, so return it _without_ the backslash.
5878 if (escaped === otherQuote) {
5880 } // If we matched an unescaped quote and it is of the _same_ type as we
5881 // intend to enclose the string with, it must be escaped, so return it with
5885 if (quote === enclosingQuote) {
5886 return "\\" + quote;
5891 } // Unescape any unnecessarily escaped character.
5892 // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27
5895 return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
5897 return enclosingQuote + newContent + enclosingQuote;
5900 function printNumber$4(rawNumber) {
5901 return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation.
5902 .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0).
5903 .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit.
5904 .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes.
5905 .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot.
5906 .replace(/\.(?=e|$)/, "");
5909 * @param {string} str
5910 * @param {string} target
5915 function getMaxContinuousCount$3(str, target) {
5916 const results = str.match(new RegExp(`(${escapeStringRegexp$2(target)})+`, "g"));
5918 if (results === null) {
5922 return results.reduce((maxCount, result) => Math.max(maxCount, result.length / target.length), 0);
5925 function getMinNotPresentContinuousCount$1(str, target) {
5926 const matches = str.match(new RegExp(`(${escapeStringRegexp$2(target)})+`, "g"));
5928 if (matches === null) {
5932 const countPresent = new Map();
5935 for (const match of matches) {
5936 const count = match.length / target.length;
5937 countPresent.set(count, true);
5944 for (let i = 1; i < max; i++) {
5945 if (!countPresent.get(i)) {
5953 * @param {string} text
5958 function getStringWidth$5(text) {
5961 } // shortcut to avoid needless string `RegExp`s, replacements, and allocations within `string-width`
5964 if (!notAsciiRegex.test(text)) {
5968 return stringWidth(text);
5971 function addCommentHelper(node, comment) {
5972 const comments = node.comments || (node.comments = []);
5973 comments.push(comment);
5974 comment.printed = false;
5975 comment.nodeDescription = describeNodeForDebugging(node);
5978 function addLeadingComment$3(node, comment) {
5979 comment.leading = true;
5980 comment.trailing = false;
5981 addCommentHelper(node, comment);
5984 function addDanglingComment$3(node, comment, marker) {
5985 comment.leading = false;
5986 comment.trailing = false;
5989 comment.marker = marker;
5992 addCommentHelper(node, comment);
5995 function addTrailingComment$3(node, comment) {
5996 comment.leading = false;
5997 comment.trailing = true;
5998 addCommentHelper(node, comment);
6001 function inferParserByLanguage$2(language, options) {
6004 } = getSupportInfo$2({
6005 plugins: options.plugins
6007 const matched = languages.find(({
6009 }) => name.toLowerCase() === language) || languages.find(({
6011 }) => Array.isArray(aliases) && aliases.includes(language)) || languages.find(({
6013 }) => Array.isArray(extensions) && extensions.includes(`.${language}`));
6014 return matched && matched.parsers[0];
6017 function isFrontMatterNode$5(node) {
6018 return node && node.type === "front-matter";
6021 function getShebang$1(text) {
6022 if (!text.startsWith("#!")) {
6026 const index = text.indexOf("\n");
6032 return text.slice(0, index);
6035 * @param {any} object
6036 * @returns {object is Array<any>}
6040 function isNonEmptyArray$j(object) {
6041 return Array.isArray(object) && object.length > 0;
6044 * @param {string} description
6045 * @returns {(node: any) => symbol}
6049 function createGroupIdMapper$2(description) {
6050 const groupIds = new WeakMap();
6051 return function (node) {
6052 if (!groupIds.has(node)) {
6053 groupIds.set(node, Symbol(description));
6056 return groupIds.get(node);
6060 function describeNodeForDebugging(node) {
6061 const nodeType = node.type || node.kind || "(unknown type)";
6062 let nodeName = String(node.name || node.id && (typeof node.id === "object" ? node.id.name : node.id) || node.key && (typeof node.key === "object" ? node.key.name : node.key) || node.value && (typeof node.value === "object" ? "" : String(node.value)) || node.operator || "");
6064 if (nodeName.length > 20) {
6065 nodeName = nodeName.slice(0, 19) + "…";
6068 return nodeType + (nodeName ? " " + nodeName : "");
6072 inferParserByLanguage: inferParserByLanguage$2,
6073 getStringWidth: getStringWidth$5,
6074 getMaxContinuousCount: getMaxContinuousCount$3,
6075 getMinNotPresentContinuousCount: getMinNotPresentContinuousCount$1,
6076 getPenultimate: getPenultimate$1,
6078 getNextNonSpaceNonCommentCharacterIndexWithStartIndex: getNextNonSpaceNonCommentCharacterIndexWithStartIndex$1,
6079 getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$4,
6080 getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter$2,
6082 skipWhitespace: skipWhitespace$2,
6083 skipSpaces: skipSpaces$2,
6084 skipToLineEnd: skipToLineEnd$1,
6085 skipEverythingButNewLine: skipEverythingButNewLine$2,
6086 skipInlineComment: skipInlineComment$1,
6087 skipTrailingComment: skipTrailingComment$1,
6088 skipNewline: skipNewline$2,
6089 isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$3,
6090 isNextLineEmpty: isNextLineEmpty$e,
6091 isPreviousLineEmpty: isPreviousLineEmpty$3,
6092 hasNewline: hasNewline$a,
6093 hasNewlineInRange: hasNewlineInRange$5,
6094 hasSpaces: hasSpaces$1,
6095 getAlignmentSize: getAlignmentSize$2,
6096 getIndentSize: getIndentSize$2,
6097 getPreferredQuote: getPreferredQuote$2,
6098 printString: printString$4,
6099 printNumber: printNumber$4,
6100 makeString: makeString$1,
6101 addLeadingComment: addLeadingComment$3,
6102 addDanglingComment: addDanglingComment$3,
6103 addTrailingComment: addTrailingComment$3,
6104 isFrontMatterNode: isFrontMatterNode$5,
6105 getShebang: getShebang$1,
6106 isNonEmptyArray: isNonEmptyArray$j,
6107 createGroupIdMapper: createGroupIdMapper$2
6110 function guessEndOfLine$1(text) {
6111 const index = text.indexOf("\r");
6114 return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
6120 function convertEndOfLineToChars$1(value) {
6133 function countEndOfLineChars$1(text, eol) {
6135 /* istanbul ignore else */
6139 } else if (eol === "\r") {
6141 } else if (eol === "\r\n") {
6144 throw new Error(`Unexpected "eol" ${JSON.stringify(eol)}.`);
6147 const endOfLines = text.match(regex);
6148 return endOfLines ? endOfLines.length : 0;
6151 function normalizeEndOfLine$2(text) {
6152 return text.replace(/\r\n?/g, "\n");
6156 guessEndOfLine: guessEndOfLine$1,
6157 convertEndOfLineToChars: convertEndOfLineToChars$1,
6158 countEndOfLineChars: countEndOfLineChars$1,
6159 normalizeEndOfLine: normalizeEndOfLine$2
6162 const fs$l = require$$0__default["default"];
6168 constructor(file, options) {
6169 options = options || {};
6170 if (!options.readChunk) options.readChunk = 1024;
6172 if (!options.newLineCharacter) {
6173 options.newLineCharacter = 0x0a; //linux line ending
6175 options.newLineCharacter = options.newLineCharacter.charCodeAt(0);
6178 if (typeof file === 'number') {
6181 this.fd = fs$l.openSync(file, 'r');
6184 this.options = options;
6185 this.newLineCharacter = options.newLineCharacter;
6189 _searchInBuffer(buffer, hexNeedle) {
6192 for (let i = 0; i <= buffer.length; i++) {
6193 let b_byte = buffer[i];
6195 if (b_byte === hexNeedle) {
6205 this.eofReached = false;
6206 this.linesCache = [];
6207 this.fdPosition = 0;
6211 fs$l.closeSync(this.fd);
6215 _extractLines(buffer) {
6218 let bufferPosition = 0;
6219 let lastNewLineBufferPosition = 0;
6222 let bufferPositionValue = buffer[bufferPosition++];
6224 if (bufferPositionValue === this.newLineCharacter) {
6225 line = buffer.slice(lastNewLineBufferPosition, bufferPosition);
6227 lastNewLineBufferPosition = bufferPosition;
6228 } else if (bufferPositionValue === undefined) {
6233 let leftovers = buffer.slice(lastNewLineBufferPosition, bufferPosition);
6235 if (leftovers.length) {
6236 lines.push(leftovers);
6242 _readChunk(lineLeftovers) {
6243 let totalBytesRead = 0;
6248 const readBuffer = new Buffer(this.options.readChunk);
6249 bytesRead = fs$l.readSync(this.fd, readBuffer, 0, this.options.readChunk, this.fdPosition);
6250 totalBytesRead = totalBytesRead + bytesRead;
6251 this.fdPosition = this.fdPosition + bytesRead;
6252 buffers.push(readBuffer);
6253 } while (bytesRead && this._searchInBuffer(buffers[buffers.length - 1], this.options.newLineCharacter) === -1);
6255 let bufferData = Buffer.concat(buffers);
6257 if (bytesRead < this.options.readChunk) {
6258 this.eofReached = true;
6259 bufferData = bufferData.slice(0, totalBytesRead);
6262 if (totalBytesRead) {
6263 this.linesCache = this._extractLines(bufferData);
6265 if (lineLeftovers) {
6266 this.linesCache[0] = Buffer.concat([lineLeftovers, this.linesCache[0]]);
6270 return totalBytesRead;
6274 if (!this.fd) return false;
6277 if (this.eofReached && this.linesCache.length === 0) {
6283 if (!this.linesCache.length) {
6284 bytesRead = this._readChunk();
6287 if (this.linesCache.length) {
6288 line = this.linesCache.shift();
6289 const lastLineCharacter = line[line.length - 1];
6291 if (lastLineCharacter !== this.newLineCharacter) {
6292 bytesRead = this._readChunk(line);
6295 line = this.linesCache.shift();
6300 if (this.eofReached && this.linesCache.length === 0) {
6304 if (line && line[line.length - 1] === this.newLineCharacter) {
6305 line = line.slice(0, line.length - 1);
6313 var readlines$1 = LineByLine;
6315 class ConfigError$1 extends Error {}
6317 class DebugError extends Error {}
6319 class UndefinedParserError$1 extends Error {}
6321 class ArgExpansionBailout$3 extends Error {}
6324 ConfigError: ConfigError$1,
6326 UndefinedParserError: UndefinedParserError$1,
6327 ArgExpansionBailout: ArgExpansionBailout$3
6332 /*! *****************************************************************************
\r
6333 Copyright (c) Microsoft Corporation.
\r
6335 Permission to use, copy, modify, and/or distribute this software for any
\r
6336 purpose with or without fee is hereby granted.
\r
6338 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
\r
6339 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
\r
6340 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
\r
6341 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
\r
6342 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
\r
6343 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
\r
6344 PERFORMANCE OF THIS SOFTWARE.
\r
6345 ***************************************************************************** */
6347 /* global Reflect, Promise */
6348 var extendStatics = function (d, b) {
6349 extendStatics = Object.setPrototypeOf || {
6351 } instanceof Array && function (d, b) {
6353 } || function (d, b) {
6354 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
6357 return extendStatics(d, b);
6360 function __extends(d, b) {
6361 extendStatics(d, b);
6364 this.constructor = d;
6367 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6369 var __assign = function () {
6370 __assign = Object.assign || function __assign(t) {
6371 for (var s, i = 1, n = arguments.length; i < n; i++) {
6374 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6380 return __assign.apply(this, arguments);
6382 function __rest(s, e) {
6385 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6387 if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
6388 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
6392 function __decorate(decorators, target, key, desc) {
6393 var c = arguments.length,
6394 r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
6396 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6397 return c > 3 && r && Object.defineProperty(target, key, r), r;
6399 function __param(paramIndex, decorator) {
6400 return function (target, key) {
6401 decorator(target, key, paramIndex);
6404 function __metadata(metadataKey, metadataValue) {
6405 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
6407 function __awaiter$2(thisArg, _arguments, P, generator) {
6408 function adopt(value) {
6409 return value instanceof P ? value : new P(function (resolve) {
6414 return new (P || (P = Promise))(function (resolve, reject) {
6415 function fulfilled(value) {
6417 step(generator.next(value));
6423 function rejected(value) {
6425 step(generator["throw"](value));
6431 function step(result) {
6432 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
6435 step((generator = generator.apply(thisArg, _arguments || [])).next());
6438 function __generator$2(thisArg, body) {
6442 if (t[0] & 1) throw t[1];
6456 }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
6461 return function (v) {
6462 return step([n, v]);
6467 if (f) throw new TypeError("Generator is already executing.");
6470 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
6471 if (y = 0, t) op = [op[0] & 2, t.value];
6500 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
6505 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
6510 if (op[0] === 6 && _.label < t[1]) {
6516 if (t && _.label < t[2]) {
6524 if (t[2]) _.ops.pop();
6531 op = body.call(thisArg, _);
6539 if (op[0] & 5) throw op[1];
6541 value: op[0] ? op[1] : void 0,
6546 function __createBinding(o, m, k, k2) {
6547 if (k2 === undefined) k2 = k;
6550 function __exportStar(m, exports) {
6551 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
6553 function __values(o) {
6554 var s = typeof Symbol === "function" && Symbol.iterator,
6557 if (m) return m.call(o);
6558 if (o && typeof o.length === "number") return {
6560 if (o && i >= o.length) o = void 0;
6567 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
6569 function __read(o, n) {
6570 var m = typeof Symbol === "function" && o[Symbol.iterator];
6578 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
6585 if (r && !r.done && (m = i["return"])) m.call(i);
6587 if (e) throw e.error;
6593 function __spread() {
6594 for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
6598 function __spreadArrays() {
6599 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
6601 for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
6605 function __await(v) {
6606 return this instanceof __await ? (this.v = v, this) : new __await(v);
6608 function __asyncGenerator(thisArg, _arguments, generator) {
6609 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
6610 var g = generator.apply(thisArg, _arguments || []),
6613 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
6618 if (g[n]) i[n] = function (v) {
6619 return new Promise(function (a, b) {
6620 q.push([n, v, a, b]) > 1 || resume(n, v);
6625 function resume(n, v) {
6634 r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
6637 function fulfill(value) {
6638 resume("next", value);
6641 function reject(value) {
6642 resume("throw", value);
6645 function settle(f, v) {
6646 if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
6649 function __asyncDelegator(o) {
6651 return i = {}, verb("next"), verb("throw", function (e) {
6653 }), verb("return"), i[Symbol.iterator] = function () {
6657 function verb(n, f) {
6658 i[n] = o[n] ? function (v) {
6660 value: __await(o[n](v)),
6661 done: n === "return"
6666 function __asyncValues(o) {
6667 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
6668 var m = o[Symbol.asyncIterator],
6670 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
6675 i[n] = o[n] && function (v) {
6676 return new Promise(function (resolve, reject) {
6677 v = o[n](v), settle(resolve, reject, v.done, v.value);
6682 function settle(resolve, reject, d, v) {
6683 Promise.resolve(v).then(function (v) {
6691 function __makeTemplateObject(cooked, raw) {
6692 if (Object.defineProperty) {
6693 Object.defineProperty(cooked, "raw", {
6702 function __importStar$2(mod) {
6703 if (mod && mod.__esModule) return mod;
6705 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6706 result.default = mod;
6709 function __importDefault$1(mod) {
6710 return mod && mod.__esModule ? mod : {
6714 function __classPrivateFieldGet(receiver, privateMap) {
6715 if (!privateMap.has(receiver)) {
6716 throw new TypeError("attempted to get private field on non-instance");
6719 return privateMap.get(receiver);
6721 function __classPrivateFieldSet(receiver, privateMap, value) {
6722 if (!privateMap.has(receiver)) {
6723 throw new TypeError("attempted to set private field on non-instance");
6726 privateMap.set(receiver, value);
6730 var tslib_es6 = /*#__PURE__*/Object.freeze({
6732 __extends: __extends,
6733 get __assign () { return __assign; },
6735 __decorate: __decorate,
6737 __metadata: __metadata,
6738 __awaiter: __awaiter$2,
6739 __generator: __generator$2,
6740 __createBinding: __createBinding,
6741 __exportStar: __exportStar,
6745 __spreadArrays: __spreadArrays,
6747 __asyncGenerator: __asyncGenerator,
6748 __asyncDelegator: __asyncDelegator,
6749 __asyncValues: __asyncValues,
6750 __makeTemplateObject: __makeTemplateObject,
6751 __importStar: __importStar$2,
6752 __importDefault: __importDefault$1,
6753 __classPrivateFieldGet: __classPrivateFieldGet,
6754 __classPrivateFieldSet: __classPrivateFieldSet
6757 var descriptors = {};
6761 (function (exports) {
6763 Object.defineProperty(exports, "__esModule", {
6766 exports.apiDescriptor = {
6767 key: key => /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(key) ? key : JSON.stringify(key),
6770 if (value === null || typeof value !== 'object') {
6771 return JSON.stringify(value);
6774 if (Array.isArray(value)) {
6775 return `[${value.map(subValue => exports.apiDescriptor.value(subValue)).join(', ')}]`;
6778 const keys = Object.keys(value);
6779 return keys.length === 0 ? '{}' : `{ ${keys.map(key => `${exports.apiDescriptor.key(key)}: ${exports.apiDescriptor.value(value[key])}`).join(', ')} }`;
6785 }) => exports.apiDescriptor.value({
6791 (function (exports) {
6793 Object.defineProperty(exports, "__esModule", {
6796 const tslib_1 = tslib_es6;
6798 tslib_1.__exportStar(api, exports);
6803 var deprecated = {};
6807 var chalk$3 = {exports: {}};
6809 var matchOperatorsRe$1 = /[|\\{}()[\]^$+*?.]/g;
6811 var escapeStringRegexp$1 = function (str) {
6812 if (typeof str !== 'string') {
6813 throw new TypeError('Expected a string');
6816 return str.replace(matchOperatorsRe$1, '\\$&');
6819 var ansiStyles$2 = {exports: {}};
6821 var conversions$5 = {exports: {}};
6824 "aliceblue": [240, 248, 255],
6825 "antiquewhite": [250, 235, 215],
6826 "aqua": [0, 255, 255],
6827 "aquamarine": [127, 255, 212],
6828 "azure": [240, 255, 255],
6829 "beige": [245, 245, 220],
6830 "bisque": [255, 228, 196],
6832 "blanchedalmond": [255, 235, 205],
6833 "blue": [0, 0, 255],
6834 "blueviolet": [138, 43, 226],
6835 "brown": [165, 42, 42],
6836 "burlywood": [222, 184, 135],
6837 "cadetblue": [95, 158, 160],
6838 "chartreuse": [127, 255, 0],
6839 "chocolate": [210, 105, 30],
6840 "coral": [255, 127, 80],
6841 "cornflowerblue": [100, 149, 237],
6842 "cornsilk": [255, 248, 220],
6843 "crimson": [220, 20, 60],
6844 "cyan": [0, 255, 255],
6845 "darkblue": [0, 0, 139],
6846 "darkcyan": [0, 139, 139],
6847 "darkgoldenrod": [184, 134, 11],
6848 "darkgray": [169, 169, 169],
6849 "darkgreen": [0, 100, 0],
6850 "darkgrey": [169, 169, 169],
6851 "darkkhaki": [189, 183, 107],
6852 "darkmagenta": [139, 0, 139],
6853 "darkolivegreen": [85, 107, 47],
6854 "darkorange": [255, 140, 0],
6855 "darkorchid": [153, 50, 204],
6856 "darkred": [139, 0, 0],
6857 "darksalmon": [233, 150, 122],
6858 "darkseagreen": [143, 188, 143],
6859 "darkslateblue": [72, 61, 139],
6860 "darkslategray": [47, 79, 79],
6861 "darkslategrey": [47, 79, 79],
6862 "darkturquoise": [0, 206, 209],
6863 "darkviolet": [148, 0, 211],
6864 "deeppink": [255, 20, 147],
6865 "deepskyblue": [0, 191, 255],
6866 "dimgray": [105, 105, 105],
6867 "dimgrey": [105, 105, 105],
6868 "dodgerblue": [30, 144, 255],
6869 "firebrick": [178, 34, 34],
6870 "floralwhite": [255, 250, 240],
6871 "forestgreen": [34, 139, 34],
6872 "fuchsia": [255, 0, 255],
6873 "gainsboro": [220, 220, 220],
6874 "ghostwhite": [248, 248, 255],
6875 "gold": [255, 215, 0],
6876 "goldenrod": [218, 165, 32],
6877 "gray": [128, 128, 128],
6878 "green": [0, 128, 0],
6879 "greenyellow": [173, 255, 47],
6880 "grey": [128, 128, 128],
6881 "honeydew": [240, 255, 240],
6882 "hotpink": [255, 105, 180],
6883 "indianred": [205, 92, 92],
6884 "indigo": [75, 0, 130],
6885 "ivory": [255, 255, 240],
6886 "khaki": [240, 230, 140],
6887 "lavender": [230, 230, 250],
6888 "lavenderblush": [255, 240, 245],
6889 "lawngreen": [124, 252, 0],
6890 "lemonchiffon": [255, 250, 205],
6891 "lightblue": [173, 216, 230],
6892 "lightcoral": [240, 128, 128],
6893 "lightcyan": [224, 255, 255],
6894 "lightgoldenrodyellow": [250, 250, 210],
6895 "lightgray": [211, 211, 211],
6896 "lightgreen": [144, 238, 144],
6897 "lightgrey": [211, 211, 211],
6898 "lightpink": [255, 182, 193],
6899 "lightsalmon": [255, 160, 122],
6900 "lightseagreen": [32, 178, 170],
6901 "lightskyblue": [135, 206, 250],
6902 "lightslategray": [119, 136, 153],
6903 "lightslategrey": [119, 136, 153],
6904 "lightsteelblue": [176, 196, 222],
6905 "lightyellow": [255, 255, 224],
6906 "lime": [0, 255, 0],
6907 "limegreen": [50, 205, 50],
6908 "linen": [250, 240, 230],
6909 "magenta": [255, 0, 255],
6910 "maroon": [128, 0, 0],
6911 "mediumaquamarine": [102, 205, 170],
6912 "mediumblue": [0, 0, 205],
6913 "mediumorchid": [186, 85, 211],
6914 "mediumpurple": [147, 112, 219],
6915 "mediumseagreen": [60, 179, 113],
6916 "mediumslateblue": [123, 104, 238],
6917 "mediumspringgreen": [0, 250, 154],
6918 "mediumturquoise": [72, 209, 204],
6919 "mediumvioletred": [199, 21, 133],
6920 "midnightblue": [25, 25, 112],
6921 "mintcream": [245, 255, 250],
6922 "mistyrose": [255, 228, 225],
6923 "moccasin": [255, 228, 181],
6924 "navajowhite": [255, 222, 173],
6925 "navy": [0, 0, 128],
6926 "oldlace": [253, 245, 230],
6927 "olive": [128, 128, 0],
6928 "olivedrab": [107, 142, 35],
6929 "orange": [255, 165, 0],
6930 "orangered": [255, 69, 0],
6931 "orchid": [218, 112, 214],
6932 "palegoldenrod": [238, 232, 170],
6933 "palegreen": [152, 251, 152],
6934 "paleturquoise": [175, 238, 238],
6935 "palevioletred": [219, 112, 147],
6936 "papayawhip": [255, 239, 213],
6937 "peachpuff": [255, 218, 185],
6938 "peru": [205, 133, 63],
6939 "pink": [255, 192, 203],
6940 "plum": [221, 160, 221],
6941 "powderblue": [176, 224, 230],
6942 "purple": [128, 0, 128],
6943 "rebeccapurple": [102, 51, 153],
6945 "rosybrown": [188, 143, 143],
6946 "royalblue": [65, 105, 225],
6947 "saddlebrown": [139, 69, 19],
6948 "salmon": [250, 128, 114],
6949 "sandybrown": [244, 164, 96],
6950 "seagreen": [46, 139, 87],
6951 "seashell": [255, 245, 238],
6952 "sienna": [160, 82, 45],
6953 "silver": [192, 192, 192],
6954 "skyblue": [135, 206, 235],
6955 "slateblue": [106, 90, 205],
6956 "slategray": [112, 128, 144],
6957 "slategrey": [112, 128, 144],
6958 "snow": [255, 250, 250],
6959 "springgreen": [0, 255, 127],
6960 "steelblue": [70, 130, 180],
6961 "tan": [210, 180, 140],
6962 "teal": [0, 128, 128],
6963 "thistle": [216, 191, 216],
6964 "tomato": [255, 99, 71],
6965 "turquoise": [64, 224, 208],
6966 "violet": [238, 130, 238],
6967 "wheat": [245, 222, 179],
6968 "white": [255, 255, 255],
6969 "whitesmoke": [245, 245, 245],
6970 "yellow": [255, 255, 0],
6971 "yellowgreen": [154, 205, 50]
6975 var cssKeywords$1 = colorName$1; // NOTE: conversions should only return primitive values (i.e. arrays, or
6976 // values that give correct `typeof` results).
6977 // do not use box values types (i.e. Number(), String(), etc.)
6979 var reverseKeywords$1 = {};
6981 for (var key$1 in cssKeywords$1) {
6982 if (cssKeywords$1.hasOwnProperty(key$1)) {
6983 reverseKeywords$1[cssKeywords$1[key$1]] = key$1;
6987 var convert$3 = conversions$5.exports = {
7038 labels: ['h', 'c', 'g']
7042 labels: ['r16', 'g16', 'b16']
7048 }; // hide .channels and .labels properties
7050 for (var model in convert$3) {
7051 if (convert$3.hasOwnProperty(model)) {
7052 if (!('channels' in convert$3[model])) {
7053 throw new Error('missing channels property: ' + model);
7056 if (!('labels' in convert$3[model])) {
7057 throw new Error('missing channel labels property: ' + model);
7060 if (convert$3[model].labels.length !== convert$3[model].channels) {
7061 throw new Error('channel and label counts mismatch: ' + model);
7064 var channels = convert$3[model].channels;
7065 var labels = convert$3[model].labels;
7066 delete convert$3[model].channels;
7067 delete convert$3[model].labels;
7068 Object.defineProperty(convert$3[model], 'channels', {
7071 Object.defineProperty(convert$3[model], 'labels', {
7077 convert$3.rgb.hsl = function (rgb) {
7078 var r = rgb[0] / 255;
7079 var g = rgb[1] / 255;
7080 var b = rgb[2] / 255;
7081 var min = Math.min(r, g, b);
7082 var max = Math.max(r, g, b);
7083 var delta = max - min;
7090 } else if (r === max) {
7091 h = (g - b) / delta;
7092 } else if (g === max) {
7093 h = 2 + (b - r) / delta;
7094 } else if (b === max) {
7095 h = 4 + (r - g) / delta;
7098 h = Math.min(h * 60, 360);
7104 l = (min + max) / 2;
7108 } else if (l <= 0.5) {
7109 s = delta / (max + min);
7111 s = delta / (2 - max - min);
7114 return [h, s * 100, l * 100];
7117 convert$3.rgb.hsv = function (rgb) {
7123 var r = rgb[0] / 255;
7124 var g = rgb[1] / 255;
7125 var b = rgb[2] / 255;
7126 var v = Math.max(r, g, b);
7127 var diff = v - Math.min(r, g, b);
7129 var diffc = function (c) {
7130 return (v - c) / 6 / diff + 1 / 2;
7143 } else if (g === v) {
7144 h = 1 / 3 + rdif - bdif;
7145 } else if (b === v) {
7146 h = 2 / 3 + gdif - rdif;
7156 return [h * 360, s * 100, v * 100];
7159 convert$3.rgb.hwb = function (rgb) {
7163 var h = convert$3.rgb.hsl(rgb)[0];
7164 var w = 1 / 255 * Math.min(r, Math.min(g, b));
7165 b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
7166 return [h, w * 100, b * 100];
7169 convert$3.rgb.cmyk = function (rgb) {
7170 var r = rgb[0] / 255;
7171 var g = rgb[1] / 255;
7172 var b = rgb[2] / 255;
7177 k = Math.min(1 - r, 1 - g, 1 - b);
7178 c = (1 - r - k) / (1 - k) || 0;
7179 m = (1 - g - k) / (1 - k) || 0;
7180 y = (1 - b - k) / (1 - k) || 0;
7181 return [c * 100, m * 100, y * 100, k * 100];
7184 * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
7188 function comparativeDistance$1(x, y) {
7189 return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
7192 convert$3.rgb.keyword = function (rgb) {
7193 var reversed = reverseKeywords$1[rgb];
7199 var currentClosestDistance = Infinity;
7200 var currentClosestKeyword;
7202 for (var keyword in cssKeywords$1) {
7203 if (cssKeywords$1.hasOwnProperty(keyword)) {
7204 var value = cssKeywords$1[keyword]; // Compute comparative distance
7206 var distance = comparativeDistance$1(rgb, value); // Check if its less, if so set as closest
7208 if (distance < currentClosestDistance) {
7209 currentClosestDistance = distance;
7210 currentClosestKeyword = keyword;
7215 return currentClosestKeyword;
7218 convert$3.keyword.rgb = function (keyword) {
7219 return cssKeywords$1[keyword];
7222 convert$3.rgb.xyz = function (rgb) {
7223 var r = rgb[0] / 255;
7224 var g = rgb[1] / 255;
7225 var b = rgb[2] / 255; // assume sRGB
7227 r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
7228 g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
7229 b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
7230 var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
7231 var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
7232 var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
7233 return [x * 100, y * 100, z * 100];
7236 convert$3.rgb.lab = function (rgb) {
7237 var xyz = convert$3.rgb.xyz(rgb);
7247 x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
7248 y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
7249 z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
7256 convert$3.hsl.rgb = function (hsl) {
7257 var h = hsl[0] / 360;
7258 var s = hsl[1] / 100;
7259 var l = hsl[2] / 100;
7268 return [val, val, val];
7280 for (var i = 0; i < 3; i++) {
7281 t3 = h + 1 / 3 * -(i - 1);
7292 val = t1 + (t2 - t1) * 6 * t3;
7293 } else if (2 * t3 < 1) {
7295 } else if (3 * t3 < 2) {
7296 val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
7307 convert$3.hsl.hsv = function (hsl) {
7309 var s = hsl[1] / 100;
7310 var l = hsl[2] / 100;
7312 var lmin = Math.max(l, 0.01);
7316 s *= l <= 1 ? l : 2 - l;
7317 smin *= lmin <= 1 ? lmin : 2 - lmin;
7319 sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
7320 return [h, sv * 100, v * 100];
7323 convert$3.hsv.rgb = function (hsv) {
7324 var h = hsv[0] / 60;
7325 var s = hsv[1] / 100;
7326 var v = hsv[2] / 100;
7327 var hi = Math.floor(h) % 6;
7328 var f = h - Math.floor(h);
7329 var p = 255 * v * (1 - s);
7330 var q = 255 * v * (1 - s * f);
7331 var t = 255 * v * (1 - s * (1 - f));
7355 convert$3.hsv.hsl = function (hsv) {
7357 var s = hsv[1] / 100;
7358 var v = hsv[2] / 100;
7359 var vmin = Math.max(v, 0.01);
7364 lmin = (2 - s) * vmin;
7366 sl /= lmin <= 1 ? lmin : 2 - lmin;
7369 return [h, sl * 100, l * 100];
7370 }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
7373 convert$3.hwb.rgb = function (hwb) {
7374 var h = hwb[0] / 360;
7375 var wh = hwb[1] / 100;
7376 var bl = hwb[2] / 100;
7377 var ratio = wh + bl;
7381 var n; // wh + bl cant be > 1
7388 i = Math.floor(6 * h);
7392 if ((i & 0x01) !== 0) {
7396 n = wh + f * (v - wh); // linear interpolation
7442 return [r * 255, g * 255, b * 255];
7445 convert$3.cmyk.rgb = function (cmyk) {
7446 var c = cmyk[0] / 100;
7447 var m = cmyk[1] / 100;
7448 var y = cmyk[2] / 100;
7449 var k = cmyk[3] / 100;
7453 r = 1 - Math.min(1, c * (1 - k) + k);
7454 g = 1 - Math.min(1, m * (1 - k) + k);
7455 b = 1 - Math.min(1, y * (1 - k) + k);
7456 return [r * 255, g * 255, b * 255];
7459 convert$3.xyz.rgb = function (xyz) {
7460 var x = xyz[0] / 100;
7461 var y = xyz[1] / 100;
7462 var z = xyz[2] / 100;
7466 r = x * 3.2406 + y * -1.5372 + z * -0.4986;
7467 g = x * -0.9689 + y * 1.8758 + z * 0.0415;
7468 b = x * 0.0557 + y * -0.2040 + z * 1.0570; // assume sRGB
7470 r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
7471 g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
7472 b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
7473 r = Math.min(Math.max(0, r), 1);
7474 g = Math.min(Math.max(0, g), 1);
7475 b = Math.min(Math.max(0, b), 1);
7476 return [r * 255, g * 255, b * 255];
7479 convert$3.xyz.lab = function (xyz) {
7489 x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
7490 y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
7491 z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
7498 convert$3.lab.xyz = function (lab) {
7508 var y2 = Math.pow(y, 3);
7509 var x2 = Math.pow(x, 3);
7510 var z2 = Math.pow(z, 3);
7511 y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
7512 x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
7513 z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
7520 convert$3.lab.lch = function (lab) {
7527 hr = Math.atan2(b, a);
7528 h = hr * 360 / 2 / Math.PI;
7534 c = Math.sqrt(a * a + b * b);
7538 convert$3.lch.lab = function (lch) {
7545 hr = h / 360 * 2 * Math.PI;
7546 a = c * Math.cos(hr);
7547 b = c * Math.sin(hr);
7551 convert$3.rgb.ansi16 = function (args) {
7555 var value = 1 in arguments ? arguments[1] : convert$3.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
7557 value = Math.round(value / 50);
7563 var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
7572 convert$3.hsv.ansi16 = function (args) {
7573 // optimization here; we already know the value and don't need to get
7574 // it converted for us.
7575 return convert$3.rgb.ansi16(convert$3.hsv.rgb(args), args[2]);
7578 convert$3.rgb.ansi256 = function (args) {
7581 var b = args[2]; // we use the extended greyscale palette here, with the exception of
7582 // black and white. normal palette only has 4 greyscale shades.
7584 if (r === g && g === b) {
7593 return Math.round((r - 8) / 247 * 24) + 232;
7596 var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
7600 convert$3.ansi16.rgb = function (args) {
7601 var color = args % 10; // handle greyscale
7603 if (color === 0 || color === 7) {
7608 color = color / 10.5 * 255;
7609 return [color, color, color];
7612 var mult = (~~(args > 50) + 1) * 0.5;
7613 var r = (color & 1) * mult * 255;
7614 var g = (color >> 1 & 1) * mult * 255;
7615 var b = (color >> 2 & 1) * mult * 255;
7619 convert$3.ansi256.rgb = function (args) {
7622 var c = (args - 232) * 10 + 8;
7628 var r = Math.floor(args / 36) / 5 * 255;
7629 var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
7630 var b = rem % 6 / 5 * 255;
7634 convert$3.rgb.hex = function (args) {
7635 var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
7636 var string = integer.toString(16).toUpperCase();
7637 return '000000'.substring(string.length) + string;
7640 convert$3.hex.rgb = function (args) {
7641 var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
7647 var colorString = match[0];
7649 if (match[0].length === 3) {
7650 colorString = colorString.split('').map(function (char) {
7655 var integer = parseInt(colorString, 16);
7656 var r = integer >> 16 & 0xFF;
7657 var g = integer >> 8 & 0xFF;
7658 var b = integer & 0xFF;
7662 convert$3.rgb.hcg = function (rgb) {
7663 var r = rgb[0] / 255;
7664 var g = rgb[1] / 255;
7665 var b = rgb[2] / 255;
7666 var max = Math.max(Math.max(r, g), b);
7667 var min = Math.min(Math.min(r, g), b);
7668 var chroma = max - min;
7673 grayscale = min / (1 - chroma);
7680 } else if (max === r) {
7681 hue = (g - b) / chroma % 6;
7682 } else if (max === g) {
7683 hue = 2 + (b - r) / chroma;
7685 hue = 4 + (r - g) / chroma + 4;
7690 return [hue * 360, chroma * 100, grayscale * 100];
7693 convert$3.hsl.hcg = function (hsl) {
7694 var s = hsl[1] / 100;
7695 var l = hsl[2] / 100;
7702 c = 2.0 * s * (1.0 - l);
7706 f = (l - 0.5 * c) / (1.0 - c);
7709 return [hsl[0], c * 100, f * 100];
7712 convert$3.hsv.hcg = function (hsv) {
7713 var s = hsv[1] / 100;
7714 var v = hsv[2] / 100;
7719 f = (v - c) / (1 - c);
7722 return [hsv[0], c * 100, f * 100];
7725 convert$3.hcg.rgb = function (hcg) {
7726 var h = hcg[0] / 360;
7727 var c = hcg[1] / 100;
7728 var g = hcg[2] / 100;
7731 return [g * 255, g * 255, g * 255];
7734 var pure = [0, 0, 0];
7740 switch (Math.floor(hi)) {
7778 return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
7781 convert$3.hcg.hsv = function (hcg) {
7782 var c = hcg[1] / 100;
7783 var g = hcg[2] / 100;
7784 var v = c + g * (1.0 - c);
7791 return [hcg[0], f * 100, v * 100];
7794 convert$3.hcg.hsl = function (hcg) {
7795 var c = hcg[1] / 100;
7796 var g = hcg[2] / 100;
7797 var l = g * (1.0 - c) + 0.5 * c;
7800 if (l > 0.0 && l < 0.5) {
7802 } else if (l >= 0.5 && l < 1.0) {
7803 s = c / (2 * (1 - l));
7806 return [hcg[0], s * 100, l * 100];
7809 convert$3.hcg.hwb = function (hcg) {
7810 var c = hcg[1] / 100;
7811 var g = hcg[2] / 100;
7812 var v = c + g * (1.0 - c);
7813 return [hcg[0], (v - c) * 100, (1 - v) * 100];
7816 convert$3.hwb.hcg = function (hwb) {
7817 var w = hwb[1] / 100;
7818 var b = hwb[2] / 100;
7824 g = (v - c) / (1 - c);
7827 return [hwb[0], c * 100, g * 100];
7830 convert$3.apple.rgb = function (apple) {
7831 return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
7834 convert$3.rgb.apple = function (rgb) {
7835 return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
7838 convert$3.gray.rgb = function (args) {
7839 return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
7842 convert$3.gray.hsl = convert$3.gray.hsv = function (args) {
7843 return [0, 0, args[0]];
7846 convert$3.gray.hwb = function (gray) {
7847 return [0, 100, gray[0]];
7850 convert$3.gray.cmyk = function (gray) {
7851 return [0, 0, 0, gray[0]];
7854 convert$3.gray.lab = function (gray) {
7855 return [gray[0], 0, 0];
7858 convert$3.gray.hex = function (gray) {
7859 var val = Math.round(gray[0] / 100 * 255) & 0xFF;
7860 var integer = (val << 16) + (val << 8) + val;
7861 var string = integer.toString(16).toUpperCase();
7862 return '000000'.substring(string.length) + string;
7865 convert$3.rgb.gray = function (rgb) {
7866 var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
7867 return [val / 255 * 100];
7870 var conversions$4 = conversions$5.exports;
7872 this function routes a model to all other models.
7874 all functions that are routed have a property `.conversion` attached
7875 to the returned synthetic function. This property is an array
7876 of strings, each with the steps in between the 'from' and 'to'
7877 color models (inclusive).
7879 conversions that are not possible simply are not included.
7882 function buildGraph$1() {
7883 var graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3
7885 var models = Object.keys(conversions$4);
7887 for (var len = models.length, i = 0; i < len; i++) {
7888 graph[models[i]] = {
7889 // http://jsperf.com/1-vs-infinity
7890 // micro-opt, but this is simple.
7897 } // https://en.wikipedia.org/wiki/Breadth-first_search
7900 function deriveBFS$1(fromModel) {
7901 var graph = buildGraph$1();
7902 var queue = [fromModel]; // unshift -> queue -> pop
7904 graph[fromModel].distance = 0;
7906 while (queue.length) {
7907 var current = queue.pop();
7908 var adjacents = Object.keys(conversions$4[current]);
7910 for (var len = adjacents.length, i = 0; i < len; i++) {
7911 var adjacent = adjacents[i];
7912 var node = graph[adjacent];
7914 if (node.distance === -1) {
7915 node.distance = graph[current].distance + 1;
7916 node.parent = current;
7917 queue.unshift(adjacent);
7925 function link$2(from, to) {
7926 return function (args) {
7927 return to(from(args));
7931 function wrapConversion$1(toModel, graph) {
7932 var path = [graph[toModel].parent, toModel];
7933 var fn = conversions$4[graph[toModel].parent][toModel];
7934 var cur = graph[toModel].parent;
7936 while (graph[cur].parent) {
7937 path.unshift(graph[cur].parent);
7938 fn = link$2(conversions$4[graph[cur].parent][cur], fn);
7939 cur = graph[cur].parent;
7942 fn.conversion = path;
7946 var route$3 = function (fromModel) {
7947 var graph = deriveBFS$1(fromModel);
7948 var conversion = {};
7949 var models = Object.keys(graph);
7951 for (var len = models.length, i = 0; i < len; i++) {
7952 var toModel = models[i];
7953 var node = graph[toModel];
7955 if (node.parent === null) {
7956 // no possible conversion, or this node is the source model.
7960 conversion[toModel] = wrapConversion$1(toModel, graph);
7966 var conversions$3 = conversions$5.exports;
7967 var route$2 = route$3;
7969 var models$1 = Object.keys(conversions$3);
7971 function wrapRaw$1(fn) {
7972 var wrappedFn = function (args) {
7973 if (args === undefined || args === null) {
7977 if (arguments.length > 1) {
7978 args = Array.prototype.slice.call(arguments);
7982 }; // preserve .conversion property if there is one
7985 if ('conversion' in fn) {
7986 wrappedFn.conversion = fn.conversion;
7992 function wrapRounded$1(fn) {
7993 var wrappedFn = function (args) {
7994 if (args === undefined || args === null) {
7998 if (arguments.length > 1) {
7999 args = Array.prototype.slice.call(arguments);
8002 var result = fn(args); // we're assuming the result is an array here.
8003 // see notice in conversions.js; don't use box types
8004 // in conversion functions.
8006 if (typeof result === 'object') {
8007 for (var len = result.length, i = 0; i < len; i++) {
8008 result[i] = Math.round(result[i]);
8013 }; // preserve .conversion property if there is one
8016 if ('conversion' in fn) {
8017 wrappedFn.conversion = fn.conversion;
8023 models$1.forEach(function (fromModel) {
8024 convert$2[fromModel] = {};
8025 Object.defineProperty(convert$2[fromModel], 'channels', {
8026 value: conversions$3[fromModel].channels
8028 Object.defineProperty(convert$2[fromModel], 'labels', {
8029 value: conversions$3[fromModel].labels
8031 var routes = route$2(fromModel);
8032 var routeModels = Object.keys(routes);
8033 routeModels.forEach(function (toModel) {
8034 var fn = routes[toModel];
8035 convert$2[fromModel][toModel] = wrapRounded$1(fn);
8036 convert$2[fromModel][toModel].raw = wrapRaw$1(fn);
8039 var colorConvert$1 = convert$2;
8041 (function (module) {
8043 const colorConvert = colorConvert$1;
8045 const wrapAnsi16 = (fn, offset) => function () {
8046 const code = fn.apply(colorConvert, arguments);
8047 return `\u001B[${code + offset}m`;
8050 const wrapAnsi256 = (fn, offset) => function () {
8051 const code = fn.apply(colorConvert, arguments);
8052 return `\u001B[${38 + offset};5;${code}m`;
8055 const wrapAnsi16m = (fn, offset) => function () {
8056 const rgb = fn.apply(colorConvert, arguments);
8057 return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
8060 function assembleStyles() {
8061 const codes = new Map();
8065 // 21 isn't widely supported and 22 does the same thing
8072 strikethrough: [9, 29]
8085 redBright: [91, 39],
8086 greenBright: [92, 39],
8087 yellowBright: [93, 39],
8088 blueBright: [94, 39],
8089 magentaBright: [95, 39],
8090 cyanBright: [96, 39],
8091 whiteBright: [97, 39]
8099 bgMagenta: [45, 49],
8103 bgBlackBright: [100, 49],
8104 bgRedBright: [101, 49],
8105 bgGreenBright: [102, 49],
8106 bgYellowBright: [103, 49],
8107 bgBlueBright: [104, 49],
8108 bgMagentaBright: [105, 49],
8109 bgCyanBright: [106, 49],
8110 bgWhiteBright: [107, 49]
8114 styles.color.grey = styles.color.gray;
8116 for (const groupName of Object.keys(styles)) {
8117 const group = styles[groupName];
8119 for (const styleName of Object.keys(group)) {
8120 const style = group[styleName];
8121 styles[styleName] = {
8122 open: `\u001B[${style[0]}m`,
8123 close: `\u001B[${style[1]}m`
8125 group[styleName] = styles[styleName];
8126 codes.set(style[0], style[1]);
8129 Object.defineProperty(styles, groupName, {
8133 Object.defineProperty(styles, 'codes', {
8139 const ansi2ansi = n => n;
8141 const rgb2rgb = (r, g, b) => [r, g, b];
8143 styles.color.close = '\u001B[39m';
8144 styles.bgColor.close = '\u001B[49m';
8145 styles.color.ansi = {
8146 ansi: wrapAnsi16(ansi2ansi, 0)
8148 styles.color.ansi256 = {
8149 ansi256: wrapAnsi256(ansi2ansi, 0)
8151 styles.color.ansi16m = {
8152 rgb: wrapAnsi16m(rgb2rgb, 0)
8154 styles.bgColor.ansi = {
8155 ansi: wrapAnsi16(ansi2ansi, 10)
8157 styles.bgColor.ansi256 = {
8158 ansi256: wrapAnsi256(ansi2ansi, 10)
8160 styles.bgColor.ansi16m = {
8161 rgb: wrapAnsi16m(rgb2rgb, 10)
8164 for (let key of Object.keys(colorConvert)) {
8165 if (typeof colorConvert[key] !== 'object') {
8169 const suite = colorConvert[key];
8171 if (key === 'ansi16') {
8175 if ('ansi16' in suite) {
8176 styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
8177 styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
8180 if ('ansi256' in suite) {
8181 styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
8182 styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
8185 if ('rgb' in suite) {
8186 styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
8187 styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
8192 } // Make the export immutable
8195 Object.defineProperty(module, 'exports', {
8201 var hasFlag$5 = (flag, argv) => {
8202 argv = argv || process.argv;
8203 const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
8204 const pos = argv.indexOf(prefix + flag);
8205 const terminatorPos = argv.indexOf('--');
8206 return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
8209 const os$4 = require$$0__default$1["default"];
8210 const hasFlag$4 = hasFlag$5;
8211 const env$2 = process.env;
8214 if (hasFlag$4('no-color') || hasFlag$4('no-colors') || hasFlag$4('color=false')) {
8215 forceColor$2 = false;
8216 } else if (hasFlag$4('color') || hasFlag$4('colors') || hasFlag$4('color=true') || hasFlag$4('color=always')) {
8217 forceColor$2 = true;
8220 if ('FORCE_COLOR' in env$2) {
8221 forceColor$2 = env$2.FORCE_COLOR.length === 0 || parseInt(env$2.FORCE_COLOR, 10) !== 0;
8224 function translateLevel$2(level) {
8237 function supportsColor$2(stream) {
8238 if (forceColor$2 === false) {
8242 if (hasFlag$4('color=16m') || hasFlag$4('color=full') || hasFlag$4('color=truecolor')) {
8246 if (hasFlag$4('color=256')) {
8250 if (stream && !stream.isTTY && forceColor$2 !== true) {
8254 const min = forceColor$2 ? 1 : 0;
8256 if (process.platform === 'win32') {
8257 // Node.js 7.5.0 is the first version of Node.js to include a patch to
8258 // libuv that enables 256 color output on Windows. Anything earlier and it
8259 // won't work. However, here we target Node.js 8 at minimum as it is an LTS
8260 // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
8261 // release that supports 256 colors. Windows 10 build 14931 is the first release
8262 // that supports 16m/TrueColor.
8263 const osRelease = os$4.release().split('.');
8265 if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
8266 return Number(osRelease[2]) >= 14931 ? 3 : 2;
8272 if ('CI' in env$2) {
8273 if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env$2) || env$2.CI_NAME === 'codeship') {
8280 if ('TEAMCITY_VERSION' in env$2) {
8281 return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$2.TEAMCITY_VERSION) ? 1 : 0;
8284 if (env$2.COLORTERM === 'truecolor') {
8288 if ('TERM_PROGRAM' in env$2) {
8289 const version = parseInt((env$2.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
8291 switch (env$2.TERM_PROGRAM) {
8293 return version >= 3 ? 3 : 2;
8295 case 'Apple_Terminal':
8301 if (/-256(color)?$/i.test(env$2.TERM)) {
8305 if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$2.TERM)) {
8309 if ('COLORTERM' in env$2) {
8313 if (env$2.TERM === 'dumb') {
8320 function getSupportLevel$2(stream) {
8321 const level = supportsColor$2(stream);
8322 return translateLevel$2(level);
8325 var supportsColor_1$2 = {
8326 supportsColor: getSupportLevel$2,
8327 stdout: getSupportLevel$2(process.stdout),
8328 stderr: getSupportLevel$2(process.stderr)
8331 const TEMPLATE_REGEX$2 = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
8332 const STYLE_REGEX$2 = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
8333 const STRING_REGEX$3 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
8334 const ESCAPE_REGEX$2 = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
8335 const ESCAPES$2 = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
8337 function unescape$2(c) {
8338 if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
8339 return String.fromCharCode(parseInt(c.slice(1), 16));
8342 return ESCAPES$2.get(c) || c;
8345 function parseArguments$2(name, args) {
8347 const chunks = args.trim().split(/\s*,\s*/g);
8350 for (const chunk of chunks) {
8351 if (!isNaN(chunk)) {
8352 results.push(Number(chunk));
8353 } else if (matches = chunk.match(STRING_REGEX$3)) {
8354 results.push(matches[2].replace(ESCAPE_REGEX$2, (m, escape, chr) => escape ? unescape$2(escape) : chr));
8356 throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
8363 function parseStyle$2(style) {
8364 STYLE_REGEX$2.lastIndex = 0;
8368 while ((matches = STYLE_REGEX$2.exec(style)) !== null) {
8369 const name = matches[1];
8372 const args = parseArguments$2(name, matches[2]);
8373 results.push([name].concat(args));
8375 results.push([name]);
8382 function buildStyle$2(chalk, styles) {
8385 for (const layer of styles) {
8386 for (const style of layer.styles) {
8387 enabled[style[0]] = layer.inverse ? null : style.slice(1);
8391 let current = chalk;
8393 for (const styleName of Object.keys(enabled)) {
8394 if (Array.isArray(enabled[styleName])) {
8395 if (!(styleName in current)) {
8396 throw new Error(`Unknown Chalk style: ${styleName}`);
8399 if (enabled[styleName].length > 0) {
8400 current = current[styleName].apply(current, enabled[styleName]);
8402 current = current[styleName];
8410 var templates$2 = (chalk, tmp) => {
8413 let chunk = []; // eslint-disable-next-line max-params
8415 tmp.replace(TEMPLATE_REGEX$2, (m, escapeChar, inverse, style, close, chr) => {
8417 chunk.push(unescape$2(escapeChar));
8419 const str = chunk.join('');
8421 chunks.push(styles.length === 0 ? str : buildStyle$2(chalk, styles)(str));
8424 styles: parseStyle$2(style)
8427 if (styles.length === 0) {
8428 throw new Error('Found extraneous } in Chalk template literal');
8431 chunks.push(buildStyle$2(chalk, styles)(chunk.join('')));
8438 chunks.push(chunk.join(''));
8440 if (styles.length > 0) {
8441 const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
8442 throw new Error(errMsg);
8445 return chunks.join('');
8448 (function (module) {
8450 const escapeStringRegexp = escapeStringRegexp$1;
8451 const ansiStyles = ansiStyles$2.exports;
8452 const stdoutColor = supportsColor_1$2.stdout;
8453 const template = templates$2;
8454 const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
8456 const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
8458 const skipModels = new Set(['gray']);
8459 const styles = Object.create(null);
8461 function applyOptions(obj, options) {
8462 options = options || {}; // Detect level if not set manually
8464 const scLevel = stdoutColor ? stdoutColor.level : 0;
8465 obj.level = options.level === undefined ? scLevel : options.level;
8466 obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
8469 function Chalk(options) {
8470 // We check for this.template here since calling `chalk.constructor()`
8471 // by itself will have a `this` of a previously constructed chalk object
8472 if (!this || !(this instanceof Chalk) || this.template) {
8474 applyOptions(chalk, options);
8476 chalk.template = function () {
8477 const args = [].slice.call(arguments);
8478 return chalkTag.apply(null, [chalk.template].concat(args));
8481 Object.setPrototypeOf(chalk, Chalk.prototype);
8482 Object.setPrototypeOf(chalk.template, chalk);
8483 chalk.template.constructor = Chalk;
8484 return chalk.template;
8487 applyOptions(this, options);
8488 } // Use bright blue on Windows as the normal blue color is illegible
8491 if (isSimpleWindowsTerm) {
8492 ansiStyles.blue.open = '\u001B[94m';
8495 for (const key of Object.keys(ansiStyles)) {
8496 ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
8499 const codes = ansiStyles[key];
8500 return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
8508 return build.call(this, this._styles || [], true, 'visible');
8512 ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
8514 for (const model of Object.keys(ansiStyles.color.ansi)) {
8515 if (skipModels.has(model)) {
8521 const level = this.level;
8522 return function () {
8523 const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
8526 close: ansiStyles.color.close,
8527 closeRe: ansiStyles.color.closeRe
8529 return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
8536 ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
8538 for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
8539 if (skipModels.has(model)) {
8543 const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
8546 const level = this.level;
8547 return function () {
8548 const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
8551 close: ansiStyles.bgColor.close,
8552 closeRe: ansiStyles.bgColor.closeRe
8554 return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
8561 const proto = Object.defineProperties(() => {}, styles);
8563 function build(_styles, _empty, key) {
8564 const builder = function () {
8565 return applyStyle.apply(builder, arguments);
8568 builder._styles = _styles;
8569 builder._empty = _empty;
8571 Object.defineProperty(builder, 'level', {
8583 Object.defineProperty(builder, 'enabled', {
8587 return self.enabled;
8591 self.enabled = enabled;
8594 }); // See below for fix regarding invisible grey/dim combination on Windows
8596 builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
8597 // no way to create a function with a different prototype
8599 builder.__proto__ = proto; // eslint-disable-line no-proto
8604 function applyStyle() {
8605 // Support varags, but simply cast to string in case there's only one arg
8606 const args = arguments;
8607 const argsLen = args.length;
8608 let str = String(arguments[0]);
8610 if (argsLen === 0) {
8615 // Don't slice `arguments`, it prevents V8 optimizations
8616 for (let a = 1; a < argsLen; a++) {
8617 str += ' ' + args[a];
8621 if (!this.enabled || this.level <= 0 || !str) {
8622 return this._empty ? '' : str;
8623 } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
8624 // see https://github.com/chalk/chalk/issues/58
8625 // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
8628 const originalDim = ansiStyles.dim.open;
8630 if (isSimpleWindowsTerm && this.hasGrey) {
8631 ansiStyles.dim.open = '';
8634 for (const code of this._styles.slice().reverse()) {
8635 // Replace any instances already present with a re-opening code
8636 // otherwise only the part of the string until said closing code
8637 // will be colored, and the rest will simply be 'plain'.
8638 str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
8639 // after next line to fix a bleed issue on macOS
8640 // https://github.com/chalk/chalk/pull/92
8642 str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
8643 } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
8646 ansiStyles.dim.open = originalDim;
8650 function chalkTag(chalk, strings) {
8651 if (!Array.isArray(strings)) {
8652 // If chalk() was called by itself or with a string,
8653 // return the string itself as a string.
8654 return [].slice.call(arguments, 1).join(' ');
8657 const args = [].slice.call(arguments, 2);
8658 const parts = [strings.raw[0]];
8660 for (let i = 1; i < strings.length; i++) {
8661 parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
8662 parts.push(String(strings.raw[i]));
8665 return template(chalk, parts.join(''));
8668 Object.defineProperties(Chalk.prototype, styles);
8669 module.exports = Chalk(); // eslint-disable-line new-cap
8671 module.exports.supportsColor = stdoutColor;
8672 module.exports.default = module.exports; // For TypeScript
8675 Object.defineProperty(common$8, "__esModule", {
8678 const chalk_1$2 = chalk$3.exports;
8680 common$8.commonDeprecatedHandler = (keyOrPair, redirectTo, {
8683 const messages = [`${chalk_1$2.default.yellow(typeof keyOrPair === 'string' ? descriptor.key(keyOrPair) : descriptor.pair(keyOrPair))} is deprecated`];
8686 messages.push(`we now treat it as ${chalk_1$2.default.blue(typeof redirectTo === 'string' ? descriptor.key(redirectTo) : descriptor.pair(redirectTo))}`);
8689 return messages.join('; ') + '.';
8692 (function (exports) {
8694 Object.defineProperty(exports, "__esModule", {
8697 const tslib_1 = tslib_es6;
8699 tslib_1.__exportStar(common$8, exports);
8706 Object.defineProperty(common$7, "__esModule", {
8709 const chalk_1$1 = chalk$3.exports;
8711 common$7.commonInvalidHandler = (key, value, utils) => [`Invalid ${chalk_1$1.default.red(utils.descriptor.key(key))} value.`, `Expected ${chalk_1$1.default.blue(utils.schemas[key].expected(utils))},`, `but received ${chalk_1$1.default.red(utils.descriptor.value(value))}.`].join(' ');
8713 (function (exports) {
8715 Object.defineProperty(exports, "__esModule", {
8718 const tslib_1 = tslib_es6;
8720 tslib_1.__exportStar(common$7, exports);
8727 /* eslint-disable no-nested-ternary */
8730 var charCodeCache$1 = [];
8732 var leven$4 = function (a, b) {
8737 var swap = a; // Swapping the strings if `a` is longer than `b` so we know which one is the
8738 // shortest & which one is the longest
8740 if (a.length > b.length) {
8745 var aLen = a.length;
8746 var bLen = b.length;
8754 } // Performing suffix trimming:
8755 // We can linearly drop suffix common to both strings since they
8756 // don't increase distance at all
8757 // Note: `~-` is the bitwise way to perform a `- 1` operation
8760 while (aLen > 0 && a.charCodeAt(~-aLen) === b.charCodeAt(~-bLen)) {
8767 } // Performing prefix trimming
8768 // We can linearly drop prefix common to both strings since they
8769 // don't increase distance at all
8774 while (start < aLen && a.charCodeAt(start) === b.charCodeAt(start)) {
8793 charCodeCache$1[start + i] = a.charCodeAt(start + i);
8798 bCharCode = b.charCodeAt(start + j);
8802 for (i = 0; i < aLen; i++) {
8803 tmp2 = bCharCode === charCodeCache$1[start + i] ? tmp : tmp + 1;
8805 ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
8812 Object.defineProperty(leven$5, "__esModule", {
8815 const chalk_1 = chalk$3.exports;
8816 const leven$3 = leven$4;
8818 leven$5.levenUnknownHandler = (key, value, {
8823 const messages = [`Ignored unknown option ${chalk_1.default.yellow(descriptor.pair({
8827 const suggestion = Object.keys(schemas).sort().find(knownKey => leven$3(key, knownKey) < 3);
8830 messages.push(`Did you mean ${chalk_1.default.blue(descriptor.key(suggestion))}?`);
8833 logger.warn(messages.join(' '));
8836 (function (exports) {
8838 Object.defineProperty(exports, "__esModule", {
8841 const tslib_1 = tslib_es6;
8843 tslib_1.__exportStar(leven$5, exports);
8846 (function (exports) {
8848 Object.defineProperty(exports, "__esModule", {
8851 const tslib_1 = tslib_es6;
8853 tslib_1.__exportStar(deprecated, exports);
8855 tslib_1.__exportStar(invalid, exports);
8857 tslib_1.__exportStar(unknown, exports);
8866 Object.defineProperty(schema, "__esModule", {
8869 const HANDLER_KEYS = ['default', 'expected', 'validate', 'deprecated', 'forward', 'redirect', 'overlap', 'preprocess', 'postprocess'];
8871 function createSchema(SchemaConstructor, parameters) {
8872 const schema = new SchemaConstructor(parameters);
8873 const subSchema = Object.create(schema);
8875 for (const handlerKey of HANDLER_KEYS) {
8876 if (handlerKey in parameters) {
8877 subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema, Schema.prototype[handlerKey].length);
8884 schema.createSchema = createSchema;
8887 constructor(parameters) {
8888 this.name = parameters.name;
8891 static create(parameters) {
8892 // @ts-ignore: https://github.com/Microsoft/TypeScript/issues/5863
8893 return createSchema(this, parameters);
8898 } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
8903 } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
8906 validate(_value, _utils) {
8910 deprecated(_value, _utils) {
8914 forward(_value, _utils) {
8918 redirect(_value, _utils) {
8922 overlap(currentValue, _newValue, _utils) {
8923 return currentValue;
8926 preprocess(value, _utils) {
8930 postprocess(value, _utils) {
8936 schema.Schema = Schema;
8938 function normalizeHandler(handler, superSchema, handlerArgumentsLength) {
8939 return typeof handler === 'function' ? (...args) => handler(...args.slice(0, handlerArgumentsLength - 1), superSchema, ...args.slice(handlerArgumentsLength - 1)) : () => handler;
8942 Object.defineProperty(alias, "__esModule", {
8945 const schema_1$6 = schema;
8947 class AliasSchema extends schema_1$6.Schema {
8948 constructor(parameters) {
8950 this._sourceName = parameters.sourceName;
8954 return utils.schemas[this._sourceName].expected(utils);
8957 validate(value, utils) {
8958 return utils.schemas[this._sourceName].validate(value, utils);
8961 redirect(_value, _utils) {
8962 return this._sourceName;
8967 alias.AliasSchema = AliasSchema;
8971 Object.defineProperty(any, "__esModule", {
8974 const schema_1$5 = schema;
8976 class AnySchema extends schema_1$5.Schema {
8987 any.AnySchema = AnySchema;
8991 Object.defineProperty(array$4, "__esModule", {
8994 const tslib_1 = tslib_es6;
8995 const schema_1$4 = schema;
8997 class ArraySchema extends schema_1$4.Schema {
9001 name = valueSchema.name
9003 handlers = tslib_1.__rest(_a, ["valueSchema", "name"]);
9005 super(Object.assign({}, handlers, {
9008 this._valueSchema = valueSchema;
9012 return `an array of ${this._valueSchema.expected(utils)}`;
9015 validate(value, utils) {
9016 if (!Array.isArray(value)) {
9020 const invalidValues = [];
9022 for (const subValue of value) {
9023 const subValidateResult = utils.normalizeValidateResult(this._valueSchema.validate(subValue, utils), subValue);
9025 if (subValidateResult !== true) {
9026 invalidValues.push(subValidateResult.value);
9030 return invalidValues.length === 0 ? true : {
9031 value: invalidValues
9035 deprecated(value, utils) {
9036 const deprecatedResult = [];
9038 for (const subValue of value) {
9039 const subDeprecatedResult = utils.normalizeDeprecatedResult(this._valueSchema.deprecated(subValue, utils), subValue);
9041 if (subDeprecatedResult !== false) {
9042 deprecatedResult.push(...subDeprecatedResult.map(({
9043 value: deprecatedValue
9045 value: [deprecatedValue]
9050 return deprecatedResult;
9053 forward(value, utils) {
9054 const forwardResult = [];
9056 for (const subValue of value) {
9057 const subForwardResult = utils.normalizeForwardResult(this._valueSchema.forward(subValue, utils), subValue);
9058 forwardResult.push(...subForwardResult.map(wrapTransferResult));
9061 return forwardResult;
9064 redirect(value, utils) {
9066 const redirect = [];
9068 for (const subValue of value) {
9069 const subRedirectResult = utils.normalizeRedirectResult(this._valueSchema.redirect(subValue, utils), subValue);
9071 if ('remain' in subRedirectResult) {
9072 remain.push(subRedirectResult.remain);
9075 redirect.push(...subRedirectResult.redirect.map(wrapTransferResult));
9078 return remain.length === 0 ? {
9086 overlap(currentValue, newValue) {
9087 return currentValue.concat(newValue);
9092 array$4.ArraySchema = ArraySchema;
9094 function wrapTransferResult({
9106 Object.defineProperty(boolean, "__esModule", {
9109 const schema_1$3 = schema;
9111 class BooleanSchema extends schema_1$3.Schema {
9113 return 'true or false';
9117 return typeof value === 'boolean';
9122 boolean.BooleanSchema = BooleanSchema;
9128 Object.defineProperty(utils$s, "__esModule", {
9132 function recordFromArray(array, mainKey) {
9133 const record = Object.create(null);
9135 for (const value of array) {
9136 const key = value[mainKey]; // istanbul ignore next
9139 throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`);
9143 record[key] = value;
9149 utils$s.recordFromArray = recordFromArray;
9151 function mapFromArray(array, mainKey) {
9152 const map = new Map();
9154 for (const value of array) {
9155 const key = value[mainKey]; // istanbul ignore next
9158 throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`);
9161 map.set(key, value);
9167 utils$s.mapFromArray = mapFromArray;
9169 function createAutoChecklist() {
9170 const map = Object.create(null);
9172 const idString = JSON.stringify(id);
9174 if (map[idString]) {
9178 map[idString] = true;
9183 utils$s.createAutoChecklist = createAutoChecklist;
9185 function partition$2(array, predicate) {
9186 const trueArray = [];
9187 const falseArray = [];
9189 for (const value of array) {
9190 if (predicate(value)) {
9191 trueArray.push(value);
9193 falseArray.push(value);
9197 return [trueArray, falseArray];
9200 utils$s.partition = partition$2;
9202 function isInt(value) {
9203 return value === Math.floor(value);
9206 utils$s.isInt = isInt;
9208 function comparePrimitive(a, b) {
9213 const typeofA = typeof a;
9214 const typeofB = typeof b;
9215 const orders = ['undefined', 'object', 'boolean', 'number', 'string'];
9217 if (typeofA !== typeofB) {
9218 return orders.indexOf(typeofA) - orders.indexOf(typeofB);
9221 if (typeofA !== 'string') {
9222 return Number(a) - Number(b);
9225 return a.localeCompare(b);
9228 utils$s.comparePrimitive = comparePrimitive;
9230 function normalizeDefaultResult(result) {
9231 return result === undefined ? {} : result;
9234 utils$s.normalizeDefaultResult = normalizeDefaultResult;
9236 function normalizeValidateResult(result, value) {
9237 return result === true ? true : result === false ? {
9242 utils$s.normalizeValidateResult = normalizeValidateResult;
9244 function normalizeDeprecatedResult(result, value, doNotNormalizeTrue = false) {
9245 return result === false ? false : result === true ? doNotNormalizeTrue ? true : [{
9247 }] : 'value' in result ? [result] : result.length === 0 ? false : result;
9250 utils$s.normalizeDeprecatedResult = normalizeDeprecatedResult;
9252 function normalizeTransferResult(result, value) {
9253 return typeof result === 'string' || 'key' in result ? {
9256 } : 'from' in result ? {
9265 utils$s.normalizeTransferResult = normalizeTransferResult;
9267 function normalizeForwardResult(result, value) {
9268 return result === undefined ? [] : Array.isArray(result) ? result.map(transferResult => normalizeTransferResult(transferResult, value)) : [normalizeTransferResult(result, value)];
9271 utils$s.normalizeForwardResult = normalizeForwardResult;
9273 function normalizeRedirectResult(result, value) {
9274 const redirect = normalizeForwardResult(typeof result === 'object' && 'redirect' in result ? result.redirect : result, value);
9275 return redirect.length === 0 ? {
9278 } : typeof result === 'object' && 'remain' in result ? {
9279 remain: result.remain,
9286 utils$s.normalizeRedirectResult = normalizeRedirectResult;
9288 Object.defineProperty(choice, "__esModule", {
9291 const schema_1$2 = schema;
9292 const utils_1$2 = utils$s;
9294 class ChoiceSchema extends schema_1$2.Schema {
9295 constructor(parameters) {
9297 this._choices = utils_1$2.mapFromArray(parameters.choices.map(choice => choice && typeof choice === 'object' ? choice : {
9305 const choiceValues = Array.from(this._choices.keys()).map(value => this._choices.get(value)).filter(choiceInfo => !choiceInfo.deprecated).map(choiceInfo => choiceInfo.value).sort(utils_1$2.comparePrimitive).map(descriptor.value);
9306 const head = choiceValues.slice(0, -2);
9307 const tail = choiceValues.slice(-2);
9308 return head.concat(tail.join(' or ')).join(', ');
9312 return this._choices.has(value);
9316 const choiceInfo = this._choices.get(value);
9318 return choiceInfo && choiceInfo.deprecated ? {
9324 const choiceInfo = this._choices.get(value);
9326 return choiceInfo ? choiceInfo.forward : undefined;
9330 const choiceInfo = this._choices.get(value);
9332 return choiceInfo ? choiceInfo.redirect : undefined;
9337 choice.ChoiceSchema = ChoiceSchema;
9343 Object.defineProperty(number, "__esModule", {
9346 const schema_1$1 = schema;
9348 class NumberSchema extends schema_1$1.Schema {
9353 validate(value, _utils) {
9354 return typeof value === 'number';
9359 number.NumberSchema = NumberSchema;
9361 Object.defineProperty(integer, "__esModule", {
9364 const utils_1$1 = utils$s;
9365 const number_1 = number;
9367 class IntegerSchema extends number_1.NumberSchema {
9369 return 'an integer';
9372 validate(value, utils) {
9373 return utils.normalizeValidateResult(super.validate(value, utils), value) === true && utils_1$1.isInt(value);
9378 integer.IntegerSchema = IntegerSchema;
9382 Object.defineProperty(string$2, "__esModule", {
9385 const schema_1 = schema;
9387 class StringSchema extends schema_1.Schema {
9393 return typeof value === 'string';
9398 string$2.StringSchema = StringSchema;
9400 (function (exports) {
9402 Object.defineProperty(exports, "__esModule", {
9405 const tslib_1 = tslib_es6;
9407 tslib_1.__exportStar(alias, exports);
9409 tslib_1.__exportStar(any, exports);
9411 tslib_1.__exportStar(array$4, exports);
9413 tslib_1.__exportStar(boolean, exports);
9415 tslib_1.__exportStar(choice, exports);
9417 tslib_1.__exportStar(integer, exports);
9419 tslib_1.__exportStar(number, exports);
9421 tslib_1.__exportStar(string$2, exports);
9424 var normalize$2 = {};
9428 Object.defineProperty(defaults, "__esModule", {
9432 const common_1 = common$8;
9433 const invalid_1 = invalid;
9434 const leven_1 = leven$5;
9435 defaults.defaultDescriptor = api_1.apiDescriptor;
9436 defaults.defaultUnknownHandler = leven_1.levenUnknownHandler;
9437 defaults.defaultInvalidHandler = invalid_1.commonInvalidHandler;
9438 defaults.defaultDeprecatedHandler = common_1.commonDeprecatedHandler;
9440 Object.defineProperty(normalize$2, "__esModule", {
9443 const defaults_1 = defaults;
9444 const utils_1 = utils$s;
9446 normalize$2.normalize = (options, schemas, opts) => new Normalizer(schemas, opts).normalize(options);
9449 constructor(schemas, opts) {
9450 // istanbul ignore next
9453 descriptor = defaults_1.defaultDescriptor,
9454 unknown = defaults_1.defaultUnknownHandler,
9455 invalid = defaults_1.defaultInvalidHandler,
9456 deprecated = defaults_1.defaultDeprecatedHandler
9461 /* istanbul ignore next */
9465 schemas: utils_1.recordFromArray(schemas, 'name'),
9466 normalizeDefaultResult: utils_1.normalizeDefaultResult,
9467 normalizeDeprecatedResult: utils_1.normalizeDeprecatedResult,
9468 normalizeForwardResult: utils_1.normalizeForwardResult,
9469 normalizeRedirectResult: utils_1.normalizeRedirectResult,
9470 normalizeValidateResult: utils_1.normalizeValidateResult
9472 this._unknownHandler = unknown;
9473 this._invalidHandler = invalid;
9474 this._deprecatedHandler = deprecated;
9475 this.cleanHistory();
9479 this._hasDeprecationWarned = utils_1.createAutoChecklist();
9482 normalize(options) {
9483 const normalized = {};
9484 const restOptionsArray = [options];
9486 const applyNormalization = () => {
9487 while (restOptionsArray.length !== 0) {
9488 const currentOptions = restOptionsArray.shift();
9490 const transferredOptionsArray = this._applyNormalization(currentOptions, normalized);
9492 restOptionsArray.push(...transferredOptionsArray);
9496 applyNormalization();
9498 for (const key of Object.keys(this._utils.schemas)) {
9499 const schema = this._utils.schemas[key];
9501 if (!(key in normalized)) {
9502 const defaultResult = utils_1.normalizeDefaultResult(schema.default(this._utils));
9504 if ('value' in defaultResult) {
9505 restOptionsArray.push({
9506 [key]: defaultResult.value
9512 applyNormalization();
9514 for (const key of Object.keys(this._utils.schemas)) {
9515 const schema = this._utils.schemas[key];
9517 if (key in normalized) {
9518 normalized[key] = schema.postprocess(normalized[key], this._utils);
9525 _applyNormalization(options, normalized) {
9526 const transferredOptionsArray = [];
9527 const [knownOptionNames, unknownOptionNames] = utils_1.partition(Object.keys(options), key => key in this._utils.schemas);
9529 for (const key of knownOptionNames) {
9530 const schema = this._utils.schemas[key];
9531 const value = schema.preprocess(options[key], this._utils);
9532 const validateResult = utils_1.normalizeValidateResult(schema.validate(value, this._utils), value);
9534 if (validateResult !== true) {
9539 const errorMessageOrError = this._invalidHandler(key, invalidValue, this._utils);
9541 throw typeof errorMessageOrError === 'string' ? new Error(errorMessageOrError) :
9542 /* istanbul ignore next*/
9543 errorMessageOrError;
9546 const appendTransferredOptions = ({
9550 transferredOptionsArray.push(typeof to === 'string' ? {
9557 const warnDeprecated = ({
9558 value: currentValue,
9561 const deprecatedResult = utils_1.normalizeDeprecatedResult(schema.deprecated(currentValue, this._utils), value,
9562 /* doNotNormalizeTrue */
9565 if (deprecatedResult === false) {
9569 if (deprecatedResult === true) {
9570 if (!this._hasDeprecationWarned(key)) {
9571 this._utils.logger.warn(this._deprecatedHandler(key, redirectTo, this._utils));
9575 value: deprecatedValue
9576 } of deprecatedResult) {
9579 value: deprecatedValue
9582 if (!this._hasDeprecationWarned(pair)) {
9583 const redirectToPair = typeof redirectTo === 'string' ? {
9585 value: deprecatedValue
9588 this._utils.logger.warn(this._deprecatedHandler(pair, redirectToPair, this._utils));
9594 const forwardResult = utils_1.normalizeForwardResult(schema.forward(value, this._utils), value);
9595 forwardResult.forEach(appendTransferredOptions);
9596 const redirectResult = utils_1.normalizeRedirectResult(schema.redirect(value, this._utils), value);
9597 redirectResult.redirect.forEach(appendTransferredOptions);
9599 if ('remain' in redirectResult) {
9600 const remainingValue = redirectResult.remain;
9601 normalized[key] = key in normalized ? schema.overlap(normalized[key], remainingValue, this._utils) : remainingValue;
9603 value: remainingValue
9610 } of redirectResult.redirect) {
9618 for (const key of unknownOptionNames) {
9619 const value = options[key];
9621 const unknownResult = this._unknownHandler(key, value, this._utils);
9623 if (unknownResult) {
9624 for (const unknownKey of Object.keys(unknownResult)) {
9625 const unknownOption = {
9626 [unknownKey]: unknownResult[unknownKey]
9629 if (unknownKey in this._utils.schemas) {
9630 transferredOptionsArray.push(unknownOption);
9632 Object.assign(normalized, unknownOption);
9638 return transferredOptionsArray;
9643 normalize$2.Normalizer = Normalizer;
9645 (function (exports) {
9647 Object.defineProperty(exports, "__esModule", {
9650 const tslib_1 = tslib_es6;
9652 tslib_1.__exportStar(descriptors, exports);
9654 tslib_1.__exportStar(handlers, exports);
9656 tslib_1.__exportStar(schemas, exports);
9658 tslib_1.__exportStar(normalize$2, exports);
9660 tslib_1.__exportStar(schema, exports);
9663 var leven$2 = {exports: {}};
9666 const charCodeCache = [];
9668 const leven$1 = (left, right) => {
9669 if (left === right) {
9673 const swap = left; // Swapping the strings if `a` is longer than `b` so we know which one is the
9674 // shortest & which one is the longest
9676 if (left.length > right.length) {
9681 let leftLength = left.length;
9682 let rightLength = right.length; // Performing suffix trimming:
9683 // We can linearly drop suffix common to both strings since they
9684 // don't increase distance at all
9685 // Note: `~-` is the bitwise way to perform a `- 1` operation
9687 while (leftLength > 0 && left.charCodeAt(~-leftLength) === right.charCodeAt(~-rightLength)) {
9690 } // Performing prefix trimming
9691 // We can linearly drop prefix common to both strings since they
9692 // don't increase distance at all
9697 while (start < leftLength && left.charCodeAt(start) === right.charCodeAt(start)) {
9701 leftLength -= start;
9702 rightLength -= start;
9704 if (leftLength === 0) {
9715 while (i < leftLength) {
9716 charCodeCache[i] = left.charCodeAt(start + i);
9720 while (j < rightLength) {
9721 bCharCode = right.charCodeAt(start + j);
9725 for (i = 0; i < leftLength; i++) {
9726 temp2 = bCharCode === charCodeCache[i] ? temp : temp + 1;
9727 temp = array$3[i]; // eslint-disable-next-line no-multi-assign
9729 result = array$3[i] = temp > result ? temp2 > result ? result + 1 : temp2 : temp2 > temp ? temp + 1 : temp2;
9736 leven$2.exports = leven$1; // TODO: Remove this for the next major release
9738 leven$2.exports.default = leven$1;
9740 var ansiStyles$1 = {exports: {}};
9743 "aliceblue": [240, 248, 255],
9744 "antiquewhite": [250, 235, 215],
9745 "aqua": [0, 255, 255],
9746 "aquamarine": [127, 255, 212],
9747 "azure": [240, 255, 255],
9748 "beige": [245, 245, 220],
9749 "bisque": [255, 228, 196],
9751 "blanchedalmond": [255, 235, 205],
9752 "blue": [0, 0, 255],
9753 "blueviolet": [138, 43, 226],
9754 "brown": [165, 42, 42],
9755 "burlywood": [222, 184, 135],
9756 "cadetblue": [95, 158, 160],
9757 "chartreuse": [127, 255, 0],
9758 "chocolate": [210, 105, 30],
9759 "coral": [255, 127, 80],
9760 "cornflowerblue": [100, 149, 237],
9761 "cornsilk": [255, 248, 220],
9762 "crimson": [220, 20, 60],
9763 "cyan": [0, 255, 255],
9764 "darkblue": [0, 0, 139],
9765 "darkcyan": [0, 139, 139],
9766 "darkgoldenrod": [184, 134, 11],
9767 "darkgray": [169, 169, 169],
9768 "darkgreen": [0, 100, 0],
9769 "darkgrey": [169, 169, 169],
9770 "darkkhaki": [189, 183, 107],
9771 "darkmagenta": [139, 0, 139],
9772 "darkolivegreen": [85, 107, 47],
9773 "darkorange": [255, 140, 0],
9774 "darkorchid": [153, 50, 204],
9775 "darkred": [139, 0, 0],
9776 "darksalmon": [233, 150, 122],
9777 "darkseagreen": [143, 188, 143],
9778 "darkslateblue": [72, 61, 139],
9779 "darkslategray": [47, 79, 79],
9780 "darkslategrey": [47, 79, 79],
9781 "darkturquoise": [0, 206, 209],
9782 "darkviolet": [148, 0, 211],
9783 "deeppink": [255, 20, 147],
9784 "deepskyblue": [0, 191, 255],
9785 "dimgray": [105, 105, 105],
9786 "dimgrey": [105, 105, 105],
9787 "dodgerblue": [30, 144, 255],
9788 "firebrick": [178, 34, 34],
9789 "floralwhite": [255, 250, 240],
9790 "forestgreen": [34, 139, 34],
9791 "fuchsia": [255, 0, 255],
9792 "gainsboro": [220, 220, 220],
9793 "ghostwhite": [248, 248, 255],
9794 "gold": [255, 215, 0],
9795 "goldenrod": [218, 165, 32],
9796 "gray": [128, 128, 128],
9797 "green": [0, 128, 0],
9798 "greenyellow": [173, 255, 47],
9799 "grey": [128, 128, 128],
9800 "honeydew": [240, 255, 240],
9801 "hotpink": [255, 105, 180],
9802 "indianred": [205, 92, 92],
9803 "indigo": [75, 0, 130],
9804 "ivory": [255, 255, 240],
9805 "khaki": [240, 230, 140],
9806 "lavender": [230, 230, 250],
9807 "lavenderblush": [255, 240, 245],
9808 "lawngreen": [124, 252, 0],
9809 "lemonchiffon": [255, 250, 205],
9810 "lightblue": [173, 216, 230],
9811 "lightcoral": [240, 128, 128],
9812 "lightcyan": [224, 255, 255],
9813 "lightgoldenrodyellow": [250, 250, 210],
9814 "lightgray": [211, 211, 211],
9815 "lightgreen": [144, 238, 144],
9816 "lightgrey": [211, 211, 211],
9817 "lightpink": [255, 182, 193],
9818 "lightsalmon": [255, 160, 122],
9819 "lightseagreen": [32, 178, 170],
9820 "lightskyblue": [135, 206, 250],
9821 "lightslategray": [119, 136, 153],
9822 "lightslategrey": [119, 136, 153],
9823 "lightsteelblue": [176, 196, 222],
9824 "lightyellow": [255, 255, 224],
9825 "lime": [0, 255, 0],
9826 "limegreen": [50, 205, 50],
9827 "linen": [250, 240, 230],
9828 "magenta": [255, 0, 255],
9829 "maroon": [128, 0, 0],
9830 "mediumaquamarine": [102, 205, 170],
9831 "mediumblue": [0, 0, 205],
9832 "mediumorchid": [186, 85, 211],
9833 "mediumpurple": [147, 112, 219],
9834 "mediumseagreen": [60, 179, 113],
9835 "mediumslateblue": [123, 104, 238],
9836 "mediumspringgreen": [0, 250, 154],
9837 "mediumturquoise": [72, 209, 204],
9838 "mediumvioletred": [199, 21, 133],
9839 "midnightblue": [25, 25, 112],
9840 "mintcream": [245, 255, 250],
9841 "mistyrose": [255, 228, 225],
9842 "moccasin": [255, 228, 181],
9843 "navajowhite": [255, 222, 173],
9844 "navy": [0, 0, 128],
9845 "oldlace": [253, 245, 230],
9846 "olive": [128, 128, 0],
9847 "olivedrab": [107, 142, 35],
9848 "orange": [255, 165, 0],
9849 "orangered": [255, 69, 0],
9850 "orchid": [218, 112, 214],
9851 "palegoldenrod": [238, 232, 170],
9852 "palegreen": [152, 251, 152],
9853 "paleturquoise": [175, 238, 238],
9854 "palevioletred": [219, 112, 147],
9855 "papayawhip": [255, 239, 213],
9856 "peachpuff": [255, 218, 185],
9857 "peru": [205, 133, 63],
9858 "pink": [255, 192, 203],
9859 "plum": [221, 160, 221],
9860 "powderblue": [176, 224, 230],
9861 "purple": [128, 0, 128],
9862 "rebeccapurple": [102, 51, 153],
9864 "rosybrown": [188, 143, 143],
9865 "royalblue": [65, 105, 225],
9866 "saddlebrown": [139, 69, 19],
9867 "salmon": [250, 128, 114],
9868 "sandybrown": [244, 164, 96],
9869 "seagreen": [46, 139, 87],
9870 "seashell": [255, 245, 238],
9871 "sienna": [160, 82, 45],
9872 "silver": [192, 192, 192],
9873 "skyblue": [135, 206, 235],
9874 "slateblue": [106, 90, 205],
9875 "slategray": [112, 128, 144],
9876 "slategrey": [112, 128, 144],
9877 "snow": [255, 250, 250],
9878 "springgreen": [0, 255, 127],
9879 "steelblue": [70, 130, 180],
9880 "tan": [210, 180, 140],
9881 "teal": [0, 128, 128],
9882 "thistle": [216, 191, 216],
9883 "tomato": [255, 99, 71],
9884 "turquoise": [64, 224, 208],
9885 "violet": [238, 130, 238],
9886 "wheat": [245, 222, 179],
9887 "white": [255, 255, 255],
9888 "whitesmoke": [245, 245, 245],
9889 "yellow": [255, 255, 0],
9890 "yellowgreen": [154, 205, 50]
9894 /* eslint-disable no-mixed-operators */
9896 const cssKeywords = colorName; // NOTE: conversions should only return primitive values (i.e. arrays, or
9897 // values that give correct `typeof` results).
9898 // do not use box values types (i.e. Number(), String(), etc.)
9900 const reverseKeywords = {};
9902 for (const key of Object.keys(cssKeywords)) {
9903 reverseKeywords[cssKeywords[key]] = key;
9957 labels: ['h', 'c', 'g']
9961 labels: ['r16', 'g16', 'b16']
9968 var conversions$2 = convert$1; // Hide .channels and .labels properties
9970 for (const model of Object.keys(convert$1)) {
9971 if (!('channels' in convert$1[model])) {
9972 throw new Error('missing channels property: ' + model);
9975 if (!('labels' in convert$1[model])) {
9976 throw new Error('missing channel labels property: ' + model);
9979 if (convert$1[model].labels.length !== convert$1[model].channels) {
9980 throw new Error('channel and label counts mismatch: ' + model);
9986 } = convert$1[model];
9987 delete convert$1[model].channels;
9988 delete convert$1[model].labels;
9989 Object.defineProperty(convert$1[model], 'channels', {
9992 Object.defineProperty(convert$1[model], 'labels', {
9997 convert$1.rgb.hsl = function (rgb) {
9998 const r = rgb[0] / 255;
9999 const g = rgb[1] / 255;
10000 const b = rgb[2] / 255;
10001 const min = Math.min(r, g, b);
10002 const max = Math.max(r, g, b);
10003 const delta = max - min;
10009 } else if (r === max) {
10010 h = (g - b) / delta;
10011 } else if (g === max) {
10012 h = 2 + (b - r) / delta;
10013 } else if (b === max) {
10014 h = 4 + (r - g) / delta;
10017 h = Math.min(h * 60, 360);
10023 const l = (min + max) / 2;
10027 } else if (l <= 0.5) {
10028 s = delta / (max + min);
10030 s = delta / (2 - max - min);
10033 return [h, s * 100, l * 100];
10036 convert$1.rgb.hsv = function (rgb) {
10042 const r = rgb[0] / 255;
10043 const g = rgb[1] / 255;
10044 const b = rgb[2] / 255;
10045 const v = Math.max(r, g, b);
10046 const diff = v - Math.min(r, g, b);
10048 const diffc = function (c) {
10049 return (v - c) / 6 / diff + 1 / 2;
10063 } else if (g === v) {
10064 h = 1 / 3 + rdif - bdif;
10065 } else if (b === v) {
10066 h = 2 / 3 + gdif - rdif;
10071 } else if (h > 1) {
10076 return [h * 360, s * 100, v * 100];
10079 convert$1.rgb.hwb = function (rgb) {
10083 const h = convert$1.rgb.hsl(rgb)[0];
10084 const w = 1 / 255 * Math.min(r, Math.min(g, b));
10085 b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
10086 return [h, w * 100, b * 100];
10089 convert$1.rgb.cmyk = function (rgb) {
10090 const r = rgb[0] / 255;
10091 const g = rgb[1] / 255;
10092 const b = rgb[2] / 255;
10093 const k = Math.min(1 - r, 1 - g, 1 - b);
10094 const c = (1 - r - k) / (1 - k) || 0;
10095 const m = (1 - g - k) / (1 - k) || 0;
10096 const y = (1 - b - k) / (1 - k) || 0;
10097 return [c * 100, m * 100, y * 100, k * 100];
10100 function comparativeDistance(x, y) {
10102 See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
10104 return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
10107 convert$1.rgb.keyword = function (rgb) {
10108 const reversed = reverseKeywords[rgb];
10114 let currentClosestDistance = Infinity;
10115 let currentClosestKeyword;
10117 for (const keyword of Object.keys(cssKeywords)) {
10118 const value = cssKeywords[keyword]; // Compute comparative distance
10120 const distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
10122 if (distance < currentClosestDistance) {
10123 currentClosestDistance = distance;
10124 currentClosestKeyword = keyword;
10128 return currentClosestKeyword;
10131 convert$1.keyword.rgb = function (keyword) {
10132 return cssKeywords[keyword];
10135 convert$1.rgb.xyz = function (rgb) {
10136 let r = rgb[0] / 255;
10137 let g = rgb[1] / 255;
10138 let b = rgb[2] / 255; // Assume sRGB
10140 r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
10141 g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
10142 b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
10143 const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
10144 const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
10145 const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
10146 return [x * 100, y * 100, z * 100];
10149 convert$1.rgb.lab = function (rgb) {
10150 const xyz = convert$1.rgb.xyz(rgb);
10157 x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
10158 y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
10159 z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
10160 const l = 116 * y - 16;
10161 const a = 500 * (x - y);
10162 const b = 200 * (y - z);
10166 convert$1.hsl.rgb = function (hsl) {
10167 const h = hsl[0] / 360;
10168 const s = hsl[1] / 100;
10169 const l = hsl[2] / 100;
10176 return [val, val, val];
10182 t2 = l + s - l * s;
10185 const t1 = 2 * l - t2;
10186 const rgb = [0, 0, 0];
10188 for (let i = 0; i < 3; i++) {
10189 t3 = h + 1 / 3 * -(i - 1);
10200 val = t1 + (t2 - t1) * 6 * t3;
10201 } else if (2 * t3 < 1) {
10203 } else if (3 * t3 < 2) {
10204 val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
10209 rgb[i] = val * 255;
10215 convert$1.hsl.hsv = function (hsl) {
10217 let s = hsl[1] / 100;
10218 let l = hsl[2] / 100;
10220 const lmin = Math.max(l, 0.01);
10222 s *= l <= 1 ? l : 2 - l;
10223 smin *= lmin <= 1 ? lmin : 2 - lmin;
10224 const v = (l + s) / 2;
10225 const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
10226 return [h, sv * 100, v * 100];
10229 convert$1.hsv.rgb = function (hsv) {
10230 const h = hsv[0] / 60;
10231 const s = hsv[1] / 100;
10232 let v = hsv[2] / 100;
10233 const hi = Math.floor(h) % 6;
10234 const f = h - Math.floor(h);
10235 const p = 255 * v * (1 - s);
10236 const q = 255 * v * (1 - s * f);
10237 const t = 255 * v * (1 - s * (1 - f));
10261 convert$1.hsv.hsl = function (hsv) {
10263 const s = hsv[1] / 100;
10264 const v = hsv[2] / 100;
10265 const vmin = Math.max(v, 0.01);
10269 const lmin = (2 - s) * vmin;
10271 sl /= lmin <= 1 ? lmin : 2 - lmin;
10274 return [h, sl * 100, l * 100];
10275 }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
10278 convert$1.hwb.rgb = function (hwb) {
10279 const h = hwb[0] / 360;
10280 let wh = hwb[1] / 100;
10281 let bl = hwb[2] / 100;
10282 const ratio = wh + bl;
10283 let f; // Wh + bl cant be > 1
10290 const i = Math.floor(6 * h);
10294 if ((i & 0x01) !== 0) {
10298 const n = wh + f * (v - wh); // Linear interpolation
10303 /* eslint-disable max-statements-per-line,no-multi-spaces */
10344 /* eslint-enable max-statements-per-line,no-multi-spaces */
10347 return [r * 255, g * 255, b * 255];
10350 convert$1.cmyk.rgb = function (cmyk) {
10351 const c = cmyk[0] / 100;
10352 const m = cmyk[1] / 100;
10353 const y = cmyk[2] / 100;
10354 const k = cmyk[3] / 100;
10355 const r = 1 - Math.min(1, c * (1 - k) + k);
10356 const g = 1 - Math.min(1, m * (1 - k) + k);
10357 const b = 1 - Math.min(1, y * (1 - k) + k);
10358 return [r * 255, g * 255, b * 255];
10361 convert$1.xyz.rgb = function (xyz) {
10362 const x = xyz[0] / 100;
10363 const y = xyz[1] / 100;
10364 const z = xyz[2] / 100;
10368 r = x * 3.2406 + y * -1.5372 + z * -0.4986;
10369 g = x * -0.9689 + y * 1.8758 + z * 0.0415;
10370 b = x * 0.0557 + y * -0.2040 + z * 1.0570; // Assume sRGB
10372 r = r > 0.0031308 ? 1.055 * r ** (1.0 / 2.4) - 0.055 : r * 12.92;
10373 g = g > 0.0031308 ? 1.055 * g ** (1.0 / 2.4) - 0.055 : g * 12.92;
10374 b = b > 0.0031308 ? 1.055 * b ** (1.0 / 2.4) - 0.055 : b * 12.92;
10375 r = Math.min(Math.max(0, r), 1);
10376 g = Math.min(Math.max(0, g), 1);
10377 b = Math.min(Math.max(0, b), 1);
10378 return [r * 255, g * 255, b * 255];
10381 convert$1.xyz.lab = function (xyz) {
10388 x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
10389 y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
10390 z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
10391 const l = 116 * y - 16;
10392 const a = 500 * (x - y);
10393 const b = 200 * (y - z);
10397 convert$1.lab.xyz = function (lab) {
10404 y = (l + 16) / 116;
10410 y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
10411 x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
10412 z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
10419 convert$1.lab.lch = function (lab) {
10424 const hr = Math.atan2(b, a);
10425 h = hr * 360 / 2 / Math.PI;
10431 const c = Math.sqrt(a * a + b * b);
10435 convert$1.lch.lab = function (lch) {
10439 const hr = h / 360 * 2 * Math.PI;
10440 const a = c * Math.cos(hr);
10441 const b = c * Math.sin(hr);
10445 convert$1.rgb.ansi16 = function (args, saturation = null) {
10446 const [r, g, b] = args;
10447 let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
10449 value = Math.round(value / 50);
10455 let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
10464 convert$1.hsv.ansi16 = function (args) {
10465 // Optimization here; we already know the value and don't need to get
10466 // it converted for us.
10467 return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
10470 convert$1.rgb.ansi256 = function (args) {
10473 const b = args[2]; // We use the extended greyscale palette here, with the exception of
10474 // black and white. normal palette only has 4 greyscale shades.
10476 if (r === g && g === b) {
10485 return Math.round((r - 8) / 247 * 24) + 232;
10488 const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
10492 convert$1.ansi16.rgb = function (args) {
10493 let color = args % 10; // Handle greyscale
10495 if (color === 0 || color === 7) {
10500 color = color / 10.5 * 255;
10501 return [color, color, color];
10504 const mult = (~~(args > 50) + 1) * 0.5;
10505 const r = (color & 1) * mult * 255;
10506 const g = (color >> 1 & 1) * mult * 255;
10507 const b = (color >> 2 & 1) * mult * 255;
10511 convert$1.ansi256.rgb = function (args) {
10512 // Handle greyscale
10514 const c = (args - 232) * 10 + 8;
10520 const r = Math.floor(args / 36) / 5 * 255;
10521 const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
10522 const b = rem % 6 / 5 * 255;
10526 convert$1.rgb.hex = function (args) {
10527 const integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
10528 const string = integer.toString(16).toUpperCase();
10529 return '000000'.substring(string.length) + string;
10532 convert$1.hex.rgb = function (args) {
10533 const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
10539 let colorString = match[0];
10541 if (match[0].length === 3) {
10542 colorString = colorString.split('').map(char => {
10543 return char + char;
10547 const integer = parseInt(colorString, 16);
10548 const r = integer >> 16 & 0xFF;
10549 const g = integer >> 8 & 0xFF;
10550 const b = integer & 0xFF;
10554 convert$1.rgb.hcg = function (rgb) {
10555 const r = rgb[0] / 255;
10556 const g = rgb[1] / 255;
10557 const b = rgb[2] / 255;
10558 const max = Math.max(Math.max(r, g), b);
10559 const min = Math.min(Math.min(r, g), b);
10560 const chroma = max - min;
10565 grayscale = min / (1 - chroma);
10572 } else if (max === r) {
10573 hue = (g - b) / chroma % 6;
10574 } else if (max === g) {
10575 hue = 2 + (b - r) / chroma;
10577 hue = 4 + (r - g) / chroma;
10582 return [hue * 360, chroma * 100, grayscale * 100];
10585 convert$1.hsl.hcg = function (hsl) {
10586 const s = hsl[1] / 100;
10587 const l = hsl[2] / 100;
10588 const c = l < 0.5 ? 2.0 * s * l : 2.0 * s * (1.0 - l);
10592 f = (l - 0.5 * c) / (1.0 - c);
10595 return [hsl[0], c * 100, f * 100];
10598 convert$1.hsv.hcg = function (hsv) {
10599 const s = hsv[1] / 100;
10600 const v = hsv[2] / 100;
10605 f = (v - c) / (1 - c);
10608 return [hsv[0], c * 100, f * 100];
10611 convert$1.hcg.rgb = function (hcg) {
10612 const h = hcg[0] / 360;
10613 const c = hcg[1] / 100;
10614 const g = hcg[2] / 100;
10617 return [g * 255, g * 255, g * 255];
10620 const pure = [0, 0, 0];
10621 const hi = h % 1 * 6;
10625 /* eslint-disable max-statements-per-line */
10627 switch (Math.floor(hi)) {
10663 /* eslint-enable max-statements-per-line */
10666 mg = (1.0 - c) * g;
10667 return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
10670 convert$1.hcg.hsv = function (hcg) {
10671 const c = hcg[1] / 100;
10672 const g = hcg[2] / 100;
10673 const v = c + g * (1.0 - c);
10680 return [hcg[0], f * 100, v * 100];
10683 convert$1.hcg.hsl = function (hcg) {
10684 const c = hcg[1] / 100;
10685 const g = hcg[2] / 100;
10686 const l = g * (1.0 - c) + 0.5 * c;
10689 if (l > 0.0 && l < 0.5) {
10691 } else if (l >= 0.5 && l < 1.0) {
10692 s = c / (2 * (1 - l));
10695 return [hcg[0], s * 100, l * 100];
10698 convert$1.hcg.hwb = function (hcg) {
10699 const c = hcg[1] / 100;
10700 const g = hcg[2] / 100;
10701 const v = c + g * (1.0 - c);
10702 return [hcg[0], (v - c) * 100, (1 - v) * 100];
10705 convert$1.hwb.hcg = function (hwb) {
10706 const w = hwb[1] / 100;
10707 const b = hwb[2] / 100;
10713 g = (v - c) / (1 - c);
10716 return [hwb[0], c * 100, g * 100];
10719 convert$1.apple.rgb = function (apple) {
10720 return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
10723 convert$1.rgb.apple = function (rgb) {
10724 return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
10727 convert$1.gray.rgb = function (args) {
10728 return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
10731 convert$1.gray.hsl = function (args) {
10732 return [0, 0, args[0]];
10735 convert$1.gray.hsv = convert$1.gray.hsl;
10737 convert$1.gray.hwb = function (gray) {
10738 return [0, 100, gray[0]];
10741 convert$1.gray.cmyk = function (gray) {
10742 return [0, 0, 0, gray[0]];
10745 convert$1.gray.lab = function (gray) {
10746 return [gray[0], 0, 0];
10749 convert$1.gray.hex = function (gray) {
10750 const val = Math.round(gray[0] / 100 * 255) & 0xFF;
10751 const integer = (val << 16) + (val << 8) + val;
10752 const string = integer.toString(16).toUpperCase();
10753 return '000000'.substring(string.length) + string;
10756 convert$1.rgb.gray = function (rgb) {
10757 const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
10758 return [val / 255 * 100];
10761 const conversions$1 = conversions$2;
10763 This function routes a model to all other models.
10765 all functions that are routed have a property `.conversion` attached
10766 to the returned synthetic function. This property is an array
10767 of strings, each with the steps in between the 'from' and 'to'
10768 color models (inclusive).
10770 conversions that are not possible simply are not included.
10773 function buildGraph() {
10774 const graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3
10776 const models = Object.keys(conversions$1);
10778 for (let len = models.length, i = 0; i < len; i++) {
10779 graph[models[i]] = {
10780 // http://jsperf.com/1-vs-infinity
10781 // micro-opt, but this is simple.
10788 } // https://en.wikipedia.org/wiki/Breadth-first_search
10791 function deriveBFS(fromModel) {
10792 const graph = buildGraph();
10793 const queue = [fromModel]; // Unshift -> queue -> pop
10795 graph[fromModel].distance = 0;
10797 while (queue.length) {
10798 const current = queue.pop();
10799 const adjacents = Object.keys(conversions$1[current]);
10801 for (let len = adjacents.length, i = 0; i < len; i++) {
10802 const adjacent = adjacents[i];
10803 const node = graph[adjacent];
10805 if (node.distance === -1) {
10806 node.distance = graph[current].distance + 1;
10807 node.parent = current;
10808 queue.unshift(adjacent);
10816 function link$1(from, to) {
10817 return function (args) {
10818 return to(from(args));
10822 function wrapConversion(toModel, graph) {
10823 const path = [graph[toModel].parent, toModel];
10824 let fn = conversions$1[graph[toModel].parent][toModel];
10825 let cur = graph[toModel].parent;
10827 while (graph[cur].parent) {
10828 path.unshift(graph[cur].parent);
10829 fn = link$1(conversions$1[graph[cur].parent][cur], fn);
10830 cur = graph[cur].parent;
10833 fn.conversion = path;
10837 var route$1 = function (fromModel) {
10838 const graph = deriveBFS(fromModel);
10839 const conversion = {};
10840 const models = Object.keys(graph);
10842 for (let len = models.length, i = 0; i < len; i++) {
10843 const toModel = models[i];
10844 const node = graph[toModel];
10846 if (node.parent === null) {
10847 // No possible conversion, or this node is the source model.
10851 conversion[toModel] = wrapConversion(toModel, graph);
10857 const conversions = conversions$2;
10858 const route = route$1;
10859 const convert = {};
10860 const models = Object.keys(conversions);
10862 function wrapRaw(fn) {
10863 const wrappedFn = function (...args) {
10864 const arg0 = args[0];
10866 if (arg0 === undefined || arg0 === null) {
10870 if (arg0.length > 1) {
10875 }; // Preserve .conversion property if there is one
10878 if ('conversion' in fn) {
10879 wrappedFn.conversion = fn.conversion;
10885 function wrapRounded(fn) {
10886 const wrappedFn = function (...args) {
10887 const arg0 = args[0];
10889 if (arg0 === undefined || arg0 === null) {
10893 if (arg0.length > 1) {
10897 const result = fn(args); // We're assuming the result is an array here.
10898 // see notice in conversions.js; don't use box types
10899 // in conversion functions.
10901 if (typeof result === 'object') {
10902 for (let len = result.length, i = 0; i < len; i++) {
10903 result[i] = Math.round(result[i]);
10908 }; // Preserve .conversion property if there is one
10911 if ('conversion' in fn) {
10912 wrappedFn.conversion = fn.conversion;
10918 models.forEach(fromModel => {
10919 convert[fromModel] = {};
10920 Object.defineProperty(convert[fromModel], 'channels', {
10921 value: conversions[fromModel].channels
10923 Object.defineProperty(convert[fromModel], 'labels', {
10924 value: conversions[fromModel].labels
10926 const routes = route(fromModel);
10927 const routeModels = Object.keys(routes);
10928 routeModels.forEach(toModel => {
10929 const fn = routes[toModel];
10930 convert[fromModel][toModel] = wrapRounded(fn);
10931 convert[fromModel][toModel].raw = wrapRaw(fn);
10934 var colorConvert = convert;
10936 (function (module) {
10938 const wrapAnsi16 = (fn, offset) => (...args) => {
10939 const code = fn(...args);
10940 return `\u001B[${code + offset}m`;
10943 const wrapAnsi256 = (fn, offset) => (...args) => {
10944 const code = fn(...args);
10945 return `\u001B[${38 + offset};5;${code}m`;
10948 const wrapAnsi16m = (fn, offset) => (...args) => {
10949 const rgb = fn(...args);
10950 return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
10953 const ansi2ansi = n => n;
10955 const rgb2rgb = (r, g, b) => [r, g, b];
10957 const setLazyProperty = (object, property, get) => {
10958 Object.defineProperty(object, property, {
10960 const value = get();
10961 Object.defineProperty(object, property, {
10972 /** @type {typeof import('color-convert')} */
10975 let colorConvert$1;
10977 const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
10978 if (colorConvert$1 === undefined) {
10979 colorConvert$1 = colorConvert;
10982 const offset = isBackground ? 10 : 0;
10985 for (const [sourceSpace, suite] of Object.entries(colorConvert$1)) {
10986 const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
10988 if (sourceSpace === targetSpace) {
10989 styles[name] = wrap(identity, offset);
10990 } else if (typeof suite === 'object') {
10991 styles[name] = wrap(suite[targetSpace], offset);
10998 function assembleStyles() {
10999 const codes = new Map();
11003 // 21 isn't widely supported and 22 does the same thing
11007 underline: [4, 24],
11010 strikethrough: [9, 29]
11022 blackBright: [90, 39],
11023 redBright: [91, 39],
11024 greenBright: [92, 39],
11025 yellowBright: [93, 39],
11026 blueBright: [94, 39],
11027 magentaBright: [95, 39],
11028 cyanBright: [96, 39],
11029 whiteBright: [97, 39]
11035 bgYellow: [43, 49],
11037 bgMagenta: [45, 49],
11041 bgBlackBright: [100, 49],
11042 bgRedBright: [101, 49],
11043 bgGreenBright: [102, 49],
11044 bgYellowBright: [103, 49],
11045 bgBlueBright: [104, 49],
11046 bgMagentaBright: [105, 49],
11047 bgCyanBright: [106, 49],
11048 bgWhiteBright: [107, 49]
11050 }; // Alias bright black as gray (and grey)
11052 styles.color.gray = styles.color.blackBright;
11053 styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
11054 styles.color.grey = styles.color.blackBright;
11055 styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
11057 for (const [groupName, group] of Object.entries(styles)) {
11058 for (const [styleName, style] of Object.entries(group)) {
11059 styles[styleName] = {
11060 open: `\u001B[${style[0]}m`,
11061 close: `\u001B[${style[1]}m`
11063 group[styleName] = styles[styleName];
11064 codes.set(style[0], style[1]);
11067 Object.defineProperty(styles, groupName, {
11073 Object.defineProperty(styles, 'codes', {
11077 styles.color.close = '\u001B[39m';
11078 styles.bgColor.close = '\u001B[49m';
11079 setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
11080 setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
11081 setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
11082 setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
11083 setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
11084 setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
11086 } // Make the export immutable
11089 Object.defineProperty(module, 'exports', {
11091 get: assembleStyles
11095 var hasFlag$3 = (flag, argv = process.argv) => {
11096 const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
11097 const position = argv.indexOf(prefix + flag);
11098 const terminatorPosition = argv.indexOf('--');
11099 return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
11102 const os$3 = require$$0__default$1["default"];
11103 const tty$2 = require$$1__default["default"];
11104 const hasFlag$2 = hasFlag$3;
11110 if (hasFlag$2('no-color') || hasFlag$2('no-colors') || hasFlag$2('color=false') || hasFlag$2('color=never')) {
11112 } else if (hasFlag$2('color') || hasFlag$2('colors') || hasFlag$2('color=true') || hasFlag$2('color=always')) {
11116 if ('FORCE_COLOR' in env$1) {
11117 if (env$1.FORCE_COLOR === 'true') {
11119 } else if (env$1.FORCE_COLOR === 'false') {
11122 forceColor$1 = env$1.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env$1.FORCE_COLOR, 10), 3);
11126 function translateLevel$1(level) {
11134 has256: level >= 2,
11139 function supportsColor$1(haveStream, streamIsTTY) {
11140 if (forceColor$1 === 0) {
11144 if (hasFlag$2('color=16m') || hasFlag$2('color=full') || hasFlag$2('color=truecolor')) {
11148 if (hasFlag$2('color=256')) {
11152 if (haveStream && !streamIsTTY && forceColor$1 === undefined) {
11156 const min = forceColor$1 || 0;
11158 if (env$1.TERM === 'dumb') {
11162 if (process.platform === 'win32') {
11163 // Windows 10 build 10586 is the first Windows release that supports 256 colors.
11164 // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
11165 const osRelease = os$3.release().split('.');
11167 if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
11168 return Number(osRelease[2]) >= 14931 ? 3 : 2;
11174 if ('CI' in env$1) {
11175 if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env$1) || env$1.CI_NAME === 'codeship') {
11182 if ('TEAMCITY_VERSION' in env$1) {
11183 return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
11186 if (env$1.COLORTERM === 'truecolor') {
11190 if ('TERM_PROGRAM' in env$1) {
11191 const version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
11193 switch (env$1.TERM_PROGRAM) {
11195 return version >= 3 ? 3 : 2;
11197 case 'Apple_Terminal':
11203 if (/-256(color)?$/i.test(env$1.TERM)) {
11207 if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
11211 if ('COLORTERM' in env$1) {
11218 function getSupportLevel$1(stream) {
11219 const level = supportsColor$1(stream, stream && stream.isTTY);
11220 return translateLevel$1(level);
11223 var supportsColor_1$1 = {
11224 supportsColor: getSupportLevel$1,
11225 stdout: translateLevel$1(supportsColor$1(true, tty$2.isatty(1))),
11226 stderr: translateLevel$1(supportsColor$1(true, tty$2.isatty(2)))
11229 const stringReplaceAll$1 = (string, substring, replacer) => {
11230 let index = string.indexOf(substring);
11232 if (index === -1) {
11236 const substringLength = substring.length;
11238 let returnValue = '';
11241 returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
11242 endIndex = index + substringLength;
11243 index = string.indexOf(substring, endIndex);
11244 } while (index !== -1);
11246 returnValue += string.substr(endIndex);
11247 return returnValue;
11250 const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
11252 let returnValue = '';
11255 const gotCR = string[index - 1] === '\r';
11256 returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
11257 endIndex = index + 1;
11258 index = string.indexOf('\n', endIndex);
11259 } while (index !== -1);
11261 returnValue += string.substr(endIndex);
11262 return returnValue;
11266 stringReplaceAll: stringReplaceAll$1,
11267 stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
11270 const TEMPLATE_REGEX$1 = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
11271 const STYLE_REGEX$1 = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
11272 const STRING_REGEX$2 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
11273 const ESCAPE_REGEX$1 = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
11274 const ESCAPES$1 = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
11276 function unescape$1(c) {
11277 const u = c[0] === 'u';
11278 const bracket = c[1] === '{';
11280 if (u && !bracket && c.length === 5 || c[0] === 'x' && c.length === 3) {
11281 return String.fromCharCode(parseInt(c.slice(1), 16));
11284 if (u && bracket) {
11285 return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
11288 return ESCAPES$1.get(c) || c;
11291 function parseArguments$1(name, arguments_) {
11292 const results = [];
11293 const chunks = arguments_.trim().split(/\s*,\s*/g);
11296 for (const chunk of chunks) {
11297 const number = Number(chunk);
11299 if (!Number.isNaN(number)) {
11300 results.push(number);
11301 } else if (matches = chunk.match(STRING_REGEX$2)) {
11302 results.push(matches[2].replace(ESCAPE_REGEX$1, (m, escape, character) => escape ? unescape$1(escape) : character));
11304 throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
11311 function parseStyle$1(style) {
11312 STYLE_REGEX$1.lastIndex = 0;
11313 const results = [];
11316 while ((matches = STYLE_REGEX$1.exec(style)) !== null) {
11317 const name = matches[1];
11320 const args = parseArguments$1(name, matches[2]);
11321 results.push([name].concat(args));
11323 results.push([name]);
11330 function buildStyle$1(chalk, styles) {
11331 const enabled = {};
11333 for (const layer of styles) {
11334 for (const style of layer.styles) {
11335 enabled[style[0]] = layer.inverse ? null : style.slice(1);
11339 let current = chalk;
11341 for (const [styleName, styles] of Object.entries(enabled)) {
11342 if (!Array.isArray(styles)) {
11346 if (!(styleName in current)) {
11347 throw new Error(`Unknown Chalk style: ${styleName}`);
11350 current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
11356 var templates$1 = (chalk, temporary) => {
11359 let chunk = []; // eslint-disable-next-line max-params
11361 temporary.replace(TEMPLATE_REGEX$1, (m, escapeCharacter, inverse, style, close, character) => {
11362 if (escapeCharacter) {
11363 chunk.push(unescape$1(escapeCharacter));
11364 } else if (style) {
11365 const string = chunk.join('');
11367 chunks.push(styles.length === 0 ? string : buildStyle$1(chalk, styles)(string));
11370 styles: parseStyle$1(style)
11372 } else if (close) {
11373 if (styles.length === 0) {
11374 throw new Error('Found extraneous } in Chalk template literal');
11377 chunks.push(buildStyle$1(chalk, styles)(chunk.join('')));
11381 chunk.push(character);
11384 chunks.push(chunk.join(''));
11386 if (styles.length > 0) {
11387 const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
11388 throw new Error(errMessage);
11391 return chunks.join('');
11394 const ansiStyles = ansiStyles$1.exports;
11396 stdout: stdoutColor,
11397 stderr: stderrColor
11398 } = supportsColor_1$1;
11401 stringEncaseCRLFWithFirstIndex
11405 } = Array; // `supportsColor.level` → `ansiStyles.color[name]` mapping
11407 const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
11408 const styles = Object.create(null);
11410 const applyOptions = (object, options = {}) => {
11411 if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
11412 throw new Error('The `level` option should be an integer from 0 to 3');
11413 } // Detect level if not set manually
11416 const colorLevel = stdoutColor ? stdoutColor.level : 0;
11417 object.level = options.level === undefined ? colorLevel : options.level;
11421 constructor(options) {
11422 // eslint-disable-next-line no-constructor-return
11423 return chalkFactory(options);
11428 const chalkFactory = options => {
11430 applyOptions(chalk, options);
11432 chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
11434 Object.setPrototypeOf(chalk, Chalk.prototype);
11435 Object.setPrototypeOf(chalk.template, chalk);
11437 chalk.template.constructor = () => {
11438 throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
11441 chalk.template.Instance = ChalkClass;
11442 return chalk.template;
11445 function Chalk(options) {
11446 return chalkFactory(options);
11449 for (const [styleName, style] of Object.entries(ansiStyles)) {
11450 styles[styleName] = {
11452 const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
11453 Object.defineProperty(this, styleName, {
11464 const builder = createBuilder(this, this._styler, true);
11465 Object.defineProperty(this, 'visible', {
11472 const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
11474 for (const model of usedModels) {
11480 return function (...arguments_) {
11481 const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
11482 return createBuilder(this, styler, this._isEmpty);
11489 for (const model of usedModels) {
11490 const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
11491 styles[bgModel] = {
11496 return function (...arguments_) {
11497 const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
11498 return createBuilder(this, styler, this._isEmpty);
11505 const proto = Object.defineProperties(() => {}, Object.assign(Object.assign({}, styles), {}, {
11510 return this._generator.level;
11514 this._generator.level = level;
11520 const createStyler = (open, close, parent) => {
11524 if (parent === undefined) {
11528 openAll = parent.openAll + open;
11529 closeAll = close + parent.closeAll;
11541 const createBuilder = (self, _styler, _isEmpty) => {
11542 const builder = (...arguments_) => {
11543 if (isArray$b(arguments_[0]) && isArray$b(arguments_[0].raw)) {
11544 // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
11545 return applyStyle(builder, chalkTag(builder, ...arguments_));
11546 } // Single argument is hot path, implicit coercion is faster than anything
11547 // eslint-disable-next-line no-implicit-coercion
11550 return applyStyle(builder, arguments_.length === 1 ? '' + arguments_[0] : arguments_.join(' '));
11551 }; // We alter the prototype because we must return a function, but there is
11552 // no way to create a function with a different prototype
11555 Object.setPrototypeOf(builder, proto);
11556 builder._generator = self;
11557 builder._styler = _styler;
11558 builder._isEmpty = _isEmpty;
11562 const applyStyle = (self, string) => {
11563 if (self.level <= 0 || !string) {
11564 return self._isEmpty ? '' : string;
11567 let styler = self._styler;
11569 if (styler === undefined) {
11578 if (string.indexOf('\u001B') !== -1) {
11579 while (styler !== undefined) {
11580 // Replace any instances already present with a re-opening code
11581 // otherwise only the part of the string until said closing code
11582 // will be colored, and the rest will simply be 'plain'.
11583 string = stringReplaceAll(string, styler.close, styler.open);
11584 styler = styler.parent;
11586 } // We can move both next actions out of loop, because remaining actions in loop won't have
11587 // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
11588 // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
11591 const lfIndex = string.indexOf('\n');
11593 if (lfIndex !== -1) {
11594 string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
11597 return openAll + string + closeAll;
11602 const chalkTag = (chalk, ...strings) => {
11603 const [firstString] = strings;
11605 if (!isArray$b(firstString) || !isArray$b(firstString.raw)) {
11606 // If chalk() was called by itself or with a string,
11607 // return the string itself as a string.
11608 return strings.join(' ');
11611 const arguments_ = strings.slice(1);
11612 const parts = [firstString.raw[0]];
11614 for (let i = 1; i < firstString.length; i++) {
11615 parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'), String(firstString.raw[i]));
11618 if (template === undefined) {
11619 template = templates$1;
11622 return template(chalk, parts.join(''));
11625 Object.defineProperties(Chalk.prototype, styles);
11626 const chalk$2 = Chalk(); // eslint-disable-line new-cap
11628 chalk$2.supportsColor = stdoutColor;
11629 chalk$2.stderr = Chalk({
11630 level: stderrColor ? stderrColor.level : 0
11631 }); // eslint-disable-line new-cap
11633 chalk$2.stderr.supportsColor = stderrColor;
11634 var source$2 = chalk$2;
11636 const _excluded$2 = ["_"];
11638 const vnopts = lib$4;
11639 const leven = leven$2.exports;
11640 const chalk$1 = source$2;
11641 const getLast$n = getLast_1;
11642 const cliDescriptor = {
11643 key: key => key.length === 1 ? `-${key}` : `--${key}`,
11644 value: value => vnopts.apiDescriptor.value(value),
11648 }) => value === false ? `--no-${key}` : value === true ? cliDescriptor.key(key) : value === "" ? `${cliDescriptor.key(key)} without an argument` : `${cliDescriptor.key(key)}=${value}`
11651 class FlagSchema extends vnopts.ChoiceSchema {
11660 this._flags = [...flags].sort();
11663 preprocess(value, utils) {
11664 if (typeof value === "string" && value.length > 0 && !this._flags.includes(value)) {
11665 const suggestion = this._flags.find(flag => leven(flag, value) < 3);
11668 utils.logger.warn([`Unknown flag ${chalk$1.yellow(utils.descriptor.value(value))},`, `did you mean ${chalk$1.blue(utils.descriptor.value(suggestion))}?`].join(" "));
11682 let hasDeprecationWarned;
11684 function normalizeOptions$5(options, optionInfos, {
11687 passThrough = false
11689 const unknown = !passThrough ? (key, value, options) => {
11690 // Don't suggest `_` for unknown flags
11691 const _options$schemas = options.schemas,
11692 schemas = _objectWithoutProperties(_options$schemas, _excluded$2);
11694 return vnopts.levenUnknownHandler(key, value, Object.assign(Object.assign({}, options), {}, {
11697 } : Array.isArray(passThrough) ? (key, value) => !passThrough.includes(key) ? undefined : {
11699 } : (key, value) => ({
11702 const descriptor = isCLI ? cliDescriptor : vnopts.apiDescriptor;
11703 const schemas = optionInfosToSchemas(optionInfos, {
11706 const normalizer = new vnopts.Normalizer(schemas, {
11711 const shouldSuppressDuplicateDeprecationWarnings = logger !== false;
11713 if (shouldSuppressDuplicateDeprecationWarnings && hasDeprecationWarned) {
11714 normalizer._hasDeprecationWarned = hasDeprecationWarned;
11717 const normalized = normalizer.normalize(options);
11719 if (shouldSuppressDuplicateDeprecationWarnings) {
11720 hasDeprecationWarned = normalizer._hasDeprecationWarned;
11726 function optionInfosToSchemas(optionInfos, {
11729 const schemas = [];
11732 schemas.push(vnopts.AnySchema.create({
11737 for (const optionInfo of optionInfos) {
11738 schemas.push(optionInfoToSchema(optionInfo, {
11743 if (optionInfo.alias && isCLI) {
11744 schemas.push(vnopts.AliasSchema.create({
11745 name: optionInfo.alias,
11746 sourceName: optionInfo.name
11754 function optionInfoToSchema(optionInfo, {
11758 let SchemaConstructor;
11759 const parameters = {
11760 name: optionInfo.name
11762 const handlers = {};
11764 switch (optionInfo.type) {
11766 SchemaConstructor = vnopts.IntegerSchema;
11769 parameters.preprocess = value => Number(value);
11775 SchemaConstructor = vnopts.StringSchema;
11779 SchemaConstructor = vnopts.ChoiceSchema;
11780 parameters.choices = optionInfo.choices.map(choiceInfo => typeof choiceInfo === "object" && choiceInfo.redirect ? Object.assign(Object.assign({}, choiceInfo), {}, {
11783 key: optionInfo.name,
11784 value: choiceInfo.redirect
11791 SchemaConstructor = vnopts.BooleanSchema;
11795 SchemaConstructor = FlagSchema;
11796 parameters.flags = optionInfos.flatMap(optionInfo => [optionInfo.alias, optionInfo.description && optionInfo.name, optionInfo.oppositeDescription && `no-${optionInfo.name}`].filter(Boolean));
11800 SchemaConstructor = vnopts.StringSchema;
11804 /* istanbul ignore next */
11805 throw new Error(`Unexpected type ${optionInfo.type}`);
11808 if (optionInfo.exception) {
11809 parameters.validate = (value, schema, utils) => optionInfo.exception(value) || schema.validate(value, utils);
11811 parameters.validate = (value, schema, utils) => value === undefined || schema.validate(value, utils);
11813 /* istanbul ignore next */
11816 if (optionInfo.redirect) {
11817 handlers.redirect = value => !value ? undefined : {
11819 key: optionInfo.redirect.option,
11820 value: optionInfo.redirect.value
11824 /* istanbul ignore next */
11827 if (optionInfo.deprecated) {
11828 handlers.deprecated = true;
11829 } // allow CLI overriding, e.g., prettier package.json --tab-width 1 --tab-width 2
11832 if (isCLI && !optionInfo.array) {
11833 const originalPreprocess = parameters.preprocess || (x => x);
11835 parameters.preprocess = (value, schema, utils) => schema.preprocess(originalPreprocess(Array.isArray(value) ? getLast$n(value) : value), utils);
11838 return optionInfo.array ? vnopts.ArraySchema.create(Object.assign(Object.assign(Object.assign({}, isCLI ? {
11839 preprocess: v => Array.isArray(v) ? v : [v]
11840 } : {}), handlers), {}, {
11841 valueSchema: SchemaConstructor.create(parameters)
11842 })) : SchemaConstructor.create(Object.assign(Object.assign({}, parameters), handlers));
11845 function normalizeApiOptions(options, optionInfos, opts) {
11846 return normalizeOptions$5(options, optionInfos, opts);
11849 function normalizeCliOptions(options, optionInfos, opts) {
11850 return normalizeOptions$5(options, optionInfos, Object.assign({
11855 var optionsNormalizer = {
11856 normalizeApiOptions,
11857 normalizeCliOptions
11861 isNonEmptyArray: isNonEmptyArray$i
11864 * @typedef {import("./types/estree").Node} Node
11867 function locStart$s(node, opts) {
11870 } = opts || {}; // Handle nodes with decorators. They should start at the first decorator
11872 if (!ignoreDecorators) {
11873 const decorators = node.declaration && node.declaration.decorators || node.decorators;
11875 if (isNonEmptyArray$i(decorators)) {
11876 return locStart$s(decorators[0]);
11880 return node.range ? node.range[0] : node.start;
11883 function locEnd$r(node) {
11884 return node.range ? node.range[1] : node.end;
11887 * @param {Node} nodeA
11888 * @param {Node} nodeB
11889 * @returns {boolean}
11893 function hasSameLocStart$1(nodeA, nodeB) {
11894 return locStart$s(nodeA) === locStart$s(nodeB);
11897 * @param {Node} nodeA
11898 * @param {Node} nodeB
11899 * @returns {boolean}
11903 function hasSameLocEnd(nodeA, nodeB) {
11904 return locEnd$r(nodeA) === locEnd$r(nodeB);
11907 * @param {Node} nodeA
11908 * @param {Node} nodeB
11909 * @returns {boolean}
11913 function hasSameLoc$1(nodeA, nodeB) {
11914 return hasSameLocStart$1(nodeA, nodeB) && hasSameLocEnd(nodeA, nodeB);
11918 locStart: locStart$s,
11920 hasSameLocStart: hasSameLocStart$1,
11921 hasSameLoc: hasSameLoc$1
11930 // License: MIT. (See LICENSE.)
11932 Object.defineProperty(jsTokens, "__esModule", {
11934 }); // This regex comes from regex.coffee, and is inserted here by generate-index.js
11935 // (run `npm run build`).
11937 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;
11939 jsTokens.matchToToken = function (match) {
11945 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";
11951 var identifier = {};
11953 Object.defineProperty(identifier, "__esModule", {
11956 identifier.isIdentifierStart = isIdentifierStart;
11957 identifier.isIdentifierChar = isIdentifierChar;
11958 identifier.isIdentifierName = isIdentifierName$1;
11959 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";
11960 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";
11961 const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
11962 const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
11963 nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
11964 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];
11965 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];
11967 function isInAstralSet(code, set) {
11970 for (let i = 0, length = set.length; i < length; i += 2) {
11972 if (pos > code) return false;
11974 if (pos >= code) return true;
11980 function isIdentifierStart(code) {
11981 if (code < 65) return code === 36;
11982 if (code <= 90) return true;
11983 if (code < 97) return code === 95;
11984 if (code <= 122) return true;
11986 if (code <= 0xffff) {
11987 return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
11990 return isInAstralSet(code, astralIdentifierStartCodes);
11993 function isIdentifierChar(code) {
11994 if (code < 48) return code === 36;
11995 if (code < 58) return true;
11996 if (code < 65) return false;
11997 if (code <= 90) return true;
11998 if (code < 97) return code === 95;
11999 if (code <= 122) return true;
12001 if (code <= 0xffff) {
12002 return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
12005 return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
12008 function isIdentifierName$1(name) {
12009 let isFirst = true;
12011 for (let i = 0; i < name.length; i++) {
12012 let cp = name.charCodeAt(i);
12014 if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) {
12015 const trail = name.charCodeAt(++i);
12017 if ((trail & 0xfc00) === 0xdc00) {
12018 cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
12025 if (!isIdentifierStart(cp)) {
12028 } else if (!isIdentifierChar(cp)) {
12036 var keyword$1 = {};
12038 Object.defineProperty(keyword$1, "__esModule", {
12041 keyword$1.isReservedWord = isReservedWord;
12042 keyword$1.isStrictReservedWord = isStrictReservedWord;
12043 keyword$1.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
12044 keyword$1.isStrictBindReservedWord = isStrictBindReservedWord;
12045 keyword$1.isKeyword = isKeyword;
12046 const reservedWords = {
12047 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"],
12048 strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
12049 strictBind: ["eval", "arguments"]
12051 const keywords$1 = new Set(reservedWords.keyword);
12052 const reservedWordsStrictSet = new Set(reservedWords.strict);
12053 const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
12055 function isReservedWord(word, inModule) {
12056 return inModule && word === "await" || word === "enum";
12059 function isStrictReservedWord(word, inModule) {
12060 return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
12063 function isStrictBindOnlyReservedWord(word) {
12064 return reservedWordsStrictBindSet.has(word);
12067 function isStrictBindReservedWord(word, inModule) {
12068 return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
12071 function isKeyword(word) {
12072 return keywords$1.has(word);
12075 (function (exports) {
12077 Object.defineProperty(exports, "__esModule", {
12080 Object.defineProperty(exports, "isIdentifierName", {
12083 return _identifier.isIdentifierName;
12086 Object.defineProperty(exports, "isIdentifierChar", {
12089 return _identifier.isIdentifierChar;
12092 Object.defineProperty(exports, "isIdentifierStart", {
12095 return _identifier.isIdentifierStart;
12098 Object.defineProperty(exports, "isReservedWord", {
12101 return _keyword.isReservedWord;
12104 Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
12107 return _keyword.isStrictBindOnlyReservedWord;
12110 Object.defineProperty(exports, "isStrictBindReservedWord", {
12113 return _keyword.isStrictBindReservedWord;
12116 Object.defineProperty(exports, "isStrictReservedWord", {
12119 return _keyword.isStrictReservedWord;
12122 Object.defineProperty(exports, "isKeyword", {
12125 return _keyword.isKeyword;
12128 var _identifier = identifier;
12129 var _keyword = keyword$1;
12132 var chalk = {exports: {}};
12134 var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
12136 var escapeStringRegexp = function (str) {
12137 if (typeof str !== 'string') {
12138 throw new TypeError('Expected a string');
12141 return str.replace(matchOperatorsRe, '\\$&');
12144 var hasFlag$1 = (flag, argv) => {
12145 argv = argv || process.argv;
12146 const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
12147 const pos = argv.indexOf(prefix + flag);
12148 const terminatorPos = argv.indexOf('--');
12149 return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
12152 const os$2 = require$$0__default$1["default"];
12153 const hasFlag = hasFlag$1;
12154 const env = process.env;
12157 if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
12158 forceColor = false;
12159 } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
12163 if ('FORCE_COLOR' in env) {
12164 forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
12167 function translateLevel(level) {
12175 has256: level >= 2,
12180 function supportsColor(stream) {
12181 if (forceColor === false) {
12185 if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
12189 if (hasFlag('color=256')) {
12193 if (stream && !stream.isTTY && forceColor !== true) {
12197 const min = forceColor ? 1 : 0;
12199 if (process.platform === 'win32') {
12200 // Node.js 7.5.0 is the first version of Node.js to include a patch to
12201 // libuv that enables 256 color output on Windows. Anything earlier and it
12202 // won't work. However, here we target Node.js 8 at minimum as it is an LTS
12203 // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
12204 // release that supports 256 colors. Windows 10 build 14931 is the first release
12205 // that supports 16m/TrueColor.
12206 const osRelease = os$2.release().split('.');
12208 if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
12209 return Number(osRelease[2]) >= 14931 ? 3 : 2;
12216 if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
12223 if ('TEAMCITY_VERSION' in env) {
12224 return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
12227 if (env.COLORTERM === 'truecolor') {
12231 if ('TERM_PROGRAM' in env) {
12232 const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
12234 switch (env.TERM_PROGRAM) {
12236 return version >= 3 ? 3 : 2;
12238 case 'Apple_Terminal':
12244 if (/-256(color)?$/i.test(env.TERM)) {
12248 if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
12252 if ('COLORTERM' in env) {
12256 if (env.TERM === 'dumb') {
12263 function getSupportLevel(stream) {
12264 const level = supportsColor(stream);
12265 return translateLevel(level);
12268 var supportsColor_1 = {
12269 supportsColor: getSupportLevel,
12270 stdout: getSupportLevel(process.stdout),
12271 stderr: getSupportLevel(process.stderr)
12274 const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
12275 const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
12276 const STRING_REGEX$1 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
12277 const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
12278 const ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
12280 function unescape(c) {
12281 if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
12282 return String.fromCharCode(parseInt(c.slice(1), 16));
12285 return ESCAPES.get(c) || c;
12288 function parseArguments(name, args) {
12289 const results = [];
12290 const chunks = args.trim().split(/\s*,\s*/g);
12293 for (const chunk of chunks) {
12294 if (!isNaN(chunk)) {
12295 results.push(Number(chunk));
12296 } else if (matches = chunk.match(STRING_REGEX$1)) {
12297 results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
12299 throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
12306 function parseStyle(style) {
12307 STYLE_REGEX.lastIndex = 0;
12308 const results = [];
12311 while ((matches = STYLE_REGEX.exec(style)) !== null) {
12312 const name = matches[1];
12315 const args = parseArguments(name, matches[2]);
12316 results.push([name].concat(args));
12318 results.push([name]);
12325 function buildStyle(chalk, styles) {
12326 const enabled = {};
12328 for (const layer of styles) {
12329 for (const style of layer.styles) {
12330 enabled[style[0]] = layer.inverse ? null : style.slice(1);
12334 let current = chalk;
12336 for (const styleName of Object.keys(enabled)) {
12337 if (Array.isArray(enabled[styleName])) {
12338 if (!(styleName in current)) {
12339 throw new Error(`Unknown Chalk style: ${styleName}`);
12342 if (enabled[styleName].length > 0) {
12343 current = current[styleName].apply(current, enabled[styleName]);
12345 current = current[styleName];
12353 var templates = (chalk, tmp) => {
12356 let chunk = []; // eslint-disable-next-line max-params
12358 tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
12360 chunk.push(unescape(escapeChar));
12361 } else if (style) {
12362 const str = chunk.join('');
12364 chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
12367 styles: parseStyle(style)
12369 } else if (close) {
12370 if (styles.length === 0) {
12371 throw new Error('Found extraneous } in Chalk template literal');
12374 chunks.push(buildStyle(chalk, styles)(chunk.join('')));
12381 chunks.push(chunk.join(''));
12383 if (styles.length > 0) {
12384 const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
12385 throw new Error(errMsg);
12388 return chunks.join('');
12391 (function (module) {
12393 const escapeStringRegexp$1 = escapeStringRegexp;
12394 const ansiStyles = ansiStyles$2.exports;
12395 const stdoutColor = supportsColor_1.stdout;
12396 const template = templates;
12397 const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
12399 const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
12401 const skipModels = new Set(['gray']);
12402 const styles = Object.create(null);
12404 function applyOptions(obj, options) {
12405 options = options || {}; // Detect level if not set manually
12407 const scLevel = stdoutColor ? stdoutColor.level : 0;
12408 obj.level = options.level === undefined ? scLevel : options.level;
12409 obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
12412 function Chalk(options) {
12413 // We check for this.template here since calling `chalk.constructor()`
12414 // by itself will have a `this` of a previously constructed chalk object
12415 if (!this || !(this instanceof Chalk) || this.template) {
12417 applyOptions(chalk, options);
12419 chalk.template = function () {
12420 const args = [].slice.call(arguments);
12421 return chalkTag.apply(null, [chalk.template].concat(args));
12424 Object.setPrototypeOf(chalk, Chalk.prototype);
12425 Object.setPrototypeOf(chalk.template, chalk);
12426 chalk.template.constructor = Chalk;
12427 return chalk.template;
12430 applyOptions(this, options);
12431 } // Use bright blue on Windows as the normal blue color is illegible
12434 if (isSimpleWindowsTerm) {
12435 ansiStyles.blue.open = '\u001B[94m';
12438 for (const key of Object.keys(ansiStyles)) {
12439 ansiStyles[key].closeRe = new RegExp(escapeStringRegexp$1(ansiStyles[key].close), 'g');
12442 const codes = ansiStyles[key];
12443 return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
12451 return build.call(this, this._styles || [], true, 'visible');
12455 ansiStyles.color.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles.color.close), 'g');
12457 for (const model of Object.keys(ansiStyles.color.ansi)) {
12458 if (skipModels.has(model)) {
12464 const level = this.level;
12465 return function () {
12466 const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
12469 close: ansiStyles.color.close,
12470 closeRe: ansiStyles.color.closeRe
12472 return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
12479 ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles.bgColor.close), 'g');
12481 for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
12482 if (skipModels.has(model)) {
12486 const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
12487 styles[bgModel] = {
12489 const level = this.level;
12490 return function () {
12491 const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
12494 close: ansiStyles.bgColor.close,
12495 closeRe: ansiStyles.bgColor.closeRe
12497 return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
12504 const proto = Object.defineProperties(() => {}, styles);
12506 function build(_styles, _empty, key) {
12507 const builder = function () {
12508 return applyStyle.apply(builder, arguments);
12511 builder._styles = _styles;
12512 builder._empty = _empty;
12514 Object.defineProperty(builder, 'level', {
12522 self.level = level;
12526 Object.defineProperty(builder, 'enabled', {
12530 return self.enabled;
12534 self.enabled = enabled;
12537 }); // See below for fix regarding invisible grey/dim combination on Windows
12539 builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
12540 // no way to create a function with a different prototype
12542 builder.__proto__ = proto; // eslint-disable-line no-proto
12547 function applyStyle() {
12548 // Support varags, but simply cast to string in case there's only one arg
12549 const args = arguments;
12550 const argsLen = args.length;
12551 let str = String(arguments[0]);
12553 if (argsLen === 0) {
12558 // Don't slice `arguments`, it prevents V8 optimizations
12559 for (let a = 1; a < argsLen; a++) {
12560 str += ' ' + args[a];
12564 if (!this.enabled || this.level <= 0 || !str) {
12565 return this._empty ? '' : str;
12566 } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
12567 // see https://github.com/chalk/chalk/issues/58
12568 // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
12571 const originalDim = ansiStyles.dim.open;
12573 if (isSimpleWindowsTerm && this.hasGrey) {
12574 ansiStyles.dim.open = '';
12577 for (const code of this._styles.slice().reverse()) {
12578 // Replace any instances already present with a re-opening code
12579 // otherwise only the part of the string until said closing code
12580 // will be colored, and the rest will simply be 'plain'.
12581 str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
12582 // after next line to fix a bleed issue on macOS
12583 // https://github.com/chalk/chalk/pull/92
12585 str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
12586 } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
12589 ansiStyles.dim.open = originalDim;
12593 function chalkTag(chalk, strings) {
12594 if (!Array.isArray(strings)) {
12595 // If chalk() was called by itself or with a string,
12596 // return the string itself as a string.
12597 return [].slice.call(arguments, 1).join(' ');
12600 const args = [].slice.call(arguments, 2);
12601 const parts = [strings.raw[0]];
12603 for (let i = 1; i < strings.length; i++) {
12604 parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
12605 parts.push(String(strings.raw[i]));
12608 return template(chalk, parts.join(''));
12611 Object.defineProperties(Chalk.prototype, styles);
12612 module.exports = Chalk(); // eslint-disable-line new-cap
12614 module.exports.supportsColor = stdoutColor;
12615 module.exports.default = module.exports; // For TypeScript
12618 Object.defineProperty(lib$2, "__esModule", {
12622 lib$2.default = highlight;
12624 lib$2.getChalk = getChalk;
12625 lib$2.shouldHighlight = shouldHighlight;
12626 var _jsTokens = jsTokens;
12627 var _helperValidatorIdentifier = lib$1;
12628 var _chalk = chalk.exports;
12629 const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
12631 function getDefs$1(chalk) {
12633 keyword: chalk.cyan,
12634 capitalized: chalk.yellow,
12635 jsxIdentifier: chalk.yellow,
12636 punctuator: chalk.yellow,
12637 number: chalk.magenta,
12638 string: chalk.green,
12639 regex: chalk.magenta,
12640 comment: chalk.grey,
12641 invalid: chalk.white.bgRed.bold
12645 const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
12646 const BRACKET = /^[()[\]{}]$/;
12649 const JSX_TAG = /^[a-z][\w-]*$/i;
12651 const getTokenType = function (token, offset, text) {
12652 if (token.type === "name") {
12653 if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) {
12657 if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
12658 return "jsxIdentifier";
12661 if (token.value[0] !== token.value[0].toLowerCase()) {
12662 return "capitalized";
12666 if (token.type === "punctuator" && BRACKET.test(token.value)) {
12670 if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
12671 return "punctuator";
12677 tokenize = function* (text) {
12680 while (match = _jsTokens.default.exec(text)) {
12681 const token = _jsTokens.matchToToken(match);
12684 type: getTokenType(token, match.index, text),
12691 function highlightTokens(defs, text) {
12692 let highlighted = "";
12697 } of tokenize(text)) {
12698 const colorize = defs[type];
12701 highlighted += value.split(NEWLINE$1).map(str => colorize(str)).join("\n");
12703 highlighted += value;
12707 return highlighted;
12710 function shouldHighlight(options) {
12711 return !!_chalk.supportsColor || options.forceColor;
12714 function getChalk(options) {
12715 return options.forceColor ? new _chalk.constructor({
12721 function highlight(code, options = {}) {
12722 if (shouldHighlight(options)) {
12723 const chalk = getChalk(options);
12724 const defs = getDefs$1(chalk);
12725 return highlightTokens(defs, code);
12731 Object.defineProperty(lib$3, "__esModule", {
12734 lib$3.codeFrameColumns = codeFrameColumns;
12735 lib$3.default = _default;
12736 var _highlight = lib$2;
12737 let deprecationWarningShown = false;
12739 function getDefs(chalk) {
12741 gutter: chalk.grey,
12742 marker: chalk.red.bold,
12743 message: chalk.red.bold
12747 const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
12749 function getMarkerLines(loc, source, opts) {
12750 const startLoc = Object.assign({
12754 const endLoc = Object.assign({}, startLoc, loc.end);
12759 const startLine = startLoc.line;
12760 const startColumn = startLoc.column;
12761 const endLine = endLoc.line;
12762 const endColumn = endLoc.column;
12763 let start = Math.max(startLine - (linesAbove + 1), 0);
12764 let end = Math.min(source.length, endLine + linesBelow);
12766 if (startLine === -1) {
12770 if (endLine === -1) {
12771 end = source.length;
12774 const lineDiff = endLine - startLine;
12775 const markerLines = {};
12778 for (let i = 0; i <= lineDiff; i++) {
12779 const lineNumber = i + startLine;
12781 if (!startColumn) {
12782 markerLines[lineNumber] = true;
12783 } else if (i === 0) {
12784 const sourceLength = source[lineNumber - 1].length;
12785 markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
12786 } else if (i === lineDiff) {
12787 markerLines[lineNumber] = [0, endColumn];
12789 const sourceLength = source[lineNumber - i].length;
12790 markerLines[lineNumber] = [0, sourceLength];
12794 if (startColumn === endColumn) {
12796 markerLines[startLine] = [startColumn, 0];
12798 markerLines[startLine] = true;
12801 markerLines[startLine] = [startColumn, endColumn - startColumn];
12812 function codeFrameColumns(rawLines, loc, opts = {}) {
12813 const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts);
12814 const chalk = (0, _highlight.getChalk)(opts);
12815 const defs = getDefs(chalk);
12817 const maybeHighlight = (chalkFn, string) => {
12818 return highlighted ? chalkFn(string) : string;
12821 const lines = rawLines.split(NEWLINE);
12826 } = getMarkerLines(loc, lines, opts);
12827 const hasColumns = loc.start && typeof loc.start.column === "number";
12828 const numberMaxWidth = String(end).length;
12829 const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines;
12830 let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
12831 const number = start + 1 + index;
12832 const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
12833 const gutter = ` ${paddedNumber} |`;
12834 const hasMarker = markerLines[number];
12835 const lastMarkerLine = !markerLines[number + 1];
12838 let markerLine = "";
12840 if (Array.isArray(hasMarker)) {
12841 const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
12842 const numberOfMarkers = hasMarker[1] || 1;
12843 markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), " ", markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
12845 if (lastMarkerLine && opts.message) {
12846 markerLine += " " + maybeHighlight(defs.message, opts.message);
12850 return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
12852 return ` ${maybeHighlight(defs.gutter, gutter)}${line.length > 0 ? ` ${line}` : ""}`;
12856 if (opts.message && !hasColumns) {
12857 frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
12861 return chalk.reset(frame);
12867 function _default(rawLines, lineNumber, colNumber, opts = {}) {
12868 if (!deprecationWarningShown) {
12869 deprecationWarningShown = true;
12870 const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
12872 if (process.emitWarning) {
12873 process.emitWarning(message, "DeprecationWarning");
12875 const deprecationError = new Error(message);
12876 deprecationError.name = "DeprecationWarning";
12877 console.warn(new Error(message));
12881 colNumber = Math.max(colNumber, 0);
12888 return codeFrameColumns(rawLines, location, opts);
12891 const path$q = require$$0__default$2["default"];
12895 const jsLoc = loc$6;
12897 locStart: locStart$r,
12899 } = jsLoc; // Use defineProperties()/getOwnPropertyDescriptor() to prevent
12900 // triggering the parsers getters.
12902 const ownNames = Object.getOwnPropertyNames;
12903 const ownDescriptor = Object.getOwnPropertyDescriptor;
12905 function getParsers(options) {
12906 const parsers = {};
12908 for (const plugin of options.plugins) {
12909 // TODO: test this with plugins
12911 /* istanbul ignore next */
12912 if (!plugin.parsers) {
12916 for (const name of ownNames(plugin.parsers)) {
12917 Object.defineProperty(parsers, name, ownDescriptor(plugin.parsers, name));
12924 function resolveParser$1(opts, parsers = getParsers(opts)) {
12925 if (typeof opts.parser === "function") {
12926 // Custom parser API always works with JavaScript.
12928 parse: opts.parser,
12929 astFormat: "estree",
12930 locStart: locStart$r,
12935 if (typeof opts.parser === "string") {
12936 if (Object.prototype.hasOwnProperty.call(parsers, opts.parser)) {
12937 return parsers[opts.parser];
12942 parse: require(path$q.resolve(process.cwd(), opts.parser)),
12943 astFormat: "estree",
12944 locStart: locStart$r,
12948 /* istanbul ignore next */
12949 throw new ConfigError(`Couldn't resolve parser "${opts.parser}"`);
12954 function parse$d(text, opts) {
12955 const parsers = getParsers(opts); // Create a new object {parserName: parseFn}. Uses defineProperty() to only call
12956 // the parsers getters when actually calling the parser `parse` function.
12958 const parsersForCustomParserApi = Object.defineProperties({}, Object.fromEntries(Object.keys(parsers).map(parserName => [parserName, {
12962 return parsers[parserName].parse;
12966 const parser = resolveParser$1(opts, parsers);
12969 if (parser.preprocess) {
12970 text = parser.preprocess(text, opts);
12975 ast: parser.parse(text, parsersForCustomParserApi, opts)
12986 error.codeFrame = codeFrameColumns(text, loc, {
12987 highlightCode: true
12989 error.message += "\n" + error.codeFrame;
12992 /* istanbul ignore next */
13001 resolveParser: resolveParser$1
13004 const fs$k = require$$0__default["default"];
13005 const path$p = require$$0__default$2["default"];
13006 const readlines = readlines$1;
13008 UndefinedParserError
13011 getSupportInfo: getSupportInfo$1
13013 const normalizer = optionsNormalizer;
13017 const hiddenDefaults = {
13018 astFormat: "estree",
13020 originalText: undefined,
13023 }; // Copy options and fill in default values.
13025 function normalize$1(options, opts = {}) {
13026 const rawOptions = Object.assign({}, options);
13027 const supportOptions = getSupportInfo$1({
13028 plugins: options.plugins,
13029 showUnreleased: true,
13030 showDeprecated: true
13032 const defaults = Object.assign(Object.assign({}, hiddenDefaults), Object.fromEntries(supportOptions.filter(optionInfo => optionInfo.default !== undefined).map(option => [option.name, option.default])));
13034 if (!rawOptions.parser) {
13035 if (!rawOptions.filepath) {
13036 const logger = opts.logger || console;
13037 logger.warn("No parser and no filepath given, using 'babel' the parser now " + "but this will throw an error in the future. " + "Please specify a parser or a filepath so one can be inferred.");
13038 rawOptions.parser = "babel";
13040 rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins);
13042 if (!rawOptions.parser) {
13043 throw new UndefinedParserError(`No parser could be inferred for file: ${rawOptions.filepath}`);
13048 const parser = resolveParser(normalizer.normalizeApiOptions(rawOptions, [supportOptions.find(x => x.name === "parser")], {
13052 rawOptions.astFormat = parser.astFormat;
13053 rawOptions.locEnd = parser.locEnd;
13054 rawOptions.locStart = parser.locStart;
13055 const plugin = getPlugin(rawOptions);
13056 rawOptions.printer = plugin.printers[rawOptions.astFormat];
13057 const pluginDefaults = Object.fromEntries(supportOptions.filter(optionInfo => optionInfo.pluginDefaults && optionInfo.pluginDefaults[plugin.name] !== undefined).map(optionInfo => [optionInfo.name, optionInfo.pluginDefaults[plugin.name]]));
13058 const mixedDefaults = Object.assign(Object.assign({}, defaults), pluginDefaults);
13060 for (const [k, value] of Object.entries(mixedDefaults)) {
13061 if (rawOptions[k] === null || rawOptions[k] === undefined) {
13062 rawOptions[k] = value;
13066 if (rawOptions.parser === "json") {
13067 rawOptions.trailingComma = "none";
13070 return normalizer.normalizeApiOptions(rawOptions, supportOptions, Object.assign({
13071 passThrough: Object.keys(hiddenDefaults)
13075 function getPlugin(options) {
13078 } = options; // TODO: test this with plugins
13080 /* istanbul ignore next */
13083 throw new Error("getPlugin() requires astFormat to be set");
13086 const printerPlugin = options.plugins.find(plugin => plugin.printers && plugin.printers[astFormat]); // TODO: test this with plugins
13088 /* istanbul ignore next */
13090 if (!printerPlugin) {
13091 throw new Error(`Couldn't find plugin for AST format "${astFormat}"`);
13094 return printerPlugin;
13097 function getInterpreter(filepath) {
13098 /* istanbul ignore next */
13099 if (typeof filepath !== "string") {
13106 fd = fs$k.openSync(filepath, "r");
13108 // istanbul ignore next
13113 const liner = new readlines(fd);
13114 const firstLine = liner.next().toString("utf8"); // #!/bin/env node, #!/usr/bin/env node
13116 const m1 = firstLine.match(/^#!\/(?:usr\/)?bin\/env\s+(\S+)/);
13120 } // #!/bin/node, #!/usr/bin/node, #!/usr/local/bin/node
13123 const m2 = firstLine.match(/^#!\/(?:usr\/(?:local\/)?)?bin\/(\S+)/);
13131 // There are some weird cases where paths are missing, causing Jest
13132 // failures. It's unclear what these correspond to in the real world.
13134 /* istanbul ignore next */
13138 // There are some weird cases where paths are missing, causing Jest
13139 // failures. It's unclear what these correspond to in the real world.
13140 fs$k.closeSync(fd);
13146 function inferParser(filepath, plugins) {
13147 const filename = path$p.basename(filepath).toLowerCase();
13148 const languages = getSupportInfo$1({
13150 }).languages.filter(language => language.since !== null); // If the file has no extension, we can try to infer the language from the
13151 // interpreter in the shebang line, if any; but since this requires FS access,
13154 let language = languages.find(language => language.extensions && language.extensions.some(extension => filename.endsWith(extension)) || language.filenames && language.filenames.some(name => name.toLowerCase() === filename));
13156 if (!language && !filename.includes(".")) {
13157 const interpreter = getInterpreter(filepath);
13158 language = languages.find(language => language.interpreters && language.interpreters.includes(interpreter));
13161 return language && language.parsers[0];
13165 normalize: normalize$1,
13170 function massageAST$1(ast, options, parent) {
13171 if (Array.isArray(ast)) {
13172 return ast.map(e => massageAST$1(e, options, parent)).filter(Boolean);
13175 if (!ast || typeof ast !== "object") {
13179 const cleanFunction = options.printer.massageAstNode;
13180 let ignoredProperties;
13182 if (cleanFunction && cleanFunction.ignoredProperties) {
13183 ignoredProperties = cleanFunction.ignoredProperties;
13185 ignoredProperties = new Set();
13190 for (const [key, value] of Object.entries(ast)) {
13191 if (!ignoredProperties.has(key) && typeof value !== "function") {
13192 newObj[key] = massageAST$1(value, options, ast);
13196 if (cleanFunction) {
13197 const result = cleanFunction(ast, newObj, parent);
13199 if (result === null) {
13211 var massageAst = massageAST$1;
13213 const assert$6 = require$$0__default$3["default"];
13217 hardline: hardline$C,
13218 breakParent: breakParent$a,
13220 lineSuffix: lineSuffix$1,
13226 hasNewline: hasNewline$9,
13227 skipNewline: skipNewline$1,
13228 skipSpaces: skipSpaces$1,
13229 isPreviousLineEmpty: isPreviousLineEmpty$2,
13230 addLeadingComment: addLeadingComment$2,
13231 addDanglingComment: addDanglingComment$2,
13232 addTrailingComment: addTrailingComment$2
13234 const childNodesCache = new WeakMap();
13236 function getSortedChildNodes(node, options, resultArray) {
13248 if (printer.canAttachComment && printer.canAttachComment(node)) {
13249 // This reverse insertion sort almost always takes constant
13250 // time because we almost always (maybe always?) append the
13251 // nodes in order anyway.
13254 for (i = resultArray.length - 1; i >= 0; --i) {
13255 if (locStart(resultArray[i]) <= locStart(node) && locEnd(resultArray[i]) <= locEnd(node)) {
13260 resultArray.splice(i + 1, 0, node);
13263 } else if (childNodesCache.has(node)) {
13264 return childNodesCache.get(node);
13267 const childNodes = printer.getCommentChildNodes && printer.getCommentChildNodes(node, options) || typeof node === "object" && Object.entries(node).filter(([key]) => key !== "enclosingNode" && key !== "precedingNode" && key !== "followingNode" && key !== "tokens" && key !== "comments").map(([, value]) => value);
13273 if (!resultArray) {
13275 childNodesCache.set(node, resultArray);
13278 for (const childNode of childNodes) {
13279 getSortedChildNodes(childNode, options, resultArray);
13282 return resultArray;
13283 } // As efficiently as possible, decorate the comment object with
13284 // .precedingNode, .enclosingNode, and/or .followingNode properties, at
13285 // least one of which is guaranteed to be defined.
13288 function decorateComment(node, comment, options, enclosingNode) {
13293 const commentStart = locStart(comment);
13294 const commentEnd = locEnd(comment);
13295 const childNodes = getSortedChildNodes(node, options);
13297 let followingNode; // Time to dust off the old binary search robes and wizard hat.
13300 let right = childNodes.length;
13302 while (left < right) {
13303 const middle = left + right >> 1;
13304 const child = childNodes[middle];
13305 const start = locStart(child);
13306 const end = locEnd(child); // The comment is completely contained by this child node.
13308 if (start <= commentStart && commentEnd <= end) {
13309 // Abandon the binary search at this level.
13310 return decorateComment(child, comment, options, child);
13313 if (end <= commentStart) {
13314 // This child node falls completely before the comment.
13315 // Because we will never consider this node or any nodes
13316 // before it again, this node must be the closest preceding
13317 // node we have encountered so far.
13318 precedingNode = child;
13323 if (commentEnd <= start) {
13324 // This child node falls completely after the comment.
13325 // Because we will never consider this node or any nodes after
13326 // it again, this node must be the closest following node we
13327 // have encountered so far.
13328 followingNode = child;
13332 /* istanbul ignore next */
13335 throw new Error("Comment location overlaps with node location");
13336 } // We don't want comments inside of different expressions inside of the same
13337 // template literal to move to another expression.
13340 if (enclosingNode && enclosingNode.type === "TemplateLiteral") {
13344 const commentIndex = findExpressionIndexForComment(quasis, comment, options);
13346 if (precedingNode && findExpressionIndexForComment(quasis, precedingNode, options) !== commentIndex) {
13347 precedingNode = null;
13350 if (followingNode && findExpressionIndexForComment(quasis, followingNode, options) !== commentIndex) {
13351 followingNode = null;
13362 const returnFalse$1 = () => false;
13364 function attach(comments, ast, text, options) {
13365 if (!Array.isArray(comments)) {
13369 const tiesToBreak = [];
13374 handleComments = {}
13376 } = options; // TODO: Make this as default behavior
13380 ownLine: handleOwnLineComment = returnFalse$1,
13381 endOfLine: handleEndOfLineComment = returnFalse$1,
13382 remaining: handleRemainingComment = returnFalse$1
13383 } = handleComments;
13384 const decoratedComments = comments.map((comment, index) => Object.assign(Object.assign({}, decorateComment(ast, comment, options)), {}, {
13389 isLastComment: comments.length - 1 === index
13392 for (const [index, context] of decoratedComments.entries()) {
13404 if (options.parser === "json" || options.parser === "json5" || options.parser === "__js_expression" || options.parser === "__vue_expression") {
13405 if (locStart(comment) - locStart(ast) <= 0) {
13406 addLeadingComment$2(ast, comment);
13410 if (locEnd(comment) - locEnd(ast) >= 0) {
13411 addTrailingComment$2(ast, comment);
13418 if (avoidAstMutation) {
13421 comment.enclosingNode = enclosingNode;
13422 comment.precedingNode = precedingNode;
13423 comment.followingNode = followingNode;
13424 args = [comment, text, options, ast, isLastComment];
13427 if (isOwnLineComment(text, options, decoratedComments, index)) {
13428 comment.placement = "ownLine"; // If a comment exists on its own line, prefer a leading comment.
13429 // We also need to check if it's the first line of the file.
13431 if (handleOwnLineComment(...args)) ; else if (followingNode) {
13432 // Always a leading comment.
13433 addLeadingComment$2(followingNode, comment);
13434 } else if (precedingNode) {
13435 addTrailingComment$2(precedingNode, comment);
13436 } else if (enclosingNode) {
13437 addDanglingComment$2(enclosingNode, comment);
13439 // There are no nodes, let's attach it to the root of the ast
13441 /* istanbul ignore next */
13442 addDanglingComment$2(ast, comment);
13444 } else if (isEndOfLineComment(text, options, decoratedComments, index)) {
13445 comment.placement = "endOfLine";
13447 if (handleEndOfLineComment(...args)) ; else if (precedingNode) {
13448 // There is content before this comment on the same line, but
13449 // none after it, so prefer a trailing comment of the previous node.
13450 addTrailingComment$2(precedingNode, comment);
13451 } else if (followingNode) {
13452 addLeadingComment$2(followingNode, comment);
13453 } else if (enclosingNode) {
13454 addDanglingComment$2(enclosingNode, comment);
13456 // There are no nodes, let's attach it to the root of the ast
13458 /* istanbul ignore next */
13459 addDanglingComment$2(ast, comment);
13462 comment.placement = "remaining";
13464 if (handleRemainingComment(...args)) ; else if (precedingNode && followingNode) {
13465 // Otherwise, text exists both before and after the comment on
13466 // the same line. If there is both a preceding and following
13467 // node, use a tie-breaking algorithm to determine if it should
13468 // be attached to the next or previous node. In the last case,
13469 // simply attach the right node;
13470 const tieCount = tiesToBreak.length;
13472 if (tieCount > 0) {
13473 const lastTie = tiesToBreak[tieCount - 1];
13475 if (lastTie.followingNode !== followingNode) {
13476 breakTies(tiesToBreak, text, options);
13480 tiesToBreak.push(context);
13481 } else if (precedingNode) {
13482 addTrailingComment$2(precedingNode, comment);
13483 } else if (followingNode) {
13484 addLeadingComment$2(followingNode, comment);
13485 } else if (enclosingNode) {
13486 addDanglingComment$2(enclosingNode, comment);
13488 // There are no nodes, let's attach it to the root of the ast
13490 /* istanbul ignore next */
13491 addDanglingComment$2(ast, comment);
13496 breakTies(tiesToBreak, text, options);
13498 if (!avoidAstMutation) {
13499 for (const comment of comments) {
13500 // These node references were useful for breaking ties, but we
13501 // don't need them anymore, and they create cycles in the AST that
13502 // may lead to infinite recursion if we don't delete them here.
13503 delete comment.precedingNode;
13504 delete comment.enclosingNode;
13505 delete comment.followingNode;
13510 const isAllEmptyAndNoLineBreak = text => !/[\S\n\u2028\u2029]/.test(text);
13512 function isOwnLineComment(text, options, decoratedComments, commentIndex) {
13516 } = decoratedComments[commentIndex];
13521 let start = locStart(comment);
13523 if (precedingNode) {
13524 // Find first comment on the same line
13525 for (let index = commentIndex - 1; index >= 0; index--) {
13528 precedingNode: currentCommentPrecedingNode
13529 } = decoratedComments[index];
13531 if (currentCommentPrecedingNode !== precedingNode || !isAllEmptyAndNoLineBreak(text.slice(locEnd(comment), start))) {
13535 start = locStart(comment);
13539 return hasNewline$9(text, start, {
13544 function isEndOfLineComment(text, options, decoratedComments, commentIndex) {
13548 } = decoratedComments[commentIndex];
13553 let end = locEnd(comment);
13555 if (followingNode) {
13556 // Find last comment on the same line
13557 for (let index = commentIndex + 1; index < decoratedComments.length; index++) {
13560 followingNode: currentCommentFollowingNode
13561 } = decoratedComments[index];
13563 if (currentCommentFollowingNode !== followingNode || !isAllEmptyAndNoLineBreak(text.slice(end, locStart(comment)))) {
13567 end = locEnd(comment);
13571 return hasNewline$9(text, end);
13574 function breakTies(tiesToBreak, text, options) {
13575 const tieCount = tiesToBreak.length;
13577 if (tieCount === 0) {
13585 } = tiesToBreak[0];
13586 const gapRegExp = options.printer.getGapRegex && options.printer.getGapRegex(enclosingNode) || /^[\s(]*$/;
13587 let gapEndPos = options.locStart(followingNode); // Iterate backwards through tiesToBreak, examining the gaps
13588 // between the tied comments. In order to qualify as leading, a
13589 // comment must be separated from followingNode by an unbroken series of
13590 // gaps (or other comments). Gaps should only contain whitespace or open
13593 let indexOfFirstLeadingComment;
13595 for (indexOfFirstLeadingComment = tieCount; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) {
13598 precedingNode: currentCommentPrecedingNode,
13599 followingNode: currentCommentFollowingNode
13600 } = tiesToBreak[indexOfFirstLeadingComment - 1];
13601 assert$6.strictEqual(currentCommentPrecedingNode, precedingNode);
13602 assert$6.strictEqual(currentCommentFollowingNode, followingNode);
13603 const gap = text.slice(options.locEnd(comment), gapEndPos);
13605 if (gapRegExp.test(gap)) {
13606 gapEndPos = options.locStart(comment);
13608 // The gap string contained something other than whitespace or open
13616 }] of tiesToBreak.entries()) {
13617 if (i < indexOfFirstLeadingComment) {
13618 addTrailingComment$2(precedingNode, comment);
13620 addLeadingComment$2(followingNode, comment);
13624 for (const node of [precedingNode, followingNode]) {
13625 if (node.comments && node.comments.length > 1) {
13626 node.comments.sort((a, b) => options.locStart(a) - options.locStart(b));
13630 tiesToBreak.length = 0;
13633 function printComment$3(path, options) {
13634 const comment = path.getValue();
13635 comment.printed = true;
13636 return options.printer.printComment(path, options);
13639 function findExpressionIndexForComment(quasis, comment, options) {
13640 const startPos = options.locStart(comment) - 1;
13642 for (let i = 1; i < quasis.length; ++i) {
13643 if (startPos < options.locStart(quasis[i])) {
13646 } // We haven't found it, it probably means that some of the locations are off.
13647 // Let's just return the first one.
13649 /* istanbul ignore next */
13655 function printLeadingComment(path, options) {
13656 const comment = path.getValue();
13657 const parts = [printComment$3(path, options)];
13664 const isBlock = printer.isBlockComment && printer.isBlockComment(comment); // Leading block comments should see if they need to stay on the
13665 // same line or not.
13668 const lineBreak = hasNewline$9(originalText, locEnd(comment)) ? hasNewline$9(originalText, locStart(comment), {
13670 }) ? hardline$C : line$A : " ";
13671 parts.push(lineBreak);
13673 parts.push(hardline$C);
13676 const index = skipNewline$1(originalText, skipSpaces$1(originalText, locEnd(comment)));
13678 if (index !== false && hasNewline$9(originalText, index)) {
13679 parts.push(hardline$C);
13685 function printTrailingComment(path, options) {
13686 const comment = path.getValue();
13687 const printed = printComment$3(path, options);
13693 const isBlock = printer.isBlockComment && printer.isBlockComment(comment);
13695 if (hasNewline$9(originalText, locStart(comment), {
13698 // This allows comments at the end of nested structures:
13704 // Those kinds of comments are almost always leading comments, but
13705 // here it doesn't go "outside" the block and turns it into a
13706 // trailing comment for `2`. We can simulate the above by checking
13707 // if this a comment on its own line; normal trailing comments are
13708 // always at the end of another expression.
13709 const isLineBeforeEmpty = isPreviousLineEmpty$2(originalText, comment, locStart);
13710 return lineSuffix$1([hardline$C, isLineBeforeEmpty ? hardline$C : "", printed]);
13713 let parts = [" ", printed]; // Trailing block comments never need a newline
13716 parts = [lineSuffix$1(parts), breakParent$a];
13722 function printDanglingComments$e(path, options, sameIndent, filter) {
13724 const node = path.getValue();
13726 if (!node || !node.comments) {
13731 const comment = path.getValue();
13733 if (!comment.leading && !comment.trailing && (!filter || filter(comment))) {
13734 parts.push(printComment$3(path, options));
13738 if (parts.length === 0) {
13743 return join$v(hardline$C, parts);
13746 return indent$z([hardline$C, join$v(hardline$C, parts)]);
13749 function printCommentsSeparately$1(path, options, ignored) {
13750 const value = path.getValue();
13756 let comments = value.comments || [];
13759 comments = comments.filter(comment => !ignored.has(comment));
13762 const isCursorNode = value === options.cursorNode;
13764 if (comments.length === 0) {
13765 const maybeCursor = isCursorNode ? cursor : "";
13767 leading: maybeCursor,
13768 trailing: maybeCursor
13772 const leadingParts = [];
13773 const trailingParts = [];
13775 const comment = path.getValue();
13777 if (ignored && ignored.has(comment)) {
13787 leadingParts.push(printLeadingComment(path, options));
13788 } else if (trailing) {
13789 trailingParts.push(printTrailingComment(path, options));
13793 if (isCursorNode) {
13794 leadingParts.unshift(cursor);
13795 trailingParts.push(cursor);
13799 leading: leadingParts,
13800 trailing: trailingParts
13804 function printComments$7(path, doc, options, ignored) {
13808 } = printCommentsSeparately$1(path, options, ignored);
13810 if (!leading && !trailing) {
13814 return [leading, doc, trailing];
13817 function ensureAllCommentsPrinted(astComments) {
13818 if (!astComments) {
13822 for (const comment of astComments) {
13823 if (!comment.printed) {
13824 throw new Error('Comment "' + comment.value.trim() + '" was not printed. Please report this error!');
13827 delete comment.printed;
13833 printComments: printComments$7,
13834 printCommentsSeparately: printCommentsSeparately$1,
13835 printDanglingComments: printDanglingComments$e,
13836 getSortedChildNodes,
13837 ensureAllCommentsPrinted
13840 const getLast$m = getLast_1;
13842 function getNodeHelper(path, count) {
13843 const stackIndex = getNodeStackIndexHelper(path.stack, count);
13844 return stackIndex === -1 ? null : path.stack[stackIndex];
13847 function getNodeStackIndexHelper(stack, count) {
13848 for (let i = stack.length - 1; i >= 0; i -= 2) {
13849 const value = stack[i];
13851 if (value && !Array.isArray(value) && --count < 0) {
13860 constructor(value) {
13861 this.stack = [value];
13862 } // The name of the current property is always the penultimate element of
13863 // this.stack, and always a String.
13875 return stack[length - 2];
13876 } // Since the name is always a string, null is a safe sentinel value to
13877 // return if we do not know the name of the (root) value.
13879 /* istanbul ignore next */
13883 } // The value of the current property is always the final element of
13888 return getLast$m(this.stack);
13891 getNode(count = 0) {
13892 return getNodeHelper(this, count);
13895 getParentNode(count = 0) {
13896 return getNodeHelper(this, count + 1);
13897 } // Temporarily push properties named by string arguments given after the
13898 // callback function onto this.stack, then call the callback with a
13899 // reference to this (modified) AstPath object. Note that the stack will
13900 // be restored to its original state after the callback is finished, so it
13901 // is probably a mistake to retain a reference to the path.
13904 call(callback, ...names) {
13911 let value = getLast$m(stack);
13913 for (const name of names) {
13914 value = value[name];
13915 stack.push(name, value);
13918 const result = callback(this);
13919 stack.length = length;
13923 callParent(callback, count = 0) {
13924 const stackIndex = getNodeStackIndexHelper(this.stack, count + 1);
13925 const parentValues = this.stack.splice(stackIndex + 1);
13926 const result = callback(this);
13927 this.stack.push(...parentValues);
13929 } // Similar to AstPath.prototype.call, except that the value obtained by
13930 // accessing this.getValue()[name1][name2]... should be array. The
13931 // callback will be called with a reference to this path object for each
13932 // element of the array.
13935 each(callback, ...names) {
13942 let value = getLast$m(stack);
13944 for (const name of names) {
13945 value = value[name];
13946 stack.push(name, value);
13949 for (let i = 0; i < value.length; ++i) {
13950 stack.push(i, value[i]);
13951 callback(this, i, value);
13955 stack.length = length;
13956 } // Similar to AstPath.prototype.each, except that the results of the
13957 // callback function invocations are stored in an array and returned at
13958 // the end of the iteration.
13961 map(callback, ...names) {
13963 this.each((path, index, value) => {
13964 result[index] = callback(path, index, value);
13969 * @param {() => void} callback
13970 * @internal Unstable API. Don't use in plugins for now.
13978 const stackBackup = [...stack];
13984 stack.push(...stackBackup);
13989 * | ((node: any, name: string | null, number: number | null) => boolean)
13995 match(...predicates) {
13996 let stackPointer = this.stack.length - 1;
13998 let node = this.stack[stackPointer--];
14000 for (const predicate of predicates) {
14001 /* istanbul ignore next */
14002 if (node === undefined) {
14004 } // skip index/array
14009 if (typeof name === "number") {
14011 name = this.stack[stackPointer--];
14012 node = this.stack[stackPointer--];
14015 if (predicate && !predicate(node, name, number)) {
14019 name = this.stack[stackPointer--];
14020 node = this.stack[stackPointer--];
14026 * Traverses the ancestors of the current node heading toward the tree root
14027 * until it finds a node that matches the provided predicate function. Will
14028 * return the first matching ancestor. If no such node exists, returns undefined.
14029 * @param {(node: any, name: string, number: number | null) => boolean} predicate
14030 * @internal Unstable API. Don't use in plugins for now.
14034 findAncestor(predicate) {
14035 let stackPointer = this.stack.length - 1;
14037 let node = this.stack[stackPointer--];
14040 // skip index/array
14043 if (typeof name === "number") {
14045 name = this.stack[stackPointer--];
14046 node = this.stack[stackPointer--];
14049 if (name !== null && predicate(node, name, number)) {
14053 name = this.stack[stackPointer--];
14054 node = this.stack[stackPointer--];
14060 var astPath = AstPath$1;
14064 stripTrailingHardline
14070 const comments$3 = comments$4;
14072 function printSubtree(path, print, options, printAstToDoc) {
14073 if (options.printer.embed && options.embeddedLanguageFormatting === "auto") {
14074 return options.printer.embed(path, print, (text, partialNextOptions, textToDocOptions) => textToDoc(text, partialNextOptions, options, printAstToDoc, textToDocOptions), options);
14078 function textToDoc(text, partialNextOptions, parentOptions, printAstToDoc, // TODO: remove `stripTrailingHardline` in v3.0.0
14080 stripTrailingHardline: shouldStripTrailingHardline = false
14082 const nextOptions = normalize(Object.assign(Object.assign(Object.assign({}, parentOptions), partialNextOptions), {}, {
14083 parentParser: parentOptions.parser,
14088 const result = parser$2.parse(text, nextOptions);
14092 text = result.text;
14093 const astComments = ast.comments;
14094 delete ast.comments;
14095 comments$3.attach(astComments, ast, text, nextOptions);
14096 nextOptions[Symbol.for("comments")] = astComments || [];
14097 nextOptions[Symbol.for("tokens")] = ast.tokens || [];
14098 const doc = printAstToDoc(ast, nextOptions);
14099 comments$3.ensureAllCommentsPrinted(astComments);
14101 if (shouldStripTrailingHardline) {
14102 // TODO: move this to `stripTrailingHardline` function in `/src/document/doc-utils.js`
14103 if (typeof doc === "string") {
14104 return doc.replace(/(?:\r?\n)*$/, "");
14107 return stripTrailingHardline(doc);
14109 /* istanbul ignore next */
14115 var multiparser$1 = {
14119 const AstPath = astPath;
14122 hardline: hardline$B,
14123 addAlignmentToDoc: addAlignmentToDoc$1
14130 printComments: printComments$6
14132 const multiparser = multiparser$1;
14134 * Takes an abstract syntax tree (AST) and recursively converts it to a
14135 * document (series of printing primitives).
14137 * This is done by descending down the AST recursively. The recursion
14138 * involves two functions that call each other:
14140 * 1. mainPrint(), which is defined as an inner function here.
14141 * It basically takes care of node caching.
14142 * 2. callPluginPrintFunction(), which checks for some options, and
14143 * ultimately calls the print() function provided by the plugin.
14145 * The plugin function will call mainPrint() again for child nodes
14146 * of the current node. mainPrint() will do its housekeeping, then call
14147 * the plugin function again, and so on.
14149 * All the while, these functions pass a "path" variable around, which
14150 * is a stack-like data structure (AstPath) that maintains the current
14151 * state of the recursion. It is called "path", because it represents
14152 * the path to the current node through the Abstract Syntax Tree.
14155 function printAstToDoc$1(ast, options, alignmentSize = 0) {
14160 if (printer.preprocess) {
14161 ast = printer.preprocess(ast, options);
14164 const cache = new Map();
14165 const path = new AstPath(ast);
14166 let doc = mainPrint();
14168 if (alignmentSize > 0) {
14169 // Add a hardline to make the indents take effect
14170 // It should be removed in index.js format()
14171 doc = addAlignmentToDoc$1([hardline$B, doc], alignmentSize, options.tabWidth);
14174 propagateBreaks(doc);
14177 function mainPrint(selector, args) {
14178 if (selector === undefined || selector === path) {
14179 return mainPrintInternal(args);
14182 if (Array.isArray(selector)) {
14183 return path.call(() => mainPrintInternal(args), ...selector);
14186 return path.call(() => mainPrintInternal(args), selector);
14189 function mainPrintInternal(args) {
14190 const value = path.getValue();
14191 const shouldCache = value && typeof value === "object" && args === undefined;
14193 if (shouldCache && cache.has(value)) {
14194 return cache.get(value);
14197 const doc = callPluginPrintFunction(path, options, mainPrint, args);
14200 cache.set(value, doc);
14207 function printPrettierIgnoredNode(node, options) {
14210 [Symbol.for("comments")]: comments,
14214 const start = locStart(node);
14215 const end = locEnd(node);
14216 const printedComments = new Set();
14218 for (const comment of comments) {
14219 if (locStart(comment) >= start && locEnd(comment) <= end) {
14220 comment.printed = true;
14221 printedComments.add(comment);
14226 doc: originalText.slice(start, end),
14231 function callPluginPrintFunction(path, options, printPath, args) {
14232 const node = path.getValue();
14237 let printedComments; // Escape hatch
14239 if (printer.hasPrettierIgnore && printer.hasPrettierIgnore(path)) {
14243 } = printPrettierIgnoredNode(node, options));
14247 // Potentially switch to a different parser
14248 doc = multiparser.printSubtree(path, printPath, options, printAstToDoc$1);
14250 /* istanbul ignore if */
14251 if (process.env.PRETTIER_DEBUG) {
14253 } // Continue with current parser
14259 doc = printer.print(path, options, printPath, args);
14261 } // We let JSXElement print its comments itself because it adds () around
14262 // UnionTypeAnnotation has to align the child without the comments
14265 if (!printer.willPrintOwnComments || !printer.willPrintOwnComments(path, options)) {
14266 // printComments will call the plugin print function and check for
14267 // comments to print
14268 doc = printComments$6(path, doc, options, printedComments);
14274 var astToDoc = printAstToDoc$1;
14276 const assert$5 = require$$0__default$3["default"];
14277 const comments$2 = comments$4;
14279 const isJsonParser = ({
14281 }) => parser === "json" || parser === "json5" || parser === "json-stringify";
14283 function findCommonAncestor(startNodeAndParents, endNodeAndParents) {
14284 const startNodeAndAncestors = [startNodeAndParents.node, ...startNodeAndParents.parentNodes];
14285 const endNodeAndAncestors = new Set([endNodeAndParents.node, ...endNodeAndParents.parentNodes]);
14286 return startNodeAndAncestors.find(node => jsonSourceElements.has(node.type) && endNodeAndAncestors.has(node));
14289 function dropRootParents(parents) {
14290 let lastParentIndex = parents.length - 1;
14293 const parent = parents[lastParentIndex];
14295 if (parent && (parent.type === "Program" || parent.type === "File")) {
14302 return parents.slice(0, lastParentIndex + 1);
14305 function findSiblingAncestors(startNodeAndParents, endNodeAndParents, {
14309 let resultStartNode = startNodeAndParents.node;
14310 let resultEndNode = endNodeAndParents.node;
14312 if (resultStartNode === resultEndNode) {
14314 startNode: resultStartNode,
14315 endNode: resultEndNode
14319 const startNodeStart = locStart(startNodeAndParents.node);
14321 for (const endParent of dropRootParents(endNodeAndParents.parentNodes)) {
14322 if (locStart(endParent) >= startNodeStart) {
14323 resultEndNode = endParent;
14329 const endNodeEnd = locEnd(endNodeAndParents.node);
14331 for (const startParent of dropRootParents(startNodeAndParents.parentNodes)) {
14332 if (locEnd(startParent) <= endNodeEnd) {
14333 resultStartNode = startParent;
14340 startNode: resultStartNode,
14341 endNode: resultEndNode
14345 function findNodeAtOffset(node, offset, options, predicate, parentNodes = [], type) {
14350 const start = locStart(node);
14351 const end = locEnd(node);
14353 if (offset > end || offset < start || type === "rangeEnd" && offset === start || type === "rangeStart" && offset === end) {
14357 for (const childNode of comments$2.getSortedChildNodes(node, options)) {
14358 const childResult = findNodeAtOffset(childNode, offset, options, predicate, [node, ...parentNodes], type);
14361 return childResult;
14365 if (!predicate || predicate(node, parentNodes[0])) {
14371 } // See https://www.ecma-international.org/ecma-262/5.1/#sec-A.5
14374 function isJsSourceElement(type, parentType) {
14375 return parentType !== "DeclareExportDeclaration" && type !== "TypeParameterDeclaration" && (type === "Directive" || type === "TypeAlias" || type === "TSExportAssignment" || type.startsWith("Declare") || type.startsWith("TSDeclare") || type.endsWith("Statement") || type.endsWith("Declaration"));
14378 const jsonSourceElements = new Set(["ObjectExpression", "ArrayExpression", "StringLiteral", "NumericLiteral", "BooleanLiteral", "NullLiteral", "UnaryExpression", "TemplateLiteral"]);
14379 const graphqlSourceElements = new Set(["OperationDefinition", "FragmentDefinition", "VariableDefinition", "TypeExtensionDefinition", "ObjectTypeDefinition", "FieldDefinition", "DirectiveDefinition", "EnumTypeDefinition", "EnumValueDefinition", "InputValueDefinition", "InputObjectTypeDefinition", "SchemaDefinition", "OperationTypeDefinition", "InterfaceTypeDefinition", "UnionTypeDefinition", "ScalarTypeDefinition"]);
14381 function isSourceElement(opts, node, parentNode) {
14382 /* istanbul ignore next */
14387 switch (opts.parser) {
14395 case "__babel_estree":
14396 return isJsSourceElement(node.type, parentNode && parentNode.type);
14400 case "json-stringify":
14401 return jsonSourceElements.has(node.type);
14404 return graphqlSourceElements.has(node.kind);
14407 return node.tag !== "root";
14413 function calculateRange(text, opts, ast) {
14420 assert$5.ok(end > start); // Contract the range so that it has non-whitespace characters at its endpoints.
14421 // This ensures we can format a range that doesn't end on a node.
14423 const firstNonWhitespaceCharacterIndex = text.slice(start, end).search(/\S/);
14424 const isAllWhitespace = firstNonWhitespaceCharacterIndex === -1;
14426 if (!isAllWhitespace) {
14427 start += firstNonWhitespaceCharacterIndex;
14429 for (; end > start; --end) {
14430 if (/\S/.test(text[end - 1])) {
14436 const startNodeAndParents = findNodeAtOffset(ast, start, opts, (node, parentNode) => isSourceElement(opts, node, parentNode), [], "rangeStart");
14437 const endNodeAndParents = // No need find Node at `end`, it will be the same as `startNodeAndParents`
14438 isAllWhitespace ? startNodeAndParents : findNodeAtOffset(ast, end, opts, node => isSourceElement(opts, node), [], "rangeEnd");
14440 if (!startNodeAndParents || !endNodeAndParents) {
14450 if (isJsonParser(opts)) {
14451 const commonAncestor = findCommonAncestor(startNodeAndParents, endNodeAndParents);
14452 startNode = commonAncestor;
14453 endNode = commonAncestor;
14458 } = findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts));
14462 rangeStart: Math.min(locStart(startNode), locStart(endNode)),
14463 rangeEnd: Math.max(locEnd(startNode), locEnd(endNode))
14467 var rangeUtil$1 = {
14472 const diff = lib$6;
14475 printDocToString: printDocToString$2
14482 getAlignmentSize: getAlignmentSize$1
14486 convertEndOfLineToChars,
14487 countEndOfLineChars,
14488 normalizeEndOfLine: normalizeEndOfLine$1
14490 const normalizeOptions$4 = options$d.normalize;
14491 const massageAST = massageAst;
14492 const comments$1 = comments$4;
14493 const parser$1 = parser$2;
14494 const printAstToDoc = astToDoc;
14495 const rangeUtil = rangeUtil$1;
14496 const BOM = "\uFEFF";
14497 const CURSOR = Symbol("cursor");
14499 function attachComments(text, ast, opts) {
14500 const astComments = ast.comments;
14503 delete ast.comments;
14504 comments$1.attach(astComments, ast, text, opts);
14507 opts[Symbol.for("comments")] = astComments || [];
14508 opts[Symbol.for("tokens")] = ast.tokens || [];
14509 opts.originalText = text;
14510 return astComments;
14513 function coreFormat(originalText, opts, addAlignmentSize = 0) {
14514 if (!originalText || originalText.trim().length === 0) {
14525 } = parser$1.parse(originalText, opts);
14527 if (opts.cursorOffset >= 0) {
14528 const nodeResult = rangeUtil.findNodeAtOffset(ast, opts.cursorOffset, opts);
14530 if (nodeResult && nodeResult.node) {
14531 opts.cursorNode = nodeResult.node;
14535 const astComments = attachComments(text, ast, opts);
14536 const doc = printAstToDoc(ast, opts, addAlignmentSize);
14537 const result = printDocToString$2(doc, opts);
14538 comments$1.ensureAllCommentsPrinted(astComments); // Remove extra leading indentation as well as the added indentation after last newline
14540 if (addAlignmentSize > 0) {
14541 const trimmed = result.formatted.trim();
14543 if (result.cursorNodeStart !== undefined) {
14544 result.cursorNodeStart -= result.formatted.indexOf(trimmed);
14547 result.formatted = trimmed + convertEndOfLineToChars(opts.endOfLine);
14550 if (opts.cursorOffset >= 0) {
14551 let oldCursorNodeStart;
14552 let oldCursorNodeText;
14553 let cursorOffsetRelativeToOldCursorNode;
14554 let newCursorNodeStart;
14555 let newCursorNodeText;
14557 if (opts.cursorNode && result.cursorNodeText) {
14558 oldCursorNodeStart = opts.locStart(opts.cursorNode);
14559 oldCursorNodeText = text.slice(oldCursorNodeStart, opts.locEnd(opts.cursorNode));
14560 cursorOffsetRelativeToOldCursorNode = opts.cursorOffset - oldCursorNodeStart;
14561 newCursorNodeStart = result.cursorNodeStart;
14562 newCursorNodeText = result.cursorNodeText;
14564 oldCursorNodeStart = 0;
14565 oldCursorNodeText = text;
14566 cursorOffsetRelativeToOldCursorNode = opts.cursorOffset;
14567 newCursorNodeStart = 0;
14568 newCursorNodeText = result.formatted;
14571 if (oldCursorNodeText === newCursorNodeText) {
14573 formatted: result.formatted,
14574 cursorOffset: newCursorNodeStart + cursorOffsetRelativeToOldCursorNode,
14575 comments: astComments
14577 } // diff old and new cursor node texts, with a special cursor
14578 // symbol inserted to find out where it moves to
14581 const oldCursorNodeCharArray = [...oldCursorNodeText];
14582 oldCursorNodeCharArray.splice(cursorOffsetRelativeToOldCursorNode, 0, CURSOR);
14583 const newCursorNodeCharArray = [...newCursorNodeText];
14584 const cursorNodeDiff = diff.diffArrays(oldCursorNodeCharArray, newCursorNodeCharArray);
14585 let cursorOffset = newCursorNodeStart;
14587 for (const entry of cursorNodeDiff) {
14588 if (entry.removed) {
14589 if (entry.value.includes(CURSOR)) {
14593 cursorOffset += entry.count;
14598 formatted: result.formatted,
14600 comments: astComments
14605 formatted: result.formatted,
14607 comments: astComments
14611 function formatRange(originalText, opts) {
14615 } = parser$1.parse(originalText, opts);
14619 } = rangeUtil.calculateRange(text, opts, ast);
14620 const rangeString = text.slice(rangeStart, rangeEnd); // Try to extend the range backwards to the beginning of the line.
14621 // This is so we can detect indentation correctly and restore it.
14622 // Use `Math.min` since `lastIndexOf` returns 0 when `rangeStart` is 0
14624 const rangeStart2 = Math.min(rangeStart, text.lastIndexOf("\n", rangeStart) + 1);
14625 const indentString = text.slice(rangeStart2, rangeStart).match(/^\s*/)[0];
14626 const alignmentSize = getAlignmentSize$1(indentString, opts.tabWidth);
14627 const rangeResult = coreFormat(rangeString, Object.assign(Object.assign({}, opts), {}, {
14629 rangeEnd: Number.POSITIVE_INFINITY,
14630 // Track the cursor offset only if it's within our range
14631 cursorOffset: opts.cursorOffset > rangeStart && opts.cursorOffset <= rangeEnd ? opts.cursorOffset - rangeStart : -1,
14632 // Always use `lf` to format, we'll replace it later
14634 }), alignmentSize); // Since the range contracts to avoid trailing whitespace,
14635 // we need to remove the newline that was inserted by the `format` call.
14637 const rangeTrimmed = rangeResult.formatted.trimEnd();
14642 if (cursorOffset > rangeEnd) {
14643 // handle the case where the cursor was past the end of the range
14644 cursorOffset += rangeTrimmed.length - rangeString.length;
14645 } else if (rangeResult.cursorOffset >= 0) {
14646 // handle the case where the cursor was in the range
14647 cursorOffset = rangeResult.cursorOffset + rangeStart;
14648 } // keep the cursor as it was if it was before the start of the range
14651 let formatted = text.slice(0, rangeStart) + rangeTrimmed + text.slice(rangeEnd);
14653 if (opts.endOfLine !== "lf") {
14654 const eol = convertEndOfLineToChars(opts.endOfLine);
14656 if (cursorOffset >= 0 && eol === "\r\n") {
14657 cursorOffset += countEndOfLineChars(formatted.slice(0, cursorOffset), "\n");
14660 formatted = formatted.replace(/\n/g, eol);
14666 comments: rangeResult.comments
14670 function ensureIndexInText(text, index, defaultValue) {
14671 if (typeof index !== "number" || Number.isNaN(index) || index < 0 || index > text.length) {
14672 return defaultValue;
14678 function normalizeIndexes(text, options) {
14684 cursorOffset = ensureIndexInText(text, cursorOffset, -1);
14685 rangeStart = ensureIndexInText(text, rangeStart, 0);
14686 rangeEnd = ensureIndexInText(text, rangeEnd, text.length);
14687 return Object.assign(Object.assign({}, options), {}, {
14694 function normalizeInputAndOptions(text, options) {
14700 } = normalizeIndexes(text, options);
14701 const hasBOM = text.charAt(0) === BOM;
14704 text = text.slice(1);
14710 if (endOfLine === "auto") {
14711 endOfLine = guessEndOfLine(text);
14712 } // get rid of CR/CRLF parsing
14715 if (text.includes("\r")) {
14716 const countCrlfBefore = index => countEndOfLineChars(text.slice(0, Math.max(index, 0)), "\r\n");
14718 cursorOffset -= countCrlfBefore(cursorOffset);
14719 rangeStart -= countCrlfBefore(rangeStart);
14720 rangeEnd -= countCrlfBefore(rangeEnd);
14721 text = normalizeEndOfLine$1(text);
14727 options: normalizeIndexes(text, Object.assign(Object.assign({}, options), {}, {
14736 function hasPragma$5(text, options) {
14737 const selectedParser = parser$1.resolveParser(options);
14738 return !selectedParser.hasPragma || selectedParser.hasPragma(text);
14741 function formatWithCursor$1(originalText, originalOptions) {
14746 } = normalizeInputAndOptions(originalText, normalizeOptions$4(originalOptions));
14748 if (options.rangeStart >= options.rangeEnd && text !== "" || options.requirePragma && !hasPragma$5(text, options)) {
14750 formatted: originalText,
14751 cursorOffset: originalOptions.cursorOffset,
14758 if (options.rangeStart > 0 || options.rangeEnd < text.length) {
14759 result = formatRange(text, options);
14761 if (!options.requirePragma && options.insertPragma && options.printer.insertPragma && !hasPragma$5(text, options)) {
14762 text = options.printer.insertPragma(text);
14765 result = coreFormat(text, options);
14769 result.formatted = BOM + result.formatted;
14771 if (result.cursorOffset >= 0) {
14772 result.cursorOffset++;
14780 formatWithCursor: formatWithCursor$1,
14782 parse(originalText, originalOptions, massage) {
14786 } = normalizeInputAndOptions(originalText, normalizeOptions$4(originalOptions));
14787 const parsed = parser$1.parse(text, options);
14790 parsed.ast = massageAST(parsed.ast, options);
14796 formatAST(ast, options) {
14797 options = normalizeOptions$4(options);
14798 const doc = printAstToDoc(ast, options);
14799 return printDocToString$2(doc, options);
14802 // Doesn't handle shebang for now
14803 formatDoc(doc, options) {
14804 return formatWithCursor$1(printDocToDebug(doc), Object.assign(Object.assign({}, options), {}, {
14805 parser: "__js_expression"
14809 printToDoc(originalText, options) {
14810 options = normalizeOptions$4(options);
14814 } = parser$1.parse(originalText, options);
14815 attachComments(text, ast, options);
14816 return printAstToDoc(ast, options);
14819 printDocToString(doc, options) {
14820 return printDocToString$2(doc, normalizeOptions$4(options));
14825 var concatMap$1 = function (xs, fn) {
14828 for (var i = 0; i < xs.length; i++) {
14829 var x = fn(xs[i], i);
14830 if (isArray$a(x)) res.push.apply(res, x);else res.push(x);
14836 var isArray$a = Array.isArray || function (xs) {
14837 return Object.prototype.toString.call(xs) === '[object Array]';
14840 var balancedMatch = balanced$1;
14842 function balanced$1(a, b, str) {
14843 if (a instanceof RegExp) a = maybeMatch(a, str);
14844 if (b instanceof RegExp) b = maybeMatch(b, str);
14845 var r = range(a, b, str);
14849 pre: str.slice(0, r[0]),
14850 body: str.slice(r[0] + a.length, r[1]),
14851 post: str.slice(r[1] + b.length)
14855 function maybeMatch(reg, str) {
14856 var m = str.match(reg);
14857 return m ? m[0] : null;
14860 balanced$1.range = range;
14862 function range(a, b, str) {
14863 var begs, beg, left, right, result;
14864 var ai = str.indexOf(a);
14865 var bi = str.indexOf(b, ai + 1);
14868 if (ai >= 0 && bi > 0) {
14876 while (i >= 0 && !result) {
14879 ai = str.indexOf(a, i + 1);
14880 } else if (begs.length == 1) {
14881 result = [begs.pop(), bi];
14890 bi = str.indexOf(b, i + 1);
14893 i = ai < bi && ai >= 0 ? ai : bi;
14897 result = [left, right];
14904 var concatMap = concatMap$1;
14905 var balanced = balancedMatch;
14906 var braceExpansion = expandTop;
14907 var escSlash = '\0SLASH' + Math.random() + '\0';
14908 var escOpen = '\0OPEN' + Math.random() + '\0';
14909 var escClose = '\0CLOSE' + Math.random() + '\0';
14910 var escComma = '\0COMMA' + Math.random() + '\0';
14911 var escPeriod = '\0PERIOD' + Math.random() + '\0';
14913 function numeric(str) {
14914 return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
14917 function escapeBraces(str) {
14918 return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
14921 function unescapeBraces(str) {
14922 return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
14923 } // Basically just str.split(","), but handling cases
14924 // where we have nested braced sections, which should be
14925 // treated as individual members, like {a,{b,c},d}
14928 function parseCommaParts(str) {
14929 if (!str) return [''];
14931 var m = balanced('{', '}', str);
14932 if (!m) return str.split(',');
14936 var p = pre.split(',');
14937 p[p.length - 1] += '{' + body + '}';
14938 var postParts = parseCommaParts(post);
14941 p[p.length - 1] += postParts.shift();
14942 p.push.apply(p, postParts);
14945 parts.push.apply(parts, p);
14949 function expandTop(str) {
14950 if (!str) return []; // I don't know why Bash 4.3 does this, but it does.
14951 // Anything starting with {} will have the first two bytes preserved
14952 // but *only* at the top level, so {},a}b will not expand to anything,
14953 // but a{},b}c will be expanded to [a}c,abc].
14954 // One could argue that this is a bug in Bash, but since the goal of
14955 // this module is to match Bash's rules, we escape a leading {}
14957 if (str.substr(0, 2) === '{}') {
14958 str = '\\{\\}' + str.substr(2);
14961 return expand$3(escapeBraces(str), true).map(unescapeBraces);
14964 function embrace(str) {
14965 return '{' + str + '}';
14968 function isPadded(el) {
14969 return /^-?0\d/.test(el);
14972 function lte(i, y) {
14976 function gte(i, y) {
14980 function expand$3(str, isTop) {
14981 var expansions = [];
14982 var m = balanced('{', '}', str);
14983 if (!m || /\$$/.test(m.pre)) return [str];
14984 var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
14985 var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
14986 var isSequence = isNumericSequence || isAlphaSequence;
14987 var isOptions = m.body.indexOf(',') >= 0;
14989 if (!isSequence && !isOptions) {
14991 if (m.post.match(/,.*\}/)) {
14992 str = m.pre + '{' + m.body + escClose + m.post;
14993 return expand$3(str);
15002 n = m.body.split(/\.\./);
15004 n = parseCommaParts(m.body);
15006 if (n.length === 1) {
15007 // x{{a,b}}y ==> x{a}y x{b}y
15008 n = expand$3(n[0], false).map(embrace);
15010 if (n.length === 1) {
15011 var post = m.post.length ? expand$3(m.post, false) : [''];
15012 return post.map(function (p) {
15013 return m.pre + n[0] + p;
15017 } // at this point, n is the parts, and we know it's not a comma set
15018 // with a single entry.
15019 // no need to expand pre, since it is guaranteed to be free of brace-sets
15023 var post = m.post.length ? expand$3(m.post, false) : [''];
15027 var x = numeric(n[0]);
15028 var y = numeric(n[1]);
15029 var width = Math.max(n[0].length, n[1].length);
15030 var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
15032 var reverse = y < x;
15039 var pad = n.some(isPadded);
15042 for (var i = x; test(i, y); i += incr) {
15045 if (isAlphaSequence) {
15046 c = String.fromCharCode(i);
15047 if (c === '\\') c = '';
15052 var need = width - c.length;
15055 var z = new Array(need + 1).join('0');
15056 if (i < 0) c = '-' + z + c.slice(1);else c = z + c;
15064 N = concatMap(n, function (el) {
15065 return expand$3(el, false);
15069 for (var j = 0; j < N.length; j++) {
15070 for (var k = 0; k < post.length; k++) {
15071 var expansion = pre + N[j] + post[k];
15072 if (!isTop || isSequence || expansion) expansions.push(expansion);
15079 var minimatch_1 = minimatch$1;
15080 minimatch$1.Minimatch = Minimatch;
15086 path$o = require('path');
15089 var GLOBSTAR$1 = minimatch$1.GLOBSTAR = Minimatch.GLOBSTAR = {};
15090 var expand$2 = braceExpansion;
15112 }; // any single thing other than /
15113 // don't need to escape / when using new RegExp()
15115 var qmark = '[^/]'; // * => any number of characters
15117 var star = qmark + '*?'; // ** when dots are allowed. Anything goes, except .. and .
15118 // not (^ or / followed by one or two dots followed by $ or /),
15119 // followed by anything, any number of times.
15121 var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; // not a ^ or / followed by a dot,
15122 // followed by anything, any number of times.
15124 var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; // characters that need to be escaped in RegExp.
15126 var reSpecials = charSet('().*{}+?[]^$\\!'); // "abc" -> { a:true, b:true, c:true }
15128 function charSet(s) {
15129 return s.split('').reduce(function (set, c) {
15133 } // normalizes slashes.
15136 var slashSplit = /\/+/;
15137 minimatch$1.filter = filter;
15139 function filter(pattern, options) {
15140 options = options || {};
15141 return function (p, i, list) {
15142 return minimatch$1(p, pattern, options);
15146 function ext(a, b) {
15150 Object.keys(b).forEach(function (k) {
15153 Object.keys(a).forEach(function (k) {
15159 minimatch$1.defaults = function (def) {
15160 if (!def || !Object.keys(def).length) return minimatch$1;
15161 var orig = minimatch$1;
15163 var m = function minimatch(p, pattern, options) {
15164 return orig.minimatch(p, pattern, ext(def, options));
15167 m.Minimatch = function Minimatch(pattern, options) {
15168 return new orig.Minimatch(pattern, ext(def, options));
15174 Minimatch.defaults = function (def) {
15175 if (!def || !Object.keys(def).length) return Minimatch;
15176 return minimatch$1.defaults(def).Minimatch;
15179 function minimatch$1(p, pattern, options) {
15180 if (typeof pattern !== 'string') {
15181 throw new TypeError('glob pattern string required');
15184 if (!options) options = {}; // shortcut: comments match nothing.
15186 if (!options.nocomment && pattern.charAt(0) === '#') {
15188 } // "" only matches ""
15191 if (pattern.trim() === '') return p === '';
15192 return new Minimatch(pattern, options).match(p);
15195 function Minimatch(pattern, options) {
15196 if (!(this instanceof Minimatch)) {
15197 return new Minimatch(pattern, options);
15200 if (typeof pattern !== 'string') {
15201 throw new TypeError('glob pattern string required');
15204 if (!options) options = {};
15205 pattern = pattern.trim(); // windows support: need to use /, not \
15207 if (path$o.sep !== '/') {
15208 pattern = pattern.split(path$o.sep).join('/');
15211 this.options = options;
15213 this.pattern = pattern;
15214 this.regexp = null;
15215 this.negate = false;
15216 this.comment = false;
15217 this.empty = false; // make the set of regexps etc.
15222 Minimatch.prototype.debug = function () {};
15224 Minimatch.prototype.make = make;
15227 // don't do it more than once.
15228 if (this._made) return;
15229 var pattern = this.pattern;
15230 var options = this.options; // empty patterns and comments match nothing.
15232 if (!options.nocomment && pattern.charAt(0) === '#') {
15233 this.comment = true;
15240 } // step 1: figure out negation, etc.
15243 this.parseNegate(); // step 2: expand braces
15245 var set = this.globSet = this.braceExpand();
15246 if (options.debug) this.debug = console.error;
15247 this.debug(this.pattern, set); // step 3: now we have a set, so turn each one into a series of path-portion
15248 // matching patterns.
15249 // These will be regexps, except in the case of "**", which is
15250 // set to the GLOBSTAR object for globstar behavior,
15251 // and will not contain any / characters
15253 set = this.globParts = set.map(function (s) {
15254 return s.split(slashSplit);
15256 this.debug(this.pattern, set); // glob --> regexps
15258 set = set.map(function (s, si, set) {
15259 return s.map(this.parse, this);
15261 this.debug(this.pattern, set); // filter out everything that didn't compile properly.
15263 set = set.filter(function (s) {
15264 return s.indexOf(false) === -1;
15266 this.debug(this.pattern, set);
15270 Minimatch.prototype.parseNegate = parseNegate;
15272 function parseNegate() {
15273 var pattern = this.pattern;
15274 var negate = false;
15275 var options = this.options;
15276 var negateOffset = 0;
15277 if (options.nonegate) return;
15279 for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) {
15284 if (negateOffset) this.pattern = pattern.substr(negateOffset);
15285 this.negate = negate;
15286 } // Brace expansion:
15287 // a{b,c}d -> abd acd
15288 // a{b,}c -> abc ac
15289 // a{0..3}d -> a0d a1d a2d a3d
15290 // a{b,c{d,e}f}g -> abg acdfg acefg
15291 // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
15293 // Invalid sets are not expanded.
15294 // a{2..}b -> a{2..}b
15298 minimatch$1.braceExpand = function (pattern, options) {
15299 return braceExpand(pattern, options);
15302 Minimatch.prototype.braceExpand = braceExpand;
15304 function braceExpand(pattern, options) {
15306 if (this instanceof Minimatch) {
15307 options = this.options;
15313 pattern = typeof pattern === 'undefined' ? this.pattern : pattern;
15315 if (typeof pattern === 'undefined') {
15316 throw new TypeError('undefined pattern');
15319 if (options.nobrace || !pattern.match(/\{.*\}/)) {
15320 // shortcut. no need to expand.
15324 return expand$2(pattern);
15325 } // parse a component of the expanded set.
15326 // At this point, no pattern may contain "/" in it
15327 // so we're going to return a 2d array, where each entry is the full
15328 // pattern, split on '/', and then turned into a regular expression.
15329 // A regexp is made at the end which joins each array with an
15330 // escaped /, and another full one which joins each regexp with |.
15332 // Following the lead of Bash 4.1, note that "**" only has special meaning
15333 // when it is the *only* thing in a path portion. Otherwise, any series
15334 // of * is equivalent to a single *. Globstar behavior is enabled by
15335 // default, and can be disabled by setting options.noglobstar.
15338 Minimatch.prototype.parse = parse$c;
15341 function parse$c(pattern, isSub) {
15342 if (pattern.length > 1024 * 64) {
15343 throw new TypeError('pattern is too long');
15346 var options = this.options; // shortcuts
15348 if (!options.noglobstar && pattern === '**') return GLOBSTAR$1;
15349 if (pattern === '') return '';
15351 var hasMagic = !!options.nocase;
15352 var escaping = false; // ? => one single character
15354 var patternListStack = [];
15355 var negativeLists = [];
15357 var inClass = false;
15358 var reClassStart = -1;
15359 var classStart = -1; // . and .. never match anything that doesn't start with .,
15360 // even when options.dot is set.
15362 var patternStart = pattern.charAt(0) === '.' ? '' // anything
15363 // not (start or / followed by . or .. followed by / or end)
15364 : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)';
15367 function clearStateChar() {
15369 // we had some state-tracking character
15370 // that wasn't consumed by this pass.
15371 switch (stateChar) {
15383 re += '\\' + stateChar;
15387 self.debug('clearStateChar %j %j', stateChar, re);
15392 for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
15393 this.debug('%s\t%s %s %j', pattern, i, re, c); // skip over any that are escaped.
15395 if (escaping && reSpecials[c]) {
15403 // completely not allowed, even escaped.
15404 // Should already be path-split by now.
15411 // the various stateChar values
15412 // for the "extglob" stuff.
15419 this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); // all of those are literals inside a class, except that
15420 // the glob [!a] means [^a] in regexp
15423 this.debug(' in class');
15424 if (c === '!' && i === classStart + 1) c = '^';
15427 } // if we already have a stateChar, then it means
15428 // that there was something like ** or +? in there.
15429 // Handle the stateChar, then proceed with this one.
15432 self.debug('call clearStateChar %j', stateChar);
15434 stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing.
15435 // just clear the statechar *now*, rather than even diving into
15436 // the patternList stuff.
15438 if (options.noext) clearStateChar();
15452 patternListStack.push({
15455 reStart: re.length,
15456 open: plTypes[stateChar].open,
15457 close: plTypes[stateChar].close
15458 }); // negation is (?:(?!js)[^/]*)
15460 re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
15461 this.debug('plType %j %j', stateChar, re);
15466 if (inClass || !patternListStack.length) {
15473 var pl = patternListStack.pop(); // negation is (?:(?!js)[^/]*)
15474 // The others are (?:<pattern>)<type>
15478 if (pl.type === '!') {
15479 negativeLists.push(pl);
15482 pl.reEnd = re.length;
15486 if (inClass || !patternListStack.length || escaping) {
15495 // these are mostly the same in regexp and glob
15498 // swallow any state-tracking char before the [
15508 reClassStart = re.length;
15513 // a right bracket shall lose its special
15514 // meaning and represent itself in
15515 // a bracket expression if it occurs
15516 // first in the list. -- POSIX.2 2.8.3.2
15517 if (i === classStart + 1 || !inClass) {
15521 } // handle the case where we left a class open.
15522 // "[z-a]" is valid, equivalent to "\[z-a\]"
15526 // split where the last [ was, make sure we don't have
15527 // an invalid re. if so, re-walk the contents of the
15528 // would-be class to re-translate any characters that
15529 // were passed through as-is
15530 // TODO: It would probably be faster to determine this
15531 // without a try/catch and a new RegExp, but it's tricky
15532 // to do safely. For now, this is safe and works.
15533 var cs = pattern.substring(classStart + 1, i);
15536 RegExp('[' + cs + ']');
15538 // not a valid class!
15539 var sp = this.parse(cs, SUBPARSE);
15540 re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
15541 hasMagic = hasMagic || sp[1];
15545 } // finish up the class.
15554 // swallow any state char that wasn't consumed
15560 } else if (reSpecials[c] && !(c === '^' && inClass)) {
15568 // handle the case where we left a class open.
15569 // "[abc" is valid, equivalent to "\[abc"
15573 // split where the last [ was, and escape it
15574 // this is a huge pita. We now have to re-walk
15575 // the contents of the would-be class to re-translate
15576 // any characters that were passed through as-is
15577 cs = pattern.substr(classStart + 1);
15578 sp = this.parse(cs, SUBPARSE);
15579 re = re.substr(0, reClassStart) + '\\[' + sp[0];
15580 hasMagic = hasMagic || sp[1];
15581 } // handle the case where we had a +( thing at the *end*
15583 // each pattern list stack adds 3 chars, and we need to go through
15584 // and escape any | chars that were passed through as-is for the regexp.
15585 // Go through and escape them, taking care not to double-escape any
15586 // | chars that were already escaped.
15589 for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
15590 var tail = re.slice(pl.reStart + pl.open.length);
15591 this.debug('setting tail', re, pl); // maybe some even number of \, then maybe 1 \, followed by a |
15593 tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
15595 // the | isn't already escaped, so escape it.
15597 } // need to escape all those slashes *again*, without escaping the
15598 // one that we need for escaping the | character. As it works out,
15599 // escaping an even number of slashes can be done by simply repeating
15600 // it exactly after itself. That's why this trick works.
15602 // I am sorry that you have to see this.
15605 return $1 + $1 + $2 + '|';
15607 this.debug('tail=%j\n %s', tail, tail, pl, re);
15608 var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
15610 re = re.slice(0, pl.reStart) + t + '\\(' + tail;
15611 } // handle trailing things that only matter at the very end.
15619 } // only need to apply the nodot start if the re starts with
15620 // something that could conceivably capture a dot
15623 var addPatternStart = false;
15625 switch (re.charAt(0)) {
15629 addPatternStart = true;
15630 } // Hack to work around lack of negative lookbehind in JS
15631 // A pattern like: *.!(x).!(y|z) needs to ensure that a name
15632 // like 'a.xyz.yz' doesn't match. So, the first negative
15633 // lookahead, has to look ALL the way ahead, to the end of
15637 for (var n = negativeLists.length - 1; n > -1; n--) {
15638 var nl = negativeLists[n];
15639 var nlBefore = re.slice(0, nl.reStart);
15640 var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
15641 var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
15642 var nlAfter = re.slice(nl.reEnd);
15643 nlLast += nlAfter; // Handle nested stuff like *(*.js|!(*.json)), where open parens
15644 // mean that we should *not* include the ) in the bit that is considered
15645 // "after" the negated section.
15647 var openParensBefore = nlBefore.split('(').length - 1;
15648 var cleanAfter = nlAfter;
15650 for (i = 0; i < openParensBefore; i++) {
15651 cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
15654 nlAfter = cleanAfter;
15657 if (nlAfter === '' && isSub !== SUBPARSE) {
15661 var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
15663 } // if the re is not "" at this point, then we need to make sure
15664 // it doesn't match against an empty path part.
15665 // Otherwise a/* will match a/, which it should not.
15668 if (re !== '' && hasMagic) {
15672 if (addPatternStart) {
15673 re = patternStart + re;
15674 } // parsing just a piece of a larger pattern.
15677 if (isSub === SUBPARSE) {
15678 return [re, hasMagic];
15679 } // skip the regexp for non-magical patterns
15680 // unescape anything in it, though, so that it'll be
15681 // an exact match against a file etc.
15685 return globUnescape(pattern);
15688 var flags = options.nocase ? 'i' : '';
15691 var regExp = new RegExp('^' + re + '$', flags);
15693 // If it was an invalid regular expression, then it can't match
15694 // anything. This trick looks for a character after the end of
15695 // the string, which is of course impossible, except in multi-line
15696 // mode, but it's not a /m regex.
15697 return new RegExp('$.');
15700 regExp._glob = pattern;
15705 minimatch$1.makeRe = function (pattern, options) {
15706 return new Minimatch(pattern, options || {}).makeRe();
15709 Minimatch.prototype.makeRe = makeRe$1;
15711 function makeRe$1() {
15712 if (this.regexp || this.regexp === false) return this.regexp; // at this point, this.set is a 2d array of partial
15713 // pattern strings, or "**".
15715 // It's better to use .match(). This function shouldn't
15716 // be used, really, but it's pretty convenient sometimes,
15717 // when you just want to work with a regex.
15719 var set = this.set;
15722 this.regexp = false;
15723 return this.regexp;
15726 var options = this.options;
15727 var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
15728 var flags = options.nocase ? 'i' : '';
15729 var re = set.map(function (pattern) {
15730 return pattern.map(function (p) {
15731 return p === GLOBSTAR$1 ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src;
15733 }).join('|'); // must match entire pattern
15734 // ending in a * or ** will make it less strict.
15736 re = '^(?:' + re + ')$'; // can match anything, as long as it's not this.
15738 if (this.negate) re = '^(?!' + re + ').*$';
15741 this.regexp = new RegExp(re, flags);
15743 this.regexp = false;
15746 return this.regexp;
15749 minimatch$1.match = function (list, pattern, options) {
15750 options = options || {};
15751 var mm = new Minimatch(pattern, options);
15752 list = list.filter(function (f) {
15753 return mm.match(f);
15756 if (mm.options.nonull && !list.length) {
15757 list.push(pattern);
15763 Minimatch.prototype.match = match;
15765 function match(f, partial) {
15766 this.debug('match', f, this.pattern); // short-circuit in the case of busted things.
15769 if (this.comment) return false;
15770 if (this.empty) return f === '';
15771 if (f === '/' && partial) return true;
15772 var options = this.options; // windows: need to use /, not \
15774 if (path$o.sep !== '/') {
15775 f = f.split(path$o.sep).join('/');
15776 } // treat the test path as a set of pathparts.
15779 f = f.split(slashSplit);
15780 this.debug(this.pattern, 'split', f); // just ONE of the pattern sets in this.set needs to match
15781 // in order for it to be valid. If negating, then just one
15782 // match means that we have failed.
15783 // Either way, return on the first hit.
15785 var set = this.set;
15786 this.debug(this.pattern, 'set', set); // Find the basename of the path by looking for the last non-empty segment
15791 for (i = f.length - 1; i >= 0; i--) {
15793 if (filename) break;
15796 for (i = 0; i < set.length; i++) {
15797 var pattern = set[i];
15800 if (options.matchBase && pattern.length === 1) {
15804 var hit = this.matchOne(file, pattern, partial);
15807 if (options.flipNegate) return true;
15808 return !this.negate;
15810 } // didn't get any hits. this is success if it's a negative
15811 // pattern, failure otherwise.
15814 if (options.flipNegate) return false;
15815 return this.negate;
15816 } // set partial to true to test if, for example,
15817 // "/a/b" matches the start of "/*/b/*/d"
15818 // Partial means, if you run out of file before you run
15819 // out of pattern, then that's fine, as long as all
15820 // the parts match.
15823 Minimatch.prototype.matchOne = function (file, pattern, partial) {
15824 var options = this.options;
15825 this.debug('matchOne', {
15830 this.debug('matchOne', file.length, pattern.length);
15832 for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
15833 this.debug('matchOne loop');
15834 var p = pattern[pi];
15836 this.debug(pattern, p, f); // should be impossible.
15837 // some invalid regexp stuff in the set.
15839 if (p === false) return false;
15841 if (p === GLOBSTAR$1) {
15842 this.debug('GLOBSTAR', [pattern, p, f]); // "**"
15843 // a/**/b/**/c would match the following:
15848 // To do this, take the rest of the pattern after
15849 // the **, and see if it would match the file remainder.
15850 // If so, return success.
15851 // If not, the ** "swallows" a segment, and try again.
15852 // This is recursively awful.
15854 // a/**/b/**/c matching a/b/x/y/z/c
15857 // - matchOne(b/x/y/z/c, b/**/c)
15860 // - matchOne(x/y/z/c, c) -> no
15861 // - matchOne(y/z/c, c) -> no
15862 // - matchOne(z/c, c) -> no
15863 // - matchOne(c, c) yes, hit
15869 this.debug('** at the end'); // a ** at the end will just swallow the rest.
15870 // We have found a match.
15871 // however, it will not swallow /.x, unless
15872 // options.dot is set.
15873 // . and .. are *never* matched by **, for explosively
15874 // exponential reasons.
15876 for (; fi < fl; fi++) {
15877 if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false;
15881 } // ok, let's see if we can swallow whatever we can.
15885 var swallowee = file[fr];
15886 this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); // XXX remove this slice. Just pass the start index.
15888 if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
15889 this.debug('globstar found match!', fr, fl, swallowee); // found a match.
15893 // can't swallow "." or ".." ever.
15894 // can only swallow ".foo" when explicitly asked.
15895 if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') {
15896 this.debug('dot detected!', file, fr, pattern, pr);
15898 } // ** swallows a segment, and continue.
15901 this.debug('globstar swallow a segment, and continue');
15904 } // no match was found.
15905 // However, in partial mode, we can't say this is necessarily over.
15906 // If there's more *pattern* left, then
15911 this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
15912 if (fr === fl) return true;
15916 } // something other than **
15917 // non-magic patterns just have to match exactly
15918 // patterns with magic have been turned into regexps.
15923 if (typeof p === 'string') {
15924 if (options.nocase) {
15925 hit = f.toLowerCase() === p.toLowerCase();
15930 this.debug('string match', p, f, hit);
15933 this.debug('pattern match', p, f, hit);
15936 if (!hit) return false;
15937 } // Note: ending in / means that we'll get a final ""
15938 // at the end of the pattern. This can only match a
15939 // corresponding "" at the end of the file.
15940 // If the file ends in /, then it can only match a
15941 // a pattern that ends in /, unless the pattern just
15942 // doesn't have any more for it. But, a/b/ should *not*
15943 // match "a/b/*", even though "" matches against the
15944 // [^/]*? pattern, except in partial mode, where it might
15945 // simply not be reached yet.
15946 // However, a/b/ should still satisfy a/*
15947 // now either we fell off the end of the pattern, or we're done.
15950 if (fi === fl && pi === pl) {
15951 // ran out of pattern and filename at the same time.
15954 } else if (fi === fl) {
15955 // ran out of file, but still had pattern left.
15956 // this is ok if we're doing the match as part of
15957 // a glob fs traversal.
15959 } else if (pi === pl) {
15960 // ran out of pattern, still have file left.
15961 // this is only acceptable if we're on the very last
15962 // empty segment of a file with a trailing slash.
15963 // a/* should match a/b/
15964 var emptyFileEnd = fi === fl - 1 && file[fi] === '';
15965 return emptyFileEnd;
15966 } // should be unreachable.
15969 throw new Error('wtf?');
15970 }; // replace stuff like \* with *
15973 function globUnescape(s) {
15974 return s.replace(/\\(.)/g, '$1');
15977 function regExpEscape(s) {
15978 return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
15981 const copyProperty = (to, from, property, ignoreNonConfigurable) => {
15982 // `Function#length` should reflect the parameters of `to` not `from` since we keep its body.
15983 // `Function#prototype` is non-writable and non-configurable so can never be modified.
15984 if (property === 'length' || property === 'prototype') {
15986 } // `Function#arguments` and `Function#caller` should not be copied. They were reported to be present in `Reflect.ownKeys` for some devices in React Native (#41), so we explicitly ignore them here.
15989 if (property === 'arguments' || property === 'caller') {
15993 const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
15994 const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
15996 if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
16000 Object.defineProperty(to, property, fromDescriptor);
16001 }; // `Object.defineProperty()` throws if the property exists, is not configurable and either:
16002 // - one its descriptors is changed
16003 // - it is non-writable and its value is changed
16006 const canCopyProperty = function (toDescriptor, fromDescriptor) {
16007 return toDescriptor === undefined || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
16010 const changePrototype = (to, from) => {
16011 const fromPrototype = Object.getPrototypeOf(from);
16013 if (fromPrototype === Object.getPrototypeOf(to)) {
16017 Object.setPrototypeOf(to, fromPrototype);
16020 const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\n${fromBody}`;
16022 const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');
16023 const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name'); // We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.
16024 // We use `bind()` instead of a closure for the same reason.
16025 // Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.
16027 const changeToString = (to, from, name) => {
16028 const withName = name === '' ? '' : `with ${name.trim()}() `;
16029 const newToString = wrappedToString.bind(null, withName, from.toString()); // Ensure `to.toString.toString` is non-enumerable and has the same `same`
16031 Object.defineProperty(newToString, 'name', toStringName);
16032 Object.defineProperty(to, 'toString', Object.assign(Object.assign({}, toStringDescriptor), {}, {
16037 const mimicFn$1 = (to, from, {
16038 ignoreNonConfigurable = false
16044 for (const property of Reflect.ownKeys(from)) {
16045 copyProperty(to, from, property, ignoreNonConfigurable);
16048 changePrototype(to, from);
16049 changeToString(to, from, name);
16053 var mimicFn_1 = mimicFn$1;
16055 var dist$2 = {exports: {}};
16057 var pDefer = () => {
16059 ret.promise = new Promise((resolve, reject) => {
16060 ret.resolve = resolve;
16061 ret.reject = reject;
16066 (function (module, exports) {
16068 var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
16069 return new (P || (P = Promise))(function (resolve, reject) {
16070 function fulfilled(value) {
16072 step(generator.next(value));
16078 function rejected(value) {
16080 step(generator["throw"](value));
16086 function step(result) {
16087 result.done ? resolve(result.value) : new P(function (resolve) {
16088 resolve(result.value);
16089 }).then(fulfilled, rejected);
16092 step((generator = generator.apply(thisArg, _arguments || [])).next());
16096 var __importDefault = this && this.__importDefault || function (mod) {
16097 return mod && mod.__esModule ? mod : {
16102 Object.defineProperty(exports, "__esModule", {
16106 const p_defer_1 = __importDefault(pDefer);
16108 function mapAgeCleaner(map, property = 'maxAge') {
16110 let processingTimer;
16111 let processingDeferred;
16113 const cleanup = () => __awaiter(this, void 0, void 0, function* () {
16114 if (processingKey !== undefined) {
16115 // If we are already processing an item, we can safely exit
16119 const setupTimer = item => __awaiter(this, void 0, void 0, function* () {
16120 processingDeferred = p_defer_1.default();
16121 const delay = item[1][property] - Date.now();
16124 // Remove the item immediately if the delay is equal to or below 0
16125 map.delete(item[0]);
16126 processingDeferred.resolve();
16128 } // Keep track of the current processed key
16131 processingKey = item[0];
16132 processingTimer = setTimeout(() => {
16133 // Remove the item when the timeout fires
16134 map.delete(item[0]);
16136 if (processingDeferred) {
16137 processingDeferred.resolve();
16139 }, delay); // tslint:disable-next-line:strict-type-predicates
16141 if (typeof processingTimer.unref === 'function') {
16142 // Don't hold up the process from exiting
16143 processingTimer.unref();
16146 return processingDeferred.promise;
16150 for (const entry of map) {
16151 yield setupTimer(entry);
16153 } catch (_a) {// Do nothing if an error occurs, this means the timer was cleaned up and we should stop processing
16156 processingKey = undefined;
16159 const reset = () => {
16160 processingKey = undefined;
16162 if (processingTimer !== undefined) {
16163 clearTimeout(processingTimer);
16164 processingTimer = undefined;
16167 if (processingDeferred !== undefined) {
16168 // tslint:disable-line:early-exit
16169 processingDeferred.reject(undefined);
16170 processingDeferred = undefined;
16174 const originalSet = map.set.bind(map);
16176 map.set = (key, value) => {
16177 if (map.has(key)) {
16178 // If the key already exist, remove it so we can add it back at the end of the map.
16180 } // Call the original `map.set`
16183 const result = originalSet(key, value); // If we are already processing a key and the key added is the current processed key, stop processing it
16185 if (processingKey && processingKey === key) {
16187 } // Always run the cleanup method in case it wasn't started yet
16190 cleanup(); // tslint:disable-line:no-floating-promises
16195 cleanup(); // tslint:disable-line:no-floating-promises
16200 exports.default = mapAgeCleaner; // Add support for CJS
16202 module.exports = mapAgeCleaner;
16203 module.exports.default = mapAgeCleaner;
16204 })(dist$2, dist$2.exports);
16206 const mimicFn = mimicFn_1;
16207 const mapAgeCleaner = dist$2.exports;
16208 const decoratorInstanceMap = new WeakMap();
16209 const cacheStore = new WeakMap();
16211 [Memoize](https://en.wikipedia.org/wiki/Memoization) functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input.
16213 @param fn - Function to be memoized.
16217 import mem = require('mem');
16220 const counter = () => ++i;
16221 const memoized = mem(counter);
16226 // Cached as it's the same arguments
16230 // Not cached anymore as the arguments changed
16239 const mem$3 = (fn, {
16244 if (typeof maxAge === 'number') {
16245 // TODO: Drop after https://github.com/SamVerschueren/map-age-cleaner/issues/5
16246 // @ts-expect-error
16247 mapAgeCleaner(cache);
16250 const memoized = function (...arguments_) {
16251 const key = cacheKey ? cacheKey(arguments_) : arguments_[0];
16252 const cacheItem = cache.get(key);
16255 return cacheItem.data;
16258 const result = fn.apply(this, arguments_);
16261 maxAge: maxAge ? Date.now() + maxAge : Number.POSITIVE_INFINITY
16266 mimicFn(memoized, fn, {
16267 ignoreNonConfigurable: true
16269 cacheStore.set(memoized, cache);
16273 @returns A [decorator](https://github.com/tc39/proposal-decorators) to memoize class methods or static class methods.
16277 import mem = require('mem');
16284 return ++this.index;
16288 class ExampleWithOptions {
16291 @mem.decorator({maxAge: 1000})
16293 return ++this.index;
16300 mem$3.decorator = (options = {}) => (target, propertyKey, descriptor) => {
16301 const input = target[propertyKey];
16303 if (typeof input !== 'function') {
16304 throw new TypeError('The decorated value must be a function');
16307 delete descriptor.value;
16308 delete descriptor.writable;
16310 descriptor.get = function () {
16311 if (!decoratorInstanceMap.has(this)) {
16312 const value = mem$3(input, options);
16313 decoratorInstanceMap.set(this, value);
16317 return decoratorInstanceMap.get(this);
16321 Clear all cached data of a memoized function.
16323 @param fn - Memoized function.
16327 mem$3.clear = fn => {
16328 const cache = cacheStore.get(fn);
16331 throw new TypeError('Can\'t clear a function that was not memoized!');
16334 if (typeof cache.clear !== 'function') {
16335 throw new TypeError('The cache Map can\'t be cleared!');
16341 var dist$1 = mem$3;
16343 var require$$7$2 = require("./third-party.js");
16345 var tomlParser = {exports: {}};
16347 const ParserEND = 0x110000;
16349 class ParserError extends Error {
16350 /* istanbul ignore next */
16351 constructor(msg, filename, linenumber) {
16352 super('[ParserError] ' + msg, filename, linenumber);
16353 this.name = 'ParserError';
16354 this.code = 'ParserError';
16355 if (Error.captureStackTrace) Error.captureStackTrace(this, ParserError);
16361 constructor(parser) {
16362 this.parser = parser;
16364 this.returned = null;
16365 this.result = null;
16366 this.resultTable = null;
16367 this.resultArr = null;
16378 this.ctx = this.obj;
16383 this.state = new State(this.parseStart);
16387 /* istanbul ignore next */
16388 if (str.length === 0 || str.length == null) return;
16389 this._buf = String(str);
16394 while (getNext === false || this.nextChar()) {
16395 getNext = this.runOne();
16402 if (this.char === 0x0A) {
16408 this.char = this._buf.codePointAt(this.ii);
16411 return this.haveBuffer();
16415 return this.ii < this._buf.length;
16419 return this.state.parser.call(this, this.state.returned);
16423 this.char = ParserEND;
16427 last = this.state.parser;
16429 } while (this.state.parser !== last);
16438 /* istanbul ignore next */
16439 if (typeof fn !== 'function') throw new ParserError('Tried to set state to non-existent state: ' + JSON.stringify(fn));
16440 this.state.parser = fn;
16445 return this.runOne();
16448 call(fn, returnWith) {
16449 if (returnWith) this.next(returnWith);
16450 this.stack.push(this.state);
16451 this.state = new State(fn);
16454 callNow(fn, returnWith) {
16455 this.call(fn, returnWith);
16456 return this.runOne();
16460 /* istanbul ignore next */
16461 if (this.stack.length === 0) throw this.error(new ParserError('Stack underflow'));
16462 if (value === undefined) value = this.state.buf;
16463 this.state = this.stack.pop();
16464 this.state.returned = value;
16468 this.return(value);
16469 return this.runOne();
16473 /* istanbul ignore next */
16474 if (this.char === ParserEND) throw this.error(new ParserError('Unexpected end-of-buffer'));
16475 this.state.buf += this._buf[this.ii];
16479 err.line = this.line;
16480 err.col = this.col;
16481 err.pos = this.pos;
16484 /* istanbul ignore next */
16488 throw new ParserError('Must declare a parseStart method');
16493 Parser.END = ParserEND;
16494 Parser.Error = ParserError;
16495 var parser = Parser;
16497 var createDatetime = value => {
16498 const date = new Date(value);
16499 /* istanbul ignore if */
16502 throw new TypeError('Invalid Datetime');
16508 var formatNum = (d, num) => {
16511 while (num.length < d) num = '0' + num;
16516 const f$2 = formatNum;
16518 class FloatingDateTime extends Date {
16519 constructor(value) {
16520 super(value + 'Z');
16521 this.isFloating = true;
16525 const date = `${this.getUTCFullYear()}-${f$2(2, this.getUTCMonth() + 1)}-${f$2(2, this.getUTCDate())}`;
16526 const time = `${f$2(2, this.getUTCHours())}:${f$2(2, this.getUTCMinutes())}:${f$2(2, this.getUTCSeconds())}.${f$2(3, this.getUTCMilliseconds())}`;
16527 return `${date}T${time}`;
16532 var createDatetimeFloat = value => {
16533 const date = new FloatingDateTime(value);
16534 /* istanbul ignore if */
16537 throw new TypeError('Invalid Datetime');
16543 const f$1 = formatNum;
16544 const DateTime = global.Date;
16546 class Date$1 extends DateTime {
16547 constructor(value) {
16549 this.isDate = true;
16553 return `${this.getUTCFullYear()}-${f$1(2, this.getUTCMonth() + 1)}-${f$1(2, this.getUTCDate())}`;
16558 var createDate$1 = value => {
16559 const date = new Date$1(value);
16560 /* istanbul ignore if */
16563 throw new TypeError('Invalid Datetime');
16569 const f = formatNum;
16571 class Time extends Date {
16572 constructor(value) {
16573 super(`0000-01-01T${value}Z`);
16574 this.isTime = true;
16578 return `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`;
16583 var createTime$1 = value => {
16584 const date = new Time(value);
16585 /* istanbul ignore if */
16588 throw new TypeError('Invalid Datetime');
16594 /* eslint-disable no-new-wrappers, no-eval, camelcase, operator-linebreak */
16597 tomlParser.exports = makeParserClass(parser);
16598 tomlParser.exports.makeParserClass = makeParserClass;
16600 class TomlError extends Error {
16603 this.name = 'TomlError';
16604 /* istanbul ignore next */
16606 if (Error.captureStackTrace) Error.captureStackTrace(this, TomlError);
16607 this.fromTOML = true;
16608 this.wrapped = null;
16613 TomlError.wrap = err => {
16614 const terr = new TomlError(err.message);
16615 terr.code = err.code;
16616 terr.wrapped = err;
16620 tomlParser.exports.TomlError = TomlError;
16621 const createDateTime = createDatetime;
16622 const createDateTimeFloat = createDatetimeFloat;
16623 const createDate = createDate$1;
16624 const createTime = createTime$1;
16625 const CTRL_I = 0x09;
16626 const CTRL_J = 0x0A;
16627 const CTRL_M = 0x0D;
16628 const CTRL_CHAR_BOUNDARY = 0x1F; // the last non-character in the latin1 region of unicode, except DEL
16630 const CHAR_SP = 0x20;
16631 const CHAR_QUOT = 0x22;
16632 const CHAR_NUM = 0x23;
16633 const CHAR_APOS = 0x27;
16634 const CHAR_PLUS$1 = 0x2B;
16635 const CHAR_COMMA$2 = 0x2C;
16636 const CHAR_HYPHEN = 0x2D;
16637 const CHAR_PERIOD = 0x2E;
16638 const CHAR_0 = 0x30;
16639 const CHAR_1 = 0x31;
16640 const CHAR_7 = 0x37;
16641 const CHAR_9 = 0x39;
16642 const CHAR_COLON = 0x3A;
16643 const CHAR_EQUALS = 0x3D;
16644 const CHAR_A = 0x41;
16645 const CHAR_E = 0x45;
16646 const CHAR_F = 0x46;
16647 const CHAR_T = 0x54;
16648 const CHAR_U = 0x55;
16649 const CHAR_Z = 0x5A;
16650 const CHAR_LOWBAR = 0x5F;
16651 const CHAR_a = 0x61;
16652 const CHAR_b = 0x62;
16653 const CHAR_e = 0x65;
16654 const CHAR_f = 0x66;
16655 const CHAR_i = 0x69;
16656 const CHAR_l = 0x6C;
16657 const CHAR_n = 0x6E;
16658 const CHAR_o = 0x6F;
16659 const CHAR_r = 0x72;
16660 const CHAR_s = 0x73;
16661 const CHAR_t = 0x74;
16662 const CHAR_u = 0x75;
16663 const CHAR_x = 0x78;
16664 const CHAR_z = 0x7A;
16665 const CHAR_LCUB = 0x7B;
16666 const CHAR_RCUB = 0x7D;
16667 const CHAR_LSQB = 0x5B;
16668 const CHAR_BSOL = 0x5C;
16669 const CHAR_RSQB = 0x5D;
16670 const CHAR_DEL = 0x7F;
16671 const SURROGATE_FIRST = 0xD800;
16672 const SURROGATE_LAST = 0xDFFF;
16674 [CHAR_b]: '\u0008',
16675 [CHAR_t]: '\u0009',
16676 [CHAR_n]: '\u000A',
16677 [CHAR_f]: '\u000C',
16678 [CHAR_r]: '\u000D',
16679 [CHAR_QUOT]: '\u0022',
16680 [CHAR_BSOL]: '\u005C'
16683 function isDigit(cp) {
16684 return cp >= CHAR_0 && cp <= CHAR_9;
16687 function isHexit(cp) {
16688 return cp >= CHAR_A && cp <= CHAR_F || cp >= CHAR_a && cp <= CHAR_f || cp >= CHAR_0 && cp <= CHAR_9;
16691 function isBit(cp) {
16692 return cp === CHAR_1 || cp === CHAR_0;
16695 function isOctit(cp) {
16696 return cp >= CHAR_0 && cp <= CHAR_7;
16699 function isAlphaNumQuoteHyphen(cp) {
16700 return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_APOS || cp === CHAR_QUOT || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN;
16703 function isAlphaNumHyphen(cp) {
16704 return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN;
16707 const _type = Symbol('type');
16709 const _declared = Symbol('declared');
16711 const hasOwnProperty$a = Object.prototype.hasOwnProperty;
16712 const defineProperty = Object.defineProperty;
16713 const descriptor = {
16714 configurable: true,
16720 function hasKey(obj, key) {
16721 if (hasOwnProperty$a.call(obj, key)) return true;
16722 if (key === '__proto__') defineProperty(obj, '__proto__', descriptor);
16726 const INLINE_TABLE = Symbol('inline-table');
16728 function InlineTable() {
16729 return Object.defineProperties({}, {
16731 value: INLINE_TABLE
16736 function isInlineTable(obj) {
16737 if (obj === null || typeof obj !== 'object') return false;
16738 return obj[_type] === INLINE_TABLE;
16741 const TABLE = Symbol('table');
16744 return Object.defineProperties({}, {
16755 function isTable(obj) {
16756 if (obj === null || typeof obj !== 'object') return false;
16757 return obj[_type] === TABLE;
16760 const _contentType = Symbol('content-type');
16762 const INLINE_LIST = Symbol('inline-list');
16764 function InlineList(type) {
16765 return Object.defineProperties([], {
16775 function isInlineList(obj) {
16776 if (obj === null || typeof obj !== 'object') return false;
16777 return obj[_type] === INLINE_LIST;
16780 const LIST = Symbol('list');
16783 return Object.defineProperties([], {
16790 function isList(obj) {
16791 if (obj === null || typeof obj !== 'object') return false;
16792 return obj[_type] === LIST;
16793 } // in an eval, to let bundlers not slurp in a util proxy
16799 const utilInspect = require('util').inspect;
16801 _custom = utilInspect.custom;
16803 /* eval require not available in transpiled bundle */
16805 /* istanbul ignore next */
16808 const _inspect = _custom || 'inspect';
16810 class BoxedBigInt {
16811 constructor(value) {
16813 this.value = global.BigInt.asIntN(64, value);
16815 /* istanbul ignore next */
16819 Object.defineProperty(this, _type, {
16825 return this.value === null;
16827 /* istanbul ignore next */
16831 return String(this.value);
16833 /* istanbul ignore next */
16837 return `[BigInt: ${this.toString()}]}`;
16846 const INTEGER = Symbol('integer');
16848 function Integer(value) {
16849 let num = Number(value); // -0 is a float thing, not an int thing
16851 if (Object.is(num, -0)) num = 0;
16852 /* istanbul ignore else */
16854 if (global.BigInt && !Number.isSafeInteger(num)) {
16855 return new BoxedBigInt(value);
16857 /* istanbul ignore next */
16858 return Object.defineProperties(new Number(num), {
16860 value: function () {
16861 return isNaN(this);
16868 value: () => `[Integer: ${value}]`
16874 function isInteger(obj) {
16875 if (obj === null || typeof obj !== 'object') return false;
16876 return obj[_type] === INTEGER;
16879 const FLOAT = Symbol('float');
16881 function Float(value) {
16882 /* istanbul ignore next */
16883 return Object.defineProperties(new Number(value), {
16888 value: () => `[Float: ${value}]`
16893 function isFloat(obj) {
16894 if (obj === null || typeof obj !== 'object') return false;
16895 return obj[_type] === FLOAT;
16898 function tomlType(value) {
16899 const type = typeof value;
16901 if (type === 'object') {
16902 /* istanbul ignore if */
16903 if (value === null) return 'null';
16904 if (value instanceof Date) return 'datetime';
16905 /* istanbul ignore else */
16907 if (_type in value) {
16908 switch (value[_type]) {
16910 return 'inline-table';
16913 return 'inline-list';
16915 /* istanbul ignore next */
16920 /* istanbul ignore next */
16937 function makeParserClass(Parser) {
16938 class TOMLParser extends Parser {
16941 this.ctx = this.obj = Table();
16947 return this.char === CHAR_NUM || this.char === CTRL_I || this.char === CHAR_SP || this.atEndOfLine();
16951 return this.char === Parser.END || this.char === CTRL_J || this.char === CTRL_M;
16955 if (this.char === Parser.END) {
16957 } else if (this.char === CHAR_LSQB) {
16958 return this.call(this.parseTableOrList);
16959 } else if (this.char === CHAR_NUM) {
16960 return this.call(this.parseComment);
16961 } else if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
16963 } else if (isAlphaNumQuoteHyphen(this.char)) {
16964 return this.callNow(this.parseAssignStatement);
16966 throw this.error(new TomlError(`Unknown character "${this.char}"`));
16968 } // HELPER, this strips any whitespace and comments to the end of the line
16969 // then RETURNS. Last state in a production.
16972 parseWhitespaceToEOL() {
16973 if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
16975 } else if (this.char === CHAR_NUM) {
16976 return this.goto(this.parseComment);
16977 } else if (this.char === Parser.END || this.char === CTRL_J) {
16978 return this.return();
16980 throw this.error(new TomlError('Unexpected character, expected only whitespace or comments till end of line'));
16983 /* ASSIGNMENT: key = value */
16986 parseAssignStatement() {
16987 return this.callNow(this.parseAssign, this.recordAssignStatement);
16990 recordAssignStatement(kv) {
16991 let target = this.ctx;
16992 let finalKey = kv.key.pop();
16994 for (let kw of kv.key) {
16995 if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
16996 throw this.error(new TomlError("Can't redefine existing key"));
16999 target = target[kw] = target[kw] || Table();
17002 if (hasKey(target, finalKey)) {
17003 throw this.error(new TomlError("Can't redefine existing key"));
17004 } // unbox our numbers
17007 if (isInteger(kv.value) || isFloat(kv.value)) {
17008 target[finalKey] = kv.value.valueOf();
17010 target[finalKey] = kv.value;
17013 return this.goto(this.parseWhitespaceToEOL);
17015 /* ASSSIGNMENT expression, key = value possibly inside an inline table */
17019 return this.callNow(this.parseKeyword, this.recordAssignKeyword);
17022 recordAssignKeyword(key) {
17023 if (this.state.resultTable) {
17024 this.state.resultTable.push(key);
17026 this.state.resultTable = [key];
17029 return this.goto(this.parseAssignKeywordPreDot);
17032 parseAssignKeywordPreDot() {
17033 if (this.char === CHAR_PERIOD) {
17034 return this.next(this.parseAssignKeywordPostDot);
17035 } else if (this.char !== CHAR_SP && this.char !== CTRL_I) {
17036 return this.goto(this.parseAssignEqual);
17040 parseAssignKeywordPostDot() {
17041 if (this.char !== CHAR_SP && this.char !== CTRL_I) {
17042 return this.callNow(this.parseKeyword, this.recordAssignKeyword);
17046 parseAssignEqual() {
17047 if (this.char === CHAR_EQUALS) {
17048 return this.next(this.parseAssignPreValue);
17050 throw this.error(new TomlError('Invalid character, expected "="'));
17054 parseAssignPreValue() {
17055 if (this.char === CHAR_SP || this.char === CTRL_I) {
17058 return this.callNow(this.parseValue, this.recordAssignValue);
17062 recordAssignValue(value) {
17063 return this.returnNow({
17064 key: this.state.resultTable,
17068 /* COMMENTS: #...eol */
17073 if (this.char === Parser.END || this.char === CTRL_J) {
17074 return this.return();
17076 } while (this.nextChar());
17078 /* TABLES AND LISTS, [foo] and [[foo]] */
17081 parseTableOrList() {
17082 if (this.char === CHAR_LSQB) {
17083 this.next(this.parseList);
17085 return this.goto(this.parseTable);
17088 /* TABLE [foo.bar.baz] */
17092 this.ctx = this.obj;
17093 return this.goto(this.parseTableNext);
17097 if (this.char === CHAR_SP || this.char === CTRL_I) {
17100 return this.callNow(this.parseKeyword, this.parseTableMore);
17104 parseTableMore(keyword) {
17105 if (this.char === CHAR_SP || this.char === CTRL_I) {
17107 } else if (this.char === CHAR_RSQB) {
17108 if (hasKey(this.ctx, keyword) && (!isTable(this.ctx[keyword]) || this.ctx[keyword][_declared])) {
17109 throw this.error(new TomlError("Can't redefine existing key"));
17111 this.ctx = this.ctx[keyword] = this.ctx[keyword] || Table();
17112 this.ctx[_declared] = true;
17115 return this.next(this.parseWhitespaceToEOL);
17116 } else if (this.char === CHAR_PERIOD) {
17117 if (!hasKey(this.ctx, keyword)) {
17118 this.ctx = this.ctx[keyword] = Table();
17119 } else if (isTable(this.ctx[keyword])) {
17120 this.ctx = this.ctx[keyword];
17121 } else if (isList(this.ctx[keyword])) {
17122 this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
17124 throw this.error(new TomlError("Can't redefine existing key"));
17127 return this.next(this.parseTableNext);
17129 throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
17132 /* LIST [[a.b.c]] */
17136 this.ctx = this.obj;
17137 return this.goto(this.parseListNext);
17141 if (this.char === CHAR_SP || this.char === CTRL_I) {
17144 return this.callNow(this.parseKeyword, this.parseListMore);
17148 parseListMore(keyword) {
17149 if (this.char === CHAR_SP || this.char === CTRL_I) {
17151 } else if (this.char === CHAR_RSQB) {
17152 if (!hasKey(this.ctx, keyword)) {
17153 this.ctx[keyword] = List();
17156 if (isInlineList(this.ctx[keyword])) {
17157 throw this.error(new TomlError("Can't extend an inline array"));
17158 } else if (isList(this.ctx[keyword])) {
17159 const next = Table();
17160 this.ctx[keyword].push(next);
17163 throw this.error(new TomlError("Can't redefine an existing key"));
17166 return this.next(this.parseListEnd);
17167 } else if (this.char === CHAR_PERIOD) {
17168 if (!hasKey(this.ctx, keyword)) {
17169 this.ctx = this.ctx[keyword] = Table();
17170 } else if (isInlineList(this.ctx[keyword])) {
17171 throw this.error(new TomlError("Can't extend an inline array"));
17172 } else if (isInlineTable(this.ctx[keyword])) {
17173 throw this.error(new TomlError("Can't extend an inline table"));
17174 } else if (isList(this.ctx[keyword])) {
17175 this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
17176 } else if (isTable(this.ctx[keyword])) {
17177 this.ctx = this.ctx[keyword];
17179 throw this.error(new TomlError("Can't redefine an existing key"));
17182 return this.next(this.parseListNext);
17184 throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
17188 parseListEnd(keyword) {
17189 if (this.char === CHAR_RSQB) {
17190 return this.next(this.parseWhitespaceToEOL);
17192 throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
17195 /* VALUE string, number, boolean, inline list, inline object */
17199 if (this.char === Parser.END) {
17200 throw this.error(new TomlError('Key without value'));
17201 } else if (this.char === CHAR_QUOT) {
17202 return this.next(this.parseDoubleString);
17205 if (this.char === CHAR_APOS) {
17206 return this.next(this.parseSingleString);
17207 } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS$1) {
17208 return this.goto(this.parseNumberSign);
17209 } else if (this.char === CHAR_i) {
17210 return this.next(this.parseInf);
17211 } else if (this.char === CHAR_n) {
17212 return this.next(this.parseNan);
17213 } else if (isDigit(this.char)) {
17214 return this.goto(this.parseNumberOrDateTime);
17215 } else if (this.char === CHAR_t || this.char === CHAR_f) {
17216 return this.goto(this.parseBoolean);
17217 } else if (this.char === CHAR_LSQB) {
17218 return this.call(this.parseInlineList, this.recordValue);
17219 } else if (this.char === CHAR_LCUB) {
17220 return this.call(this.parseInlineTable, this.recordValue);
17222 throw this.error(new TomlError('Unexpected character, expecting string, number, datetime, boolean, inline array or inline table'));
17226 recordValue(value) {
17227 return this.returnNow(value);
17231 if (this.char === CHAR_n) {
17232 return this.next(this.parseInf2);
17234 throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
17239 if (this.char === CHAR_f) {
17240 if (this.state.buf === '-') {
17241 return this.return(-Infinity);
17243 return this.return(Infinity);
17246 throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
17251 if (this.char === CHAR_a) {
17252 return this.next(this.parseNan2);
17254 throw this.error(new TomlError('Unexpected character, expected "nan"'));
17259 if (this.char === CHAR_n) {
17260 return this.return(NaN);
17262 throw this.error(new TomlError('Unexpected character, expected "nan"'));
17265 /* KEYS, barewords or basic, literal, or dotted */
17269 if (this.char === CHAR_QUOT) {
17270 return this.next(this.parseBasicString);
17271 } else if (this.char === CHAR_APOS) {
17272 return this.next(this.parseLiteralString);
17274 return this.goto(this.parseBareKey);
17277 /* KEYS: barewords */
17282 if (this.char === Parser.END) {
17283 throw this.error(new TomlError('Key ended without value'));
17284 } else if (isAlphaNumHyphen(this.char)) {
17286 } else if (this.state.buf.length === 0) {
17287 throw this.error(new TomlError('Empty bare keys are not allowed'));
17289 return this.returnNow();
17291 } while (this.nextChar());
17293 /* STRINGS, single quoted (literal) */
17296 parseSingleString() {
17297 if (this.char === CHAR_APOS) {
17298 return this.next(this.parseLiteralMultiStringMaybe);
17300 return this.goto(this.parseLiteralString);
17304 parseLiteralString() {
17306 if (this.char === CHAR_APOS) {
17307 return this.return();
17308 } else if (this.atEndOfLine()) {
17309 throw this.error(new TomlError('Unterminated string'));
17310 } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
17311 throw this.errorControlCharInString();
17315 } while (this.nextChar());
17318 parseLiteralMultiStringMaybe() {
17319 if (this.char === CHAR_APOS) {
17320 return this.next(this.parseLiteralMultiString);
17322 return this.returnNow();
17326 parseLiteralMultiString() {
17327 if (this.char === CTRL_M) {
17329 } else if (this.char === CTRL_J) {
17330 return this.next(this.parseLiteralMultiStringContent);
17332 return this.goto(this.parseLiteralMultiStringContent);
17336 parseLiteralMultiStringContent() {
17338 if (this.char === CHAR_APOS) {
17339 return this.next(this.parseLiteralMultiEnd);
17340 } else if (this.char === Parser.END) {
17341 throw this.error(new TomlError('Unterminated multi-line string'));
17342 } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
17343 throw this.errorControlCharInString();
17347 } while (this.nextChar());
17350 parseLiteralMultiEnd() {
17351 if (this.char === CHAR_APOS) {
17352 return this.next(this.parseLiteralMultiEnd2);
17354 this.state.buf += "'";
17355 return this.goto(this.parseLiteralMultiStringContent);
17359 parseLiteralMultiEnd2() {
17360 if (this.char === CHAR_APOS) {
17361 return this.return();
17363 this.state.buf += "''";
17364 return this.goto(this.parseLiteralMultiStringContent);
17367 /* STRINGS double quoted */
17370 parseDoubleString() {
17371 if (this.char === CHAR_QUOT) {
17372 return this.next(this.parseMultiStringMaybe);
17374 return this.goto(this.parseBasicString);
17378 parseBasicString() {
17380 if (this.char === CHAR_BSOL) {
17381 return this.call(this.parseEscape, this.recordEscapeReplacement);
17382 } else if (this.char === CHAR_QUOT) {
17383 return this.return();
17384 } else if (this.atEndOfLine()) {
17385 throw this.error(new TomlError('Unterminated string'));
17386 } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
17387 throw this.errorControlCharInString();
17391 } while (this.nextChar());
17394 recordEscapeReplacement(replacement) {
17395 this.state.buf += replacement;
17396 return this.goto(this.parseBasicString);
17399 parseMultiStringMaybe() {
17400 if (this.char === CHAR_QUOT) {
17401 return this.next(this.parseMultiString);
17403 return this.returnNow();
17407 parseMultiString() {
17408 if (this.char === CTRL_M) {
17410 } else if (this.char === CTRL_J) {
17411 return this.next(this.parseMultiStringContent);
17413 return this.goto(this.parseMultiStringContent);
17417 parseMultiStringContent() {
17419 if (this.char === CHAR_BSOL) {
17420 return this.call(this.parseMultiEscape, this.recordMultiEscapeReplacement);
17421 } else if (this.char === CHAR_QUOT) {
17422 return this.next(this.parseMultiEnd);
17423 } else if (this.char === Parser.END) {
17424 throw this.error(new TomlError('Unterminated multi-line string'));
17425 } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
17426 throw this.errorControlCharInString();
17430 } while (this.nextChar());
17433 errorControlCharInString() {
17434 let displayCode = '\\u00';
17436 if (this.char < 16) {
17437 displayCode += '0';
17440 displayCode += this.char.toString(16);
17441 return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in strings, use ${displayCode} instead`));
17444 recordMultiEscapeReplacement(replacement) {
17445 this.state.buf += replacement;
17446 return this.goto(this.parseMultiStringContent);
17450 if (this.char === CHAR_QUOT) {
17451 return this.next(this.parseMultiEnd2);
17453 this.state.buf += '"';
17454 return this.goto(this.parseMultiStringContent);
17459 if (this.char === CHAR_QUOT) {
17460 return this.return();
17462 this.state.buf += '""';
17463 return this.goto(this.parseMultiStringContent);
17467 parseMultiEscape() {
17468 if (this.char === CTRL_M || this.char === CTRL_J) {
17469 return this.next(this.parseMultiTrim);
17470 } else if (this.char === CHAR_SP || this.char === CTRL_I) {
17471 return this.next(this.parsePreMultiTrim);
17473 return this.goto(this.parseEscape);
17477 parsePreMultiTrim() {
17478 if (this.char === CHAR_SP || this.char === CTRL_I) {
17480 } else if (this.char === CTRL_M || this.char === CTRL_J) {
17481 return this.next(this.parseMultiTrim);
17483 throw this.error(new TomlError("Can't escape whitespace"));
17488 // explicitly whitespace here, END should follow the same path as chars
17489 if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
17492 return this.returnNow();
17497 if (this.char in escapes) {
17498 return this.return(escapes[this.char]);
17499 } else if (this.char === CHAR_u) {
17500 return this.call(this.parseSmallUnicode, this.parseUnicodeReturn);
17501 } else if (this.char === CHAR_U) {
17502 return this.call(this.parseLargeUnicode, this.parseUnicodeReturn);
17504 throw this.error(new TomlError('Unknown escape character: ' + this.char));
17508 parseUnicodeReturn(char) {
17510 const codePoint = parseInt(char, 16);
17512 if (codePoint >= SURROGATE_FIRST && codePoint <= SURROGATE_LAST) {
17513 throw this.error(new TomlError('Invalid unicode, character in range 0xD800 - 0xDFFF is reserved'));
17516 return this.returnNow(String.fromCodePoint(codePoint));
17518 throw this.error(TomlError.wrap(err));
17522 parseSmallUnicode() {
17523 if (!isHexit(this.char)) {
17524 throw this.error(new TomlError('Invalid character in unicode sequence, expected hex'));
17527 if (this.state.buf.length >= 4) return this.return();
17531 parseLargeUnicode() {
17532 if (!isHexit(this.char)) {
17533 throw this.error(new TomlError('Invalid character in unicode sequence, expected hex'));
17536 if (this.state.buf.length >= 8) return this.return();
17542 parseNumberSign() {
17544 return this.next(this.parseMaybeSignedInfOrNan);
17547 parseMaybeSignedInfOrNan() {
17548 if (this.char === CHAR_i) {
17549 return this.next(this.parseInf);
17550 } else if (this.char === CHAR_n) {
17551 return this.next(this.parseNan);
17553 return this.callNow(this.parseNoUnder, this.parseNumberIntegerStart);
17557 parseNumberIntegerStart() {
17558 if (this.char === CHAR_0) {
17560 return this.next(this.parseNumberIntegerExponentOrDecimal);
17562 return this.goto(this.parseNumberInteger);
17566 parseNumberIntegerExponentOrDecimal() {
17567 if (this.char === CHAR_PERIOD) {
17569 return this.call(this.parseNoUnder, this.parseNumberFloat);
17570 } else if (this.char === CHAR_E || this.char === CHAR_e) {
17572 return this.next(this.parseNumberExponentSign);
17574 return this.returnNow(Integer(this.state.buf));
17578 parseNumberInteger() {
17579 if (isDigit(this.char)) {
17581 } else if (this.char === CHAR_LOWBAR) {
17582 return this.call(this.parseNoUnder);
17583 } else if (this.char === CHAR_E || this.char === CHAR_e) {
17585 return this.next(this.parseNumberExponentSign);
17586 } else if (this.char === CHAR_PERIOD) {
17588 return this.call(this.parseNoUnder, this.parseNumberFloat);
17590 const result = Integer(this.state.buf);
17591 /* istanbul ignore if */
17593 if (result.isNaN()) {
17594 throw this.error(new TomlError('Invalid number'));
17596 return this.returnNow(result);
17602 if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD || this.char === CHAR_E || this.char === CHAR_e) {
17603 throw this.error(new TomlError('Unexpected character, expected digit'));
17604 } else if (this.atEndOfWord()) {
17605 throw this.error(new TomlError('Incomplete number'));
17608 return this.returnNow();
17611 parseNoUnderHexOctBinLiteral() {
17612 if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD) {
17613 throw this.error(new TomlError('Unexpected character, expected digit'));
17614 } else if (this.atEndOfWord()) {
17615 throw this.error(new TomlError('Incomplete number'));
17618 return this.returnNow();
17621 parseNumberFloat() {
17622 if (this.char === CHAR_LOWBAR) {
17623 return this.call(this.parseNoUnder, this.parseNumberFloat);
17624 } else if (isDigit(this.char)) {
17626 } else if (this.char === CHAR_E || this.char === CHAR_e) {
17628 return this.next(this.parseNumberExponentSign);
17630 return this.returnNow(Float(this.state.buf));
17634 parseNumberExponentSign() {
17635 if (isDigit(this.char)) {
17636 return this.goto(this.parseNumberExponent);
17637 } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS$1) {
17639 this.call(this.parseNoUnder, this.parseNumberExponent);
17641 throw this.error(new TomlError('Unexpected character, expected -, + or digit'));
17645 parseNumberExponent() {
17646 if (isDigit(this.char)) {
17648 } else if (this.char === CHAR_LOWBAR) {
17649 return this.call(this.parseNoUnder);
17651 return this.returnNow(Float(this.state.buf));
17654 /* NUMBERS or DATETIMES */
17657 parseNumberOrDateTime() {
17658 if (this.char === CHAR_0) {
17660 return this.next(this.parseNumberBaseOrDateTime);
17662 return this.goto(this.parseNumberOrDateTimeOnly);
17666 parseNumberOrDateTimeOnly() {
17667 // note, if two zeros are in a row then it MUST be a date
17668 if (this.char === CHAR_LOWBAR) {
17669 return this.call(this.parseNoUnder, this.parseNumberInteger);
17670 } else if (isDigit(this.char)) {
17672 if (this.state.buf.length > 4) this.next(this.parseNumberInteger);
17673 } else if (this.char === CHAR_E || this.char === CHAR_e) {
17675 return this.next(this.parseNumberExponentSign);
17676 } else if (this.char === CHAR_PERIOD) {
17678 return this.call(this.parseNoUnder, this.parseNumberFloat);
17679 } else if (this.char === CHAR_HYPHEN) {
17680 return this.goto(this.parseDateTime);
17681 } else if (this.char === CHAR_COLON) {
17682 return this.goto(this.parseOnlyTimeHour);
17684 return this.returnNow(Integer(this.state.buf));
17688 parseDateTimeOnly() {
17689 if (this.state.buf.length < 4) {
17690 if (isDigit(this.char)) {
17691 return this.consume();
17692 } else if (this.char === CHAR_COLON) {
17693 return this.goto(this.parseOnlyTimeHour);
17695 throw this.error(new TomlError('Expected digit while parsing year part of a date'));
17698 if (this.char === CHAR_HYPHEN) {
17699 return this.goto(this.parseDateTime);
17701 throw this.error(new TomlError('Expected hyphen (-) while parsing year part of date'));
17706 parseNumberBaseOrDateTime() {
17707 if (this.char === CHAR_b) {
17709 return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerBin);
17710 } else if (this.char === CHAR_o) {
17712 return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerOct);
17713 } else if (this.char === CHAR_x) {
17715 return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerHex);
17716 } else if (this.char === CHAR_PERIOD) {
17717 return this.goto(this.parseNumberInteger);
17718 } else if (isDigit(this.char)) {
17719 return this.goto(this.parseDateTimeOnly);
17721 return this.returnNow(Integer(this.state.buf));
17725 parseIntegerHex() {
17726 if (isHexit(this.char)) {
17728 } else if (this.char === CHAR_LOWBAR) {
17729 return this.call(this.parseNoUnderHexOctBinLiteral);
17731 const result = Integer(this.state.buf);
17732 /* istanbul ignore if */
17734 if (result.isNaN()) {
17735 throw this.error(new TomlError('Invalid number'));
17737 return this.returnNow(result);
17742 parseIntegerOct() {
17743 if (isOctit(this.char)) {
17745 } else if (this.char === CHAR_LOWBAR) {
17746 return this.call(this.parseNoUnderHexOctBinLiteral);
17748 const result = Integer(this.state.buf);
17749 /* istanbul ignore if */
17751 if (result.isNaN()) {
17752 throw this.error(new TomlError('Invalid number'));
17754 return this.returnNow(result);
17759 parseIntegerBin() {
17760 if (isBit(this.char)) {
17762 } else if (this.char === CHAR_LOWBAR) {
17763 return this.call(this.parseNoUnderHexOctBinLiteral);
17765 const result = Integer(this.state.buf);
17766 /* istanbul ignore if */
17768 if (result.isNaN()) {
17769 throw this.error(new TomlError('Invalid number'));
17771 return this.returnNow(result);
17779 // we enter here having just consumed the year and about to consume the hyphen
17780 if (this.state.buf.length < 4) {
17781 throw this.error(new TomlError('Years less than 1000 must be zero padded to four characters'));
17784 this.state.result = this.state.buf;
17785 this.state.buf = '';
17786 return this.next(this.parseDateMonth);
17790 if (this.char === CHAR_HYPHEN) {
17791 if (this.state.buf.length < 2) {
17792 throw this.error(new TomlError('Months less than 10 must be zero padded to two characters'));
17795 this.state.result += '-' + this.state.buf;
17796 this.state.buf = '';
17797 return this.next(this.parseDateDay);
17798 } else if (isDigit(this.char)) {
17801 throw this.error(new TomlError('Incomplete datetime'));
17806 if (this.char === CHAR_T || this.char === CHAR_SP) {
17807 if (this.state.buf.length < 2) {
17808 throw this.error(new TomlError('Days less than 10 must be zero padded to two characters'));
17811 this.state.result += '-' + this.state.buf;
17812 this.state.buf = '';
17813 return this.next(this.parseStartTimeHour);
17814 } else if (this.atEndOfWord()) {
17815 return this.returnNow(createDate(this.state.result + '-' + this.state.buf));
17816 } else if (isDigit(this.char)) {
17819 throw this.error(new TomlError('Incomplete datetime'));
17823 parseStartTimeHour() {
17824 if (this.atEndOfWord()) {
17825 return this.returnNow(createDate(this.state.result));
17827 return this.goto(this.parseTimeHour);
17832 if (this.char === CHAR_COLON) {
17833 if (this.state.buf.length < 2) {
17834 throw this.error(new TomlError('Hours less than 10 must be zero padded to two characters'));
17837 this.state.result += 'T' + this.state.buf;
17838 this.state.buf = '';
17839 return this.next(this.parseTimeMin);
17840 } else if (isDigit(this.char)) {
17843 throw this.error(new TomlError('Incomplete datetime'));
17848 if (this.state.buf.length < 2 && isDigit(this.char)) {
17850 } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
17851 this.state.result += ':' + this.state.buf;
17852 this.state.buf = '';
17853 return this.next(this.parseTimeSec);
17855 throw this.error(new TomlError('Incomplete datetime'));
17860 if (isDigit(this.char)) {
17863 if (this.state.buf.length === 2) {
17864 this.state.result += ':' + this.state.buf;
17865 this.state.buf = '';
17866 return this.next(this.parseTimeZoneOrFraction);
17869 throw this.error(new TomlError('Incomplete datetime'));
17873 parseOnlyTimeHour() {
17874 /* istanbul ignore else */
17875 if (this.char === CHAR_COLON) {
17876 if (this.state.buf.length < 2) {
17877 throw this.error(new TomlError('Hours less than 10 must be zero padded to two characters'));
17880 this.state.result = this.state.buf;
17881 this.state.buf = '';
17882 return this.next(this.parseOnlyTimeMin);
17884 throw this.error(new TomlError('Incomplete time'));
17888 parseOnlyTimeMin() {
17889 if (this.state.buf.length < 2 && isDigit(this.char)) {
17891 } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
17892 this.state.result += ':' + this.state.buf;
17893 this.state.buf = '';
17894 return this.next(this.parseOnlyTimeSec);
17896 throw this.error(new TomlError('Incomplete time'));
17900 parseOnlyTimeSec() {
17901 if (isDigit(this.char)) {
17904 if (this.state.buf.length === 2) {
17905 return this.next(this.parseOnlyTimeFractionMaybe);
17908 throw this.error(new TomlError('Incomplete time'));
17912 parseOnlyTimeFractionMaybe() {
17913 this.state.result += ':' + this.state.buf;
17915 if (this.char === CHAR_PERIOD) {
17916 this.state.buf = '';
17917 this.next(this.parseOnlyTimeFraction);
17919 return this.return(createTime(this.state.result));
17923 parseOnlyTimeFraction() {
17924 if (isDigit(this.char)) {
17926 } else if (this.atEndOfWord()) {
17927 if (this.state.buf.length === 0) throw this.error(new TomlError('Expected digit in milliseconds'));
17928 return this.returnNow(createTime(this.state.result + '.' + this.state.buf));
17930 throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
17934 parseTimeZoneOrFraction() {
17935 if (this.char === CHAR_PERIOD) {
17937 this.next(this.parseDateTimeFraction);
17938 } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS$1) {
17940 this.next(this.parseTimeZoneHour);
17941 } else if (this.char === CHAR_Z) {
17943 return this.return(createDateTime(this.state.result + this.state.buf));
17944 } else if (this.atEndOfWord()) {
17945 return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf));
17947 throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
17951 parseDateTimeFraction() {
17952 if (isDigit(this.char)) {
17954 } else if (this.state.buf.length === 1) {
17955 throw this.error(new TomlError('Expected digit in milliseconds'));
17956 } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS$1) {
17958 this.next(this.parseTimeZoneHour);
17959 } else if (this.char === CHAR_Z) {
17961 return this.return(createDateTime(this.state.result + this.state.buf));
17962 } else if (this.atEndOfWord()) {
17963 return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf));
17965 throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
17969 parseTimeZoneHour() {
17970 if (isDigit(this.char)) {
17971 this.consume(); // FIXME: No more regexps
17973 if (/\d\d$/.test(this.state.buf)) return this.next(this.parseTimeZoneSep);
17975 throw this.error(new TomlError('Unexpected character in datetime, expected digit'));
17979 parseTimeZoneSep() {
17980 if (this.char === CHAR_COLON) {
17982 this.next(this.parseTimeZoneMin);
17984 throw this.error(new TomlError('Unexpected character in datetime, expected colon'));
17988 parseTimeZoneMin() {
17989 if (isDigit(this.char)) {
17991 if (/\d\d$/.test(this.state.buf)) return this.return(createDateTime(this.state.result + this.state.buf));
17993 throw this.error(new TomlError('Unexpected character in datetime, expected digit'));
18000 /* istanbul ignore else */
18001 if (this.char === CHAR_t) {
18003 return this.next(this.parseTrue_r);
18004 } else if (this.char === CHAR_f) {
18006 return this.next(this.parseFalse_a);
18011 if (this.char === CHAR_r) {
18013 return this.next(this.parseTrue_u);
18015 throw this.error(new TomlError('Invalid boolean, expected true or false'));
18020 if (this.char === CHAR_u) {
18022 return this.next(this.parseTrue_e);
18024 throw this.error(new TomlError('Invalid boolean, expected true or false'));
18029 if (this.char === CHAR_e) {
18030 return this.return(true);
18032 throw this.error(new TomlError('Invalid boolean, expected true or false'));
18037 if (this.char === CHAR_a) {
18039 return this.next(this.parseFalse_l);
18041 throw this.error(new TomlError('Invalid boolean, expected true or false'));
18046 if (this.char === CHAR_l) {
18048 return this.next(this.parseFalse_s);
18050 throw this.error(new TomlError('Invalid boolean, expected true or false'));
18055 if (this.char === CHAR_s) {
18057 return this.next(this.parseFalse_e);
18059 throw this.error(new TomlError('Invalid boolean, expected true or false'));
18064 if (this.char === CHAR_e) {
18065 return this.return(false);
18067 throw this.error(new TomlError('Invalid boolean, expected true or false'));
18073 parseInlineList() {
18074 if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
18076 } else if (this.char === Parser.END) {
18077 throw this.error(new TomlError('Unterminated inline array'));
18078 } else if (this.char === CHAR_NUM) {
18079 return this.call(this.parseComment);
18080 } else if (this.char === CHAR_RSQB) {
18081 return this.return(this.state.resultArr || InlineList());
18083 return this.callNow(this.parseValue, this.recordInlineListValue);
18087 recordInlineListValue(value) {
18088 if (this.state.resultArr) {
18089 const listType = this.state.resultArr[_contentType];
18090 const valueType = tomlType(value);
18092 if (listType !== valueType) {
18093 throw this.error(new TomlError(`Inline lists must be a single type, not a mix of ${listType} and ${valueType}`));
18096 this.state.resultArr = InlineList(tomlType(value));
18099 if (isFloat(value) || isInteger(value)) {
18100 // unbox now that we've verified they're ok
18101 this.state.resultArr.push(value.valueOf());
18103 this.state.resultArr.push(value);
18106 return this.goto(this.parseInlineListNext);
18109 parseInlineListNext() {
18110 if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
18112 } else if (this.char === CHAR_NUM) {
18113 return this.call(this.parseComment);
18114 } else if (this.char === CHAR_COMMA$2) {
18115 return this.next(this.parseInlineList);
18116 } else if (this.char === CHAR_RSQB) {
18117 return this.goto(this.parseInlineList);
18119 throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'));
18125 parseInlineTable() {
18126 if (this.char === CHAR_SP || this.char === CTRL_I) {
18128 } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
18129 throw this.error(new TomlError('Unterminated inline array'));
18130 } else if (this.char === CHAR_RCUB) {
18131 return this.return(this.state.resultTable || InlineTable());
18133 if (!this.state.resultTable) this.state.resultTable = InlineTable();
18134 return this.callNow(this.parseAssign, this.recordInlineTableValue);
18138 recordInlineTableValue(kv) {
18139 let target = this.state.resultTable;
18140 let finalKey = kv.key.pop();
18142 for (let kw of kv.key) {
18143 if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
18144 throw this.error(new TomlError("Can't redefine existing key"));
18147 target = target[kw] = target[kw] || Table();
18150 if (hasKey(target, finalKey)) {
18151 throw this.error(new TomlError("Can't redefine existing key"));
18154 if (isInteger(kv.value) || isFloat(kv.value)) {
18155 target[finalKey] = kv.value.valueOf();
18157 target[finalKey] = kv.value;
18160 return this.goto(this.parseInlineTableNext);
18163 parseInlineTableNext() {
18164 if (this.char === CHAR_SP || this.char === CTRL_I) {
18166 } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
18167 throw this.error(new TomlError('Unterminated inline array'));
18168 } else if (this.char === CHAR_COMMA$2) {
18169 return this.next(this.parseInlineTable);
18170 } else if (this.char === CHAR_RCUB) {
18171 return this.goto(this.parseInlineTable);
18173 throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'));
18182 var parsePrettyError = prettyError$1;
18184 function prettyError$1(err, buf) {
18185 /* istanbul ignore if */
18186 if (err.pos == null || err.line == null) return err;
18187 let msg = err.message;
18188 msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}:\n`;
18189 /* istanbul ignore else */
18191 if (buf && buf.split) {
18192 const lines = buf.split(/\n/);
18193 const lineNumWidth = String(Math.min(lines.length, err.line + 3)).length;
18194 let linePadding = ' ';
18196 while (linePadding.length < lineNumWidth) linePadding += ' ';
18198 for (let ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) {
18199 let lineNum = String(ii + 1);
18200 if (lineNum.length < lineNumWidth) lineNum = ' ' + lineNum;
18202 if (err.line === ii) {
18203 msg += lineNum + '> ' + lines[ii] + '\n';
18204 msg += linePadding + ' ';
18206 for (let hh = 0; hh < err.col; ++hh) {
18212 msg += lineNum + ': ' + lines[ii] + '\n';
18217 err.message = msg + '\n';
18221 var parseString_1 = parseString$1;
18222 const TOMLParser = tomlParser.exports;
18223 const prettyError = parsePrettyError;
18225 function parseString$1(str) {
18226 if (global.Buffer && global.Buffer.isBuffer(str)) {
18227 str = str.toString('utf8');
18230 const parser = new TOMLParser();
18234 return parser.finish();
18236 throw prettyError(err, str);
18240 const parse$b = parseString_1;
18242 var loadToml$1 = function (filePath, content) {
18244 return parse$b(content);
18246 error.message = `TOML Error in ${filePath}:\n${error.message}`;
18251 // This is a generated file. Do not edit.
18252 var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
18253 var ID_Start = /[\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\u0561-\u0587\u05D0-\u05EA\u05F0-\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\u08A0-\u08B4\u08B6-\u08BD\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\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\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\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\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-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\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\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\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\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\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-\uAB65\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
18254 var ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\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\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\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\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
18256 Space_Separator: Space_Separator,
18257 ID_Start: ID_Start,
18258 ID_Continue: ID_Continue
18261 isSpaceSeparator(c) {
18262 return typeof c === 'string' && unicode.Space_Separator.test(c);
18266 return typeof c === 'string' && (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c === '$' || c === '_' || unicode.ID_Start.test(c));
18269 isIdContinueChar(c) {
18270 return typeof c === 'string' && (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c === '$' || c === '_' || c === '\u200C' || c === '\u200D' || unicode.ID_Continue.test(c));
18274 return typeof c === 'string' && /[0-9]/.test(c);
18278 return typeof c === 'string' && /[0-9A-Fa-f]/.test(c);
18292 var parse$a = function parse(text, reviver) {
18293 source$1 = String(text);
18294 parseState = 'start';
18301 root$9 = undefined;
18304 token = lex(); // This code is unreachable.
18305 // if (!parseStates[parseState]) {
18306 // throw invalidParseState()
18309 parseStates[parseState]();
18310 } while (token.type !== 'eof');
18312 if (typeof reviver === 'function') {
18313 return internalize({
18321 function internalize(holder, name, reviver) {
18322 const value = holder[name];
18324 if (value != null && typeof value === 'object') {
18325 for (const key in value) {
18326 const replacement = internalize(value, key, reviver);
18328 if (replacement === undefined) {
18331 value[key] = replacement;
18336 return reviver.call(holder, name, value);
18346 lexState = 'default';
18348 doubleQuote = false;
18352 c = peek(); // This code is unreachable.
18353 // if (!lexStates[lexState]) {
18354 // throw invalidLexState(lexState)
18357 const token = lexStates[lexState]();
18366 if (source$1[pos]) {
18367 return String.fromCodePoint(source$1.codePointAt(pos));
18371 function read$4() {
18378 column += c.length;
18390 const lexStates = {
18408 lexState = 'comment';
18413 return newToken('eof');
18416 if (util$6.isSpaceSeparator(c)) {
18419 } // This code is unreachable.
18420 // if (!lexStates[parseState]) {
18421 // throw invalidLexState(parseState)
18425 return lexStates[parseState]();
18432 lexState = 'multiLineComment';
18437 lexState = 'singleLineComment';
18441 throw invalidChar(read$4());
18444 multiLineComment() {
18448 lexState = 'multiLineCommentAsterisk';
18452 throw invalidChar(read$4());
18458 multiLineCommentAsterisk() {
18466 lexState = 'default';
18470 throw invalidChar(read$4());
18474 lexState = 'multiLineComment';
18477 singleLineComment() {
18484 lexState = 'default';
18489 return newToken('eof');
18499 return newToken('punctuator', read$4());
18504 return newToken('null', null);
18509 return newToken('boolean', true);
18514 return newToken('boolean', false);
18518 if (read$4() === '-') {
18526 buffer$2 = read$4();
18527 lexState = 'decimalPointLeading';
18531 buffer$2 = read$4();
18544 buffer$2 = read$4();
18545 lexState = 'decimalInteger';
18550 literal$1('nfinity');
18551 return newToken('numeric', Infinity);
18556 return newToken('numeric', NaN);
18560 doubleQuote = read$4() === '"';
18562 lexState = 'string';
18566 throw invalidChar(read$4());
18569 identifierNameStartEscape() {
18571 throw invalidChar(read$4());
18575 const u = unicodeEscape();
18583 if (!util$6.isIdStartChar(u)) {
18584 throw invalidIdentifier();
18591 lexState = 'identifierName';
18600 buffer$2 += read$4();
18605 lexState = 'identifierNameEscape';
18609 if (util$6.isIdContinueChar(c)) {
18610 buffer$2 += read$4();
18614 return newToken('identifier', buffer$2);
18617 identifierNameEscape() {
18619 throw invalidChar(read$4());
18623 const u = unicodeEscape();
18633 if (!util$6.isIdContinueChar(u)) {
18634 throw invalidIdentifier();
18641 lexState = 'identifierName';
18647 buffer$2 = read$4();
18648 lexState = 'decimalPointLeading';
18652 buffer$2 = read$4();
18665 buffer$2 = read$4();
18666 lexState = 'decimalInteger';
18671 literal$1('nfinity');
18672 return newToken('numeric', sign * Infinity);
18677 return newToken('numeric', NaN);
18680 throw invalidChar(read$4());
18686 buffer$2 += read$4();
18687 lexState = 'decimalPoint';
18692 buffer$2 += read$4();
18693 lexState = 'decimalExponent';
18698 buffer$2 += read$4();
18699 lexState = 'hexadecimal';
18703 return newToken('numeric', sign * 0);
18709 buffer$2 += read$4();
18710 lexState = 'decimalPoint';
18715 buffer$2 += read$4();
18716 lexState = 'decimalExponent';
18720 if (util$6.isDigit(c)) {
18721 buffer$2 += read$4();
18725 return newToken('numeric', sign * Number(buffer$2));
18728 decimalPointLeading() {
18729 if (util$6.isDigit(c)) {
18730 buffer$2 += read$4();
18731 lexState = 'decimalFraction';
18735 throw invalidChar(read$4());
18742 buffer$2 += read$4();
18743 lexState = 'decimalExponent';
18747 if (util$6.isDigit(c)) {
18748 buffer$2 += read$4();
18749 lexState = 'decimalFraction';
18753 return newToken('numeric', sign * Number(buffer$2));
18756 decimalFraction() {
18760 buffer$2 += read$4();
18761 lexState = 'decimalExponent';
18765 if (util$6.isDigit(c)) {
18766 buffer$2 += read$4();
18770 return newToken('numeric', sign * Number(buffer$2));
18773 decimalExponent() {
18777 buffer$2 += read$4();
18778 lexState = 'decimalExponentSign';
18782 if (util$6.isDigit(c)) {
18783 buffer$2 += read$4();
18784 lexState = 'decimalExponentInteger';
18788 throw invalidChar(read$4());
18791 decimalExponentSign() {
18792 if (util$6.isDigit(c)) {
18793 buffer$2 += read$4();
18794 lexState = 'decimalExponentInteger';
18798 throw invalidChar(read$4());
18801 decimalExponentInteger() {
18802 if (util$6.isDigit(c)) {
18803 buffer$2 += read$4();
18807 return newToken('numeric', sign * Number(buffer$2));
18811 if (util$6.isHexDigit(c)) {
18812 buffer$2 += read$4();
18813 lexState = 'hexadecimalInteger';
18817 throw invalidChar(read$4());
18820 hexadecimalInteger() {
18821 if (util$6.isHexDigit(c)) {
18822 buffer$2 += read$4();
18826 return newToken('numeric', sign * Number(buffer$2));
18833 buffer$2 += escape$1();
18839 return newToken('string', buffer$2);
18842 buffer$2 += read$4();
18846 if (!doubleQuote) {
18848 return newToken('string', buffer$2);
18851 buffer$2 += read$4();
18856 throw invalidChar(read$4());
18864 throw invalidChar(read$4());
18867 buffer$2 += read$4();
18874 return newToken('punctuator', read$4());
18875 // This code is unreachable since the default lexState handles eof.
18877 // return newToken('eof')
18880 lexState = 'value';
18883 beforePropertyName() {
18887 buffer$2 = read$4();
18888 lexState = 'identifierName';
18893 lexState = 'identifierNameStartEscape';
18897 return newToken('punctuator', read$4());
18901 doubleQuote = read$4() === '"';
18902 lexState = 'string';
18906 if (util$6.isIdStartChar(c)) {
18907 buffer$2 += read$4();
18908 lexState = 'identifierName';
18912 throw invalidChar(read$4());
18915 afterPropertyName() {
18917 return newToken('punctuator', read$4());
18920 throw invalidChar(read$4());
18923 beforePropertyValue() {
18924 lexState = 'value';
18927 afterPropertyValue() {
18931 return newToken('punctuator', read$4());
18934 throw invalidChar(read$4());
18937 beforeArrayValue() {
18939 return newToken('punctuator', read$4());
18942 lexState = 'value';
18945 afterArrayValue() {
18949 return newToken('punctuator', read$4());
18952 throw invalidChar(read$4());
18956 // This code is unreachable since it's handled by the default lexState.
18957 // if (c === undefined) {
18959 // return newToken('eof')
18961 throw invalidChar(read$4());
18966 function newToken(type, value) {
18975 function literal$1(s) {
18976 for (const c of s) {
18980 throw invalidChar(read$4());
18987 function escape$1() {
19018 if (util$6.isDigit(peek())) {
19019 throw invalidChar(read$4());
19026 return hexEscape();
19030 return unicodeEscape();
19041 if (peek() === '\n') {
19056 throw invalidChar(read$4());
19059 throw invalidChar(read$4());
19065 function hexEscape() {
19069 if (!util$6.isHexDigit(c)) {
19070 throw invalidChar(read$4());
19073 buffer += read$4();
19076 if (!util$6.isHexDigit(c)) {
19077 throw invalidChar(read$4());
19080 buffer += read$4();
19081 return String.fromCodePoint(parseInt(buffer, 16));
19084 function unicodeEscape() {
19088 while (count-- > 0) {
19091 if (!util$6.isHexDigit(c)) {
19092 throw invalidChar(read$4());
19095 buffer += read$4();
19098 return String.fromCodePoint(parseInt(buffer, 16));
19101 const parseStates = {
19103 if (token.type === 'eof') {
19104 throw invalidEOF();
19110 beforePropertyName() {
19111 switch (token.type) {
19115 parseState = 'afterPropertyName';
19119 // This code is unreachable since it's handled by the lexState.
19120 // if (token.value !== '}') {
19121 // throw invalidToken()
19127 throw invalidEOF();
19128 } // This code is unreachable since it's handled by the lexState.
19129 // throw invalidToken()
19133 afterPropertyName() {
19134 // This code is unreachable since it's handled by the lexState.
19135 // if (token.type !== 'punctuator' || token.value !== ':') {
19136 // throw invalidToken()
19138 if (token.type === 'eof') {
19139 throw invalidEOF();
19142 parseState = 'beforePropertyValue';
19145 beforePropertyValue() {
19146 if (token.type === 'eof') {
19147 throw invalidEOF();
19153 beforeArrayValue() {
19154 if (token.type === 'eof') {
19155 throw invalidEOF();
19158 if (token.type === 'punctuator' && token.value === ']') {
19166 afterPropertyValue() {
19167 // This code is unreachable since it's handled by the lexState.
19168 // if (token.type !== 'punctuator') {
19169 // throw invalidToken()
19171 if (token.type === 'eof') {
19172 throw invalidEOF();
19175 switch (token.value) {
19177 parseState = 'beforePropertyName';
19182 } // This code is unreachable since it's handled by the lexState.
19183 // throw invalidToken()
19187 afterArrayValue() {
19188 // This code is unreachable since it's handled by the lexState.
19189 // if (token.type !== 'punctuator') {
19190 // throw invalidToken()
19192 if (token.type === 'eof') {
19193 throw invalidEOF();
19196 switch (token.value) {
19198 parseState = 'beforeArrayValue';
19203 } // This code is unreachable since it's handled by the lexState.
19204 // throw invalidToken()
19208 end() {// This code is unreachable since it's handled by the lexState.
19209 // if (token.type !== 'eof') {
19210 // throw invalidToken()
19216 function push$1() {
19219 switch (token.type) {
19221 switch (token.value) {
19237 value = token.value;
19239 // This code is unreachable.
19241 // throw invalidToken()
19244 if (root$9 === undefined) {
19247 const parent = stack[stack.length - 1];
19249 if (Array.isArray(parent)) {
19250 parent.push(value);
19252 parent[key] = value;
19256 if (value !== null && typeof value === 'object') {
19259 if (Array.isArray(value)) {
19260 parseState = 'beforeArrayValue';
19262 parseState = 'beforePropertyName';
19265 const current = stack[stack.length - 1];
19267 if (current == null) {
19268 parseState = 'end';
19269 } else if (Array.isArray(current)) {
19270 parseState = 'afterArrayValue';
19272 parseState = 'afterPropertyValue';
19279 const current = stack[stack.length - 1];
19281 if (current == null) {
19282 parseState = 'end';
19283 } else if (Array.isArray(current)) {
19284 parseState = 'afterArrayValue';
19286 parseState = 'afterPropertyValue';
19288 } // This code is unreachable.
19289 // function invalidParseState () {
19290 // return new Error(`JSON5: invalid parse state '${parseState}'`)
19292 // This code is unreachable.
19293 // function invalidLexState (state) {
19294 // return new Error(`JSON5: invalid lex state '${state}'`)
19298 function invalidChar(c) {
19299 if (c === undefined) {
19300 return syntaxError$2(`JSON5: invalid end of input at ${line$z}:${column}`);
19303 return syntaxError$2(`JSON5: invalid character '${formatChar(c)}' at ${line$z}:${column}`);
19306 function invalidEOF() {
19307 return syntaxError$2(`JSON5: invalid end of input at ${line$z}:${column}`);
19308 } // This code is unreachable.
19309 // function invalidToken () {
19310 // if (token.type === 'eof') {
19311 // return syntaxError(`JSON5: invalid end of input at ${line}:${column}`)
19313 // const c = String.fromCodePoint(token.value.codePointAt(0))
19314 // return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`)
19318 function invalidIdentifier() {
19320 return syntaxError$2(`JSON5: invalid identifier character at ${line$z}:${column}`);
19323 function separatorChar(c) {
19324 console.warn(`JSON5: '${formatChar(c)}' in strings is not valid ECMAScript; consider escaping`);
19327 function formatChar(c) {
19328 const replacements = {
19339 '\u2028': '\\u2028',
19340 '\u2029': '\\u2029'
19343 if (replacements[c]) {
19344 return replacements[c];
19348 const hexString = c.charCodeAt(0).toString(16);
19349 return '\\x' + ('00' + hexString).substring(hexString.length);
19355 function syntaxError$2(message) {
19356 const err = new SyntaxError(message);
19357 err.lineNumber = line$z;
19358 err.columnNumber = column;
19362 var stringify$6 = function stringify(value, replacer, space) {
19370 if (replacer != null && typeof replacer === 'object' && !Array.isArray(replacer)) {
19371 space = replacer.space;
19372 quote = replacer.quote;
19373 replacer = replacer.replacer;
19376 if (typeof replacer === 'function') {
19377 replacerFunc = replacer;
19378 } else if (Array.isArray(replacer)) {
19381 for (const v of replacer) {
19384 if (typeof v === 'string') {
19386 } else if (typeof v === 'number' || v instanceof String || v instanceof Number) {
19390 if (item !== undefined && propertyList.indexOf(item) < 0) {
19391 propertyList.push(item);
19396 if (space instanceof Number) {
19397 space = Number(space);
19398 } else if (space instanceof String) {
19399 space = String(space);
19402 if (typeof space === 'number') {
19404 space = Math.min(10, Math.floor(space));
19405 gap = ' '.substr(0, space);
19407 } else if (typeof space === 'string') {
19408 gap = space.substr(0, 10);
19411 return serializeProperty('', {
19415 function serializeProperty(key, holder) {
19416 let value = holder[key];
19418 if (value != null) {
19419 if (typeof value.toJSON5 === 'function') {
19420 value = value.toJSON5(key);
19421 } else if (typeof value.toJSON === 'function') {
19422 value = value.toJSON(key);
19426 if (replacerFunc) {
19427 value = replacerFunc.call(holder, key, value);
19430 if (value instanceof Number) {
19431 value = Number(value);
19432 } else if (value instanceof String) {
19433 value = String(value);
19434 } else if (value instanceof Boolean) {
19435 value = value.valueOf();
19449 if (typeof value === 'string') {
19450 return quoteString(value);
19453 if (typeof value === 'number') {
19454 return String(value);
19457 if (typeof value === 'object') {
19458 return Array.isArray(value) ? serializeArray(value) : serializeObject(value);
19464 function quoteString(value) {
19469 const replacements = {
19480 '\u2028': '\\u2028',
19481 '\u2029': '\\u2029'
19485 for (let i = 0; i < value.length; i++) {
19486 const c = value[i];
19496 if (util$6.isDigit(value[i + 1])) {
19497 product += '\\x00';
19503 if (replacements[c]) {
19504 product += replacements[c];
19509 let hexString = c.charCodeAt(0).toString(16);
19510 product += '\\x' + ('00' + hexString).substring(hexString.length);
19517 const quoteChar = quote || Object.keys(quotes).reduce((a, b) => quotes[a] < quotes[b] ? a : b);
19518 product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar]);
19519 return quoteChar + product + quoteChar;
19522 function serializeObject(value) {
19523 if (stack.indexOf(value) >= 0) {
19524 throw TypeError('Converting circular structure to JSON5');
19528 let stepback = indent;
19529 indent = indent + gap;
19530 let keys = propertyList || Object.keys(value);
19533 for (const key of keys) {
19534 const propertyString = serializeProperty(key, value);
19536 if (propertyString !== undefined) {
19537 let member = serializeKey(key) + ':';
19543 member += propertyString;
19544 partial.push(member);
19550 if (partial.length === 0) {
19556 properties = partial.join(',');
19557 final = '{' + properties + '}';
19559 let separator = ',\n' + indent;
19560 properties = partial.join(separator);
19561 final = '{\n' + indent + properties + ',\n' + stepback + '}';
19570 function serializeKey(key) {
19571 if (key.length === 0) {
19572 return quoteString(key);
19575 const firstChar = String.fromCodePoint(key.codePointAt(0));
19577 if (!util$6.isIdStartChar(firstChar)) {
19578 return quoteString(key);
19581 for (let i = firstChar.length; i < key.length; i++) {
19582 if (!util$6.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
19583 return quoteString(key);
19590 function serializeArray(value) {
19591 if (stack.indexOf(value) >= 0) {
19592 throw TypeError('Converting circular structure to JSON5');
19596 let stepback = indent;
19597 indent = indent + gap;
19600 for (let i = 0; i < value.length; i++) {
19601 const propertyString = serializeProperty(String(i), value);
19602 partial.push(propertyString !== undefined ? propertyString : 'null');
19607 if (partial.length === 0) {
19611 let properties = partial.join(',');
19612 final = '[' + properties + ']';
19614 let separator = ',\n' + indent;
19615 let properties = partial.join(separator);
19616 final = '[\n' + indent + properties + ',\n' + stepback + ']';
19628 stringify: stringify$6
19632 var dist = /*#__PURE__*/Object.freeze({
19637 var require$$0$4 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(dist);
19643 var loadJson5$1 = function (filePath, content) {
19645 return parse$9(content);
19647 error.message = `JSON5 Error in ${filePath}:\n${error.message}`;
19652 var caller$2 = function () {
19653 // see https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
19654 var origPrepareStackTrace = Error.prepareStackTrace;
19656 Error.prepareStackTrace = function (_, stack) {
19660 var stack = new Error().stack;
19661 Error.prepareStackTrace = origPrepareStackTrace;
19662 return stack[2].getFileName();
19665 var pathParse = {exports: {}};
19667 var isWindows = process.platform === 'win32'; // Regex to split a windows path into into [dir, root, basename, name, ext]
19669 var splitWindowsRe = /^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/;
19672 function win32SplitPath(filename) {
19673 return splitWindowsRe.exec(filename).slice(1);
19676 win32.parse = function (pathString) {
19677 if (typeof pathString !== 'string') {
19678 throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
19681 var allParts = win32SplitPath(pathString);
19683 if (!allParts || allParts.length !== 5) {
19684 throw new TypeError("Invalid path '" + pathString + "'");
19689 dir: allParts[0] === allParts[1] ? allParts[0] : allParts[0].slice(0, -1),
19694 }; // Split a filename into [dir, root, basename, name, ext], unix version
19695 // 'root' is just a slash, or nothing.
19698 var splitPathRe = /^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/;
19701 function posixSplitPath(filename) {
19702 return splitPathRe.exec(filename).slice(1);
19705 posix.parse = function (pathString) {
19706 if (typeof pathString !== 'string') {
19707 throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
19710 var allParts = posixSplitPath(pathString);
19712 if (!allParts || allParts.length !== 5) {
19713 throw new TypeError("Invalid path '" + pathString + "'");
19718 dir: allParts[0].slice(0, -1),
19725 if (isWindows) pathParse.exports = win32.parse;else
19727 pathParse.exports = posix.parse;
19728 pathParse.exports.posix = posix.parse;
19729 pathParse.exports.win32 = win32.parse;
19731 var path$n = require$$0__default$2["default"];
19732 var parse$8 = path$n.parse || pathParse.exports;
19734 var getNodeModulesDirs = function getNodeModulesDirs(absoluteStart, modules) {
19737 if (/^([A-Za-z]:)/.test(absoluteStart)) {
19739 } else if (/^\\\\/.test(absoluteStart)) {
19743 var paths = [absoluteStart];
19744 var parsed = parse$8(absoluteStart);
19746 while (parsed.dir !== paths[paths.length - 1]) {
19747 paths.push(parsed.dir);
19748 parsed = parse$8(parsed.dir);
19751 return paths.reduce(function (dirs, aPath) {
19752 return dirs.concat(modules.map(function (moduleDir) {
19753 return path$n.resolve(prefix, aPath, moduleDir);
19758 var nodeModulesPaths$2 = function nodeModulesPaths(start, opts, request) {
19759 var modules = opts && opts.moduleDirectory ? [].concat(opts.moduleDirectory) : ['node_modules'];
19761 if (opts && typeof opts.paths === 'function') {
19762 return opts.paths(request, start, function () {
19763 return getNodeModulesDirs(start, modules);
19767 var dirs = getNodeModulesDirs(start, modules);
19768 return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
19771 var normalizeOptions$3 = function (x, opts) {
19773 * This file is purposefully a passthrough. It's expected that third-party
19774 * environments will override it at runtime in order to inject special logic
19775 * into `resolve` (by manipulating the options). One such example is the PnP
19776 * code path in Yarn.
19781 /* eslint no-invalid-this: 1 */
19784 var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
19785 var slice$1 = Array.prototype.slice;
19786 var toStr = Object.prototype.toString;
19787 var funcType = '[object Function]';
19789 var implementation$1 = function bind(that) {
19792 if (typeof target !== 'function' || toStr.call(target) !== funcType) {
19793 throw new TypeError(ERROR_MESSAGE + target);
19796 var args = slice$1.call(arguments, 1);
19799 var binder = function () {
19800 if (this instanceof bound) {
19801 var result = target.apply(this, args.concat(slice$1.call(arguments)));
19803 if (Object(result) === result) {
19809 return target.apply(that, args.concat(slice$1.call(arguments)));
19813 var boundLength = Math.max(0, target.length - args.length);
19814 var boundArgs = [];
19816 for (var i = 0; i < boundLength; i++) {
19817 boundArgs.push('$' + i);
19820 bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
19822 if (target.prototype) {
19823 var Empty = function Empty() {};
19825 Empty.prototype = target.prototype;
19826 bound.prototype = new Empty();
19827 Empty.prototype = null;
19833 var implementation = implementation$1;
19834 var functionBind = Function.prototype.bind || implementation;
19836 var bind = functionBind;
19837 var src$2 = bind.call(Function.call, Object.prototype.hasOwnProperty);
19839 var assert$4 = true;
19840 var async_hooks$1 = ">= 8";
19841 var buffer_ieee754$1 = "< 0.9.7";
19842 var buffer$1 = true;
19843 var child_process$1 = true;
19844 var cluster$1 = true;
19845 var console$2 = true;
19846 var constants$6 = true;
19847 var crypto$1 = true;
19848 var _debug_agent$1 = ">= 1 && < 8";
19849 var _debugger$1 = "< 8";
19850 var dgram$1 = true;
19851 var diagnostics_channel$1 = [
19852 ">= 14.17 && < 15",
19856 var domain$1 = ">= 0.7.12";
19857 var events$1 = true;
19858 var freelist$1 = "< 6";
19860 var _http_agent$1 = ">= 0.11.1";
19861 var _http_client$1 = ">= 0.11.1";
19862 var _http_common$1 = ">= 0.11.1";
19863 var _http_incoming$1 = ">= 0.11.1";
19864 var _http_outgoing$1 = ">= 0.11.1";
19865 var _http_server$1 = ">= 0.11.1";
19867 var http2$1 = ">= 8.8";
19868 var https$1 = true;
19869 var inspector$1 = ">= 8";
19870 var _linklist$1 = "< 8";
19871 var module$3 = true;
19875 var perf_hooks$1 = ">= 8.5";
19876 var process$2 = ">= 1";
19877 var punycode$1 = true;
19878 var querystring$1 = true;
19879 var readline$1 = true;
19881 var smalloc$1 = ">= 0.11.5 && < 3";
19882 var _stream_duplex$1 = ">= 0.9.4";
19883 var _stream_transform$1 = ">= 0.9.4";
19884 var _stream_wrap$1 = ">= 1.4.1";
19885 var _stream_passthrough$1 = ">= 0.9.4";
19886 var _stream_readable$1 = ">= 0.9.4";
19887 var _stream_writable$1 = ">= 0.9.4";
19888 var stream$6 = true;
19889 var string_decoder$1 = true;
19894 var timers$1 = true;
19895 var _tls_common$1 = ">= 0.11.13";
19896 var _tls_legacy$1 = ">= 0.11.3 && < 10";
19897 var _tls_wrap$1 = ">= 0.11.3";
19899 var trace_events$1 = ">= 10";
19905 var wasi$1 = ">= 13.4 && < 13.5";
19906 var worker_threads$1 = ">= 11.7";
19908 var require$$1$2 = {
19911 ">= 14.18 && < 15",
19914 "assert/strict": ">= 15",
19915 "node:assert/strict": ">= 16",
19916 async_hooks: async_hooks$1,
19917 "node:async_hooks": [
19918 ">= 14.18 && < 15",
19921 buffer_ieee754: buffer_ieee754$1,
19924 ">= 14.18 && < 15",
19927 child_process: child_process$1,
19928 "node:child_process": [
19929 ">= 14.18 && < 15",
19932 cluster: cluster$1,
19934 ">= 14.18 && < 15",
19937 console: console$2,
19939 ">= 14.18 && < 15",
19942 constants: constants$6,
19943 "node:constants": [
19944 ">= 14.18 && < 15",
19949 ">= 14.18 && < 15",
19952 _debug_agent: _debug_agent$1,
19953 _debugger: _debugger$1,
19956 ">= 14.18 && < 15",
19959 diagnostics_channel: diagnostics_channel$1,
19960 "node:diagnostics_channel": [
19961 ">= 14.18 && < 15",
19966 ">= 14.18 && < 15",
19969 "dns/promises": ">= 15",
19970 "node:dns/promises": ">= 16",
19973 ">= 14.18 && < 15",
19978 ">= 14.18 && < 15",
19981 freelist: freelist$1,
19984 ">= 14.18 && < 15",
19991 "node:fs/promises": [
19992 ">= 14.18 && < 15",
19995 _http_agent: _http_agent$1,
19996 "node:_http_agent": [
19997 ">= 14.18 && < 15",
20000 _http_client: _http_client$1,
20001 "node:_http_client": [
20002 ">= 14.18 && < 15",
20005 _http_common: _http_common$1,
20006 "node:_http_common": [
20007 ">= 14.18 && < 15",
20010 _http_incoming: _http_incoming$1,
20011 "node:_http_incoming": [
20012 ">= 14.18 && < 15",
20015 _http_outgoing: _http_outgoing$1,
20016 "node:_http_outgoing": [
20017 ">= 14.18 && < 15",
20020 _http_server: _http_server$1,
20021 "node:_http_server": [
20022 ">= 14.18 && < 15",
20027 ">= 14.18 && < 15",
20032 ">= 14.18 && < 15",
20037 ">= 14.18 && < 15",
20040 inspector: inspector$1,
20041 "node:inspector": [
20042 ">= 14.18 && < 15",
20045 _linklist: _linklist$1,
20048 ">= 14.18 && < 15",
20053 ">= 14.18 && < 15",
20056 "node-inspect/lib/_inspect": ">= 7.6 && < 12",
20057 "node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12",
20058 "node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12",
20061 ">= 14.18 && < 15",
20066 ">= 14.18 && < 15",
20069 "path/posix": ">= 15.3",
20070 "node:path/posix": ">= 16",
20071 "path/win32": ">= 15.3",
20072 "node:path/win32": ">= 16",
20073 perf_hooks: perf_hooks$1,
20074 "node:perf_hooks": [
20075 ">= 14.18 && < 15",
20078 process: process$2,
20080 ">= 14.18 && < 15",
20083 punycode: punycode$1,
20085 ">= 14.18 && < 15",
20088 querystring: querystring$1,
20089 "node:querystring": [
20090 ">= 14.18 && < 15",
20093 readline: readline$1,
20095 ">= 14.18 && < 15",
20098 "readline/promises": ">= 17",
20099 "node:readline/promises": ">= 17",
20102 ">= 14.18 && < 15",
20105 smalloc: smalloc$1,
20106 _stream_duplex: _stream_duplex$1,
20107 "node:_stream_duplex": [
20108 ">= 14.18 && < 15",
20111 _stream_transform: _stream_transform$1,
20112 "node:_stream_transform": [
20113 ">= 14.18 && < 15",
20116 _stream_wrap: _stream_wrap$1,
20117 "node:_stream_wrap": [
20118 ">= 14.18 && < 15",
20121 _stream_passthrough: _stream_passthrough$1,
20122 "node:_stream_passthrough": [
20123 ">= 14.18 && < 15",
20126 _stream_readable: _stream_readable$1,
20127 "node:_stream_readable": [
20128 ">= 14.18 && < 15",
20131 _stream_writable: _stream_writable$1,
20132 "node:_stream_writable": [
20133 ">= 14.18 && < 15",
20138 ">= 14.18 && < 15",
20141 "stream/consumers": ">= 16.7",
20142 "node:stream/consumers": ">= 16.7",
20143 "stream/promises": ">= 15",
20144 "node:stream/promises": ">= 16",
20145 "stream/web": ">= 16.5",
20146 "node:stream/web": ">= 16.5",
20147 string_decoder: string_decoder$1,
20148 "node:string_decoder": [
20149 ">= 14.18 && < 15",
20154 ">= 14.18 && < 15",
20159 ">= 14.18 && < 15",
20162 "timers/promises": ">= 15",
20163 "node:timers/promises": ">= 16",
20164 _tls_common: _tls_common$1,
20165 "node:_tls_common": [
20166 ">= 14.18 && < 15",
20169 _tls_legacy: _tls_legacy$1,
20170 _tls_wrap: _tls_wrap$1,
20171 "node:_tls_wrap": [
20172 ">= 14.18 && < 15",
20177 ">= 14.18 && < 15",
20180 trace_events: trace_events$1,
20181 "node:trace_events": [
20182 ">= 14.18 && < 15",
20187 ">= 14.18 && < 15",
20192 ">= 14.18 && < 15",
20197 ">= 14.18 && < 15",
20200 "util/types": ">= 15.3",
20201 "node:util/types": ">= 16",
20202 "v8/tools/arguments": ">= 10 && < 12",
20203 "v8/tools/codemap": [
20207 "v8/tools/consarray": [
20211 "v8/tools/csvparser": [
20215 "v8/tools/logreader": [
20219 "v8/tools/profile_view": [
20223 "v8/tools/splaytree": [
20229 ">= 14.18 && < 15",
20234 ">= 14.18 && < 15",
20238 worker_threads: worker_threads$1,
20239 "node:worker_threads": [
20240 ">= 14.18 && < 15",
20245 ">= 14.18 && < 15",
20252 function specifierIncluded$1(current, specifier) {
20253 var nodeParts = current.split('.');
20254 var parts = specifier.split(' ');
20255 var op = parts.length > 1 ? parts[0] : '=';
20256 var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
20258 for (var i = 0; i < 3; ++i) {
20259 var cur = parseInt(nodeParts[i] || 0, 10);
20260 var ver = parseInt(versionParts[i] || 0, 10);
20263 continue; // eslint-disable-line no-restricted-syntax, no-continue
20277 return op === '>=';
20280 function matchesRange$1(current, range) {
20281 var specifiers = range.split(/ ?&& ?/);
20283 if (specifiers.length === 0) {
20287 for (var i = 0; i < specifiers.length; ++i) {
20288 if (!specifierIncluded$1(current, specifiers[i])) {
20296 function versionIncluded$1(nodeVersion, specifierValue) {
20297 if (typeof specifierValue === 'boolean') {
20298 return specifierValue;
20301 var current = typeof nodeVersion === 'undefined' ? process.versions && process.versions.node : nodeVersion;
20303 if (typeof current !== 'string') {
20304 throw new TypeError(typeof nodeVersion === 'undefined' ? 'Unable to determine current node version' : 'If provided, a valid node version is required');
20307 if (specifierValue && typeof specifierValue === 'object') {
20308 for (var i = 0; i < specifierValue.length; ++i) {
20309 if (matchesRange$1(current, specifierValue[i])) {
20317 return matchesRange$1(current, specifierValue);
20320 var data$2 = require$$1$2;
20322 var isCoreModule$1 = function isCore(x, nodeVersion) {
20323 return has(data$2, x) && versionIncluded$1(nodeVersion, data$2[x]);
20326 var fs$i = require$$0__default["default"];
20327 var path$l = require$$0__default$2["default"];
20328 var caller$1 = caller$2;
20329 var nodeModulesPaths$1 = nodeModulesPaths$2;
20330 var normalizeOptions$2 = normalizeOptions$3;
20331 var isCore$2 = isCoreModule$1;
20332 var realpathFS$1 = fs$i.realpath && typeof fs$i.realpath.native === 'function' ? fs$i.realpath.native : fs$i.realpath;
20334 var defaultIsFile$1 = function isFile(file, cb) {
20335 fs$i.stat(file, function (err, stat) {
20337 return cb(null, stat.isFile() || stat.isFIFO());
20340 if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
20345 var defaultIsDir$1 = function isDirectory(dir, cb) {
20346 fs$i.stat(dir, function (err, stat) {
20348 return cb(null, stat.isDirectory());
20351 if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
20356 var defaultRealpath = function realpath(x, cb) {
20357 realpathFS$1(x, function (realpathErr, realPath) {
20358 if (realpathErr && realpathErr.code !== 'ENOENT') cb(realpathErr);else cb(null, realpathErr ? x : realPath);
20362 var maybeRealpath = function maybeRealpath(realpath, x, opts, cb) {
20363 if (opts && opts.preserveSymlinks === false) {
20370 var defaultReadPackage = function defaultReadPackage(readFile, pkgfile, cb) {
20371 readFile(pkgfile, function (readFileErr, body) {
20372 if (readFileErr) cb(readFileErr);else {
20374 var pkg = JSON.parse(body);
20376 } catch (jsonErr) {
20383 var getPackageCandidates$1 = function getPackageCandidates(x, start, opts) {
20384 var dirs = nodeModulesPaths$1(start, opts, x);
20386 for (var i = 0; i < dirs.length; i++) {
20387 dirs[i] = path$l.join(dirs[i], x);
20393 var async$8 = function resolve(x, options, callback) {
20395 var opts = options;
20397 if (typeof options === 'function') {
20402 if (typeof x !== 'string') {
20403 var err = new TypeError('Path must be a string.');
20404 return process.nextTick(function () {
20409 opts = normalizeOptions$2(x, opts);
20410 var isFile = opts.isFile || defaultIsFile$1;
20411 var isDirectory = opts.isDirectory || defaultIsDir$1;
20412 var readFile = opts.readFile || fs$i.readFile;
20413 var realpath = opts.realpath || defaultRealpath;
20414 var readPackage = opts.readPackage || defaultReadPackage;
20416 if (opts.readFile && opts.readPackage) {
20417 var conflictErr = new TypeError('`readFile` and `readPackage` are mutually exclusive.');
20418 return process.nextTick(function () {
20423 var packageIterator = opts.packageIterator;
20424 var extensions = opts.extensions || ['.js'];
20425 var includeCoreModules = opts.includeCoreModules !== false;
20426 var basedir = opts.basedir || path$l.dirname(caller$1());
20427 var parent = opts.filename || basedir;
20428 opts.paths = opts.paths || []; // ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
20430 var absoluteStart = path$l.resolve(basedir);
20431 maybeRealpath(realpath, absoluteStart, opts, function (err, realStart) {
20432 if (err) cb(err);else init(realStart);
20436 function init(basedir) {
20437 if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
20438 res = path$l.resolve(basedir, x);
20439 if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
20441 if (/\/$/.test(x) && res === basedir) {
20442 loadAsDirectory(res, opts.package, onfile);
20443 } else loadAsFile(res, opts.package, onfile);
20444 } else if (includeCoreModules && isCore$2(x)) {
20445 return cb(null, x);
20446 } else loadNodeModules(x, basedir, function (err, n, pkg) {
20447 if (err) cb(err);else if (n) {
20448 return maybeRealpath(realpath, n, opts, function (err, realN) {
20452 cb(null, realN, pkg);
20456 var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
20457 moduleError.code = 'MODULE_NOT_FOUND';
20463 function onfile(err, m, pkg) {
20464 if (err) cb(err);else if (m) cb(null, m, pkg);else loadAsDirectory(res, function (err, d, pkg) {
20465 if (err) cb(err);else if (d) {
20466 maybeRealpath(realpath, d, opts, function (err, realD) {
20470 cb(null, realD, pkg);
20474 var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
20475 moduleError.code = 'MODULE_NOT_FOUND';
20481 function loadAsFile(x, thePackage, callback) {
20482 var loadAsFilePackage = thePackage;
20485 if (typeof loadAsFilePackage === 'function') {
20486 cb = loadAsFilePackage;
20487 loadAsFilePackage = undefined;
20490 var exts = [''].concat(extensions);
20491 load(exts, x, loadAsFilePackage);
20493 function load(exts, x, loadPackage) {
20494 if (exts.length === 0) return cb(null, undefined, loadPackage);
20495 var file = x + exts[0];
20496 var pkg = loadPackage;
20497 if (pkg) onpkg(null, pkg);else loadpkg(path$l.dirname(file), onpkg);
20499 function onpkg(err, pkg_, dir) {
20501 if (err) return cb(err);
20503 if (dir && pkg && opts.pathFilter) {
20504 var rfile = path$l.relative(dir, file);
20505 var rel = rfile.slice(0, rfile.length - exts[0].length);
20506 var r = opts.pathFilter(pkg, x, rel);
20507 if (r) return load([''].concat(extensions.slice()), path$l.resolve(dir, r), pkg);
20510 isFile(file, onex);
20513 function onex(err, ex) {
20514 if (err) return cb(err);
20515 if (ex) return cb(null, file, pkg);
20516 load(exts.slice(1), x, pkg);
20521 function loadpkg(dir, cb) {
20522 if (dir === '' || dir === '/') return cb(null);
20524 if (process.platform === 'win32' && /^\w:[/\\]*$/.test(dir)) {
20528 if (/[/\\]node_modules[/\\]*$/.test(dir)) return cb(null);
20529 maybeRealpath(realpath, dir, opts, function (unwrapErr, pkgdir) {
20530 if (unwrapErr) return loadpkg(path$l.dirname(dir), cb);
20531 var pkgfile = path$l.join(pkgdir, 'package.json');
20532 isFile(pkgfile, function (err, ex) {
20533 // on err, ex is false
20534 if (!ex) return loadpkg(path$l.dirname(dir), cb);
20535 readPackage(readFile, pkgfile, function (err, pkgParam) {
20537 var pkg = pkgParam;
20539 if (pkg && opts.packageFilter) {
20540 pkg = opts.packageFilter(pkg, pkgfile);
20543 cb(null, pkg, dir);
20549 function loadAsDirectory(x, loadAsDirectoryPackage, callback) {
20551 var fpkg = loadAsDirectoryPackage;
20553 if (typeof fpkg === 'function') {
20555 fpkg = opts.package;
20558 maybeRealpath(realpath, x, opts, function (unwrapErr, pkgdir) {
20559 if (unwrapErr) return cb(unwrapErr);
20560 var pkgfile = path$l.join(pkgdir, 'package.json');
20561 isFile(pkgfile, function (err, ex) {
20562 if (err) return cb(err);
20563 if (!ex) return loadAsFile(path$l.join(x, 'index'), fpkg, cb);
20564 readPackage(readFile, pkgfile, function (err, pkgParam) {
20565 if (err) return cb(err);
20566 var pkg = pkgParam;
20568 if (pkg && opts.packageFilter) {
20569 pkg = opts.packageFilter(pkg, pkgfile);
20572 if (pkg && pkg.main) {
20573 if (typeof pkg.main !== 'string') {
20574 var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
20575 mainError.code = 'INVALID_PACKAGE_MAIN';
20576 return cb(mainError);
20579 if (pkg.main === '.' || pkg.main === './') {
20580 pkg.main = 'index';
20583 loadAsFile(path$l.resolve(x, pkg.main), pkg, function (err, m, pkg) {
20584 if (err) return cb(err);
20585 if (m) return cb(null, m, pkg);
20586 if (!pkg) return loadAsFile(path$l.join(x, 'index'), pkg, cb);
20587 var dir = path$l.resolve(x, pkg.main);
20588 loadAsDirectory(dir, pkg, function (err, n, pkg) {
20589 if (err) return cb(err);
20590 if (n) return cb(null, n, pkg);
20591 loadAsFile(path$l.join(x, 'index'), pkg, cb);
20597 loadAsFile(path$l.join(x, '/index'), pkg, cb);
20603 function processDirs(cb, dirs) {
20604 if (dirs.length === 0) return cb(null, undefined);
20606 isDirectory(path$l.dirname(dir), isdir);
20608 function isdir(err, isdir) {
20609 if (err) return cb(err);
20610 if (!isdir) return processDirs(cb, dirs.slice(1));
20611 loadAsFile(dir, opts.package, onfile);
20614 function onfile(err, m, pkg) {
20615 if (err) return cb(err);
20616 if (m) return cb(null, m, pkg);
20617 loadAsDirectory(dir, opts.package, ondir);
20620 function ondir(err, n, pkg) {
20621 if (err) return cb(err);
20622 if (n) return cb(null, n, pkg);
20623 processDirs(cb, dirs.slice(1));
20627 function loadNodeModules(x, start, cb) {
20628 var thunk = function () {
20629 return getPackageCandidates$1(x, start, opts);
20632 processDirs(cb, packageIterator ? packageIterator(x, start, thunk, opts) : thunk());
20636 var assert$3 = true;
20637 var async_hooks = ">= 8";
20638 var buffer_ieee754 = "< 0.9.7";
20640 var child_process = true;
20641 var cluster = true;
20642 var console$1 = true;
20643 var constants$5 = true;
20645 var _debug_agent = ">= 1 && < 8";
20646 var _debugger = "< 8";
20648 var diagnostics_channel = ">= 15.1";
20650 var domain = ">= 0.7.12";
20652 var freelist = "< 6";
20654 var _http_agent = ">= 0.11.1";
20655 var _http_client = ">= 0.11.1";
20656 var _http_common = ">= 0.11.1";
20657 var _http_incoming = ">= 0.11.1";
20658 var _http_outgoing = ">= 0.11.1";
20659 var _http_server = ">= 0.11.1";
20661 var http2 = ">= 8.8";
20663 var inspector = ">= 8.0.0";
20664 var _linklist = "< 8";
20665 var module$2 = true;
20669 var perf_hooks = ">= 8.5";
20670 var process$1 = ">= 1";
20671 var punycode = true;
20672 var querystring = true;
20673 var readline = true;
20675 var smalloc = ">= 0.11.5 && < 3";
20676 var _stream_duplex = ">= 0.9.4";
20677 var _stream_transform = ">= 0.9.4";
20678 var _stream_wrap = ">= 1.4.1";
20679 var _stream_passthrough = ">= 0.9.4";
20680 var _stream_readable = ">= 0.9.4";
20681 var _stream_writable = ">= 0.9.4";
20682 var stream$5 = true;
20683 var string_decoder = true;
20689 var _tls_common = ">= 0.11.13";
20690 var _tls_legacy = ">= 0.11.3 && < 10";
20691 var _tls_wrap = ">= 0.11.3";
20693 var trace_events = ">= 10";
20699 var wasi = ">= 13.4 && < 13.5";
20700 var worker_threads = ">= 11.7";
20702 var require$$0$3 = {
20704 "assert/strict": ">= 15",
20705 async_hooks: async_hooks,
20706 buffer_ieee754: buffer_ieee754,
20708 child_process: child_process,
20710 console: console$1,
20711 constants: constants$5,
20713 _debug_agent: _debug_agent,
20714 _debugger: _debugger,
20716 diagnostics_channel: diagnostics_channel,
20718 "dns/promises": ">= 15",
20721 freelist: freelist,
20727 _http_agent: _http_agent,
20728 _http_client: _http_client,
20729 _http_common: _http_common,
20730 _http_incoming: _http_incoming,
20731 _http_outgoing: _http_outgoing,
20732 _http_server: _http_server,
20736 inspector: inspector,
20737 _linklist: _linklist,
20740 "node-inspect/lib/_inspect": ">= 7.6.0 && < 12",
20741 "node-inspect/lib/internal/inspect_client": ">= 7.6.0 && < 12",
20742 "node-inspect/lib/internal/inspect_repl": ">= 7.6.0 && < 12",
20745 "path/posix": ">= 15.3",
20746 "path/win32": ">= 15.3",
20747 perf_hooks: perf_hooks,
20748 process: process$1,
20749 punycode: punycode,
20750 querystring: querystring,
20751 readline: readline,
20754 _stream_duplex: _stream_duplex,
20755 _stream_transform: _stream_transform,
20756 _stream_wrap: _stream_wrap,
20757 _stream_passthrough: _stream_passthrough,
20758 _stream_readable: _stream_readable,
20759 _stream_writable: _stream_writable,
20761 "stream/promises": ">= 15",
20762 string_decoder: string_decoder,
20765 "timers/promises": ">= 15",
20766 _tls_common: _tls_common,
20767 _tls_legacy: _tls_legacy,
20768 _tls_wrap: _tls_wrap,
20770 trace_events: trace_events,
20774 "util/types": ">= 15.3",
20775 "v8/tools/arguments": ">= 10 && < 12",
20776 "v8/tools/codemap": [
20780 "v8/tools/consarray": [
20784 "v8/tools/csvparser": [
20788 "v8/tools/logreader": [
20792 "v8/tools/profile_view": [
20796 "v8/tools/splaytree": [
20803 worker_threads: worker_threads,
20807 var current = process.versions && process.versions.node && process.versions.node.split('.') || [];
20809 function specifierIncluded(specifier) {
20810 var parts = specifier.split(' ');
20811 var op = parts.length > 1 ? parts[0] : '=';
20812 var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
20814 for (var i = 0; i < 3; ++i) {
20815 var cur = parseInt(current[i] || 0, 10);
20816 var ver = parseInt(versionParts[i] || 0, 10);
20819 continue; // eslint-disable-line no-restricted-syntax, no-continue
20824 } else if (op === '>=') {
20831 return op === '>=';
20834 function matchesRange(range) {
20835 var specifiers = range.split(/ ?&& ?/);
20837 if (specifiers.length === 0) {
20841 for (var i = 0; i < specifiers.length; ++i) {
20842 if (!specifierIncluded(specifiers[i])) {
20850 function versionIncluded(specifierValue) {
20851 if (typeof specifierValue === 'boolean') {
20852 return specifierValue;
20855 if (specifierValue && typeof specifierValue === 'object') {
20856 for (var i = 0; i < specifierValue.length; ++i) {
20857 if (matchesRange(specifierValue[i])) {
20865 return matchesRange(specifierValue);
20868 var data$1 = require$$0$3;
20871 for (var mod in data$1) {
20872 // eslint-disable-line no-restricted-syntax
20873 if (Object.prototype.hasOwnProperty.call(data$1, mod)) {
20874 core$1[mod] = versionIncluded(data$1[mod]);
20878 var core_1 = core$1;
20880 var isCoreModule = isCoreModule$1;
20882 var isCore$1 = function isCore(x) {
20883 return isCoreModule(x);
20886 var isCore = isCoreModule$1;
20887 var fs$g = require$$0__default["default"];
20888 var path$j = require$$0__default$2["default"];
20889 var caller = caller$2;
20890 var nodeModulesPaths = nodeModulesPaths$2;
20891 var normalizeOptions$1 = normalizeOptions$3;
20892 var realpathFS = fs$g.realpathSync && typeof fs$g.realpathSync.native === 'function' ? fs$g.realpathSync.native : fs$g.realpathSync;
20894 var defaultIsFile = function isFile(file) {
20896 var stat = fs$g.statSync(file);
20898 if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
20902 return stat.isFile() || stat.isFIFO();
20905 var defaultIsDir = function isDirectory(dir) {
20907 var stat = fs$g.statSync(dir);
20909 if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
20913 return stat.isDirectory();
20916 var defaultRealpathSync = function realpathSync(x) {
20918 return realpathFS(x);
20919 } catch (realpathErr) {
20920 if (realpathErr.code !== 'ENOENT') {
20928 var maybeRealpathSync = function maybeRealpathSync(realpathSync, x, opts) {
20929 if (opts && opts.preserveSymlinks === false) {
20930 return realpathSync(x);
20936 var defaultReadPackageSync = function defaultReadPackageSync(readFileSync, pkgfile) {
20937 var body = readFileSync(pkgfile);
20940 var pkg = JSON.parse(body);
20942 } catch (jsonErr) {}
20945 var getPackageCandidates = function getPackageCandidates(x, start, opts) {
20946 var dirs = nodeModulesPaths(start, opts, x);
20948 for (var i = 0; i < dirs.length; i++) {
20949 dirs[i] = path$j.join(dirs[i], x);
20955 var sync$8 = function resolveSync(x, options) {
20956 if (typeof x !== 'string') {
20957 throw new TypeError('Path must be a string.');
20960 var opts = normalizeOptions$1(x, options);
20961 var isFile = opts.isFile || defaultIsFile;
20962 var readFileSync = opts.readFileSync || fs$g.readFileSync;
20963 var isDirectory = opts.isDirectory || defaultIsDir;
20964 var realpathSync = opts.realpathSync || defaultRealpathSync;
20965 var readPackageSync = opts.readPackageSync || defaultReadPackageSync;
20967 if (opts.readFileSync && opts.readPackageSync) {
20968 throw new TypeError('`readFileSync` and `readPackageSync` are mutually exclusive.');
20971 var packageIterator = opts.packageIterator;
20972 var extensions = opts.extensions || ['.js'];
20973 var includeCoreModules = opts.includeCoreModules !== false;
20974 var basedir = opts.basedir || path$j.dirname(caller());
20975 var parent = opts.filename || basedir;
20976 opts.paths = opts.paths || []; // ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
20978 var absoluteStart = maybeRealpathSync(realpathSync, path$j.resolve(basedir), opts);
20980 if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
20981 var res = path$j.resolve(absoluteStart, x);
20982 if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
20983 var m = loadAsFileSync(res) || loadAsDirectorySync(res);
20984 if (m) return maybeRealpathSync(realpathSync, m, opts);
20985 } else if (includeCoreModules && isCore(x)) {
20988 var n = loadNodeModulesSync(x, absoluteStart);
20989 if (n) return maybeRealpathSync(realpathSync, n, opts);
20992 var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
20993 err.code = 'MODULE_NOT_FOUND';
20996 function loadAsFileSync(x) {
20997 var pkg = loadpkg(path$j.dirname(x));
20999 if (pkg && pkg.dir && pkg.pkg && opts.pathFilter) {
21000 var rfile = path$j.relative(pkg.dir, x);
21001 var r = opts.pathFilter(pkg.pkg, x, rfile);
21004 x = path$j.resolve(pkg.dir, r); // eslint-disable-line no-param-reassign
21012 for (var i = 0; i < extensions.length; i++) {
21013 var file = x + extensions[i];
21015 if (isFile(file)) {
21021 function loadpkg(dir) {
21022 if (dir === '' || dir === '/') return;
21024 if (process.platform === 'win32' && /^\w:[/\\]*$/.test(dir)) {
21028 if (/[/\\]node_modules[/\\]*$/.test(dir)) return;
21029 var pkgfile = path$j.join(maybeRealpathSync(realpathSync, dir, opts), 'package.json');
21031 if (!isFile(pkgfile)) {
21032 return loadpkg(path$j.dirname(dir));
21035 var pkg = readPackageSync(readFileSync, pkgfile);
21037 if (pkg && opts.packageFilter) {
21038 // v2 will pass pkgfile
21039 pkg = opts.packageFilter(pkg,
21041 dir); // eslint-disable-line spaced-comment
21050 function loadAsDirectorySync(x) {
21051 var pkgfile = path$j.join(maybeRealpathSync(realpathSync, x, opts), '/package.json');
21053 if (isFile(pkgfile)) {
21055 var pkg = readPackageSync(readFileSync, pkgfile);
21058 if (pkg && opts.packageFilter) {
21059 // v2 will pass pkgfile
21060 pkg = opts.packageFilter(pkg,
21062 x); // eslint-disable-line spaced-comment
21065 if (pkg && pkg.main) {
21066 if (typeof pkg.main !== 'string') {
21067 var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
21068 mainError.code = 'INVALID_PACKAGE_MAIN';
21072 if (pkg.main === '.' || pkg.main === './') {
21073 pkg.main = 'index';
21077 var m = loadAsFileSync(path$j.resolve(x, pkg.main));
21079 var n = loadAsDirectorySync(path$j.resolve(x, pkg.main));
21085 return loadAsFileSync(path$j.join(x, '/index'));
21088 function loadNodeModulesSync(x, start) {
21089 var thunk = function () {
21090 return getPackageCandidates(x, start, opts);
21093 var dirs = packageIterator ? packageIterator(x, start, thunk, opts) : thunk();
21095 for (var i = 0; i < dirs.length; i++) {
21098 if (isDirectory(path$j.dirname(dir))) {
21099 var m = loadAsFileSync(dir);
21101 var n = loadAsDirectorySync(dir);
21108 var async$7 = async$8;
21109 async$7.core = core_1;
21110 async$7.isCore = isCore$1;
21111 async$7.sync = sync$8;
21112 var resolve$3 = async$7;
21116 } = require; // In the VS Code and Atom extensions `require` is overridden and `require.resolve` doesn't support the 2nd argument.
21118 if (resolve$2.length === 1 || process.env.PRETTIER_FALLBACK_RESOLVE) {
21119 // @ts-expect-error
21120 resolve$2 = (id, options) => {
21123 if (options && options.paths && options.paths.length === 1) {
21124 basedir = options.paths[0];
21127 return resolve$3.sync(id, {
21133 var resolve_1 = resolve$2;
21137 var semver$1 = {exports: {}};
21139 (function (module, exports) {
21140 exports = module.exports = SemVer;
21142 /* istanbul ignore next */
21144 if (typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
21145 debug = function () {
21146 var args = Array.prototype.slice.call(arguments, 0);
21147 args.unshift('SEMVER');
21148 console.log.apply(console, args);
21151 debug = function () {};
21152 } // Note: this is the semver.org version of the spec that it implements
21153 // Not necessarily the package version of this code.
21156 exports.SEMVER_SPEC_VERSION = '2.0.0';
21157 var MAX_LENGTH = 256;
21158 var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
21159 /* istanbul ignore next */
21160 9007199254740991; // Max safe segment length for coercion.
21162 var MAX_SAFE_COMPONENT_LENGTH = 16; // The actual regexps go on exports.re
21164 var re = exports.re = [];
21165 var src = exports.src = [];
21166 var R = 0; // The following Regular Expressions can be used for tokenizing,
21167 // validating, and parsing SemVer version strings.
21168 // ## Numeric Identifier
21169 // A single `0`, or a non-zero digit followed by zero or more digits.
21171 var NUMERICIDENTIFIER = R++;
21172 src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
21173 var NUMERICIDENTIFIERLOOSE = R++;
21174 src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier
21175 // Zero or more digits, followed by a letter or hyphen, and then zero or
21176 // more letters, digits, or hyphens.
21178 var NONNUMERICIDENTIFIER = R++;
21179 src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version
21180 // Three dot-separated numeric identifiers.
21182 var MAINVERSION = R++;
21183 src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')';
21184 var MAINVERSIONLOOSE = R++;
21185 src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier
21186 // A numeric identifier, or a non-numeric identifier.
21188 var PRERELEASEIDENTIFIER = R++;
21189 src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + '|' + src[NONNUMERICIDENTIFIER] + ')';
21190 var PRERELEASEIDENTIFIERLOOSE = R++;
21191 src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + '|' + src[NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version
21192 // Hyphen, followed by one or more dot-separated pre-release version
21195 var PRERELEASE = R++;
21196 src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
21197 var PRERELEASELOOSE = R++;
21198 src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier
21199 // Any combination of digits, letters, or hyphens.
21201 var BUILDIDENTIFIER = R++;
21202 src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata
21203 // Plus sign, followed by one or more period-separated build metadata
21207 src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))'; // ## Full Version String
21208 // A main version, followed optionally by a pre-release version and
21210 // Note that the only major, minor, patch, and pre-release sections of
21211 // the version string are capturing groups. The build metadata is not a
21212 // capturing group, because it should not ever be used in version
21216 var FULLPLAIN = 'v?' + src[MAINVERSION] + src[PRERELEASE] + '?' + src[BUILD] + '?';
21217 src[FULL] = '^' + FULLPLAIN + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
21218 // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
21219 // common in the npm registry.
21221 var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + '?' + src[BUILD] + '?';
21223 src[LOOSE] = '^' + LOOSEPLAIN + '$';
21225 src[GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x".
21226 // Note that "x.x" is a valid xRange identifer, meaning "any version"
21227 // Only the first item is strictly required.
21229 var XRANGEIDENTIFIERLOOSE = R++;
21230 src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
21231 var XRANGEIDENTIFIER = R++;
21232 src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
21233 var XRANGEPLAIN = R++;
21234 src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:' + src[PRERELEASE] + ')?' + src[BUILD] + '?' + ')?)?';
21235 var XRANGEPLAINLOOSE = R++;
21236 src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[PRERELEASELOOSE] + ')?' + src[BUILD] + '?' + ')?)?';
21238 src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
21239 var XRANGELOOSE = R++;
21240 src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; // Coercion.
21241 // Extract anything that could conceivably be a part of a valid semver
21244 src[COERCE] = '(?:^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])'; // Tilde ranges.
21245 // Meaning is "reasonably at or greater than"
21247 var LONETILDE = R++;
21248 src[LONETILDE] = '(?:~>?)';
21249 var TILDETRIM = R++;
21250 src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
21251 re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
21252 var tildeTrimReplace = '$1~';
21254 src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
21255 var TILDELOOSE = R++;
21256 src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'; // Caret ranges.
21257 // Meaning is "at least and backwards compatible with"
21259 var LONECARET = R++;
21260 src[LONECARET] = '(?:\\^)';
21261 var CARETTRIM = R++;
21262 src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
21263 re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
21264 var caretTrimReplace = '$1^';
21266 src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
21267 var CARETLOOSE = R++;
21268 src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version"
21270 var COMPARATORLOOSE = R++;
21271 src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
21272 var COMPARATOR = R++;
21273 src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing
21274 // it modifies, so that `> 1.2.3` ==> `>1.2.3`
21276 var COMPARATORTRIM = R++;
21277 src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'; // this one has to use the /g flag
21279 re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
21280 var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
21281 // Note that these all use the loose form, because they'll be
21282 // checked against either the strict or loose comparator form
21285 var HYPHENRANGE = R++;
21286 src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAIN] + ')' + '\\s*$';
21287 var HYPHENRANGELOOSE = R++;
21288 src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all.
21291 src[STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects.
21292 // All are flag-free, unless they were created above with a flag.
21294 for (var i = 0; i < R; i++) {
21298 re[i] = new RegExp(src[i]);
21302 exports.parse = parse;
21304 function parse(version, options) {
21305 if (!options || typeof options !== 'object') {
21308 includePrerelease: false
21312 if (version instanceof SemVer) {
21316 if (typeof version !== 'string') {
21320 if (version.length > MAX_LENGTH) {
21324 var r = options.loose ? re[LOOSE] : re[FULL];
21326 if (!r.test(version)) {
21331 return new SemVer(version, options);
21337 exports.valid = valid;
21339 function valid(version, options) {
21340 var v = parse(version, options);
21341 return v ? v.version : null;
21344 exports.clean = clean;
21346 function clean(version, options) {
21347 var s = parse(version.trim().replace(/^[=v]+/, ''), options);
21348 return s ? s.version : null;
21351 exports.SemVer = SemVer;
21353 function SemVer(version, options) {
21354 if (!options || typeof options !== 'object') {
21357 includePrerelease: false
21361 if (version instanceof SemVer) {
21362 if (version.loose === options.loose) {
21365 version = version.version;
21367 } else if (typeof version !== 'string') {
21368 throw new TypeError('Invalid Version: ' + version);
21371 if (version.length > MAX_LENGTH) {
21372 throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
21375 if (!(this instanceof SemVer)) {
21376 return new SemVer(version, options);
21379 debug('SemVer', version, options);
21380 this.options = options;
21381 this.loose = !!options.loose;
21382 var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]);
21385 throw new TypeError('Invalid Version: ' + version);
21388 this.raw = version; // these are actually numbers
21390 this.major = +m[1];
21391 this.minor = +m[2];
21392 this.patch = +m[3];
21394 if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
21395 throw new TypeError('Invalid major version');
21398 if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
21399 throw new TypeError('Invalid minor version');
21402 if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
21403 throw new TypeError('Invalid patch version');
21404 } // numberify any prerelease numeric ids
21408 this.prerelease = [];
21410 this.prerelease = m[4].split('.').map(function (id) {
21411 if (/^[0-9]+$/.test(id)) {
21414 if (num >= 0 && num < MAX_SAFE_INTEGER) {
21423 this.build = m[5] ? m[5].split('.') : [];
21427 SemVer.prototype.format = function () {
21428 this.version = this.major + '.' + this.minor + '.' + this.patch;
21430 if (this.prerelease.length) {
21431 this.version += '-' + this.prerelease.join('.');
21434 return this.version;
21437 SemVer.prototype.toString = function () {
21438 return this.version;
21441 SemVer.prototype.compare = function (other) {
21442 debug('SemVer.compare', this.version, this.options, other);
21444 if (!(other instanceof SemVer)) {
21445 other = new SemVer(other, this.options);
21448 return this.compareMain(other) || this.comparePre(other);
21451 SemVer.prototype.compareMain = function (other) {
21452 if (!(other instanceof SemVer)) {
21453 other = new SemVer(other, this.options);
21456 return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
21459 SemVer.prototype.comparePre = function (other) {
21460 if (!(other instanceof SemVer)) {
21461 other = new SemVer(other, this.options);
21462 } // NOT having a prerelease is > having one
21465 if (this.prerelease.length && !other.prerelease.length) {
21467 } else if (!this.prerelease.length && other.prerelease.length) {
21469 } else if (!this.prerelease.length && !other.prerelease.length) {
21476 var a = this.prerelease[i];
21477 var b = other.prerelease[i];
21478 debug('prerelease compare', i, a, b);
21480 if (a === undefined && b === undefined) {
21482 } else if (b === undefined) {
21484 } else if (a === undefined) {
21486 } else if (a === b) {
21489 return compareIdentifiers(a, b);
21492 }; // preminor will bump the version up to the next minor release, and immediately
21493 // down to pre-release. premajor and prepatch work the same way.
21496 SemVer.prototype.inc = function (release, identifier) {
21499 this.prerelease.length = 0;
21503 this.inc('pre', identifier);
21507 this.prerelease.length = 0;
21510 this.inc('pre', identifier);
21514 // If this is already a prerelease, it will bump to the next version
21515 // drop any prereleases that might already exist, since they are not
21516 // relevant at this point.
21517 this.prerelease.length = 0;
21518 this.inc('patch', identifier);
21519 this.inc('pre', identifier);
21521 // If the input is a non-prerelease version, this acts the same as
21525 if (this.prerelease.length === 0) {
21526 this.inc('patch', identifier);
21529 this.inc('pre', identifier);
21533 // If this is a pre-major version, bump up to the same major version.
21534 // Otherwise increment major.
21535 // 1.0.0-5 bumps to 1.0.0
21536 // 1.1.0 bumps to 2.0.0
21537 if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
21543 this.prerelease = [];
21547 // If this is a pre-minor version, bump up to the same minor version.
21548 // Otherwise increment minor.
21549 // 1.2.0-5 bumps to 1.2.0
21550 // 1.2.1 bumps to 1.3.0
21551 if (this.patch !== 0 || this.prerelease.length === 0) {
21556 this.prerelease = [];
21560 // If this is not a pre-release version, it will increment the patch.
21561 // If it is a pre-release it will bump up to the same patch version.
21562 // 1.2.0-5 patches to 1.2.0
21563 // 1.2.0 patches to 1.2.1
21564 if (this.prerelease.length === 0) {
21568 this.prerelease = [];
21570 // This probably shouldn't be used publicly.
21571 // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
21574 if (this.prerelease.length === 0) {
21575 this.prerelease = [0];
21577 var i = this.prerelease.length;
21580 if (typeof this.prerelease[i] === 'number') {
21581 this.prerelease[i]++;
21587 // didn't increment anything
21588 this.prerelease.push(0);
21593 // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
21594 // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
21595 if (this.prerelease[0] === identifier) {
21596 if (isNaN(this.prerelease[1])) {
21597 this.prerelease = [identifier, 0];
21600 this.prerelease = [identifier, 0];
21607 throw new Error('invalid increment argument: ' + release);
21611 this.raw = this.version;
21617 function inc(version, release, loose, identifier) {
21618 if (typeof loose === 'string') {
21619 identifier = loose;
21624 return new SemVer(version, loose).inc(release, identifier).version;
21630 exports.diff = diff;
21632 function diff(version1, version2) {
21633 if (eq(version1, version2)) {
21636 var v1 = parse(version1);
21637 var v2 = parse(version2);
21640 if (v1.prerelease.length || v2.prerelease.length) {
21642 var defaultResult = 'prerelease';
21645 for (var key in v1) {
21646 if (key === 'major' || key === 'minor' || key === 'patch') {
21647 if (v1[key] !== v2[key]) {
21648 return prefix + key;
21653 return defaultResult; // may be undefined
21657 exports.compareIdentifiers = compareIdentifiers;
21658 var numeric = /^[0-9]+$/;
21660 function compareIdentifiers(a, b) {
21661 var anum = numeric.test(a);
21662 var bnum = numeric.test(b);
21664 if (anum && bnum) {
21669 return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
21672 exports.rcompareIdentifiers = rcompareIdentifiers;
21674 function rcompareIdentifiers(a, b) {
21675 return compareIdentifiers(b, a);
21678 exports.major = major;
21680 function major(a, loose) {
21681 return new SemVer(a, loose).major;
21684 exports.minor = minor;
21686 function minor(a, loose) {
21687 return new SemVer(a, loose).minor;
21690 exports.patch = patch;
21692 function patch(a, loose) {
21693 return new SemVer(a, loose).patch;
21696 exports.compare = compare;
21698 function compare(a, b, loose) {
21699 return new SemVer(a, loose).compare(new SemVer(b, loose));
21702 exports.compareLoose = compareLoose;
21704 function compareLoose(a, b) {
21705 return compare(a, b, true);
21708 exports.rcompare = rcompare;
21710 function rcompare(a, b, loose) {
21711 return compare(b, a, loose);
21714 exports.sort = sort;
21716 function sort(list, loose) {
21717 return list.sort(function (a, b) {
21718 return exports.compare(a, b, loose);
21722 exports.rsort = rsort;
21724 function rsort(list, loose) {
21725 return list.sort(function (a, b) {
21726 return exports.rcompare(a, b, loose);
21732 function gt(a, b, loose) {
21733 return compare(a, b, loose) > 0;
21738 function lt(a, b, loose) {
21739 return compare(a, b, loose) < 0;
21744 function eq(a, b, loose) {
21745 return compare(a, b, loose) === 0;
21750 function neq(a, b, loose) {
21751 return compare(a, b, loose) !== 0;
21756 function gte(a, b, loose) {
21757 return compare(a, b, loose) >= 0;
21762 function lte(a, b, loose) {
21763 return compare(a, b, loose) <= 0;
21768 function cmp(a, op, b, loose) {
21771 if (typeof a === 'object') a = a.version;
21772 if (typeof b === 'object') b = b.version;
21776 if (typeof a === 'object') a = a.version;
21777 if (typeof b === 'object') b = b.version;
21783 return eq(a, b, loose);
21786 return neq(a, b, loose);
21789 return gt(a, b, loose);
21792 return gte(a, b, loose);
21795 return lt(a, b, loose);
21798 return lte(a, b, loose);
21801 throw new TypeError('Invalid operator: ' + op);
21805 exports.Comparator = Comparator;
21807 function Comparator(comp, options) {
21808 if (!options || typeof options !== 'object') {
21811 includePrerelease: false
21815 if (comp instanceof Comparator) {
21816 if (comp.loose === !!options.loose) {
21823 if (!(this instanceof Comparator)) {
21824 return new Comparator(comp, options);
21827 debug('comparator', comp, options);
21828 this.options = options;
21829 this.loose = !!options.loose;
21832 if (this.semver === ANY) {
21835 this.value = this.operator + this.semver.version;
21838 debug('comp', this);
21843 Comparator.prototype.parse = function (comp) {
21844 var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
21845 var m = comp.match(r);
21848 throw new TypeError('Invalid comparator: ' + comp);
21851 this.operator = m[1];
21853 if (this.operator === '=') {
21854 this.operator = '';
21855 } // if it literally is just '>' or '' then allow anything.
21861 this.semver = new SemVer(m[2], this.options.loose);
21865 Comparator.prototype.toString = function () {
21869 Comparator.prototype.test = function (version) {
21870 debug('Comparator.test', version, this.options.loose);
21872 if (this.semver === ANY) {
21876 if (typeof version === 'string') {
21877 version = new SemVer(version, this.options);
21880 return cmp(version, this.operator, this.semver, this.options);
21883 Comparator.prototype.intersects = function (comp, options) {
21884 if (!(comp instanceof Comparator)) {
21885 throw new TypeError('a Comparator is required');
21888 if (!options || typeof options !== 'object') {
21891 includePrerelease: false
21897 if (this.operator === '') {
21898 rangeTmp = new Range(comp.value, options);
21899 return satisfies(this.value, rangeTmp, options);
21900 } else if (comp.operator === '') {
21901 rangeTmp = new Range(this.value, options);
21902 return satisfies(comp.semver, rangeTmp, options);
21905 var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
21906 var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
21907 var sameSemVer = this.semver.version === comp.semver.version;
21908 var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
21909 var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
21910 var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
21911 return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
21914 exports.Range = Range;
21916 function Range(range, options) {
21917 if (!options || typeof options !== 'object') {
21920 includePrerelease: false
21924 if (range instanceof Range) {
21925 if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
21928 return new Range(range.raw, options);
21932 if (range instanceof Comparator) {
21933 return new Range(range.value, options);
21936 if (!(this instanceof Range)) {
21937 return new Range(range, options);
21940 this.options = options;
21941 this.loose = !!options.loose;
21942 this.includePrerelease = !!options.includePrerelease; // First, split based on boolean or ||
21945 this.set = range.split(/\s*\|\|\s*/).map(function (range) {
21946 return this.parseRange(range.trim());
21947 }, this).filter(function (c) {
21948 // throw out any that are not relevant for whatever reason
21952 if (!this.set.length) {
21953 throw new TypeError('Invalid SemVer Range: ' + range);
21959 Range.prototype.format = function () {
21960 this.range = this.set.map(function (comps) {
21961 return comps.join(' ').trim();
21962 }).join('||').trim();
21966 Range.prototype.toString = function () {
21970 Range.prototype.parseRange = function (range) {
21971 var loose = this.options.loose;
21972 range = range.trim(); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
21974 var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
21975 range = range.replace(hr, hyphenReplace);
21976 debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
21978 range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
21979 debug('comparator trim', range, re[COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
21981 range = range.replace(re[TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
21983 range = range.replace(re[CARETTRIM], caretTrimReplace); // normalize spaces
21985 range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
21986 // ready to be split into comparators.
21988 var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
21989 var set = range.split(' ').map(function (comp) {
21990 return parseComparator(comp, this.options);
21991 }, this).join(' ').split(/\s+/);
21993 if (this.options.loose) {
21994 // in loose mode, throw out any that are not valid comparators
21995 set = set.filter(function (comp) {
21996 return !!comp.match(compRe);
22000 set = set.map(function (comp) {
22001 return new Comparator(comp, this.options);
22006 Range.prototype.intersects = function (range, options) {
22007 if (!(range instanceof Range)) {
22008 throw new TypeError('a Range is required');
22011 return this.set.some(function (thisComparators) {
22012 return thisComparators.every(function (thisComparator) {
22013 return range.set.some(function (rangeComparators) {
22014 return rangeComparators.every(function (rangeComparator) {
22015 return thisComparator.intersects(rangeComparator, options);
22020 }; // Mostly just for testing and legacy API reasons
22023 exports.toComparators = toComparators;
22025 function toComparators(range, options) {
22026 return new Range(range, options).set.map(function (comp) {
22027 return comp.map(function (c) {
22029 }).join(' ').trim().split(' ');
22031 } // comprised of xranges, tildes, stars, and gtlt's at this point.
22032 // already replaced the hyphen ranges
22033 // turn into a set of JUST comparators.
22036 function parseComparator(comp, options) {
22037 debug('comp', comp, options);
22038 comp = replaceCarets(comp, options);
22039 debug('caret', comp);
22040 comp = replaceTildes(comp, options);
22041 debug('tildes', comp);
22042 comp = replaceXRanges(comp, options);
22043 debug('xrange', comp);
22044 comp = replaceStars(comp, options);
22045 debug('stars', comp);
22050 return !id || id.toLowerCase() === 'x' || id === '*';
22051 } // ~, ~> --> * (any, kinda silly)
22052 // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
22053 // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
22054 // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
22055 // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
22056 // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
22059 function replaceTildes(comp, options) {
22060 return comp.trim().split(/\s+/).map(function (comp) {
22061 return replaceTilde(comp, options);
22065 function replaceTilde(comp, options) {
22066 var r = options.loose ? re[TILDELOOSE] : re[TILDE];
22067 return comp.replace(r, function (_, M, m, p, pr) {
22068 debug('tilde', comp, _, M, m, p, pr);
22073 } else if (isX(m)) {
22074 ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
22075 } else if (isX(p)) {
22076 // ~1.2 == >=1.2.0 <1.3.0
22077 ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
22079 debug('replaceTilde pr', pr);
22080 ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
22082 // ~1.2.3 == >=1.2.3 <1.3.0
22083 ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
22086 debug('tilde return', ret);
22089 } // ^ --> * (any, kinda silly)
22090 // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
22091 // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
22092 // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
22093 // ^1.2.3 --> >=1.2.3 <2.0.0
22094 // ^1.2.0 --> >=1.2.0 <2.0.0
22097 function replaceCarets(comp, options) {
22098 return comp.trim().split(/\s+/).map(function (comp) {
22099 return replaceCaret(comp, options);
22103 function replaceCaret(comp, options) {
22104 debug('caret', comp, options);
22105 var r = options.loose ? re[CARETLOOSE] : re[CARET];
22106 return comp.replace(r, function (_, M, m, p, pr) {
22107 debug('caret', comp, _, M, m, p, pr);
22112 } else if (isX(m)) {
22113 ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
22114 } else if (isX(p)) {
22116 ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
22118 ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
22121 debug('replaceCaret pr', pr);
22125 ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + m + '.' + (+p + 1);
22127 ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
22130 ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + (+M + 1) + '.0.0';
22137 ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);
22139 ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
22142 ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
22146 debug('caret return', ret);
22151 function replaceXRanges(comp, options) {
22152 debug('replaceXRanges', comp, options);
22153 return comp.split(/\s+/).map(function (comp) {
22154 return replaceXRange(comp, options);
22158 function replaceXRange(comp, options) {
22159 comp = comp.trim();
22160 var r = options.loose ? re[XRANGELOOSE] : re[XRANGE];
22161 return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
22162 debug('xRange', comp, ret, gtlt, M, m, p, pr);
22164 var xm = xM || isX(m);
22165 var xp = xm || isX(p);
22168 if (gtlt === '=' && anyX) {
22173 if (gtlt === '>' || gtlt === '<') {
22174 // nothing is allowed
22177 // nothing is forbidden
22180 } else if (gtlt && anyX) {
22181 // we know patch is an x, because we have any x at all.
22182 // replace X with 0
22189 if (gtlt === '>') {
22192 // >1.2.3 => >= 1.2.4
22203 } else if (gtlt === '<=') {
22204 // <=0.7.x is actually <0.8.0, since any 0.7.x should
22205 // pass. Similarly, <=7.x is actually <8.0.0, etc.
22215 ret = gtlt + M + '.' + m + '.' + p;
22217 ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
22219 ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
22222 debug('xRange return', ret);
22225 } // Because * is AND-ed with everything else in the comparator,
22226 // and '' means "any version", just remove the *s entirely.
22229 function replaceStars(comp, options) {
22230 debug('replaceStars', comp, options); // Looseness is ignored here. star is always as loose as it gets!
22232 return comp.trim().replace(re[STAR], '');
22233 } // This function is passed to string.replace(re[HYPHENRANGE])
22234 // M, m, patch, prerelease, build
22235 // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
22236 // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
22237 // 1.2 - 3.4 => >=1.2.0 <3.5.0
22240 function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
22243 } else if (isX(fm)) {
22244 from = '>=' + fM + '.0.0';
22245 } else if (isX(fp)) {
22246 from = '>=' + fM + '.' + fm + '.0';
22248 from = '>=' + from;
22253 } else if (isX(tm)) {
22254 to = '<' + (+tM + 1) + '.0.0';
22255 } else if (isX(tp)) {
22256 to = '<' + tM + '.' + (+tm + 1) + '.0';
22258 to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
22263 return (from + ' ' + to).trim();
22264 } // if ANY of the sets match ALL of its comparators, then pass
22267 Range.prototype.test = function (version) {
22272 if (typeof version === 'string') {
22273 version = new SemVer(version, this.options);
22276 for (var i = 0; i < this.set.length; i++) {
22277 if (testSet(this.set[i], version, this.options)) {
22285 function testSet(set, version, options) {
22286 for (var i = 0; i < set.length; i++) {
22287 if (!set[i].test(version)) {
22292 if (version.prerelease.length && !options.includePrerelease) {
22293 // Find the set of versions that are allowed to have prereleases
22294 // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
22295 // That should allow `1.2.3-pr.2` to pass.
22296 // However, `1.2.4-alpha.notready` should NOT be allowed,
22297 // even though it's within the range set by the comparators.
22298 for (i = 0; i < set.length; i++) {
22299 debug(set[i].semver);
22301 if (set[i].semver === ANY) {
22305 if (set[i].semver.prerelease.length > 0) {
22306 var allowed = set[i].semver;
22308 if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
22312 } // Version has a -pre, but it's not one of the ones we like.
22321 exports.satisfies = satisfies;
22323 function satisfies(version, range, options) {
22325 range = new Range(range, options);
22330 return range.test(version);
22333 exports.maxSatisfying = maxSatisfying;
22335 function maxSatisfying(versions, range, options) {
22340 var rangeObj = new Range(range, options);
22345 versions.forEach(function (v) {
22346 if (rangeObj.test(v)) {
22347 // satisfies(v, range, options)
22348 if (!max || maxSV.compare(v) === -1) {
22349 // compare(max, v, true)
22351 maxSV = new SemVer(max, options);
22358 exports.minSatisfying = minSatisfying;
22360 function minSatisfying(versions, range, options) {
22365 var rangeObj = new Range(range, options);
22370 versions.forEach(function (v) {
22371 if (rangeObj.test(v)) {
22372 // satisfies(v, range, options)
22373 if (!min || minSV.compare(v) === 1) {
22374 // compare(min, v, true)
22376 minSV = new SemVer(min, options);
22383 exports.minVersion = minVersion;
22385 function minVersion(range, loose) {
22386 range = new Range(range, loose);
22387 var minver = new SemVer('0.0.0');
22389 if (range.test(minver)) {
22393 minver = new SemVer('0.0.0-0');
22395 if (range.test(minver)) {
22401 for (var i = 0; i < range.set.length; ++i) {
22402 var comparators = range.set[i];
22403 comparators.forEach(function (comparator) {
22404 // Clone to avoid manipulating the comparator's semver object.
22405 var compver = new SemVer(comparator.semver.version);
22407 switch (comparator.operator) {
22409 if (compver.prerelease.length === 0) {
22412 compver.prerelease.push(0);
22415 compver.raw = compver.format();
22421 if (!minver || gt(minver, compver)) {
22429 /* Ignore maximum versions */
22432 /* istanbul ignore next */
22435 throw new Error('Unexpected operation: ' + comparator.operator);
22440 if (minver && range.test(minver)) {
22447 exports.validRange = validRange;
22449 function validRange(range, options) {
22451 // Return '*' instead of '' so that truthiness works.
22452 // This will throw if it's invalid anyway
22453 return new Range(range, options).range || '*';
22457 } // Determine if version is less than all the versions possible in the range
22462 function ltr(version, range, options) {
22463 return outside(version, range, '<', options);
22464 } // Determine if version is greater than all the versions possible in the range.
22469 function gtr(version, range, options) {
22470 return outside(version, range, '>', options);
22473 exports.outside = outside;
22475 function outside(version, range, hilo, options) {
22476 version = new SemVer(version, options);
22477 range = new Range(range, options);
22478 var gtfn, ltefn, ltfn, comp, ecomp;
22498 throw new TypeError('Must provide a hilo val of "<" or ">"');
22499 } // If it satisifes the range it is not outside
22502 if (satisfies(version, range, options)) {
22504 } // From now on, variable terms are as if we're in "gtr" mode.
22505 // but note that everything is flipped for the "ltr" function.
22508 for (var i = 0; i < range.set.length; ++i) {
22509 var comparators = range.set[i];
22512 comparators.forEach(function (comparator) {
22513 if (comparator.semver === ANY) {
22514 comparator = new Comparator('>=0.0.0');
22517 high = high || comparator;
22518 low = low || comparator;
22520 if (gtfn(comparator.semver, high.semver, options)) {
22522 } else if (ltfn(comparator.semver, low.semver, options)) {
22525 }); // If the edge version comparator has a operator then our version
22526 // isn't outside it
22528 if (high.operator === comp || high.operator === ecomp) {
22530 } // If the lowest version comparator has an operator and our version
22531 // is less than it then it isn't higher than the range
22534 if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
22536 } else if (low.operator === ecomp && ltfn(version, low.semver)) {
22544 exports.prerelease = prerelease;
22546 function prerelease(version, options) {
22547 var parsed = parse(version, options);
22548 return parsed && parsed.prerelease.length ? parsed.prerelease : null;
22551 exports.intersects = intersects;
22553 function intersects(r1, r2, options) {
22554 r1 = new Range(r1, options);
22555 r2 = new Range(r2, options);
22556 return r1.intersects(r2);
22559 exports.coerce = coerce;
22561 function coerce(version) {
22562 if (version instanceof SemVer) {
22566 if (typeof version !== 'string') {
22570 var match = version.match(re[COERCE]);
22572 if (match == null) {
22576 return parse(match[1] + '.' + (match[2] || '0') + '.' + (match[3] || '0'));
22578 })(semver$1, semver$1.exports);
22580 var fnmatch$1 = {exports: {}};
22582 var map$1 = {exports: {}};
22584 var hasOwnProperty$9 = Object.prototype.hasOwnProperty;
22585 var pseudomap = PseudoMap;
22587 function PseudoMap(set) {
22588 if (!(this instanceof PseudoMap)) // whyyyyyyy
22589 throw new TypeError("Constructor PseudoMap requires 'new'");
22593 if (set instanceof PseudoMap || typeof Map === 'function' && set instanceof Map) set.forEach(function (value, key) {
22594 this.set(key, value);
22595 }, this);else if (Array.isArray(set)) set.forEach(function (kv) {
22596 this.set(kv[0], kv[1]);
22597 }, this);else throw new TypeError('invalid argument');
22601 PseudoMap.prototype.forEach = function (fn, thisp) {
22602 thisp = thisp || this;
22603 Object.keys(this._data).forEach(function (k) {
22604 if (k !== 'size') fn.call(thisp, this._data[k].value, this._data[k].key);
22608 PseudoMap.prototype.has = function (k) {
22609 return !!find(this._data, k);
22612 PseudoMap.prototype.get = function (k) {
22613 var res = find(this._data, k);
22614 return res && res.value;
22617 PseudoMap.prototype.set = function (k, v) {
22618 set(this._data, k, v);
22621 PseudoMap.prototype.delete = function (k) {
22622 var res = find(this._data, k);
22625 delete this._data[res._index];
22630 PseudoMap.prototype.clear = function () {
22631 var data = Object.create(null);
22633 Object.defineProperty(this, '_data', {
22636 configurable: true,
22641 Object.defineProperty(PseudoMap.prototype, 'size', {
22643 return this._data.size;
22645 set: function (n) {},
22650 PseudoMap.prototype.values = PseudoMap.prototype.keys = PseudoMap.prototype.entries = function () {
22651 throw new Error('iterators are not implemented in this version');
22652 }; // Either identical, or both NaN
22655 function same(a, b) {
22656 return a === b || a !== a && b !== b;
22659 function Entry$1(k, v, i) {
22665 function find(data, k) {
22666 for (var i = 0, s = '_' + k, key = s; hasOwnProperty$9.call(data, key); key = s + i++) {
22667 if (same(data[key].key, k)) return data[key];
22671 function set(data, k, v) {
22672 for (var i = 0, s = '_' + k, key = s; hasOwnProperty$9.call(data, key); key = s + i++) {
22673 if (same(data[key].key, k)) {
22674 data[key].value = v;
22680 data[key] = new Entry$1(k, v, key);
22683 if (process.env.npm_package_name === 'pseudomap' && process.env.npm_lifecycle_script === 'test') process.env.TEST_PSEUDOMAP = 'true';
22685 if (typeof Map === 'function' && !process.env.TEST_PSEUDOMAP) {
22686 map$1.exports = Map;
22688 map$1.exports = pseudomap;
22691 var yallist = Yallist$1;
22692 Yallist$1.Node = Node;
22693 Yallist$1.create = Yallist$1;
22695 function Yallist$1(list) {
22698 if (!(self instanceof Yallist$1)) {
22699 self = new Yallist$1();
22706 if (list && typeof list.forEach === 'function') {
22707 list.forEach(function (item) {
22710 } else if (arguments.length > 0) {
22711 for (var i = 0, l = arguments.length; i < l; i++) {
22712 self.push(arguments[i]);
22719 Yallist$1.prototype.removeNode = function (node) {
22720 if (node.list !== this) {
22721 throw new Error('removing node which does not belong to this list');
22724 var next = node.next;
22725 var prev = node.prev;
22735 if (node === this.head) {
22739 if (node === this.tail) {
22743 node.list.length--;
22749 Yallist$1.prototype.unshiftNode = function (node) {
22750 if (node === this.head) {
22755 node.list.removeNode(node);
22758 var head = this.head;
22775 Yallist$1.prototype.pushNode = function (node) {
22776 if (node === this.tail) {
22781 node.list.removeNode(node);
22784 var tail = this.tail;
22801 Yallist$1.prototype.push = function () {
22802 for (var i = 0, l = arguments.length; i < l; i++) {
22803 push(this, arguments[i]);
22806 return this.length;
22809 Yallist$1.prototype.unshift = function () {
22810 for (var i = 0, l = arguments.length; i < l; i++) {
22811 unshift(this, arguments[i]);
22814 return this.length;
22817 Yallist$1.prototype.pop = function () {
22822 var res = this.tail.value;
22823 this.tail = this.tail.prev;
22826 this.tail.next = null;
22835 Yallist$1.prototype.shift = function () {
22840 var res = this.head.value;
22841 this.head = this.head.next;
22844 this.head.prev = null;
22853 Yallist$1.prototype.forEach = function (fn, thisp) {
22854 thisp = thisp || this;
22856 for (var walker = this.head, i = 0; walker !== null; i++) {
22857 fn.call(thisp, walker.value, i, this);
22858 walker = walker.next;
22862 Yallist$1.prototype.forEachReverse = function (fn, thisp) {
22863 thisp = thisp || this;
22865 for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
22866 fn.call(thisp, walker.value, i, this);
22867 walker = walker.prev;
22871 Yallist$1.prototype.get = function (n) {
22872 for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
22873 // abort out of the list early if we hit a cycle
22874 walker = walker.next;
22877 if (i === n && walker !== null) {
22878 return walker.value;
22882 Yallist$1.prototype.getReverse = function (n) {
22883 for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
22884 // abort out of the list early if we hit a cycle
22885 walker = walker.prev;
22888 if (i === n && walker !== null) {
22889 return walker.value;
22893 Yallist$1.prototype.map = function (fn, thisp) {
22894 thisp = thisp || this;
22895 var res = new Yallist$1();
22897 for (var walker = this.head; walker !== null;) {
22898 res.push(fn.call(thisp, walker.value, this));
22899 walker = walker.next;
22905 Yallist$1.prototype.mapReverse = function (fn, thisp) {
22906 thisp = thisp || this;
22907 var res = new Yallist$1();
22909 for (var walker = this.tail; walker !== null;) {
22910 res.push(fn.call(thisp, walker.value, this));
22911 walker = walker.prev;
22917 Yallist$1.prototype.reduce = function (fn, initial) {
22919 var walker = this.head;
22921 if (arguments.length > 1) {
22923 } else if (this.head) {
22924 walker = this.head.next;
22925 acc = this.head.value;
22927 throw new TypeError('Reduce of empty list with no initial value');
22930 for (var i = 0; walker !== null; i++) {
22931 acc = fn(acc, walker.value, i);
22932 walker = walker.next;
22938 Yallist$1.prototype.reduceReverse = function (fn, initial) {
22940 var walker = this.tail;
22942 if (arguments.length > 1) {
22944 } else if (this.tail) {
22945 walker = this.tail.prev;
22946 acc = this.tail.value;
22948 throw new TypeError('Reduce of empty list with no initial value');
22951 for (var i = this.length - 1; walker !== null; i--) {
22952 acc = fn(acc, walker.value, i);
22953 walker = walker.prev;
22959 Yallist$1.prototype.toArray = function () {
22960 var arr = new Array(this.length);
22962 for (var i = 0, walker = this.head; walker !== null; i++) {
22963 arr[i] = walker.value;
22964 walker = walker.next;
22970 Yallist$1.prototype.toArrayReverse = function () {
22971 var arr = new Array(this.length);
22973 for (var i = 0, walker = this.tail; walker !== null; i++) {
22974 arr[i] = walker.value;
22975 walker = walker.prev;
22981 Yallist$1.prototype.slice = function (from, to) {
22982 to = to || this.length;
22991 from += this.length;
22994 var ret = new Yallist$1();
22996 if (to < from || to < 0) {
23004 if (to > this.length) {
23008 for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
23009 walker = walker.next;
23012 for (; walker !== null && i < to; i++, walker = walker.next) {
23013 ret.push(walker.value);
23019 Yallist$1.prototype.sliceReverse = function (from, to) {
23020 to = to || this.length;
23029 from += this.length;
23032 var ret = new Yallist$1();
23034 if (to < from || to < 0) {
23042 if (to > this.length) {
23046 for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
23047 walker = walker.prev;
23050 for (; walker !== null && i > from; i--, walker = walker.prev) {
23051 ret.push(walker.value);
23057 Yallist$1.prototype.reverse = function () {
23058 var head = this.head;
23059 var tail = this.tail;
23061 for (var walker = head; walker !== null; walker = walker.prev) {
23062 var p = walker.prev;
23063 walker.prev = walker.next;
23072 function push(self, item) {
23073 self.tail = new Node(item, self.tail, null, self);
23076 self.head = self.tail;
23082 function unshift(self, item) {
23083 self.head = new Node(item, null, self.head, self);
23086 self.tail = self.head;
23092 function Node(value, prev, next, list) {
23093 if (!(this instanceof Node)) {
23094 return new Node(value, prev, next, list);
23098 this.value = value;
23115 var lruCache = LRUCache; // This will be a proper iterable 'Map' in engines that support it,
23116 // or a fakey-fake PseudoMap in older versions.
23118 var Map$5 = map$1.exports;
23119 var util$3 = require$$0__default$4["default"]; // A linked list to keep track of recently-used-ness
23121 var Yallist = yallist; // use symbols if possible, otherwise just _props
23123 var hasSymbol = typeof Symbol === 'function' && process.env._nodeLRUCacheForceNoSymbol !== '1';
23127 makeSymbol = function (key) {
23128 return Symbol(key);
23131 makeSymbol = function (key) {
23136 var MAX = makeSymbol('max');
23137 var LENGTH = makeSymbol('length');
23138 var LENGTH_CALCULATOR = makeSymbol('lengthCalculator');
23139 var ALLOW_STALE = makeSymbol('allowStale');
23140 var MAX_AGE = makeSymbol('maxAge');
23141 var DISPOSE = makeSymbol('dispose');
23142 var NO_DISPOSE_ON_SET = makeSymbol('noDisposeOnSet');
23143 var LRU_LIST = makeSymbol('lruList');
23144 var CACHE = makeSymbol('cache');
23146 function naiveLength() {
23148 } // lruList is a yallist where the head is the youngest
23149 // item, and the tail is the oldest. the list contains the Hit
23150 // objects as the entries.
23151 // Each Hit object has a reference to its Yallist.Node. This
23154 // cache is a Map (or PseudoMap) that matches the keys to
23155 // the Yallist.Node object.
23158 function LRUCache(options) {
23159 if (!(this instanceof LRUCache)) {
23160 return new LRUCache(options);
23163 if (typeof options === 'number') {
23173 var max = this[MAX] = options.max; // Kind of weird to have a default max of Infinity, but oh well.
23175 if (!max || !(typeof max === 'number') || max <= 0) {
23176 this[MAX] = Infinity;
23179 var lc = options.length || naiveLength;
23181 if (typeof lc !== 'function') {
23185 this[LENGTH_CALCULATOR] = lc;
23186 this[ALLOW_STALE] = options.stale || false;
23187 this[MAX_AGE] = options.maxAge || 0;
23188 this[DISPOSE] = options.dispose;
23189 this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
23191 } // resize the cache when the max changes.
23194 Object.defineProperty(LRUCache.prototype, 'max', {
23195 set: function (mL) {
23196 if (!mL || !(typeof mL === 'number') || mL <= 0) {
23208 Object.defineProperty(LRUCache.prototype, 'allowStale', {
23209 set: function (allowStale) {
23210 this[ALLOW_STALE] = !!allowStale;
23213 return this[ALLOW_STALE];
23217 Object.defineProperty(LRUCache.prototype, 'maxAge', {
23218 set: function (mA) {
23219 if (!mA || !(typeof mA === 'number') || mA < 0) {
23223 this[MAX_AGE] = mA;
23227 return this[MAX_AGE];
23230 }); // resize the cache when the lengthCalculator changes.
23232 Object.defineProperty(LRUCache.prototype, 'lengthCalculator', {
23233 set: function (lC) {
23234 if (typeof lC !== 'function') {
23238 if (lC !== this[LENGTH_CALCULATOR]) {
23239 this[LENGTH_CALCULATOR] = lC;
23241 this[LRU_LIST].forEach(function (hit) {
23242 hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
23243 this[LENGTH] += hit.length;
23250 return this[LENGTH_CALCULATOR];
23254 Object.defineProperty(LRUCache.prototype, 'length', {
23256 return this[LENGTH];
23260 Object.defineProperty(LRUCache.prototype, 'itemCount', {
23262 return this[LRU_LIST].length;
23267 LRUCache.prototype.rforEach = function (fn, thisp) {
23268 thisp = thisp || this;
23270 for (var walker = this[LRU_LIST].tail; walker !== null;) {
23271 var prev = walker.prev;
23272 forEachStep(this, fn, walker, thisp);
23277 function forEachStep(self, fn, node, thisp) {
23278 var hit = node.value;
23280 if (isStale(self, hit)) {
23283 if (!self[ALLOW_STALE]) {
23289 fn.call(thisp, hit.value, hit.key, self);
23293 LRUCache.prototype.forEach = function (fn, thisp) {
23294 thisp = thisp || this;
23296 for (var walker = this[LRU_LIST].head; walker !== null;) {
23297 var next = walker.next;
23298 forEachStep(this, fn, walker, thisp);
23303 LRUCache.prototype.keys = function () {
23304 return this[LRU_LIST].toArray().map(function (k) {
23309 LRUCache.prototype.values = function () {
23310 return this[LRU_LIST].toArray().map(function (k) {
23315 LRUCache.prototype.reset = function () {
23316 if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
23317 this[LRU_LIST].forEach(function (hit) {
23318 this[DISPOSE](hit.key, hit.value);
23322 this[CACHE] = new Map$5(); // hash of items by key
23324 this[LRU_LIST] = new Yallist(); // list of items in order of use recency
23326 this[LENGTH] = 0; // length of items in the list
23329 LRUCache.prototype.dump = function () {
23330 return this[LRU_LIST].map(function (hit) {
23331 if (!isStale(this, hit)) {
23335 e: hit.now + (hit.maxAge || 0)
23338 }, this).toArray().filter(function (h) {
23343 LRUCache.prototype.dumpLru = function () {
23344 return this[LRU_LIST];
23346 /* istanbul ignore next */
23349 LRUCache.prototype.inspect = function (n, opts) {
23350 var str = 'LRUCache {';
23351 var extras = false;
23352 var as = this[ALLOW_STALE];
23355 str += '\n allowStale: true';
23359 var max = this[MAX];
23361 if (max && max !== Infinity) {
23366 str += '\n max: ' + util$3.inspect(max, opts);
23370 var maxAge = this[MAX_AGE];
23377 str += '\n maxAge: ' + util$3.inspect(maxAge, opts);
23381 var lc = this[LENGTH_CALCULATOR];
23383 if (lc && lc !== naiveLength) {
23388 str += '\n length: ' + util$3.inspect(this[LENGTH], opts);
23392 var didFirst = false;
23393 this[LRU_LIST].forEach(function (item) {
23405 var key = util$3.inspect(item.key).split('\n').join('\n ');
23410 if (item.maxAge !== maxAge) {
23411 val.maxAge = item.maxAge;
23414 if (lc !== naiveLength) {
23415 val.length = item.length;
23418 if (isStale(this, item)) {
23422 val = util$3.inspect(val, opts).split('\n').join('\n ');
23423 str += key + ' => ' + val;
23426 if (didFirst || extras) {
23434 LRUCache.prototype.set = function (key, value, maxAge) {
23435 maxAge = maxAge || this[MAX_AGE];
23436 var now = maxAge ? Date.now() : 0;
23437 var len = this[LENGTH_CALCULATOR](value, key);
23439 if (this[CACHE].has(key)) {
23440 if (len > this[MAX]) {
23441 del$1(this, this[CACHE].get(key));
23445 var node = this[CACHE].get(key);
23446 var item = node.value; // dispose of the old one before overwriting
23447 // split out into 2 ifs for better coverage tracking
23449 if (this[DISPOSE]) {
23450 if (!this[NO_DISPOSE_ON_SET]) {
23451 this[DISPOSE](key, item.value);
23456 item.maxAge = maxAge;
23457 item.value = value;
23458 this[LENGTH] += len - item.length;
23465 var hit = new Entry(key, value, len, now, maxAge); // oversized objects fall out of cache automatically.
23467 if (hit.length > this[MAX]) {
23468 if (this[DISPOSE]) {
23469 this[DISPOSE](key, value);
23475 this[LENGTH] += hit.length;
23476 this[LRU_LIST].unshift(hit);
23477 this[CACHE].set(key, this[LRU_LIST].head);
23482 LRUCache.prototype.has = function (key) {
23483 if (!this[CACHE].has(key)) return false;
23484 var hit = this[CACHE].get(key).value;
23486 if (isStale(this, hit)) {
23493 LRUCache.prototype.get = function (key) {
23494 return get$2(this, key, true);
23497 LRUCache.prototype.peek = function (key) {
23498 return get$2(this, key, false);
23501 LRUCache.prototype.pop = function () {
23502 var node = this[LRU_LIST].tail;
23503 if (!node) return null;
23508 LRUCache.prototype.del = function (key) {
23509 del$1(this, this[CACHE].get(key));
23512 LRUCache.prototype.load = function (arr) {
23515 var now = Date.now(); // A previous serialized cache has the most recent items first
23517 for (var l = arr.length - 1; l >= 0; l--) {
23519 var expiresAt = hit.e || 0;
23521 if (expiresAt === 0) {
23522 // the item was created without expiration in a non aged cache
23523 this.set(hit.k, hit.v);
23525 var maxAge = expiresAt - now; // dont add already expired items
23528 this.set(hit.k, hit.v, maxAge);
23534 LRUCache.prototype.prune = function () {
23536 this[CACHE].forEach(function (value, key) {
23537 get$2(self, key, false);
23541 function get$2(self, key, doUse) {
23542 var node = self[CACHE].get(key);
23545 var hit = node.value;
23547 if (isStale(self, hit)) {
23549 if (!self[ALLOW_STALE]) hit = undefined;
23552 self[LRU_LIST].unshiftNode(node);
23556 if (hit) hit = hit.value;
23562 function isStale(self, hit) {
23563 if (!hit || !hit.maxAge && !self[MAX_AGE]) {
23568 var diff = Date.now() - hit.now;
23571 stale = diff > hit.maxAge;
23573 stale = self[MAX_AGE] && diff > self[MAX_AGE];
23579 function trim(self) {
23580 if (self[LENGTH] > self[MAX]) {
23581 for (var walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
23582 // We know that we're about to delete this one, and also
23583 // what the next least recently used key will be, so just
23584 // go ahead and set it now.
23585 var prev = walker.prev;
23586 del$1(self, walker);
23592 function del$1(self, node) {
23594 var hit = node.value;
23596 if (self[DISPOSE]) {
23597 self[DISPOSE](hit.key, hit.value);
23600 self[LENGTH] -= hit.length;
23601 self[CACHE].delete(hit.key);
23602 self[LRU_LIST].removeNode(node);
23604 } // classy, since V8 prefers predictable objects.
23607 function Entry(key, value, length, now, maxAge) {
23609 this.value = value;
23610 this.length = length;
23612 this.maxAge = maxAge || 0;
23615 var sigmund_1 = sigmund;
23617 function sigmund(subject, maxSessions) {
23618 maxSessions = maxSessions || 10;
23623 function psychoAnalyze(subject, session) {
23624 if (session > maxSessions) return;
23626 if (typeof subject === 'function' || typeof subject === 'undefined') {
23630 if (typeof subject !== 'object' || !subject || subject instanceof RE) {
23631 analysis += subject;
23635 if (notes.indexOf(subject) !== -1 || session === maxSessions) return;
23636 notes.push(subject);
23638 Object.keys(subject).forEach(function (issue, _, __) {
23639 // pseudo-private values. skip those.
23640 if (issue.charAt(0) === '_') return;
23641 var to = typeof subject[issue];
23642 if (to === 'function' || to === 'undefined') return;
23644 psychoAnalyze(subject[issue], session + 1);
23648 psychoAnalyze(subject, 0);
23650 } // vim: set softtabstop=4 shiftwidth=4:
23652 (function (module, exports) {
23653 // Based on minimatch.js by isaacs <https://npmjs.org/package/minimatch>
23654 var platform = typeof process === "object" ? process.platform : "win32";
23655 if (module) module.exports = minimatch;else exports.minimatch = minimatch;
23656 minimatch.Minimatch = Minimatch;
23657 var LRU = lruCache,
23658 cache = minimatch.cache = new LRU({
23661 GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {},
23662 sigmund = sigmund_1;
23663 var path = require$$0__default$2["default"] // any single thing other than /
23664 // don't need to escape / when using new RegExp()
23666 qmark = "[^/]" // * => any number of characters
23668 star = qmark + "*?" // ** when dots are allowed. Anything goes, except .. and .
23669 // not (^ or / followed by one or two dots followed by $ or /),
23670 // followed by anything, any number of times.
23672 twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?" // not a ^ or / followed by a dot,
23673 // followed by anything, any number of times.
23675 twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?" // characters that need to be escaped in RegExp.
23677 reSpecials = charSet("().*{}+?[]^$\\!"); // "abc" -> { a:true, b:true, c:true }
23679 function charSet(s) {
23680 return s.split("").reduce(function (set, c) {
23684 } // normalizes slashes.
23687 var slashSplit = /\/+/;
23688 minimatch.monkeyPatch = monkeyPatch;
23690 function monkeyPatch() {
23691 var desc = Object.getOwnPropertyDescriptor(String.prototype, "match");
23692 var orig = desc.value;
23694 desc.value = function (p) {
23695 if (p instanceof Minimatch) return p.match(this);
23696 return orig.call(this, p);
23699 Object.defineProperty(String.prototype, desc);
23702 minimatch.filter = filter;
23704 function filter(pattern, options) {
23705 options = options || {};
23706 return function (p, i, list) {
23707 return minimatch(p, pattern, options);
23711 function ext(a, b) {
23715 Object.keys(b).forEach(function (k) {
23718 Object.keys(a).forEach(function (k) {
23724 minimatch.defaults = function (def) {
23725 if (!def || !Object.keys(def).length) return minimatch;
23726 var orig = minimatch;
23728 var m = function minimatch(p, pattern, options) {
23729 return orig.minimatch(p, pattern, ext(def, options));
23732 m.Minimatch = function Minimatch(pattern, options) {
23733 return new orig.Minimatch(pattern, ext(def, options));
23739 Minimatch.defaults = function (def) {
23740 if (!def || !Object.keys(def).length) return Minimatch;
23741 return minimatch.defaults(def).Minimatch;
23744 function minimatch(p, pattern, options) {
23745 if (typeof pattern !== "string") {
23746 throw new TypeError("glob pattern string required");
23749 if (!options) options = {}; // shortcut: comments match nothing.
23751 if (!options.nocomment && pattern.charAt(0) === "#") {
23753 } // "" only matches ""
23756 if (pattern.trim() === "") return p === "";
23757 return new Minimatch(pattern, options).match(p);
23760 function Minimatch(pattern, options) {
23761 if (!(this instanceof Minimatch)) {
23762 return new Minimatch(pattern, options, cache);
23765 if (typeof pattern !== "string") {
23766 throw new TypeError("glob pattern string required");
23769 if (!options) options = {}; // windows: need to use /, not \
23770 // On other platforms, \ is a valid (albeit bad) filename char.
23772 if (platform === "win32") {
23773 pattern = pattern.split("\\").join("/");
23775 // these things aren't particularly big, but walking down the string
23776 // and turning it into a regexp can get pretty costly.
23779 var cacheKey = pattern + "\n" + sigmund(options);
23780 var cached = minimatch.cache.get(cacheKey);
23781 if (cached) return cached;
23782 minimatch.cache.set(cacheKey, this);
23783 this.options = options;
23785 this.pattern = pattern;
23786 this.regexp = null;
23787 this.negate = false;
23788 this.comment = false;
23789 this.empty = false; // make the set of regexps etc.
23794 Minimatch.prototype.make = make;
23797 // don't do it more than once.
23798 if (this._made) return;
23799 var pattern = this.pattern;
23800 var options = this.options; // empty patterns and comments match nothing.
23802 if (!options.nocomment && pattern.charAt(0) === "#") {
23803 this.comment = true;
23810 } // step 1: figure out negation, etc.
23813 this.parseNegate(); // step 2: expand braces
23815 var set = this.globSet = this.braceExpand();
23816 if (options.debug) console.error(this.pattern, set); // step 3: now we have a set, so turn each one into a series of path-portion
23817 // matching patterns.
23818 // These will be regexps, except in the case of "**", which is
23819 // set to the GLOBSTAR object for globstar behavior,
23820 // and will not contain any / characters
23822 set = this.globParts = set.map(function (s) {
23823 return s.split(slashSplit);
23825 if (options.debug) console.error(this.pattern, set); // glob --> regexps
23827 set = set.map(function (s, si, set) {
23828 return s.map(this.parse, this);
23830 if (options.debug) console.error(this.pattern, set); // filter out everything that didn't compile properly.
23832 set = set.filter(function (s) {
23833 return -1 === s.indexOf(false);
23835 if (options.debug) console.error(this.pattern, set);
23839 Minimatch.prototype.parseNegate = parseNegate;
23841 function parseNegate() {
23842 var pattern = this.pattern,
23844 options = this.options,
23846 if (options.nonegate) return;
23848 for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === "!"; i++) {
23853 if (negateOffset) this.pattern = pattern.substr(negateOffset);
23854 this.negate = negate;
23855 } // Brace expansion:
23856 // a{b,c}d -> abd acd
23857 // a{b,}c -> abc ac
23858 // a{0..3}d -> a0d a1d a2d a3d
23859 // a{b,c{d,e}f}g -> abg acdfg acefg
23860 // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
23862 // Invalid sets are not expanded.
23863 // a{2..}b -> a{2..}b
23867 minimatch.braceExpand = function (pattern, options) {
23868 return new Minimatch(pattern, options).braceExpand();
23871 Minimatch.prototype.braceExpand = braceExpand;
23873 function braceExpand(pattern, options) {
23874 options = options || this.options;
23875 pattern = typeof pattern === "undefined" ? this.pattern : pattern;
23877 if (typeof pattern === "undefined") {
23878 throw new Error("undefined pattern");
23881 if (options.nobrace || !pattern.match(/\{.*\}/)) {
23882 // shortcut. no need to expand.
23886 var escaping = false; // examples and comments refer to this crazy pattern:
23887 // a{b,c{d,e},{f,g}h}x{y,z}
23899 // everything before the first \{ is just a prefix.
23900 // So, we pluck that off, and work with the rest,
23901 // and then prepend it to everything we find.
23903 if (pattern.charAt(0) !== "{") {
23904 // console.error(pattern)
23907 for (var i = 0, l = pattern.length; i < l; i++) {
23908 var c = pattern.charAt(i); // console.error(i, c)
23911 escaping = !escaping;
23912 } else if (c === "{" && !escaping) {
23913 prefix = pattern.substr(0, i);
23916 } // actually no sets, all { were escaped.
23919 if (prefix === null) {
23920 // console.error("no sets")
23924 var tail = braceExpand(pattern.substr(i), options);
23925 return tail.map(function (t) {
23928 } // now we have something like:
23929 // {b,c{d,e},{f,g}h}x{y,z}
23930 // walk through the set, expanding each part, until
23931 // the set ends. then, we'll expand the suffix.
23932 // If the set only has a single member, then'll put the {} back
23933 // first, handle numeric sets, since they're easier
23936 var numset = pattern.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/);
23939 // console.error("numset", numset[1], numset[2])
23940 var suf = braceExpand(pattern.substr(numset[0].length), options),
23941 start = +numset[1],
23943 inc = start > end ? -1 : 1,
23946 for (var i = start; i != end + inc; i += inc) {
23947 // append all the suffixes
23948 for (var ii = 0, ll = suf.length; ii < ll; ii++) {
23949 set.push(i + suf[ii]);
23954 } // ok, walk through the set
23955 // We hope, somewhat optimistically, that there
23956 // will be a } at the end.
23957 // If the closing brace isn't found, then the pattern is
23958 // interpreted as braceExpand("\\" + pattern) so that
23959 // the leading \{ will be interpreted literally.
23962 var i = 1 // skip the \{
23969 function addMember() {
23972 } // console.error("Entering for")
23975 FOR: for (i = 1, l = pattern.length; i < l; i++) {
23976 var c = pattern.charAt(i); // console.error("", i, c)
23980 member += "\\" + c;
23993 depth--; // if this closes the actual set, then we're done
23996 addMember(); // pluck off the close-brace
24022 // now we've either finished the set, and the suffix is
24023 // pattern.substr(i), or we have *not* closed the set,
24024 // and need to escape the leading brace
24028 // console.error("didn't close", pattern)
24029 return braceExpand("\\" + pattern, options);
24030 } // x{y,z} -> ["xy", "xz"]
24031 // console.error("set", set)
24032 // console.error("suffix", pattern.substr(i))
24035 var suf = braceExpand(pattern.substr(i), options); // ["b", "c{d,e}","{f,g}h"] ->
24036 // [["b"], ["cd", "ce"], ["fh", "gh"]]
24038 var addBraces = set.length === 1; // console.error("set pre-expanded", set)
24040 set = set.map(function (p) {
24041 return braceExpand(p, options);
24042 }); // console.error("set expanded", set)
24043 // [["b"], ["cd", "ce"], ["fh", "gh"]] ->
24044 // ["b", "cd", "ce", "fh", "gh"]
24046 set = set.reduce(function (l, r) {
24047 return l.concat(r);
24051 set = set.map(function (s) {
24052 return "{" + s + "}";
24054 } // now attach the suffixes.
24059 for (var i = 0, l = set.length; i < l; i++) {
24060 for (var ii = 0, ll = suf.length; ii < ll; ii++) {
24061 ret.push(set[i] + suf[ii]);
24066 } // parse a component of the expanded set.
24067 // At this point, no pattern may contain "/" in it
24068 // so we're going to return a 2d array, where each entry is the full
24069 // pattern, split on '/', and then turned into a regular expression.
24070 // A regexp is made at the end which joins each array with an
24071 // escaped /, and another full one which joins each regexp with |.
24073 // Following the lead of Bash 4.1, note that "**" only has special meaning
24074 // when it is the *only* thing in a path portion. Otherwise, any series
24075 // of * is equivalent to a single *. Globstar behavior is enabled by
24076 // default, and can be disabled by setting options.noglobstar.
24079 Minimatch.prototype.parse = parse;
24082 function parse(pattern, isSub) {
24083 var options = this.options; // shortcuts
24085 if (!options.noglobstar && pattern === "**") return GLOBSTAR;
24086 if (pattern === "") return "";
24088 hasMagic = !!options.nocase,
24089 escaping = false // ? => one single character
24091 patternListStack = [],
24096 classStart = -1 // . and .. never match anything that doesn't start with .,
24097 // even when options.dot is set.
24099 patternStart = pattern.charAt(0) === "." ? "" // anything
24100 // not (start or / followed by . or .. followed by / or end)
24101 : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))" : "(?!\\.)";
24103 function clearStateChar() {
24105 // we had some state-tracking character
24106 // that wasn't consumed by this pass.
24107 switch (stateChar) {
24119 re += "\\" + stateChar;
24127 for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
24128 if (options.debug) {
24129 console.error("%s\t%s %s %j", pattern, i, re, c);
24130 } // skip over any that are escaped.
24133 if (escaping && reSpecials[c]) {
24141 // completely not allowed, even escaped.
24142 // Should already be path-split by now.
24149 // the various stateChar values
24150 // for the "extglob" stuff.
24157 if (options.debug) {
24158 console.error("%s\t%s %s %j <-- stateChar", pattern, i, re, c);
24159 } // all of those are literals inside a class, except that
24160 // the glob [!a] means [^a] in regexp
24164 if (c === "!" && i === classStart + 1) c = "^";
24167 } // if we already have a stateChar, then it means
24168 // that there was something like ** or +? in there.
24169 // Handle the stateChar, then proceed with this one.
24173 stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing.
24174 // just clear the statechar *now*, rather than even diving into
24175 // the patternList stuff.
24177 if (options.noext) clearStateChar();
24191 plType = stateChar;
24192 patternListStack.push({
24196 }); // negation is (?:(?!js)[^/]*)
24198 re += stateChar === "!" ? "(?:(?!" : "(?:";
24203 if (inClass || !patternListStack.length) {
24210 plType = patternListStack.pop().type; // negation is (?:(?!js)[^/]*)
24211 // The others are (?:<pattern>)<type>
24222 // the default anyway
24228 if (inClass || !patternListStack.length || escaping) {
24236 // these are mostly the same in regexp and glob
24239 // swallow any state-tracking char before the [
24249 reClassStart = re.length;
24254 // a right bracket shall lose its special
24255 // meaning and represent itself in
24256 // a bracket expression if it occurs
24257 // first in the list. -- POSIX.2 2.8.3.2
24258 if (i === classStart + 1 || !inClass) {
24262 } // finish up the class.
24271 // swallow any state char that wasn't consumed
24277 } else if (reSpecials[c] && !(c === "^" && inClass)) {
24285 // handle the case where we left a class open.
24286 // "[abc" is valid, equivalent to "\[abc"
24290 // split where the last [ was, and escape it
24291 // this is a huge pita. We now have to re-walk
24292 // the contents of the would-be class to re-translate
24293 // any characters that were passed through as-is
24294 var cs = pattern.substr(classStart + 1),
24295 sp = this.parse(cs, SUBPARSE);
24296 re = re.substr(0, reClassStart) + "\\[" + sp[0];
24297 hasMagic = hasMagic || sp[1];
24298 } // handle the case where we had a +( thing at the *end*
24300 // each pattern list stack adds 3 chars, and we need to go through
24301 // and escape any | chars that were passed through as-is for the regexp.
24302 // Go through and escape them, taking care not to double-escape any
24303 // | chars that were already escaped.
24308 while (pl = patternListStack.pop()) {
24309 var tail = re.slice(pl.reStart + 3); // maybe some even number of \, then maybe 1 \, followed by a |
24311 tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) {
24313 // the | isn't already escaped, so escape it.
24315 } // need to escape all those slashes *again*, without escaping the
24316 // one that we need for escaping the | character. As it works out,
24317 // escaping an even number of slashes can be done by simply repeating
24318 // it exactly after itself. That's why this trick works.
24320 // I am sorry that you have to see this.
24323 return $1 + $1 + $2 + "|";
24324 }); // console.error("tail=%j\n %s", tail, tail)
24326 var t = pl.type === "*" ? star : pl.type === "?" ? qmark : "\\" + pl.type;
24328 re = re.slice(0, pl.reStart) + t + "\\(" + tail;
24329 } // handle trailing things that only matter at the very end.
24337 } // only need to apply the nodot start if the re starts with
24338 // something that could conceivably capture a dot
24341 var addPatternStart = false;
24343 switch (re.charAt(0)) {
24347 addPatternStart = true;
24348 } // if the re is not "" at this point, then we need to make sure
24349 // it doesn't match against an empty path part.
24350 // Otherwise a/* will match a/, which it should not.
24353 if (re !== "" && hasMagic) re = "(?=.)" + re;
24354 if (addPatternStart) re = patternStart + re; // parsing just a piece of a larger pattern.
24356 if (isSub === SUBPARSE) {
24357 return [re, hasMagic];
24358 } // skip the regexp for non-magical patterns
24359 // unescape anything in it, though, so that it'll be
24360 // an exact match against a file etc.
24364 return globUnescape(pattern);
24367 var flags = options.nocase ? "i" : "",
24368 regExp = new RegExp("^" + re + "$", flags);
24369 regExp._glob = pattern;
24374 minimatch.makeRe = function (pattern, options) {
24375 return new Minimatch(pattern, options || {}).makeRe();
24378 Minimatch.prototype.makeRe = makeRe;
24380 function makeRe() {
24381 if (this.regexp || this.regexp === false) return this.regexp; // at this point, this.set is a 2d array of partial
24382 // pattern strings, or "**".
24384 // It's better to use .match(). This function shouldn't
24385 // be used, really, but it's pretty convenient sometimes,
24386 // when you just want to work with a regex.
24388 var set = this.set;
24389 if (!set.length) return this.regexp = false;
24390 var options = this.options;
24391 var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot,
24392 flags = options.nocase ? "i" : "";
24393 var re = set.map(function (pattern) {
24394 return pattern.map(function (p) {
24395 return p === GLOBSTAR ? twoStar : typeof p === "string" ? regExpEscape(p) : p._src;
24397 }).join("|"); // must match entire pattern
24398 // ending in a * or ** will make it less strict.
24400 re = "^(?:" + re + ")$"; // can match anything, as long as it's not this.
24402 if (this.negate) re = "^(?!" + re + ").*$";
24405 return this.regexp = new RegExp(re, flags);
24407 return this.regexp = false;
24411 minimatch.match = function (list, pattern, options) {
24412 var mm = new Minimatch(pattern, options);
24413 list = list.filter(function (f) {
24414 return mm.match(f);
24417 if (options.nonull && !list.length) {
24418 list.push(pattern);
24424 Minimatch.prototype.match = match;
24426 function match(f, partial) {
24427 // console.error("match", f, this.pattern)
24428 // short-circuit in the case of busted things.
24430 if (this.comment) return false;
24431 if (this.empty) return f === "";
24432 if (f === "/" && partial) return true;
24433 var options = this.options; // windows: need to use /, not \
24434 // On other platforms, \ is a valid (albeit bad) filename char.
24436 if (platform === "win32") {
24437 f = f.split("\\").join("/");
24438 } // treat the test path as a set of pathparts.
24441 f = f.split(slashSplit);
24443 if (options.debug) {
24444 console.error(this.pattern, "split", f);
24445 } // just ONE of the pattern sets in this.set needs to match
24446 // in order for it to be valid. If negating, then just one
24447 // match means that we have failed.
24448 // Either way, return on the first hit.
24451 var set = this.set; // console.error(this.pattern, "set", set)
24453 for (var i = 0, l = set.length; i < l; i++) {
24454 var pattern = set[i];
24455 var hit = this.matchOne(f, pattern, partial);
24458 if (options.flipNegate) return true;
24459 return !this.negate;
24461 } // didn't get any hits. this is success if it's a negative
24462 // pattern, failure otherwise.
24465 if (options.flipNegate) return false;
24466 return this.negate;
24467 } // set partial to true to test if, for example,
24468 // "/a/b" matches the start of "/*/b/*/d"
24469 // Partial means, if you run out of file before you run
24470 // out of pattern, then that's fine, as long as all
24471 // the parts match.
24474 Minimatch.prototype.matchOne = function (file, pattern, partial) {
24475 var options = this.options;
24477 if (options.debug) {
24478 console.error("matchOne", {
24485 if (options.matchBase && pattern.length === 1) {
24486 file = path.basename(file.join("/")).split("/");
24489 if (options.debug) {
24490 console.error("matchOne", file.length, pattern.length);
24493 for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
24494 if (options.debug) {
24495 console.error("matchOne loop");
24498 var p = pattern[pi],
24501 if (options.debug) {
24502 console.error(pattern, p, f);
24503 } // should be impossible.
24504 // some invalid regexp stuff in the set.
24507 if (p === false) return false;
24509 if (p === GLOBSTAR) {
24510 if (options.debug) console.error('GLOBSTAR', [pattern, p, f]); // "**"
24511 // a/**/b/**/c would match the following:
24516 // To do this, take the rest of the pattern after
24517 // the **, and see if it would match the file remainder.
24518 // If so, return success.
24519 // If not, the ** "swallows" a segment, and try again.
24520 // This is recursively awful.
24522 // a/**/b/**/c matching a/b/x/y/z/c
24525 // - matchOne(b/x/y/z/c, b/**/c)
24528 // - matchOne(x/y/z/c, c) -> no
24529 // - matchOne(y/z/c, c) -> no
24530 // - matchOne(z/c, c) -> no
24531 // - matchOne(c, c) yes, hit
24537 if (options.debug) console.error('** at the end'); // a ** at the end will just swallow the rest.
24538 // We have found a match.
24539 // however, it will not swallow /.x, unless
24540 // options.dot is set.
24541 // . and .. are *never* matched by **, for explosively
24542 // exponential reasons.
24544 for (; fi < fl; fi++) {
24545 if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".") return false;
24549 } // ok, let's see if we can swallow whatever we can.
24552 WHILE: while (fr < fl) {
24553 var swallowee = file[fr];
24555 if (options.debug) {
24556 console.error('\nglobstar while', file, fr, pattern, pr, swallowee);
24557 } // XXX remove this slice. Just pass the start index.
24560 if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
24561 if (options.debug) console.error('globstar found match!', fr, fl, swallowee); // found a match.
24565 // can't swallow "." or ".." ever.
24566 // can only swallow ".foo" when explicitly asked.
24567 if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
24568 if (options.debug) console.error("dot detected!", file, fr, pattern, pr);
24570 } // ** swallows a segment, and continue.
24573 if (options.debug) console.error('globstar swallow a segment, and continue');
24576 } // no match was found.
24577 // However, in partial mode, we can't say this is necessarily over.
24578 // If there's more *pattern* left, then
24583 // console.error("\n>>> no match, partial?", file, fr, pattern, pr)
24584 if (fr === fl) return true;
24588 } // something other than **
24589 // non-magic patterns just have to match exactly
24590 // patterns with magic have been turned into regexps.
24595 if (typeof p === "string") {
24596 if (options.nocase) {
24597 hit = f.toLowerCase() === p.toLowerCase();
24602 if (options.debug) {
24603 console.error("string match", p, f, hit);
24608 if (options.debug) {
24609 console.error("pattern match", p, f, hit);
24613 if (!hit) return false;
24614 } // Note: ending in / means that we'll get a final ""
24615 // at the end of the pattern. This can only match a
24616 // corresponding "" at the end of the file.
24617 // If the file ends in /, then it can only match a
24618 // a pattern that ends in /, unless the pattern just
24619 // doesn't have any more for it. But, a/b/ should *not*
24620 // match "a/b/*", even though "" matches against the
24621 // [^/]*? pattern, except in partial mode, where it might
24622 // simply not be reached yet.
24623 // However, a/b/ should still satisfy a/*
24624 // now either we fell off the end of the pattern, or we're done.
24627 if (fi === fl && pi === pl) {
24628 // ran out of pattern and filename at the same time.
24631 } else if (fi === fl) {
24632 // ran out of file, but still had pattern left.
24633 // this is ok if we're doing the match as part of
24634 // a glob fs traversal.
24636 } else if (pi === pl) {
24637 // ran out of pattern, still have file left.
24638 // this is only acceptable if we're on the very last
24639 // empty segment of a file with a trailing slash.
24640 // a/* should match a/b/
24641 var emptyFileEnd = fi === fl - 1 && file[fi] === "";
24642 return emptyFileEnd;
24643 } // should be unreachable.
24646 throw new Error("wtf?");
24647 }; // replace stuff like \* with *
24650 function globUnescape(s) {
24651 return s.replace(/\\(.)/g, "$1");
24654 function regExpEscape(s) {
24655 return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
24657 })(fnmatch$1, fnmatch$1.exports);
24661 var __awaiter$1 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
24662 return new (P || (P = Promise))(function (resolve, reject) {
24663 function fulfilled(value) {
24665 step(generator.next(value));
24671 function rejected(value) {
24673 step(generator["throw"](value));
24679 function step(result) {
24680 result.done ? resolve(result.value) : new P(function (resolve) {
24681 resolve(result.value);
24682 }).then(fulfilled, rejected);
24685 step((generator = generator.apply(thisArg, _arguments || [])).next());
24689 var __generator$1 = undefined && undefined.__generator || function (thisArg, body) {
24692 sent: function () {
24693 if (t[0] & 1) throw t[1];
24707 }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
24712 return function (v) {
24713 return step([n, v]);
24717 function step(op) {
24718 if (f) throw new TypeError("Generator is already executing.");
24721 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
24722 if (y = 0, t) op = [op[0] & 2, t.value];
24751 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
24756 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
24761 if (op[0] === 6 && _.label < t[1]) {
24767 if (t && _.label < t[2]) {
24775 if (t[2]) _.ops.pop();
24782 op = body.call(thisArg, _);
24790 if (op[0] & 5) throw op[1];
24792 value: op[0] ? op[1] : void 0,
24798 var __importStar$1 = undefined && undefined.__importStar || function (mod) {
24799 if (mod && mod.__esModule) return mod;
24801 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
24802 result["default"] = mod;
24806 Object.defineProperty(ini, "__esModule", {
24810 var fs$f = __importStar$1(require$$0__default["default"]);
24812 * define the possible values:
\r
24813 * section: [section]
\r
24814 * param: key=value
\r
24815 * comment: ;this is a comment
\r
24820 section: /^\s*\[(([^#;]|\\#|\\;)+)\]\s*([#;].*)?$/,
24821 param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/,
24822 comment: /^\s*[#;].*$/
24825 * Parses an .ini file
\r
24826 * @param file The location of the .ini file
\r
24829 function parse$7(file) {
24830 return __awaiter$1(this, void 0, void 0, function () {
24831 return __generator$1(this, function (_a) {
24834 , new Promise(function (resolve, reject) {
24835 fs$f.readFile(file, 'utf8', function (err, data) {
24841 resolve(parseString(data));
24848 ini.parse = parse$7;
24850 function parseSync$1(file) {
24851 return parseString(fs$f.readFileSync(file, 'utf8'));
24854 ini.parseSync = parseSync$1;
24856 function parseString(data) {
24857 var sectionBody = {};
24858 var sectionName = null;
24859 var value = [[sectionName, sectionBody]];
24860 var lines = data.split(/\r\n|\r|\n/);
24861 lines.forEach(function (line) {
24864 if (regex.comment.test(line)) {
24868 if (regex.param.test(line)) {
24869 match = line.match(regex.param);
24870 sectionBody[match[1]] = match[2];
24871 } else if (regex.section.test(line)) {
24872 match = line.match(regex.section);
24873 sectionName = match[1];
24875 value.push([sectionName, sectionBody]);
24881 ini.parseString = parseString;
24883 var name$g = "editorconfig";
24884 var version$1 = "0.15.3";
24885 var description = "EditorConfig File Locator and Interpreter for Node.js";
24890 var main = "src/index.js";
24891 var contributors = [
24892 "Hong Xu (topbug.net)",
24893 "Jed Mao (https://github.com/jedmao/)",
24894 "Trey Hunner (http://treyhunner.com)"
24896 var directories = {
24901 clean: "rimraf dist",
24902 prebuild: "npm run clean",
24904 pretest: "npm run lint && npm run build && npm run copy && cmake .",
24906 "pretest:ci": "npm run pretest",
24907 "test:ci": "ctest -VV --output-on-failure .",
24908 lint: "npm run eclint && npm run tslint",
24909 eclint: "eclint check --indent_size ignore \"src/**\"",
24910 tslint: "tslint --project tsconfig.json --exclude package.json",
24911 copy: "cpy .npmignore LICENSE README.md CHANGELOG.md dist && cpy bin/* dist/bin && cpy src/lib/fnmatch*.* dist/src/lib",
24912 prepub: "npm run lint && npm run build && npm run copy",
24913 pub: "npm publish ./dist"
24917 url: "git://github.com/editorconfig/editorconfig-core-js.git"
24919 var bugs = "https://github.com/editorconfig/editorconfig-core-js/issues";
24920 var author = "EditorConfig Team";
24921 var license = "MIT";
24922 var dependencies = {
24923 commander: "^2.19.0",
24924 "lru-cache": "^4.1.5",
24928 var devDependencies = {
24929 "@types/mocha": "^5.2.6",
24930 "@types/node": "^10.12.29",
24931 "@types/semver": "^5.5.0",
24932 "cpy-cli": "^2.0.0",
24938 typescript: "^3.3.3333"
24940 var require$$5$4 = {
24942 version: version$1,
24943 description: description,
24944 keywords: keywords,
24946 contributors: contributors,
24947 directories: directories,
24949 repository: repository,
24953 dependencies: dependencies,
24954 devDependencies: devDependencies
24957 var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
24958 return new (P || (P = Promise))(function (resolve, reject) {
24959 function fulfilled(value) {
24961 step(generator.next(value));
24967 function rejected(value) {
24969 step(generator["throw"](value));
24975 function step(result) {
24976 result.done ? resolve(result.value) : new P(function (resolve) {
24977 resolve(result.value);
24978 }).then(fulfilled, rejected);
24981 step((generator = generator.apply(thisArg, _arguments || [])).next());
24985 var __generator = undefined && undefined.__generator || function (thisArg, body) {
24988 sent: function () {
24989 if (t[0] & 1) throw t[1];
25003 }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
25008 return function (v) {
25009 return step([n, v]);
25013 function step(op) {
25014 if (f) throw new TypeError("Generator is already executing.");
25017 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
25018 if (y = 0, t) op = [op[0] & 2, t.value];
25047 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
25052 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
25057 if (op[0] === 6 && _.label < t[1]) {
25063 if (t && _.label < t[2]) {
25071 if (t[2]) _.ops.pop();
25078 op = body.call(thisArg, _);
25086 if (op[0] & 5) throw op[1];
25088 value: op[0] ? op[1] : void 0,
25094 var __importStar = undefined && undefined.__importStar || function (mod) {
25095 if (mod && mod.__esModule) return mod;
25097 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
25098 result["default"] = mod;
25102 var __importDefault = undefined && undefined.__importDefault || function (mod) {
25103 return mod && mod.__esModule ? mod : {
25108 Object.defineProperty(src$1, "__esModule", {
25112 var fs$e = __importStar(require$$0__default["default"]);
25114 var path$i = __importStar(require$$0__default$2["default"]);
25116 var semver = __importStar(semver$1.exports);
25118 var fnmatch_1 = __importDefault(fnmatch$1.exports);
25121 src$1.parseString = ini_1.parseString;
25123 var package_json_1 = __importDefault(require$$5$4);
25127 indent_style: true,
25129 insert_final_newline: true,
25130 trim_trailing_whitespace: true,
25134 function fnmatch(filepath, glob) {
25135 var matchOptions = {
25140 glob = glob.replace(/\*\*/g, '{*,**/**/**}');
25141 return fnmatch_1.default(filepath, glob, matchOptions);
25144 function getConfigFileNames(filepath, options) {
25148 filepath = path$i.dirname(filepath);
25149 paths.push(path$i.join(filepath, options.config));
25150 } while (filepath !== options.root);
25155 function processMatches(matches, version) {
25156 // Set indent_size to 'tab' if indent_size is unspecified and
25157 // indent_style is set to 'tab'.
25158 if ('indent_style' in matches && matches.indent_style === 'tab' && !('indent_size' in matches) && semver.gte(version, '0.10.0')) {
25159 matches.indent_size = 'tab';
25160 } // Set tab_width to indent_size if indent_size is specified and
25161 // tab_width is unspecified
25164 if ('indent_size' in matches && !('tab_width' in matches) && matches.indent_size !== 'tab') {
25165 matches.tab_width = matches.indent_size;
25166 } // Set indent_size to tab_width if indent_size is 'tab'
25169 if ('indent_size' in matches && 'tab_width' in matches && matches.indent_size === 'tab') {
25170 matches.indent_size = matches.tab_width;
25176 function processOptions(options, filepath) {
25177 if (options === void 0) {
25182 config: options.config || '.editorconfig',
25183 version: options.version || package_json_1.default.version,
25184 root: path$i.resolve(options.root || path$i.parse(filepath).root)
25188 function buildFullGlob(pathPrefix, glob) {
25189 switch (glob.indexOf('/')) {
25191 glob = '**/' + glob;
25195 glob = glob.substring(1);
25199 return path$i.join(pathPrefix, glob);
25202 function extendProps(props, options) {
25203 if (props === void 0) {
25207 if (options === void 0) {
25211 for (var key in options) {
25212 if (options.hasOwnProperty(key)) {
25213 var value = options[key];
25214 var key2 = key.toLowerCase();
25215 var value2 = value;
25217 if (knownProps[key2]) {
25218 value2 = value.toLowerCase();
25222 value2 = JSON.parse(value);
25225 if (typeof value === 'undefined' || value === null) {
25226 // null and undefined are values specific to JSON (no special meaning
25227 // in editorconfig) & should just be returned as regular strings.
25228 value2 = String(value);
25231 props[key2] = value2;
25238 function parseFromConfigs(configs, filepath, options) {
25239 return processMatches(configs.reverse().reduce(function (matches, file) {
25240 var pathPrefix = path$i.dirname(file.name);
25241 file.contents.forEach(function (section) {
25242 var glob = section[0];
25243 var options2 = section[1];
25249 var fullGlob = buildFullGlob(pathPrefix, glob);
25251 if (!fnmatch(filepath, fullGlob)) {
25255 matches = extendProps(matches, options2);
25258 }, {}), options.version);
25261 function getConfigsForFiles(files) {
25264 for (var i in files) {
25265 if (files.hasOwnProperty(i)) {
25266 var file = files[i];
25267 var contents = ini_1.parseString(file.contents);
25273 if ((contents[0][1].root || '').toLowerCase() === 'true') {
25282 function readConfigFiles(filepaths) {
25283 return __awaiter(this, void 0, void 0, function () {
25284 return __generator(this, function (_a) {
25287 , Promise.all(filepaths.map(function (name) {
25288 return new Promise(function (resolve) {
25289 fs$e.readFile(name, 'utf8', function (err, data) {
25292 contents: err ? '' : data
25301 function readConfigFilesSync(filepaths) {
25304 filepaths.forEach(function (filepath) {
25306 file = fs$e.readFileSync(filepath, 'utf8');
25319 function opts(filepath, options) {
25320 if (options === void 0) {
25324 var resolvedFilePath = path$i.resolve(filepath);
25325 return [resolvedFilePath, processOptions(options, resolvedFilePath)];
25328 function parseFromFiles(filepath, files, options) {
25329 if (options === void 0) {
25333 return __awaiter(this, void 0, void 0, function () {
25334 var _a, resolvedFilePath, processedOptions;
25336 return __generator(this, function (_b) {
25337 _a = opts(filepath, options), resolvedFilePath = _a[0], processedOptions = _a[1];
25340 , files.then(getConfigsForFiles).then(function (configs) {
25341 return parseFromConfigs(configs, resolvedFilePath, processedOptions);
25347 src$1.parseFromFiles = parseFromFiles;
25349 function parseFromFilesSync(filepath, files, options) {
25350 if (options === void 0) {
25354 var _a = opts(filepath, options),
25355 resolvedFilePath = _a[0],
25356 processedOptions = _a[1];
25358 return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
25361 src$1.parseFromFilesSync = parseFromFilesSync;
25363 function parse$6(_filepath, _options) {
25364 if (_options === void 0) {
25368 return __awaiter(this, void 0, void 0, function () {
25369 var _a, resolvedFilePath, processedOptions, filepaths;
25371 return __generator(this, function (_b) {
25372 _a = opts(_filepath, _options), resolvedFilePath = _a[0], processedOptions = _a[1];
25373 filepaths = getConfigFileNames(resolvedFilePath, processedOptions);
25376 , readConfigFiles(filepaths).then(getConfigsForFiles).then(function (configs) {
25377 return parseFromConfigs(configs, resolvedFilePath, processedOptions);
25383 src$1.parse = parse$6;
25385 function parseSync(_filepath, _options) {
25386 if (_options === void 0) {
25390 var _a = opts(_filepath, _options),
25391 resolvedFilePath = _a[0],
25392 processedOptions = _a[1];
25394 var filepaths = getConfigFileNames(resolvedFilePath, processedOptions);
25395 var files = readConfigFilesSync(filepaths);
25396 return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
25399 src$1.parseSync = parseSync;
25401 var editorconfigToPrettier = editorConfigToPrettier$1;
25403 function removeUnset(editorConfig) {
25405 const keys = Object.keys(editorConfig);
25407 for (let i = 0; i < keys.length; i++) {
25408 const key = keys[i];
25410 if (editorConfig[key] === "unset") {
25414 result[key] = editorConfig[key];
25420 function editorConfigToPrettier$1(editorConfig) {
25421 if (!editorConfig) {
25425 editorConfig = removeUnset(editorConfig);
25427 if (Object.keys(editorConfig).length === 0) {
25433 if (editorConfig.indent_style) {
25434 result.useTabs = editorConfig.indent_style === "tab";
25437 if (editorConfig.indent_size === "tab") {
25438 result.useTabs = true;
25441 if (result.useTabs && editorConfig.tab_width) {
25442 result.tabWidth = editorConfig.tab_width;
25443 } else if (editorConfig.indent_style === "space" && editorConfig.indent_size && editorConfig.indent_size !== "tab") {
25444 result.tabWidth = editorConfig.indent_size;
25445 } else if (editorConfig.tab_width !== undefined) {
25446 result.tabWidth = editorConfig.tab_width;
25449 if (editorConfig.max_line_length && editorConfig.max_line_length !== "off") {
25450 result.printWidth = editorConfig.max_line_length;
25453 if (editorConfig.quote_type === "single") {
25454 result.singleQuote = true;
25455 } else if (editorConfig.quote_type === "double") {
25456 result.singleQuote = false;
25459 if (["cr", "crlf", "lf"].indexOf(editorConfig.end_of_line) !== -1) {
25460 result.endOfLine = editorConfig.end_of_line;
25463 if (editorConfig.insert_final_newline === false || editorConfig.insert_final_newline === true) {
25464 result.insertFinalNewline = editorConfig.insert_final_newline;
25470 // https://github.com/kirstein/find-project-root/blob/master/index.js
25473 const fs$d = require$$0__default["default"];
25474 const path$h = require$$0__default$2["default"];
25475 const MARKERS = [".git", ".hg"];
25477 const markerExists = directory => MARKERS.some(mark => fs$d.existsSync(path$h.join(directory, mark)));
25479 function findProjectRoot$1(directory) {
25480 while (!markerExists(directory)) {
25481 const parentDirectory = path$h.resolve(directory, "..");
25483 if (parentDirectory === directory) {
25487 directory = parentDirectory;
25493 var findProjectRoot_1 = findProjectRoot$1;
25495 const path$g = require$$0__default$2["default"];
25496 const editorconfig = src$1;
25497 const mem$2 = dist$1;
25498 const editorConfigToPrettier = editorconfigToPrettier;
25499 const findProjectRoot = findProjectRoot_1;
25501 const jsonStringifyMem = fn => mem$2(fn, {
25502 cacheKey: JSON.stringify
25505 const maybeParse = (filePath, parse) => filePath && parse(filePath, {
25506 root: findProjectRoot(path$g.dirname(path$g.resolve(filePath)))
25509 const editorconfigAsyncNoCache = async filePath => editorConfigToPrettier(await maybeParse(filePath, editorconfig.parse));
25511 const editorconfigAsyncWithCache = jsonStringifyMem(editorconfigAsyncNoCache);
25513 const editorconfigSyncNoCache = filePath => editorConfigToPrettier(maybeParse(filePath, editorconfig.parseSync));
25515 const editorconfigSyncWithCache = jsonStringifyMem(editorconfigSyncNoCache);
25517 function getLoadFunction(opts) {
25518 if (!opts.editorconfig) {
25523 return opts.cache ? editorconfigSyncWithCache : editorconfigSyncNoCache;
25526 return opts.cache ? editorconfigAsyncWithCache : editorconfigAsyncNoCache;
25529 function clearCache$2() {
25530 mem$2.clear(editorconfigSyncWithCache);
25531 mem$2.clear(editorconfigAsyncWithCache);
25534 var resolveConfigEditorconfig = {
25536 clearCache: clearCache$2
25539 const _excluded$1 = ["overrides"];
25541 const path$f = require$$0__default$2["default"];
25542 const minimatch = minimatch_1;
25543 const mem$1 = dist$1;
25544 const thirdParty$1 = require$$7$2;
25545 const loadToml = loadToml$1;
25546 const loadJson5 = loadJson5$1;
25547 const resolve$1 = resolve_1;
25548 const resolveEditorConfig = resolveConfigEditorconfig;
25550 * @typedef {import("cosmiconfig/dist/Explorer").Explorer} Explorer
25551 * @typedef {{sync: boolean; cache: boolean }} Options
25555 * @type {(opts: Options) => Explorer}
25558 const getExplorerMemoized = mem$1(opts => {
25559 const cosmiconfig = thirdParty$1["cosmiconfig" + (opts.sync ? "Sync" : "")];
25560 const explorer = cosmiconfig("prettier", {
25562 transform: result => {
25563 if (result && result.config) {
25564 if (typeof result.config === "string") {
25565 const dir = path$f.dirname(result.filepath);
25566 const modulePath = resolve$1(result.config, {
25569 result.config = require(modulePath);
25572 if (typeof result.config !== "object") {
25573 throw new TypeError("Config is only allowed to be an object, " + `but received ${typeof result.config} in "${result.filepath}"`);
25576 delete result.config.$schema;
25581 searchPlaces: ["package.json", ".prettierrc", ".prettierrc.json", ".prettierrc.yaml", ".prettierrc.yml", ".prettierrc.json5", ".prettierrc.js", ".prettierrc.cjs", "prettier.config.js", "prettier.config.cjs", ".prettierrc.toml"],
25584 ".json5": loadJson5
25589 cacheKey: JSON.stringify
25592 * @param {Options} opts
25593 * @return {Explorer}
25596 function getExplorer(opts) {
25597 // Normalize opts before passing to a memoized function
25598 opts = Object.assign({
25602 return getExplorerMemoized(opts);
25605 function _resolveConfig(filePath, opts, sync) {
25606 opts = Object.assign({
25610 cache: Boolean(opts.useCache),
25611 sync: Boolean(sync),
25612 editorconfig: Boolean(opts.editorconfig)
25617 } = getExplorer(loadOpts);
25618 const loadEditorConfig = resolveEditorConfig.getLoadFunction(loadOpts);
25619 const arr = [opts.config ? load(opts.config) : search(filePath), loadEditorConfig(filePath)];
25621 const unwrapAndMerge = ([result, editorConfigured]) => {
25622 const merged = Object.assign(Object.assign({}, editorConfigured), mergeOverrides(result, filePath));
25624 for (const optionName of ["plugins", "pluginSearchDirs"]) {
25625 if (Array.isArray(merged[optionName])) {
25626 merged[optionName] = merged[optionName].map(value => typeof value === "string" && value.startsWith(".") // relative path
25627 ? path$f.resolve(path$f.dirname(result.filepath), value) : value);
25631 if (!result && !editorConfigured) {
25633 } // We are not using this option
25636 delete merged.insertFinalNewline;
25640 if (loadOpts.sync) {
25641 return unwrapAndMerge(arr);
25644 return Promise.all(arr).then(unwrapAndMerge);
25647 const resolveConfig = (filePath, opts) => _resolveConfig(filePath, opts, false);
25649 resolveConfig.sync = (filePath, opts) => _resolveConfig(filePath, opts, true);
25651 function clearCache$1() {
25652 mem$1.clear(getExplorerMemoized);
25653 resolveEditorConfig.clearCache();
25656 async function resolveConfigFile(filePath) {
25662 const result = await search(filePath);
25663 return result ? result.filepath : null;
25666 resolveConfigFile.sync = filePath => {
25672 const result = search(filePath);
25673 return result ? result.filepath : null;
25676 function mergeOverrides(configResult, filePath) {
25679 filepath: configPath
25680 } = configResult || {};
25682 const _ref = config || {},
25686 options = _objectWithoutProperties(_ref, _excluded$1);
25688 if (filePath && overrides) {
25689 const relativeFilePath = path$f.relative(path$f.dirname(configPath), filePath);
25691 for (const override of overrides) {
25692 if (pathMatchesGlobs(relativeFilePath, override.files, override.excludeFiles)) {
25693 Object.assign(options, override.options);
25699 } // Based on eslint: https://github.com/eslint/eslint/blob/master/lib/config/config-ops.js
25702 function pathMatchesGlobs(filePath, patterns, excludedPatterns = []) {
25703 const patternList = Array.isArray(patterns) ? patterns : [patterns];
25704 const excludedPatternList = Array.isArray(excludedPatterns) ? excludedPatterns : [excludedPatterns];
25709 return patternList.some(pattern => minimatch(filePath, pattern, opts)) && !excludedPatternList.some(excludedPattern => minimatch(filePath, excludedPattern, opts));
25712 var resolveConfig_1 = {
25715 clearCache: clearCache$1
25718 function make_array(subject) {
25719 return Array.isArray(subject) ? subject : [subject];
25722 const REGEX_BLANK_LINE = /^\s+$/;
25723 const REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
25724 const REGEX_LEADING_EXCAPED_HASH = /^\\#/;
25725 const SLASH$1 = '/';
25726 const KEY_IGNORE$1 = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
25727 /* istanbul ignore next */
25730 const define$1 = (object, key, value) => Object.defineProperty(object, key, {
25734 const REGEX_REGEXP_RANGE$1 = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
25735 // The cases are complicated, see test cases for details
25737 const sanitizeRange$1 = range => range.replace(REGEX_REGEXP_RANGE$1, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
25738 // fatal for JavaScript regular expression, so eliminate it.
25739 : ''); // > If the pattern ends with a slash,
25740 // > it is removed for the purpose of the following description,
25741 // > but it would only find a match with a directory.
25742 // > In other words, foo/ will match a directory foo and paths underneath it,
25743 // > but will not match a regular file or a symbolic link foo
25744 // > (this is consistent with the way how pathspec works in general in Git).
25745 // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
25746 // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
25747 // you could use option `mark: true` with `glob`
25748 // '`foo/`' should not continue with the '`..`'
25751 const DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
25755 /\\?\s+$/, match => match.indexOf('\\') === 0 ? ' ' : ''], // replace (\ ) with ' '
25756 [/\\\s/g, () => ' '], // Escape metacharacters
25757 // which is written down by users but means special for regular expressions.
25758 // > There are 12 characters with special meanings:
25759 // > - the backslash \,
25760 // > - the caret ^,
25761 // > - the dollar sign $,
25762 // > - the period or dot .,
25763 // > - the vertical bar or pipe symbol |,
25764 // > - the question mark ?,
25765 // > - the asterisk or star *,
25766 // > - the plus sign +,
25767 // > - the opening parenthesis (,
25768 // > - the closing parenthesis ),
25769 // > - and the opening square bracket [,
25770 // > - the opening curly brace {,
25771 // > These special characters are often called "metacharacters".
25772 [/[\\^$.|*+(){]/g, match => `\\${match}`], [// > [abc] matches any character inside the brackets
25773 // > (in this case a, b, or c);
25774 /\[([^\]/]*)($|\])/g, (match, p1, p2) => p2 === ']' ? `[${sanitizeRange$1(p1)}]` : `\\${match}`], [// > a question mark (?) matches a single character
25775 /(?!\\)\?/g, () => '[^/]'], // leading slash
25776 [// > A leading slash matches the beginning of the pathname.
25777 // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
25778 // A leading slash matches the beginning of the pathname
25779 /^\//, () => '^'], // replace special metacharacter slash after the leading slash
25780 [/\//g, () => '\\/'], [// > A leading "**" followed by a slash means match in all directories.
25781 // > For example, "**/foo" matches file or directory "foo" anywhere,
25782 // > the same as pattern "foo".
25783 // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
25784 // > under directory "foo".
25785 // Notice that the '*'s have been replaced as '\\*'
25786 /^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
25787 () => '^(?:.*\\/)?']];
25788 const DEFAULT_REPLACER_SUFFIX = [// starting
25789 [// there will be no leading '/'
25790 // (which has been replaced by section "leading slash")
25791 // If starts with '**', adding a '^' to the regular expression also works
25792 /^(?=[^^])/, function startingReplacer() {
25793 return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /,
25794 // > Git treats it as a shell glob pattern
25795 // Actually, if there is only a trailing slash,
25796 // git also treats it as a shell glob pattern
25797 ? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
25798 // > consumption by fnmatch(3)
25800 }], // two globstars
25801 [// Use lookahead assertions so that we could match more than one `'/**'`
25802 /\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
25803 // should not use '*', or it will be replaced by the next replacer
25804 // Check if it is not the last `'/**'`
25805 (match, index, str) => index + 6 < str.length // case: /**/
25806 // > A slash followed by two consecutive asterisks then a slash matches
25807 // > zero or more directories.
25808 // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
25810 ? '(?:\\/[^\\/]+)*' // case: /**
25811 // > A trailing `"/**"` matches everything inside.
25812 // #21: everything inside but it should not include the current folder
25813 : '\\/.+'], // intermediate wildcards
25814 [// Never replace escaped '*'
25815 // ignore rule '\*' will match the path '*'
25817 // 'abc.*' -> skip this rule
25818 /(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
25819 // '*.js' doesn't match 'abc'
25820 (match, p1) => `${p1}[^\\/]*`], // trailing wildcard
25821 [/(\^|\\\/)?\\\*$/, (match, p1) => {
25822 const prefix = p1 // '\^':
25823 // '/*' does not match ''
25824 // '/*' does not match everything
25826 // 'abc/*' does not match 'abc/'
25827 ? `${p1}[^/]+` // 'a*' matches 'a'
25828 // 'a*' matches 'aa'
25830 return `${prefix}(?=$|\\/$)`;
25832 /\\\\\\/g, () => '\\']];
25833 const POSITIVE_REPLACERS = [...DEFAULT_REPLACER_PREFIX, // 'f'
25845 [// 'js' will not match 'js.'
25846 // 'ab' will not match 'abc'
25847 /(?:[^*/])$/, // 'js*' will not match 'a.js'
25848 // 'js/' will not match 'a.js'
25849 // 'js' will match 'a.js' and 'a.js/'
25850 match => `${match}(?=$|\\/)`], ...DEFAULT_REPLACER_SUFFIX];
25851 const NEGATIVE_REPLACERS = [...DEFAULT_REPLACER_PREFIX, // #24, #38
25852 // The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
25853 // A negative pattern without a trailing wildcard should not
25854 // re-include the things inside that directory.
25856 // ['node_modules/*', '!node_modules']
25857 // should ignore `node_modules/a.js`
25858 [/(?:[^*])$/, match => `${match}(?=$|\\/$)`], ...DEFAULT_REPLACER_SUFFIX]; // A simple cache, because an ignore rule only has only one certain meaning
25860 const cache = Object.create(null); // @param {pattern}
25862 const make_regex = (pattern, negative, ignorecase) => {
25863 const r = cache[pattern];
25869 const replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
25870 const source = replacers.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
25871 return cache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
25872 }; // > A blank line matches no files, so it can serve as a separator for readability.
25875 const checkPattern$1 = pattern => pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
25876 && pattern.indexOf('#') !== 0;
25878 const createRule$1 = (pattern, ignorecase) => {
25879 const origin = pattern;
25880 let negative = false; // > An optional prefix "!" which negates the pattern;
25882 if (pattern.indexOf('!') === 0) {
25884 pattern = pattern.substr(1);
25887 pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
25888 // > begin with a literal "!", for example, `"\!important!.txt"`.
25889 .replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
25890 // > begin with a hash.
25891 .replace(REGEX_LEADING_EXCAPED_HASH, '#');
25892 const regex = make_regex(pattern, negative, ignorecase);
25906 this._ignorecase = ignorecase;
25907 define$1(this, KEY_IGNORE$1, true);
25913 this._cache = Object.create(null);
25914 } // @param {Array.<string>|string|Ignore} pattern
25918 this._added = false;
25920 if (typeof pattern === 'string') {
25921 pattern = pattern.split(/\r?\n/g);
25924 make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
25925 // making the behavior changed.
25935 addPattern(pattern) {
25936 return this.add(pattern);
25939 _addPattern(pattern) {
25941 if (pattern && pattern[KEY_IGNORE$1]) {
25942 this._rules = this._rules.concat(pattern._rules);
25943 this._added = true;
25947 if (checkPattern$1(pattern)) {
25948 const rule = createRule$1(pattern, this._ignorecase);
25949 this._added = true;
25951 this._rules.push(rule);
25956 return make_array(paths).filter(path => this._filter(path));
25960 return path => this._filter(path);
25964 return !this._filter(path);
25965 } // @returns `Boolean` true if the `path` is NOT ignored
25968 _filter(path, slices) {
25973 if (path in this._cache) {
25974 return this._cache[path];
25979 // ['path', 'to', 'a.js']
25980 slices = path.split(SLASH$1);
25984 return this._cache[path] = slices.length // > It is not possible to re-include a file if a parent directory of
25985 // > that file is excluded.
25986 // If the path contains a parent directory, check the parent first
25987 ? this._filter(slices.join(SLASH$1) + SLASH$1, slices) && this._test(path) // Or only test the path
25988 : this._test(path);
25989 } // @returns {Boolean} true if a file is NOT ignored
25993 // Explicitly define variable type by setting matched to `0`
25996 this._rules.forEach(rule => {
25997 // if matched = true, then we only test negative rules
25998 // if matched = false, then we test non-negative rules
25999 if (!(matched ^ rule.negative)) {
26000 matched = rule.negative ^ rule.regex.test(path);
26008 // --------------------------------------------------------------
26010 /* istanbul ignore if */
26013 if ( // Detect `process` so that it can run in browsers.
26014 typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
26015 const filter = IgnoreBase.prototype._filter;
26016 /* eslint no-control-regex: "off" */
26018 const make_posix = str => /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
26020 IgnoreBase.prototype._filter = function filterWin32(path, slices) {
26021 path = make_posix(path);
26022 return filter.call(this, path, slices);
26026 var ignore$2 = options => new IgnoreBase(options);
26028 const fs$c = require$$0__default["default"];
26029 const fsAsync = fs$c.promises;
26031 * @param {string} filename
26032 * @returns {Promise<null | string>}
26035 async function getFileContentOrNull$1(filename) {
26037 return await fsAsync.readFile(filename, "utf8");
26039 return handleError(filename, error);
26043 * @param {string} filename
26044 * @returns {null | string}
26048 getFileContentOrNull$1.sync = function (filename) {
26050 return fs$c.readFileSync(filename, "utf8");
26052 return handleError(filename, error);
26056 function handleError(filename, error) {
26057 if (error && error.code === "ENOENT") {
26061 throw new Error(`Unable to read ${filename}: ${error.message}`);
26064 var getFileContentOrNull_1 = getFileContentOrNull$1;
26066 const path$e = require$$0__default$2["default"];
26067 const ignore$1 = ignore$2;
26068 const getFileContentOrNull = getFileContentOrNull_1;
26070 * @param {string?} ignorePath
26071 * @param {boolean?} withNodeModules
26074 async function createIgnorer$1(ignorePath, withNodeModules) {
26075 const ignoreContent = ignorePath ? await getFileContentOrNull(path$e.resolve(ignorePath)) : null;
26076 return _createIgnorer(ignoreContent, withNodeModules);
26079 * @param {string?} ignorePath
26080 * @param {boolean?} withNodeModules
26084 createIgnorer$1.sync = function (ignorePath, withNodeModules) {
26085 const ignoreContent = !ignorePath ? null : getFileContentOrNull.sync(path$e.resolve(ignorePath));
26086 return _createIgnorer(ignoreContent, withNodeModules);
26089 * @param {null | string} ignoreContent
26090 * @param {boolean?} withNodeModules
26094 function _createIgnorer(ignoreContent, withNodeModules) {
26095 const ignorer = ignore$1().add(ignoreContent || "");
26097 if (!withNodeModules) {
26098 ignorer.add("node_modules");
26104 var createIgnorer_1 = createIgnorer$1;
26106 const path$d = require$$0__default$2["default"];
26107 const options$c = options$d;
26108 const config$1 = resolveConfig_1;
26109 const createIgnorer = createIgnorer_1;
26111 * @typedef {{ ignorePath?: string, withNodeModules?: boolean, plugins: object }} FileInfoOptions
26112 * @typedef {{ ignored: boolean, inferredParser: string | null }} FileInfoResult
26116 * @param {string} filePath
26117 * @param {FileInfoOptions} opts
26118 * @returns {Promise<FileInfoResult>}
26120 * Please note that prettier.getFileInfo() expects opts.plugins to be an array of paths,
26121 * not an object. A transformation from this array to an object is automatically done
26122 * internally by the method wrapper. See withPlugins() in index.js.
26125 async function getFileInfo$1(filePath, opts) {
26126 if (typeof filePath !== "string") {
26127 throw new TypeError(`expect \`filePath\` to be a string, got \`${typeof filePath}\``);
26130 const ignorer = await createIgnorer(opts.ignorePath, opts.withNodeModules);
26131 return _getFileInfo({
26134 plugins: opts.plugins,
26135 resolveConfig: opts.resolveConfig,
26136 ignorePath: opts.ignorePath,
26141 * @param {string} filePath
26142 * @param {FileInfoOptions} opts
26143 * @returns {FileInfoResult}
26147 getFileInfo$1.sync = function (filePath, opts) {
26148 if (typeof filePath !== "string") {
26149 throw new TypeError(`expect \`filePath\` to be a string, got \`${typeof filePath}\``);
26152 const ignorer = createIgnorer.sync(opts.ignorePath, opts.withNodeModules);
26153 return _getFileInfo({
26156 plugins: opts.plugins,
26157 resolveConfig: opts.resolveConfig,
26158 ignorePath: opts.ignorePath,
26163 function getFileParser(resolvedConfig, filePath, plugins) {
26164 if (resolvedConfig && resolvedConfig.parser) {
26165 return resolvedConfig.parser;
26168 const inferredParser = options$c.inferParser(filePath, plugins);
26170 if (inferredParser) {
26171 return inferredParser;
26177 function _getFileInfo({
26181 resolveConfig = false,
26185 const normalizedFilePath = normalizeFilePath(filePath, ignorePath);
26187 ignored: ignorer.ignores(normalizedFilePath),
26188 inferredParser: null
26191 if (fileInfo.ignored) {
26195 let resolvedConfig;
26197 if (resolveConfig) {
26199 resolvedConfig = config$1.resolveConfig.sync(filePath);
26201 return config$1.resolveConfig(filePath).then(resolvedConfig => {
26202 fileInfo.inferredParser = getFileParser(resolvedConfig, filePath, plugins);
26208 fileInfo.inferredParser = getFileParser(resolvedConfig, filePath, plugins);
26212 function normalizeFilePath(filePath, ignorePath) {
26213 return ignorePath ? path$d.relative(path$d.dirname(ignorePath), filePath) : filePath;
26216 var getFileInfo_1 = getFileInfo$1;
26219 getMaxContinuousCount: getMaxContinuousCount$2,
26220 getStringWidth: getStringWidth$4,
26222 getIndentSize: getIndentSize$1,
26224 skipWhitespace: skipWhitespace$1,
26228 skipEverythingButNewLine: skipEverythingButNewLine$1,
26230 skipTrailingComment,
26231 hasNewline: hasNewline$8,
26232 hasNewlineInRange: hasNewlineInRange$4,
26234 isNextLineEmpty: isNextLineEmpty$d,
26235 isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$2,
26236 isPreviousLineEmpty: isPreviousLineEmpty$1,
26237 getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$3,
26239 addLeadingComment: addLeadingComment$1,
26240 addDanglingComment: addDanglingComment$1,
26241 addTrailingComment: addTrailingComment$1
26244 getMaxContinuousCount: getMaxContinuousCount$2,
26245 getStringWidth: getStringWidth$4,
26247 getIndentSize: getIndentSize$1,
26249 skipWhitespace: skipWhitespace$1,
26253 skipEverythingButNewLine: skipEverythingButNewLine$1,
26255 skipTrailingComment,
26256 hasNewline: hasNewline$8,
26257 hasNewlineInRange: hasNewlineInRange$4,
26259 isNextLineEmpty: isNextLineEmpty$d,
26260 isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$2,
26261 isPreviousLineEmpty: isPreviousLineEmpty$1,
26262 getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$3,
26264 addLeadingComment: addLeadingComment$1,
26265 addDanglingComment: addDanglingComment$1,
26266 addTrailingComment: addTrailingComment$1
26270 * Removes all key-value entries from the list cache.
26274 * @memberOf ListCache
26277 function listCacheClear$1() {
26278 this.__data__ = [];
26282 var _listCacheClear = listCacheClear$1;
26286 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
26287 * comparison between two values to determine if they are equivalent.
26293 * @param {*} value The value to compare.
26294 * @param {*} other The other value to compare.
26295 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
26298 * var object = { 'a': 1 };
26299 * var other = { 'a': 1 };
26301 * _.eq(object, object);
26304 * _.eq(object, other);
26310 * _.eq('a', Object('a'));
26317 function eq$2(value, other) {
26318 return value === other || value !== value && other !== other;
26325 * Gets the index at which the `key` is found in `array` of key-value pairs.
26328 * @param {Array} array The array to inspect.
26329 * @param {*} key The key to search for.
26330 * @returns {number} Returns the index of the matched value, else `-1`.
26333 function assocIndexOf$4(array, key) {
26334 var length = array.length;
26337 if (eq$1(array[length][0], key)) {
26345 var _assocIndexOf = assocIndexOf$4;
26347 var assocIndexOf$3 = _assocIndexOf;
26348 /** Used for built-in method references. */
26350 var arrayProto = Array.prototype;
26351 /** Built-in value references. */
26353 var splice = arrayProto.splice;
26355 * Removes `key` and its value from the list cache.
26359 * @memberOf ListCache
26360 * @param {string} key The key of the value to remove.
26361 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
26364 function listCacheDelete$1(key) {
26365 var data = this.__data__,
26366 index = assocIndexOf$3(data, key);
26372 var lastIndex = data.length - 1;
26374 if (index == lastIndex) {
26377 splice.call(data, index, 1);
26384 var _listCacheDelete = listCacheDelete$1;
26386 var assocIndexOf$2 = _assocIndexOf;
26388 * Gets the list cache value for `key`.
26392 * @memberOf ListCache
26393 * @param {string} key The key of the value to get.
26394 * @returns {*} Returns the entry value.
26397 function listCacheGet$1(key) {
26398 var data = this.__data__,
26399 index = assocIndexOf$2(data, key);
26400 return index < 0 ? undefined : data[index][1];
26403 var _listCacheGet = listCacheGet$1;
26405 var assocIndexOf$1 = _assocIndexOf;
26407 * Checks if a list cache value for `key` exists.
26411 * @memberOf ListCache
26412 * @param {string} key The key of the entry to check.
26413 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
26416 function listCacheHas$1(key) {
26417 return assocIndexOf$1(this.__data__, key) > -1;
26420 var _listCacheHas = listCacheHas$1;
26422 var assocIndexOf = _assocIndexOf;
26424 * Sets the list cache `key` to `value`.
26428 * @memberOf ListCache
26429 * @param {string} key The key of the value to set.
26430 * @param {*} value The value to set.
26431 * @returns {Object} Returns the list cache instance.
26434 function listCacheSet$1(key, value) {
26435 var data = this.__data__,
26436 index = assocIndexOf(data, key);
26440 data.push([key, value]);
26442 data[index][1] = value;
26448 var _listCacheSet = listCacheSet$1;
26450 var listCacheClear = _listCacheClear,
26451 listCacheDelete = _listCacheDelete,
26452 listCacheGet = _listCacheGet,
26453 listCacheHas = _listCacheHas,
26454 listCacheSet = _listCacheSet;
26456 * Creates an list cache object.
26460 * @param {Array} [entries] The key-value pairs to cache.
26463 function ListCache$4(entries) {
26465 length = entries == null ? 0 : entries.length;
26468 while (++index < length) {
26469 var entry = entries[index];
26470 this.set(entry[0], entry[1]);
26472 } // Add methods to `ListCache`.
26475 ListCache$4.prototype.clear = listCacheClear;
26476 ListCache$4.prototype['delete'] = listCacheDelete;
26477 ListCache$4.prototype.get = listCacheGet;
26478 ListCache$4.prototype.has = listCacheHas;
26479 ListCache$4.prototype.set = listCacheSet;
26480 var _ListCache = ListCache$4;
26482 var ListCache$3 = _ListCache;
26484 * Removes all key-value entries from the stack.
26491 function stackClear$1() {
26492 this.__data__ = new ListCache$3();
26496 var _stackClear = stackClear$1;
26499 * Removes `key` and its value from the stack.
26504 * @param {string} key The key of the value to remove.
26505 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
26508 function stackDelete$1(key) {
26509 var data = this.__data__,
26510 result = data['delete'](key);
26511 this.size = data.size;
26515 var _stackDelete = stackDelete$1;
26518 * Gets the stack value for `key`.
26523 * @param {string} key The key of the value to get.
26524 * @returns {*} Returns the entry value.
26527 function stackGet$1(key) {
26528 return this.__data__.get(key);
26531 var _stackGet = stackGet$1;
26534 * Checks if a stack value for `key` exists.
26539 * @param {string} key The key of the entry to check.
26540 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
26543 function stackHas$1(key) {
26544 return this.__data__.has(key);
26547 var _stackHas = stackHas$1;
26549 /** Detect free variable `global` from Node.js. */
26550 var freeGlobal$1 = typeof global == 'object' && global && global.Object === Object && global;
26551 var _freeGlobal = freeGlobal$1;
26553 var freeGlobal = _freeGlobal;
26554 /** Detect free variable `self`. */
26556 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
26557 /** Used as a reference to the global object. */
26559 var root$8 = freeGlobal || freeSelf || Function('return this')();
26560 var _root = root$8;
26562 var root$7 = _root;
26563 /** Built-in value references. */
26565 var Symbol$5 = root$7.Symbol;
26566 var _Symbol = Symbol$5;
26568 var Symbol$4 = _Symbol;
26569 /** Used for built-in method references. */
26571 var objectProto$b = Object.prototype;
26572 /** Used to check objects for own properties. */
26574 var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
26576 * Used to resolve the
26577 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
26581 var nativeObjectToString$1 = objectProto$b.toString;
26582 /** Built-in value references. */
26584 var symToStringTag$1 = Symbol$4 ? Symbol$4.toStringTag : undefined;
26586 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
26589 * @param {*} value The value to query.
26590 * @returns {string} Returns the raw `toStringTag`.
26593 function getRawTag$1(value) {
26594 var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
26595 tag = value[symToStringTag$1];
26598 value[symToStringTag$1] = undefined;
26599 var unmasked = true;
26602 var result = nativeObjectToString$1.call(value);
26606 value[symToStringTag$1] = tag;
26608 delete value[symToStringTag$1];
26615 var _getRawTag = getRawTag$1;
26617 /** Used for built-in method references. */
26618 var objectProto$a = Object.prototype;
26620 * Used to resolve the
26621 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
26625 var nativeObjectToString = objectProto$a.toString;
26627 * Converts `value` to a string using `Object.prototype.toString`.
26630 * @param {*} value The value to convert.
26631 * @returns {string} Returns the converted string.
26634 function objectToString$1(value) {
26635 return nativeObjectToString.call(value);
26638 var _objectToString = objectToString$1;
26640 var Symbol$3 = _Symbol,
26641 getRawTag = _getRawTag,
26642 objectToString = _objectToString;
26643 /** `Object#toString` result references. */
26645 var nullTag = '[object Null]',
26646 undefinedTag = '[object Undefined]';
26647 /** Built-in value references. */
26649 var symToStringTag = Symbol$3 ? Symbol$3.toStringTag : undefined;
26651 * The base implementation of `getTag` without fallbacks for buggy environments.
26654 * @param {*} value The value to query.
26655 * @returns {string} Returns the `toStringTag`.
26658 function baseGetTag$5(value) {
26659 if (value == null) {
26660 return value === undefined ? undefinedTag : nullTag;
26663 return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
26666 var _baseGetTag = baseGetTag$5;
26669 * Checks if `value` is the
26670 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
26671 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
26677 * @param {*} value The value to check.
26678 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
26684 * _.isObject([1, 2, 3]);
26687 * _.isObject(_.noop);
26690 * _.isObject(null);
26694 function isObject$5(value) {
26695 var type = typeof value;
26696 return value != null && (type == 'object' || type == 'function');
26699 var isObject_1 = isObject$5;
26701 var baseGetTag$4 = _baseGetTag,
26702 isObject$4 = isObject_1;
26703 /** `Object#toString` result references. */
26705 var asyncTag = '[object AsyncFunction]',
26706 funcTag$1 = '[object Function]',
26707 genTag = '[object GeneratorFunction]',
26708 proxyTag = '[object Proxy]';
26710 * Checks if `value` is classified as a `Function` object.
26716 * @param {*} value The value to check.
26717 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
26723 * _.isFunction(/abc/);
26727 function isFunction$2(value) {
26728 if (!isObject$4(value)) {
26730 } // The use of `Object#toString` avoids issues with the `typeof` operator
26731 // in Safari 9 which returns 'object' for typed arrays and other constructors.
26734 var tag = baseGetTag$4(value);
26735 return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
26738 var isFunction_1 = isFunction$2;
26740 var root$6 = _root;
26741 /** Used to detect overreaching core-js shims. */
26743 var coreJsData$1 = root$6['__core-js_shared__'];
26744 var _coreJsData = coreJsData$1;
26746 var coreJsData = _coreJsData;
26747 /** Used to detect methods masquerading as native. */
26749 var maskSrcKey = function () {
26750 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
26751 return uid ? 'Symbol(src)_1.' + uid : '';
26754 * Checks if `func` has its source masked.
26757 * @param {Function} func The function to check.
26758 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
26762 function isMasked$1(func) {
26763 return !!maskSrcKey && maskSrcKey in func;
26766 var _isMasked = isMasked$1;
26768 /** Used for built-in method references. */
26769 var funcProto$1 = Function.prototype;
26770 /** Used to resolve the decompiled source of functions. */
26772 var funcToString$1 = funcProto$1.toString;
26774 * Converts `func` to its source code.
26777 * @param {Function} func The function to convert.
26778 * @returns {string} Returns the source code.
26781 function toSource$2(func) {
26782 if (func != null) {
26784 return funcToString$1.call(func);
26795 var _toSource = toSource$2;
26797 var isFunction$1 = isFunction_1,
26798 isMasked = _isMasked,
26799 isObject$3 = isObject_1,
26800 toSource$1 = _toSource;
26802 * Used to match `RegExp`
26803 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
26806 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
26807 /** Used to detect host constructors (Safari). */
26809 var reIsHostCtor = /^\[object .+?Constructor\]$/;
26810 /** Used for built-in method references. */
26812 var funcProto = Function.prototype,
26813 objectProto$9 = Object.prototype;
26814 /** Used to resolve the decompiled source of functions. */
26816 var funcToString = funcProto.toString;
26817 /** Used to check objects for own properties. */
26819 var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
26820 /** Used to detect if a method is native. */
26822 var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
26824 * The base implementation of `_.isNative` without bad shim checks.
26827 * @param {*} value The value to check.
26828 * @returns {boolean} Returns `true` if `value` is a native function,
26832 function baseIsNative$1(value) {
26833 if (!isObject$3(value) || isMasked(value)) {
26837 var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
26838 return pattern.test(toSource$1(value));
26841 var _baseIsNative = baseIsNative$1;
26844 * Gets the value at `key` of `object`.
26847 * @param {Object} [object] The object to query.
26848 * @param {string} key The key of the property to get.
26849 * @returns {*} Returns the property value.
26852 function getValue$1(object, key) {
26853 return object == null ? undefined : object[key];
26856 var _getValue = getValue$1;
26858 var baseIsNative = _baseIsNative,
26859 getValue = _getValue;
26861 * Gets the native function at `key` of `object`.
26864 * @param {Object} object The object to query.
26865 * @param {string} key The key of the method to get.
26866 * @returns {*} Returns the function if it's native, else `undefined`.
26869 function getNative$6(object, key) {
26870 var value = getValue(object, key);
26871 return baseIsNative(value) ? value : undefined;
26874 var _getNative = getNative$6;
26876 var getNative$5 = _getNative,
26878 /* Built-in method references that are verified to be native. */
26880 var Map$4 = getNative$5(root$5, 'Map');
26883 var getNative$4 = _getNative;
26884 /* Built-in method references that are verified to be native. */
26886 var nativeCreate$4 = getNative$4(Object, 'create');
26887 var _nativeCreate = nativeCreate$4;
26889 var nativeCreate$3 = _nativeCreate;
26891 * Removes all key-value entries from the hash.
26898 function hashClear$1() {
26899 this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
26903 var _hashClear = hashClear$1;
26906 * Removes `key` and its value from the hash.
26911 * @param {Object} hash The hash to modify.
26912 * @param {string} key The key of the value to remove.
26913 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
26916 function hashDelete$1(key) {
26917 var result = this.has(key) && delete this.__data__[key];
26918 this.size -= result ? 1 : 0;
26922 var _hashDelete = hashDelete$1;
26924 var nativeCreate$2 = _nativeCreate;
26925 /** Used to stand-in for `undefined` hash values. */
26927 var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
26928 /** Used for built-in method references. */
26930 var objectProto$8 = Object.prototype;
26931 /** Used to check objects for own properties. */
26933 var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
26935 * Gets the hash value for `key`.
26940 * @param {string} key The key of the value to get.
26941 * @returns {*} Returns the entry value.
26944 function hashGet$1(key) {
26945 var data = this.__data__;
26947 if (nativeCreate$2) {
26948 var result = data[key];
26949 return result === HASH_UNDEFINED$2 ? undefined : result;
26952 return hasOwnProperty$6.call(data, key) ? data[key] : undefined;
26955 var _hashGet = hashGet$1;
26957 var nativeCreate$1 = _nativeCreate;
26958 /** Used for built-in method references. */
26960 var objectProto$7 = Object.prototype;
26961 /** Used to check objects for own properties. */
26963 var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
26965 * Checks if a hash value for `key` exists.
26970 * @param {string} key The key of the entry to check.
26971 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
26974 function hashHas$1(key) {
26975 var data = this.__data__;
26976 return nativeCreate$1 ? data[key] !== undefined : hasOwnProperty$5.call(data, key);
26979 var _hashHas = hashHas$1;
26981 var nativeCreate = _nativeCreate;
26982 /** Used to stand-in for `undefined` hash values. */
26984 var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
26986 * Sets the hash `key` to `value`.
26991 * @param {string} key The key of the value to set.
26992 * @param {*} value The value to set.
26993 * @returns {Object} Returns the hash instance.
26996 function hashSet$1(key, value) {
26997 var data = this.__data__;
26998 this.size += this.has(key) ? 0 : 1;
26999 data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED$1 : value;
27003 var _hashSet = hashSet$1;
27005 var hashClear = _hashClear,
27006 hashDelete = _hashDelete,
27007 hashGet = _hashGet,
27008 hashHas = _hashHas,
27009 hashSet = _hashSet;
27011 * Creates a hash object.
27015 * @param {Array} [entries] The key-value pairs to cache.
27018 function Hash$1(entries) {
27020 length = entries == null ? 0 : entries.length;
27023 while (++index < length) {
27024 var entry = entries[index];
27025 this.set(entry[0], entry[1]);
27027 } // Add methods to `Hash`.
27030 Hash$1.prototype.clear = hashClear;
27031 Hash$1.prototype['delete'] = hashDelete;
27032 Hash$1.prototype.get = hashGet;
27033 Hash$1.prototype.has = hashHas;
27034 Hash$1.prototype.set = hashSet;
27035 var _Hash = Hash$1;
27038 ListCache$2 = _ListCache,
27041 * Removes all key-value entries from the map.
27045 * @memberOf MapCache
27048 function mapCacheClear$1() {
27051 'hash': new Hash(),
27052 'map': new (Map$3 || ListCache$2)(),
27053 'string': new Hash()
27057 var _mapCacheClear = mapCacheClear$1;
27060 * Checks if `value` is suitable for use as unique object key.
27063 * @param {*} value The value to check.
27064 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
27067 function isKeyable$1(value) {
27068 var type = typeof value;
27069 return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
27072 var _isKeyable = isKeyable$1;
27074 var isKeyable = _isKeyable;
27076 * Gets the data for `map`.
27079 * @param {Object} map The map to query.
27080 * @param {string} key The reference key.
27081 * @returns {*} Returns the map data.
27084 function getMapData$4(map, key) {
27085 var data = map.__data__;
27086 return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
27089 var _getMapData = getMapData$4;
27091 var getMapData$3 = _getMapData;
27093 * Removes `key` and its value from the map.
27097 * @memberOf MapCache
27098 * @param {string} key The key of the value to remove.
27099 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
27102 function mapCacheDelete$1(key) {
27103 var result = getMapData$3(this, key)['delete'](key);
27104 this.size -= result ? 1 : 0;
27108 var _mapCacheDelete = mapCacheDelete$1;
27110 var getMapData$2 = _getMapData;
27112 * Gets the map value for `key`.
27116 * @memberOf MapCache
27117 * @param {string} key The key of the value to get.
27118 * @returns {*} Returns the entry value.
27121 function mapCacheGet$1(key) {
27122 return getMapData$2(this, key).get(key);
27125 var _mapCacheGet = mapCacheGet$1;
27127 var getMapData$1 = _getMapData;
27129 * Checks if a map value for `key` exists.
27133 * @memberOf MapCache
27134 * @param {string} key The key of the entry to check.
27135 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
27138 function mapCacheHas$1(key) {
27139 return getMapData$1(this, key).has(key);
27142 var _mapCacheHas = mapCacheHas$1;
27144 var getMapData = _getMapData;
27146 * Sets the map `key` to `value`.
27150 * @memberOf MapCache
27151 * @param {string} key The key of the value to set.
27152 * @param {*} value The value to set.
27153 * @returns {Object} Returns the map cache instance.
27156 function mapCacheSet$1(key, value) {
27157 var data = getMapData(this, key),
27159 data.set(key, value);
27160 this.size += data.size == size ? 0 : 1;
27164 var _mapCacheSet = mapCacheSet$1;
27166 var mapCacheClear = _mapCacheClear,
27167 mapCacheDelete = _mapCacheDelete,
27168 mapCacheGet = _mapCacheGet,
27169 mapCacheHas = _mapCacheHas,
27170 mapCacheSet = _mapCacheSet;
27172 * Creates a map cache object to store key-value pairs.
27176 * @param {Array} [entries] The key-value pairs to cache.
27179 function MapCache$3(entries) {
27181 length = entries == null ? 0 : entries.length;
27184 while (++index < length) {
27185 var entry = entries[index];
27186 this.set(entry[0], entry[1]);
27188 } // Add methods to `MapCache`.
27191 MapCache$3.prototype.clear = mapCacheClear;
27192 MapCache$3.prototype['delete'] = mapCacheDelete;
27193 MapCache$3.prototype.get = mapCacheGet;
27194 MapCache$3.prototype.has = mapCacheHas;
27195 MapCache$3.prototype.set = mapCacheSet;
27196 var _MapCache = MapCache$3;
27198 var ListCache$1 = _ListCache,
27200 MapCache$2 = _MapCache;
27201 /** Used as the size to enable large array optimizations. */
27203 var LARGE_ARRAY_SIZE$1 = 200;
27205 * Sets the stack `key` to `value`.
27210 * @param {string} key The key of the value to set.
27211 * @param {*} value The value to set.
27212 * @returns {Object} Returns the stack cache instance.
27215 function stackSet$1(key, value) {
27216 var data = this.__data__;
27218 if (data instanceof ListCache$1) {
27219 var pairs = data.__data__;
27221 if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE$1 - 1) {
27222 pairs.push([key, value]);
27223 this.size = ++data.size;
27227 data = this.__data__ = new MapCache$2(pairs);
27230 data.set(key, value);
27231 this.size = data.size;
27235 var _stackSet = stackSet$1;
27237 var ListCache = _ListCache,
27238 stackClear = _stackClear,
27239 stackDelete = _stackDelete,
27240 stackGet = _stackGet,
27241 stackHas = _stackHas,
27242 stackSet = _stackSet;
27244 * Creates a stack cache object to store key-value pairs.
27248 * @param {Array} [entries] The key-value pairs to cache.
27251 function Stack$2(entries) {
27252 var data = this.__data__ = new ListCache(entries);
27253 this.size = data.size;
27254 } // Add methods to `Stack`.
27257 Stack$2.prototype.clear = stackClear;
27258 Stack$2.prototype['delete'] = stackDelete;
27259 Stack$2.prototype.get = stackGet;
27260 Stack$2.prototype.has = stackHas;
27261 Stack$2.prototype.set = stackSet;
27262 var _Stack = Stack$2;
27264 /** Used to stand-in for `undefined` hash values. */
27265 var HASH_UNDEFINED = '__lodash_hash_undefined__';
27267 * Adds `value` to the array cache.
27271 * @memberOf SetCache
27273 * @param {*} value The value to cache.
27274 * @returns {Object} Returns the cache instance.
27277 function setCacheAdd$1(value) {
27278 this.__data__.set(value, HASH_UNDEFINED);
27283 var _setCacheAdd = setCacheAdd$1;
27286 * Checks if `value` is in the array cache.
27290 * @memberOf SetCache
27291 * @param {*} value The value to search for.
27292 * @returns {number} Returns `true` if `value` is found, else `false`.
27295 function setCacheHas$1(value) {
27296 return this.__data__.has(value);
27299 var _setCacheHas = setCacheHas$1;
27301 var MapCache$1 = _MapCache,
27302 setCacheAdd = _setCacheAdd,
27303 setCacheHas = _setCacheHas;
27306 * Creates an array cache object to store unique values.
27310 * @param {Array} [values] The values to cache.
27313 function SetCache$2(values) {
27315 length = values == null ? 0 : values.length;
27316 this.__data__ = new MapCache$1();
27318 while (++index < length) {
27319 this.add(values[index]);
27321 } // Add methods to `SetCache`.
27324 SetCache$2.prototype.add = SetCache$2.prototype.push = setCacheAdd;
27325 SetCache$2.prototype.has = setCacheHas;
27326 var _SetCache = SetCache$2;
27329 * A specialized version of `_.some` for arrays without support for iteratee
27333 * @param {Array} [array] The array to iterate over.
27334 * @param {Function} predicate The function invoked per iteration.
27335 * @returns {boolean} Returns `true` if any element passes the predicate check,
27339 function arraySome$1(array, predicate) {
27341 length = array == null ? 0 : array.length;
27343 while (++index < length) {
27344 if (predicate(array[index], index, array)) {
27352 var _arraySome = arraySome$1;
27355 * Checks if a `cache` value for `key` exists.
27358 * @param {Object} cache The cache to query.
27359 * @param {string} key The key of the entry to check.
27360 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
27363 function cacheHas$2(cache, key) {
27364 return cache.has(key);
27367 var _cacheHas = cacheHas$2;
27369 var SetCache$1 = _SetCache,
27370 arraySome = _arraySome,
27371 cacheHas$1 = _cacheHas;
27372 /** Used to compose bitmasks for value comparisons. */
27374 var COMPARE_PARTIAL_FLAG$5 = 1,
27375 COMPARE_UNORDERED_FLAG$3 = 2;
27377 * A specialized version of `baseIsEqualDeep` for arrays with support for
27378 * partial deep comparisons.
27381 * @param {Array} array The array to compare.
27382 * @param {Array} other The other array to compare.
27383 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
27384 * @param {Function} customizer The function to customize comparisons.
27385 * @param {Function} equalFunc The function to determine equivalents of values.
27386 * @param {Object} stack Tracks traversed `array` and `other` objects.
27387 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
27390 function equalArrays$2(array, other, bitmask, customizer, equalFunc, stack) {
27391 var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
27392 arrLength = array.length,
27393 othLength = other.length;
27395 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
27397 } // Check that cyclic values are equal.
27400 var arrStacked = stack.get(array);
27401 var othStacked = stack.get(other);
27403 if (arrStacked && othStacked) {
27404 return arrStacked == other && othStacked == array;
27409 seen = bitmask & COMPARE_UNORDERED_FLAG$3 ? new SetCache$1() : undefined;
27410 stack.set(array, other);
27411 stack.set(other, array); // Ignore non-index properties.
27413 while (++index < arrLength) {
27414 var arrValue = array[index],
27415 othValue = other[index];
27418 var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
27421 if (compared !== undefined) {
27428 } // Recursively compare arrays (susceptible to call stack limits).
27432 if (!arraySome(other, function (othValue, othIndex) {
27433 if (!cacheHas$1(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
27434 return seen.push(othIndex);
27440 } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
27446 stack['delete'](array);
27447 stack['delete'](other);
27451 var _equalArrays = equalArrays$2;
27453 var root$4 = _root;
27454 /** Built-in value references. */
27456 var Uint8Array$1 = root$4.Uint8Array;
27457 var _Uint8Array = Uint8Array$1;
27460 * Converts `map` to its key-value pairs.
27463 * @param {Object} map The map to convert.
27464 * @returns {Array} Returns the key-value pairs.
27467 function mapToArray$1(map) {
27469 result = Array(map.size);
27470 map.forEach(function (value, key) {
27471 result[++index] = [key, value];
27476 var _mapToArray = mapToArray$1;
27479 * Converts `set` to an array of its values.
27482 * @param {Object} set The set to convert.
27483 * @returns {Array} Returns the values.
27486 function setToArray$3(set) {
27488 result = Array(set.size);
27489 set.forEach(function (value) {
27490 result[++index] = value;
27495 var _setToArray = setToArray$3;
27497 var Symbol$2 = _Symbol,
27498 Uint8Array = _Uint8Array,
27500 equalArrays$1 = _equalArrays,
27501 mapToArray = _mapToArray,
27502 setToArray$2 = _setToArray;
27503 /** Used to compose bitmasks for value comparisons. */
27505 var COMPARE_PARTIAL_FLAG$4 = 1,
27506 COMPARE_UNORDERED_FLAG$2 = 2;
27507 /** `Object#toString` result references. */
27509 var boolTag$1 = '[object Boolean]',
27510 dateTag$1 = '[object Date]',
27511 errorTag$1 = '[object Error]',
27512 mapTag$2 = '[object Map]',
27513 numberTag$1 = '[object Number]',
27514 regexpTag$1 = '[object RegExp]',
27515 setTag$2 = '[object Set]',
27516 stringTag$1 = '[object String]',
27517 symbolTag$1 = '[object Symbol]';
27518 var arrayBufferTag$1 = '[object ArrayBuffer]',
27519 dataViewTag$2 = '[object DataView]';
27520 /** Used to convert symbols to primitives and strings. */
27522 var symbolProto$1 = Symbol$2 ? Symbol$2.prototype : undefined,
27523 symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined;
27525 * A specialized version of `baseIsEqualDeep` for comparing objects of
27526 * the same `toStringTag`.
27528 * **Note:** This function only supports comparing values with tags of
27529 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
27532 * @param {Object} object The object to compare.
27533 * @param {Object} other The other object to compare.
27534 * @param {string} tag The `toStringTag` of the objects to compare.
27535 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
27536 * @param {Function} customizer The function to customize comparisons.
27537 * @param {Function} equalFunc The function to determine equivalents of values.
27538 * @param {Object} stack Tracks traversed `object` and `other` objects.
27539 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
27542 function equalByTag$1(object, other, tag, bitmask, customizer, equalFunc, stack) {
27544 case dataViewTag$2:
27545 if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
27549 object = object.buffer;
27550 other = other.buffer;
27552 case arrayBufferTag$1:
27553 if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
27562 // Coerce booleans to `1` or `0` and dates to milliseconds.
27563 // Invalid dates are coerced to `NaN`.
27564 return eq(+object, +other);
27567 return object.name == other.name && object.message == other.message;
27571 // Coerce regexes to strings and treat strings, primitives and objects,
27572 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
27573 // for more details.
27574 return object == other + '';
27577 var convert = mapToArray;
27580 var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
27581 convert || (convert = setToArray$2);
27583 if (object.size != other.size && !isPartial) {
27585 } // Assume cyclic values are equal.
27588 var stacked = stack.get(object);
27591 return stacked == other;
27594 bitmask |= COMPARE_UNORDERED_FLAG$2; // Recursively compare objects (susceptible to call stack limits).
27596 stack.set(object, other);
27597 var result = equalArrays$1(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
27598 stack['delete'](object);
27602 if (symbolValueOf) {
27603 return symbolValueOf.call(object) == symbolValueOf.call(other);
27611 var _equalByTag = equalByTag$1;
27614 * Appends the elements of `values` to `array`.
27617 * @param {Array} array The array to modify.
27618 * @param {Array} values The values to append.
27619 * @returns {Array} Returns `array`.
27622 function arrayPush$1(array, values) {
27624 length = values.length,
27625 offset = array.length;
27627 while (++index < length) {
27628 array[offset + index] = values[index];
27634 var _arrayPush = arrayPush$1;
27637 * Checks if `value` is classified as an `Array` object.
27643 * @param {*} value The value to check.
27644 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
27647 * _.isArray([1, 2, 3]);
27650 * _.isArray(document.body.children);
27653 * _.isArray('abc');
27656 * _.isArray(_.noop);
27659 var isArray$9 = Array.isArray;
27660 var isArray_1 = isArray$9;
27662 var arrayPush = _arrayPush,
27663 isArray$8 = isArray_1;
27665 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
27666 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
27667 * symbols of `object`.
27670 * @param {Object} object The object to query.
27671 * @param {Function} keysFunc The function to get the keys of `object`.
27672 * @param {Function} symbolsFunc The function to get the symbols of `object`.
27673 * @returns {Array} Returns the array of property names and symbols.
27676 function baseGetAllKeys$1(object, keysFunc, symbolsFunc) {
27677 var result = keysFunc(object);
27678 return isArray$8(object) ? result : arrayPush(result, symbolsFunc(object));
27681 var _baseGetAllKeys = baseGetAllKeys$1;
27684 * A specialized version of `_.filter` for arrays without support for
27685 * iteratee shorthands.
27688 * @param {Array} [array] The array to iterate over.
27689 * @param {Function} predicate The function invoked per iteration.
27690 * @returns {Array} Returns the new filtered array.
27693 function arrayFilter$1(array, predicate) {
27695 length = array == null ? 0 : array.length,
27699 while (++index < length) {
27700 var value = array[index];
27702 if (predicate(value, index, array)) {
27703 result[resIndex++] = value;
27710 var _arrayFilter = arrayFilter$1;
27713 * This method returns a new empty array.
27719 * @returns {Array} Returns the new empty array.
27722 * var arrays = _.times(2, _.stubArray);
27724 * console.log(arrays);
27727 * console.log(arrays[0] === arrays[1]);
27731 function stubArray$1() {
27735 var stubArray_1 = stubArray$1;
27737 var arrayFilter = _arrayFilter,
27738 stubArray = stubArray_1;
27739 /** Used for built-in method references. */
27741 var objectProto$6 = Object.prototype;
27742 /** Built-in value references. */
27744 var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
27745 /* Built-in method references for those with the same name as other `lodash` methods. */
27747 var nativeGetSymbols = Object.getOwnPropertySymbols;
27749 * Creates an array of the own enumerable symbols of `object`.
27752 * @param {Object} object The object to query.
27753 * @returns {Array} Returns the array of symbols.
27756 var getSymbols$1 = !nativeGetSymbols ? stubArray : function (object) {
27757 if (object == null) {
27761 object = Object(object);
27762 return arrayFilter(nativeGetSymbols(object), function (symbol) {
27763 return propertyIsEnumerable$1.call(object, symbol);
27766 var _getSymbols = getSymbols$1;
27769 * The base implementation of `_.times` without support for iteratee shorthands
27770 * or max array length checks.
27773 * @param {number} n The number of times to invoke `iteratee`.
27774 * @param {Function} iteratee The function invoked per iteration.
27775 * @returns {Array} Returns the array of results.
27778 function baseTimes$1(n, iteratee) {
27782 while (++index < n) {
27783 result[index] = iteratee(index);
27789 var _baseTimes = baseTimes$1;
27792 * Checks if `value` is object-like. A value is object-like if it's not `null`
27793 * and has a `typeof` result of "object".
27799 * @param {*} value The value to check.
27800 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
27803 * _.isObjectLike({});
27806 * _.isObjectLike([1, 2, 3]);
27809 * _.isObjectLike(_.noop);
27812 * _.isObjectLike(null);
27816 function isObjectLike$5(value) {
27817 return value != null && typeof value == 'object';
27820 var isObjectLike_1 = isObjectLike$5;
27822 var baseGetTag$3 = _baseGetTag,
27823 isObjectLike$4 = isObjectLike_1;
27824 /** `Object#toString` result references. */
27826 var argsTag$2 = '[object Arguments]';
27828 * The base implementation of `_.isArguments`.
27831 * @param {*} value The value to check.
27832 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
27835 function baseIsArguments$1(value) {
27836 return isObjectLike$4(value) && baseGetTag$3(value) == argsTag$2;
27839 var _baseIsArguments = baseIsArguments$1;
27841 var baseIsArguments = _baseIsArguments,
27842 isObjectLike$3 = isObjectLike_1;
27843 /** Used for built-in method references. */
27845 var objectProto$5 = Object.prototype;
27846 /** Used to check objects for own properties. */
27848 var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
27849 /** Built-in value references. */
27851 var propertyIsEnumerable = objectProto$5.propertyIsEnumerable;
27853 * Checks if `value` is likely an `arguments` object.
27859 * @param {*} value The value to check.
27860 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
27864 * _.isArguments(function() { return arguments; }());
27867 * _.isArguments([1, 2, 3]);
27871 var isArguments$2 = baseIsArguments(function () {
27873 }()) ? baseIsArguments : function (value) {
27874 return isObjectLike$3(value) && hasOwnProperty$4.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
27876 var isArguments_1 = isArguments$2;
27878 var isBuffer$2 = {exports: {}};
27881 * This method returns `false`.
27887 * @returns {boolean} Returns `false`.
27890 * _.times(2, _.stubFalse);
27891 * // => [false, false]
27894 function stubFalse() {
27898 var stubFalse_1 = stubFalse;
27900 (function (module, exports) {
27902 stubFalse = stubFalse_1;
27903 /** Detect free variable `exports`. */
27905 var freeExports = exports && !exports.nodeType && exports;
27906 /** Detect free variable `module`. */
27908 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
27909 /** Detect the popular CommonJS extension `module.exports`. */
27911 var moduleExports = freeModule && freeModule.exports === freeExports;
27912 /** Built-in value references. */
27914 var Buffer = moduleExports ? root.Buffer : undefined;
27915 /* Built-in method references for those with the same name as other `lodash` methods. */
27917 var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
27919 * Checks if `value` is a buffer.
27925 * @param {*} value The value to check.
27926 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
27929 * _.isBuffer(new Buffer(2));
27932 * _.isBuffer(new Uint8Array(2));
27936 var isBuffer = nativeIsBuffer || stubFalse;
27937 module.exports = isBuffer;
27938 })(isBuffer$2, isBuffer$2.exports);
27940 /** Used as references for various `Number` constants. */
27941 var MAX_SAFE_INTEGER$1 = 9007199254740991;
27942 /** Used to detect unsigned integer values. */
27944 var reIsUint = /^(?:0|[1-9]\d*)$/;
27946 * Checks if `value` is a valid array-like index.
27949 * @param {*} value The value to check.
27950 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
27951 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
27954 function isIndex$2(value, length) {
27955 var type = typeof value;
27956 length = length == null ? MAX_SAFE_INTEGER$1 : length;
27957 return !!length && (type == 'number' || type != 'symbol' && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
27960 var _isIndex = isIndex$2;
27962 /** Used as references for various `Number` constants. */
27963 var MAX_SAFE_INTEGER = 9007199254740991;
27965 * Checks if `value` is a valid array-like length.
27967 * **Note:** This method is loosely based on
27968 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
27974 * @param {*} value The value to check.
27975 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
27981 * _.isLength(Number.MIN_VALUE);
27984 * _.isLength(Infinity);
27991 function isLength$3(value) {
27992 return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
27995 var isLength_1 = isLength$3;
27997 var baseGetTag$2 = _baseGetTag,
27998 isLength$2 = isLength_1,
27999 isObjectLike$2 = isObjectLike_1;
28000 /** `Object#toString` result references. */
28002 var argsTag$1 = '[object Arguments]',
28003 arrayTag$1 = '[object Array]',
28004 boolTag = '[object Boolean]',
28005 dateTag = '[object Date]',
28006 errorTag = '[object Error]',
28007 funcTag = '[object Function]',
28008 mapTag$1 = '[object Map]',
28009 numberTag = '[object Number]',
28010 objectTag$2 = '[object Object]',
28011 regexpTag = '[object RegExp]',
28012 setTag$1 = '[object Set]',
28013 stringTag = '[object String]',
28014 weakMapTag$1 = '[object WeakMap]';
28015 var arrayBufferTag = '[object ArrayBuffer]',
28016 dataViewTag$1 = '[object DataView]',
28017 float32Tag = '[object Float32Array]',
28018 float64Tag = '[object Float64Array]',
28019 int8Tag = '[object Int8Array]',
28020 int16Tag = '[object Int16Array]',
28021 int32Tag = '[object Int32Array]',
28022 uint8Tag = '[object Uint8Array]',
28023 uint8ClampedTag = '[object Uint8ClampedArray]',
28024 uint16Tag = '[object Uint16Array]',
28025 uint32Tag = '[object Uint32Array]';
28026 /** Used to identify `toStringTag` values of typed arrays. */
28028 var typedArrayTags = {};
28029 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
28030 typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag$1] = typedArrayTags[numberTag] = typedArrayTags[objectTag$2] = typedArrayTags[regexpTag] = typedArrayTags[setTag$1] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag$1] = false;
28032 * The base implementation of `_.isTypedArray` without Node.js optimizations.
28035 * @param {*} value The value to check.
28036 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
28039 function baseIsTypedArray$1(value) {
28040 return isObjectLike$2(value) && isLength$2(value.length) && !!typedArrayTags[baseGetTag$2(value)];
28043 var _baseIsTypedArray = baseIsTypedArray$1;
28046 * The base implementation of `_.unary` without support for storing metadata.
28049 * @param {Function} func The function to cap arguments for.
28050 * @returns {Function} Returns the new capped function.
28053 function baseUnary$1(func) {
28054 return function (value) {
28055 return func(value);
28059 var _baseUnary = baseUnary$1;
28061 var _nodeUtil = {exports: {}};
28063 (function (module, exports) {
28064 var freeGlobal = _freeGlobal;
28065 /** Detect free variable `exports`. */
28067 var freeExports = exports && !exports.nodeType && exports;
28068 /** Detect free variable `module`. */
28070 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
28071 /** Detect the popular CommonJS extension `module.exports`. */
28073 var moduleExports = freeModule && freeModule.exports === freeExports;
28074 /** Detect free variable `process` from Node.js. */
28076 var freeProcess = moduleExports && freeGlobal.process;
28077 /** Used to access faster Node.js helpers. */
28079 var nodeUtil = function () {
28081 // Use `util.types` for Node.js 10+.
28082 var types = freeModule && freeModule.require && freeModule.require('util').types;
28086 } // Legacy `process.binding('util')` for Node.js < 10.
28089 return freeProcess && freeProcess.binding && freeProcess.binding('util');
28093 module.exports = nodeUtil;
28094 })(_nodeUtil, _nodeUtil.exports);
28096 var baseIsTypedArray = _baseIsTypedArray,
28097 baseUnary = _baseUnary,
28098 nodeUtil = _nodeUtil.exports;
28099 /* Node.js helper references. */
28101 var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
28103 * Checks if `value` is classified as a typed array.
28109 * @param {*} value The value to check.
28110 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
28113 * _.isTypedArray(new Uint8Array);
28116 * _.isTypedArray([]);
28120 var isTypedArray$2 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
28121 var isTypedArray_1 = isTypedArray$2;
28123 var baseTimes = _baseTimes,
28124 isArguments$1 = isArguments_1,
28125 isArray$7 = isArray_1,
28126 isBuffer$1 = isBuffer$2.exports,
28127 isIndex$1 = _isIndex,
28128 isTypedArray$1 = isTypedArray_1;
28129 /** Used for built-in method references. */
28131 var objectProto$4 = Object.prototype;
28132 /** Used to check objects for own properties. */
28134 var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
28136 * Creates an array of the enumerable property names of the array-like `value`.
28139 * @param {*} value The value to query.
28140 * @param {boolean} inherited Specify returning inherited property names.
28141 * @returns {Array} Returns the array of property names.
28144 function arrayLikeKeys$1(value, inherited) {
28145 var isArr = isArray$7(value),
28146 isArg = !isArr && isArguments$1(value),
28147 isBuff = !isArr && !isArg && isBuffer$1(value),
28148 isType = !isArr && !isArg && !isBuff && isTypedArray$1(value),
28149 skipIndexes = isArr || isArg || isBuff || isType,
28150 result = skipIndexes ? baseTimes(value.length, String) : [],
28151 length = result.length;
28153 for (var key in value) {
28154 if ((inherited || hasOwnProperty$3.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode.
28155 key == 'length' || // Node.js 0.10 has enumerable non-index properties on buffers.
28156 isBuff && (key == 'offset' || key == 'parent') || // PhantomJS 2 has enumerable non-index properties on typed arrays.
28157 isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || // Skip index properties.
28158 isIndex$1(key, length)))) {
28166 var _arrayLikeKeys = arrayLikeKeys$1;
28168 /** Used for built-in method references. */
28169 var objectProto$3 = Object.prototype;
28171 * Checks if `value` is likely a prototype object.
28174 * @param {*} value The value to check.
28175 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
28178 function isPrototype$1(value) {
28179 var Ctor = value && value.constructor,
28180 proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$3;
28181 return value === proto;
28184 var _isPrototype = isPrototype$1;
28187 * Creates a unary function that invokes `func` with its argument transformed.
28190 * @param {Function} func The function to wrap.
28191 * @param {Function} transform The argument transform.
28192 * @returns {Function} Returns the new function.
28195 function overArg$1(func, transform) {
28196 return function (arg) {
28197 return func(transform(arg));
28201 var _overArg = overArg$1;
28203 var overArg = _overArg;
28204 /* Built-in method references for those with the same name as other `lodash` methods. */
28206 var nativeKeys$1 = overArg(Object.keys, Object);
28207 var _nativeKeys = nativeKeys$1;
28209 var isPrototype = _isPrototype,
28210 nativeKeys = _nativeKeys;
28211 /** Used for built-in method references. */
28213 var objectProto$2 = Object.prototype;
28214 /** Used to check objects for own properties. */
28216 var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
28218 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
28221 * @param {Object} object The object to query.
28222 * @returns {Array} Returns the array of property names.
28225 function baseKeys$1(object) {
28226 if (!isPrototype(object)) {
28227 return nativeKeys(object);
28232 for (var key in Object(object)) {
28233 if (hasOwnProperty$2.call(object, key) && key != 'constructor') {
28241 var _baseKeys = baseKeys$1;
28243 var isFunction = isFunction_1,
28244 isLength$1 = isLength_1;
28246 * Checks if `value` is array-like. A value is considered array-like if it's
28247 * not a function and has a `value.length` that's an integer greater than or
28248 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
28254 * @param {*} value The value to check.
28255 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
28258 * _.isArrayLike([1, 2, 3]);
28261 * _.isArrayLike(document.body.children);
28264 * _.isArrayLike('abc');
28267 * _.isArrayLike(_.noop);
28271 function isArrayLike$2(value) {
28272 return value != null && isLength$1(value.length) && !isFunction(value);
28275 var isArrayLike_1 = isArrayLike$2;
28277 var arrayLikeKeys = _arrayLikeKeys,
28278 baseKeys = _baseKeys,
28279 isArrayLike$1 = isArrayLike_1;
28281 * Creates an array of the own enumerable property names of `object`.
28283 * **Note:** Non-object values are coerced to objects. See the
28284 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
28285 * for more details.
28291 * @param {Object} object The object to query.
28292 * @returns {Array} Returns the array of property names.
28300 * Foo.prototype.c = 3;
28303 * // => ['a', 'b'] (iteration order is not guaranteed)
28309 function keys$3(object) {
28310 return isArrayLike$1(object) ? arrayLikeKeys(object) : baseKeys(object);
28313 var keys_1 = keys$3;
28315 var baseGetAllKeys = _baseGetAllKeys,
28316 getSymbols = _getSymbols,
28319 * Creates an array of own enumerable property names and symbols of `object`.
28322 * @param {Object} object The object to query.
28323 * @returns {Array} Returns the array of property names and symbols.
28326 function getAllKeys$1(object) {
28327 return baseGetAllKeys(object, keys$2, getSymbols);
28330 var _getAllKeys = getAllKeys$1;
28332 var getAllKeys = _getAllKeys;
28333 /** Used to compose bitmasks for value comparisons. */
28335 var COMPARE_PARTIAL_FLAG$3 = 1;
28336 /** Used for built-in method references. */
28338 var objectProto$1 = Object.prototype;
28339 /** Used to check objects for own properties. */
28341 var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
28343 * A specialized version of `baseIsEqualDeep` for objects with support for
28344 * partial deep comparisons.
28347 * @param {Object} object The object to compare.
28348 * @param {Object} other The other object to compare.
28349 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
28350 * @param {Function} customizer The function to customize comparisons.
28351 * @param {Function} equalFunc The function to determine equivalents of values.
28352 * @param {Object} stack Tracks traversed `object` and `other` objects.
28353 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
28356 function equalObjects$1(object, other, bitmask, customizer, equalFunc, stack) {
28357 var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
28358 objProps = getAllKeys(object),
28359 objLength = objProps.length,
28360 othProps = getAllKeys(other),
28361 othLength = othProps.length;
28363 if (objLength != othLength && !isPartial) {
28367 var index = objLength;
28370 var key = objProps[index];
28372 if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
28375 } // Check that cyclic values are equal.
28378 var objStacked = stack.get(object);
28379 var othStacked = stack.get(other);
28381 if (objStacked && othStacked) {
28382 return objStacked == other && othStacked == object;
28386 stack.set(object, other);
28387 stack.set(other, object);
28388 var skipCtor = isPartial;
28390 while (++index < objLength) {
28391 key = objProps[index];
28392 var objValue = object[key],
28393 othValue = other[key];
28396 var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
28397 } // Recursively compare objects (susceptible to call stack limits).
28400 if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
28405 skipCtor || (skipCtor = key == 'constructor');
28408 if (result && !skipCtor) {
28409 var objCtor = object.constructor,
28410 othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal.
28412 if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
28417 stack['delete'](object);
28418 stack['delete'](other);
28422 var _equalObjects = equalObjects$1;
28424 var getNative$3 = _getNative,
28426 /* Built-in method references that are verified to be native. */
28428 var DataView$1 = getNative$3(root$3, 'DataView');
28429 var _DataView = DataView$1;
28431 var getNative$2 = _getNative,
28433 /* Built-in method references that are verified to be native. */
28435 var Promise$2 = getNative$2(root$2, 'Promise');
28436 var _Promise = Promise$2;
28438 var getNative$1 = _getNative,
28440 /* Built-in method references that are verified to be native. */
28442 var Set$3 = getNative$1(root$1, 'Set');
28445 var getNative = _getNative,
28447 /* Built-in method references that are verified to be native. */
28449 var WeakMap$2 = getNative(root, 'WeakMap');
28450 var _WeakMap = WeakMap$2;
28452 var DataView = _DataView,
28454 Promise$1 = _Promise,
28456 WeakMap$1 = _WeakMap,
28457 baseGetTag$1 = _baseGetTag,
28458 toSource = _toSource;
28459 /** `Object#toString` result references. */
28461 var mapTag = '[object Map]',
28462 objectTag$1 = '[object Object]',
28463 promiseTag = '[object Promise]',
28464 setTag = '[object Set]',
28465 weakMapTag = '[object WeakMap]';
28466 var dataViewTag = '[object DataView]';
28467 /** Used to detect maps, sets, and weakmaps. */
28469 var dataViewCtorString = toSource(DataView),
28470 mapCtorString = toSource(Map$1),
28471 promiseCtorString = toSource(Promise$1),
28472 setCtorString = toSource(Set$2),
28473 weakMapCtorString = toSource(WeakMap$1);
28475 * Gets the `toStringTag` of `value`.
28478 * @param {*} value The value to query.
28479 * @returns {string} Returns the `toStringTag`.
28482 var getTag$1 = baseGetTag$1; // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
28484 if (DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag || Map$1 && getTag$1(new Map$1()) != mapTag || Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag || Set$2 && getTag$1(new Set$2()) != setTag || WeakMap$1 && getTag$1(new WeakMap$1()) != weakMapTag) {
28485 getTag$1 = function (value) {
28486 var result = baseGetTag$1(value),
28487 Ctor = result == objectTag$1 ? value.constructor : undefined,
28488 ctorString = Ctor ? toSource(Ctor) : '';
28491 switch (ctorString) {
28492 case dataViewCtorString:
28493 return dataViewTag;
28495 case mapCtorString:
28498 case promiseCtorString:
28501 case setCtorString:
28504 case weakMapCtorString:
28513 var _getTag = getTag$1;
28515 var Stack$1 = _Stack,
28516 equalArrays = _equalArrays,
28517 equalByTag = _equalByTag,
28518 equalObjects = _equalObjects,
28520 isArray$6 = isArray_1,
28521 isBuffer = isBuffer$2.exports,
28522 isTypedArray = isTypedArray_1;
28523 /** Used to compose bitmasks for value comparisons. */
28525 var COMPARE_PARTIAL_FLAG$2 = 1;
28526 /** `Object#toString` result references. */
28528 var argsTag = '[object Arguments]',
28529 arrayTag = '[object Array]',
28530 objectTag = '[object Object]';
28531 /** Used for built-in method references. */
28533 var objectProto = Object.prototype;
28534 /** Used to check objects for own properties. */
28536 var hasOwnProperty = objectProto.hasOwnProperty;
28538 * A specialized version of `baseIsEqual` for arrays and objects which performs
28539 * deep comparisons and tracks traversed objects enabling objects with circular
28540 * references to be compared.
28543 * @param {Object} object The object to compare.
28544 * @param {Object} other The other object to compare.
28545 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
28546 * @param {Function} customizer The function to customize comparisons.
28547 * @param {Function} equalFunc The function to determine equivalents of values.
28548 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
28549 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
28552 function baseIsEqualDeep$1(object, other, bitmask, customizer, equalFunc, stack) {
28553 var objIsArr = isArray$6(object),
28554 othIsArr = isArray$6(other),
28555 objTag = objIsArr ? arrayTag : getTag(object),
28556 othTag = othIsArr ? arrayTag : getTag(other);
28557 objTag = objTag == argsTag ? objectTag : objTag;
28558 othTag = othTag == argsTag ? objectTag : othTag;
28559 var objIsObj = objTag == objectTag,
28560 othIsObj = othTag == objectTag,
28561 isSameTag = objTag == othTag;
28563 if (isSameTag && isBuffer(object)) {
28564 if (!isBuffer(other)) {
28572 if (isSameTag && !objIsObj) {
28573 stack || (stack = new Stack$1());
28574 return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
28577 if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
28578 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
28579 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
28581 if (objIsWrapped || othIsWrapped) {
28582 var objUnwrapped = objIsWrapped ? object.value() : object,
28583 othUnwrapped = othIsWrapped ? other.value() : other;
28584 stack || (stack = new Stack$1());
28585 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
28593 stack || (stack = new Stack$1());
28594 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
28597 var _baseIsEqualDeep = baseIsEqualDeep$1;
28599 var baseIsEqualDeep = _baseIsEqualDeep,
28600 isObjectLike$1 = isObjectLike_1;
28602 * The base implementation of `_.isEqual` which supports partial comparisons
28603 * and tracks traversed objects.
28606 * @param {*} value The value to compare.
28607 * @param {*} other The other value to compare.
28608 * @param {boolean} bitmask The bitmask flags.
28609 * 1 - Unordered comparison
28610 * 2 - Partial comparison
28611 * @param {Function} [customizer] The function to customize comparisons.
28612 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
28613 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
28616 function baseIsEqual$2(value, other, bitmask, customizer, stack) {
28617 if (value === other) {
28621 if (value == null || other == null || !isObjectLike$1(value) && !isObjectLike$1(other)) {
28622 return value !== value && other !== other;
28625 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual$2, stack);
28628 var _baseIsEqual = baseIsEqual$2;
28630 var Stack = _Stack,
28631 baseIsEqual$1 = _baseIsEqual;
28632 /** Used to compose bitmasks for value comparisons. */
28634 var COMPARE_PARTIAL_FLAG$1 = 1,
28635 COMPARE_UNORDERED_FLAG$1 = 2;
28637 * The base implementation of `_.isMatch` without support for iteratee shorthands.
28640 * @param {Object} object The object to inspect.
28641 * @param {Object} source The object of property values to match.
28642 * @param {Array} matchData The property names, values, and compare flags to match.
28643 * @param {Function} [customizer] The function to customize comparisons.
28644 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
28647 function baseIsMatch$1(object, source, matchData, customizer) {
28648 var index = matchData.length,
28650 noCustomizer = !customizer;
28652 if (object == null) {
28656 object = Object(object);
28659 var data = matchData[index];
28661 if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
28666 while (++index < length) {
28667 data = matchData[index];
28669 objValue = object[key],
28670 srcValue = data[1];
28672 if (noCustomizer && data[2]) {
28673 if (objValue === undefined && !(key in object)) {
28677 var stack = new Stack();
28680 var result = customizer(objValue, srcValue, key, object, source, stack);
28683 if (!(result === undefined ? baseIsEqual$1(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) : result)) {
28692 var _baseIsMatch = baseIsMatch$1;
28694 var isObject$2 = isObject_1;
28696 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
28699 * @param {*} value The value to check.
28700 * @returns {boolean} Returns `true` if `value` if suitable for strict
28701 * equality comparisons, else `false`.
28704 function isStrictComparable$2(value) {
28705 return value === value && !isObject$2(value);
28708 var _isStrictComparable = isStrictComparable$2;
28710 var isStrictComparable$1 = _isStrictComparable,
28713 * Gets the property names, values, and compare flags of `object`.
28716 * @param {Object} object The object to query.
28717 * @returns {Array} Returns the match data of `object`.
28720 function getMatchData$1(object) {
28721 var result = keys$1(object),
28722 length = result.length;
28725 var key = result[length],
28726 value = object[key];
28727 result[length] = [key, value, isStrictComparable$1(value)];
28733 var _getMatchData = getMatchData$1;
28736 * A specialized version of `matchesProperty` for source values suitable
28737 * for strict equality comparisons, i.e. `===`.
28740 * @param {string} key The key of the property to get.
28741 * @param {*} srcValue The value to match.
28742 * @returns {Function} Returns the new spec function.
28745 function matchesStrictComparable$2(key, srcValue) {
28746 return function (object) {
28747 if (object == null) {
28751 return object[key] === srcValue && (srcValue !== undefined || key in Object(object));
28755 var _matchesStrictComparable = matchesStrictComparable$2;
28757 var baseIsMatch = _baseIsMatch,
28758 getMatchData = _getMatchData,
28759 matchesStrictComparable$1 = _matchesStrictComparable;
28761 * The base implementation of `_.matches` which doesn't clone `source`.
28764 * @param {Object} source The object of property values to match.
28765 * @returns {Function} Returns the new spec function.
28768 function baseMatches$1(source) {
28769 var matchData = getMatchData(source);
28771 if (matchData.length == 1 && matchData[0][2]) {
28772 return matchesStrictComparable$1(matchData[0][0], matchData[0][1]);
28775 return function (object) {
28776 return object === source || baseIsMatch(object, source, matchData);
28780 var _baseMatches = baseMatches$1;
28782 var baseGetTag = _baseGetTag,
28783 isObjectLike = isObjectLike_1;
28784 /** `Object#toString` result references. */
28786 var symbolTag = '[object Symbol]';
28788 * Checks if `value` is classified as a `Symbol` primitive or object.
28794 * @param {*} value The value to check.
28795 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
28798 * _.isSymbol(Symbol.iterator);
28801 * _.isSymbol('abc');
28805 function isSymbol$3(value) {
28806 return typeof value == 'symbol' || isObjectLike(value) && baseGetTag(value) == symbolTag;
28809 var isSymbol_1 = isSymbol$3;
28811 var isArray$5 = isArray_1,
28812 isSymbol$2 = isSymbol_1;
28813 /** Used to match property names within property paths. */
28815 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
28816 reIsPlainProp = /^\w*$/;
28818 * Checks if `value` is a property name and not a property path.
28821 * @param {*} value The value to check.
28822 * @param {Object} [object] The object to query keys on.
28823 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
28826 function isKey$3(value, object) {
28827 if (isArray$5(value)) {
28831 var type = typeof value;
28833 if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol$2(value)) {
28837 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
28840 var _isKey = isKey$3;
28842 var MapCache = _MapCache;
28843 /** Error message constants. */
28845 var FUNC_ERROR_TEXT = 'Expected a function';
28847 * Creates a function that memoizes the result of `func`. If `resolver` is
28848 * provided, it determines the cache key for storing the result based on the
28849 * arguments provided to the memoized function. By default, the first argument
28850 * provided to the memoized function is used as the map cache key. The `func`
28851 * is invoked with the `this` binding of the memoized function.
28853 * **Note:** The cache is exposed as the `cache` property on the memoized
28854 * function. Its creation may be customized by replacing the `_.memoize.Cache`
28855 * constructor with one whose instances implement the
28856 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
28857 * method interface of `clear`, `delete`, `get`, `has`, and `set`.
28862 * @category Function
28863 * @param {Function} func The function to have its output memoized.
28864 * @param {Function} [resolver] The function to resolve the cache key.
28865 * @returns {Function} Returns the new memoized function.
28868 * var object = { 'a': 1, 'b': 2 };
28869 * var other = { 'c': 3, 'd': 4 };
28871 * var values = _.memoize(_.values);
28882 * // Modify the result cache.
28883 * values.cache.set(object, ['a', 'b']);
28887 * // Replace `_.memoize.Cache`.
28888 * _.memoize.Cache = WeakMap;
28891 function memoize$1(func, resolver) {
28892 if (typeof func != 'function' || resolver != null && typeof resolver != 'function') {
28893 throw new TypeError(FUNC_ERROR_TEXT);
28896 var memoized = function () {
28897 var args = arguments,
28898 key = resolver ? resolver.apply(this, args) : args[0],
28899 cache = memoized.cache;
28901 if (cache.has(key)) {
28902 return cache.get(key);
28905 var result = func.apply(this, args);
28906 memoized.cache = cache.set(key, result) || cache;
28910 memoized.cache = new (memoize$1.Cache || MapCache)();
28912 } // Expose `MapCache`.
28915 memoize$1.Cache = MapCache;
28916 var memoize_1 = memoize$1;
28918 var memoize = memoize_1;
28919 /** Used as the maximum memoize cache size. */
28921 var MAX_MEMOIZE_SIZE = 500;
28923 * A specialized version of `_.memoize` which clears the memoized function's
28924 * cache when it exceeds `MAX_MEMOIZE_SIZE`.
28927 * @param {Function} func The function to have its output memoized.
28928 * @returns {Function} Returns the new memoized function.
28931 function memoizeCapped$1(func) {
28932 var result = memoize(func, function (key) {
28933 if (cache.size === MAX_MEMOIZE_SIZE) {
28939 var cache = result.cache;
28943 var _memoizeCapped = memoizeCapped$1;
28945 var memoizeCapped = _memoizeCapped;
28946 /** Used to match property names within property paths. */
28948 var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
28949 /** Used to match backslashes in property paths. */
28951 var reEscapeChar = /\\(\\)?/g;
28953 * Converts `string` to a property path array.
28956 * @param {string} string The string to convert.
28957 * @returns {Array} Returns the property path array.
28960 var stringToPath$1 = memoizeCapped(function (string) {
28963 if (string.charCodeAt(0) === 46
28969 string.replace(rePropName, function (match, number, quote, subString) {
28970 result.push(quote ? subString.replace(reEscapeChar, '$1') : number || match);
28974 var _stringToPath = stringToPath$1;
28977 * A specialized version of `_.map` for arrays without support for iteratee
28981 * @param {Array} [array] The array to iterate over.
28982 * @param {Function} iteratee The function invoked per iteration.
28983 * @returns {Array} Returns the new mapped array.
28986 function arrayMap$1(array, iteratee) {
28988 length = array == null ? 0 : array.length,
28989 result = Array(length);
28991 while (++index < length) {
28992 result[index] = iteratee(array[index], index, array);
28998 var _arrayMap = arrayMap$1;
29000 var Symbol$1 = _Symbol,
29001 arrayMap = _arrayMap,
29002 isArray$4 = isArray_1,
29003 isSymbol$1 = isSymbol_1;
29004 /** Used as references for various `Number` constants. */
29006 var INFINITY$2 = 1 / 0;
29007 /** Used to convert symbols to primitives and strings. */
29009 var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
29010 symbolToString = symbolProto ? symbolProto.toString : undefined;
29012 * The base implementation of `_.toString` which doesn't convert nullish
29013 * values to empty strings.
29016 * @param {*} value The value to process.
29017 * @returns {string} Returns the string.
29020 function baseToString$1(value) {
29021 // Exit early for strings to avoid a performance hit in some environments.
29022 if (typeof value == 'string') {
29026 if (isArray$4(value)) {
29027 // Recursively convert values (susceptible to call stack limits).
29028 return arrayMap(value, baseToString$1) + '';
29031 if (isSymbol$1(value)) {
29032 return symbolToString ? symbolToString.call(value) : '';
29035 var result = value + '';
29036 return result == '0' && 1 / value == -INFINITY$2 ? '-0' : result;
29039 var _baseToString = baseToString$1;
29041 var baseToString = _baseToString;
29043 * Converts `value` to a string. An empty string is returned for `null`
29044 * and `undefined` values. The sign of `-0` is preserved.
29050 * @param {*} value The value to convert.
29051 * @returns {string} Returns the converted string.
29054 * _.toString(null);
29060 * _.toString([1, 2, 3]);
29064 function toString$1(value) {
29065 return value == null ? '' : baseToString(value);
29068 var toString_1 = toString$1;
29070 var isArray$3 = isArray_1,
29072 stringToPath = _stringToPath,
29073 toString = toString_1;
29075 * Casts `value` to a path array if it's not one.
29078 * @param {*} value The value to inspect.
29079 * @param {Object} [object] The object to query keys on.
29080 * @returns {Array} Returns the cast property path array.
29083 function castPath$2(value, object) {
29084 if (isArray$3(value)) {
29088 return isKey$2(value, object) ? [value] : stringToPath(toString(value));
29091 var _castPath = castPath$2;
29093 var isSymbol = isSymbol_1;
29094 /** Used as references for various `Number` constants. */
29096 var INFINITY$1 = 1 / 0;
29098 * Converts `value` to a string key if it's not a string or symbol.
29101 * @param {*} value The value to inspect.
29102 * @returns {string|symbol} Returns the key.
29105 function toKey$4(value) {
29106 if (typeof value == 'string' || isSymbol(value)) {
29110 var result = value + '';
29111 return result == '0' && 1 / value == -INFINITY$1 ? '-0' : result;
29114 var _toKey = toKey$4;
29116 var castPath$1 = _castPath,
29119 * The base implementation of `_.get` without support for default values.
29122 * @param {Object} object The object to query.
29123 * @param {Array|string} path The path of the property to get.
29124 * @returns {*} Returns the resolved value.
29127 function baseGet$2(object, path) {
29128 path = castPath$1(path, object);
29130 length = path.length;
29132 while (object != null && index < length) {
29133 object = object[toKey$3(path[index++])];
29136 return index && index == length ? object : undefined;
29139 var _baseGet = baseGet$2;
29141 var baseGet$1 = _baseGet;
29143 * Gets the value at `path` of `object`. If the resolved value is
29144 * `undefined`, the `defaultValue` is returned in its place.
29150 * @param {Object} object The object to query.
29151 * @param {Array|string} path The path of the property to get.
29152 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
29153 * @returns {*} Returns the resolved value.
29156 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
29158 * _.get(object, 'a[0].b.c');
29161 * _.get(object, ['a', '0', 'b', 'c']);
29164 * _.get(object, 'a.b.c', 'default');
29168 function get$1(object, path, defaultValue) {
29169 var result = object == null ? undefined : baseGet$1(object, path);
29170 return result === undefined ? defaultValue : result;
29176 * The base implementation of `_.hasIn` without support for deep paths.
29179 * @param {Object} [object] The object to query.
29180 * @param {Array|string} key The key to check.
29181 * @returns {boolean} Returns `true` if `key` exists, else `false`.
29184 function baseHasIn$1(object, key) {
29185 return object != null && key in Object(object);
29188 var _baseHasIn = baseHasIn$1;
29190 var castPath = _castPath,
29191 isArguments = isArguments_1,
29192 isArray$2 = isArray_1,
29193 isIndex = _isIndex,
29194 isLength = isLength_1,
29197 * Checks if `path` exists on `object`.
29200 * @param {Object} object The object to query.
29201 * @param {Array|string} path The path to check.
29202 * @param {Function} hasFunc The function to check properties.
29203 * @returns {boolean} Returns `true` if `path` exists, else `false`.
29206 function hasPath$1(object, path, hasFunc) {
29207 path = castPath(path, object);
29209 length = path.length,
29212 while (++index < length) {
29213 var key = toKey$2(path[index]);
29215 if (!(result = object != null && hasFunc(object, key))) {
29219 object = object[key];
29222 if (result || ++index != length) {
29226 length = object == null ? 0 : object.length;
29227 return !!length && isLength(length) && isIndex(key, length) && (isArray$2(object) || isArguments(object));
29230 var _hasPath = hasPath$1;
29232 var baseHasIn = _baseHasIn,
29233 hasPath = _hasPath;
29235 * Checks if `path` is a direct or inherited property of `object`.
29241 * @param {Object} object The object to query.
29242 * @param {Array|string} path The path to check.
29243 * @returns {boolean} Returns `true` if `path` exists, else `false`.
29246 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
29248 * _.hasIn(object, 'a');
29251 * _.hasIn(object, 'a.b');
29254 * _.hasIn(object, ['a', 'b']);
29257 * _.hasIn(object, 'b');
29261 function hasIn$1(object, path) {
29262 return object != null && hasPath(object, path, baseHasIn);
29265 var hasIn_1 = hasIn$1;
29267 var baseIsEqual = _baseIsEqual,
29271 isStrictComparable = _isStrictComparable,
29272 matchesStrictComparable = _matchesStrictComparable,
29274 /** Used to compose bitmasks for value comparisons. */
29276 var COMPARE_PARTIAL_FLAG = 1,
29277 COMPARE_UNORDERED_FLAG = 2;
29279 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
29282 * @param {string} path The path of the property to get.
29283 * @param {*} srcValue The value to match.
29284 * @returns {Function} Returns the new spec function.
29287 function baseMatchesProperty$1(path, srcValue) {
29288 if (isKey$1(path) && isStrictComparable(srcValue)) {
29289 return matchesStrictComparable(toKey$1(path), srcValue);
29292 return function (object) {
29293 var objValue = get(object, path);
29294 return objValue === undefined && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
29298 var _baseMatchesProperty = baseMatchesProperty$1;
29301 * This method returns the first argument it receives.
29307 * @param {*} value Any value.
29308 * @returns {*} Returns `value`.
29311 * var object = { 'a': 1 };
29313 * console.log(_.identity(object) === object);
29317 function identity$3(value) {
29321 var identity_1 = identity$3;
29324 * The base implementation of `_.property` without support for deep paths.
29327 * @param {string} key The key of the property to get.
29328 * @returns {Function} Returns the new accessor function.
29331 function baseProperty$1(key) {
29332 return function (object) {
29333 return object == null ? undefined : object[key];
29337 var _baseProperty = baseProperty$1;
29339 var baseGet = _baseGet;
29341 * A specialized version of `baseProperty` which supports deep paths.
29344 * @param {Array|string} path The path of the property to get.
29345 * @returns {Function} Returns the new accessor function.
29348 function basePropertyDeep$1(path) {
29349 return function (object) {
29350 return baseGet(object, path);
29354 var _basePropertyDeep = basePropertyDeep$1;
29356 var baseProperty = _baseProperty,
29357 basePropertyDeep = _basePropertyDeep,
29361 * Creates a function that returns the value at `path` of a given object.
29367 * @param {Array|string} path The path of the property to get.
29368 * @returns {Function} Returns the new accessor function.
29372 * { 'a': { 'b': 2 } },
29373 * { 'a': { 'b': 1 } }
29376 * _.map(objects, _.property('a.b'));
29379 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
29383 function property$2(path) {
29384 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
29387 var property_1 = property$2;
29389 var baseMatches = _baseMatches,
29390 baseMatchesProperty = _baseMatchesProperty,
29391 identity$2 = identity_1,
29392 isArray$1 = isArray_1,
29393 property$1 = property_1;
29395 * The base implementation of `_.iteratee`.
29398 * @param {*} [value=_.identity] The value to convert to an iteratee.
29399 * @returns {Function} Returns the iteratee.
29402 function baseIteratee$2(value) {
29403 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
29404 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
29405 if (typeof value == 'function') {
29409 if (value == null) {
29413 if (typeof value == 'object') {
29414 return isArray$1(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
29417 return property$1(value);
29420 var _baseIteratee = baseIteratee$2;
29423 * The base implementation of `_.findIndex` and `_.findLastIndex` without
29424 * support for iteratee shorthands.
29427 * @param {Array} array The array to inspect.
29428 * @param {Function} predicate The function invoked per iteration.
29429 * @param {number} fromIndex The index to search from.
29430 * @param {boolean} [fromRight] Specify iterating from right to left.
29431 * @returns {number} Returns the index of the matched value, else `-1`.
29434 function baseFindIndex$1(array, predicate, fromIndex, fromRight) {
29435 var length = array.length,
29436 index = fromIndex + (fromRight ? 1 : -1);
29438 while (fromRight ? index-- : ++index < length) {
29439 if (predicate(array[index], index, array)) {
29447 var _baseFindIndex = baseFindIndex$1;
29450 * The base implementation of `_.isNaN` without support for number objects.
29453 * @param {*} value The value to check.
29454 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
29457 function baseIsNaN$1(value) {
29458 return value !== value;
29461 var _baseIsNaN = baseIsNaN$1;
29464 * A specialized version of `_.indexOf` which performs strict equality
29465 * comparisons of values, i.e. `===`.
29468 * @param {Array} array The array to inspect.
29469 * @param {*} value The value to search for.
29470 * @param {number} fromIndex The index to search from.
29471 * @returns {number} Returns the index of the matched value, else `-1`.
29474 function strictIndexOf$1(array, value, fromIndex) {
29475 var index = fromIndex - 1,
29476 length = array.length;
29478 while (++index < length) {
29479 if (array[index] === value) {
29487 var _strictIndexOf = strictIndexOf$1;
29489 var baseFindIndex = _baseFindIndex,
29490 baseIsNaN = _baseIsNaN,
29491 strictIndexOf = _strictIndexOf;
29493 * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
29496 * @param {Array} array The array to inspect.
29497 * @param {*} value The value to search for.
29498 * @param {number} fromIndex The index to search from.
29499 * @returns {number} Returns the index of the matched value, else `-1`.
29502 function baseIndexOf$1(array, value, fromIndex) {
29503 return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex);
29506 var _baseIndexOf = baseIndexOf$1;
29508 var baseIndexOf = _baseIndexOf;
29510 * A specialized version of `_.includes` for arrays without support for
29511 * specifying an index to search from.
29514 * @param {Array} [array] The array to inspect.
29515 * @param {*} target The value to search for.
29516 * @returns {boolean} Returns `true` if `target` is found, else `false`.
29519 function arrayIncludes$1(array, value) {
29520 var length = array == null ? 0 : array.length;
29521 return !!length && baseIndexOf(array, value, 0) > -1;
29524 var _arrayIncludes = arrayIncludes$1;
29527 * This function is like `arrayIncludes` except that it accepts a comparator.
29530 * @param {Array} [array] The array to inspect.
29531 * @param {*} target The value to search for.
29532 * @param {Function} comparator The comparator invoked per element.
29533 * @returns {boolean} Returns `true` if `target` is found, else `false`.
29536 function arrayIncludesWith$1(array, value, comparator) {
29538 length = array == null ? 0 : array.length;
29540 while (++index < length) {
29541 if (comparator(value, array[index])) {
29549 var _arrayIncludesWith = arrayIncludesWith$1;
29552 * This method returns `undefined`.
29560 * _.times(2, _.noop);
29561 * // => [undefined, undefined]
29564 function noop$2() {// No operation performed.
29567 var noop_1 = noop$2;
29571 setToArray$1 = _setToArray;
29572 /** Used as references for various `Number` constants. */
29574 var INFINITY = 1 / 0;
29576 * Creates a set object of `values`.
29579 * @param {Array} values The values to add to the set.
29580 * @returns {Object} Returns the new set.
29583 var createSet$1 = !(Set$1 && 1 / setToArray$1(new Set$1([, -0]))[1] == INFINITY) ? noop$1 : function (values) {
29584 return new Set$1(values);
29586 var _createSet = createSet$1;
29588 var SetCache = _SetCache,
29589 arrayIncludes = _arrayIncludes,
29590 arrayIncludesWith = _arrayIncludesWith,
29591 cacheHas = _cacheHas,
29592 createSet = _createSet,
29593 setToArray = _setToArray;
29594 /** Used as the size to enable large array optimizations. */
29596 var LARGE_ARRAY_SIZE = 200;
29598 * The base implementation of `_.uniqBy` without support for iteratee shorthands.
29601 * @param {Array} array The array to inspect.
29602 * @param {Function} [iteratee] The iteratee invoked per element.
29603 * @param {Function} [comparator] The comparator invoked per element.
29604 * @returns {Array} Returns the new duplicate free array.
29607 function baseUniq$1(array, iteratee, comparator) {
29609 includes = arrayIncludes,
29610 length = array.length,
29617 includes = arrayIncludesWith;
29618 } else if (length >= LARGE_ARRAY_SIZE) {
29619 var set = iteratee ? null : createSet(array);
29622 return setToArray(set);
29626 includes = cacheHas;
29627 seen = new SetCache();
29629 seen = iteratee ? [] : result;
29632 outer: while (++index < length) {
29633 var value = array[index],
29634 computed = iteratee ? iteratee(value) : value;
29635 value = comparator || value !== 0 ? value : 0;
29637 if (isCommon && computed === computed) {
29638 var seenIndex = seen.length;
29640 while (seenIndex--) {
29641 if (seen[seenIndex] === computed) {
29647 seen.push(computed);
29650 result.push(value);
29651 } else if (!includes(seen, computed, comparator)) {
29652 if (seen !== result) {
29653 seen.push(computed);
29656 result.push(value);
29663 var _baseUniq = baseUniq$1;
29665 var baseIteratee$1 = _baseIteratee,
29666 baseUniq = _baseUniq;
29668 * This method is like `_.uniq` except that it accepts `iteratee` which is
29669 * invoked for each element in `array` to generate the criterion by which
29670 * uniqueness is computed. The order of result values is determined by the
29671 * order they occur in the array. The iteratee is invoked with one argument:
29678 * @param {Array} array The array to inspect.
29679 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
29680 * @returns {Array} Returns the new duplicate free array.
29683 * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
29686 * // The `_.property` iteratee shorthand.
29687 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
29688 * // => [{ 'x': 1 }, { 'x': 2 }]
29691 function uniqBy$1(array, iteratee) {
29692 return array && array.length ? baseUniq(array, baseIteratee$1(iteratee)) : [];
29695 var uniqBy_1 = uniqBy$1;
29698 * A specialized version of `baseAggregator` for arrays.
29701 * @param {Array} [array] The array to iterate over.
29702 * @param {Function} setter The function to set `accumulator` values.
29703 * @param {Function} iteratee The iteratee to transform keys.
29704 * @param {Object} accumulator The initial aggregated object.
29705 * @returns {Function} Returns `accumulator`.
29708 function arrayAggregator$1(array, setter, iteratee, accumulator) {
29710 length = array == null ? 0 : array.length;
29712 while (++index < length) {
29713 var value = array[index];
29714 setter(accumulator, value, iteratee(value), array);
29717 return accumulator;
29720 var _arrayAggregator = arrayAggregator$1;
29723 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
29726 * @param {boolean} [fromRight] Specify iterating from right to left.
29727 * @returns {Function} Returns the new base function.
29730 function createBaseFor$1(fromRight) {
29731 return function (object, iteratee, keysFunc) {
29733 iterable = Object(object),
29734 props = keysFunc(object),
29735 length = props.length;
29738 var key = props[fromRight ? length : ++index];
29740 if (iteratee(iterable[key], key, iterable) === false) {
29749 var _createBaseFor = createBaseFor$1;
29751 var createBaseFor = _createBaseFor;
29753 * The base implementation of `baseForOwn` which iterates over `object`
29754 * properties returned by `keysFunc` and invokes `iteratee` for each property.
29755 * Iteratee functions may exit iteration early by explicitly returning `false`.
29758 * @param {Object} object The object to iterate over.
29759 * @param {Function} iteratee The function invoked per iteration.
29760 * @param {Function} keysFunc The function to get the keys of `object`.
29761 * @returns {Object} Returns `object`.
29764 var baseFor$1 = createBaseFor();
29765 var _baseFor = baseFor$1;
29767 var baseFor = _baseFor,
29770 * The base implementation of `_.forOwn` without support for iteratee shorthands.
29773 * @param {Object} object The object to iterate over.
29774 * @param {Function} iteratee The function invoked per iteration.
29775 * @returns {Object} Returns `object`.
29778 function baseForOwn$1(object, iteratee) {
29779 return object && baseFor(object, iteratee, keys);
29782 var _baseForOwn = baseForOwn$1;
29784 var isArrayLike = isArrayLike_1;
29786 * Creates a `baseEach` or `baseEachRight` function.
29789 * @param {Function} eachFunc The function to iterate over a collection.
29790 * @param {boolean} [fromRight] Specify iterating from right to left.
29791 * @returns {Function} Returns the new base function.
29794 function createBaseEach$1(eachFunc, fromRight) {
29795 return function (collection, iteratee) {
29796 if (collection == null) {
29800 if (!isArrayLike(collection)) {
29801 return eachFunc(collection, iteratee);
29804 var length = collection.length,
29805 index = fromRight ? length : -1,
29806 iterable = Object(collection);
29808 while (fromRight ? index-- : ++index < length) {
29809 if (iteratee(iterable[index], index, iterable) === false) {
29818 var _createBaseEach = createBaseEach$1;
29820 var baseForOwn = _baseForOwn,
29821 createBaseEach = _createBaseEach;
29823 * The base implementation of `_.forEach` without support for iteratee shorthands.
29826 * @param {Array|Object} collection The collection to iterate over.
29827 * @param {Function} iteratee The function invoked per iteration.
29828 * @returns {Array|Object} Returns `collection`.
29831 var baseEach$1 = createBaseEach(baseForOwn);
29832 var _baseEach = baseEach$1;
29834 var baseEach = _baseEach;
29836 * Aggregates elements of `collection` on `accumulator` with keys transformed
29837 * by `iteratee` and values set by `setter`.
29840 * @param {Array|Object} collection The collection to iterate over.
29841 * @param {Function} setter The function to set `accumulator` values.
29842 * @param {Function} iteratee The iteratee to transform keys.
29843 * @param {Object} accumulator The initial aggregated object.
29844 * @returns {Function} Returns `accumulator`.
29847 function baseAggregator$1(collection, setter, iteratee, accumulator) {
29848 baseEach(collection, function (value, key, collection) {
29849 setter(accumulator, value, iteratee(value), collection);
29851 return accumulator;
29854 var _baseAggregator = baseAggregator$1;
29856 var arrayAggregator = _arrayAggregator,
29857 baseAggregator = _baseAggregator,
29858 baseIteratee = _baseIteratee,
29859 isArray = isArray_1;
29861 * Creates a function like `_.groupBy`.
29864 * @param {Function} setter The function to set accumulator values.
29865 * @param {Function} [initializer] The accumulator object initializer.
29866 * @returns {Function} Returns the new aggregator function.
29869 function createAggregator$1(setter, initializer) {
29870 return function (collection, iteratee) {
29871 var func = isArray(collection) ? arrayAggregator : baseAggregator,
29872 accumulator = initializer ? initializer() : {};
29873 return func(collection, setter, baseIteratee(iteratee), accumulator);
29877 var _createAggregator = createAggregator$1;
29879 var createAggregator = _createAggregator;
29881 * Creates an array of elements split into two groups, the first of which
29882 * contains elements `predicate` returns truthy for, the second of which
29883 * contains elements `predicate` returns falsey for. The predicate is
29884 * invoked with one argument: (value).
29889 * @category Collection
29890 * @param {Array|Object} collection The collection to iterate over.
29891 * @param {Function} [predicate=_.identity] The function invoked per iteration.
29892 * @returns {Array} Returns the array of grouped elements.
29896 * { 'user': 'barney', 'age': 36, 'active': false },
29897 * { 'user': 'fred', 'age': 40, 'active': true },
29898 * { 'user': 'pebbles', 'age': 1, 'active': false }
29901 * _.partition(users, function(o) { return o.active; });
29902 * // => objects for [['fred'], ['barney', 'pebbles']]
29904 * // The `_.matches` iteratee shorthand.
29905 * _.partition(users, { 'age': 1, 'active': false });
29906 * // => objects for [['pebbles'], ['barney', 'fred']]
29908 * // The `_.matchesProperty` iteratee shorthand.
29909 * _.partition(users, ['active', false]);
29910 * // => objects for [['barney', 'pebbles'], ['fred']]
29912 * // The `_.property` iteratee shorthand.
29913 * _.partition(users, 'active');
29914 * // => objects for [['fred'], ['barney', 'pebbles']]
29917 var partition$1 = createAggregator(function (result, value, key) {
29918 result[key ? 0 : 1].push(value);
29922 var partition_1 = partition$1;
29924 var globby$2 = {exports: {}};
29926 var arrayUnion$1 = (...arguments_) => {
29927 return [...new Set([].concat(...arguments_))];
29932 * https://github.com/teambition/merge2
29934 * Copyright (c) 2014-2020 Teambition
29935 * Licensed under the MIT license.
29939 const Stream = require$$0__default$5["default"];
29940 const PassThrough = Stream.PassThrough;
29941 const slice = Array.prototype.slice;
29942 var merge2_1 = merge2$2;
29944 function merge2$2() {
29945 const streamsQueue = [];
29946 const args = slice.call(arguments);
29947 let merging = false;
29948 let options = args[args.length - 1];
29950 if (options && !Array.isArray(options) && options.pipe == null) {
29956 const doEnd = options.end !== false;
29957 const doPipeError = options.pipeError === true;
29959 if (options.objectMode == null) {
29960 options.objectMode = true;
29963 if (options.highWaterMark == null) {
29964 options.highWaterMark = 64 * 1024;
29967 const mergedStream = PassThrough(options);
29969 function addStream() {
29970 for (let i = 0, len = arguments.length; i < len; i++) {
29971 streamsQueue.push(pauseStreams(arguments[i], options));
29978 function mergeStream() {
29984 let streams = streamsQueue.shift();
29987 process.nextTick(endStream);
29991 if (!Array.isArray(streams)) {
29992 streams = [streams];
29995 let pipesCount = streams.length + 1;
29998 if (--pipesCount > 0) {
30006 function pipe(stream) {
30008 stream.removeListener('merge2UnpipeEnd', onend);
30009 stream.removeListener('end', onend);
30012 stream.removeListener('error', onerror);
30018 function onerror(err) {
30019 mergedStream.emit('error', err);
30020 } // skip ended stream
30023 if (stream._readableState.endEmitted) {
30027 stream.on('merge2UnpipeEnd', onend);
30028 stream.on('end', onend);
30031 stream.on('error', onerror);
30034 stream.pipe(mergedStream, {
30036 }); // compatible for old stream
30041 for (let i = 0; i < streams.length; i++) {
30048 function endStream() {
30049 merging = false; // emit 'queueDrain' when all streams merged.
30051 mergedStream.emit('queueDrain');
30054 mergedStream.end();
30058 mergedStream.setMaxListeners(0);
30059 mergedStream.add = addStream;
30060 mergedStream.on('unpipe', function (stream) {
30061 stream.emit('merge2UnpipeEnd');
30065 addStream.apply(null, args);
30068 return mergedStream;
30069 } // check and pause streams for pipe.
30072 function pauseStreams(streams, options) {
30073 if (!Array.isArray(streams)) {
30074 // Backwards-compat with old-style streams
30075 if (!streams._readableState && streams.pipe) {
30076 streams = streams.pipe(PassThrough(options));
30079 if (!streams._readableState || !streams.pause || !streams.pipe) {
30080 throw new Error('Only readable stream can be merged.');
30085 for (let i = 0, len = streams.length; i < len; i++) {
30086 streams[i] = pauseStreams(streams[i], options);
30099 Object.defineProperty(array$2, "__esModule", {
30102 array$2.splitWhen = array$2.flatten = void 0;
30104 function flatten(items) {
30105 return items.reduce((collection, item) => [].concat(collection, item), []);
30108 array$2.flatten = flatten;
30110 function splitWhen(items, predicate) {
30111 const result = [[]];
30112 let groupIndex = 0;
30114 for (const item of items) {
30115 if (predicate(item)) {
30117 result[groupIndex] = [];
30119 result[groupIndex].push(item);
30126 array$2.splitWhen = splitWhen;
30130 Object.defineProperty(errno$1, "__esModule", {
30133 errno$1.isEnoentCodeError = void 0;
30135 function isEnoentCodeError(error) {
30136 return error.code === 'ENOENT';
30139 errno$1.isEnoentCodeError = isEnoentCodeError;
30143 Object.defineProperty(fs$b, "__esModule", {
30146 fs$b.createDirentFromStats = void 0;
30148 class DirentFromStats$1 {
30149 constructor(name, stats) {
30151 this.isBlockDevice = stats.isBlockDevice.bind(stats);
30152 this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
30153 this.isDirectory = stats.isDirectory.bind(stats);
30154 this.isFIFO = stats.isFIFO.bind(stats);
30155 this.isFile = stats.isFile.bind(stats);
30156 this.isSocket = stats.isSocket.bind(stats);
30157 this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
30162 function createDirentFromStats$1(name, stats) {
30163 return new DirentFromStats$1(name, stats);
30166 fs$b.createDirentFromStats = createDirentFromStats$1;
30170 Object.defineProperty(path$c, "__esModule", {
30173 path$c.removeLeadingDotSegment = path$c.escape = path$c.makeAbsolute = path$c.unixify = void 0;
30174 const path$b = require$$0__default$2["default"];
30175 const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
30177 const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
30179 * Designed to work only with simple paths: `dir\\file`.
30182 function unixify(filepath) {
30183 return filepath.replace(/\\/g, '/');
30186 path$c.unixify = unixify;
30188 function makeAbsolute(cwd, filepath) {
30189 return path$b.resolve(cwd, filepath);
30192 path$c.makeAbsolute = makeAbsolute;
30194 function escape(pattern) {
30195 return pattern.replace(UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
30198 path$c.escape = escape;
30200 function removeLeadingDotSegment(entry) {
30201 // We do not use `startsWith` because this is 10x slower than current implementation for some cases.
30202 // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
30203 if (entry.charAt(0) === '.') {
30204 const secondCharactery = entry.charAt(1);
30206 if (secondCharactery === '/' || secondCharactery === '\\') {
30207 return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT);
30214 path$c.removeLeadingDotSegment = removeLeadingDotSegment;
30216 var pattern$1 = {};
30219 * is-extglob <https://github.com/jonschlinkert/is-extglob>
30221 * Copyright (c) 2014-2016, Jon Schlinkert.
30222 * Licensed under the MIT License.
30225 var isExtglob$1 = function isExtglob(str) {
30226 if (typeof str !== 'string' || str === '') {
30232 while (match = /(\\).|([@?!+*]\(.*\))/g.exec(str)) {
30233 if (match[2]) return true;
30234 str = str.slice(match.index + match[0].length);
30241 * is-glob <https://github.com/jonschlinkert/is-glob>
30243 * Copyright (c) 2014-2017, Jon Schlinkert.
30244 * Released under the MIT License.
30246 var isExtglob = isExtglob$1;
30253 var strictCheck = function (str) {
30254 if (str[0] === '!') {
30259 var pipeIndex = -2;
30260 var closeSquareIndex = -2;
30261 var closeCurlyIndex = -2;
30262 var closeParenIndex = -2;
30263 var backSlashIndex = -2;
30265 while (index < str.length) {
30266 if (str[index] === '*') {
30270 if (str[index + 1] === '?' && /[\].+)]/.test(str[index])) {
30274 if (closeSquareIndex !== -1 && str[index] === '[' && str[index + 1] !== ']') {
30275 if (closeSquareIndex < index) {
30276 closeSquareIndex = str.indexOf(']', index);
30279 if (closeSquareIndex > index) {
30280 if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) {
30284 backSlashIndex = str.indexOf('\\', index);
30286 if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) {
30292 if (closeCurlyIndex !== -1 && str[index] === '{' && str[index + 1] !== '}') {
30293 closeCurlyIndex = str.indexOf('}', index);
30295 if (closeCurlyIndex > index) {
30296 backSlashIndex = str.indexOf('\\', index);
30298 if (backSlashIndex === -1 || backSlashIndex > closeCurlyIndex) {
30304 if (closeParenIndex !== -1 && str[index] === '(' && str[index + 1] === '?' && /[:!=]/.test(str[index + 2]) && str[index + 3] !== ')') {
30305 closeParenIndex = str.indexOf(')', index);
30307 if (closeParenIndex > index) {
30308 backSlashIndex = str.indexOf('\\', index);
30310 if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) {
30316 if (pipeIndex !== -1 && str[index] === '(' && str[index + 1] !== '|') {
30317 if (pipeIndex < index) {
30318 pipeIndex = str.indexOf('|', index);
30321 if (pipeIndex !== -1 && str[pipeIndex + 1] !== ')') {
30322 closeParenIndex = str.indexOf(')', pipeIndex);
30324 if (closeParenIndex > pipeIndex) {
30325 backSlashIndex = str.indexOf('\\', pipeIndex);
30327 if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) {
30334 if (str[index] === '\\') {
30335 var open = str[index + 1];
30337 var close = chars$1[open];
30340 var n = str.indexOf(close, index);
30347 if (str[index] === '!') {
30358 var relaxedCheck = function (str) {
30359 if (str[0] === '!') {
30365 while (index < str.length) {
30366 if (/[*?{}()[\]]/.test(str[index])) {
30370 if (str[index] === '\\') {
30371 var open = str[index + 1];
30373 var close = chars$1[open];
30376 var n = str.indexOf(close, index);
30383 if (str[index] === '!') {
30394 var isGlob$1 = function isGlob(str, options) {
30395 if (typeof str !== 'string' || str === '') {
30399 if (isExtglob(str)) {
30403 var check = strictCheck; // optionally relax check
30405 if (options && options.strict === false) {
30406 check = relaxedCheck;
30412 var isGlob = isGlob$1;
30413 var pathPosixDirname = require$$0__default$2["default"].posix.dirname;
30414 var isWin32 = require$$0__default$1["default"].platform() === 'win32';
30416 var backslash = /\\/g;
30417 var enclosure = /[\{\[].*[\}\]]$/;
30418 var globby$1 = /(^|[^\\])([\{\[]|\([^\)]+$)/;
30419 var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g;
30421 * @param {string} str
30422 * @param {Object} opts
30423 * @param {boolean} [opts.flipBackslashes=true]
30424 * @returns {string}
30427 var globParent$1 = function globParent(str, opts) {
30428 var options = Object.assign({
30429 flipBackslashes: true
30430 }, opts); // flip windows path separators
30432 if (options.flipBackslashes && isWin32 && str.indexOf(slash$2) < 0) {
30433 str = str.replace(backslash, slash$2);
30434 } // special case for strings ending in enclosure containing path separator
30437 if (enclosure.test(str)) {
30439 } // preserves full path in case of trailing path separator
30442 str += 'a'; // remove path parts that are globby
30445 str = pathPosixDirname(str);
30446 } while (isGlob(str) || globby$1.test(str)); // remove escape chars and return result
30449 return str.replace(escaped, '$1');
30454 (function (exports) {
30456 exports.isInteger = num => {
30457 if (typeof num === 'number') {
30458 return Number.isInteger(num);
30461 if (typeof num === 'string' && num.trim() !== '') {
30462 return Number.isInteger(Number(num));
30468 * Find a node of the given type
30472 exports.find = (node, type) => node.nodes.find(node => node.type === type);
30474 * Find a node of the given type
30478 exports.exceedsLimit = (min, max, step = 1, limit) => {
30479 if (limit === false) return false;
30480 if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
30481 return (Number(max) - Number(min)) / Number(step) >= limit;
30484 * Escape the given node with '\\' before node.value
30488 exports.escapeNode = (block, n = 0, type) => {
30489 let node = block.nodes[n];
30492 if (type && node.type === type || node.type === 'open' || node.type === 'close') {
30493 if (node.escaped !== true) {
30494 node.value = '\\' + node.value;
30495 node.escaped = true;
30500 * Returns true if the given brace node should be enclosed in literal braces
30504 exports.encloseBrace = node => {
30505 if (node.type !== 'brace') return false;
30507 if (node.commas >> 0 + node.ranges >> 0 === 0) {
30508 node.invalid = true;
30515 * Returns true if a brace node is invalid.
30519 exports.isInvalidBrace = block => {
30520 if (block.type !== 'brace') return false;
30521 if (block.invalid === true || block.dollar) return true;
30523 if (block.commas >> 0 + block.ranges >> 0 === 0) {
30524 block.invalid = true;
30528 if (block.open !== true || block.close !== true) {
30529 block.invalid = true;
30536 * Returns true if a node is an open or close node
30540 exports.isOpenOrClose = node => {
30541 if (node.type === 'open' || node.type === 'close') {
30545 return node.open === true || node.close === true;
30548 * Reduce an array of text nodes.
30552 exports.reduce = nodes => nodes.reduce((acc, node) => {
30553 if (node.type === 'text') acc.push(node.value);
30554 if (node.type === 'range') node.type = 'text';
30562 exports.flatten = (...args) => {
30565 const flat = arr => {
30566 for (let i = 0; i < arr.length; i++) {
30568 Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele);
30579 const utils$p = utils$q;
30581 var stringify$5 = (ast, options = {}) => {
30582 let stringify = (node, parent = {}) => {
30583 let invalidBlock = options.escapeInvalid && utils$p.isInvalidBrace(parent);
30584 let invalidNode = node.invalid === true && options.escapeInvalid === true;
30588 if ((invalidBlock || invalidNode) && utils$p.isOpenOrClose(node)) {
30589 return '\\' + node.value;
30600 for (let child of node.nodes) {
30601 output += stringify(child);
30608 return stringify(ast);
30612 * is-number <https://github.com/jonschlinkert/is-number>
30614 * Copyright (c) 2014-present, Jon Schlinkert.
30615 * Released under the MIT License.
30618 var isNumber$2 = function (num) {
30619 if (typeof num === 'number') {
30620 return num - num === 0;
30623 if (typeof num === 'string' && num.trim() !== '') {
30624 return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
30630 const isNumber$1 = isNumber$2;
30632 const toRegexRange$1 = (min, max, options) => {
30633 if (isNumber$1(min) === false) {
30634 throw new TypeError('toRegexRange: expected the first argument to be a number');
30637 if (max === void 0 || min === max) {
30638 return String(min);
30641 if (isNumber$1(max) === false) {
30642 throw new TypeError('toRegexRange: expected the second argument to be a number.');
30645 let opts = Object.assign({
30649 if (typeof opts.strictZeros === 'boolean') {
30650 opts.relaxZeros = opts.strictZeros === false;
30653 let relax = String(opts.relaxZeros);
30654 let shorthand = String(opts.shorthand);
30655 let capture = String(opts.capture);
30656 let wrap = String(opts.wrap);
30657 let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap;
30659 if (toRegexRange$1.cache.hasOwnProperty(cacheKey)) {
30660 return toRegexRange$1.cache[cacheKey].result;
30663 let a = Math.min(min, max);
30664 let b = Math.max(min, max);
30666 if (Math.abs(a - b) === 1) {
30667 let result = min + '|' + max;
30669 if (opts.capture) {
30670 return `(${result})`;
30673 if (opts.wrap === false) {
30677 return `(?:${result})`;
30680 let isPadded = hasPadding(min) || hasPadding(max);
30687 let positives = [];
30688 let negatives = [];
30691 state.isPadded = isPadded;
30692 state.maxLen = String(state.max).length;
30696 let newMin = b < 0 ? Math.abs(b) : 1;
30697 negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
30702 positives = splitToPatterns(a, b, state, opts);
30705 state.negatives = negatives;
30706 state.positives = positives;
30707 state.result = collatePatterns(negatives, positives);
30709 if (opts.capture === true) {
30710 state.result = `(${state.result})`;
30711 } else if (opts.wrap !== false && positives.length + negatives.length > 1) {
30712 state.result = `(?:${state.result})`;
30715 toRegexRange$1.cache[cacheKey] = state;
30716 return state.result;
30719 function collatePatterns(neg, pos, options) {
30720 let onlyNegative = filterPatterns(neg, pos, '-', false) || [];
30721 let onlyPositive = filterPatterns(pos, neg, '', false) || [];
30722 let intersected = filterPatterns(neg, pos, '-?', true) || [];
30723 let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
30724 return subpatterns.join('|');
30727 function splitToRanges(min, max) {
30730 let stop = countNines(min, nines);
30731 let stops = new Set([max]);
30733 while (min <= stop && stop <= max) {
30736 stop = countNines(min, nines);
30739 stop = countZeros(max + 1, zeros) - 1;
30741 while (min < stop && stop <= max) {
30744 stop = countZeros(max + 1, zeros) - 1;
30747 stops = [...stops];
30748 stops.sort(compare);
30752 * Convert a range to a regex pattern
30753 * @param {Number} `start`
30754 * @param {Number} `stop`
30759 function rangeToPattern(start, stop, options) {
30760 if (start === stop) {
30768 let zipped = zip(start, stop);
30769 let digits = zipped.length;
30773 for (let i = 0; i < digits; i++) {
30774 let [startDigit, stopDigit] = zipped[i];
30776 if (startDigit === stopDigit) {
30777 pattern += startDigit;
30778 } else if (startDigit !== '0' || stopDigit !== '9') {
30779 pattern += toCharacterClass(startDigit, stopDigit);
30786 pattern += options.shorthand === true ? '\\d' : '[0-9]';
30796 function splitToPatterns(min, max, tok, options) {
30797 let ranges = splitToRanges(min, max);
30802 for (let i = 0; i < ranges.length; i++) {
30803 let max = ranges[i];
30804 let obj = rangeToPattern(String(start), String(max), options);
30807 if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
30808 if (prev.count.length > 1) {
30812 prev.count.push(obj.count[0]);
30813 prev.string = prev.pattern + toQuantifier(prev.count);
30818 if (tok.isPadded) {
30819 zeros = padZeros(max, tok, options);
30822 obj.string = zeros + obj.pattern + toQuantifier(obj.count);
30831 function filterPatterns(arr, comparison, prefix, intersection, options) {
30834 for (let ele of arr) {
30837 } = ele; // only push if _both_ are negative...
30839 if (!intersection && !contains(comparison, 'string', string)) {
30840 result.push(prefix + string);
30841 } // or _both_ are positive
30844 if (intersection && contains(comparison, 'string', string)) {
30845 result.push(prefix + string);
30856 function zip(a, b) {
30859 for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]);
30864 function compare(a, b) {
30865 return a > b ? 1 : b > a ? -1 : 0;
30868 function contains(arr, key, val) {
30869 return arr.some(ele => ele[key] === val);
30872 function countNines(min, len) {
30873 return Number(String(min).slice(0, -len) + '9'.repeat(len));
30876 function countZeros(integer, zeros) {
30877 return integer - integer % Math.pow(10, zeros);
30880 function toQuantifier(digits) {
30881 let [start = 0, stop = ''] = digits;
30883 if (stop || start > 1) {
30884 return `{${start + (stop ? ',' + stop : '')}}`;
30890 function toCharacterClass(a, b, options) {
30891 return `[${a}${b - a === 1 ? '' : '-'}${b}]`;
30894 function hasPadding(str) {
30895 return /^-?(0+)\d/.test(str);
30898 function padZeros(value, tok, options) {
30899 if (!tok.isPadded) {
30903 let diff = Math.abs(tok.maxLen - String(value).length);
30904 let relax = options.relaxZeros !== false;
30911 return relax ? '0?' : '0';
30914 return relax ? '0{0,2}' : '00';
30918 return relax ? `0{0,${diff}}` : `0{${diff}}`;
30927 toRegexRange$1.cache = {};
30929 toRegexRange$1.clearCache = () => toRegexRange$1.cache = {};
30931 * Expose `toRegexRange`
30935 var toRegexRange_1 = toRegexRange$1;
30937 const util$2 = require$$0__default$4["default"];
30938 const toRegexRange = toRegexRange_1;
30940 const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
30942 const transform = toNumber => {
30943 return value => toNumber === true ? Number(value) : String(value);
30946 const isValidValue = value => {
30947 return typeof value === 'number' || typeof value === 'string' && value !== '';
30950 const isNumber = num => Number.isInteger(+num);
30952 const zeros = input => {
30953 let value = `${input}`;
30955 if (value[0] === '-') value = value.slice(1);
30956 if (value === '0') return false;
30958 while (value[++index] === '0');
30963 const stringify$4 = (start, end, options) => {
30964 if (typeof start === 'string' || typeof end === 'string') {
30968 return options.stringify === true;
30971 const pad = (input, maxLength, toNumber) => {
30972 if (maxLength > 0) {
30973 let dash = input[0] === '-' ? '-' : '';
30974 if (dash) input = input.slice(1);
30975 input = dash + input.padStart(dash ? maxLength - 1 : maxLength, '0');
30978 if (toNumber === false) {
30979 return String(input);
30985 const toMaxLen = (input, maxLength) => {
30986 let negative = input[0] === '-' ? '-' : '';
30989 input = input.slice(1);
30993 while (input.length < maxLength) input = '0' + input;
30995 return negative ? '-' + input : input;
30998 const toSequence = (parts, options) => {
30999 parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
31000 parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
31001 let prefix = options.capture ? '' : '?:';
31002 let positives = '';
31003 let negatives = '';
31006 if (parts.positives.length) {
31007 positives = parts.positives.join('|');
31010 if (parts.negatives.length) {
31011 negatives = `-(${prefix}${parts.negatives.join('|')})`;
31014 if (positives && negatives) {
31015 result = `${positives}|${negatives}`;
31017 result = positives || negatives;
31020 if (options.wrap) {
31021 return `(${prefix}${result})`;
31027 const toRange = (a, b, isNumbers, options) => {
31029 return toRegexRange(a, b, Object.assign({
31034 let start = String.fromCharCode(a);
31035 if (a === b) return start;
31036 let stop = String.fromCharCode(b);
31037 return `[${start}-${stop}]`;
31040 const toRegex = (start, end, options) => {
31041 if (Array.isArray(start)) {
31042 let wrap = options.wrap === true;
31043 let prefix = options.capture ? '' : '?:';
31044 return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
31047 return toRegexRange(start, end, options);
31050 const rangeError = (...args) => {
31051 return new RangeError('Invalid range arguments: ' + util$2.inspect(...args));
31054 const invalidRange = (start, end, options) => {
31055 if (options.strictRanges === true) throw rangeError([start, end]);
31059 const invalidStep = (step, options) => {
31060 if (options.strictRanges === true) {
31061 throw new TypeError(`Expected step "${step}" to be a number`);
31067 const fillNumbers = (start, end, step = 1, options = {}) => {
31068 let a = Number(start);
31069 let b = Number(end);
31071 if (!Number.isInteger(a) || !Number.isInteger(b)) {
31072 if (options.strictRanges === true) throw rangeError([start, end]);
31074 } // fix negative zero
31077 if (a === 0) a = 0;
31078 if (b === 0) b = 0;
31079 let descending = a > b;
31080 let startString = String(start);
31081 let endString = String(end);
31082 let stepString = String(step);
31083 step = Math.max(Math.abs(step), 1);
31084 let padded = zeros(startString) || zeros(endString) || zeros(stepString);
31085 let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
31086 let toNumber = padded === false && stringify$4(start, end, options) === false;
31087 let format = options.transform || transform(toNumber);
31089 if (options.toRegex && step === 1) {
31090 return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
31098 let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
31103 while (descending ? a >= b : a <= b) {
31104 if (options.toRegex === true && step > 1) {
31107 range.push(pad(format(a, index), maxLen, toNumber));
31110 a = descending ? a - step : a + step;
31114 if (options.toRegex === true) {
31115 return step > 1 ? toSequence(parts, options) : toRegex(range, null, Object.assign({
31123 const fillLetters = (start, end, step = 1, options = {}) => {
31124 if (!isNumber(start) && start.length > 1 || !isNumber(end) && end.length > 1) {
31125 return invalidRange(start, end, options);
31128 let format = options.transform || (val => String.fromCharCode(val));
31130 let a = `${start}`.charCodeAt(0);
31131 let b = `${end}`.charCodeAt(0);
31132 let descending = a > b;
31133 let min = Math.min(a, b);
31134 let max = Math.max(a, b);
31136 if (options.toRegex && step === 1) {
31137 return toRange(min, max, false, options);
31143 while (descending ? a >= b : a <= b) {
31144 range.push(format(a, index));
31145 a = descending ? a - step : a + step;
31149 if (options.toRegex === true) {
31150 return toRegex(range, null, {
31159 const fill$b = (start, end, step, options = {}) => {
31160 if (end == null && isValidValue(start)) {
31164 if (!isValidValue(start) || !isValidValue(end)) {
31165 return invalidRange(start, end, options);
31168 if (typeof step === 'function') {
31169 return fill$b(start, end, 1, {
31174 if (isObject$1(step)) {
31175 return fill$b(start, end, 0, step);
31178 let opts = Object.assign({}, options);
31179 if (opts.capture === true) opts.wrap = true;
31180 step = step || opts.step || 1;
31182 if (!isNumber(step)) {
31183 if (step != null && !isObject$1(step)) return invalidStep(step, opts);
31184 return fill$b(start, end, 1, step);
31187 if (isNumber(start) && isNumber(end)) {
31188 return fillNumbers(start, end, step, opts);
31191 return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
31194 var fillRange = fill$b;
31196 const fill$a = fillRange;
31197 const utils$o = utils$q;
31199 const compile$1 = (ast, options = {}) => {
31200 let walk = (node, parent = {}) => {
31201 let invalidBlock = utils$o.isInvalidBrace(parent);
31202 let invalidNode = node.invalid === true && options.escapeInvalid === true;
31203 let invalid = invalidBlock === true || invalidNode === true;
31204 let prefix = options.escapeInvalid === true ? '\\' : '';
31207 if (node.isOpen === true) {
31208 return prefix + node.value;
31211 if (node.isClose === true) {
31212 return prefix + node.value;
31215 if (node.type === 'open') {
31216 return invalid ? prefix + node.value : '(';
31219 if (node.type === 'close') {
31220 return invalid ? prefix + node.value : ')';
31223 if (node.type === 'comma') {
31224 return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
31231 if (node.nodes && node.ranges > 0) {
31232 let args = utils$o.reduce(node.nodes);
31233 let range = fill$a(...args, Object.assign(Object.assign({}, options), {}, {
31238 if (range.length !== 0) {
31239 return args.length > 1 && range.length > 1 ? `(${range})` : range;
31244 for (let child of node.nodes) {
31245 output += walk(child, node);
31255 var compile_1 = compile$1;
31257 const fill$9 = fillRange;
31258 const stringify$3 = stringify$5;
31259 const utils$n = utils$q;
31261 const append = (queue = '', stash = '', enclose = false) => {
31263 queue = [].concat(queue);
31264 stash = [].concat(stash);
31265 if (!stash.length) return queue;
31267 if (!queue.length) {
31268 return enclose ? utils$n.flatten(stash).map(ele => `{${ele}}`) : stash;
31271 for (let item of queue) {
31272 if (Array.isArray(item)) {
31273 for (let value of item) {
31274 result.push(append(value, stash, enclose));
31277 for (let ele of stash) {
31278 if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
31279 result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
31284 return utils$n.flatten(result);
31287 const expand$1 = (ast, options = {}) => {
31288 let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
31290 let walk = (node, parent = {}) => {
31293 let q = parent.queue;
31295 while (p.type !== 'brace' && p.type !== 'root' && p.parent) {
31300 if (node.invalid || node.dollar) {
31301 q.push(append(q.pop(), stringify$3(node, options)));
31305 if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) {
31306 q.push(append(q.pop(), ['{}']));
31310 if (node.nodes && node.ranges > 0) {
31311 let args = utils$n.reduce(node.nodes);
31313 if (utils$n.exceedsLimit(...args, options.step, rangeLimit)) {
31314 throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
31317 let range = fill$9(...args, options);
31319 if (range.length === 0) {
31320 range = stringify$3(node, options);
31323 q.push(append(q.pop(), range));
31328 let enclose = utils$n.encloseBrace(node);
31329 let queue = node.queue;
31332 while (block.type !== 'brace' && block.type !== 'root' && block.parent) {
31333 block = block.parent;
31334 queue = block.queue;
31337 for (let i = 0; i < node.nodes.length; i++) {
31338 let child = node.nodes[i];
31340 if (child.type === 'comma' && node.type === 'brace') {
31341 if (i === 1) queue.push('');
31346 if (child.type === 'close') {
31347 q.push(append(q.pop(), queue, enclose));
31351 if (child.value && child.type !== 'open') {
31352 queue.push(append(queue.pop(), child.value));
31364 return utils$n.flatten(walk(ast));
31367 var expand_1 = expand$1;
31369 var constants$4 = {
31370 MAX_LENGTH: 1024 * 64,
31379 CHAR_UPPERCASE_A: 'A',
31382 CHAR_LOWERCASE_A: 'a',
31385 CHAR_UPPERCASE_Z: 'Z',
31388 CHAR_LOWERCASE_Z: 'z',
31391 CHAR_LEFT_PARENTHESES: '(',
31394 CHAR_RIGHT_PARENTHESES: ')',
31397 CHAR_ASTERISK: '*',
31400 // Non-alphabetic chars.
31401 CHAR_AMPERSAND: '&',
31407 CHAR_BACKSLASH: '\\',
31410 CHAR_BACKTICK: '`',
31413 CHAR_CARRIAGE_RETURN: '\r',
31416 CHAR_CIRCUMFLEX_ACCENT: '^',
31431 CHAR_DOUBLE_QUOTE: '"',
31437 CHAR_EXCLAMATION_MARK: '!',
31440 CHAR_FORM_FEED: '\f',
31443 CHAR_FORWARD_SLASH: '/',
31449 CHAR_HYPHEN_MINUS: '-',
31452 CHAR_LEFT_ANGLE_BRACKET: '<',
31455 CHAR_LEFT_CURLY_BRACE: '{',
31458 CHAR_LEFT_SQUARE_BRACKET: '[',
31461 CHAR_LINE_FEED: '\n',
31464 CHAR_NO_BREAK_SPACE: '\u00A0',
31473 CHAR_QUESTION_MARK: '?',
31476 CHAR_RIGHT_ANGLE_BRACKET: '>',
31479 CHAR_RIGHT_CURLY_BRACE: '}',
31482 CHAR_RIGHT_SQUARE_BRACKET: ']',
31485 CHAR_SEMICOLON: ';',
31488 CHAR_SINGLE_QUOTE: '\'',
31497 CHAR_UNDERSCORE: '_',
31500 CHAR_VERTICAL_LINE: '|',
31503 CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF'
31508 const stringify$2 = stringify$5;
31514 MAX_LENGTH: MAX_LENGTH$1,
31521 CHAR_COMMA: CHAR_COMMA$1,
31524 CHAR_DOT: CHAR_DOT$1,
31527 CHAR_LEFT_PARENTHESES: CHAR_LEFT_PARENTHESES$1,
31530 CHAR_RIGHT_PARENTHESES: CHAR_RIGHT_PARENTHESES$1,
31533 CHAR_LEFT_CURLY_BRACE: CHAR_LEFT_CURLY_BRACE$1,
31536 CHAR_RIGHT_CURLY_BRACE: CHAR_RIGHT_CURLY_BRACE$1,
31539 CHAR_LEFT_SQUARE_BRACKET: CHAR_LEFT_SQUARE_BRACKET$1,
31542 CHAR_RIGHT_SQUARE_BRACKET: CHAR_RIGHT_SQUARE_BRACKET$1,
31551 CHAR_NO_BREAK_SPACE,
31552 CHAR_ZERO_WIDTH_NOBREAK_SPACE
31558 const parse$5 = (input, options = {}) => {
31559 if (typeof input !== 'string') {
31560 throw new TypeError('Expected a string');
31563 let opts = options || {};
31564 let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$1, opts.maxLength) : MAX_LENGTH$1;
31566 if (input.length > max) {
31567 throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
31579 let length = input.length;
31587 const advance = () => input[index++];
31589 const push = node => {
31590 if (node.type === 'text' && prev.type === 'dot') {
31591 prev.type = 'text';
31594 if (prev && prev.type === 'text' && node.type === 'text') {
31595 prev.value += node.value;
31599 block.nodes.push(node);
31600 node.parent = block;
31610 while (index < length) {
31611 block = stack[stack.length - 1];
31617 if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
31625 if (value === CHAR_BACKSLASH) {
31628 value: (options.keepEscaping ? value : '') + advance()
31633 * Right square bracket (literal): ']'
31637 if (value === CHAR_RIGHT_SQUARE_BRACKET$1) {
31640 value: '\\' + value
31645 * Left square bracket: '['
31649 if (value === CHAR_LEFT_SQUARE_BRACKET$1) {
31653 while (index < length && (next = advance())) {
31656 if (next === CHAR_LEFT_SQUARE_BRACKET$1) {
31661 if (next === CHAR_BACKSLASH) {
31662 value += advance();
31666 if (next === CHAR_RIGHT_SQUARE_BRACKET$1) {
31669 if (brackets === 0) {
31686 if (value === CHAR_LEFT_PARENTHESES$1) {
31699 if (value === CHAR_RIGHT_PARENTHESES$1) {
31700 if (block.type !== 'paren') {
31708 block = stack.pop();
31713 block = stack[stack.length - 1];
31721 if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
31725 if (options.keepQuotes !== true) {
31729 while (index < length && (next = advance())) {
31730 if (next === CHAR_BACKSLASH) {
31731 value += next + advance();
31735 if (next === open) {
31736 if (options.keepQuotes === true) value += next;
31750 * Left curly brace: '{'
31754 if (value === CHAR_LEFT_CURLY_BRACE$1) {
31756 let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
31767 block = push(brace);
31776 * Right curly brace: '}'
31780 if (value === CHAR_RIGHT_CURLY_BRACE$1) {
31781 if (block.type !== 'brace') {
31789 let type = 'close';
31790 block = stack.pop();
31791 block.close = true;
31797 block = stack[stack.length - 1];
31805 if (value === CHAR_COMMA$1 && depth > 0) {
31806 if (block.ranges > 0) {
31808 let open = block.nodes.shift();
31809 block.nodes = [open, {
31811 value: stringify$2(block)
31827 if (value === CHAR_DOT$1 && depth > 0 && block.commas === 0) {
31828 let siblings = block.nodes;
31830 if (depth === 0 || siblings.length === 0) {
31838 if (prev.type === 'dot') {
31840 prev.value += value;
31841 prev.type = 'range';
31843 if (block.nodes.length !== 3 && block.nodes.length !== 5) {
31844 block.invalid = true;
31846 prev.type = 'text';
31855 if (prev.type === 'range') {
31857 let before = siblings[siblings.length - 1];
31858 before.value += prev.value + value;
31879 } // Mark imbalanced braces and brackets as invalid
31883 block = stack.pop();
31885 if (block.type !== 'root') {
31886 block.nodes.forEach(node => {
31888 if (node.type === 'open') node.isOpen = true;
31889 if (node.type === 'close') node.isClose = true;
31890 if (!node.nodes) node.type = 'text';
31891 node.invalid = true;
31893 }); // get the location of the block on parent.nodes (block's siblings)
31895 let parent = stack[stack.length - 1];
31896 let index = parent.nodes.indexOf(block); // replace the (invalid) block with it's nodes
31898 parent.nodes.splice(index, 1, ...block.nodes);
31900 } while (stack.length > 0);
31908 var parse_1$2 = parse$5;
31910 const stringify$1 = stringify$5;
31911 const compile = compile_1;
31912 const expand = expand_1;
31913 const parse$4 = parse_1$2;
31915 * Expand the given pattern or create a regex-compatible string.
31918 * const braces = require('braces');
31919 * console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)']
31920 * console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c']
31922 * @param {String} `str`
31923 * @param {Object} `options`
31928 const braces$1 = (input, options = {}) => {
31931 if (Array.isArray(input)) {
31932 for (let pattern of input) {
31933 let result = braces$1.create(pattern, options);
31935 if (Array.isArray(result)) {
31936 output.push(...result);
31938 output.push(result);
31942 output = [].concat(braces$1.create(input, options));
31945 if (options && options.expand === true && options.nodupes === true) {
31946 output = [...new Set(output)];
31952 * Parse the given `str` with the given `options`.
31955 * // braces.parse(pattern, [, options]);
31956 * const ast = braces.parse('a/{b,c}/d');
31957 * console.log(ast);
31959 * @param {String} pattern Brace pattern to parse
31960 * @param {Object} options
31961 * @return {Object} Returns an AST
31966 braces$1.parse = (input, options = {}) => parse$4(input, options);
31968 * Creates a braces string from an AST, or an AST node.
31971 * const braces = require('braces');
31972 * let ast = braces.parse('foo/{a,b}/bar');
31973 * console.log(stringify(ast.nodes[2])); //=> '{a,b}'
31975 * @param {String} `input` Brace pattern or AST.
31976 * @param {Object} `options`
31977 * @return {Array} Returns an array of expanded values.
31982 braces$1.stringify = (input, options = {}) => {
31983 if (typeof input === 'string') {
31984 return stringify$1(braces$1.parse(input, options), options);
31987 return stringify$1(input, options);
31990 * Compiles a brace pattern into a regex-compatible, optimized string.
31991 * This method is called by the main [braces](#braces) function by default.
31994 * const braces = require('braces');
31995 * console.log(braces.compile('a/{b,c}/d'));
31996 * //=> ['a/(b|c)/d']
31998 * @param {String} `input` Brace pattern or AST.
31999 * @param {Object} `options`
32000 * @return {Array} Returns an array of expanded values.
32005 braces$1.compile = (input, options = {}) => {
32006 if (typeof input === 'string') {
32007 input = braces$1.parse(input, options);
32010 return compile(input, options);
32013 * Expands a brace pattern into an array. This method is called by the
32014 * main [braces](#braces) function when `options.expand` is true. Before
32015 * using this method it's recommended that you read the [performance notes](#performance))
32016 * and advantages of using [.compile](#compile) instead.
32019 * const braces = require('braces');
32020 * console.log(braces.expand('a/{b,c}/d'));
32021 * //=> ['a/b/d', 'a/c/d'];
32023 * @param {String} `pattern` Brace pattern
32024 * @param {Object} `options`
32025 * @return {Array} Returns an array of expanded values.
32030 braces$1.expand = (input, options = {}) => {
32031 if (typeof input === 'string') {
32032 input = braces$1.parse(input, options);
32035 let result = expand(input, options); // filter out empty strings if specified
32037 if (options.noempty === true) {
32038 result = result.filter(Boolean);
32039 } // filter out duplicates if specified
32042 if (options.nodupes === true) {
32043 result = [...new Set(result)];
32049 * Processes a brace pattern and returns either an expanded array
32050 * (if `options.expand` is true), a highly optimized regex-compatible string.
32051 * This method is called by the main [braces](#braces) function.
32054 * const braces = require('braces');
32055 * console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}'))
32056 * //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)'
32058 * @param {String} `pattern` Brace pattern
32059 * @param {Object} `options`
32060 * @return {Array} Returns an array of expanded values.
32065 braces$1.create = (input, options = {}) => {
32066 if (input === '' || input.length < 3) {
32070 return options.expand !== true ? braces$1.compile(input, options) : braces$1.expand(input, options);
32077 var braces_1 = braces$1;
32081 const path$a = require$$0__default$2["default"];
32082 const WIN_SLASH = '\\\\/';
32083 const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
32088 const DOT_LITERAL = '\\.';
32089 const PLUS_LITERAL = '\\+';
32090 const QMARK_LITERAL = '\\?';
32091 const SLASH_LITERAL = '\\/';
32092 const ONE_CHAR = '(?=.)';
32093 const QMARK = '[^/]';
32094 const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
32095 const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
32096 const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
32097 const NO_DOT = `(?!${DOT_LITERAL})`;
32098 const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
32099 const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
32100 const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
32101 const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
32102 const STAR = `${QMARK}*?`;
32103 const POSIX_CHARS = {
32121 * Windows glob regex
32124 const WINDOWS_CHARS = Object.assign(Object.assign({}, POSIX_CHARS), {}, {
32125 SLASH_LITERAL: `[${WIN_SLASH}]`,
32126 QMARK: WIN_NO_SLASH,
32127 STAR: `${WIN_NO_SLASH}*?`,
32128 DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
32129 NO_DOT: `(?!${DOT_LITERAL})`,
32130 NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
32131 NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
32132 NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
32133 QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
32134 START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
32135 END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
32138 * POSIX Bracket Regex
32141 const POSIX_REGEX_SOURCE$1 = {
32142 alnum: 'a-zA-Z0-9',
32144 ascii: '\\x00-\\x7F',
32146 cntrl: '\\x00-\\x1F\\x7F',
32148 graph: '\\x21-\\x7E',
32150 print: '\\x20-\\x7E ',
32151 punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
32152 space: ' \\t\\r\\n\\v\\f',
32154 word: 'A-Za-z0-9_',
32155 xdigit: 'A-Fa-f0-9'
32157 var constants$3 = {
32158 MAX_LENGTH: 1024 * 64,
32159 POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
32160 // regular expressions
32161 REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
32162 REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
32163 REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
32164 REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
32165 REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
32166 REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
32167 // Replace globs with equivalent patterns to reduce parsing time.
32181 CHAR_UPPERCASE_A: 65,
32184 CHAR_LOWERCASE_A: 97,
32187 CHAR_UPPERCASE_Z: 90,
32190 CHAR_LOWERCASE_Z: 122,
32193 CHAR_LEFT_PARENTHESES: 40,
32196 CHAR_RIGHT_PARENTHESES: 41,
32202 // Non-alphabetic chars.
32203 CHAR_AMPERSAND: 38,
32209 CHAR_BACKWARD_SLASH: 92,
32212 CHAR_CARRIAGE_RETURN: 13,
32215 CHAR_CIRCUMFLEX_ACCENT: 94,
32227 CHAR_DOUBLE_QUOTE: 34,
32233 CHAR_EXCLAMATION_MARK: 33,
32236 CHAR_FORM_FEED: 12,
32239 CHAR_FORWARD_SLASH: 47,
32242 CHAR_GRAVE_ACCENT: 96,
32248 CHAR_HYPHEN_MINUS: 45,
32251 CHAR_LEFT_ANGLE_BRACKET: 60,
32254 CHAR_LEFT_CURLY_BRACE: 123,
32257 CHAR_LEFT_SQUARE_BRACKET: 91,
32260 CHAR_LINE_FEED: 10,
32263 CHAR_NO_BREAK_SPACE: 160,
32272 CHAR_QUESTION_MARK: 63,
32275 CHAR_RIGHT_ANGLE_BRACKET: 62,
32278 CHAR_RIGHT_CURLY_BRACE: 125,
32281 CHAR_RIGHT_SQUARE_BRACKET: 93,
32284 CHAR_SEMICOLON: 59,
32287 CHAR_SINGLE_QUOTE: 39,
32296 CHAR_UNDERSCORE: 95,
32299 CHAR_VERTICAL_LINE: 124,
32302 CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
32308 * Create EXTGLOB_CHARS
32310 extglobChars(chars) {
32315 close: `))${chars.STAR})`
32341 * Create GLOB_CHARS
32344 return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
32349 (function (exports) {
32351 const path = require$$0__default$2["default"];
32352 const win32 = process.platform === 'win32';
32355 REGEX_REMOVE_BACKSLASH,
32356 REGEX_SPECIAL_CHARS,
32357 REGEX_SPECIAL_CHARS_GLOBAL
32360 exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
32362 exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
32364 exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
32366 exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
32368 exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
32370 exports.removeBackslashes = str => {
32371 return str.replace(REGEX_REMOVE_BACKSLASH, match => {
32372 return match === '\\' ? '' : match;
32376 exports.supportsLookbehinds = () => {
32377 const segs = process.version.slice(1).split('.').map(Number);
32379 if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) {
32386 exports.isWindows = options => {
32387 if (options && typeof options.windows === 'boolean') {
32388 return options.windows;
32391 return win32 === true || path.sep === '\\';
32394 exports.escapeLast = (input, char, lastIdx) => {
32395 const idx = input.lastIndexOf(char, lastIdx);
32396 if (idx === -1) return input;
32397 if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
32398 return `${input.slice(0, idx)}\\${input.slice(idx)}`;
32401 exports.removePrefix = (input, state = {}) => {
32402 let output = input;
32404 if (output.startsWith('./')) {
32405 output = output.slice(2);
32406 state.prefix = './';
32412 exports.wrapOutput = (input, state = {}, options = {}) => {
32413 const prepend = options.contains ? '' : '^';
32414 const append = options.contains ? '' : '$';
32415 let output = `${prepend}(?:${input})${append}`;
32417 if (state.negated === true) {
32418 output = `(?:^(?!${output}).*$)`;
32425 const utils$l = utils$m;
32433 CHAR_BACKWARD_SLASH,
32442 CHAR_EXCLAMATION_MARK,
32445 CHAR_FORWARD_SLASH,
32448 CHAR_LEFT_CURLY_BRACE,
32451 CHAR_LEFT_PARENTHESES,
32454 CHAR_LEFT_SQUARE_BRACKET,
32460 CHAR_QUESTION_MARK,
32463 CHAR_RIGHT_CURLY_BRACE,
32466 CHAR_RIGHT_PARENTHESES,
32469 CHAR_RIGHT_SQUARE_BRACKET
32474 const isPathSeparator = code => {
32475 return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
32478 const depth = token => {
32479 if (token.isPrefix !== true) {
32480 token.depth = token.isGlobstar ? Infinity : 1;
32484 * Quickly scans a glob pattern and returns an object with a handful of
32485 * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
32486 * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
32487 * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
32490 * const pm = require('picomatch');
32491 * console.log(pm.scan('foo/bar/*.js'));
32492 * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
32494 * @param {String} `str`
32495 * @param {Object} `options`
32496 * @return {Object} Returns an object with tokens and regex source string.
32501 const scan$1 = (input, options) => {
32502 const opts = options || {};
32503 const length = input.length - 1;
32504 const scanToEnd = opts.parts === true || opts.scanToEnd === true;
32505 const slashes = [];
32512 let isBrace = false;
32513 let isBracket = false;
32514 let isGlob = false;
32515 let isExtglob = false;
32516 let isGlobstar = false;
32517 let braceEscaped = false;
32518 let backslashes = false;
32519 let negated = false;
32520 let negatedExtglob = false;
32521 let finished = false;
32531 const eos = () => index >= length;
32533 const peek = () => str.charCodeAt(index + 1);
32535 const advance = () => {
32537 return str.charCodeAt(++index);
32540 while (index < length) {
32544 if (code === CHAR_BACKWARD_SLASH) {
32545 backslashes = token.backslashes = true;
32548 if (code === CHAR_LEFT_CURLY_BRACE) {
32549 braceEscaped = true;
32555 if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
32558 while (eos() !== true && (code = advance())) {
32559 if (code === CHAR_BACKWARD_SLASH) {
32560 backslashes = token.backslashes = true;
32565 if (code === CHAR_LEFT_CURLY_BRACE) {
32570 if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
32571 isBrace = token.isBrace = true;
32572 isGlob = token.isGlob = true;
32575 if (scanToEnd === true) {
32582 if (braceEscaped !== true && code === CHAR_COMMA) {
32583 isBrace = token.isBrace = true;
32584 isGlob = token.isGlob = true;
32587 if (scanToEnd === true) {
32594 if (code === CHAR_RIGHT_CURLY_BRACE) {
32597 if (braces === 0) {
32598 braceEscaped = false;
32599 isBrace = token.isBrace = true;
32606 if (scanToEnd === true) {
32613 if (code === CHAR_FORWARD_SLASH) {
32614 slashes.push(index);
32615 tokens.push(token);
32621 if (finished === true) continue;
32623 if (prev === CHAR_DOT && index === start + 1) {
32628 lastIndex = index + 1;
32632 if (opts.noext !== true) {
32633 const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
32635 if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
32636 isGlob = token.isGlob = true;
32637 isExtglob = token.isExtglob = true;
32640 if (code === CHAR_EXCLAMATION_MARK && index === start) {
32641 negatedExtglob = true;
32644 if (scanToEnd === true) {
32645 while (eos() !== true && (code = advance())) {
32646 if (code === CHAR_BACKWARD_SLASH) {
32647 backslashes = token.backslashes = true;
32652 if (code === CHAR_RIGHT_PARENTHESES) {
32653 isGlob = token.isGlob = true;
32666 if (code === CHAR_ASTERISK) {
32667 if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
32668 isGlob = token.isGlob = true;
32671 if (scanToEnd === true) {
32678 if (code === CHAR_QUESTION_MARK) {
32679 isGlob = token.isGlob = true;
32682 if (scanToEnd === true) {
32689 if (code === CHAR_LEFT_SQUARE_BRACKET) {
32690 while (eos() !== true && (next = advance())) {
32691 if (next === CHAR_BACKWARD_SLASH) {
32692 backslashes = token.backslashes = true;
32697 if (next === CHAR_RIGHT_SQUARE_BRACKET) {
32698 isBracket = token.isBracket = true;
32699 isGlob = token.isGlob = true;
32705 if (scanToEnd === true) {
32712 if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
32713 negated = token.negated = true;
32718 if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
32719 isGlob = token.isGlob = true;
32721 if (scanToEnd === true) {
32722 while (eos() !== true && (code = advance())) {
32723 if (code === CHAR_LEFT_PARENTHESES) {
32724 backslashes = token.backslashes = true;
32729 if (code === CHAR_RIGHT_PARENTHESES) {
32741 if (isGlob === true) {
32744 if (scanToEnd === true) {
32752 if (opts.noext === true) {
32762 prefix = str.slice(0, start);
32763 str = str.slice(start);
32764 lastIndex -= start;
32767 if (base && isGlob === true && lastIndex > 0) {
32768 base = str.slice(0, lastIndex);
32769 glob = str.slice(lastIndex);
32770 } else if (isGlob === true) {
32777 if (base && base !== '' && base !== '/' && base !== str) {
32778 if (isPathSeparator(base.charCodeAt(base.length - 1))) {
32779 base = base.slice(0, -1);
32783 if (opts.unescape === true) {
32784 if (glob) glob = utils$l.removeBackslashes(glob);
32786 if (base && backslashes === true) {
32787 base = utils$l.removeBackslashes(base);
32806 if (opts.tokens === true) {
32807 state.maxDepth = 0;
32809 if (!isPathSeparator(code)) {
32810 tokens.push(token);
32813 state.tokens = tokens;
32816 if (opts.parts === true || opts.tokens === true) {
32819 for (let idx = 0; idx < slashes.length; idx++) {
32820 const n = prevIndex ? prevIndex + 1 : start;
32821 const i = slashes[idx];
32822 const value = input.slice(n, i);
32825 if (idx === 0 && start !== 0) {
32826 tokens[idx].isPrefix = true;
32827 tokens[idx].value = prefix;
32829 tokens[idx].value = value;
32832 depth(tokens[idx]);
32833 state.maxDepth += tokens[idx].depth;
32836 if (idx !== 0 || value !== '') {
32843 if (prevIndex && prevIndex + 1 < input.length) {
32844 const value = input.slice(prevIndex + 1);
32848 tokens[tokens.length - 1].value = value;
32849 depth(tokens[tokens.length - 1]);
32850 state.maxDepth += tokens[tokens.length - 1].depth;
32854 state.slashes = slashes;
32855 state.parts = parts;
32861 var scan_1 = scan$1;
32863 const constants$2 = constants$3;
32864 const utils$k = utils$m;
32871 POSIX_REGEX_SOURCE,
32872 REGEX_NON_SPECIAL_CHARS,
32873 REGEX_SPECIAL_CHARS_BACKREF,
32880 const expandRange = (args, options) => {
32881 if (typeof options.expandRange === 'function') {
32882 return options.expandRange(...args, options);
32886 const value = `[${args.join('-')}]`;
32889 /* eslint-disable-next-line no-new */
32892 return args.map(v => utils$k.escapeRegex(v)).join('..');
32898 * Create the message for a syntax error
32902 const syntaxError$1 = (type, char) => {
32903 return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
32906 * Parse the given input string.
32907 * @param {String} input
32908 * @param {Object} options
32913 const parse$3 = (input, options) => {
32914 if (typeof input !== 'string') {
32915 throw new TypeError('Expected a string');
32918 input = REPLACEMENTS[input] || input;
32919 const opts = Object.assign({}, options);
32920 const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
32921 let len = input.length;
32924 throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
32930 output: opts.prepend || ''
32932 const tokens = [bos];
32933 const capture = opts.capture ? '' : '?:';
32934 const win32 = utils$k.isWindows(options); // create constants based on platform, for windows or posix
32936 const PLATFORM_CHARS = constants$2.globChars(win32);
32937 const EXTGLOB_CHARS = constants$2.extglobChars(PLATFORM_CHARS);
32951 } = PLATFORM_CHARS;
32953 const globstar = opts => {
32954 return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
32957 const nodot = opts.dot ? '' : NO_DOT;
32958 const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
32959 let star = opts.bash === true ? globstar(opts) : STAR;
32961 if (opts.capture) {
32962 star = `(${star})`;
32963 } // minimatch options support
32966 if (typeof opts.noext === 'boolean') {
32967 opts.noextglob = opts.noext;
32974 dot: opts.dot === true,
32987 input = utils$k.removePrefix(input, state);
32988 len = input.length;
32989 const extglobs = [];
32995 * Tokenizing helpers
32998 const eos = () => state.index === len - 1;
33000 const peek = state.peek = (n = 1) => input[state.index + n];
33002 const advance = state.advance = () => input[++state.index] || '';
33004 const remaining = () => input.slice(state.index + 1);
33006 const consume = (value = '', num = 0) => {
33007 state.consumed += value;
33008 state.index += num;
33011 const append = token => {
33012 state.output += token.output != null ? token.output : token.value;
33013 consume(token.value);
33016 const negate = () => {
33019 while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
33025 if (count % 2 === 0) {
33029 state.negated = true;
33034 const increment = type => {
33039 const decrement = type => {
33044 * Push tokens onto the tokens array. This helper speeds up
33045 * tokenizing by 1) helping us avoid backtracking as much as possible,
33046 * and 2) helping us avoid creating extra tokens when consecutive
33047 * characters are plain text. This improves performance and simplifies
33052 const push = tok => {
33053 if (prev.type === 'globstar') {
33054 const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
33055 const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren');
33057 if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
33058 state.output = state.output.slice(0, -prev.output.length);
33059 prev.type = 'star';
33061 prev.output = star;
33062 state.output += prev.output;
33066 if (extglobs.length && tok.type !== 'paren') {
33067 extglobs[extglobs.length - 1].inner += tok.value;
33070 if (tok.value || tok.output) append(tok);
33072 if (prev && prev.type === 'text' && tok.type === 'text') {
33073 prev.value += tok.value;
33074 prev.output = (prev.output || '') + tok.value;
33083 const extglobOpen = (type, value) => {
33084 const token = Object.assign(Object.assign({}, EXTGLOB_CHARS[value]), {}, {
33089 token.parens = state.parens;
33090 token.output = state.output;
33091 const output = (opts.capture ? '(' : '') + token.open;
33092 increment('parens');
33096 output: state.output ? '' : ONE_CHAR
33104 extglobs.push(token);
33107 const extglobClose = token => {
33108 let output = token.close + (opts.capture ? ')' : '');
33111 if (token.type === 'negate') {
33112 let extglobStar = star;
33114 if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
33115 extglobStar = globstar(opts);
33118 if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
33119 output = token.close = `)$))${extglobStar}`;
33122 if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
33123 output = token.close = `)${rest})${extglobStar})`;
33126 if (token.prev.type === 'bos') {
33127 state.negatedExtglob = true;
33137 decrement('parens');
33144 if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
33145 let backslashes = false;
33146 let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
33147 if (first === '\\') {
33148 backslashes = true;
33152 if (first === '?') {
33154 return esc + first + (rest ? QMARK.repeat(rest.length) : '');
33158 return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
33161 return QMARK.repeat(chars.length);
33164 if (first === '.') {
33165 return DOT_LITERAL.repeat(chars.length);
33168 if (first === '*') {
33170 return esc + first + (rest ? star : '');
33176 return esc ? m : `\\${m}`;
33179 if (backslashes === true) {
33180 if (opts.unescape === true) {
33181 output = output.replace(/\\/g, '');
33183 output = output.replace(/\\+/g, m => {
33184 return m.length % 2 === 0 ? '\\\\' : m ? '\\' : '';
33189 if (output === input && opts.contains === true) {
33190 state.output = input;
33194 state.output = utils$k.wrapOutput(output, state, options);
33198 * Tokenize input until we reach end-of-string
33205 if (value === '\u0000') {
33209 * Escaped characters
33213 if (value === '\\') {
33214 const next = peek();
33216 if (next === '/' && opts.bash !== true) {
33220 if (next === '.' || next === ';') {
33231 } // collapse slashes to reduce potential for exploits
33234 const match = /^\\+/.exec(remaining());
33237 if (match && match[0].length > 2) {
33238 slashes = match[0].length;
33239 state.index += slashes;
33241 if (slashes % 2 !== 0) {
33246 if (opts.unescape === true) {
33249 value += advance();
33252 if (state.brackets === 0) {
33261 * If we're inside a regex character class, continue
33262 * until we reach the closing bracket.
33266 if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
33267 if (opts.posix !== false && value === ':') {
33268 const inner = prev.value.slice(1);
33270 if (inner.includes('[')) {
33273 if (inner.includes(':')) {
33274 const idx = prev.value.lastIndexOf('[');
33275 const pre = prev.value.slice(0, idx);
33276 const rest = prev.value.slice(idx + 2);
33277 const posix = POSIX_REGEX_SOURCE[rest];
33280 prev.value = pre + posix;
33281 state.backtrack = true;
33284 if (!bos.output && tokens.indexOf(prev) === 1) {
33285 bos.output = ONE_CHAR;
33294 if (value === '[' && peek() !== ':' || value === '-' && peek() === ']') {
33295 value = `\\${value}`;
33298 if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
33299 value = `\\${value}`;
33302 if (opts.posix === true && value === '!' && prev.value === '[') {
33306 prev.value += value;
33313 * If we're inside a quoted string, continue
33314 * until we reach the closing double quote.
33318 if (state.quotes === 1 && value !== '"') {
33319 value = utils$k.escapeRegex(value);
33320 prev.value += value;
33331 if (value === '"') {
33332 state.quotes = state.quotes === 1 ? 0 : 1;
33334 if (opts.keepQuotes === true) {
33348 if (value === '(') {
33349 increment('parens');
33357 if (value === ')') {
33358 if (state.parens === 0 && opts.strictBrackets === true) {
33359 throw new SyntaxError(syntaxError$1('opening', '('));
33362 const extglob = extglobs[extglobs.length - 1];
33364 if (extglob && state.parens === extglob.parens + 1) {
33365 extglobClose(extglobs.pop());
33372 output: state.parens ? ')' : '\\)'
33374 decrement('parens');
33382 if (value === '[') {
33383 if (opts.nobracket === true || !remaining().includes(']')) {
33384 if (opts.nobracket !== true && opts.strictBrackets === true) {
33385 throw new SyntaxError(syntaxError$1('closing', ']'));
33388 value = `\\${value}`;
33390 increment('brackets');
33400 if (value === ']') {
33401 if (opts.nobracket === true || prev && prev.type === 'bracket' && prev.value.length === 1) {
33405 output: `\\${value}`
33410 if (state.brackets === 0) {
33411 if (opts.strictBrackets === true) {
33412 throw new SyntaxError(syntaxError$1('opening', '['));
33418 output: `\\${value}`
33423 decrement('brackets');
33424 const prevValue = prev.value.slice(1);
33426 if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
33427 value = `/${value}`;
33430 prev.value += value;
33433 }); // when literal brackets are explicitly disabled
33434 // assume we should match with a regex character class
33436 if (opts.literalBrackets === false || utils$k.hasRegexChars(prevValue)) {
33440 const escaped = utils$k.escapeRegex(prev.value);
33441 state.output = state.output.slice(0, -prev.value.length); // when literal brackets are explicitly enabled
33442 // assume we should escape the brackets to match literal characters
33444 if (opts.literalBrackets === true) {
33445 state.output += escaped;
33446 prev.value = escaped;
33448 } // when the user specifies nothing, try to match both
33451 prev.value = `(${capture}${escaped}|${prev.value})`;
33452 state.output += prev.value;
33460 if (value === '{' && opts.nobrace !== true) {
33461 increment('braces');
33466 outputIndex: state.output.length,
33467 tokensIndex: state.tokens.length
33474 if (value === '}') {
33475 const brace = braces[braces.length - 1];
33477 if (opts.nobrace === true || !brace) {
33488 if (brace.dots === true) {
33489 const arr = tokens.slice();
33492 for (let i = arr.length - 1; i >= 0; i--) {
33495 if (arr[i].type === 'brace') {
33499 if (arr[i].type !== 'dots') {
33500 range.unshift(arr[i].value);
33504 output = expandRange(range, opts);
33505 state.backtrack = true;
33508 if (brace.comma !== true && brace.dots !== true) {
33509 const out = state.output.slice(0, brace.outputIndex);
33510 const toks = state.tokens.slice(brace.tokensIndex);
33511 brace.value = brace.output = '\\{';
33512 value = output = '\\}';
33513 state.output = out;
33515 for (const t of toks) {
33516 state.output += t.output || t.value;
33525 decrement('braces');
33534 if (value === '|') {
33535 if (extglobs.length > 0) {
33536 extglobs[extglobs.length - 1].conditions++;
33550 if (value === ',') {
33551 let output = value;
33552 const brace = braces[braces.length - 1];
33554 if (brace && stack[stack.length - 1] === 'braces') {
33555 brace.comma = true;
33571 if (value === '/') {
33572 // if the beginning of the glob is "./", advance the start
33573 // to the current index, and don't add the "./" characters
33574 // to the state. This greatly simplifies lookbehinds when
33575 // checking for BOS characters like "!" and "." (not "./")
33576 if (prev.type === 'dot' && state.index === state.start + 1) {
33577 state.start = state.index + 1;
33578 state.consumed = '';
33581 prev = bos; // reset "prev" to the first token
33589 output: SLASH_LITERAL
33598 if (value === '.') {
33599 if (state.braces > 0 && prev.type === 'dot') {
33600 if (prev.value === '.') prev.output = DOT_LITERAL;
33601 const brace = braces[braces.length - 1];
33602 prev.type = 'dots';
33603 prev.output += value;
33604 prev.value += value;
33609 if (state.braces + state.parens === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
33613 output: DOT_LITERAL
33621 output: DOT_LITERAL
33630 if (value === '?') {
33631 const isGroup = prev && prev.value === '(';
33633 if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
33634 extglobOpen('qmark', value);
33638 if (prev && prev.type === 'paren') {
33639 const next = peek();
33640 let output = value;
33642 if (next === '<' && !utils$k.supportsLookbehinds()) {
33643 throw new Error('Node.js v10 or higher is required for regex lookbehinds');
33646 if (prev.value === '(' && !/[!=<:]/.test(next) || next === '<' && !/<([!=]|\w+>)/.test(remaining())) {
33647 output = `\\${value}`;
33658 if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
33662 output: QMARK_NO_DOT
33679 if (value === '!') {
33680 if (opts.noextglob !== true && peek() === '(') {
33681 if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
33682 extglobOpen('negate', value);
33687 if (opts.nonegate !== true && state.index === 0) {
33697 if (value === '+') {
33698 if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
33699 extglobOpen('plus', value);
33703 if (prev && prev.value === '(' || opts.regex === false) {
33707 output: PLUS_LITERAL
33712 if (prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace') || state.parens > 0) {
33722 value: PLUS_LITERAL
33731 if (value === '@') {
33732 if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
33753 if (value !== '*') {
33754 if (value === '$' || value === '^') {
33755 value = `\\${value}`;
33758 const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
33762 state.index += match[0].length;
33776 if (prev && (prev.type === 'globstar' || prev.star === true)) {
33777 prev.type = 'star';
33779 prev.value += value;
33780 prev.output = star;
33781 state.backtrack = true;
33782 state.globstar = true;
33787 let rest = remaining();
33789 if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
33790 extglobOpen('star', value);
33794 if (prev.type === 'star') {
33795 if (opts.noglobstar === true) {
33800 const prior = prev.prev;
33801 const before = prior.prev;
33802 const isStart = prior.type === 'slash' || prior.type === 'bos';
33803 const afterStar = before && (before.type === 'star' || before.type === 'globstar');
33805 if (opts.bash === true && (!isStart || rest[0] && rest[0] !== '/')) {
33814 const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
33815 const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
33817 if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
33824 } // strip consecutive `/**/`
33827 while (rest.slice(0, 3) === '/**') {
33828 const after = input[state.index + 4];
33830 if (after && after !== '/') {
33834 rest = rest.slice(3);
33838 if (prior.type === 'bos' && eos()) {
33839 prev.type = 'globstar';
33840 prev.value += value;
33841 prev.output = globstar(opts);
33842 state.output = prev.output;
33843 state.globstar = true;
33848 if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
33849 state.output = state.output.slice(0, -(prior.output + prev.output).length);
33850 prior.output = `(?:${prior.output}`;
33851 prev.type = 'globstar';
33852 prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
33853 prev.value += value;
33854 state.globstar = true;
33855 state.output += prior.output + prev.output;
33860 if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
33861 const end = rest[1] !== void 0 ? '|$' : '';
33862 state.output = state.output.slice(0, -(prior.output + prev.output).length);
33863 prior.output = `(?:${prior.output}`;
33864 prev.type = 'globstar';
33865 prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
33866 prev.value += value;
33867 state.output += prior.output + prev.output;
33868 state.globstar = true;
33869 consume(value + advance());
33878 if (prior.type === 'bos' && rest[0] === '/') {
33879 prev.type = 'globstar';
33880 prev.value += value;
33881 prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
33882 state.output = prev.output;
33883 state.globstar = true;
33884 consume(value + advance());
33891 } // remove single star from output
33894 state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar
33896 prev.type = 'globstar';
33897 prev.output = globstar(opts);
33898 prev.value += value; // reset output with globstar
33900 state.output += prev.output;
33901 state.globstar = true;
33912 if (opts.bash === true) {
33913 token.output = '.*?';
33915 if (prev.type === 'bos' || prev.type === 'slash') {
33916 token.output = nodot + token.output;
33923 if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
33924 token.output = value;
33929 if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
33930 if (prev.type === 'dot') {
33931 state.output += NO_DOT_SLASH;
33932 prev.output += NO_DOT_SLASH;
33933 } else if (opts.dot === true) {
33934 state.output += NO_DOTS_SLASH;
33935 prev.output += NO_DOTS_SLASH;
33937 state.output += nodot;
33938 prev.output += nodot;
33941 if (peek() !== '*') {
33942 state.output += ONE_CHAR;
33943 prev.output += ONE_CHAR;
33950 while (state.brackets > 0) {
33951 if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', ']'));
33952 state.output = utils$k.escapeLast(state.output, '[');
33953 decrement('brackets');
33956 while (state.parens > 0) {
33957 if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', ')'));
33958 state.output = utils$k.escapeLast(state.output, '(');
33959 decrement('parens');
33962 while (state.braces > 0) {
33963 if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', '}'));
33964 state.output = utils$k.escapeLast(state.output, '{');
33965 decrement('braces');
33968 if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
33970 type: 'maybe_slash',
33972 output: `${SLASH_LITERAL}?`
33974 } // rebuild the output if we had to backtrack at any point
33977 if (state.backtrack === true) {
33980 for (const token of state.tokens) {
33981 state.output += token.output != null ? token.output : token.value;
33983 if (token.suffix) {
33984 state.output += token.suffix;
33992 * Fast paths for creating regular expressions for common glob patterns.
33993 * This can significantly speed up processing and has very little downside
33994 * impact when none of the fast paths match.
33998 parse$3.fastpaths = (input, options) => {
33999 const opts = Object.assign({}, options);
34000 const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
34001 const len = input.length;
34004 throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
34007 input = REPLACEMENTS[input] || input;
34008 const win32 = utils$k.isWindows(options); // create constants based on platform, for windows or posix
34020 } = constants$2.globChars(win32);
34021 const nodot = opts.dot ? NO_DOTS : NO_DOT;
34022 const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
34023 const capture = opts.capture ? '' : '?:';
34028 let star = opts.bash === true ? '.*?' : STAR;
34030 if (opts.capture) {
34031 star = `(${star})`;
34034 const globstar = opts => {
34035 if (opts.noglobstar === true) return star;
34036 return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
34039 const create = str => {
34042 return `${nodot}${ONE_CHAR}${star}`;
34045 return `${DOT_LITERAL}${ONE_CHAR}${star}`;
34048 return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
34051 return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
34054 return nodot + globstar(opts);
34057 return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
34060 return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
34063 return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
34067 const match = /^(.*?)\.(\w+)$/.exec(str);
34068 if (!match) return;
34069 const source = create(match[1]);
34070 if (!source) return;
34071 return source + DOT_LITERAL + match[2];
34076 const output = utils$k.removePrefix(input, state);
34077 let source = create(output);
34079 if (source && opts.strictSlashes !== true) {
34080 source += `${SLASH_LITERAL}?`;
34086 var parse_1$1 = parse$3;
34088 const path$9 = require$$0__default$2["default"];
34089 const scan = scan_1;
34090 const parse$2 = parse_1$1;
34091 const utils$j = utils$m;
34092 const constants$1 = constants$3;
34094 const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
34096 * Creates a matcher function from one or more glob patterns. The
34097 * returned function takes a string to match as its first argument,
34098 * and returns true if the string is a match. The returned matcher
34099 * function also takes a boolean as the second argument that, when true,
34100 * returns an object with additional information.
34103 * const picomatch = require('picomatch');
34104 * // picomatch(glob[, options]);
34106 * const isMatch = picomatch('*.!(*a)');
34107 * console.log(isMatch('a.a')); //=> false
34108 * console.log(isMatch('a.b')); //=> true
34111 * @param {String|Array} `globs` One or more glob patterns.
34112 * @param {Object=} `options`
34113 * @return {Function=} Returns a matcher function.
34118 const picomatch$2 = (glob, options, returnState = false) => {
34119 if (Array.isArray(glob)) {
34120 const fns = glob.map(input => picomatch$2(input, options, returnState));
34122 const arrayMatcher = str => {
34123 for (const isMatch of fns) {
34124 const state = isMatch(str);
34125 if (state) return state;
34131 return arrayMatcher;
34134 const isState = isObject(glob) && glob.tokens && glob.input;
34136 if (glob === '' || typeof glob !== 'string' && !isState) {
34137 throw new TypeError('Expected pattern to be a non-empty string');
34140 const opts = options || {};
34141 const posix = utils$j.isWindows(options);
34142 const regex = isState ? picomatch$2.compileRe(glob, options) : picomatch$2.makeRe(glob, options, false, true);
34143 const state = regex.state;
34144 delete regex.state;
34146 let isIgnored = () => false;
34149 const ignoreOpts = Object.assign(Object.assign({}, options), {}, {
34154 isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
34157 const matcher = (input, returnObject = false) => {
34162 } = picomatch$2.test(input, regex, options, {
34177 if (typeof opts.onResult === 'function') {
34178 opts.onResult(result);
34181 if (isMatch === false) {
34182 result.isMatch = false;
34183 return returnObject ? result : false;
34186 if (isIgnored(input)) {
34187 if (typeof opts.onIgnore === 'function') {
34188 opts.onIgnore(result);
34191 result.isMatch = false;
34192 return returnObject ? result : false;
34195 if (typeof opts.onMatch === 'function') {
34196 opts.onMatch(result);
34199 return returnObject ? result : true;
34203 matcher.state = state;
34209 * Test `input` with the given `regex`. This is used by the main
34210 * `picomatch()` function to test the input string.
34213 * const picomatch = require('picomatch');
34214 * // picomatch.test(input, regex[, options]);
34216 * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
34217 * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
34219 * @param {String} `input` String to test.
34220 * @param {RegExp} `regex`
34221 * @return {Object} Returns an object with matching info.
34226 picomatch$2.test = (input, regex, options, {
34230 if (typeof input !== 'string') {
34231 throw new TypeError('Expected input to be a string');
34234 if (input === '') {
34241 const opts = options || {};
34242 const format = opts.format || (posix ? utils$j.toPosixSlashes : null);
34243 let match = input === glob;
34244 let output = match && format ? format(input) : input;
34246 if (match === false) {
34247 output = format ? format(input) : input;
34248 match = output === glob;
34251 if (match === false || opts.capture === true) {
34252 if (opts.matchBase === true || opts.basename === true) {
34253 match = picomatch$2.matchBase(input, regex, options, posix);
34255 match = regex.exec(output);
34260 isMatch: Boolean(match),
34266 * Match the basename of a filepath.
34269 * const picomatch = require('picomatch');
34270 * // picomatch.matchBase(input, glob[, options]);
34271 * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
34273 * @param {String} `input` String to test.
34274 * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
34275 * @return {Boolean}
34280 picomatch$2.matchBase = (input, glob, options, posix = utils$j.isWindows(options)) => {
34281 const regex = glob instanceof RegExp ? glob : picomatch$2.makeRe(glob, options);
34282 return regex.test(path$9.basename(input));
34285 * Returns true if **any** of the given glob `patterns` match the specified `string`.
34288 * const picomatch = require('picomatch');
34289 * // picomatch.isMatch(string, patterns[, options]);
34291 * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
34292 * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
34294 * @param {String|Array} str The string to test.
34295 * @param {String|Array} patterns One or more glob patterns to use for matching.
34296 * @param {Object} [options] See available [options](#options).
34297 * @return {Boolean} Returns true if any patterns match `str`
34302 picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
34304 * Parse a glob pattern to create the source string for a regular
34308 * const picomatch = require('picomatch');
34309 * const result = picomatch.parse(pattern[, options]);
34311 * @param {String} `pattern`
34312 * @param {Object} `options`
34313 * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
34318 picomatch$2.parse = (pattern, options) => {
34319 if (Array.isArray(pattern)) return pattern.map(p => picomatch$2.parse(p, options));
34320 return parse$2(pattern, Object.assign(Object.assign({}, options), {}, {
34325 * Scan a glob pattern to separate the pattern into segments.
34328 * const picomatch = require('picomatch');
34329 * // picomatch.scan(input[, options]);
34331 * const result = picomatch.scan('!./foo/*.js');
34332 * console.log(result);
34334 * input: '!./foo/*.js',
34339 * isBracket: false,
34341 * isExtglob: false,
34342 * isGlobstar: false,
34345 * @param {String} `input` Glob pattern to scan.
34346 * @param {Object} `options`
34347 * @return {Object} Returns an object with
34352 picomatch$2.scan = (input, options) => scan(input, options);
34354 * Compile a regular expression from the `state` object returned by the
34355 * [parse()](#parse) method.
34357 * @param {Object} `state`
34358 * @param {Object} `options`
34359 * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
34360 * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
34366 picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
34367 if (returnOutput === true) {
34368 return state.output;
34371 const opts = options || {};
34372 const prepend = opts.contains ? '' : '^';
34373 const append = opts.contains ? '' : '$';
34374 let source = `${prepend}(?:${state.output})${append}`;
34376 if (state && state.negated === true) {
34377 source = `^(?!${source}).*$`;
34380 const regex = picomatch$2.toRegex(source, options);
34382 if (returnState === true) {
34383 regex.state = state;
34389 * Create a regular expression from a parsed glob pattern.
34392 * const picomatch = require('picomatch');
34393 * const state = picomatch.parse('*.js');
34394 * // picomatch.compileRe(state[, options]);
34396 * console.log(picomatch.compileRe(state));
34397 * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
34399 * @param {String} `state` The object returned from the `.parse` method.
34400 * @param {Object} `options`
34401 * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
34402 * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
34403 * @return {RegExp} Returns a regex created from the given pattern.
34408 picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
34409 if (!input || typeof input !== 'string') {
34410 throw new TypeError('Expected a non-empty string');
34418 if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
34419 parsed.output = parse$2.fastpaths(input, options);
34422 if (!parsed.output) {
34423 parsed = parse$2(input, options);
34426 return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
34429 * Create a regular expression from the given regex source string.
34432 * const picomatch = require('picomatch');
34433 * // picomatch.toRegex(source[, options]);
34435 * const { output } = picomatch.parse('*.js');
34436 * console.log(picomatch.toRegex(output));
34437 * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
34439 * @param {String} `source` Regular expression source string.
34440 * @param {Object} `options`
34446 picomatch$2.toRegex = (source, options) => {
34448 const opts = options || {};
34449 return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
34451 if (options && options.debug === true) throw err;
34456 * Picomatch constants.
34461 picomatch$2.constants = constants$1;
34463 * Expose "picomatch"
34466 var picomatch_1 = picomatch$2;
34468 var picomatch$1 = picomatch_1;
34470 const util$1 = require$$0__default$4["default"];
34471 const braces = braces_1;
34472 const picomatch = picomatch$1;
34473 const utils$i = utils$m;
34475 const isEmptyString = val => val === '' || val === './';
34477 * Returns an array of strings that match one or more glob patterns.
34480 * const mm = require('micromatch');
34481 * // mm(list, patterns[, options]);
34483 * console.log(mm(['a.js', 'a.txt'], ['*.js']));
34486 * @param {String|Array<string>} `list` List of strings to match.
34487 * @param {String|Array<string>} `patterns` One or more glob patterns to use for matching.
34488 * @param {Object} `options` See available [options](#options)
34489 * @return {Array} Returns an array of matches
34495 const micromatch$1 = (list, patterns, options) => {
34496 patterns = [].concat(patterns);
34497 list = [].concat(list);
34498 let omit = new Set();
34499 let keep = new Set();
34500 let items = new Set();
34503 let onResult = state => {
34504 items.add(state.output);
34506 if (options && options.onResult) {
34507 options.onResult(state);
34511 for (let i = 0; i < patterns.length; i++) {
34512 let isMatch = picomatch(String(patterns[i]), Object.assign(Object.assign({}, options), {}, {
34515 let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
34516 if (negated) negatives++;
34518 for (let item of list) {
34519 let matched = isMatch(item, true);
34520 let match = negated ? !matched.isMatch : matched.isMatch;
34521 if (!match) continue;
34524 omit.add(matched.output);
34526 omit.delete(matched.output);
34527 keep.add(matched.output);
34532 let result = negatives === patterns.length ? [...items] : [...keep];
34533 let matches = result.filter(item => !omit.has(item));
34535 if (options && matches.length === 0) {
34536 if (options.failglob === true) {
34537 throw new Error(`No matches found for "${patterns.join(', ')}"`);
34540 if (options.nonull === true || options.nullglob === true) {
34541 return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns;
34548 * Backwards compatibility
34552 micromatch$1.match = micromatch$1;
34554 * Returns a matcher function from the given glob `pattern` and `options`.
34555 * The returned function takes a string to match as its only argument and returns
34556 * true if the string is a match.
34559 * const mm = require('micromatch');
34560 * // mm.matcher(pattern[, options]);
34562 * const isMatch = mm.matcher('*.!(*a)');
34563 * console.log(isMatch('a.a')); //=> false
34564 * console.log(isMatch('a.b')); //=> true
34566 * @param {String} `pattern` Glob pattern
34567 * @param {Object} `options`
34568 * @return {Function} Returns a matcher function.
34572 micromatch$1.matcher = (pattern, options) => picomatch(pattern, options);
34574 * Returns true if **any** of the given glob `patterns` match the specified `string`.
34577 * const mm = require('micromatch');
34578 * // mm.isMatch(string, patterns[, options]);
34580 * console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
34581 * console.log(mm.isMatch('a.a', 'b.*')); //=> false
34583 * @param {String} `str` The string to test.
34584 * @param {String|Array} `patterns` One or more glob patterns to use for matching.
34585 * @param {Object} `[options]` See available [options](#options).
34586 * @return {Boolean} Returns true if any patterns match `str`
34591 micromatch$1.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
34593 * Backwards compatibility
34597 micromatch$1.any = micromatch$1.isMatch;
34599 * Returns a list of strings that _**do not match any**_ of the given `patterns`.
34602 * const mm = require('micromatch');
34603 * // mm.not(list, patterns[, options]);
34605 * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
34606 * //=> ['b.b', 'c.c']
34608 * @param {Array} `list` Array of strings to match.
34609 * @param {String|Array} `patterns` One or more glob pattern to use for matching.
34610 * @param {Object} `options` See available [options](#options) for changing how matches are performed
34611 * @return {Array} Returns an array of strings that **do not match** the given patterns.
34615 micromatch$1.not = (list, patterns, options = {}) => {
34616 patterns = [].concat(patterns).map(String);
34617 let result = new Set();
34620 let onResult = state => {
34621 if (options.onResult) options.onResult(state);
34622 items.push(state.output);
34625 let matches = micromatch$1(list, patterns, Object.assign(Object.assign({}, options), {}, {
34629 for (let item of items) {
34630 if (!matches.includes(item)) {
34635 return [...result];
34638 * Returns true if the given `string` contains the given pattern. Similar
34639 * to [.isMatch](#isMatch) but the pattern can match any part of the string.
34642 * var mm = require('micromatch');
34643 * // mm.contains(string, pattern[, options]);
34645 * console.log(mm.contains('aa/bb/cc', '*b'));
34647 * console.log(mm.contains('aa/bb/cc', '*d'));
34650 * @param {String} `str` The string to match.
34651 * @param {String|Array} `patterns` Glob pattern to use for matching.
34652 * @param {Object} `options` See available [options](#options) for changing how matches are performed
34653 * @return {Boolean} Returns true if any of the patterns matches any part of `str`.
34658 micromatch$1.contains = (str, pattern, options) => {
34659 if (typeof str !== 'string') {
34660 throw new TypeError(`Expected a string: "${util$1.inspect(str)}"`);
34663 if (Array.isArray(pattern)) {
34664 return pattern.some(p => micromatch$1.contains(str, p, options));
34667 if (typeof pattern === 'string') {
34668 if (isEmptyString(str) || isEmptyString(pattern)) {
34672 if (str.includes(pattern) || str.startsWith('./') && str.slice(2).includes(pattern)) {
34677 return micromatch$1.isMatch(str, pattern, Object.assign(Object.assign({}, options), {}, {
34682 * Filter the keys of the given object with the given `glob` pattern
34683 * and `options`. Does not attempt to match nested keys. If you need this feature,
34684 * use [glob-object][] instead.
34687 * const mm = require('micromatch');
34688 * // mm.matchKeys(object, patterns[, options]);
34690 * const obj = { aa: 'a', ab: 'b', ac: 'c' };
34691 * console.log(mm.matchKeys(obj, '*b'));
34694 * @param {Object} `object` The object with keys to filter.
34695 * @param {String|Array} `patterns` One or more glob patterns to use for matching.
34696 * @param {Object} `options` See available [options](#options) for changing how matches are performed
34697 * @return {Object} Returns an object with only keys that match the given patterns.
34702 micromatch$1.matchKeys = (obj, patterns, options) => {
34703 if (!utils$i.isObject(obj)) {
34704 throw new TypeError('Expected the first argument to be an object');
34707 let keys = micromatch$1(Object.keys(obj), patterns, options);
34710 for (let key of keys) res[key] = obj[key];
34715 * Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
34718 * const mm = require('micromatch');
34719 * // mm.some(list, patterns[, options]);
34721 * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
34723 * console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
34726 * @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
34727 * @param {String|Array} `patterns` One or more glob patterns to use for matching.
34728 * @param {Object} `options` See available [options](#options) for changing how matches are performed
34729 * @return {Boolean} Returns true if any `patterns` matches any of the strings in `list`
34734 micromatch$1.some = (list, patterns, options) => {
34735 let items = [].concat(list);
34737 for (let pattern of [].concat(patterns)) {
34738 let isMatch = picomatch(String(pattern), options);
34740 if (items.some(item => isMatch(item))) {
34748 * Returns true if every string in the given `list` matches
34749 * any of the given glob `patterns`.
34752 * const mm = require('micromatch');
34753 * // mm.every(list, patterns[, options]);
34755 * console.log(mm.every('foo.js', ['foo.js']));
34757 * console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
34759 * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
34761 * console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
34764 * @param {String|Array} `list` The string or array of strings to test.
34765 * @param {String|Array} `patterns` One or more glob patterns to use for matching.
34766 * @param {Object} `options` See available [options](#options) for changing how matches are performed
34767 * @return {Boolean} Returns true if all `patterns` matches all of the strings in `list`
34772 micromatch$1.every = (list, patterns, options) => {
34773 let items = [].concat(list);
34775 for (let pattern of [].concat(patterns)) {
34776 let isMatch = picomatch(String(pattern), options);
34778 if (!items.every(item => isMatch(item))) {
34786 * Returns true if **all** of the given `patterns` match
34787 * the specified string.
34790 * const mm = require('micromatch');
34791 * // mm.all(string, patterns[, options]);
34793 * console.log(mm.all('foo.js', ['foo.js']));
34796 * console.log(mm.all('foo.js', ['*.js', '!foo.js']));
34799 * console.log(mm.all('foo.js', ['*.js', 'foo.js']));
34802 * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
34805 * @param {String|Array} `str` The string to test.
34806 * @param {String|Array} `patterns` One or more glob patterns to use for matching.
34807 * @param {Object} `options` See available [options](#options) for changing how matches are performed
34808 * @return {Boolean} Returns true if any patterns match `str`
34813 micromatch$1.all = (str, patterns, options) => {
34814 if (typeof str !== 'string') {
34815 throw new TypeError(`Expected a string: "${util$1.inspect(str)}"`);
34818 return [].concat(patterns).every(p => picomatch(p, options)(str));
34821 * Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
34824 * const mm = require('micromatch');
34825 * // mm.capture(pattern, string[, options]);
34827 * console.log(mm.capture('test/*.js', 'test/foo.js'));
34829 * console.log(mm.capture('test/*.js', 'foo/bar.css'));
34832 * @param {String} `glob` Glob pattern to use for matching.
34833 * @param {String} `input` String to match
34834 * @param {Object} `options` See available [options](#options) for changing how matches are performed
34835 * @return {Array|null} Returns an array of captures if the input matches the glob pattern, otherwise `null`.
34840 micromatch$1.capture = (glob, input, options) => {
34841 let posix = utils$i.isWindows(options);
34842 let regex = picomatch.makeRe(String(glob), Object.assign(Object.assign({}, options), {}, {
34845 let match = regex.exec(posix ? utils$i.toPosixSlashes(input) : input);
34848 return match.slice(1).map(v => v === void 0 ? '' : v);
34852 * Create a regular expression from the given glob `pattern`.
34855 * const mm = require('micromatch');
34856 * // mm.makeRe(pattern[, options]);
34858 * console.log(mm.makeRe('*.js'));
34859 * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
34861 * @param {String} `pattern` A glob pattern to convert to regex.
34862 * @param {Object} `options`
34863 * @return {RegExp} Returns a regex created from the given pattern.
34868 micromatch$1.makeRe = (...args) => picomatch.makeRe(...args);
34870 * Scan a glob pattern to separate the pattern into segments. Used
34871 * by the [split](#split) method.
34874 * const mm = require('micromatch');
34875 * const state = mm.scan(pattern[, options]);
34877 * @param {String} `pattern`
34878 * @param {Object} `options`
34879 * @return {Object} Returns an object with
34884 micromatch$1.scan = (...args) => picomatch.scan(...args);
34886 * Parse a glob pattern to create the source string for a regular
34890 * const mm = require('micromatch');
34891 * const state = mm(pattern[, options]);
34893 * @param {String} `glob`
34894 * @param {Object} `options`
34895 * @return {Object} Returns an object with useful properties and output to be used as regex source string.
34900 micromatch$1.parse = (patterns, options) => {
34903 for (let pattern of [].concat(patterns || [])) {
34904 for (let str of braces(String(pattern), options)) {
34905 res.push(picomatch.parse(str, options));
34912 * Process the given brace `pattern`.
34915 * const { braces } = require('micromatch');
34916 * console.log(braces('foo/{a,b,c}/bar'));
34917 * //=> [ 'foo/(a|b|c)/bar' ]
34919 * console.log(braces('foo/{a,b,c}/bar', { expand: true }));
34920 * //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ]
34922 * @param {String} `pattern` String with brace pattern to process.
34923 * @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
34929 micromatch$1.braces = (pattern, options) => {
34930 if (typeof pattern !== 'string') throw new TypeError('Expected a string');
34932 if (options && options.nobrace === true || !/\{.*\}/.test(pattern)) {
34936 return braces(pattern, options);
34943 micromatch$1.braceExpand = (pattern, options) => {
34944 if (typeof pattern !== 'string') throw new TypeError('Expected a string');
34945 return micromatch$1.braces(pattern, Object.assign(Object.assign({}, options), {}, {
34950 * Expose micromatch
34954 var micromatch_1 = micromatch$1;
34956 Object.defineProperty(pattern$1, "__esModule", {
34959 pattern$1.matchAny = pattern$1.convertPatternsToRe = pattern$1.makeRe = pattern$1.getPatternParts = pattern$1.expandBraceExpansion = pattern$1.expandPatternsWithBraceExpansion = pattern$1.isAffectDepthOfReadingPattern = pattern$1.endsWithSlashGlobStar = pattern$1.hasGlobStar = pattern$1.getBaseDirectory = pattern$1.isPatternRelatedToParentDirectory = pattern$1.getPatternsOutsideCurrentDirectory = pattern$1.getPatternsInsideCurrentDirectory = pattern$1.getPositivePatterns = pattern$1.getNegativePatterns = pattern$1.isPositivePattern = pattern$1.isNegativePattern = pattern$1.convertToNegativePattern = pattern$1.convertToPositivePattern = pattern$1.isDynamicPattern = pattern$1.isStaticPattern = void 0;
34960 const path$8 = require$$0__default$2["default"];
34961 const globParent = globParent$1;
34962 const micromatch = micromatch_1;
34963 const GLOBSTAR = '**';
34964 const ESCAPE_SYMBOL = '\\';
34965 const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
34966 const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[.*]/;
34967 const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\(.*\|.*\)/;
34968 const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\(.*\)/;
34969 const BRACE_EXPANSIONS_SYMBOLS_RE = /{.*(?:,|\.\.).*}/;
34971 function isStaticPattern(pattern, options = {}) {
34972 return !isDynamicPattern(pattern, options);
34975 pattern$1.isStaticPattern = isStaticPattern;
34977 function isDynamicPattern(pattern, options = {}) {
34979 * A special case with an empty string is necessary for matching patterns that start with a forward slash.
34980 * An empty string cannot be a dynamic pattern.
34981 * For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
34983 if (pattern === '') {
34987 * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
34988 * filepath directly (without read directory).
34992 if (options.caseSensitiveMatch === false || pattern.includes(ESCAPE_SYMBOL)) {
34996 if (COMMON_GLOB_SYMBOLS_RE.test(pattern) || REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || REGEX_GROUP_SYMBOLS_RE.test(pattern)) {
35000 if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) {
35004 if (options.braceExpansion !== false && BRACE_EXPANSIONS_SYMBOLS_RE.test(pattern)) {
35011 pattern$1.isDynamicPattern = isDynamicPattern;
35013 function convertToPositivePattern(pattern) {
35014 return isNegativePattern(pattern) ? pattern.slice(1) : pattern;
35017 pattern$1.convertToPositivePattern = convertToPositivePattern;
35019 function convertToNegativePattern(pattern) {
35020 return '!' + pattern;
35023 pattern$1.convertToNegativePattern = convertToNegativePattern;
35025 function isNegativePattern(pattern) {
35026 return pattern.startsWith('!') && pattern[1] !== '(';
35029 pattern$1.isNegativePattern = isNegativePattern;
35031 function isPositivePattern(pattern) {
35032 return !isNegativePattern(pattern);
35035 pattern$1.isPositivePattern = isPositivePattern;
35037 function getNegativePatterns(patterns) {
35038 return patterns.filter(isNegativePattern);
35041 pattern$1.getNegativePatterns = getNegativePatterns;
35043 function getPositivePatterns$1(patterns) {
35044 return patterns.filter(isPositivePattern);
35047 pattern$1.getPositivePatterns = getPositivePatterns$1;
35049 * Returns patterns that can be applied inside the current directory.
35052 * // ['./*', '*', 'a/*']
35053 * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
35056 function getPatternsInsideCurrentDirectory(patterns) {
35057 return patterns.filter(pattern => !isPatternRelatedToParentDirectory(pattern));
35060 pattern$1.getPatternsInsideCurrentDirectory = getPatternsInsideCurrentDirectory;
35062 * Returns patterns to be expanded relative to (outside) the current directory.
35065 * // ['../*', './../*']
35066 * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
35069 function getPatternsOutsideCurrentDirectory(patterns) {
35070 return patterns.filter(isPatternRelatedToParentDirectory);
35073 pattern$1.getPatternsOutsideCurrentDirectory = getPatternsOutsideCurrentDirectory;
35075 function isPatternRelatedToParentDirectory(pattern) {
35076 return pattern.startsWith('..') || pattern.startsWith('./..');
35079 pattern$1.isPatternRelatedToParentDirectory = isPatternRelatedToParentDirectory;
35081 function getBaseDirectory(pattern) {
35082 return globParent(pattern, {
35083 flipBackslashes: false
35087 pattern$1.getBaseDirectory = getBaseDirectory;
35089 function hasGlobStar(pattern) {
35090 return pattern.includes(GLOBSTAR);
35093 pattern$1.hasGlobStar = hasGlobStar;
35095 function endsWithSlashGlobStar(pattern) {
35096 return pattern.endsWith('/' + GLOBSTAR);
35099 pattern$1.endsWithSlashGlobStar = endsWithSlashGlobStar;
35101 function isAffectDepthOfReadingPattern(pattern) {
35102 const basename = path$8.basename(pattern);
35103 return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
35106 pattern$1.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
35108 function expandPatternsWithBraceExpansion(patterns) {
35109 return patterns.reduce((collection, pattern) => {
35110 return collection.concat(expandBraceExpansion(pattern));
35114 pattern$1.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
35116 function expandBraceExpansion(pattern) {
35117 return micromatch.braces(pattern, {
35123 pattern$1.expandBraceExpansion = expandBraceExpansion;
35125 function getPatternParts(pattern, options) {
35128 } = micromatch.scan(pattern, Object.assign(Object.assign({}, options), {
35132 * The scan method returns an empty array in some cases.
35133 * See micromatch/picomatch#58 for more details.
35136 if (parts.length === 0) {
35140 * The scan method does not return an empty part for the pattern with a forward slash.
35141 * This is another part of micromatch/picomatch#58.
35145 if (parts[0].startsWith('/')) {
35146 parts[0] = parts[0].slice(1);
35153 pattern$1.getPatternParts = getPatternParts;
35155 function makeRe(pattern, options) {
35156 return micromatch.makeRe(pattern, options);
35159 pattern$1.makeRe = makeRe;
35161 function convertPatternsToRe(patterns, options) {
35162 return patterns.map(pattern => makeRe(pattern, options));
35165 pattern$1.convertPatternsToRe = convertPatternsToRe;
35167 function matchAny(entry, patternsRe) {
35168 return patternsRe.some(patternRe => patternRe.test(entry));
35171 pattern$1.matchAny = matchAny;
35175 Object.defineProperty(stream$4, "__esModule", {
35178 stream$4.merge = void 0;
35179 const merge2$1 = merge2_1;
35181 function merge(streams) {
35182 const mergedStream = merge2$1(streams);
35183 streams.forEach(stream => {
35184 stream.once('error', error => mergedStream.emit('error', error));
35186 mergedStream.once('close', () => propagateCloseEventToSources(streams));
35187 mergedStream.once('end', () => propagateCloseEventToSources(streams));
35188 return mergedStream;
35191 stream$4.merge = merge;
35193 function propagateCloseEventToSources(streams) {
35194 streams.forEach(stream => stream.emit('close'));
35199 Object.defineProperty(string$1, "__esModule", {
35202 string$1.isEmpty = string$1.isString = void 0;
35204 function isString$1(input) {
35205 return typeof input === 'string';
35208 string$1.isString = isString$1;
35210 function isEmpty(input) {
35211 return input === '';
35214 string$1.isEmpty = isEmpty;
35216 Object.defineProperty(utils$r, "__esModule", {
35219 utils$r.string = utils$r.stream = utils$r.pattern = utils$r.path = utils$r.fs = utils$r.errno = utils$r.array = void 0;
35220 const array$1 = array$2;
35221 utils$r.array = array$1;
35222 const errno = errno$1;
35223 utils$r.errno = errno;
35226 const path$7 = path$c;
35227 utils$r.path = path$7;
35228 const pattern = pattern$1;
35229 utils$r.pattern = pattern;
35230 const stream$3 = stream$4;
35231 utils$r.stream = stream$3;
35232 const string = string$1;
35233 utils$r.string = string;
35235 Object.defineProperty(tasks, "__esModule", {
35238 tasks.convertPatternGroupToTask = tasks.convertPatternGroupsToTasks = tasks.groupPatternsByBaseDirectory = tasks.getNegativePatternsAsPositive = tasks.getPositivePatterns = tasks.convertPatternsToTasks = tasks.generate = void 0;
35239 const utils$h = utils$r;
35241 function generate(patterns, settings) {
35242 const positivePatterns = getPositivePatterns(patterns);
35243 const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore);
35244 const staticPatterns = positivePatterns.filter(pattern => utils$h.pattern.isStaticPattern(pattern, settings));
35245 const dynamicPatterns = positivePatterns.filter(pattern => utils$h.pattern.isDynamicPattern(pattern, settings));
35246 const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns,
35249 const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns,
35252 return staticTasks.concat(dynamicTasks);
35255 tasks.generate = generate;
35257 * Returns tasks grouped by basic pattern directories.
35259 * Patterns that can be found inside (`./`) and outside (`../`) the current directory are handled separately.
35260 * This is necessary because directory traversal starts at the base directory and goes deeper.
35263 function convertPatternsToTasks(positive, negative, dynamic) {
35265 const patternsOutsideCurrentDirectory = utils$h.pattern.getPatternsOutsideCurrentDirectory(positive);
35266 const patternsInsideCurrentDirectory = utils$h.pattern.getPatternsInsideCurrentDirectory(positive);
35267 const outsideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsOutsideCurrentDirectory);
35268 const insideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsInsideCurrentDirectory);
35269 tasks.push(...convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, negative, dynamic));
35271 * For the sake of reducing future accesses to the file system, we merge all tasks within the current directory
35272 * into a global task, if at least one pattern refers to the root (`.`). In this case, the global task covers the rest.
35275 if ('.' in insideCurrentDirectoryGroup) {
35276 tasks.push(convertPatternGroupToTask('.', patternsInsideCurrentDirectory, negative, dynamic));
35278 tasks.push(...convertPatternGroupsToTasks(insideCurrentDirectoryGroup, negative, dynamic));
35284 tasks.convertPatternsToTasks = convertPatternsToTasks;
35286 function getPositivePatterns(patterns) {
35287 return utils$h.pattern.getPositivePatterns(patterns);
35290 tasks.getPositivePatterns = getPositivePatterns;
35292 function getNegativePatternsAsPositive(patterns, ignore) {
35293 const negative = utils$h.pattern.getNegativePatterns(patterns).concat(ignore);
35294 const positive = negative.map(utils$h.pattern.convertToPositivePattern);
35298 tasks.getNegativePatternsAsPositive = getNegativePatternsAsPositive;
35300 function groupPatternsByBaseDirectory(patterns) {
35302 return patterns.reduce((collection, pattern) => {
35303 const base = utils$h.pattern.getBaseDirectory(pattern);
35305 if (base in collection) {
35306 collection[base].push(pattern);
35308 collection[base] = [pattern];
35315 tasks.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory;
35317 function convertPatternGroupsToTasks(positive, negative, dynamic) {
35318 return Object.keys(positive).map(base => {
35319 return convertPatternGroupToTask(base, positive[base], negative, dynamic);
35323 tasks.convertPatternGroupsToTasks = convertPatternGroupsToTasks;
35325 function convertPatternGroupToTask(base, positive, negative, dynamic) {
35331 patterns: [].concat(positive, negative.map(utils$h.pattern.convertToNegativePattern))
35335 tasks.convertPatternGroupToTask = convertPatternGroupToTask;
35345 Object.defineProperty(async$5, "__esModule", {
35348 async$5.read = void 0;
35350 function read$3(path, settings, callback) {
35351 settings.fs.lstat(path, (lstatError, lstat) => {
35352 if (lstatError !== null) {
35353 callFailureCallback$2(callback, lstatError);
35357 if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
35358 callSuccessCallback$2(callback, lstat);
35362 settings.fs.stat(path, (statError, stat) => {
35363 if (statError !== null) {
35364 if (settings.throwErrorOnBrokenSymbolicLink) {
35365 callFailureCallback$2(callback, statError);
35369 callSuccessCallback$2(callback, lstat);
35373 if (settings.markSymbolicLink) {
35374 stat.isSymbolicLink = () => true;
35377 callSuccessCallback$2(callback, stat);
35382 async$5.read = read$3;
35384 function callFailureCallback$2(callback, error) {
35388 function callSuccessCallback$2(callback, result) {
35389 callback(null, result);
35394 Object.defineProperty(sync$7, "__esModule", {
35397 sync$7.read = void 0;
35399 function read$2(path, settings) {
35400 const lstat = settings.fs.lstatSync(path);
35402 if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
35407 const stat = settings.fs.statSync(path);
35409 if (settings.markSymbolicLink) {
35410 stat.isSymbolicLink = () => true;
35415 if (!settings.throwErrorOnBrokenSymbolicLink) {
35423 sync$7.read = read$2;
35425 var settings$3 = {};
35429 (function (exports) {
35431 Object.defineProperty(exports, "__esModule", {
35434 exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
35435 const fs = require$$0__default["default"];
35436 exports.FILE_SYSTEM_ADAPTER = {
35439 lstatSync: fs.lstatSync,
35440 statSync: fs.statSync
35443 function createFileSystemAdapter(fsMethods) {
35444 if (fsMethods === undefined) {
35445 return exports.FILE_SYSTEM_ADAPTER;
35448 return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
35451 exports.createFileSystemAdapter = createFileSystemAdapter;
35454 Object.defineProperty(settings$3, "__esModule", {
35460 constructor(_options = {}) {
35461 this._options = _options;
35462 this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
35463 this.fs = fs$8.createFileSystemAdapter(this._options.fs);
35464 this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
35465 this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
35468 _getValue(option, value) {
35469 return option !== null && option !== void 0 ? option : value;
35474 settings$3.default = Settings$2;
35476 Object.defineProperty(out$3, "__esModule", {
35479 out$3.statSync = out$3.stat = out$3.Settings = void 0;
35480 const async$4 = async$5;
35481 const sync$6 = sync$7;
35482 const settings_1$3 = settings$3;
35483 out$3.Settings = settings_1$3.default;
35485 function stat(path, optionsOrSettingsOrCallback, callback) {
35486 if (typeof optionsOrSettingsOrCallback === 'function') {
35487 async$4.read(path, getSettings$2(), optionsOrSettingsOrCallback);
35491 async$4.read(path, getSettings$2(optionsOrSettingsOrCallback), callback);
35496 function statSync(path, optionsOrSettings) {
35497 const settings = getSettings$2(optionsOrSettings);
35498 return sync$6.read(path, settings);
35501 out$3.statSync = statSync;
35503 function getSettings$2(settingsOrOptions = {}) {
35504 if (settingsOrOptions instanceof settings_1$3.default) {
35505 return settingsOrOptions;
35508 return new settings_1$3.default(settingsOrOptions);
35521 /*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
35523 var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask.bind(typeof window !== 'undefined' ? window : global) // reuse resolved promise, and allocate it lazily
35524 : cb => (promise || (promise = Promise.resolve())).then(cb).catch(err => setTimeout(() => {
35528 /*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
35529 var runParallel_1 = runParallel;
35530 const queueMicrotask$1 = queueMicrotask_1;
35532 function runParallel(tasks, cb) {
35533 let results, pending, keys;
35536 if (Array.isArray(tasks)) {
35538 pending = tasks.length;
35540 keys = Object.keys(tasks);
35542 pending = keys.length;
35545 function done(err) {
35547 if (cb) cb(err, results);
35551 if (isSync) queueMicrotask$1(end);else end();
35554 function each(i, err, result) {
35555 results[i] = result;
35557 if (--pending === 0 || err) {
35567 keys.forEach(function (key) {
35568 tasks[key](function (err, result) {
35569 each(key, err, result);
35574 tasks.forEach(function (task, i) {
35575 task(function (err, result) {
35576 each(i, err, result);
35584 var constants = {};
35586 Object.defineProperty(constants, "__esModule", {
35589 constants.IS_SUPPORT_READDIR_WITH_FILE_TYPES = void 0;
35590 const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.');
35592 if (NODE_PROCESS_VERSION_PARTS[0] === undefined || NODE_PROCESS_VERSION_PARTS[1] === undefined) {
35593 throw new Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);
35596 const MAJOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[0], 10);
35597 const MINOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[1], 10);
35598 const SUPPORTED_MAJOR_VERSION = 10;
35599 const SUPPORTED_MINOR_VERSION = 10;
35600 const IS_MATCHED_BY_MAJOR = MAJOR_VERSION > SUPPORTED_MAJOR_VERSION;
35601 const IS_MATCHED_BY_MAJOR_AND_MINOR = MAJOR_VERSION === SUPPORTED_MAJOR_VERSION && MINOR_VERSION >= SUPPORTED_MINOR_VERSION;
35603 * IS `true` for Node.js 10.10 and greater.
35606 constants.IS_SUPPORT_READDIR_WITH_FILE_TYPES = IS_MATCHED_BY_MAJOR || IS_MATCHED_BY_MAJOR_AND_MINOR;
35612 Object.defineProperty(fs$7, "__esModule", {
35615 fs$7.createDirentFromStats = void 0;
35617 class DirentFromStats {
35618 constructor(name, stats) {
35620 this.isBlockDevice = stats.isBlockDevice.bind(stats);
35621 this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
35622 this.isDirectory = stats.isDirectory.bind(stats);
35623 this.isFIFO = stats.isFIFO.bind(stats);
35624 this.isFile = stats.isFile.bind(stats);
35625 this.isSocket = stats.isSocket.bind(stats);
35626 this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
35631 function createDirentFromStats(name, stats) {
35632 return new DirentFromStats(name, stats);
35635 fs$7.createDirentFromStats = createDirentFromStats;
35637 Object.defineProperty(utils$g, "__esModule", {
35640 utils$g.fs = void 0;
35646 Object.defineProperty(common$6, "__esModule", {
35649 common$6.joinPathSegments = void 0;
35651 function joinPathSegments$1(a, b, separator) {
35653 * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
35655 if (a.endsWith(separator)) {
35659 return a + separator + b;
35662 common$6.joinPathSegments = joinPathSegments$1;
35664 Object.defineProperty(async$1, "__esModule", {
35667 async$1.readdir = async$1.readdirWithFileTypes = async$1.read = void 0;
35668 const fsStat$5 = out$3;
35669 const rpl = runParallel_1;
35670 const constants_1$1 = constants;
35671 const utils$f = utils$g;
35672 const common$5 = common$6;
35674 function read$1(directory, settings, callback) {
35675 if (!settings.stats && constants_1$1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
35676 readdirWithFileTypes$1(directory, settings, callback);
35680 readdir$1(directory, settings, callback);
35683 async$1.read = read$1;
35685 function readdirWithFileTypes$1(directory, settings, callback) {
35686 settings.fs.readdir(directory, {
35687 withFileTypes: true
35688 }, (readdirError, dirents) => {
35689 if (readdirError !== null) {
35690 callFailureCallback$1(callback, readdirError);
35694 const entries = dirents.map(dirent => ({
35697 path: common$5.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
35700 if (!settings.followSymbolicLinks) {
35701 callSuccessCallback$1(callback, entries);
35705 const tasks = entries.map(entry => makeRplTaskEntry(entry, settings));
35706 rpl(tasks, (rplError, rplEntries) => {
35707 if (rplError !== null) {
35708 callFailureCallback$1(callback, rplError);
35712 callSuccessCallback$1(callback, rplEntries);
35717 async$1.readdirWithFileTypes = readdirWithFileTypes$1;
35719 function makeRplTaskEntry(entry, settings) {
35721 if (!entry.dirent.isSymbolicLink()) {
35726 settings.fs.stat(entry.path, (statError, stats) => {
35727 if (statError !== null) {
35728 if (settings.throwErrorOnBrokenSymbolicLink) {
35737 entry.dirent = utils$f.fs.createDirentFromStats(entry.name, stats);
35743 function readdir$1(directory, settings, callback) {
35744 settings.fs.readdir(directory, (readdirError, names) => {
35745 if (readdirError !== null) {
35746 callFailureCallback$1(callback, readdirError);
35750 const tasks = names.map(name => {
35751 const path = common$5.joinPathSegments(directory, name, settings.pathSegmentSeparator);
35753 fsStat$5.stat(path, settings.fsStatSettings, (error, stats) => {
35754 if (error !== null) {
35762 dirent: utils$f.fs.createDirentFromStats(name, stats)
35765 if (settings.stats) {
35766 entry.stats = stats;
35773 rpl(tasks, (rplError, entries) => {
35774 if (rplError !== null) {
35775 callFailureCallback$1(callback, rplError);
35779 callSuccessCallback$1(callback, entries);
35784 async$1.readdir = readdir$1;
35786 function callFailureCallback$1(callback, error) {
35790 function callSuccessCallback$1(callback, result) {
35791 callback(null, result);
35796 Object.defineProperty(sync$5, "__esModule", {
35799 sync$5.readdir = sync$5.readdirWithFileTypes = sync$5.read = void 0;
35800 const fsStat$4 = out$3;
35801 const constants_1 = constants;
35802 const utils$e = utils$g;
35803 const common$4 = common$6;
35805 function read(directory, settings) {
35806 if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
35807 return readdirWithFileTypes(directory, settings);
35810 return readdir(directory, settings);
35813 sync$5.read = read;
35815 function readdirWithFileTypes(directory, settings) {
35816 const dirents = settings.fs.readdirSync(directory, {
35817 withFileTypes: true
35819 return dirents.map(dirent => {
35823 path: common$4.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
35826 if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) {
35828 const stats = settings.fs.statSync(entry.path);
35829 entry.dirent = utils$e.fs.createDirentFromStats(entry.name, stats);
35831 if (settings.throwErrorOnBrokenSymbolicLink) {
35841 sync$5.readdirWithFileTypes = readdirWithFileTypes;
35843 function readdir(directory, settings) {
35844 const names = settings.fs.readdirSync(directory);
35845 return names.map(name => {
35846 const entryPath = common$4.joinPathSegments(directory, name, settings.pathSegmentSeparator);
35847 const stats = fsStat$4.statSync(entryPath, settings.fsStatSettings);
35851 dirent: utils$e.fs.createDirentFromStats(name, stats)
35854 if (settings.stats) {
35855 entry.stats = stats;
35862 sync$5.readdir = readdir;
35864 var settings$2 = {};
35868 (function (exports) {
35870 Object.defineProperty(exports, "__esModule", {
35873 exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
35874 const fs = require$$0__default["default"];
35875 exports.FILE_SYSTEM_ADAPTER = {
35878 lstatSync: fs.lstatSync,
35879 statSync: fs.statSync,
35880 readdir: fs.readdir,
35881 readdirSync: fs.readdirSync
35884 function createFileSystemAdapter(fsMethods) {
35885 if (fsMethods === undefined) {
35886 return exports.FILE_SYSTEM_ADAPTER;
35889 return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
35892 exports.createFileSystemAdapter = createFileSystemAdapter;
35895 Object.defineProperty(settings$2, "__esModule", {
35898 const path$6 = require$$0__default$2["default"];
35899 const fsStat$3 = out$3;
35903 constructor(_options = {}) {
35904 this._options = _options;
35905 this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
35906 this.fs = fs$4.createFileSystemAdapter(this._options.fs);
35907 this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$6.sep);
35908 this.stats = this._getValue(this._options.stats, false);
35909 this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
35910 this.fsStatSettings = new fsStat$3.Settings({
35911 followSymbolicLink: this.followSymbolicLinks,
35913 throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink
35917 _getValue(option, value) {
35918 return option !== null && option !== void 0 ? option : value;
35923 settings$2.default = Settings$1;
35925 Object.defineProperty(out$1, "__esModule", {
35928 out$1.Settings = out$1.scandirSync = out$1.scandir = void 0;
35929 const async = async$1;
35930 const sync$4 = sync$5;
35931 const settings_1$2 = settings$2;
35932 out$1.Settings = settings_1$2.default;
35934 function scandir(path, optionsOrSettingsOrCallback, callback) {
35935 if (typeof optionsOrSettingsOrCallback === 'function') {
35936 async.read(path, getSettings$1(), optionsOrSettingsOrCallback);
35940 async.read(path, getSettings$1(optionsOrSettingsOrCallback), callback);
35943 out$1.scandir = scandir;
35945 function scandirSync(path, optionsOrSettings) {
35946 const settings = getSettings$1(optionsOrSettings);
35947 return sync$4.read(path, settings);
35950 out$1.scandirSync = scandirSync;
35952 function getSettings$1(settingsOrOptions = {}) {
35953 if (settingsOrOptions instanceof settings_1$2.default) {
35954 return settingsOrOptions;
35957 return new settings_1$2.default(settingsOrOptions);
35960 var queue = {exports: {}};
35962 function reusify$1(Constructor) {
35963 var head = new Constructor();
35967 var current = head;
35969 if (current.next) {
35970 head = current.next;
35972 head = new Constructor();
35976 current.next = null;
35980 function release(obj) {
35991 var reusify_1 = reusify$1;
35993 /* eslint-disable no-var */
35996 var reusify = reusify_1;
35998 function fastqueue(context, worker, concurrency) {
35999 if (typeof context === 'function') {
36000 concurrency = worker;
36005 if (concurrency < 1) {
36006 throw new Error('fastqueue concurrency must be greater than 1');
36009 var cache = reusify(Task);
36010 var queueHead = null;
36011 var queueTail = null;
36013 var errorHandler = null;
36020 concurrency: concurrency,
36025 getQueue: getQueue,
36029 killAndDrain: killAndDrain,
36034 function running() {
36039 self.paused = true;
36042 function length() {
36043 var current = queueHead;
36047 current = current.next;
36054 function getQueue() {
36055 var current = queueHead;
36059 tasks.push(current.value);
36060 current = current.next;
36066 function resume() {
36067 if (!self.paused) return;
36068 self.paused = false;
36070 for (var i = 0; i < self.concurrency; i++) {
36077 return _running === 0 && self.length() === 0;
36080 function push(value, done) {
36081 var current = cache.get();
36082 current.context = context;
36083 current.release = release;
36084 current.value = value;
36085 current.callback = done || noop;
36086 current.errorHandler = errorHandler;
36088 if (_running === self.concurrency || self.paused) {
36090 queueTail.next = current;
36091 queueTail = current;
36093 queueHead = current;
36094 queueTail = current;
36099 worker.call(context, current.value, current.worked);
36103 function unshift(value, done) {
36104 var current = cache.get();
36105 current.context = context;
36106 current.release = release;
36107 current.value = value;
36108 current.callback = done || noop;
36110 if (_running === self.concurrency || self.paused) {
36112 current.next = queueHead;
36113 queueHead = current;
36115 queueHead = current;
36116 queueTail = current;
36121 worker.call(context, current.value, current.worked);
36125 function release(holder) {
36127 cache.release(holder);
36130 var next = queueHead;
36133 if (!self.paused) {
36134 if (queueTail === queueHead) {
36138 queueHead = next.next;
36140 worker.call(context, next.value, next.worked);
36142 if (queueTail === null) {
36148 } else if (--_running === 0) {
36159 function killAndDrain() {
36166 function error(handler) {
36167 errorHandler = handler;
36175 this.callback = noop;
36177 this.release = noop;
36178 this.context = null;
36179 this.errorHandler = null;
36182 this.worked = function worked(err, result) {
36183 var callback = self.callback;
36184 var errorHandler = self.errorHandler;
36185 var val = self.value;
36187 self.callback = noop;
36189 if (self.errorHandler) {
36190 errorHandler(err, val);
36193 callback.call(self.context, err, result);
36194 self.release(self);
36198 function queueAsPromised(context, worker, concurrency) {
36199 if (typeof context === 'function') {
36200 concurrency = worker;
36205 function asyncWrapper(arg, cb) {
36206 worker.call(this, arg).then(function (res) {
36211 var queue = fastqueue(context, asyncWrapper, concurrency);
36212 var pushCb = queue.push;
36213 var unshiftCb = queue.unshift;
36215 queue.unshift = unshift;
36216 queue.drained = drained;
36219 function push(value) {
36220 var p = new Promise(function (resolve, reject) {
36221 pushCb(value, function (err, result) {
36229 }); // Let's fork the promise chain to
36230 // make the error bubble up to the user but
36231 // not lead to a unhandledRejection
36237 function unshift(value) {
36238 var p = new Promise(function (resolve, reject) {
36239 unshiftCb(value, function (err, result) {
36247 }); // Let's fork the promise chain to
36248 // make the error bubble up to the user but
36249 // not lead to a unhandledRejection
36255 function drained() {
36256 var previousDrain = queue.drain;
36257 var p = new Promise(function (resolve) {
36258 queue.drain = function () {
36267 queue.exports = fastqueue;
36268 queue.exports.promise = queueAsPromised;
36272 Object.defineProperty(common$3, "__esModule", {
36275 common$3.joinPathSegments = common$3.replacePathSegmentSeparator = common$3.isAppliedFilter = common$3.isFatalError = void 0;
36277 function isFatalError(settings, error) {
36278 if (settings.errorFilter === null) {
36282 return !settings.errorFilter(error);
36285 common$3.isFatalError = isFatalError;
36287 function isAppliedFilter(filter, value) {
36288 return filter === null || filter(value);
36291 common$3.isAppliedFilter = isAppliedFilter;
36293 function replacePathSegmentSeparator(filepath, separator) {
36294 return filepath.split(/[/\\]/).join(separator);
36297 common$3.replacePathSegmentSeparator = replacePathSegmentSeparator;
36299 function joinPathSegments(a, b, separator) {
36304 * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
36308 if (a.endsWith(separator)) {
36312 return a + separator + b;
36315 common$3.joinPathSegments = joinPathSegments;
36319 Object.defineProperty(reader$1, "__esModule", {
36322 const common$2 = common$3;
36325 constructor(_root, _settings) {
36326 this._root = _root;
36327 this._settings = _settings;
36328 this._root = common$2.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator);
36333 reader$1.default = Reader$1;
36335 Object.defineProperty(async$2, "__esModule", {
36338 const events_1 = require$$0__default$6["default"];
36339 const fsScandir$2 = out$1;
36340 const fastq = queue.exports;
36341 const common$1 = common$3;
36342 const reader_1$3 = reader$1;
36344 class AsyncReader extends reader_1$3.default {
36345 constructor(_root, _settings) {
36346 super(_root, _settings);
36347 this._settings = _settings;
36348 this._scandir = fsScandir$2.scandir;
36349 this._emitter = new events_1.EventEmitter();
36350 this._queue = fastq(this._worker.bind(this), this._settings.concurrency);
36351 this._isFatalError = false;
36352 this._isDestroyed = false;
36354 this._queue.drain = () => {
36355 if (!this._isFatalError) {
36356 this._emitter.emit('end');
36362 this._isFatalError = false;
36363 this._isDestroyed = false;
36364 setImmediate(() => {
36365 this._pushToQueue(this._root, this._settings.basePath);
36367 return this._emitter;
36370 get isDestroyed() {
36371 return this._isDestroyed;
36375 if (this._isDestroyed) {
36376 throw new Error('The reader is already destroyed');
36379 this._isDestroyed = true;
36381 this._queue.killAndDrain();
36384 onEntry(callback) {
36385 this._emitter.on('entry', callback);
36388 onError(callback) {
36389 this._emitter.once('error', callback);
36393 this._emitter.once('end', callback);
36396 _pushToQueue(directory, base) {
36397 const queueItem = {
36402 this._queue.push(queueItem, error => {
36403 if (error !== null) {
36404 this._handleError(error);
36409 _worker(item, done) {
36410 this._scandir(item.directory, this._settings.fsScandirSettings, (error, entries) => {
36411 if (error !== null) {
36412 done(error, undefined);
36416 for (const entry of entries) {
36417 this._handleEntry(entry, item.base);
36420 done(null, undefined);
36424 _handleError(error) {
36425 if (this._isDestroyed || !common$1.isFatalError(this._settings, error)) {
36429 this._isFatalError = true;
36430 this._isDestroyed = true;
36432 this._emitter.emit('error', error);
36435 _handleEntry(entry, base) {
36436 if (this._isDestroyed || this._isFatalError) {
36440 const fullpath = entry.path;
36442 if (base !== undefined) {
36443 entry.path = common$1.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
36446 if (common$1.isAppliedFilter(this._settings.entryFilter, entry)) {
36447 this._emitEntry(entry);
36450 if (entry.dirent.isDirectory() && common$1.isAppliedFilter(this._settings.deepFilter, entry)) {
36451 this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
36455 _emitEntry(entry) {
36456 this._emitter.emit('entry', entry);
36461 async$2.default = AsyncReader;
36463 Object.defineProperty(async$3, "__esModule", {
36466 const async_1$3 = async$2;
36468 class AsyncProvider {
36469 constructor(_root, _settings) {
36470 this._root = _root;
36471 this._settings = _settings;
36472 this._reader = new async_1$3.default(this._root, this._settings);
36473 this._storage = [];
36477 this._reader.onError(error => {
36478 callFailureCallback(callback, error);
36481 this._reader.onEntry(entry => {
36482 this._storage.push(entry);
36485 this._reader.onEnd(() => {
36486 callSuccessCallback(callback, this._storage);
36489 this._reader.read();
36494 async$3.default = AsyncProvider;
36496 function callFailureCallback(callback, error) {
36500 function callSuccessCallback(callback, entries) {
36501 callback(null, entries);
36506 Object.defineProperty(stream$1, "__esModule", {
36509 const stream_1$5 = require$$0__default$5["default"];
36510 const async_1$2 = async$2;
36512 class StreamProvider {
36513 constructor(_root, _settings) {
36514 this._root = _root;
36515 this._settings = _settings;
36516 this._reader = new async_1$2.default(this._root, this._settings);
36517 this._stream = new stream_1$5.Readable({
36521 if (!this._reader.isDestroyed) {
36522 this._reader.destroy();
36529 this._reader.onError(error => {
36530 this._stream.emit('error', error);
36533 this._reader.onEntry(entry => {
36534 this._stream.push(entry);
36537 this._reader.onEnd(() => {
36538 this._stream.push(null);
36541 this._reader.read();
36543 return this._stream;
36548 stream$1.default = StreamProvider;
36554 Object.defineProperty(sync$2, "__esModule", {
36557 const fsScandir$1 = out$1;
36558 const common = common$3;
36559 const reader_1$2 = reader$1;
36561 class SyncReader extends reader_1$2.default {
36563 super(...arguments);
36564 this._scandir = fsScandir$1.scandirSync;
36565 this._storage = [];
36566 this._queue = new Set();
36570 this._pushToQueue(this._root, this._settings.basePath);
36572 this._handleQueue();
36574 return this._storage;
36577 _pushToQueue(directory, base) {
36585 for (const item of this._queue.values()) {
36586 this._handleDirectory(item.directory, item.base);
36590 _handleDirectory(directory, base) {
36592 const entries = this._scandir(directory, this._settings.fsScandirSettings);
36594 for (const entry of entries) {
36595 this._handleEntry(entry, base);
36598 this._handleError(error);
36602 _handleError(error) {
36603 if (!common.isFatalError(this._settings, error)) {
36610 _handleEntry(entry, base) {
36611 const fullpath = entry.path;
36613 if (base !== undefined) {
36614 entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
36617 if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
36618 this._pushToStorage(entry);
36621 if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
36622 this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
36626 _pushToStorage(entry) {
36627 this._storage.push(entry);
36632 sync$2.default = SyncReader;
36634 Object.defineProperty(sync$3, "__esModule", {
36637 const sync_1$3 = sync$2;
36639 class SyncProvider {
36640 constructor(_root, _settings) {
36641 this._root = _root;
36642 this._settings = _settings;
36643 this._reader = new sync_1$3.default(this._root, this._settings);
36647 return this._reader.read();
36652 sync$3.default = SyncProvider;
36654 var settings$1 = {};
36656 Object.defineProperty(settings$1, "__esModule", {
36659 const path$5 = require$$0__default$2["default"];
36660 const fsScandir = out$1;
36663 constructor(_options = {}) {
36664 this._options = _options;
36665 this.basePath = this._getValue(this._options.basePath, undefined);
36666 this.concurrency = this._getValue(this._options.concurrency, Number.POSITIVE_INFINITY);
36667 this.deepFilter = this._getValue(this._options.deepFilter, null);
36668 this.entryFilter = this._getValue(this._options.entryFilter, null);
36669 this.errorFilter = this._getValue(this._options.errorFilter, null);
36670 this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$5.sep);
36671 this.fsScandirSettings = new fsScandir.Settings({
36672 followSymbolicLinks: this._options.followSymbolicLinks,
36673 fs: this._options.fs,
36674 pathSegmentSeparator: this._options.pathSegmentSeparator,
36675 stats: this._options.stats,
36676 throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink
36680 _getValue(option, value) {
36681 return option !== null && option !== void 0 ? option : value;
36686 settings$1.default = Settings;
36688 Object.defineProperty(out$2, "__esModule", {
36691 out$2.Settings = out$2.walkStream = out$2.walkSync = out$2.walk = void 0;
36692 const async_1$1 = async$3;
36693 const stream_1$4 = stream$1;
36694 const sync_1$2 = sync$3;
36695 const settings_1$1 = settings$1;
36696 out$2.Settings = settings_1$1.default;
36698 function walk(directory, optionsOrSettingsOrCallback, callback) {
36699 if (typeof optionsOrSettingsOrCallback === 'function') {
36700 new async_1$1.default(directory, getSettings()).read(optionsOrSettingsOrCallback);
36704 new async_1$1.default(directory, getSettings(optionsOrSettingsOrCallback)).read(callback);
36709 function walkSync(directory, optionsOrSettings) {
36710 const settings = getSettings(optionsOrSettings);
36711 const provider = new sync_1$2.default(directory, settings);
36712 return provider.read();
36715 out$2.walkSync = walkSync;
36717 function walkStream(directory, optionsOrSettings) {
36718 const settings = getSettings(optionsOrSettings);
36719 const provider = new stream_1$4.default(directory, settings);
36720 return provider.read();
36723 out$2.walkStream = walkStream;
36725 function getSettings(settingsOrOptions = {}) {
36726 if (settingsOrOptions instanceof settings_1$1.default) {
36727 return settingsOrOptions;
36730 return new settings_1$1.default(settingsOrOptions);
36735 Object.defineProperty(reader, "__esModule", {
36738 const path$4 = require$$0__default$2["default"];
36739 const fsStat$2 = out$3;
36740 const utils$d = utils$r;
36743 constructor(_settings) {
36744 this._settings = _settings;
36745 this._fsStatSettings = new fsStat$2.Settings({
36746 followSymbolicLink: this._settings.followSymbolicLinks,
36747 fs: this._settings.fs,
36748 throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks
36752 _getFullEntryPath(filepath) {
36753 return path$4.resolve(this._settings.cwd, filepath);
36756 _makeEntry(stats, pattern) {
36760 dirent: utils$d.fs.createDirentFromStats(pattern, stats)
36763 if (this._settings.stats) {
36764 entry.stats = stats;
36770 _isFatalError(error) {
36771 return !utils$d.errno.isEnoentCodeError(error) && !this._settings.suppressErrors;
36776 reader.default = Reader;
36778 Object.defineProperty(stream$2, "__esModule", {
36781 const stream_1$3 = require$$0__default$5["default"];
36782 const fsStat$1 = out$3;
36783 const fsWalk$1 = out$2;
36784 const reader_1$1 = reader;
36786 class ReaderStream extends reader_1$1.default {
36788 super(...arguments);
36789 this._walkStream = fsWalk$1.walkStream;
36790 this._stat = fsStat$1.stat;
36793 dynamic(root, options) {
36794 return this._walkStream(root, options);
36797 static(patterns, options) {
36798 const filepaths = patterns.map(this._getFullEntryPath, this);
36799 const stream = new stream_1$3.PassThrough({
36803 stream._write = (index, _enc, done) => {
36804 return this._getEntry(filepaths[index], patterns[index], options).then(entry => {
36805 if (entry !== null && options.entryFilter(entry)) {
36806 stream.push(entry);
36809 if (index === filepaths.length - 1) {
36817 for (let i = 0; i < filepaths.length; i++) {
36824 _getEntry(filepath, pattern, options) {
36825 return this._getStat(filepath).then(stats => this._makeEntry(stats, pattern)).catch(error => {
36826 if (options.errorFilter(error)) {
36834 _getStat(filepath) {
36835 return new Promise((resolve, reject) => {
36836 this._stat(filepath, this._fsStatSettings, (error, stats) => {
36837 return error === null ? resolve(stats) : reject(error);
36844 stream$2.default = ReaderStream;
36854 Object.defineProperty(matcher, "__esModule", {
36857 const utils$c = utils$r;
36860 constructor(_patterns, _settings, _micromatchOptions) {
36861 this._patterns = _patterns;
36862 this._settings = _settings;
36863 this._micromatchOptions = _micromatchOptions;
36864 this._storage = [];
36866 this._fillStorage();
36871 * The original pattern may include `{,*,**,a/*}`, which will lead to problems with matching (unresolved level).
36872 * So, before expand patterns with brace expansion into separated patterns.
36874 const patterns = utils$c.pattern.expandPatternsWithBraceExpansion(this._patterns);
36876 for (const pattern of patterns) {
36877 const segments = this._getPatternSegments(pattern);
36879 const sections = this._splitSegmentsIntoSections(segments);
36881 this._storage.push({
36882 complete: sections.length <= 1,
36890 _getPatternSegments(pattern) {
36891 const parts = utils$c.pattern.getPatternParts(pattern, this._micromatchOptions);
36892 return parts.map(part => {
36893 const dynamic = utils$c.pattern.isDynamicPattern(part, this._settings);
36905 patternRe: utils$c.pattern.makeRe(part, this._micromatchOptions)
36910 _splitSegmentsIntoSections(segments) {
36911 return utils$c.array.splitWhen(segments, segment => segment.dynamic && utils$c.pattern.hasGlobStar(segment.pattern));
36916 matcher.default = Matcher;
36918 Object.defineProperty(partial, "__esModule", {
36921 const matcher_1 = matcher;
36923 class PartialMatcher extends matcher_1.default {
36925 const parts = filepath.split('/');
36926 const levels = parts.length;
36928 const patterns = this._storage.filter(info => !info.complete || info.segments.length > levels);
36930 for (const pattern of patterns) {
36931 const section = pattern.sections[0];
36933 * In this case, the pattern has a globstar and we must read all directories unconditionally,
36934 * but only if the level has reached the end of the first group.
36936 * fixtures/{a,b}/**
36937 * ^ true/false ^ always true
36940 if (!pattern.complete && levels > section.length) {
36944 const match = parts.every((part, index) => {
36945 const segment = pattern.segments[index];
36947 if (segment.dynamic && segment.patternRe.test(part)) {
36951 if (!segment.dynamic && segment.pattern === part) {
36968 partial.default = PartialMatcher;
36970 Object.defineProperty(deep, "__esModule", {
36973 const utils$b = utils$r;
36974 const partial_1 = partial;
36977 constructor(_settings, _micromatchOptions) {
36978 this._settings = _settings;
36979 this._micromatchOptions = _micromatchOptions;
36982 getFilter(basePath, positive, negative) {
36983 const matcher = this._getMatcher(positive);
36985 const negativeRe = this._getNegativePatternsRe(negative);
36987 return entry => this._filter(basePath, entry, matcher, negativeRe);
36990 _getMatcher(patterns) {
36991 return new partial_1.default(patterns, this._settings, this._micromatchOptions);
36994 _getNegativePatternsRe(patterns) {
36995 const affectDepthOfReadingPatterns = patterns.filter(utils$b.pattern.isAffectDepthOfReadingPattern);
36996 return utils$b.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions);
36999 _filter(basePath, entry, matcher, negativeRe) {
37000 if (this._isSkippedByDeep(basePath, entry.path)) {
37004 if (this._isSkippedSymbolicLink(entry)) {
37008 const filepath = utils$b.path.removeLeadingDotSegment(entry.path);
37010 if (this._isSkippedByPositivePatterns(filepath, matcher)) {
37014 return this._isSkippedByNegativePatterns(filepath, negativeRe);
37017 _isSkippedByDeep(basePath, entryPath) {
37019 * Avoid unnecessary depth calculations when it doesn't matter.
37021 if (this._settings.deep === Infinity) {
37025 return this._getEntryLevel(basePath, entryPath) >= this._settings.deep;
37028 _getEntryLevel(basePath, entryPath) {
37029 const entryPathDepth = entryPath.split('/').length;
37031 if (basePath === '') {
37032 return entryPathDepth;
37035 const basePathDepth = basePath.split('/').length;
37036 return entryPathDepth - basePathDepth;
37039 _isSkippedSymbolicLink(entry) {
37040 return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink();
37043 _isSkippedByPositivePatterns(entryPath, matcher) {
37044 return !this._settings.baseNameMatch && !matcher.match(entryPath);
37047 _isSkippedByNegativePatterns(entryPath, patternsRe) {
37048 return !utils$b.pattern.matchAny(entryPath, patternsRe);
37053 deep.default = DeepFilter;
37057 Object.defineProperty(entry$1, "__esModule", {
37060 const utils$a = utils$r;
37062 class EntryFilter {
37063 constructor(_settings, _micromatchOptions) {
37064 this._settings = _settings;
37065 this._micromatchOptions = _micromatchOptions;
37066 this.index = new Map();
37069 getFilter(positive, negative) {
37070 const positiveRe = utils$a.pattern.convertPatternsToRe(positive, this._micromatchOptions);
37071 const negativeRe = utils$a.pattern.convertPatternsToRe(negative, this._micromatchOptions);
37072 return entry => this._filter(entry, positiveRe, negativeRe);
37075 _filter(entry, positiveRe, negativeRe) {
37076 if (this._settings.unique && this._isDuplicateEntry(entry)) {
37080 if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) {
37084 if (this._isSkippedByAbsoluteNegativePatterns(entry.path, negativeRe)) {
37088 const filepath = this._settings.baseNameMatch ? entry.name : entry.path;
37089 const isMatched = this._isMatchToPatterns(filepath, positiveRe) && !this._isMatchToPatterns(entry.path, negativeRe);
37091 if (this._settings.unique && isMatched) {
37092 this._createIndexRecord(entry);
37098 _isDuplicateEntry(entry) {
37099 return this.index.has(entry.path);
37102 _createIndexRecord(entry) {
37103 this.index.set(entry.path, undefined);
37106 _onlyFileFilter(entry) {
37107 return this._settings.onlyFiles && !entry.dirent.isFile();
37110 _onlyDirectoryFilter(entry) {
37111 return this._settings.onlyDirectories && !entry.dirent.isDirectory();
37114 _isSkippedByAbsoluteNegativePatterns(entryPath, patternsRe) {
37115 if (!this._settings.absolute) {
37119 const fullpath = utils$a.path.makeAbsolute(this._settings.cwd, entryPath);
37120 return utils$a.pattern.matchAny(fullpath, patternsRe);
37123 _isMatchToPatterns(entryPath, patternsRe) {
37124 const filepath = utils$a.path.removeLeadingDotSegment(entryPath);
37125 return utils$a.pattern.matchAny(filepath, patternsRe);
37130 entry$1.default = EntryFilter;
37134 Object.defineProperty(error$1, "__esModule", {
37137 const utils$9 = utils$r;
37139 class ErrorFilter {
37140 constructor(_settings) {
37141 this._settings = _settings;
37145 return error => this._isNonFatalError(error);
37148 _isNonFatalError(error) {
37149 return utils$9.errno.isEnoentCodeError(error) || this._settings.suppressErrors;
37154 error$1.default = ErrorFilter;
37158 Object.defineProperty(entry, "__esModule", {
37161 const utils$8 = utils$r;
37163 class EntryTransformer {
37164 constructor(_settings) {
37165 this._settings = _settings;
37169 return entry => this._transform(entry);
37172 _transform(entry) {
37173 let filepath = entry.path;
37175 if (this._settings.absolute) {
37176 filepath = utils$8.path.makeAbsolute(this._settings.cwd, filepath);
37177 filepath = utils$8.path.unixify(filepath);
37180 if (this._settings.markDirectories && entry.dirent.isDirectory()) {
37184 if (!this._settings.objectMode) {
37188 return Object.assign(Object.assign({}, entry), {
37195 entry.default = EntryTransformer;
37197 Object.defineProperty(provider, "__esModule", {
37200 const path$3 = require$$0__default$2["default"];
37201 const deep_1 = deep;
37202 const entry_1 = entry$1;
37203 const error_1 = error$1;
37204 const entry_2 = entry;
37207 constructor(_settings) {
37208 this._settings = _settings;
37209 this.errorFilter = new error_1.default(this._settings);
37210 this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions());
37211 this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions());
37212 this.entryTransformer = new entry_2.default(this._settings);
37215 _getRootDirectory(task) {
37216 return path$3.resolve(this._settings.cwd, task.base);
37219 _getReaderOptions(task) {
37220 const basePath = task.base === '.' ? '' : task.base;
37223 pathSegmentSeparator: '/',
37224 concurrency: this._settings.concurrency,
37225 deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative),
37226 entryFilter: this.entryFilter.getFilter(task.positive, task.negative),
37227 errorFilter: this.errorFilter.getFilter(),
37228 followSymbolicLinks: this._settings.followSymbolicLinks,
37229 fs: this._settings.fs,
37230 stats: this._settings.stats,
37231 throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink,
37232 transform: this.entryTransformer.getTransformer()
37236 _getMicromatchOptions() {
37238 dot: this._settings.dot,
37239 matchBase: this._settings.baseNameMatch,
37240 nobrace: !this._settings.braceExpansion,
37241 nocase: !this._settings.caseSensitiveMatch,
37242 noext: !this._settings.extglob,
37243 noglobstar: !this._settings.globstar,
37245 strictSlashes: false
37251 provider.default = Provider;
37253 Object.defineProperty(async$6, "__esModule", {
37256 const stream_1$2 = stream$2;
37257 const provider_1$2 = provider;
37259 class ProviderAsync extends provider_1$2.default {
37261 super(...arguments);
37262 this._reader = new stream_1$2.default(this._settings);
37266 const root = this._getRootDirectory(task);
37268 const options = this._getReaderOptions(task);
37270 const entries = [];
37271 return new Promise((resolve, reject) => {
37272 const stream = this.api(root, task, options);
37273 stream.once('error', reject);
37274 stream.on('data', entry => entries.push(options.transform(entry)));
37275 stream.once('end', () => resolve(entries));
37279 api(root, task, options) {
37280 if (task.dynamic) {
37281 return this._reader.dynamic(root, options);
37284 return this._reader.static(task.patterns, options);
37289 async$6.default = ProviderAsync;
37293 Object.defineProperty(stream, "__esModule", {
37296 const stream_1$1 = require$$0__default$5["default"];
37297 const stream_2 = stream$2;
37298 const provider_1$1 = provider;
37300 class ProviderStream extends provider_1$1.default {
37302 super(...arguments);
37303 this._reader = new stream_2.default(this._settings);
37307 const root = this._getRootDirectory(task);
37309 const options = this._getReaderOptions(task);
37311 const source = this.api(root, task, options);
37312 const destination = new stream_1$1.Readable({
37316 source.once('error', error => destination.emit('error', error)).on('data', entry => destination.emit('data', options.transform(entry))).once('end', () => destination.emit('end'));
37317 destination.once('close', () => source.destroy());
37318 return destination;
37321 api(root, task, options) {
37322 if (task.dynamic) {
37323 return this._reader.dynamic(root, options);
37326 return this._reader.static(task.patterns, options);
37331 stream.default = ProviderStream;
37337 Object.defineProperty(sync, "__esModule", {
37340 const fsStat = out$3;
37341 const fsWalk = out$2;
37342 const reader_1 = reader;
37344 class ReaderSync extends reader_1.default {
37346 super(...arguments);
37347 this._walkSync = fsWalk.walkSync;
37348 this._statSync = fsStat.statSync;
37351 dynamic(root, options) {
37352 return this._walkSync(root, options);
37355 static(patterns, options) {
37356 const entries = [];
37358 for (const pattern of patterns) {
37359 const filepath = this._getFullEntryPath(pattern);
37361 const entry = this._getEntry(filepath, pattern, options);
37363 if (entry === null || !options.entryFilter(entry)) {
37367 entries.push(entry);
37373 _getEntry(filepath, pattern, options) {
37375 const stats = this._getStat(filepath);
37377 return this._makeEntry(stats, pattern);
37379 if (options.errorFilter(error)) {
37387 _getStat(filepath) {
37388 return this._statSync(filepath, this._fsStatSettings);
37393 sync.default = ReaderSync;
37395 Object.defineProperty(sync$1, "__esModule", {
37398 const sync_1$1 = sync;
37399 const provider_1 = provider;
37401 class ProviderSync extends provider_1.default {
37403 super(...arguments);
37404 this._reader = new sync_1$1.default(this._settings);
37408 const root = this._getRootDirectory(task);
37410 const options = this._getReaderOptions(task);
37412 const entries = this.api(root, task, options);
37413 return entries.map(options.transform);
37416 api(root, task, options) {
37417 if (task.dynamic) {
37418 return this._reader.dynamic(root, options);
37421 return this._reader.static(task.patterns, options);
37426 sync$1.default = ProviderSync;
37430 (function (exports) {
37432 Object.defineProperty(exports, "__esModule", {
37435 exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
37436 const fs = require$$0__default["default"];
37437 const os = require$$0__default$1["default"];
37439 * The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
37440 * https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
37443 const CPU_COUNT = Math.max(os.cpus().length, 1);
37444 exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
37446 lstatSync: fs.lstatSync,
37448 statSync: fs.statSync,
37449 readdir: fs.readdir,
37450 readdirSync: fs.readdirSync
37454 constructor(_options = {}) {
37455 this._options = _options;
37456 this.absolute = this._getValue(this._options.absolute, false);
37457 this.baseNameMatch = this._getValue(this._options.baseNameMatch, false);
37458 this.braceExpansion = this._getValue(this._options.braceExpansion, true);
37459 this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true);
37460 this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT);
37461 this.cwd = this._getValue(this._options.cwd, process.cwd());
37462 this.deep = this._getValue(this._options.deep, Infinity);
37463 this.dot = this._getValue(this._options.dot, false);
37464 this.extglob = this._getValue(this._options.extglob, true);
37465 this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true);
37466 this.fs = this._getFileSystemMethods(this._options.fs);
37467 this.globstar = this._getValue(this._options.globstar, true);
37468 this.ignore = this._getValue(this._options.ignore, []);
37469 this.markDirectories = this._getValue(this._options.markDirectories, false);
37470 this.objectMode = this._getValue(this._options.objectMode, false);
37471 this.onlyDirectories = this._getValue(this._options.onlyDirectories, false);
37472 this.onlyFiles = this._getValue(this._options.onlyFiles, true);
37473 this.stats = this._getValue(this._options.stats, false);
37474 this.suppressErrors = this._getValue(this._options.suppressErrors, false);
37475 this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
37476 this.unique = this._getValue(this._options.unique, true);
37478 if (this.onlyDirectories) {
37479 this.onlyFiles = false;
37483 this.objectMode = true;
37487 _getValue(option, value) {
37488 return option === undefined ? value : option;
37491 _getFileSystemMethods(methods = {}) {
37492 return Object.assign(Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER), methods);
37497 exports.default = Settings;
37500 const taskManager = tasks;
37501 const async_1 = async$6;
37502 const stream_1 = stream;
37503 const sync_1 = sync$1;
37504 const settings_1 = settings;
37505 const utils$7 = utils$r;
37507 async function FastGlob(source, options) {
37508 assertPatternsInput$1(source);
37509 const works = getWorks(source, async_1.default, options);
37510 const result = await Promise.all(works);
37511 return utils$7.array.flatten(result);
37512 } // https://github.com/typescript-eslint/typescript-eslint/issues/60
37513 // eslint-disable-next-line no-redeclare
37516 (function (FastGlob) {
37517 function sync(source, options) {
37518 assertPatternsInput$1(source);
37519 const works = getWorks(source, sync_1.default, options);
37520 return utils$7.array.flatten(works);
37523 FastGlob.sync = sync;
37525 function stream(source, options) {
37526 assertPatternsInput$1(source);
37527 const works = getWorks(source, stream_1.default, options);
37529 * The stream returned by the provider cannot work with an asynchronous iterator.
37530 * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
37531 * This affects performance (+25%). I don't see best solution right now.
37534 return utils$7.stream.merge(works);
37537 FastGlob.stream = stream;
37539 function generateTasks(source, options) {
37540 assertPatternsInput$1(source);
37541 const patterns = [].concat(source);
37542 const settings = new settings_1.default(options);
37543 return taskManager.generate(patterns, settings);
37546 FastGlob.generateTasks = generateTasks;
37548 function isDynamicPattern(source, options) {
37549 assertPatternsInput$1(source);
37550 const settings = new settings_1.default(options);
37551 return utils$7.pattern.isDynamicPattern(source, settings);
37554 FastGlob.isDynamicPattern = isDynamicPattern;
37556 function escapePath(source) {
37557 assertPatternsInput$1(source);
37558 return utils$7.path.escape(source);
37561 FastGlob.escapePath = escapePath;
37562 })(FastGlob || (FastGlob = {}));
37564 function getWorks(source, _Provider, options) {
37565 const patterns = [].concat(source);
37566 const settings = new settings_1.default(options);
37567 const tasks = taskManager.generate(patterns, settings);
37568 const provider = new _Provider(settings);
37569 return tasks.map(provider.read, provider);
37572 function assertPatternsInput$1(input) {
37573 const source = [].concat(input);
37574 const isValidSource = source.every(item => utils$7.string.isString(item) && !utils$7.string.isEmpty(item));
37576 if (!isValidSource) {
37577 throw new TypeError('Patterns must be a string (non empty) or an array of strings');
37581 var out = FastGlob;
37583 var dirGlob$1 = {exports: {}};
37585 var pathType$1 = {};
37588 promisify: promisify$1
37589 } = require$$0__default$4["default"];
37590 const fs$3 = require$$0__default["default"];
37592 async function isType(fsStatType, statsMethodName, filePath) {
37593 if (typeof filePath !== 'string') {
37594 throw new TypeError(`Expected a string, got ${typeof filePath}`);
37598 const stats = await promisify$1(fs$3[fsStatType])(filePath);
37599 return stats[statsMethodName]();
37601 if (error.code === 'ENOENT') {
37609 function isTypeSync(fsStatType, statsMethodName, filePath) {
37610 if (typeof filePath !== 'string') {
37611 throw new TypeError(`Expected a string, got ${typeof filePath}`);
37615 return fs$3[fsStatType](filePath)[statsMethodName]();
37617 if (error.code === 'ENOENT') {
37625 pathType$1.isFile = isType.bind(null, 'stat', 'isFile');
37626 pathType$1.isDirectory = isType.bind(null, 'stat', 'isDirectory');
37627 pathType$1.isSymlink = isType.bind(null, 'lstat', 'isSymbolicLink');
37628 pathType$1.isFileSync = isTypeSync.bind(null, 'statSync', 'isFile');
37629 pathType$1.isDirectorySync = isTypeSync.bind(null, 'statSync', 'isDirectory');
37630 pathType$1.isSymlinkSync = isTypeSync.bind(null, 'lstatSync', 'isSymbolicLink');
37632 const path$2 = require$$0__default$2["default"];
37633 const pathType = pathType$1;
37635 const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0];
37637 const getPath = (filepath, cwd) => {
37638 const pth = filepath[0] === '!' ? filepath.slice(1) : filepath;
37639 return path$2.isAbsolute(pth) ? pth : path$2.join(cwd, pth);
37642 const addExtensions = (file, extensions) => {
37643 if (path$2.extname(file)) {
37644 return `**/${file}`;
37647 return `**/${file}.${getExtensions(extensions)}`;
37650 const getGlob = (directory, options) => {
37651 if (options.files && !Array.isArray(options.files)) {
37652 throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof options.files}\``);
37655 if (options.extensions && !Array.isArray(options.extensions)) {
37656 throw new TypeError(`Expected \`extensions\` to be of type \`Array\` but received type \`${typeof options.extensions}\``);
37659 if (options.files && options.extensions) {
37660 return options.files.map(x => path$2.posix.join(directory, addExtensions(x, options.extensions)));
37663 if (options.files) {
37664 return options.files.map(x => path$2.posix.join(directory, `**/${x}`));
37667 if (options.extensions) {
37668 return [path$2.posix.join(directory, `**/*.${getExtensions(options.extensions)}`)];
37671 return [path$2.posix.join(directory, '**')];
37674 dirGlob$1.exports = async (input, options) => {
37675 options = Object.assign({
37679 if (typeof options.cwd !== 'string') {
37680 throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
37683 const globs = await Promise.all([].concat(input).map(async x => {
37684 const isDirectory = await pathType.isDirectory(getPath(x, options.cwd));
37685 return isDirectory ? getGlob(x, options) : x;
37687 return [].concat.apply([], globs); // eslint-disable-line prefer-spread
37690 dirGlob$1.exports.sync = (input, options) => {
37691 options = Object.assign({
37695 if (typeof options.cwd !== 'string') {
37696 throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
37699 const globs = [].concat(input).map(x => pathType.isDirectorySync(getPath(x, options.cwd)) ? getGlob(x, options) : x);
37700 return [].concat.apply([], globs); // eslint-disable-line prefer-spread
37703 var gitignore$1 = {exports: {}};
37705 function makeArray(subject) {
37706 return Array.isArray(subject) ? subject : [subject];
37711 const ESCAPE = '\\';
37712 const REGEX_TEST_BLANK_LINE = /^\s+$/;
37713 const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
37714 const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
37715 const REGEX_SPLITALL_CRLF = /\r?\n/g; // /foo,
37721 const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
37723 const KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
37724 /* istanbul ignore next */
37727 const define = (object, key, value) => Object.defineProperty(object, key, {
37731 const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
37732 // The cases are complicated, see test cases for details
37734 const sanitizeRange = range => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
37735 // fatal for JavaScript regular expression, so eliminate it.
37736 : EMPTY); // See fixtures #59
37739 const cleanRangeBackSlash = slashes => {
37743 return slashes.slice(0, length - length % 2);
37744 }; // > If the pattern ends with a slash,
37745 // > it is removed for the purpose of the following description,
37746 // > but it would only find a match with a directory.
37747 // > In other words, foo/ will match a directory foo and paths underneath it,
37748 // > but will not match a regular file or a symbolic link foo
37749 // > (this is consistent with the way how pathspec works in general in Git).
37750 // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
37751 // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
37752 // you could use option `mark: true` with `glob`
37753 // '`foo/`' should not continue with the '`..`'
37756 const REPLACERS = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
37760 /\\?\s+$/, match => match.indexOf('\\') === 0 ? SPACE : EMPTY], // replace (\ ) with ' '
37761 [/\\\s/g, () => SPACE], // Escape metacharacters
37762 // which is written down by users but means special for regular expressions.
37763 // > There are 12 characters with special meanings:
37764 // > - the backslash \,
37765 // > - the caret ^,
37766 // > - the dollar sign $,
37767 // > - the period or dot .,
37768 // > - the vertical bar or pipe symbol |,
37769 // > - the question mark ?,
37770 // > - the asterisk or star *,
37771 // > - the plus sign +,
37772 // > - the opening parenthesis (,
37773 // > - the closing parenthesis ),
37774 // > - and the opening square bracket [,
37775 // > - the opening curly brace {,
37776 // > These special characters are often called "metacharacters".
37777 [/[\\$.|*+(){^]/g, match => `\\${match}`], [// > a question mark (?) matches a single character
37778 /(?!\\)\?/g, () => '[^/]'], // leading slash
37779 [// > A leading slash matches the beginning of the pathname.
37780 // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
37781 // A leading slash matches the beginning of the pathname
37782 /^\//, () => '^'], // replace special metacharacter slash after the leading slash
37783 [/\//g, () => '\\/'], [// > A leading "**" followed by a slash means match in all directories.
37784 // > For example, "**/foo" matches file or directory "foo" anywhere,
37785 // > the same as pattern "foo".
37786 // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
37787 // > under directory "foo".
37788 // Notice that the '*'s have been replaced as '\\*'
37789 /^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
37790 () => '^(?:.*\\/)?'], // starting
37791 [// there will be no leading '/'
37792 // (which has been replaced by section "leading slash")
37793 // If starts with '**', adding a '^' to the regular expression also works
37794 /^(?=[^^])/, function startingReplacer() {
37795 // If has a slash `/` at the beginning or middle
37796 return !/\/(?!$)/.test(this) // > Prior to 2.22.1
37797 // > If the pattern does not contain a slash /,
37798 // > Git treats it as a shell glob pattern
37799 // Actually, if there is only a trailing slash,
37800 // git also treats it as a shell glob pattern
37801 // After 2.22.1 (compatible but clearer)
37802 // > If there is a separator at the beginning or middle (or both)
37803 // > of the pattern, then the pattern is relative to the directory
37804 // > level of the particular .gitignore file itself.
37805 // > Otherwise the pattern may also match at any level below
37806 // > the .gitignore level.
37807 ? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
37808 // > consumption by fnmatch(3)
37810 }], // two globstars
37811 [// Use lookahead assertions so that we could match more than one `'/**'`
37812 /\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
37813 // should not use '*', or it will be replaced by the next replacer
37814 // Check if it is not the last `'/**'`
37815 (_, index, str) => index + 6 < str.length // case: /**/
37816 // > A slash followed by two consecutive asterisks then a slash matches
37817 // > zero or more directories.
37818 // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
37820 ? '(?:\\/[^\\/]+)*' // case: /**
37821 // > A trailing `"/**"` matches everything inside.
37822 // #21: everything inside but it should not include the current folder
37823 : '\\/.+'], // intermediate wildcards
37824 [// Never replace escaped '*'
37825 // ignore rule '\*' will match the path '*'
37827 // 'abc.*' -> skip this rule
37828 /(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
37829 // '*.js' doesn't match 'abc'
37830 (_, p1) => `${p1}[^\\/]*`], [// unescape, revert step 3 except for back slash
37831 // For example, if a user escape a '\\*',
37832 // after step 3, the result will be '\\\\\\*'
37833 /\\\\\\(?=[$.|*+(){^])/g, () => ESCAPE], [// '\\\\' -> '\\'
37834 /\\\\/g, () => ESCAPE], [// > The range notation, e.g. [a-zA-Z],
37835 // > can be used to match one of the characters in a range.
37836 // `\` is escaped by step 3
37837 /(\\)?\[([^\]/]*?)(\\*)($|\])/g, (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE // '\\[bar]' -> '\\\\[bar\\]'
37838 ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === ']' ? endEscape.length % 2 === 0 // A normal case, and it is a range notation
37841 ? `[${sanitizeRange(range)}${endEscape}]` // Invalid range notaton
37842 // '[bar\\]' -> '[bar\\\\]'
37843 : '[]' : '[]'], // ending
37844 [// 'js' will not match 'js.'
37845 // 'ab' will not match 'abc'
37846 /(?:[^*])$/, // WTF!
37847 // https://git-scm.com/docs/gitignore
37848 // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
37849 // which re-fixes #24, #38
37850 // > If there is a separator at the end of the pattern then the pattern
37851 // > will only match directories, otherwise the pattern can match both
37852 // > files and directories.
37853 // 'js*' will not match 'a.js'
37854 // 'js/' will not match 'a.js'
37855 // 'js' will match 'a.js' and 'a.js/'
37856 match => /\/$/.test(match) // foo/ will not match 'foo'
37857 ? `${match}$` // foo matches 'foo' and 'foo/'
37858 : `${match}(?=$|\\/$)`], // trailing wildcard
37859 [/(\^|\\\/)?\\\*$/, (_, p1) => {
37860 const prefix = p1 // '\^':
37861 // '/*' does not match EMPTY
37862 // '/*' does not match everything
37864 // 'abc/*' does not match 'abc/'
37865 ? `${p1}[^/]+` // 'a*' matches 'a'
37866 // 'a*' matches 'aa'
37868 return `${prefix}(?=$|\\/$)`;
37869 }]]; // A simple cache, because an ignore rule only has only one certain meaning
37871 const regexCache = Object.create(null); // @param {pattern}
37873 const makeRegex = (pattern, ignorecase) => {
37874 let source = regexCache[pattern];
37877 source = REPLACERS.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
37878 regexCache[pattern] = source;
37881 return ignorecase ? new RegExp(source, 'i') : new RegExp(source);
37884 const isString = subject => typeof subject === 'string'; // > A blank line matches no files, so it can serve as a separator for readability.
37887 const checkPattern = pattern => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
37888 && pattern.indexOf('#') !== 0;
37890 const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF);
37893 constructor(origin, pattern, negative, regex) {
37894 this.origin = origin;
37895 this.pattern = pattern;
37896 this.negative = negative;
37897 this.regex = regex;
37902 const createRule = (pattern, ignorecase) => {
37903 const origin = pattern;
37904 let negative = false; // > An optional prefix "!" which negates the pattern;
37906 if (pattern.indexOf('!') === 0) {
37908 pattern = pattern.substr(1);
37911 pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
37912 // > begin with a literal "!", for example, `"\!important!.txt"`.
37913 .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
37914 // > begin with a hash.
37915 .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#');
37916 const regex = makeRegex(pattern, ignorecase);
37917 return new IgnoreRule(origin, pattern, negative, regex);
37920 const throwError = (message, Ctor) => {
37921 throw new Ctor(message);
37924 const checkPath = (path, originalPath, doThrow) => {
37925 if (!isString(path)) {
37926 return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
37927 } // We don't know if we should ignore EMPTY, so throw
37931 return doThrow(`path must not be empty`, TypeError);
37932 } // Check if it is a relative path
37935 if (checkPath.isNotRelative(path)) {
37936 const r = '`path.relative()`d';
37937 return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
37943 const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path);
37945 checkPath.isNotRelative = isNotRelative;
37947 checkPath.convert = p => p;
37953 define(this, KEY_IGNORE, true);
37955 this._ignorecase = ignorecase;
37961 this._ignoreCache = Object.create(null);
37962 this._testCache = Object.create(null);
37965 _addPattern(pattern) {
37967 if (pattern && pattern[KEY_IGNORE]) {
37968 this._rules = this._rules.concat(pattern._rules);
37969 this._added = true;
37973 if (checkPattern(pattern)) {
37974 const rule = createRule(pattern, this._ignorecase);
37975 this._added = true;
37977 this._rules.push(rule);
37979 } // @param {Array<string> | string | Ignore} pattern
37983 this._added = false;
37984 makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
37985 // making the behavior changed.
37995 addPattern(pattern) {
37996 return this.add(pattern);
37997 } // | ignored : unignored
37998 // negative | 0:0 | 0:1 | 1:0 | 1:1
37999 // -------- | ------- | ------- | ------- | --------
38000 // 0 | TEST | TEST | SKIP | X
38001 // 1 | TESTIF | SKIP | TEST | X
38002 // - SKIP: always skip
38003 // - TEST: always test
38004 // - TESTIF: only test if checkUnignored
38005 // - X: that never happen
38006 // @param {boolean} whether should check if the path is unignored,
38007 // setting `checkUnignored` to `false` could reduce additional
38009 // @returns {TestResult} true if a file is ignored
38012 _testOne(path, checkUnignored) {
38013 let ignored = false;
38014 let unignored = false;
38016 this._rules.forEach(rule => {
38021 if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
38025 const matched = rule.regex.test(path);
38028 ignored = !negative;
38029 unignored = negative;
38037 } // @returns {TestResult}
38040 _test(originalPath, cache, checkUnignored, slices) {
38041 const path = originalPath // Supports nullable path
38042 && checkPath.convert(originalPath);
38043 checkPath(path, originalPath, throwError);
38044 return this._t(path, cache, checkUnignored, slices);
38047 _t(path, cache, checkUnignored, slices) {
38048 if (path in cache) {
38049 return cache[path];
38054 // ['path', 'to', 'a.js']
38055 slices = path.split(SLASH);
38058 slices.pop(); // If the path has no parent directory, just test it
38060 if (!slices.length) {
38061 return cache[path] = this._testOne(path, checkUnignored);
38064 const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices); // If the path contains a parent directory, check the parent first
38067 return cache[path] = parent.ignored // > It is not possible to re-include a file if a parent directory of
38068 // > that file is excluded.
38069 ? parent : this._testOne(path, checkUnignored);
38073 return this._test(path, this._ignoreCache, false).ignored;
38077 return path => !this.ignores(path);
38081 return makeArray(paths).filter(this.createFilter());
38082 } // @returns {TestResult}
38086 return this._test(path, this._testCache, true);
38091 const factory = options => new Ignore(options);
38093 const returnFalse = () => false;
38095 const isPathValid = path => checkPath(path && checkPath.convert(path), path, returnFalse);
38097 factory.isPathValid = isPathValid; // Fixes typescript
38099 factory.default = factory;
38100 var ignore = factory; // Windows
38101 // --------------------------------------------------------------
38103 /* istanbul ignore if */
38105 if ( // Detect `process` so that it can run in browsers.
38106 typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
38107 /* eslint no-control-regex: "off" */
38108 const makePosix = str => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, '/');
38110 checkPath.convert = makePosix; // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/'
38113 const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
38115 checkPath.isNotRelative = path => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
38118 var slash$1 = path => {
38119 const isExtendedLengthPath = /^\\\\\?\\/.test(path);
38120 const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex
38122 if (isExtendedLengthPath || hasNonAscii) {
38126 return path.replace(/\\/g, '/');
38131 } = require$$0__default$4["default"];
38132 const fs$2 = require$$0__default["default"];
38133 const path$1 = require$$0__default$2["default"];
38134 const fastGlob$1 = out;
38135 const gitIgnore = ignore;
38136 const slash = slash$1;
38137 const DEFAULT_IGNORE = ['**/node_modules/**', '**/flow-typed/**', '**/coverage/**', '**/.git'];
38138 const readFileP = promisify(fs$2.readFile);
38140 const mapGitIgnorePatternTo = base => ignore => {
38141 if (ignore.startsWith('!')) {
38142 return '!' + path$1.posix.join(base, ignore.slice(1));
38145 return path$1.posix.join(base, ignore);
38148 const parseGitIgnore = (content, options) => {
38149 const base = slash(path$1.relative(options.cwd, path$1.dirname(options.fileName)));
38150 return content.split(/\r?\n/).filter(Boolean).filter(line => !line.startsWith('#')).map(mapGitIgnorePatternTo(base));
38153 const reduceIgnore = files => {
38154 const ignores = gitIgnore();
38156 for (const file of files) {
38157 ignores.add(parseGitIgnore(file.content, {
38159 fileName: file.filePath
38166 const ensureAbsolutePathForCwd = (cwd, p) => {
38169 if (path$1.isAbsolute(p)) {
38170 if (slash(p).startsWith(cwd)) {
38174 throw new Error(`Path ${p} is not in cwd ${cwd}`);
38177 return path$1.join(cwd, p);
38180 const getIsIgnoredPredecate = (ignores, cwd) => {
38181 return p => ignores.ignores(slash(path$1.relative(cwd, ensureAbsolutePathForCwd(cwd, p.path || p))));
38184 const getFile = async (file, cwd) => {
38185 const filePath = path$1.join(cwd, file);
38186 const content = await readFileP(filePath, 'utf8');
38194 const getFileSync = (file, cwd) => {
38195 const filePath = path$1.join(cwd, file);
38196 const content = fs$2.readFileSync(filePath, 'utf8');
38204 const normalizeOptions = ({
38206 cwd = slash(process.cwd())
38214 gitignore$1.exports = async options => {
38215 options = normalizeOptions(options);
38216 const paths = await fastGlob$1('**/.gitignore', {
38217 ignore: DEFAULT_IGNORE.concat(options.ignore),
38220 const files = await Promise.all(paths.map(file => getFile(file, options.cwd)));
38221 const ignores = reduceIgnore(files);
38222 return getIsIgnoredPredecate(ignores, options.cwd);
38225 gitignore$1.exports.sync = options => {
38226 options = normalizeOptions(options);
38227 const paths = fastGlob$1.sync('**/.gitignore', {
38228 ignore: DEFAULT_IGNORE.concat(options.ignore),
38231 const files = paths.map(file => getFileSync(file, options.cwd));
38232 const ignores = reduceIgnore(files);
38233 return getIsIgnoredPredecate(ignores, options.cwd);
38238 } = require$$0__default$5["default"];
38240 class ObjectTransform extends Transform {
38249 class FilterStream$1 extends ObjectTransform {
38250 constructor(filter) {
38252 this._filter = filter;
38255 _transform(data, encoding, callback) {
38256 if (this._filter(data)) {
38265 class UniqueStream$1 extends ObjectTransform {
38268 this._pushed = new Set();
38271 _transform(data, encoding, callback) {
38272 if (!this._pushed.has(data)) {
38275 this._pushed.add(data);
38283 var streamUtils = {
38284 FilterStream: FilterStream$1,
38285 UniqueStream: UniqueStream$1
38288 const fs$1 = require$$0__default["default"];
38289 const arrayUnion = arrayUnion$1;
38290 const merge2 = merge2_1;
38291 const fastGlob = out;
38292 const dirGlob = dirGlob$1.exports;
38293 const gitignore = gitignore$1.exports;
38299 const DEFAULT_FILTER = () => false;
38301 const isNegative = pattern => pattern[0] === '!';
38303 const assertPatternsInput = patterns => {
38304 if (!patterns.every(pattern => typeof pattern === 'string')) {
38305 throw new TypeError('Patterns must be a string or an array of strings');
38309 const checkCwdOption = (options = {}) => {
38310 if (!options.cwd) {
38317 stat = fs$1.statSync(options.cwd);
38322 if (!stat.isDirectory()) {
38323 throw new Error('The `cwd` option must be a path to a directory');
38327 const getPathString = p => p.stats instanceof fs$1.Stats ? p.path : p;
38329 const generateGlobTasks = (patterns, taskOptions) => {
38330 patterns = arrayUnion([].concat(patterns));
38331 assertPatternsInput(patterns);
38332 checkCwdOption(taskOptions);
38333 const globTasks = [];
38334 taskOptions = Object.assign({
38336 expandDirectories: true
38339 for (const [index, pattern] of patterns.entries()) {
38340 if (isNegative(pattern)) {
38344 const ignore = patterns.slice(index).filter(pattern => isNegative(pattern)).map(pattern => pattern.slice(1));
38345 const options = Object.assign(Object.assign({}, taskOptions), {}, {
38346 ignore: taskOptions.ignore.concat(ignore)
38357 const globDirs = (task, fn) => {
38360 if (task.options.cwd) {
38361 options.cwd = task.options.cwd;
38364 if (Array.isArray(task.options.expandDirectories)) {
38365 options = Object.assign(Object.assign({}, options), {}, {
38366 files: task.options.expandDirectories
38368 } else if (typeof task.options.expandDirectories === 'object') {
38369 options = Object.assign(Object.assign({}, options), task.options.expandDirectories);
38372 return fn(task.pattern, options);
38375 const getPattern = (task, fn) => task.options.expandDirectories ? globDirs(task, fn) : [task.pattern];
38377 const getFilterSync = options => {
38378 return options && options.gitignore ? gitignore.sync({
38380 ignore: options.ignore
38381 }) : DEFAULT_FILTER;
38384 const globToTask = task => glob => {
38389 if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) {
38390 options.ignore = dirGlob.sync(options.ignore);
38399 globby$2.exports = async (patterns, options) => {
38400 const globTasks = generateGlobTasks(patterns, options);
38402 const getFilter = async () => {
38403 return options && options.gitignore ? gitignore({
38405 ignore: options.ignore
38406 }) : DEFAULT_FILTER;
38409 const getTasks = async () => {
38410 const tasks = await Promise.all(globTasks.map(async task => {
38411 const globs = await getPattern(task, dirGlob);
38412 return Promise.all(globs.map(globToTask(task)));
38414 return arrayUnion(...tasks);
38417 const [filter, tasks] = await Promise.all([getFilter(), getTasks()]);
38418 const paths = await Promise.all(tasks.map(task => fastGlob(task.pattern, task.options)));
38419 return arrayUnion(...paths).filter(path_ => !filter(getPathString(path_)));
38422 globby$2.exports.sync = (patterns, options) => {
38423 const globTasks = generateGlobTasks(patterns, options);
38426 for (const task of globTasks) {
38427 const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
38428 tasks.push(...newTask);
38431 const filter = getFilterSync(options);
38434 for (const task of tasks) {
38435 matches = arrayUnion(matches, fastGlob.sync(task.pattern, task.options));
38438 return matches.filter(path_ => !filter(path_));
38441 globby$2.exports.stream = (patterns, options) => {
38442 const globTasks = generateGlobTasks(patterns, options);
38445 for (const task of globTasks) {
38446 const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
38447 tasks.push(...newTask);
38450 const filter = getFilterSync(options);
38451 const filterStream = new FilterStream(p => !filter(p));
38452 const uniqueStream = new UniqueStream();
38453 return merge2(tasks.map(task => fastGlob.stream(task.pattern, task.options))).pipe(filterStream).pipe(uniqueStream);
38456 globby$2.exports.generateGlobTasks = generateGlobTasks;
38458 globby$2.exports.hasMagic = (patterns, options) => [].concat(patterns).some(pattern => fastGlob.isDynamicPattern(pattern, options));
38460 globby$2.exports.gitignore = gitignore;
38462 const _excluded = ["languageId"];
38464 var createLanguage$7 = function (linguistData, override) {
38468 rest = _objectWithoutProperties(linguistData, _excluded);
38470 return Object.assign(Object.assign({
38471 linguistLanguageId: languageId
38472 }, rest), override(linguistData));
38477 var ast = {exports: {}};
38480 Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
38482 Redistribution and use in source and binary forms, with or without
38483 modification, are permitted provided that the following conditions are met:
38485 * Redistributions of source code must retain the above copyright
38486 notice, this list of conditions and the following disclaimer.
38487 * Redistributions in binary form must reproduce the above copyright
38488 notice, this list of conditions and the following disclaimer in the
38489 documentation and/or other materials provided with the distribution.
38491 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
38492 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38493 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38494 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
38495 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38496 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38497 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38498 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38499 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
38500 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38505 function isExpression(node) {
38506 if (node == null) {
38510 switch (node.type) {
38511 case 'ArrayExpression':
38512 case 'AssignmentExpression':
38513 case 'BinaryExpression':
38514 case 'CallExpression':
38515 case 'ConditionalExpression':
38516 case 'FunctionExpression':
38519 case 'LogicalExpression':
38520 case 'MemberExpression':
38521 case 'NewExpression':
38522 case 'ObjectExpression':
38523 case 'SequenceExpression':
38524 case 'ThisExpression':
38525 case 'UnaryExpression':
38526 case 'UpdateExpression':
38533 function isIterationStatement(node) {
38534 if (node == null) {
38538 switch (node.type) {
38539 case 'DoWhileStatement':
38540 case 'ForInStatement':
38541 case 'ForStatement':
38542 case 'WhileStatement':
38549 function isStatement(node) {
38550 if (node == null) {
38554 switch (node.type) {
38555 case 'BlockStatement':
38556 case 'BreakStatement':
38557 case 'ContinueStatement':
38558 case 'DebuggerStatement':
38559 case 'DoWhileStatement':
38560 case 'EmptyStatement':
38561 case 'ExpressionStatement':
38562 case 'ForInStatement':
38563 case 'ForStatement':
38564 case 'IfStatement':
38565 case 'LabeledStatement':
38566 case 'ReturnStatement':
38567 case 'SwitchStatement':
38568 case 'ThrowStatement':
38569 case 'TryStatement':
38570 case 'VariableDeclaration':
38571 case 'WhileStatement':
38572 case 'WithStatement':
38579 function isSourceElement(node) {
38580 return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
38583 function trailingStatement(node) {
38584 switch (node.type) {
38585 case 'IfStatement':
38586 if (node.alternate != null) {
38587 return node.alternate;
38590 return node.consequent;
38592 case 'LabeledStatement':
38593 case 'ForStatement':
38594 case 'ForInStatement':
38595 case 'WhileStatement':
38596 case 'WithStatement':
38603 function isProblematicIfStatement(node) {
38606 if (node.type !== 'IfStatement') {
38610 if (node.alternate == null) {
38614 current = node.consequent;
38617 if (current.type === 'IfStatement') {
38618 if (current.alternate == null) {
38623 current = trailingStatement(current);
38630 isExpression: isExpression,
38631 isStatement: isStatement,
38632 isIterationStatement: isIterationStatement,
38633 isSourceElement: isSourceElement,
38634 isProblematicIfStatement: isProblematicIfStatement,
38635 trailingStatement: trailingStatement
38639 var code = {exports: {}};
38642 Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
38643 Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
38645 Redistribution and use in source and binary forms, with or without
38646 modification, are permitted provided that the following conditions are met:
38648 * Redistributions of source code must retain the above copyright
38649 notice, this list of conditions and the following disclaimer.
38650 * Redistributions in binary form must reproduce the above copyright
38651 notice, this list of conditions and the following disclaimer in the
38652 documentation and/or other materials provided with the distribution.
38654 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38655 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38656 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38657 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
38658 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38659 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38660 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38661 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38662 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
38663 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38668 var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`.
38671 // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierStart:
38672 NonAsciiIdentifierStart: /[\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\u0561-\u0587\u05D0-\u05EA\u05F0-\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\u08A0-\u08B4\u08B6-\u08BD\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\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\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\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\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\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-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\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\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\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\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\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-\uAB65\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]/,
38673 // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierPart:
38674 NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\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\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\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\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/
38677 // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierStart:
38678 NonAsciiIdentifierStart: /[\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\u0561-\u0587\u05D0-\u05EA\u05F0-\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\u08A0-\u08B4\u08B6-\u08BD\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\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\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\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\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\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-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\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-\u2C2E\u2C30-\u2C5E\u2C60-\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-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\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-\uAB65\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
38679 // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierPart:
38680 NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\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\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\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\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
38683 function isDecimalDigit(ch) {
38684 return 0x30 <= ch && ch <= 0x39; // 0..9
38687 function isHexDigit(ch) {
38688 return 0x30 <= ch && ch <= 0x39 || // 0..9
38689 0x61 <= ch && ch <= 0x66 || // a..f
38690 0x41 <= ch && ch <= 0x46; // A..F
38693 function isOctalDigit(ch) {
38694 return ch >= 0x30 && ch <= 0x37; // 0..7
38695 } // 7.2 White Space
38698 NON_ASCII_WHITESPACES = [0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
38700 function isWhiteSpace(ch) {
38701 return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
38702 } // 7.3 Line Terminators
38705 function isLineTerminator(ch) {
38706 return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
38707 } // 7.6 Identifier Names and Identifiers
38710 function fromCodePoint(cp) {
38711 if (cp <= 0xFFFF) {
38712 return String.fromCharCode(cp);
38715 var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
38716 var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
38720 IDENTIFIER_START = new Array(0x80);
38722 for (ch = 0; ch < 0x80; ++ch) {
38723 IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
38724 ch >= 0x41 && ch <= 0x5A || // A..Z
38725 ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
38728 IDENTIFIER_PART = new Array(0x80);
38730 for (ch = 0; ch < 0x80; ++ch) {
38731 IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
38732 ch >= 0x41 && ch <= 0x5A || // A..Z
38733 ch >= 0x30 && ch <= 0x39 || // 0..9
38734 ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
38737 function isIdentifierStartES5(ch) {
38738 return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
38741 function isIdentifierPartES5(ch) {
38742 return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
38745 function isIdentifierStartES6(ch) {
38746 return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
38749 function isIdentifierPartES6(ch) {
38750 return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
38754 isDecimalDigit: isDecimalDigit,
38755 isHexDigit: isHexDigit,
38756 isOctalDigit: isOctalDigit,
38757 isWhiteSpace: isWhiteSpace,
38758 isLineTerminator: isLineTerminator,
38759 isIdentifierStartES5: isIdentifierStartES5,
38760 isIdentifierPartES5: isIdentifierPartES5,
38761 isIdentifierStartES6: isIdentifierStartES6,
38762 isIdentifierPartES6: isIdentifierPartES6
38766 var keyword = {exports: {}};
38769 Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
38771 Redistribution and use in source and binary forms, with or without
38772 modification, are permitted provided that the following conditions are met:
38774 * Redistributions of source code must retain the above copyright
38775 notice, this list of conditions and the following disclaimer.
38776 * Redistributions in binary form must reproduce the above copyright
38777 notice, this list of conditions and the following disclaimer in the
38778 documentation and/or other materials provided with the distribution.
38780 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38781 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38782 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38783 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
38784 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38785 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38786 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38787 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38788 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
38789 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38794 var code$1 = code.exports;
38796 function isStrictModeReservedWordES6(id) {
38813 function isKeywordES5(id, strict) {
38814 // yield should not be treated as keyword under non-strict mode.
38815 if (!strict && id === 'yield') {
38819 return isKeywordES6(id, strict);
38822 function isKeywordES6(id, strict) {
38823 if (strict && isStrictModeReservedWordES6(id)) {
38827 switch (id.length) {
38829 return id === 'if' || id === 'in' || id === 'do';
38832 return id === 'var' || id === 'for' || id === 'new' || id === 'try';
38835 return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
38838 return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
38841 return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
38844 return id === 'default' || id === 'finally' || id === 'extends';
38847 return id === 'function' || id === 'continue' || id === 'debugger';
38850 return id === 'instanceof';
38857 function isReservedWordES5(id, strict) {
38858 return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
38861 function isReservedWordES6(id, strict) {
38862 return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
38865 function isRestrictedWord(id) {
38866 return id === 'eval' || id === 'arguments';
38869 function isIdentifierNameES5(id) {
38872 if (id.length === 0) {
38876 ch = id.charCodeAt(0);
38878 if (!code$1.isIdentifierStartES5(ch)) {
38882 for (i = 1, iz = id.length; i < iz; ++i) {
38883 ch = id.charCodeAt(i);
38885 if (!code$1.isIdentifierPartES5(ch)) {
38893 function decodeUtf16(lead, trail) {
38894 return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
38897 function isIdentifierNameES6(id) {
38898 var i, iz, ch, lowCh, check;
38900 if (id.length === 0) {
38904 check = code$1.isIdentifierStartES6;
38906 for (i = 0, iz = id.length; i < iz; ++i) {
38907 ch = id.charCodeAt(i);
38909 if (0xD800 <= ch && ch <= 0xDBFF) {
38916 lowCh = id.charCodeAt(i);
38918 if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
38922 ch = decodeUtf16(ch, lowCh);
38929 check = code$1.isIdentifierPartES6;
38935 function isIdentifierES5(id, strict) {
38936 return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
38939 function isIdentifierES6(id, strict) {
38940 return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
38943 keyword.exports = {
38944 isKeywordES5: isKeywordES5,
38945 isKeywordES6: isKeywordES6,
38946 isReservedWordES5: isReservedWordES5,
38947 isReservedWordES6: isReservedWordES6,
38948 isRestrictedWord: isRestrictedWord,
38949 isIdentifierNameES5: isIdentifierNameES5,
38950 isIdentifierNameES6: isIdentifierNameES6,
38951 isIdentifierES5: isIdentifierES5,
38952 isIdentifierES6: isIdentifierES6
38957 Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
38959 Redistribution and use in source and binary forms, with or without
38960 modification, are permitted provided that the following conditions are met:
38962 * Redistributions of source code must retain the above copyright
38963 notice, this list of conditions and the following disclaimer.
38964 * Redistributions in binary form must reproduce the above copyright
38965 notice, this list of conditions and the following disclaimer in the
38966 documentation and/or other materials provided with the distribution.
38968 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38969 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38970 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38971 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
38972 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38973 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38974 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38975 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38976 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
38977 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38982 utils$6.ast = ast.exports;
38983 utils$6.code = code.exports;
38984 utils$6.keyword = keyword.exports;
38987 const isIdentifierName = utils$6.keyword.isIdentifierNameES5;
38989 getLast: getLast$l,
38990 hasNewline: hasNewline$7,
38992 isNonEmptyArray: isNonEmptyArray$h,
38993 isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$1,
38994 getStringWidth: getStringWidth$3
38997 locStart: locStart$q,
39002 * @typedef {import("./types/estree").Node} Node
39003 * @typedef {import("./types/estree").TemplateLiteral} TemplateLiteral
39004 * @typedef {import("./types/estree").Comment} Comment
39005 * @typedef {import("./types/estree").MemberExpression} MemberExpression
39006 * @typedef {import("./types/estree").OptionalMemberExpression} OptionalMemberExpression
39007 * @typedef {import("./types/estree").CallExpression} CallExpression
39008 * @typedef {import("./types/estree").OptionalCallExpression} OptionalCallExpression
39009 * @typedef {import("./types/estree").Expression} Expression
39010 * @typedef {import("./types/estree").Property} Property
39011 * @typedef {import("./types/estree").ObjectTypeProperty} ObjectTypeProperty
39012 * @typedef {import("./types/estree").TaggedTemplateExpression} TaggedTemplateExpression
39013 * @typedef {import("./types/estree").Literal} Literal
39015 * @typedef {import("../common/ast-path")} AstPath
39017 // We match any whitespace except line terminators because
39018 // Flow annotation comments cannot be split across lines. For example:
39021 // : any */).foo = 5;
39023 // is not picked up by Flow (see https://github.com/facebook/flow/issues/7050), so
39024 // removing the newline would create a type annotation that the user did not intend
39027 const NON_LINE_TERMINATING_WHITE_SPACE = "(?:(?=.)\\s)";
39028 const FLOW_SHORTHAND_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*:`);
39029 const FLOW_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*::`);
39031 * @param {Node} node
39032 * @returns {boolean}
39035 function hasFlowShorthandAnnotationComment$3(node) {
39036 // https://flow.org/en/docs/types/comments/
39037 // Syntax example: const r = new (window.Request /*: Class<Request> */)("");
39038 return node.extra && node.extra.parenthesized && isNonEmptyArray$h(node.trailingComments) && isBlockComment$5(node.trailingComments[0]) && FLOW_SHORTHAND_ANNOTATION.test(node.trailingComments[0].value);
39041 * @param {Comment[]} comments
39042 * @returns {boolean}
39046 function hasFlowAnnotationComment$2(comments) {
39047 return isNonEmptyArray$h(comments) && isBlockComment$5(comments[0]) && FLOW_ANNOTATION.test(comments[0].value);
39050 * @param {Node} node
39051 * @param {(Node) => boolean} fn
39052 * @returns {boolean}
39056 function hasNode$2(node, fn) {
39057 if (!node || typeof node !== "object") {
39061 if (Array.isArray(node)) {
39062 return node.some(value => hasNode$2(value, fn));
39065 const result = fn(node);
39066 return typeof result === "boolean" ? result : Object.values(node).some(value => hasNode$2(value, fn));
39069 * @param {Node} node
39070 * @returns {boolean}
39074 function hasNakedLeftSide$3(node) {
39075 return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression" || node.type === "ConditionalExpression" || isCallExpression$d(node) || isMemberExpression$a(node) || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" || node.type === "UpdateExpression" && !node.prefix || node.type === "TSAsExpression" || node.type === "TSNonNullExpression";
39078 function getLeftSide$1(node) {
39079 if (node.expressions) {
39080 return node.expressions[0];
39083 return node.left || node.test || node.callee || node.object || node.tag || node.argument || node.expression;
39086 function getLeftSidePathName$2(path, node) {
39087 if (node.expressions) {
39088 return ["expressions", 0];
39111 if (node.argument) {
39112 return ["argument"];
39115 if (node.expression) {
39116 return ["expression"];
39119 throw new Error("Unexpected node has no left side.");
39122 * @param {Comment} comment
39123 * @returns {boolean}
39127 function isBlockComment$5(comment) {
39128 return comment.type === "Block" || comment.type === "CommentBlock" || // `meriyah`
39129 comment.type === "MultiLine";
39132 * @param {Comment} comment
39133 * @returns {boolean}
39137 function isLineComment$3(comment) {
39138 return comment.type === "Line" || comment.type === "CommentLine" || // `meriyah` has `SingleLine`, `HashbangComment`, `HTMLOpen`, and `HTMLClose`
39139 comment.type === "SingleLine" || comment.type === "HashbangComment" || comment.type === "HTMLOpen" || comment.type === "HTMLClose";
39142 const exportDeclarationTypes = new Set(["ExportDefaultDeclaration", "ExportDefaultSpecifier", "DeclareExportDeclaration", "ExportNamedDeclaration", "ExportAllDeclaration"]);
39144 * @param {Node} node
39145 * @returns {boolean}
39148 function isExportDeclaration(node) {
39149 return node && exportDeclarationTypes.has(node.type);
39152 * @param {AstPath} path
39153 * @returns {Node | null}
39157 function getParentExportDeclaration$2(path) {
39158 const parentNode = path.getParentNode();
39160 if (path.getName() === "declaration" && isExportDeclaration(parentNode)) {
39167 * @param {Node} node
39168 * @returns {boolean}
39172 function isLiteral$3(node) {
39173 return node.type === "BooleanLiteral" || node.type === "DirectiveLiteral" || node.type === "Literal" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "BigIntLiteral" || node.type === "DecimalLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "TemplateLiteral" || node.type === "TSTypeLiteral" || node.type === "JSXText";
39176 * @param {Node} node
39177 * @returns {boolean}
39181 function isNumericLiteral$5(node) {
39182 return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
39185 function isSignedNumericLiteral$2(node) {
39186 return node.type === "UnaryExpression" && (node.operator === "+" || node.operator === "-") && isNumericLiteral$5(node.argument);
39189 * @param {Node} node
39190 * @returns {boolean}
39194 function isStringLiteral$5(node) {
39195 return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
39198 * @param {Node} node
39199 * @returns {boolean}
39203 function isObjectType$3(node) {
39204 return node.type === "ObjectTypeAnnotation" || node.type === "TSTypeLiteral" || node.type === "TSMappedType";
39207 * @param {Node} node
39208 * @returns {boolean}
39212 function isFunctionOrArrowExpression$1(node) {
39213 return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
39216 * @param {Node} node
39217 * @returns {boolean}
39221 function isFunctionOrArrowExpressionWithBody(node) {
39222 return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement";
39225 * @param {Node} node
39226 * @returns {boolean}
39230 function isTemplateLiteral(node) {
39231 return node.type === "TemplateLiteral";
39234 * Note: `inject` is used in AngularJS 1.x, `async` in Angular 2+
39235 * example: https://docs.angularjs.org/guide/unit-testing#using-beforeall-
39237 * @param {CallExpression} node
39238 * @returns {boolean}
39242 function isAngularTestWrapper(node) {
39243 return isCallExpression$d(node) && node.callee.type === "Identifier" && (node.callee.name === "async" || node.callee.name === "inject" || node.callee.name === "fakeAsync");
39246 * @param {Node} node
39247 * @returns {boolean}
39251 function isJsxNode$7(node) {
39252 return node.type === "JSXElement" || node.type === "JSXFragment";
39255 function isTheOnlyJsxElementInMarkdown$2(options, path) {
39256 if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
39260 const node = path.getNode();
39262 if (!node.expression || !isJsxNode$7(node.expression)) {
39266 const parent = path.getParentNode();
39267 return parent.type === "Program" && parent.body.length === 1;
39270 function isGetterOrSetter$1(node) {
39271 return node.kind === "get" || node.kind === "set";
39272 } // TODO: This is a bad hack and we need a better way to distinguish between
39273 // arrow functions and otherwise
39276 function isFunctionNotation$1(node) {
39277 return isGetterOrSetter$1(node) || hasSameLocStart(node, node.value);
39278 } // Hack to differentiate between the following two which have the same ast
39279 // type T = { method: () => void };
39280 // type T = { method(): void };
39283 * @param {Node} node
39284 * @returns {boolean}
39288 function isObjectTypePropertyAFunction$2(node) {
39289 return (node.type === "ObjectTypeProperty" || node.type === "ObjectTypeInternalSlot") && node.value.type === "FunctionTypeAnnotation" && !node.static && !isFunctionNotation$1(node);
39290 } // Hack to differentiate between the following two which have the same ast
39291 // declare function f(a): void;
39292 // var f: (a) => void;
39295 function isTypeAnnotationAFunction$1(node) {
39296 return (node.type === "TypeAnnotation" || node.type === "TSTypeAnnotation") && node.typeAnnotation.type === "FunctionTypeAnnotation" && !node.static && !hasSameLocStart(node, node.typeAnnotation);
39299 const binaryishNodeTypes = new Set(["BinaryExpression", "LogicalExpression", "NGPipeExpression"]);
39301 * @param {Node} node
39302 * @returns {boolean}
39305 function isBinaryish$5(node) {
39306 return binaryishNodeTypes.has(node.type);
39309 * @param {Node} node
39310 * @returns {boolean}
39314 function isMemberish$2(node) {
39315 return isMemberExpression$a(node) || node.type === "BindExpression" && Boolean(node.object);
39318 const simpleTypeAnnotations = new Set([// `any`
39319 "AnyTypeAnnotation", "TSAnyKeyword", // `null`
39320 "NullLiteralTypeAnnotation", "TSNullKeyword", // `this`
39321 "ThisTypeAnnotation", "TSThisType", // `number`
39322 "NumberTypeAnnotation", "TSNumberKeyword", // `void`
39323 "VoidTypeAnnotation", "TSVoidKeyword", // `boolean`
39324 "BooleanTypeAnnotation", "TSBooleanKeyword", // `bigint`
39325 "BigIntTypeAnnotation", "TSBigIntKeyword", // `symbol`
39326 "SymbolTypeAnnotation", "TSSymbolKeyword", // `string`
39327 "StringTypeAnnotation", "TSStringKeyword", // literals
39328 "BooleanLiteralTypeAnnotation", "StringLiteralTypeAnnotation", "BigIntLiteralTypeAnnotation", "NumberLiteralTypeAnnotation", "TSLiteralType", "TSTemplateLiteralType", // flow only, `empty`, `mixed`
39329 "EmptyTypeAnnotation", "MixedTypeAnnotation", // typescript only, `never`, `object`, `undefined`, `unknown`
39330 "TSNeverKeyword", "TSObjectKeyword", "TSUndefinedKeyword", "TSUnknownKeyword"]);
39332 * @param {Node} node
39333 * @returns {boolean}
39336 function isSimpleType$2(node) {
39341 if ((node.type === "GenericTypeAnnotation" || node.type === "TSTypeReference") && !node.typeParameters) {
39345 if (simpleTypeAnnotations.has(node.type)) {
39352 const unitTestRe = /^(?:skip|[fx]?(?:it|describe|test))$/;
39354 * @param {{callee: MemberExpression | OptionalMemberExpression}} node
39355 * @returns {boolean}
39358 function isSkipOrOnlyBlock(node) {
39359 return isMemberExpression$a(node.callee) && node.callee.object.type === "Identifier" && node.callee.property.type === "Identifier" && unitTestRe.test(node.callee.object.name) && (node.callee.property.name === "only" || node.callee.property.name === "skip");
39362 * @param {CallExpression} node
39363 * @returns {boolean}
39367 function isUnitTestSetUp(node) {
39368 const unitTestSetUpRe = /^(?:before|after)(?:Each|All)$/;
39369 return node.callee.type === "Identifier" && unitTestSetUpRe.test(node.callee.name) && node.arguments.length === 1;
39370 } // eg; `describe("some string", (done) => {})`
39373 function isTestCall$3(node, parent) {
39374 if (node.type !== "CallExpression") {
39378 if (node.arguments.length === 1) {
39379 if (isAngularTestWrapper(node) && parent && isTestCall$3(parent)) {
39380 return isFunctionOrArrowExpression$1(node.arguments[0]);
39383 if (isUnitTestSetUp(node)) {
39384 return isAngularTestWrapper(node.arguments[0]);
39386 } else if (node.arguments.length === 2 || node.arguments.length === 3) {
39387 if ((node.callee.type === "Identifier" && unitTestRe.test(node.callee.name) || isSkipOrOnlyBlock(node)) && (isTemplateLiteral(node.arguments[0]) || isStringLiteral$5(node.arguments[0]))) {
39388 // it("name", () => { ... }, 2500)
39389 if (node.arguments[2] && !isNumericLiteral$5(node.arguments[2])) {
39393 return (node.arguments.length === 2 ? isFunctionOrArrowExpression$1(node.arguments[1]) : isFunctionOrArrowExpressionWithBody(node.arguments[1]) && getFunctionParameters$6(node.arguments[1]).length <= 1) || isAngularTestWrapper(node.arguments[1]);
39400 * @param {Node} node
39401 * @returns {boolean}
39405 function isCallExpression$d(node) {
39406 return node && (node.type === "CallExpression" || node.type === "OptionalCallExpression");
39409 * @param {Node} node
39410 * @returns {boolean}
39414 function isMemberExpression$a(node) {
39415 return node && (node.type === "MemberExpression" || node.type === "OptionalMemberExpression");
39419 * @param {any} node
39420 * @returns {boolean}
39424 function isSimpleTemplateLiteral$1(node) {
39425 let expressionsKey = "expressions";
39427 if (node.type === "TSTemplateLiteralType") {
39428 expressionsKey = "types";
39431 const expressions = node[expressionsKey];
39433 if (expressions.length === 0) {
39437 return expressions.every(expr => {
39438 // Disallow comments since printDocToString can't print them here
39439 if (hasComment$j(expr)) {
39441 } // Allow `x` and `this`
39444 if (expr.type === "Identifier" || expr.type === "ThisExpression") {
39446 } // Allow `a.b.c`, `a.b[c]`, and `this.x.y`
39449 if (isMemberExpression$a(expr)) {
39452 while (isMemberExpression$a(head)) {
39453 if (head.property.type !== "Identifier" && head.property.type !== "Literal" && head.property.type !== "StringLiteral" && head.property.type !== "NumericLiteral") {
39457 head = head.object;
39459 if (hasComment$j(head)) {
39464 if (head.type === "Identifier" || head.type === "ThisExpression") {
39475 * @param {string} tokenNode
39476 * @param {string} keyword
39477 * @returns {string}
39481 function getTypeScriptMappedTypeModifier$1(tokenNode, keyword) {
39482 if (tokenNode === "+") {
39483 return "+" + keyword;
39486 if (tokenNode === "-") {
39487 return "-" + keyword;
39493 * @param {string} text
39494 * @param {Node} typeAnnotation
39495 * @returns {boolean}
39499 function isFlowAnnotationComment$2(text, typeAnnotation) {
39500 const start = locStart$q(typeAnnotation);
39501 const end = skipWhitespace(text, locEnd$p(typeAnnotation));
39502 return end !== false && text.slice(start, start + 2) === "/*" && text.slice(end, end + 2) === "*/";
39505 * @param {string} text
39506 * @param {Node} node
39507 * @returns {boolean}
39511 function hasLeadingOwnLineComment$4(text, node) {
39512 if (isJsxNode$7(node)) {
39513 return hasNodeIgnoreComment$1(node);
39516 return hasComment$j(node, CommentCheckFlags$g.Leading, comment => hasNewline$7(text, locEnd$p(comment)));
39517 } // Note: Quoting/unquoting numbers in TypeScript is not safe.
39519 // let a = { 1: 1, 2: 2 }
39520 // let b = { '1': 1, '2': 2 }
39522 // declare let aa: keyof typeof a;
39523 // declare let bb: keyof typeof b;
39527 // Type '"1" | "2"' is not assignable to type '1 | 2'.
39528 // Type '"1"' is not assignable to type '1 | 2'.(2322)
39530 // And in Flow, you get:
39534 // ^ Non-string literal property keys not supported. [unsupported-syntax]
39537 // Angular does not support unquoted numbers in expressions.
39539 // So we play it safe and only unquote numbers for the JavaScript parsers.
39540 // (Vue supports unquoted numbers in expressions, but let’s keep it simple.)
39542 // Identifiers can be unquoted in more circumstances, though.
39545 function isStringPropSafeToUnquote$1(node, options) {
39546 return options.parser !== "json" && isStringLiteral$5(node.key) && rawText$5(node.key).slice(1, -1) === node.key.value && (isIdentifierName(node.key.value) && // With `--strictPropertyInitialization`, TS treats properties with quoted names differently than unquoted ones.
39547 // See https://github.com/microsoft/TypeScript/pull/20075
39548 !(options.parser === "babel-ts" && node.type === "ClassProperty" || options.parser === "typescript" && node.type === "PropertyDefinition") || isSimpleNumber$1(node.key.value) && String(Number(node.key.value)) === node.key.value && (options.parser === "babel" || options.parser === "espree" || options.parser === "meriyah" || options.parser === "__babel_estree"));
39549 } // Matches “simple” numbers like `123` and `2.5` but not `1_000`, `1e+100` or `0b10`.
39552 function isSimpleNumber$1(numberString) {
39553 return /^(?:\d+|\d+\.\d+)$/.test(numberString);
39556 * @param {Node} node
39557 * @param {Node} parentNode
39558 * @returns {boolean}
39562 function isJestEachTemplateLiteral$1(node, parentNode) {
39564 * describe.each`table`(name, fn)
39565 * describe.only.each`table`(name, fn)
39566 * describe.skip.each`table`(name, fn)
39567 * test.each`table`(name, fn)
39568 * test.only.each`table`(name, fn)
39569 * test.skip.each`table`(name, fn)
39571 * Ref: https://github.com/facebook/jest/pull/6102
39573 const jestEachTriggerRegex = /^[fx]?(?:describe|it|test)$/;
39574 return parentNode.type === "TaggedTemplateExpression" && parentNode.quasi === node && parentNode.tag.type === "MemberExpression" && parentNode.tag.property.type === "Identifier" && parentNode.tag.property.name === "each" && (parentNode.tag.object.type === "Identifier" && jestEachTriggerRegex.test(parentNode.tag.object.name) || parentNode.tag.object.type === "MemberExpression" && parentNode.tag.object.property.type === "Identifier" && (parentNode.tag.object.property.name === "only" || parentNode.tag.object.property.name === "skip") && parentNode.tag.object.object.type === "Identifier" && jestEachTriggerRegex.test(parentNode.tag.object.object.name));
39577 * @param {TemplateLiteral} template
39578 * @returns {boolean}
39582 function templateLiteralHasNewLines(template) {
39583 return template.quasis.some(quasi => quasi.value.raw.includes("\n"));
39586 * @param {TemplateLiteral | TaggedTemplateExpression} node
39587 * @param {string} text
39588 * @returns {boolean}
39592 function isTemplateOnItsOwnLine$2(node, text) {
39593 return (node.type === "TemplateLiteral" && templateLiteralHasNewLines(node) || node.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(node.quasi)) && !hasNewline$7(text, locStart$q(node), {
39598 * @param {Node} node
39599 * @returns {boolean}
39603 function needsHardlineAfterDanglingComment$2(node) {
39604 if (!hasComment$j(node)) {
39608 const lastDanglingComment = getLast$l(getComments$5(node, CommentCheckFlags$g.Dangling));
39609 return lastDanglingComment && !isBlockComment$5(lastDanglingComment);
39610 } // Logic to check for args with multiple anonymous functions. For instance,
39611 // the following call should be split on multiple lines for readability:
39612 // source.pipe(map((x) => x + x), filter((x) => x % 2 === 0))
39615 function isFunctionCompositionArgs$1(args) {
39616 if (args.length <= 1) {
39622 for (const arg of args) {
39623 if (isFunctionOrArrowExpression$1(arg)) {
39629 } else if (isCallExpression$d(arg)) {
39630 for (const childArg of arg.arguments) {
39631 if (isFunctionOrArrowExpression$1(childArg)) {
39639 } // Logic to determine if a call is a “long curried function call”.
39640 // See https://github.com/prettier/prettier/issues/1420.
39642 // `connect(a, b, c)(d)`
39643 // In the above call expression, the second call is the parent node and the
39644 // first call is the current node.
39647 * @param {AstPath} path
39648 * @returns {boolean}
39652 function isLongCurriedCallExpression$2(path) {
39653 const node = path.getValue();
39654 const parent = path.getParentNode();
39655 return isCallExpression$d(node) && isCallExpression$d(parent) && parent.callee === node && node.arguments.length > parent.arguments.length && parent.arguments.length > 0;
39658 * @param {any} node
39659 * @param {number} depth
39660 * @returns {boolean}
39664 function isSimpleCallArgument$1(node, depth) {
39669 const isChildSimple = child => isSimpleCallArgument$1(child, depth + 1);
39671 const regexpPattern = node.type === "Literal" && "regex" in node && node.regex.pattern || node.type === "RegExpLiteral" && node.pattern;
39673 if (regexpPattern && getStringWidth$3(regexpPattern) > 5) {
39677 if (node.type === "Literal" || node.type === "BigIntLiteral" || node.type === "DecimalLiteral" || node.type === "BooleanLiteral" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "Identifier" || node.type === "ThisExpression" || node.type === "Super" || node.type === "PrivateName" || node.type === "PrivateIdentifier" || node.type === "ArgumentPlaceholder" || node.type === "Import") {
39681 if (node.type === "TemplateLiteral") {
39682 return node.quasis.every(element => !element.value.raw.includes("\n")) && node.expressions.every(isChildSimple);
39685 if (node.type === "ObjectExpression") {
39686 return node.properties.every(p => !p.computed && (p.shorthand || p.value && isChildSimple(p.value)));
39689 if (node.type === "ArrayExpression") {
39690 return node.elements.every(x => x === null || isChildSimple(x));
39693 if (isCallLikeExpression$2(node)) {
39694 return (node.type === "ImportExpression" || isSimpleCallArgument$1(node.callee, depth)) && getCallArguments$5(node).every(isChildSimple);
39697 if (isMemberExpression$a(node)) {
39698 return isSimpleCallArgument$1(node.object, depth) && isSimpleCallArgument$1(node.property, depth);
39701 if (node.type === "UnaryExpression" && (node.operator === "!" || node.operator === "-")) {
39702 return isSimpleCallArgument$1(node.argument, depth);
39705 if (node.type === "TSNonNullExpression") {
39706 return isSimpleCallArgument$1(node.expression, depth);
39712 function rawText$5(node) {
39713 return node.extra ? node.extra.raw : node.raw;
39716 function identity$1(x) {
39720 function isTSXFile$1(options) {
39721 return options.filepath && /\.tsx$/i.test(options.filepath);
39724 * @param {any} options
39725 * @param {("es5" | "all")} [level]
39726 * @returns {boolean}
39730 function shouldPrintComma$b(options, level = "es5") {
39731 return options.trailingComma === "es5" && level === "es5" || options.trailingComma === "all" && (level === "all" || level === "es5");
39734 * Tests if an expression starts with `{`, or (if forbidFunctionClassAndDoExpr
39735 * holds) `function`, `class`, or `do {}`. Will be overzealous if there's
39736 * already necessary grouping parentheses.
39738 * @param {Node} node
39739 * @param {boolean} forbidFunctionClassAndDoExpr
39740 * @returns {boolean}
39744 function startsWithNoLookaheadToken$2(node, forbidFunctionClassAndDoExpr) {
39745 node = getLeftMost(node);
39747 switch (node.type) {
39748 case "FunctionExpression":
39749 case "ClassExpression":
39750 case "DoExpression":
39751 return forbidFunctionClassAndDoExpr;
39753 case "ObjectExpression":
39756 case "MemberExpression":
39757 case "OptionalMemberExpression":
39758 return startsWithNoLookaheadToken$2(node.object, forbidFunctionClassAndDoExpr);
39760 case "TaggedTemplateExpression":
39761 if (node.tag.type === "FunctionExpression") {
39762 // IIFEs are always already parenthesized
39766 return startsWithNoLookaheadToken$2(node.tag, forbidFunctionClassAndDoExpr);
39768 case "CallExpression":
39769 case "OptionalCallExpression":
39770 if (node.callee.type === "FunctionExpression") {
39771 // IIFEs are always already parenthesized
39775 return startsWithNoLookaheadToken$2(node.callee, forbidFunctionClassAndDoExpr);
39777 case "ConditionalExpression":
39778 return startsWithNoLookaheadToken$2(node.test, forbidFunctionClassAndDoExpr);
39780 case "UpdateExpression":
39781 return !node.prefix && startsWithNoLookaheadToken$2(node.argument, forbidFunctionClassAndDoExpr);
39783 case "BindExpression":
39784 return node.object && startsWithNoLookaheadToken$2(node.object, forbidFunctionClassAndDoExpr);
39786 case "SequenceExpression":
39787 return startsWithNoLookaheadToken$2(node.expressions[0], forbidFunctionClassAndDoExpr);
39789 case "TSAsExpression":
39790 case "TSNonNullExpression":
39791 return startsWithNoLookaheadToken$2(node.expression, forbidFunctionClassAndDoExpr);
39798 const equalityOperators = {
39804 const multiplicativeOperators = {
39809 const bitshiftOperators = {
39815 function shouldFlatten$2(parentOp, nodeOp) {
39816 if (getPrecedence$1(nodeOp) !== getPrecedence$1(parentOp)) {
39818 } // ** is right-associative
39819 // x ** y ** z --> x ** (y ** z)
39822 if (parentOp === "**") {
39824 } // x == y == z --> (x == y) == z
39827 if (equalityOperators[parentOp] && equalityOperators[nodeOp]) {
39829 } // x * y % z --> (x * y) % z
39832 if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) {
39834 } // x * y / z --> (x * y) / z
39835 // x / y * z --> (x / y) * z
39838 if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) {
39840 } // x << y << z --> (x << y) << z
39843 if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) {
39850 const PRECEDENCE = {};
39852 for (const [i, tier] of [["|>"], ["??"], ["||"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]].entries()) {
39853 for (const op of tier) {
39854 PRECEDENCE[op] = i;
39858 function getPrecedence$1(op) {
39859 return PRECEDENCE[op];
39862 function getLeftMost(node) {
39863 while (node.left) {
39870 function isBitwiseOperator$1(operator) {
39871 return Boolean(bitshiftOperators[operator]) || operator === "|" || operator === "^" || operator === "&";
39874 function hasRestParameter$1(node) {
39879 const parameters = getFunctionParameters$6(node);
39880 return parameters.length > 0 && getLast$l(parameters).type === "RestElement";
39883 const functionParametersCache = new WeakMap();
39885 function getFunctionParameters$6(node) {
39886 if (functionParametersCache.has(node)) {
39887 return functionParametersCache.get(node);
39890 const parameters = [];
39893 parameters.push(node.this);
39894 } // `params` vs `parameters` - see https://github.com/babel/babel/issues/9231
39897 if (Array.isArray(node.parameters)) {
39898 parameters.push(...node.parameters);
39899 } else if (Array.isArray(node.params)) {
39900 parameters.push(...node.params);
39904 parameters.push(node.rest);
39907 functionParametersCache.set(node, parameters);
39911 function iterateFunctionParametersPath$1(path, iteratee) {
39912 const node = path.getValue();
39915 const callback = childPath => iteratee(childPath, index++);
39918 path.call(callback, "this");
39921 if (Array.isArray(node.parameters)) {
39922 path.each(callback, "parameters");
39923 } else if (Array.isArray(node.params)) {
39924 path.each(callback, "params");
39928 path.call(callback, "rest");
39932 const callArgumentsCache = new WeakMap();
39934 function getCallArguments$5(node) {
39935 if (callArgumentsCache.has(node)) {
39936 return callArgumentsCache.get(node);
39939 let args = node.arguments;
39941 if (node.type === "ImportExpression") {
39942 args = [node.source];
39944 if (node.attributes) {
39945 args.push(node.attributes);
39949 callArgumentsCache.set(node, args);
39953 function iterateCallArgumentsPath$2(path, iteratee) {
39954 const node = path.getValue();
39956 if (node.type === "ImportExpression") {
39957 path.call(sourcePath => iteratee(sourcePath, 0), "source");
39959 if (node.attributes) {
39960 path.call(sourcePath => iteratee(sourcePath, 1), "attributes");
39963 path.each(iteratee, "arguments");
39967 function isPrettierIgnoreComment$1(comment) {
39968 return comment.value.trim() === "prettier-ignore" && !comment.unignore;
39971 function hasNodeIgnoreComment$1(node) {
39972 return node && (node.prettierIgnore || hasComment$j(node, CommentCheckFlags$g.PrettierIgnore));
39975 function hasIgnoreComment$2(path) {
39976 const node = path.getValue();
39977 return hasNodeIgnoreComment$1(node);
39980 const CommentCheckFlags$g = {
39981 /** Check comment is a leading comment */
39984 /** Check comment is a trailing comment */
39987 /** Check comment is a dangling comment */
39990 /** Check comment is a block comment */
39993 /** Check comment is a line comment */
39996 /** Check comment is a `prettier-ignore` comment */
39997 PrettierIgnore: 1 << 6,
39999 /** Check comment is the first attached comment */
40002 /** Check comment is the last attached comment */
40006 const getCommentTestFunction = (flags, fn) => {
40007 if (typeof flags === "function") {
40013 return (comment, index, comments) => !(flags & CommentCheckFlags$g.Leading && !comment.leading || flags & CommentCheckFlags$g.Trailing && !comment.trailing || flags & CommentCheckFlags$g.Dangling && (comment.leading || comment.trailing) || flags & CommentCheckFlags$g.Block && !isBlockComment$5(comment) || flags & CommentCheckFlags$g.Line && !isLineComment$3(comment) || flags & CommentCheckFlags$g.First && index !== 0 || flags & CommentCheckFlags$g.Last && index !== comments.length - 1 || flags & CommentCheckFlags$g.PrettierIgnore && !isPrettierIgnoreComment$1(comment) || fn && !fn(comment));
40017 * @param {Node} node
40018 * @param {number | function} [flags]
40019 * @param {function} [fn]
40020 * @returns {boolean}
40024 function hasComment$j(node, flags, fn) {
40025 if (!node || !isNonEmptyArray$h(node.comments)) {
40029 const test = getCommentTestFunction(flags, fn);
40030 return test ? node.comments.some(test) : true;
40033 * @param {Node} node
40034 * @param {number | function} [flags]
40035 * @param {function} [fn]
40036 * @returns {Comment[]}
40040 function getComments$5(node, flags, fn) {
40041 if (!node || !Array.isArray(node.comments)) {
40045 const test = getCommentTestFunction(flags, fn);
40046 return test ? node.comments.filter(test) : node.comments;
40049 * @param {Node} node
40050 * @returns {boolean}
40054 const isNextLineEmpty$c = (node, {
40056 }) => isNextLineEmptyAfterIndex$1(originalText, locEnd$p(node));
40058 function isCallLikeExpression$2(node) {
40059 return isCallExpression$d(node) || node.type === "NewExpression" || node.type === "ImportExpression";
40062 function isObjectProperty$6(node) {
40063 return node && (node.type === "ObjectProperty" || node.type === "Property" && !node.method && node.kind === "init");
40066 function isEnabledHackPipeline$1(options) {
40067 return Boolean(options.__isUsingHackPipeline);
40071 getFunctionParameters: getFunctionParameters$6,
40072 iterateFunctionParametersPath: iterateFunctionParametersPath$1,
40073 getCallArguments: getCallArguments$5,
40074 iterateCallArgumentsPath: iterateCallArgumentsPath$2,
40075 hasRestParameter: hasRestParameter$1,
40076 getLeftSide: getLeftSide$1,
40077 getLeftSidePathName: getLeftSidePathName$2,
40078 getParentExportDeclaration: getParentExportDeclaration$2,
40079 getTypeScriptMappedTypeModifier: getTypeScriptMappedTypeModifier$1,
40080 hasFlowAnnotationComment: hasFlowAnnotationComment$2,
40081 hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$3,
40082 hasLeadingOwnLineComment: hasLeadingOwnLineComment$4,
40083 hasNakedLeftSide: hasNakedLeftSide$3,
40084 hasNode: hasNode$2,
40085 hasIgnoreComment: hasIgnoreComment$2,
40086 hasNodeIgnoreComment: hasNodeIgnoreComment$1,
40087 identity: identity$1,
40088 isBinaryish: isBinaryish$5,
40089 isBlockComment: isBlockComment$5,
40090 isCallLikeExpression: isCallLikeExpression$2,
40091 isEnabledHackPipeline: isEnabledHackPipeline$1,
40092 isLineComment: isLineComment$3,
40093 isPrettierIgnoreComment: isPrettierIgnoreComment$1,
40094 isCallExpression: isCallExpression$d,
40095 isMemberExpression: isMemberExpression$a,
40096 isExportDeclaration,
40097 isFlowAnnotationComment: isFlowAnnotationComment$2,
40098 isFunctionCompositionArgs: isFunctionCompositionArgs$1,
40099 isFunctionNotation: isFunctionNotation$1,
40100 isFunctionOrArrowExpression: isFunctionOrArrowExpression$1,
40101 isGetterOrSetter: isGetterOrSetter$1,
40102 isJestEachTemplateLiteral: isJestEachTemplateLiteral$1,
40103 isJsxNode: isJsxNode$7,
40104 isLiteral: isLiteral$3,
40105 isLongCurriedCallExpression: isLongCurriedCallExpression$2,
40106 isSimpleCallArgument: isSimpleCallArgument$1,
40107 isMemberish: isMemberish$2,
40108 isNumericLiteral: isNumericLiteral$5,
40109 isSignedNumericLiteral: isSignedNumericLiteral$2,
40110 isObjectProperty: isObjectProperty$6,
40111 isObjectType: isObjectType$3,
40112 isObjectTypePropertyAFunction: isObjectTypePropertyAFunction$2,
40113 isSimpleType: isSimpleType$2,
40114 isSimpleNumber: isSimpleNumber$1,
40115 isSimpleTemplateLiteral: isSimpleTemplateLiteral$1,
40116 isStringLiteral: isStringLiteral$5,
40117 isStringPropSafeToUnquote: isStringPropSafeToUnquote$1,
40118 isTemplateOnItsOwnLine: isTemplateOnItsOwnLine$2,
40119 isTestCall: isTestCall$3,
40120 isTheOnlyJsxElementInMarkdown: isTheOnlyJsxElementInMarkdown$2,
40121 isTSXFile: isTSXFile$1,
40122 isTypeAnnotationAFunction: isTypeAnnotationAFunction$1,
40123 isNextLineEmpty: isNextLineEmpty$c,
40124 needsHardlineAfterDanglingComment: needsHardlineAfterDanglingComment$2,
40125 rawText: rawText$5,
40126 shouldPrintComma: shouldPrintComma$b,
40127 isBitwiseOperator: isBitwiseOperator$1,
40128 shouldFlatten: shouldFlatten$2,
40129 startsWithNoLookaheadToken: startsWithNoLookaheadToken$2,
40130 getPrecedence: getPrecedence$1,
40131 hasComment: hasComment$j,
40132 getComments: getComments$5,
40133 CommentCheckFlags: CommentCheckFlags$g
40136 const getLast$k = getLast_1;
40138 getStringWidth: getStringWidth$2,
40144 hardline: hardline$A,
40145 softline: softline$t,
40149 lineSuffixBoundary: lineSuffixBoundary$1,
40153 printDocToString: printDocToString$1
40160 isBinaryish: isBinaryish$4,
40161 isJestEachTemplateLiteral,
40162 isSimpleTemplateLiteral,
40163 hasComment: hasComment$i,
40164 isMemberExpression: isMemberExpression$9
40167 function printTemplateLiteral$2(path, print, options) {
40168 const node = path.getValue();
40169 const isTemplateLiteral = node.type === "TemplateLiteral";
40171 if (isTemplateLiteral && isJestEachTemplateLiteral(node, path.getParentNode())) {
40172 const printed = printJestEachTemplateLiteral(path, options, print);
40179 let expressionsKey = "expressions";
40181 if (node.type === "TSTemplateLiteralType") {
40182 expressionsKey = "types";
40186 let expressions = path.map(print, expressionsKey);
40187 const isSimple = isSimpleTemplateLiteral(node);
40190 expressions = expressions.map(doc => printDocToString$1(doc, Object.assign(Object.assign({}, options), {}, {
40191 printWidth: Number.POSITIVE_INFINITY
40195 parts.push(lineSuffixBoundary$1, "`");
40196 path.each(childPath => {
40197 const i = childPath.getName();
40198 parts.push(print());
40200 if (i < expressions.length) {
40201 // For a template literal of the following form:
40208 // the expression is on its own line (there is a \n in the previous
40209 // quasi literal), therefore we want to indent the JavaScript
40210 // expression inside at the beginning of ${ instead of the beginning
40215 const quasi = childPath.getValue();
40216 const indentSize = getIndentSize(quasi.value.raw, tabWidth);
40217 let printed = expressions[i];
40220 const expression = node[expressionsKey][i]; // Breaks at the template element boundaries (${ and }) are preferred to breaking
40221 // in the middle of a MemberExpression
40223 if (hasComment$i(expression) || isMemberExpression$9(expression) || expression.type === "ConditionalExpression" || expression.type === "SequenceExpression" || expression.type === "TSAsExpression" || isBinaryish$4(expression)) {
40224 printed = [indent$y([softline$t, printed]), softline$t];
40228 const aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$5(Number.NEGATIVE_INFINITY, printed) : addAlignmentToDoc(printed, indentSize, tabWidth);
40229 parts.push(group$C(["${", aligned, lineSuffixBoundary$1, "}"]));
40236 function printJestEachTemplateLiteral(path, options, print) {
40239 * ${1} | ${1} | ${2}
40240 * ${1} | ${2} | ${3}
40241 * ${2} | ${1} | ${3}
40243 const node = path.getNode();
40244 const headerNames = node.quasis[0].value.raw.trim().split(/\s*\|\s*/);
40246 if (headerNames.length > 1 || headerNames.some(headerName => headerName.length > 0)) {
40247 options.__inJestEach = true;
40248 const expressions = path.map(print, "expressions");
40249 options.__inJestEach = false;
40251 const stringifiedExpressions = expressions.map(doc => "${" + printDocToString$1(doc, Object.assign(Object.assign({}, options), {}, {
40252 printWidth: Number.POSITIVE_INFINITY,
40254 })).formatted + "}");
40255 const tableBody = [{
40256 hasLineBreak: false,
40260 for (let i = 1; i < node.quasis.length; i++) {
40261 const row = getLast$k(tableBody);
40262 const correspondingExpression = stringifiedExpressions[i - 1];
40263 row.cells.push(correspondingExpression);
40265 if (correspondingExpression.includes("\n")) {
40266 row.hasLineBreak = true;
40269 if (node.quasis[i].value.raw.includes("\n")) {
40271 hasLineBreak: false,
40277 const maxColumnCount = Math.max(headerNames.length, ...tableBody.map(row => row.cells.length));
40278 const maxColumnWidths = Array.from({
40279 length: maxColumnCount
40283 }, ...tableBody.filter(row => row.cells.length > 0)];
40287 } of table.filter(row => !row.hasLineBreak)) {
40288 for (const [index, cell] of cells.entries()) {
40289 maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$2(cell));
40293 parts.push(lineSuffixBoundary$1, "`", indent$y([hardline$A, join$u(hardline$A, table.map(row => join$u(" | ", row.cells.map((cell, index) => row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$2(cell))))))]), hardline$A, "`");
40298 function printTemplateExpression(path, print) {
40299 const node = path.getValue();
40300 let printed = print();
40302 if (hasComment$i(node)) {
40303 printed = group$C([indent$y([softline$t, printed]), softline$t]);
40306 return ["${", printed, lineSuffixBoundary$1, "}"];
40309 function printTemplateExpressions$3(path, print) {
40310 return path.map(path => printTemplateExpression(path, print), "expressions");
40313 function escapeTemplateCharacters$2(doc, raw) {
40314 return mapDoc$3(doc, currentDoc => {
40315 if (typeof currentDoc === "string") {
40316 return raw ? currentDoc.replace(/(\\*)`/g, "$1$1\\`") : uncookTemplateElementValue$1(currentDoc);
40323 function uncookTemplateElementValue$1(cookedValue) {
40324 return cookedValue.replace(/([\\`]|\${)/g, "\\$1");
40327 var templateLiteral = {
40328 printTemplateLiteral: printTemplateLiteral$2,
40329 printTemplateExpressions: printTemplateExpressions$3,
40330 escapeTemplateCharacters: escapeTemplateCharacters$2,
40331 uncookTemplateElementValue: uncookTemplateElementValue$1
40337 softline: softline$s,
40338 literalline: literalline$4,
40339 dedentToRoot: dedentToRoot$2
40343 escapeTemplateCharacters: escapeTemplateCharacters$1
40344 } = templateLiteral;
40346 function format$3(path, print, textToDoc) {
40347 const node = path.getValue();
40348 let text = node.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, (_, backslashes) => "\\".repeat(backslashes.length / 2) + "`");
40349 const indentation = getIndentation(text);
40350 const hasIndent = indentation !== "";
40353 text = text.replace(new RegExp(`^${indentation}`, "gm"), "");
40356 const doc = escapeTemplateCharacters$1(textToDoc(text, {
40357 parser: "markdown",
40358 __inJsTemplate: true
40360 stripTrailingHardline: true
40362 return ["`", hasIndent ? indent$x([softline$s, doc]) : [literalline$4, dedentToRoot$2(doc)], softline$s, "`"];
40365 function getIndentation(str) {
40366 const firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
40367 return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
40370 var markdown = format$3;
40373 isNonEmptyArray: isNonEmptyArray$g
40378 hardline: hardline$z,
40379 softline: softline$r
40383 replaceEndOfLine: replaceEndOfLine$1,
40384 cleanDoc: cleanDoc$3
40388 printTemplateExpressions: printTemplateExpressions$2
40389 } = templateLiteral;
40391 function format$2(path, print, textToDoc) {
40392 const node = path.getValue(); // Get full template literal with expressions replaced by placeholders
40394 const rawQuasis = node.quasis.map(q => q.value.raw);
40395 let placeholderID = 0;
40396 const text = rawQuasis.reduce((prevVal, currVal, idx) => idx === 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal, "");
40397 const doc = textToDoc(text, {
40400 stripTrailingHardline: true
40402 const expressionDocs = printTemplateExpressions$2(path, print);
40403 return transformCssDoc(doc, node, expressionDocs);
40406 function transformCssDoc(quasisDoc, parentNode, expressionDocs) {
40407 const isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
40413 const newDoc = replacePlaceholders(quasisDoc, expressionDocs);
40414 /* istanbul ignore if */
40417 throw new Error("Couldn't insert all the expressions");
40420 return ["`", indent$w([hardline$z, newDoc]), softline$r, "`"];
40421 } // Search all the placeholders in the quasisDoc tree
40422 // and replace them with the expression docs one by one
40423 // returns a new doc with all the placeholders replaced,
40424 // or null if it couldn't replace any expression
40427 function replacePlaceholders(quasisDoc, expressionDocs) {
40428 if (!isNonEmptyArray$g(expressionDocs)) {
40432 let replaceCounter = 0;
40433 const newDoc = mapDoc$2(cleanDoc$3(quasisDoc), doc => {
40434 if (typeof doc !== "string" || !doc.includes("@prettier-placeholder")) {
40436 } // When we have multiple placeholders in one line, like:
40437 // ${Child}${Child2}:not(:first-child)
40440 return doc.split(/@prettier-placeholder-(\d+)-id/).map((component, idx) => {
40441 // The placeholder is always at odd indices
40442 if (idx % 2 === 0) {
40443 return replaceEndOfLine$1(component);
40444 } // The component will always be a number at odd index
40448 return expressionDocs[component];
40451 return expressionDocs.length === replaceCounter ? newDoc : null;
40454 var css = format$2;
40460 hardline: hardline$y
40464 escapeTemplateCharacters,
40465 printTemplateExpressions: printTemplateExpressions$1
40466 } = templateLiteral;
40468 function format$1(path, print, textToDoc) {
40469 const node = path.getValue();
40470 const numQuasis = node.quasis.length;
40472 if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
40476 const expressionDocs = printTemplateExpressions$1(path, print);
40479 for (let i = 0; i < numQuasis; i++) {
40480 const templateElement = node.quasis[i];
40481 const isFirst = i === 0;
40482 const isLast = i === numQuasis - 1;
40483 const text = templateElement.value.cooked;
40484 const lines = text.split("\n");
40485 const numLines = lines.length;
40486 const expressionDoc = expressionDocs[i];
40487 const startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === "";
40488 const endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
40489 const commentsAndWhitespaceOnly = lines.every(line => /^\s*(?:#[^\n\r]*)?$/.test(line)); // Bail out if an interpolation occurs within a comment.
40491 if (!isLast && /#[^\n\r]*$/.test(lines[numLines - 1])) {
40497 if (commentsAndWhitespaceOnly) {
40498 doc = printGraphqlComments(lines);
40500 doc = textToDoc(text, {
40503 stripTrailingHardline: true
40508 doc = escapeTemplateCharacters(doc, false);
40510 if (!isFirst && startsWithBlankLine) {
40516 if (!isLast && endsWithBlankLine) {
40519 } else if (!isFirst && !isLast && startsWithBlankLine) {
40523 if (expressionDoc) {
40524 parts.push(expressionDoc);
40528 return ["`", indent$v([hardline$y, join$t(hardline$y, parts)]), hardline$y, "`"];
40531 function printGraphqlComments(lines) {
40533 let seenComment = false;
40534 const array = lines.map(textLine => textLine.trim());
40536 for (const [i, textLine] of array.entries()) {
40537 // Lines are either whitespace only, or a comment (with potential whitespace
40538 // around it). Drop whitespace-only lines.
40539 if (textLine === "") {
40543 if (array[i - 1] === "" && seenComment) {
40544 // If a non-first comment is preceded by a blank (whitespace only) line,
40545 // add in a blank line.
40546 parts.push([hardline$y, textLine]);
40548 parts.push(textLine);
40551 seenComment = true;
40552 } // If `lines` was whitespace only, return `null`.
40555 return parts.length === 0 ? null : join$t(hardline$y, parts);
40558 var graphql = format$1;
40564 hardline: hardline$x,
40572 printTemplateExpressions,
40573 uncookTemplateElementValue
40574 } = templateLiteral; // The counter is needed to distinguish nested embeds.
40576 let htmlTemplateLiteralCounter = 0;
40578 function format(path, print, textToDoc, options, {
40581 const node = path.getValue();
40582 const counter = htmlTemplateLiteralCounter;
40583 htmlTemplateLiteralCounter = htmlTemplateLiteralCounter + 1 >>> 0;
40585 const composePlaceholder = index => `PRETTIER_HTML_PLACEHOLDER_${index}_${counter}_IN_JS`;
40587 const text = node.quasis.map((quasi, index, quasis) => index === quasis.length - 1 ? quasi.value.cooked : quasi.value.cooked + composePlaceholder(index)).join("");
40588 const expressionDocs = printTemplateExpressions(path, print);
40590 if (expressionDocs.length === 0 && text.trim().length === 0) {
40594 const placeholderRegex = new RegExp(composePlaceholder("(\\d+)"), "g");
40595 let topLevelCount = 0;
40596 const doc = textToDoc(text, {
40599 __onHtmlRoot(root) {
40600 topLevelCount = root.children.length;
40604 stripTrailingHardline: true
40606 const contentDoc = mapDoc$1(doc, doc => {
40607 if (typeof doc !== "string") {
40612 const components = doc.split(placeholderRegex);
40614 for (let i = 0; i < components.length; i++) {
40615 let component = components[i];
40619 component = uncookTemplateElementValue(component);
40621 if (options.__embeddedInHtml) {
40622 component = component.replace(/<\/(script)\b/gi, "<\\/$1");
40625 parts.push(component);
40631 const placeholderIndex = Number(component);
40632 parts.push(expressionDocs[placeholderIndex]);
40637 const leadingWhitespace = /^\s/.test(text) ? " " : "";
40638 const trailingWhitespace = /\s$/.test(text) ? " " : "";
40639 const linebreak = options.htmlWhitespaceSensitivity === "ignore" ? hardline$x : leadingWhitespace && trailingWhitespace ? line$y : null;
40642 return group$B(["`", indent$u([linebreak, group$B(contentDoc)]), linebreak, "`"]);
40645 return group$B(["`", leadingWhitespace, topLevelCount > 1 ? indent$u(group$B(contentDoc)) : group$B(contentDoc), trailingWhitespace, "`"]);
40648 var html$3 = format;
40651 hasComment: hasComment$h,
40652 CommentCheckFlags: CommentCheckFlags$f,
40653 isObjectProperty: isObjectProperty$5
40655 const formatMarkdown = markdown;
40656 const formatCss = css;
40657 const formatGraphql = graphql;
40658 const formatHtml = html$3;
40660 function getLanguage(path) {
40661 if (isStyledJsx(path) || isStyledComponents(path) || isCssProp(path) || isAngularComponentStyles(path)) {
40665 if (isGraphQL(path)) {
40669 if (isHtml(path)) {
40673 if (isAngularComponentTemplate(path)) {
40677 if (isMarkdown(path)) {
40682 function embed$a(path, print, textToDoc, options) {
40683 const node = path.getValue();
40685 if (node.type !== "TemplateLiteral" || // Bail out if any of the quasis have an invalid escape sequence
40686 // (which would make the `cooked` value be `null`)
40687 hasInvalidCookedValue(node)) {
40691 const language = getLanguage(path);
40697 if (language === "markdown") {
40698 return formatMarkdown(path, print, textToDoc);
40701 if (language === "css") {
40702 return formatCss(path, print, textToDoc);
40705 if (language === "graphql") {
40706 return formatGraphql(path, print, textToDoc);
40709 if (language === "html" || language === "angular") {
40710 return formatHtml(path, print, textToDoc, options, {
40721 function isMarkdown(path) {
40722 const node = path.getValue();
40723 const parent = path.getParentNode();
40724 return parent && parent.type === "TaggedTemplateExpression" && node.quasis.length === 1 && parent.tag.type === "Identifier" && (parent.tag.name === "md" || parent.tag.name === "markdown");
40727 * Template literal in these contexts:
40728 * <style jsx>{`div{color:red}`}</style>
40735 function isStyledJsx(path) {
40736 const node = path.getValue();
40737 const parent = path.getParentNode();
40738 const parentParent = path.getParentNode(1);
40739 return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "style" && parentParent.openingElement.attributes.some(attribute => attribute.name.name === "jsx") || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "Identifier" && parent.tag.name === "css" || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "MemberExpression" && parent.tag.object.name === "css" && (parent.tag.property.name === "global" || parent.tag.property.name === "resolve");
40742 * Angular Components can have:
40743 * - Inline HTML template
40744 * - Inline CSS styles
40746 * ...which are both within template literals somewhere
40747 * inside of the Component decorator factory.
40751 * template: `<div>...</div>`,
40752 * styles: [`h1 { color: blue; }`]
40757 function isAngularComponentStyles(path) {
40758 return path.match(node => node.type === "TemplateLiteral", (node, name) => node.type === "ArrayExpression" && name === "elements", (node, name) => isObjectProperty$5(node) && node.key.type === "Identifier" && node.key.name === "styles" && name === "value", ...angularComponentObjectExpressionPredicates);
40761 function isAngularComponentTemplate(path) {
40762 return path.match(node => node.type === "TemplateLiteral", (node, name) => isObjectProperty$5(node) && node.key.type === "Identifier" && node.key.name === "template" && name === "value", ...angularComponentObjectExpressionPredicates);
40765 const angularComponentObjectExpressionPredicates = [(node, name) => node.type === "ObjectExpression" && name === "properties", (node, name) => node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "Component" && name === "arguments", (node, name) => node.type === "Decorator" && name === "expression"];
40767 * styled-components template literals
40770 function isStyledComponents(path) {
40771 const parent = path.getParentNode();
40773 if (!parent || parent.type !== "TaggedTemplateExpression") {
40777 const tag = parent.tag.type === "ParenthesizedExpression" ? parent.tag.expression : parent.tag;
40779 switch (tag.type) {
40780 case "MemberExpression":
40781 return (// styled.foo``
40782 isStyledIdentifier(tag.object) || // Component.extend``
40783 isStyledExtend(tag)
40786 case "CallExpression":
40787 return (// styled(Component)``
40788 isStyledIdentifier(tag.callee) || tag.callee.type === "MemberExpression" && (tag.callee.object.type === "MemberExpression" && ( // styled.foo.attrs({})``
40789 isStyledIdentifier(tag.callee.object.object) || // Component.extend.attrs({})``
40790 isStyledExtend(tag.callee.object)) || // styled(Component).attrs({})``
40791 tag.callee.object.type === "CallExpression" && isStyledIdentifier(tag.callee.object.callee))
40796 return tag.name === "css";
40803 * JSX element with CSS prop
40807 function isCssProp(path) {
40808 const parent = path.getParentNode();
40809 const parentParent = path.getParentNode(1);
40810 return parentParent && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" && parentParent.name.type === "JSXIdentifier" && parentParent.name.name === "css";
40813 function isStyledIdentifier(node) {
40814 return node.type === "Identifier" && node.name === "styled";
40817 function isStyledExtend(node) {
40818 return /^[A-Z]/.test(node.object.name) && node.property.name === "extend";
40821 * react-relay and graphql-tag
40823 * graphql.experimental`...`
40825 * GraphQL comment block
40827 * This intentionally excludes Relay Classic tags, as Prettier does not
40828 * support Relay Classic formatting.
40832 function isGraphQL(path) {
40833 const node = path.getValue();
40834 const parent = path.getParentNode();
40835 return hasLanguageComment(node, "GraphQL") || parent && (parent.type === "TaggedTemplateExpression" && (parent.tag.type === "MemberExpression" && parent.tag.object.name === "graphql" && parent.tag.property.name === "experimental" || parent.tag.type === "Identifier" && (parent.tag.name === "gql" || parent.tag.name === "graphql")) || parent.type === "CallExpression" && parent.callee.type === "Identifier" && parent.callee.name === "graphql");
40838 function hasLanguageComment(node, languageName) {
40839 // This checks for a leading comment that is exactly `/* GraphQL */`
40840 // In order to be in line with other implementations of this comment tag
40841 // we will not trim the comment value and we will expect exactly one space on
40842 // either side of the GraphQL string
40843 // Also see ./clean.js
40844 return hasComment$h(node, CommentCheckFlags$f.Block | CommentCheckFlags$f.Leading, ({
40846 }) => value === ` ${languageName} `);
40850 * - HTML comment block
40854 function isHtml(path) {
40855 return hasLanguageComment(path.getValue(), "HTML") || path.match(node => node.type === "TemplateLiteral", (node, name) => node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "html" && name === "quasi");
40858 function hasInvalidCookedValue({
40861 return quasis.some(({
40865 }) => cooked === null);
40868 var embed_1$4 = embed$a;
40871 isBlockComment: isBlockComment$4
40873 const ignoredProperties$4 = new Set(["range", "raw", "comments", "leadingComments", "trailingComments", "innerComments", "extra", "start", "end", "loc", "flags", "errors", "tokens"]);
40875 const removeTemplateElementsValue = node => {
40876 for (const templateElement of node.quasis) {
40877 delete templateElement.value;
40881 function clean$c(ast, newObj, parent) {
40882 if (ast.type === "Program") {
40883 delete newObj.sourceType;
40886 if (ast.type === "BigIntLiteral" || ast.type === "BigIntLiteralTypeAnnotation") {
40887 if (newObj.value) {
40888 newObj.value = newObj.value.toLowerCase();
40892 if (ast.type === "BigIntLiteral" || ast.type === "Literal") {
40893 if (newObj.bigint) {
40894 newObj.bigint = newObj.bigint.toLowerCase();
40898 if (ast.type === "DecimalLiteral") {
40899 newObj.value = Number(newObj.value);
40902 if (ast.type === "Literal" && newObj.decimal) {
40903 newObj.decimal = Number(newObj.decimal);
40904 } // We remove extra `;` and add them when needed
40907 if (ast.type === "EmptyStatement") {
40909 } // We move text around, including whitespaces and add {" "}
40912 if (ast.type === "JSXText") {
40916 if (ast.type === "JSXExpressionContainer" && (ast.expression.type === "Literal" || ast.expression.type === "StringLiteral") && ast.expression.value === " ") {
40918 } // We change {'key': value} into {key: value}.
40919 // And {key: value} into {'key': value}.
40920 // Also for (some) number keys.
40923 if ((ast.type === "Property" || ast.type === "ObjectProperty" || ast.type === "MethodDefinition" || ast.type === "ClassProperty" || ast.type === "ClassMethod" || ast.type === "PropertyDefinition" || ast.type === "TSDeclareMethod" || ast.type === "TSPropertySignature" || ast.type === "ObjectTypeProperty") && typeof ast.key === "object" && ast.key && (ast.key.type === "Literal" || ast.key.type === "NumericLiteral" || ast.key.type === "StringLiteral" || ast.key.type === "Identifier")) {
40925 } // Remove raw and cooked values from TemplateElement when it's CSS
40929 if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some(attr => attr.name.name === "jsx")) {
40933 } of newObj.children) {
40934 if (type === "JSXExpressionContainer" && expression.type === "TemplateLiteral") {
40935 removeTemplateElementsValue(expression);
40938 } // CSS template literals in css prop
40941 if (ast.type === "JSXAttribute" && ast.name.name === "css" && ast.value.type === "JSXExpressionContainer" && ast.value.expression.type === "TemplateLiteral") {
40942 removeTemplateElementsValue(newObj.value.expression);
40943 } // We change quotes
40946 if (ast.type === "JSXAttribute" && ast.value && ast.value.type === "Literal" && /["']|"|'/.test(ast.value.value)) {
40947 newObj.value.value = newObj.value.value.replace(/["']|"|'/g, '"');
40948 } // Angular Components: Inline HTML template and Inline CSS styles
40951 const expression = ast.expression || ast.callee;
40953 if (ast.type === "Decorator" && expression.type === "CallExpression" && expression.callee.name === "Component" && expression.arguments.length === 1) {
40954 const astProps = ast.expression.arguments[0].properties;
40956 for (const [index, prop] of newObj.expression.arguments[0].properties.entries()) {
40957 switch (astProps[index].key.name) {
40959 if (prop.value.type === "ArrayExpression") {
40960 removeTemplateElementsValue(prop.value.elements[0]);
40966 if (prop.value.type === "TemplateLiteral") {
40967 removeTemplateElementsValue(prop.value);
40973 } // styled-components, graphql, markdown
40976 if (ast.type === "TaggedTemplateExpression" && (ast.tag.type === "MemberExpression" || ast.tag.type === "Identifier" && (ast.tag.name === "gql" || ast.tag.name === "graphql" || ast.tag.name === "css" || ast.tag.name === "md" || ast.tag.name === "markdown" || ast.tag.name === "html") || ast.tag.type === "CallExpression")) {
40977 removeTemplateElementsValue(newObj.quasi);
40980 if (ast.type === "TemplateLiteral") {
40981 // This checks for a leading comment that is exactly `/* GraphQL */`
40982 // In order to be in line with other implementations of this comment tag
40983 // we will not trim the comment value and we will expect exactly one space on
40984 // either side of the GraphQL string
40985 // Also see ./embed.js
40986 const hasLanguageComment = ast.leadingComments && ast.leadingComments.some(comment => isBlockComment$4(comment) && ["GraphQL", "HTML"].some(languageName => comment.value === ` ${languageName} `));
40988 if (hasLanguageComment || parent.type === "CallExpression" && parent.callee.name === "graphql" || // TODO: check parser
40989 // `flow` and `typescript` don't have `leadingComments`
40990 !ast.leadingComments) {
40991 removeTemplateElementsValue(newObj);
40995 if (ast.type === "InterpreterDirective") {
40996 newObj.value = newObj.value.trimEnd();
40997 } // Prettier removes degenerate union and intersection types with only one member.
41000 if ((ast.type === "TSIntersectionType" || ast.type === "TSUnionType") && ast.types.length === 1) {
41001 return newObj.types[0];
41005 clean$c.ignoredProperties = ignoredProperties$4;
41006 var clean_1$4 = clean$c;
41010 var detectNewline$1 = {exports: {}};
41012 const detectNewline = string => {
41013 if (typeof string !== 'string') {
41014 throw new TypeError('Expected a string');
41017 const newlines = string.match(/(?:\r?\n)/g) || [];
41019 if (newlines.length === 0) {
41023 const crlf = newlines.filter(newline => newline === '\r\n').length;
41024 const lf = newlines.length - crlf;
41025 return crlf > lf ? '\r\n' : '\n';
41028 detectNewline$1.exports = detectNewline;
41030 detectNewline$1.exports.graceful = string => typeof string === 'string' && detectNewline(string) || '\n';
41032 Object.defineProperty(build, '__esModule', {
41035 build.extract = extract$1;
41036 build.strip = strip$1;
41037 build.parse = parse$1;
41038 build.parseWithComments = parseWithComments$1;
41039 build.print = print$3;
41042 const data = require$$0__default$1["default"];
41044 _os = function () {
41051 function _detectNewline() {
41052 const data = _interopRequireDefault(detectNewline$1.exports);
41054 _detectNewline = function () {
41061 function _interopRequireDefault(obj) {
41062 return obj && obj.__esModule ? obj : {
41067 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
41069 * This source code is licensed under the MIT license found in the
41070 * LICENSE file in the root directory of this source tree.
41074 const commentEndRe = /\*\/$/;
41075 const commentStartRe = /^\/\*\*/;
41076 const docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
41077 const lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
41078 const ltrimNewlineRe = /^(\r?\n)+/;
41079 const multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
41080 const propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
41081 const stringStartRe = /(\r?\n|^) *\* ?/g;
41082 const STRING_ARRAY = [];
41084 function extract$1(contents) {
41085 const match = contents.match(docblockRe);
41086 return match ? match[0].trimLeft() : '';
41089 function strip$1(contents) {
41090 const match = contents.match(docblockRe);
41091 return match && match[0] ? contents.substring(match[0].length) : contents;
41094 function parse$1(docblock) {
41095 return parseWithComments$1(docblock).pragmas;
41098 function parseWithComments$1(docblock) {
41099 const line = (0, _detectNewline().default)(docblock) || _os().EOL;
41101 docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); // Normalize multi-line directives
41105 while (prev !== docblock) {
41107 docblock = docblock.replace(multilineRe, `${line}$1 $2${line}`);
41110 docblock = docblock.replace(ltrimNewlineRe, '').trimRight();
41111 const result = Object.create(null);
41112 const comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight();
41115 while (match = propertyRe.exec(docblock)) {
41116 // strip linecomments from pragmas
41117 const nextPragma = match[2].replace(lineCommentRe, '');
41119 if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) {
41120 result[match[1]] = STRING_ARRAY.concat(result[match[1]], nextPragma);
41122 result[match[1]] = nextPragma;
41136 const line = (0, _detectNewline().default)(comments) || _os().EOL;
41138 const head = '/**';
41139 const start = ' *';
41140 const tail = ' */';
41141 const keys = Object.keys(pragmas);
41142 const printedObject = keys.map(key => printKeyValues(key, pragmas[key])).reduce((arr, next) => arr.concat(next), []).map(keyValue => start + ' ' + keyValue + line).join('');
41145 if (keys.length === 0) {
41149 if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) {
41150 const value = pragmas[keys[0]];
41151 return `${head} ${printKeyValues(keys[0], value)[0]}${tail}`;
41155 const printedComments = comments.split(line).map(textLine => `${start} ${textLine}`).join(line) + line;
41156 return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail;
41159 function printKeyValues(key, valueOrArray) {
41160 return STRING_ARRAY.concat(valueOrArray).map(value => `@${key} ${value}`.trim());
41176 function parseDocBlock(text) {
41177 const shebang = getShebang(text);
41180 text = text.slice(shebang.length + 1);
41183 const docBlock = extract(text);
41187 } = parseWithComments(docBlock);
41196 function hasPragma$4(text) {
41197 const pragmas = Object.keys(parseDocBlock(text).pragmas);
41198 return pragmas.includes("prettier") || pragmas.includes("format");
41201 function insertPragma$a(originalText) {
41207 } = parseDocBlock(originalText);
41208 const strippedText = strip(text);
41209 const docBlock = print$2({
41210 pragmas: Object.assign({
41213 comments: comments.trimStart()
41215 return (shebang ? `${shebang}\n` : "") + // normalise newlines (mitigate use of os.EOL by jest-docblock)
41216 normalizeEndOfLine(docBlock) + (strippedText.startsWith("\n") ? "\n" : "\n\n") + strippedText;
41220 hasPragma: hasPragma$4,
41221 insertPragma: insertPragma$a
41225 getLast: getLast$j,
41226 hasNewline: hasNewline$6,
41227 getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
41228 getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter$1,
41229 hasNewlineInRange: hasNewlineInRange$3,
41231 addTrailingComment,
41232 addDanglingComment,
41233 getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$2,
41234 isNonEmptyArray: isNonEmptyArray$f
41237 isBlockComment: isBlockComment$3,
41238 getFunctionParameters: getFunctionParameters$5,
41239 isPrettierIgnoreComment,
41240 isJsxNode: isJsxNode$6,
41241 hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$2,
41242 hasFlowAnnotationComment: hasFlowAnnotationComment$1,
41243 hasIgnoreComment: hasIgnoreComment$1,
41244 isCallLikeExpression: isCallLikeExpression$1,
41245 getCallArguments: getCallArguments$4,
41246 isCallExpression: isCallExpression$c,
41247 isMemberExpression: isMemberExpression$8,
41248 isObjectProperty: isObjectProperty$4,
41249 getComments: getComments$4,
41250 CommentCheckFlags: CommentCheckFlags$e
41253 locStart: locStart$p,
41257 * @typedef {import("./types/estree").Node} Node
41258 * @typedef {import("./types/estree").Comment} Comment
41259 * @typedef {import("../common/ast-path")} AstPath
41261 * @typedef {Object} CommentContext
41262 * @property {Comment} comment
41263 * @property {Node} precedingNode
41264 * @property {Node} enclosingNode
41265 * @property {Node} followingNode
41266 * @property {string} text
41267 * @property {any} options
41268 * @property {Node} ast
41269 * @property {boolean} isLastComment
41273 * @param {CommentContext} context
41274 * @returns {boolean}
41277 function handleOwnLineComment(context) {
41278 return [handleIgnoreComments, handleLastFunctionArgComments, handleMemberExpressionComments, handleIfStatementComments, handleWhileComments, handleTryStatementComments, handleClassComments, handleImportSpecifierComments, handleForComments, handleUnionTypeComments, handleOnlyComments, handleImportDeclarationComments, handleAssignmentPatternComments, handleMethodNameComments, handleLabeledStatementComments].some(fn => fn(context));
41281 * @param {CommentContext} context
41282 * @returns {boolean}
41286 function handleEndOfLineComment(context) {
41287 return [handleClosureTypeCastComments, handleLastFunctionArgComments, handleConditionalExpressionComments, handleImportSpecifierComments, handleIfStatementComments, handleWhileComments, handleTryStatementComments, handleClassComments, handleLabeledStatementComments, handleCallExpressionComments, handlePropertyComments, handleOnlyComments, handleTypeAliasComments, handleVariableDeclaratorComments].some(fn => fn(context));
41290 * @param {CommentContext} context
41291 * @returns {boolean}
41295 function handleRemainingComment(context) {
41296 return [handleIgnoreComments, handleIfStatementComments, handleWhileComments, handleObjectPropertyAssignment, handleCommentInEmptyParens, handleMethodNameComments, handleOnlyComments, handleCommentAfterArrowParams, handleFunctionNameComments, handleTSMappedTypeComments, handleBreakAndContinueStatementComments, handleTSFunctionTrailingComments].some(fn => fn(context));
41299 * @param {Node} node
41304 function addBlockStatementFirstComment(node, comment) {
41305 // @ts-expect-error
41306 const firstNonEmptyNode = (node.body || node.properties).find(({
41308 }) => type !== "EmptyStatement");
41310 if (firstNonEmptyNode) {
41311 addLeadingComment(firstNonEmptyNode, comment);
41313 addDanglingComment(node, comment);
41317 * @param {Node} node
41322 function addBlockOrNotComment(node, comment) {
41323 if (node.type === "BlockStatement") {
41324 addBlockStatementFirstComment(node, comment);
41326 addLeadingComment(node, comment);
41330 function handleClosureTypeCastComments({
41334 if (followingNode && isTypeCastComment(comment)) {
41335 addLeadingComment(followingNode, comment);
41340 } // There are often comments before the else clause of if statements like
41346 // They are being attached as leading comments of the BlockExpression which
41347 // is not well printed. What we want is to instead move the comment inside
41348 // of the block and make it leadingComment of the first element of the block
41349 // or dangling comment of the block if there is nothing inside
41358 function handleIfStatementComments({
41365 if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
41367 } // We unfortunately have no way using the AST or location of nodes to know
41368 // if the comment is positioned before the condition parenthesis:
41369 // if (a /* comment */) {}
41370 // The only workaround I found is to look at the next character to see if
41374 const nextCharacter = getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o);
41376 if (nextCharacter === ")") {
41377 addTrailingComment(precedingNode, comment);
41379 } // Comments before `else`:
41380 // - treat as trailing comments of the consequent, if it's a BlockStatement
41381 // - treat as a dangling comment otherwise
41384 if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
41385 if (precedingNode.type === "BlockStatement") {
41386 addTrailingComment(precedingNode, comment);
41388 addDanglingComment(enclosingNode, comment);
41394 if (followingNode.type === "BlockStatement") {
41395 addBlockStatementFirstComment(followingNode, comment);
41399 if (followingNode.type === "IfStatement") {
41400 addBlockOrNotComment(followingNode.consequent, comment);
41402 } // For comments positioned after the condition parenthesis in an if statement
41403 // before the consequent without brackets on, such as
41404 // if (a) /* comment */ true,
41405 // we look at the next character to see if the following node
41406 // is the consequent for the if statement
41409 if (enclosingNode.consequent === followingNode) {
41410 addLeadingComment(followingNode, comment);
41417 function handleWhileComments({
41424 if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
41426 } // We unfortunately have no way using the AST or location of nodes to know
41427 // if the comment is positioned before the condition parenthesis:
41428 // while (a /* comment */) {}
41429 // The only workaround I found is to look at the next character to see if
41433 const nextCharacter = getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o);
41435 if (nextCharacter === ")") {
41436 addTrailingComment(precedingNode, comment);
41440 if (followingNode.type === "BlockStatement") {
41441 addBlockStatementFirstComment(followingNode, comment);
41445 if (enclosingNode.body === followingNode) {
41446 addLeadingComment(followingNode, comment);
41451 } // Same as IfStatement but for TryStatement
41454 function handleTryStatementComments({
41460 if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
41464 if (enclosingNode.type === "CatchClause" && precedingNode) {
41465 addTrailingComment(precedingNode, comment);
41469 if (followingNode.type === "BlockStatement") {
41470 addBlockStatementFirstComment(followingNode, comment);
41474 if (followingNode.type === "TryStatement") {
41475 addBlockOrNotComment(followingNode.finalizer, comment);
41479 if (followingNode.type === "CatchClause") {
41480 addBlockOrNotComment(followingNode.body, comment);
41487 function handleMemberExpressionComments({
41492 if (isMemberExpression$8(enclosingNode) && followingNode && followingNode.type === "Identifier") {
41493 addLeadingComment(enclosingNode, comment);
41500 function handleConditionalExpressionComments({
41507 const isSameLineAsPrecedingNode = precedingNode && !hasNewlineInRange$3(text, locEnd$o(precedingNode), locStart$p(comment));
41509 if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && (enclosingNode.type === "ConditionalExpression" || enclosingNode.type === "TSConditionalType") && followingNode) {
41510 addLeadingComment(followingNode, comment);
41517 function handleObjectPropertyAssignment({
41522 if (isObjectProperty$4(enclosingNode) && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
41523 addTrailingComment(enclosingNode.value.left, comment);
41530 function handleClassComments({
41536 if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression" || enclosingNode.type === "DeclareClass" || enclosingNode.type === "DeclareInterface" || enclosingNode.type === "InterfaceDeclaration" || enclosingNode.type === "TSInterfaceDeclaration")) {
41537 if (isNonEmptyArray$f(enclosingNode.decorators) && !(followingNode && followingNode.type === "Decorator")) {
41538 addTrailingComment(getLast$j(enclosingNode.decorators), comment);
41542 if (enclosingNode.body && followingNode === enclosingNode.body) {
41543 addBlockStatementFirstComment(enclosingNode.body, comment);
41545 } // Don't add leading comments to `implements`, `extends`, `mixins` to
41546 // avoid printing the comment after the keyword.
41549 if (followingNode) {
41550 for (const prop of ["implements", "extends", "mixins"]) {
41551 if (enclosingNode[prop] && followingNode === enclosingNode[prop][0]) {
41552 if (precedingNode && (precedingNode === enclosingNode.id || precedingNode === enclosingNode.typeParameters || precedingNode === enclosingNode.superClass)) {
41553 addTrailingComment(precedingNode, comment);
41555 addDanglingComment(enclosingNode, comment, prop);
41567 function handleMethodNameComments({
41573 // This is only needed for estree parsers (flow, typescript) to attach
41574 // after a method name:
41575 // obj = { fn /*comment*/() {} };
41576 if (enclosingNode && precedingNode && ( // "MethodDefinition" is handled in getCommentChildNodes
41577 enclosingNode.type === "Property" || enclosingNode.type === "TSDeclareMethod" || enclosingNode.type === "TSAbstractMethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
41578 // comment should be attached to value instead of key
41579 getNextNonSpaceNonCommentCharacter$1(text, precedingNode, locEnd$o) !== ":") {
41580 addTrailingComment(precedingNode, comment);
41582 } // Print comments between decorators and class methods as a trailing comment
41583 // on the decorator node instead of the method node
41586 if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "PropertyDefinition" || enclosingNode.type === "TSAbstractPropertyDefinition" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "TSDeclareMethod" || enclosingNode.type === "MethodDefinition")) {
41587 addTrailingComment(precedingNode, comment);
41594 function handleFunctionNameComments({
41600 if (getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o) !== "(") {
41604 if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
41605 addTrailingComment(precedingNode, comment);
41612 function handleCommentAfterArrowParams({
41617 if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
41621 const index = getNextNonSpaceNonCommentCharacterIndex$2(text, comment, locEnd$o);
41623 if (index !== false && text.slice(index, index + 2) === "=>") {
41624 addDanglingComment(enclosingNode, comment);
41631 function handleCommentInEmptyParens({
41636 if (getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o) !== ")") {
41638 } // Only add dangling comments to fix the case when no params are present,
41639 // i.e. a function without any argument.
41642 if (enclosingNode && (isRealFunctionLikeNode(enclosingNode) && getFunctionParameters$5(enclosingNode).length === 0 || isCallLikeExpression$1(enclosingNode) && getCallArguments$4(enclosingNode).length === 0)) {
41643 addDanglingComment(enclosingNode, comment);
41647 if (enclosingNode && (enclosingNode.type === "MethodDefinition" || enclosingNode.type === "TSAbstractMethodDefinition") && getFunctionParameters$5(enclosingNode.value).length === 0) {
41648 addDanglingComment(enclosingNode.value, comment);
41655 function handleLastFunctionArgComments({
41662 // Flow function type definitions
41663 if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
41664 addTrailingComment(precedingNode, comment);
41666 } // Real functions and TypeScript function type definitions
41669 if (precedingNode && (precedingNode.type === "Identifier" || precedingNode.type === "AssignmentPattern") && enclosingNode && isRealFunctionLikeNode(enclosingNode) && getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o) === ")") {
41670 addTrailingComment(precedingNode, comment);
41674 if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
41675 const functionParamRightParenIndex = (() => {
41676 const parameters = getFunctionParameters$5(enclosingNode);
41678 if (parameters.length > 0) {
41679 return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd$o(getLast$j(parameters)));
41682 const functionParamLeftParenIndex = getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd$o(enclosingNode.id));
41683 return functionParamLeftParenIndex !== false && getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
41686 if (locStart$p(comment) > functionParamRightParenIndex) {
41687 addBlockStatementFirstComment(followingNode, comment);
41695 function handleImportSpecifierComments({
41699 if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
41700 addLeadingComment(enclosingNode, comment);
41707 function handleLabeledStatementComments({
41711 if (enclosingNode && enclosingNode.type === "LabeledStatement") {
41712 addLeadingComment(enclosingNode, comment);
41719 function handleBreakAndContinueStatementComments({
41723 if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
41724 addTrailingComment(enclosingNode, comment);
41731 function handleCallExpressionComments({
41736 if (isCallExpression$c(enclosingNode) && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
41737 addLeadingComment(enclosingNode.arguments[0], comment);
41744 function handleUnionTypeComments({
41750 if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
41751 if (isPrettierIgnoreComment(comment)) {
41752 followingNode.prettierIgnore = true;
41753 comment.unignore = true;
41756 if (precedingNode) {
41757 addTrailingComment(precedingNode, comment);
41764 if (followingNode && (followingNode.type === "UnionTypeAnnotation" || followingNode.type === "TSUnionType") && isPrettierIgnoreComment(comment)) {
41765 followingNode.types[0].prettierIgnore = true;
41766 comment.unignore = true;
41772 function handlePropertyComments({
41776 if (isObjectProperty$4(enclosingNode)) {
41777 addLeadingComment(enclosingNode, comment);
41784 function handleOnlyComments({
41791 // With Flow the enclosingNode is undefined so use the AST instead.
41792 if (ast && ast.body && ast.body.length === 0) {
41793 if (isLastComment) {
41794 addDanglingComment(ast, comment);
41796 addLeadingComment(ast, comment);
41802 if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && !isNonEmptyArray$f(enclosingNode.directives)) {
41803 if (isLastComment) {
41804 addDanglingComment(enclosingNode, comment);
41806 addLeadingComment(enclosingNode, comment);
41812 if (followingNode && followingNode.type === "Program" && followingNode.body.length === 0 && enclosingNode && enclosingNode.type === "ModuleExpression") {
41813 addDanglingComment(followingNode, comment);
41820 function handleForComments({
41824 if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
41825 addLeadingComment(enclosingNode, comment);
41832 function handleImportDeclarationComments({
41838 if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && hasNewline$6(text, locEnd$o(comment))) {
41839 addTrailingComment(precedingNode, comment);
41846 function handleAssignmentPatternComments({
41850 if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
41851 addLeadingComment(enclosingNode, comment);
41858 function handleTypeAliasComments({
41862 if (enclosingNode && enclosingNode.type === "TypeAlias") {
41863 addLeadingComment(enclosingNode, comment);
41870 function handleVariableDeclaratorComments({
41875 if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression" || isBlockComment$3(comment))) {
41876 addLeadingComment(followingNode, comment);
41883 function handleTSFunctionTrailingComments({
41889 if (!followingNode && enclosingNode && (enclosingNode.type === "TSMethodSignature" || enclosingNode.type === "TSDeclareFunction" || enclosingNode.type === "TSAbstractMethodDefinition") && getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o) === ";") {
41890 addTrailingComment(enclosingNode, comment);
41897 function handleIgnoreComments({
41902 if (isPrettierIgnoreComment(comment) && enclosingNode && enclosingNode.type === "TSMappedType" && followingNode && followingNode.type === "TSTypeParameter" && followingNode.constraint) {
41903 enclosingNode.prettierIgnore = true;
41904 comment.unignore = true;
41909 function handleTSMappedTypeComments({
41915 if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
41919 if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
41920 addLeadingComment(followingNode.name, comment);
41924 if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
41925 addTrailingComment(precedingNode.constraint, comment);
41932 * @param {Node} node
41933 * @returns {boolean}
41937 function isRealFunctionLikeNode(node) {
41938 return node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration" || node.type === "ObjectMethod" || node.type === "ClassMethod" || node.type === "TSDeclareFunction" || node.type === "TSCallSignatureDeclaration" || node.type === "TSConstructSignatureDeclaration" || node.type === "TSMethodSignature" || node.type === "TSConstructorType" || node.type === "TSFunctionType" || node.type === "TSDeclareMethod";
41941 * @param {any} node
41942 * @returns {Node[] | void}
41946 function getCommentChildNodes(node, options) {
41947 // Prevent attaching comments to FunctionExpression in this case:
41949 // bar() // comment
41954 if ((options.parser === "typescript" || options.parser === "flow" || options.parser === "espree" || options.parser === "meriyah" || options.parser === "__babel_estree") && node.type === "MethodDefinition" && node.value && node.value.type === "FunctionExpression" && getFunctionParameters$5(node.value).length === 0 && !node.value.returnType && !isNonEmptyArray$f(node.value.typeParameters) && node.value.body) {
41955 return [...(node.decorators || []), node.key, node.value.body];
41959 * @param {Comment} comment
41960 * @returns {boolean}
41964 function isTypeCastComment(comment) {
41965 return isBlockComment$3(comment) && comment.value[0] === "*" && // TypeScript expects the type to be enclosed in curly brackets, however
41966 // Closure Compiler accepts types in parens and even without any delimiters at all.
41967 // That's why we just search for "@type".
41968 /@type\b/.test(comment.value);
41971 * @param {AstPath} path
41972 * @returns {boolean}
41976 function willPrintOwnComments$1(path
41979 const node = path.getValue();
41980 const parent = path.getParentNode();
41982 const hasFlowAnnotations = node => hasFlowAnnotationComment$1(getComments$4(node, CommentCheckFlags$e.Leading)) || hasFlowAnnotationComment$1(getComments$4(node, CommentCheckFlags$e.Trailing));
41984 return (node && (isJsxNode$6(node) || hasFlowShorthandAnnotationComment$2(node) || isCallExpression$c(parent) && hasFlowAnnotations(node)) || parent && (parent.type === "JSXSpreadAttribute" || parent.type === "JSXSpreadChild" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || (parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node)) && (!hasIgnoreComment$1(path) || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType");
41988 handleOwnLineComment,
41989 handleEndOfLineComment,
41990 handleRemainingComment,
41992 getCommentChildNodes,
41993 willPrintOwnComments: willPrintOwnComments$1
41996 const getLast$i = getLast_1;
41998 getFunctionParameters: getFunctionParameters$4,
41999 getLeftSidePathName: getLeftSidePathName$1,
42000 hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$1,
42001 hasNakedLeftSide: hasNakedLeftSide$2,
42002 hasNode: hasNode$1,
42004 startsWithNoLookaheadToken: startsWithNoLookaheadToken$1,
42005 shouldFlatten: shouldFlatten$1,
42007 isCallExpression: isCallExpression$b,
42008 isMemberExpression: isMemberExpression$7,
42009 isObjectProperty: isObjectProperty$3
42012 function needsParens(path, options) {
42013 const parent = path.getParentNode();
42019 const name = path.getName();
42020 const node = path.getNode(); // to avoid unexpected `}}` in HTML interpolations
42022 if (options.__isInHtmlInterpolation && !options.bracketSpacing && endsWithRightBracket(node) && isFollowedByRightBracket(path)) {
42024 } // Only statements don't need parentheses.
42027 if (isStatement(node)) {
42031 if ( // Preserve parens if we have a Flow annotation comment, unless we're using the Flow
42032 // parser. The Flow parser turns Flow comments into type annotation nodes in its
42033 // AST, which we handle separately.
42034 options.parser !== "flow" && hasFlowShorthandAnnotationComment$1(path.getValue())) {
42036 } // Identifiers never need parentheses.
42039 if (node.type === "Identifier") {
42040 // ...unless those identifiers are embed placeholders. They might be substituted by complex
42041 // expressions, so the parens around them should not be dropped. Example (JS-in-HTML-in-JS):
42042 // let tpl = html`<script> f((${expr}) / 2); </script>`;
42043 // If the inner JS formatter removes the parens, the expression might change its meaning:
42044 // f((a + b) / 2) vs f(a + b / 2)
42045 if (node.extra && node.extra.parenthesized && /^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(node.name)) {
42047 } // `for (async of []);` is invalid
42050 if (name === "left" && node.name === "async" && parent.type === "ForOfStatement" && !parent.await) {
42057 switch (parent.type) {
42058 case "ParenthesizedExpression":
42061 case "ClassDeclaration":
42062 case "ClassExpression":
42064 // Add parens around the extends clause of a class. It is needed for almost
42065 // all expressions.
42066 if (name === "superClass" && (node.type === "ArrowFunctionExpression" || node.type === "AssignmentExpression" || node.type === "AwaitExpression" || node.type === "BinaryExpression" || node.type === "ConditionalExpression" || node.type === "LogicalExpression" || node.type === "NewExpression" || node.type === "ObjectExpression" || node.type === "ParenthesizedExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "UnaryExpression" || node.type === "UpdateExpression" || node.type === "YieldExpression" || node.type === "TSNonNullExpression")) {
42073 case "ExportDefaultDeclaration":
42075 return (// `export default function` or `export default class` can't be followed by
42076 // anything after. So an expression like `export default (function(){}).toString()`
42077 // needs to be followed by a parentheses
42078 shouldWrapFunctionForExportDefault(path, options) || // `export default (foo, bar)` also needs parentheses
42079 node.type === "SequenceExpression"
42085 if (name === "expression") {
42086 let hasCallExpression = false;
42087 let hasMemberExpression = false;
42088 let current = node;
42091 switch (current.type) {
42092 case "MemberExpression":
42093 hasMemberExpression = true;
42094 current = current.object;
42097 case "CallExpression":
42100 hasMemberExpression ||
42102 hasCallExpression) {
42103 return options.parser !== "typescript";
42106 hasCallExpression = true;
42107 current = current.callee;
42113 case "TaggedTemplateExpression":
42114 // babel-parser cannot parse
42116 return options.parser !== "typescript";
42129 case "ExpressionStatement":
42131 if (startsWithNoLookaheadToken$1(node,
42132 /* forbidFunctionClassAndDoExpr */
42140 case "ArrowFunctionExpression":
42142 if (name === "body" && node.type !== "SequenceExpression" && // these have parens added anyway
42143 startsWithNoLookaheadToken$1(node,
42144 /* forbidFunctionClassAndDoExpr */
42153 switch (node.type) {
42154 case "UpdateExpression":
42155 if (parent.type === "UnaryExpression") {
42156 return node.prefix && (node.operator === "++" && parent.operator === "+" || node.operator === "--" && parent.operator === "-");
42159 // else fallthrough
42161 case "UnaryExpression":
42162 switch (parent.type) {
42163 case "UnaryExpression":
42164 return node.operator === parent.operator && (node.operator === "+" || node.operator === "-");
42166 case "BindExpression":
42169 case "MemberExpression":
42170 case "OptionalMemberExpression":
42171 return name === "object";
42173 case "TaggedTemplateExpression":
42176 case "NewExpression":
42177 case "CallExpression":
42178 case "OptionalCallExpression":
42179 return name === "callee";
42181 case "BinaryExpression":
42182 return name === "left" && parent.operator === "**";
42184 case "TSNonNullExpression":
42191 case "BinaryExpression":
42193 if (parent.type === "UpdateExpression") {
42195 } // We add parentheses to any `a in b` inside `ForStatement` initializer
42196 // https://github.com/prettier/prettier/issues/907#issuecomment-284304321
42199 if (node.operator === "in" && isPathInForStatementInitializer(path)) {
42203 if (node.operator === "|>" && node.extra && node.extra.parenthesized) {
42204 const grandParent = path.getParentNode(1);
42206 if (grandParent.type === "BinaryExpression" && grandParent.operator === "|>") {
42213 case "TSTypeAssertion":
42214 case "TSAsExpression":
42215 case "LogicalExpression":
42216 switch (parent.type) {
42217 case "TSAsExpression":
42218 // example: foo as unknown as Bar
42219 return node.type !== "TSAsExpression";
42221 case "ConditionalExpression":
42222 return node.type === "TSAsExpression";
42224 case "CallExpression":
42225 case "NewExpression":
42226 case "OptionalCallExpression":
42227 return name === "callee";
42229 case "ClassExpression":
42230 case "ClassDeclaration":
42231 return name === "superClass";
42233 case "TSTypeAssertion":
42234 case "TaggedTemplateExpression":
42235 case "UnaryExpression":
42236 case "JSXSpreadAttribute":
42237 case "SpreadElement":
42238 case "SpreadProperty":
42239 case "BindExpression":
42240 case "AwaitExpression":
42241 case "TSNonNullExpression":
42242 case "UpdateExpression":
42245 case "MemberExpression":
42246 case "OptionalMemberExpression":
42247 return name === "object";
42249 case "AssignmentExpression":
42250 case "AssignmentPattern":
42251 return name === "left" && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
42253 case "LogicalExpression":
42254 if (node.type === "LogicalExpression") {
42255 return parent.operator !== node.operator;
42258 // else fallthrough
42260 case "BinaryExpression":
42267 if (!operator && type !== "TSTypeAssertion") {
42271 const precedence = getPrecedence(operator);
42272 const parentOperator = parent.operator;
42273 const parentPrecedence = getPrecedence(parentOperator);
42275 if (parentPrecedence > precedence) {
42279 if (name === "right" && parentPrecedence === precedence) {
42283 if (parentPrecedence === precedence && !shouldFlatten$1(parentOperator, operator)) {
42287 if (parentPrecedence < precedence && operator === "%") {
42288 return parentOperator === "+" || parentOperator === "-";
42289 } // Add parenthesis when working with bitwise operators
42290 // It's not strictly needed but helps with code understanding
42293 if (isBitwiseOperator(parentOperator)) {
42304 case "SequenceExpression":
42305 switch (parent.type) {
42306 case "ReturnStatement":
42309 case "ForStatement":
42310 // Although parentheses wouldn't hurt around sequence
42311 // expressions in the head of for loops, traditional style
42312 // dictates that e.g. i++, j++ should not be wrapped with
42316 case "ExpressionStatement":
42317 return name !== "expression";
42319 case "ArrowFunctionExpression":
42320 // We do need parentheses, but SequenceExpressions are handled
42321 // specially when printing bodies of arrow functions.
42322 return name !== "body";
42325 // Otherwise err on the side of overparenthesization, adding
42326 // explicit exceptions above if this proves overzealous.
42330 case "YieldExpression":
42331 if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || parent.type === "TSAsExpression" || parent.type === "TSNonNullExpression") {
42335 // else fallthrough
42337 case "AwaitExpression":
42338 switch (parent.type) {
42339 case "TaggedTemplateExpression":
42340 case "UnaryExpression":
42341 case "LogicalExpression":
42342 case "SpreadElement":
42343 case "SpreadProperty":
42344 case "TSAsExpression":
42345 case "TSNonNullExpression":
42346 case "BindExpression":
42349 case "MemberExpression":
42350 case "OptionalMemberExpression":
42351 return name === "object";
42353 case "NewExpression":
42354 case "CallExpression":
42355 case "OptionalCallExpression":
42356 return name === "callee";
42358 case "ConditionalExpression":
42359 return name === "test";
42361 case "BinaryExpression":
42363 if (!node.argument && parent.operator === "|>") {
42374 case "TSConditionalType":
42375 if (name === "extendsType" && parent.type === "TSConditionalType") {
42381 case "TSFunctionType":
42382 case "TSConstructorType":
42383 if (name === "checkType" && parent.type === "TSConditionalType") {
42389 case "TSUnionType":
42390 case "TSIntersectionType":
42391 if ((parent.type === "TSUnionType" || parent.type === "TSIntersectionType") && parent.types.length > 1 && (!node.types || node.types.length > 1)) {
42397 case "TSInferType":
42398 if (node.type === "TSInferType" && parent.type === "TSRestType") {
42404 case "TSTypeOperator":
42405 return parent.type === "TSArrayType" || parent.type === "TSOptionalType" || parent.type === "TSRestType" || name === "objectType" && parent.type === "TSIndexedAccessType" || parent.type === "TSTypeOperator" || parent.type === "TSTypeAnnotation" && path.getParentNode(1).type.startsWith("TSJSDoc");
42407 case "ArrayTypeAnnotation":
42408 return parent.type === "NullableTypeAnnotation";
42410 case "IntersectionTypeAnnotation":
42411 case "UnionTypeAnnotation":
42412 return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation" || name === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType");
42414 case "NullableTypeAnnotation":
42415 return parent.type === "ArrayTypeAnnotation" || name === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType");
42417 case "FunctionTypeAnnotation":
42419 const ancestor = parent.type === "NullableTypeAnnotation" ? path.getParentNode(1) : parent;
42420 return ancestor.type === "UnionTypeAnnotation" || ancestor.type === "IntersectionTypeAnnotation" || ancestor.type === "ArrayTypeAnnotation" || name === "objectType" && (ancestor.type === "IndexedAccessType" || ancestor.type === "OptionalIndexedAccessType") || // We should check ancestor's parent to know whether the parentheses
42421 // are really needed, but since ??T doesn't make sense this check
42422 // will almost never be true.
42423 ancestor.type === "NullableTypeAnnotation" || // See #5283
42424 parent.type === "FunctionTypeParam" && parent.name === null && getFunctionParameters$4(node).some(param => param.typeAnnotation && param.typeAnnotation.type === "NullableTypeAnnotation");
42427 case "OptionalIndexedAccessType":
42428 return name === "objectType" && parent.type === "IndexedAccessType";
42430 case "TypeofTypeAnnotation":
42431 return name === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType");
42433 case "StringLiteral":
42434 case "NumericLiteral":
42436 if (typeof node.value === "string" && parent.type === "ExpressionStatement" && !parent.directive) {
42437 // To avoid becoming a directive
42438 const grandParent = path.getParentNode(1);
42439 return grandParent.type === "Program" || grandParent.type === "BlockStatement";
42442 return name === "object" && parent.type === "MemberExpression" && typeof node.value === "number";
42444 case "AssignmentExpression":
42446 const grandParent = path.getParentNode(1);
42448 if (name === "body" && parent.type === "ArrowFunctionExpression") {
42452 if (name === "key" && (parent.type === "ClassProperty" || parent.type === "PropertyDefinition") && parent.computed) {
42456 if ((name === "init" || name === "update") && parent.type === "ForStatement") {
42460 if (parent.type === "ExpressionStatement") {
42461 return node.left.type === "ObjectPattern";
42464 if (name === "key" && parent.type === "TSPropertySignature") {
42468 if (parent.type === "AssignmentExpression") {
42472 if (parent.type === "SequenceExpression" && grandParent && grandParent.type === "ForStatement" && (grandParent.init === parent || grandParent.update === parent)) {
42476 if (name === "value" && parent.type === "Property" && grandParent && grandParent.type === "ObjectPattern" && grandParent.properties.includes(parent)) {
42480 if (parent.type === "NGChainedExpression") {
42487 case "ConditionalExpression":
42488 switch (parent.type) {
42489 case "TaggedTemplateExpression":
42490 case "UnaryExpression":
42491 case "SpreadElement":
42492 case "SpreadProperty":
42493 case "BinaryExpression":
42494 case "LogicalExpression":
42495 case "NGPipeExpression":
42496 case "ExportDefaultDeclaration":
42497 case "AwaitExpression":
42498 case "JSXSpreadAttribute":
42499 case "TSTypeAssertion":
42500 case "TypeCastExpression":
42501 case "TSAsExpression":
42502 case "TSNonNullExpression":
42505 case "NewExpression":
42506 case "CallExpression":
42507 case "OptionalCallExpression":
42508 return name === "callee";
42510 case "ConditionalExpression":
42511 return name === "test";
42513 case "MemberExpression":
42514 case "OptionalMemberExpression":
42515 return name === "object";
42521 case "FunctionExpression":
42522 switch (parent.type) {
42523 case "NewExpression":
42524 case "CallExpression":
42525 case "OptionalCallExpression":
42526 // Not always necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
42527 // Is necessary if it is `expression` of `ExpressionStatement`.
42528 return name === "callee";
42530 case "TaggedTemplateExpression":
42532 // This is basically a kind of IIFE.
42538 case "ArrowFunctionExpression":
42539 switch (parent.type) {
42540 case "BinaryExpression":
42541 return parent.operator !== "|>" || node.extra && node.extra.parenthesized;
42543 case "NewExpression":
42544 case "CallExpression":
42545 case "OptionalCallExpression":
42546 return name === "callee";
42548 case "MemberExpression":
42549 case "OptionalMemberExpression":
42550 return name === "object";
42552 case "TSAsExpression":
42553 case "TSNonNullExpression":
42554 case "BindExpression":
42555 case "TaggedTemplateExpression":
42556 case "UnaryExpression":
42557 case "LogicalExpression":
42558 case "AwaitExpression":
42559 case "TSTypeAssertion":
42562 case "ConditionalExpression":
42563 return name === "test";
42569 case "ClassExpression":
42570 switch (parent.type) {
42571 case "NewExpression":
42572 return name === "callee";
42578 case "OptionalMemberExpression":
42579 case "OptionalCallExpression":
42581 const parentParent = path.getParentNode(1);
42583 if (name === "object" && parent.type === "MemberExpression" || name === "callee" && (parent.type === "CallExpression" || parent.type === "NewExpression") || parent.type === "TSNonNullExpression" && parentParent.type === "MemberExpression" && parentParent.object === parent) {
42589 case "CallExpression":
42590 case "MemberExpression":
42591 case "TaggedTemplateExpression":
42592 case "TSNonNullExpression":
42593 if (name === "callee" && (parent.type === "BindExpression" || parent.type === "NewExpression")) {
42597 switch (object.type) {
42598 case "CallExpression":
42599 case "OptionalCallExpression":
42602 case "MemberExpression":
42603 case "OptionalMemberExpression":
42604 case "BindExpression":
42605 object = object.object;
42607 // tagged templates are basically member expressions from a grammar perspective
42608 // see https://tc39.github.io/ecma262/#prod-MemberExpression
42610 case "TaggedTemplateExpression":
42611 object = object.tag;
42614 case "TSNonNullExpression":
42615 object = object.expression;
42626 case "BindExpression":
42627 return name === "callee" && (parent.type === "BindExpression" || parent.type === "NewExpression") || name === "object" && isMemberExpression$7(parent);
42629 case "NGPipeExpression":
42630 if (parent.type === "NGRoot" || parent.type === "NGMicrosyntaxExpression" || parent.type === "ObjectProperty" && // Preserve parens for compatibility with AngularJS expressions
42631 !(node.extra && node.extra.parenthesized) || parent.type === "ArrayExpression" || isCallExpression$b(parent) && parent.arguments[name] === node || name === "right" && parent.type === "NGPipeExpression" || name === "property" && parent.type === "MemberExpression" || parent.type === "AssignmentExpression") {
42637 case "JSXFragment":
42639 return name === "callee" || name === "left" && parent.type === "BinaryExpression" && parent.operator === "<" || parent.type !== "ArrayExpression" && parent.type !== "ArrowFunctionExpression" && parent.type !== "AssignmentExpression" && parent.type !== "AssignmentPattern" && parent.type !== "BinaryExpression" && parent.type !== "NewExpression" && parent.type !== "ConditionalExpression" && parent.type !== "ExpressionStatement" && parent.type !== "JsExpressionRoot" && parent.type !== "JSXAttribute" && parent.type !== "JSXElement" && parent.type !== "JSXExpressionContainer" && parent.type !== "JSXFragment" && parent.type !== "LogicalExpression" && !isCallExpression$b(parent) && !isObjectProperty$3(parent) && parent.type !== "ReturnStatement" && parent.type !== "ThrowStatement" && parent.type !== "TypeCastExpression" && parent.type !== "VariableDeclarator" && parent.type !== "YieldExpression";
42641 case "TypeAnnotation":
42642 return name === "returnType" && parent.type === "ArrowFunctionExpression" && includesFunctionTypeInObjectType(node);
42648 function isStatement(node) {
42649 return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "PropertyDefinition" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "EnumDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
42652 function isPathInForStatementInitializer(path) {
42654 let node = path.getValue();
42657 const parent = path.getParentNode(i++);
42659 if (parent && parent.type === "ForStatement" && parent.init === node) {
42669 function includesFunctionTypeInObjectType(node) {
42670 return hasNode$1(node, n1 => n1.type === "ObjectTypeAnnotation" && hasNode$1(n1, n2 => n2.type === "FunctionTypeAnnotation" || undefined) || undefined);
42673 function endsWithRightBracket(node) {
42674 switch (node.type) {
42675 case "ObjectExpression":
42683 function isFollowedByRightBracket(path) {
42684 const node = path.getValue();
42685 const parent = path.getParentNode();
42686 const name = path.getName();
42688 switch (parent.type) {
42689 case "NGPipeExpression":
42690 if (typeof name === "number" && parent.arguments[name] === node && parent.arguments.length - 1 === name) {
42691 return path.callParent(isFollowedByRightBracket);
42696 case "ObjectProperty":
42697 if (name === "value") {
42698 const parentParent = path.getParentNode(1);
42699 return getLast$i(parentParent.properties) === parent;
42704 case "BinaryExpression":
42705 case "LogicalExpression":
42706 if (name === "right") {
42707 return path.callParent(isFollowedByRightBracket);
42712 case "ConditionalExpression":
42713 if (name === "alternate") {
42714 return path.callParent(isFollowedByRightBracket);
42719 case "UnaryExpression":
42720 if (parent.prefix) {
42721 return path.callParent(isFollowedByRightBracket);
42730 function shouldWrapFunctionForExportDefault(path, options) {
42731 const node = path.getValue();
42732 const parent = path.getParentNode();
42734 if (node.type === "FunctionExpression" || node.type === "ClassExpression") {
42735 return parent.type === "ExportDefaultDeclaration" || // in some cases the function is already wrapped
42736 // (e.g. `export default (function() {})();`)
42737 // in this case we don't need to add extra parens
42738 !needsParens(path, options);
42741 if (!hasNakedLeftSide$2(node) || parent.type !== "ExportDefaultDeclaration" && needsParens(path, options)) {
42745 return path.call(childPath => shouldWrapFunctionForExportDefault(childPath, options), ...getLeftSidePathName$1(path, node));
42748 var needsParens_1 = needsParens;
42750 function preprocess$8(ast, options) {
42751 switch (options.parser) {
42754 case "json-stringify":
42755 case "__js_expression":
42756 case "__vue_expression":
42757 return Object.assign(Object.assign({}, ast), {}, {
42758 type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
42761 rootMarker: options.rootMarker
42769 var printPreprocess$3 = preprocess$8;
42776 softline: softline$q,
42781 function printHtmlBinding$1(path, options, print) {
42782 const node = path.getValue();
42784 if (options.__onHtmlBindingRoot && path.getName() === null) {
42785 options.__onHtmlBindingRoot(node, options);
42788 if (node.type !== "File") {
42792 if (options.__isVueForBindingLeft) {
42793 return path.call(functionDeclarationPath => {
42794 const printed = join$s([",", line$x], functionDeclarationPath.map(print, "params"));
42797 } = functionDeclarationPath.getValue();
42799 if (params.length === 1) {
42803 return ["(", indent$t([softline$q, group$A(printed)]), softline$q, ")"];
42804 }, "program", "body", 0);
42807 if (options.__isVueBindings) {
42808 return path.call(functionDeclarationPath => join$s([",", line$x], functionDeclarationPath.map(print, "params")), "program", "body", 0);
42810 } // based on https://github.com/prettier/prettier/blob/main/src/language-html/syntax-vue.js isVueEventBindingExpression()
42813 function isVueEventBindingExpression$3(node) {
42814 switch (node.type) {
42815 case "MemberExpression":
42816 switch (node.property.type) {
42818 case "NumericLiteral":
42819 case "StringLiteral":
42820 return isVueEventBindingExpression$3(node.object);
42833 var htmlBinding = {
42834 isVueEventBindingExpression: isVueEventBindingExpression$3,
42835 printHtmlBinding: printHtmlBinding$1
42839 printComments: printComments$5
42848 softline: softline$p,
42852 ifBreak: ifBreak$m,
42853 indentIfBreak: indentIfBreak$3
42856 cleanDoc: cleanDoc$2,
42857 getDocParts: getDocParts$6,
42858 isConcat: isConcat$1
42862 hasLeadingOwnLineComment: hasLeadingOwnLineComment$3,
42863 isBinaryish: isBinaryish$3,
42864 isJsxNode: isJsxNode$5,
42866 hasComment: hasComment$g,
42867 CommentCheckFlags: CommentCheckFlags$d,
42868 isCallExpression: isCallExpression$a,
42869 isMemberExpression: isMemberExpression$6,
42870 isObjectProperty: isObjectProperty$2,
42871 isEnabledHackPipeline
42873 /** @typedef {import("../../document").Doc} Doc */
42877 function printBinaryishExpression$2(path, options, print) {
42878 const node = path.getValue();
42879 const parent = path.getParentNode();
42880 const parentParent = path.getParentNode(1);
42881 const isInsideParenthesis = node !== parent.body && (parent.type === "IfStatement" || parent.type === "WhileStatement" || parent.type === "SwitchStatement" || parent.type === "DoWhileStatement");
42882 const isHackPipeline = isEnabledHackPipeline(options) && node.operator === "|>";
42883 const parts = printBinaryishExpressions(path, print, options,
42885 false, isInsideParenthesis); // if (
42886 // this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft
42889 // looks super weird, we want to break the children if the parent breaks
42892 // this.hasPlugin("dynamicImports") &&
42893 // this.lookahead().type === tt.parenLeft
42896 if (isInsideParenthesis) {
42900 if (isHackPipeline) {
42901 return group$z(parts);
42902 } // Break between the parens in
42903 // unaries or in a member or specific call expression, i.e.
42912 if (isCallExpression$a(parent) && parent.callee === node || parent.type === "UnaryExpression" || isMemberExpression$6(parent) && !parent.computed) {
42913 return group$z([indent$s([softline$p, ...parts]), softline$p]);
42914 } // Avoid indenting sub-expressions in some cases where the first sub-expression is already
42915 // indented accordingly. We should indent sub-expressions where the first case isn't indented.
42918 const shouldNotIndent = parent.type === "ReturnStatement" || parent.type === "ThrowStatement" || parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" || node.operator !== "|" && parent.type === "JsExpressionRoot" || node.type !== "NGPipeExpression" && (parent.type === "NGRoot" && options.parser === "__ng_binding" || parent.type === "NGMicrosyntaxExpression" && parentParent.type === "NGMicrosyntax" && parentParent.body.length === 1) || node === parent.body && parent.type === "ArrowFunctionExpression" || node !== parent.body && parent.type === "ForStatement" || parent.type === "ConditionalExpression" && parentParent.type !== "ReturnStatement" && parentParent.type !== "ThrowStatement" && !isCallExpression$a(parentParent) || parent.type === "TemplateLiteral";
42919 const shouldIndentIfInlining = parent.type === "AssignmentExpression" || parent.type === "VariableDeclarator" || parent.type === "ClassProperty" || parent.type === "PropertyDefinition" || parent.type === "TSAbstractPropertyDefinition" || parent.type === "ClassPrivateProperty" || isObjectProperty$2(parent);
42920 const samePrecedenceSubExpression = isBinaryish$3(node.left) && shouldFlatten(node.operator, node.left.operator);
42922 if (shouldNotIndent || shouldInlineLogicalExpression$1(node) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression$1(node) && shouldIndentIfInlining) {
42923 return group$z(parts);
42926 if (parts.length === 0) {
42928 } // If the right part is a JSX node, we include it in a separate group to
42929 // prevent it breaking the whole chain, so we can print the expression like:
42938 const hasJsx = isJsxNode$5(node.right);
42939 const firstGroupIndex = parts.findIndex(part => typeof part !== "string" && !Array.isArray(part) && part.type === "group"); // Separate the leftmost expression, possibly with its leading comments.
42941 const headParts = parts.slice(0, firstGroupIndex === -1 ? 1 : firstGroupIndex + 1);
42942 const rest = parts.slice(headParts.length, hasJsx ? -1 : undefined);
42943 const groupId = Symbol("logicalChain-" + ++uid);
42944 const chain = group$z([// Don't include the initial expression in the indentation
42945 // level. The first item is guaranteed to be the first
42946 // left-most expression.
42947 ...headParts, indent$s(rest)], {
42955 const jsxPart = getLast$h(parts);
42956 return group$z([chain, indentIfBreak$3(jsxPart, {
42959 } // For binary expressions to be consistent, we need to group
42960 // subsequent operators with the same precedence level under a single
42961 // group. Otherwise they will be nested such that some of them break
42962 // onto new lines but not all. Operators with the same precedence
42963 // level should either all break or not. Because we group them by
42964 // precedence level and the AST is structured based on precedence
42965 // level, things are naturally broken up correctly, i.e. `&&` is
42966 // broken before `+`.
42969 function printBinaryishExpressions(path, print, options, isNested, isInsideParenthesis) {
42970 const node = path.getValue(); // Simply print the node normally.
42972 if (!isBinaryish$3(node)) {
42973 return [group$z(print())];
42975 /** @type{Doc[]} */
42978 let parts = []; // We treat BinaryExpression and LogicalExpression nodes the same.
42979 // Put all operators with the same precedence level in the same
42980 // group. The reason we only need to do this with the `left`
42981 // expression is because given an expression like `1 + 2 - 3`, it
42982 // is always parsed like `((1 + 2) - 3)`, meaning the `left` side
42983 // is where the rest of the expression will exist. Binary
42984 // expressions on the right side mean they have a difference
42985 // precedence level and should be treated as a separate group, so
42986 // print them normally. (This doesn't hold for the `**` operator,
42987 // which is unique in that it is right-associative.)
42989 if (shouldFlatten(node.operator, node.left.operator)) {
42990 // Flatten them out by recursively calling this function.
42991 parts = path.call(left => printBinaryishExpressions(left, print, options,
42993 true, isInsideParenthesis), "left");
42995 parts.push(group$z(print("left")));
42998 const shouldInline = shouldInlineLogicalExpression$1(node);
42999 const lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment$3(options.originalText, node.right);
43000 const operator = node.type === "NGPipeExpression" ? "|" : node.operator;
43001 const rightSuffix = node.type === "NGPipeExpression" && node.arguments.length > 0 ? group$z(indent$s([softline$p, ": ", join$r([softline$p, ":", ifBreak$m(" ")], path.map(print, "arguments").map(arg => align$4(2, group$z(arg))))])) : "";
43006 if (shouldInline) {
43007 right = [operator, " ", print("right"), rightSuffix];
43009 const isHackPipeline = isEnabledHackPipeline(options) && operator === "|>";
43010 const rightContent = isHackPipeline ? path.call(left => printBinaryishExpressions(left, print, options,
43012 true, isInsideParenthesis), "right") : print("right");
43013 right = [lineBeforeOperator ? line$w : "", operator, lineBeforeOperator ? " " : line$w, rightContent, rightSuffix];
43014 } // If there's only a single binary expression, we want to create a group
43015 // in order to avoid having a small right part like -1 be on its own line.
43018 const parent = path.getParentNode();
43019 const shouldBreak = hasComment$g(node.left, CommentCheckFlags$d.Trailing | CommentCheckFlags$d.Line);
43020 const shouldGroup = shouldBreak || !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type;
43021 parts.push(lineBeforeOperator ? "" : " ", shouldGroup ? group$z(right, {
43023 }) : right); // The root comments are already printed, but we need to manually print
43024 // the other ones since we don't call the normal print on BinaryExpression,
43025 // only for the left and right parts
43027 if (isNested && hasComment$g(node)) {
43028 const printed = cleanDoc$2(printComments$5(path, parts, options));
43029 /* istanbul ignore else */
43031 if (isConcat$1(printed) || printed.type === "fill") {
43032 return getDocParts$6(printed);
43041 function shouldInlineLogicalExpression$1(node) {
43042 if (node.type !== "LogicalExpression") {
43046 if (node.right.type === "ObjectExpression" && node.right.properties.length > 0) {
43050 if (node.right.type === "ArrayExpression" && node.right.elements.length > 0) {
43054 if (isJsxNode$5(node.right)) {
43062 printBinaryishExpression: printBinaryishExpression$2,
43063 shouldInlineLogicalExpression: shouldInlineLogicalExpression$1
43075 hasComment: hasComment$f,
43076 getComments: getComments$3
43079 printBinaryishExpression: printBinaryishExpression$1
43081 /** @typedef {import("../../common/ast-path")} AstPath */
43083 function printAngular$1(path, options, print) {
43084 const node = path.getValue(); // Angular nodes always starts with `NG`
43086 if (!node.type.startsWith("NG")) {
43090 switch (node.type) {
43092 return [print("node"), !hasComment$f(node.node) ? "" : " //" + getComments$3(node.node)[0].value.trimEnd()];
43094 case "NGPipeExpression":
43095 return printBinaryishExpression$1(path, options, print);
43097 case "NGChainedExpression":
43098 return group$y(join$q([";", line$v], path.map(childPath => hasNgSideEffect(childPath) ? print() : ["(", print(), ")"], "expressions")));
43100 case "NGEmptyExpression":
43103 case "NGQuotedExpression":
43104 return [node.prefix, ": ", node.value.trim()];
43106 case "NGMicrosyntax":
43107 return path.map((childPath, index) => [index === 0 ? "" : isNgForOf(childPath.getValue(), index, node) ? " " : [";", line$v], print()], "body");
43109 case "NGMicrosyntaxKey":
43110 return /^[$_a-z][\w$]*(?:-[$_a-z][\w$])*$/i.test(node.name) ? node.name : JSON.stringify(node.name);
43112 case "NGMicrosyntaxExpression":
43113 return [print("expression"), node.alias === null ? "" : [" as ", print("alias")]];
43115 case "NGMicrosyntaxKeyedExpression":
43117 const index = path.getName();
43118 const parentNode = path.getParentNode();
43119 const shouldNotPrintColon = isNgForOf(node, index, parentNode) || (index === 1 && (node.key.name === "then" || node.key.name === "else") || index === 2 && node.key.name === "else" && parentNode.body[index - 1].type === "NGMicrosyntaxKeyedExpression" && parentNode.body[index - 1].key.name === "then") && parentNode.body[0].type === "NGMicrosyntaxExpression";
43120 return [print("key"), shouldNotPrintColon ? " " : ": ", print("expression")];
43123 case "NGMicrosyntaxLet":
43124 return ["let ", print("key"), node.value === null ? "" : [" = ", print("value")]];
43126 case "NGMicrosyntaxAs":
43127 return [print("key"), " as ", print("alias")];
43130 /* istanbul ignore next */
43131 throw new Error(`Unknown Angular node type: ${JSON.stringify(node.type)}.`);
43135 function isNgForOf(node, index, parentNode) {
43136 return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null;
43138 /** identify if an angular expression seems to have side effects */
43141 * @param {AstPath} path
43142 * @returns {boolean}
43146 function hasNgSideEffect(path) {
43147 return hasNode(path.getValue(), node => {
43148 switch (node.type) {
43152 case "CallExpression":
43153 case "OptionalCallExpression":
43154 case "AssignmentExpression":
43161 printAngular: printAngular$1
43165 printComments: printComments$4,
43166 printDanglingComments: printDanglingComments$d
43171 hardline: hardline$w,
43172 softline: softline$o,
43175 conditionalGroup: conditionalGroup$4,
43177 ifBreak: ifBreak$l,
43178 lineSuffixBoundary,
43182 willBreak: willBreak$5
43186 getLast: getLast$g,
43187 getPreferredQuote: getPreferredQuote$1
43190 isJsxNode: isJsxNode$4,
43191 rawText: rawText$4,
43192 isLiteral: isLiteral$2,
43193 isCallExpression: isCallExpression$9,
43194 isStringLiteral: isStringLiteral$4,
43195 isBinaryish: isBinaryish$2,
43196 hasComment: hasComment$e,
43197 CommentCheckFlags: CommentCheckFlags$c,
43198 hasNodeIgnoreComment
43200 const pathNeedsParens$5 = needsParens_1;
43202 willPrintOwnComments
43205 const isEmptyStringOrAnyLine = doc => doc === "" || doc === line$u || doc === hardline$w || doc === softline$o;
43207 * @typedef {import("../../common/ast-path")} AstPath
43208 * @typedef {import("../types/estree").Node} Node
43209 * @typedef {import("../types/estree").JSXElement} JSXElement
43211 // JSX expands children from the inside-out, instead of the outside-in.
43212 // This is both to break children before attributes,
43213 // and to ensure that when children break, their parents do as well.
43215 // Any element that is written without any newlines and fits on a single line
43216 // is left that way.
43217 // Not only that, any user-written-line containing multiple JSX siblings
43218 // should also be kept on one line if possible,
43219 // so each user-written-line is wrapped in its own group.
43221 // Elements that contain newlines or don't fit on a single line (recursively)
43222 // are fully-split, using hardline and shouldBreak: true.
43224 // To support that case properly, all leading and trailing spaces
43225 // are stripped from the list of children, and replaced with a single hardline.
43228 function printJsxElementInternal(path, options, print) {
43229 const node = path.getValue();
43231 if (node.type === "JSXElement" && isEmptyJsxElement(node)) {
43232 return [print("openingElement"), print("closingElement")];
43235 const openingLines = node.type === "JSXElement" ? print("openingElement") : print("openingFragment");
43236 const closingLines = node.type === "JSXElement" ? print("closingElement") : print("closingFragment");
43238 if (node.children.length === 1 && node.children[0].type === "JSXExpressionContainer" && (node.children[0].expression.type === "TemplateLiteral" || node.children[0].expression.type === "TaggedTemplateExpression")) {
43239 return [openingLines, ...path.map(print, "children"), closingLines];
43240 } // Convert `{" "}` to text nodes containing a space.
43241 // This makes it easy to turn them into `jsxWhitespace` which
43242 // can then print as either a space or `{" "}` when breaking.
43245 node.children = node.children.map(child => {
43246 if (isJsxWhitespaceExpression(child)) {
43256 const containsTag = node.children.some(isJsxNode$4);
43257 const containsMultipleExpressions = node.children.filter(child => child.type === "JSXExpressionContainer").length > 1;
43258 const containsMultipleAttributes = node.type === "JSXElement" && node.openingElement.attributes.length > 1; // Record any breaks. Should never go from true to false, only false to true.
43260 let forcedBreak = willBreak$5(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions;
43261 const isMdxBlock = path.getParentNode().rootMarker === "mdx";
43262 const rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
43263 const jsxWhitespace = isMdxBlock ? " " : ifBreak$l([rawJsxWhitespace, softline$o], " ");
43264 const isFacebookTranslationTag = node.openingElement && node.openingElement.name && node.openingElement.name.name === "fbt";
43265 const children = printJsxChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag);
43266 const containsText = node.children.some(child => isMeaningfulJsxText(child)); // We can end up we multiple whitespace elements with empty string
43267 // content between them.
43268 // We need to remove empty whitespace and softlines before JSX whitespace
43269 // to get the correct output.
43271 for (let i = children.length - 2; i >= 0; i--) {
43272 const isPairOfEmptyStrings = children[i] === "" && children[i + 1] === "";
43273 const isPairOfHardlines = children[i] === hardline$w && children[i + 1] === "" && children[i + 2] === hardline$w;
43274 const isLineFollowedByJsxWhitespace = (children[i] === softline$o || children[i] === hardline$w) && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
43275 const isJsxWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$o || children[i + 2] === hardline$w);
43276 const isDoubleJsxWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
43277 const isPairOfHardOrSoftLines = children[i] === softline$o && children[i + 1] === "" && children[i + 2] === hardline$w || children[i] === hardline$w && children[i + 1] === "" && children[i + 2] === softline$o;
43279 if (isPairOfHardlines && containsText || isPairOfEmptyStrings || isLineFollowedByJsxWhitespace || isDoubleJsxWhitespace || isPairOfHardOrSoftLines) {
43280 children.splice(i, 2);
43281 } else if (isJsxWhitespaceFollowedByLine) {
43282 children.splice(i + 1, 2);
43284 } // Trim trailing lines (or empty strings)
43287 while (children.length > 0 && isEmptyStringOrAnyLine(getLast$g(children))) {
43289 } // Trim leading lines (or empty strings)
43292 while (children.length > 1 && isEmptyStringOrAnyLine(children[0]) && isEmptyStringOrAnyLine(children[1])) {
43295 } // Tweak how we format children if outputting this element over multiple lines.
43296 // Also detect whether we will force this element to output over multiple lines.
43299 const multilineChildren = [];
43301 for (const [i, child] of children.entries()) {
43302 // There are a number of situations where we need to ensure we display
43303 // whitespace as `{" "}` when outputting this element over multiple lines.
43304 if (child === jsxWhitespace) {
43305 if (i === 1 && children[i - 1] === "") {
43306 if (children.length === 2) {
43307 // Solitary whitespace
43308 multilineChildren.push(rawJsxWhitespace);
43310 } // Leading whitespace
43313 multilineChildren.push([rawJsxWhitespace, hardline$w]);
43315 } else if (i === children.length - 1) {
43316 // Trailing whitespace
43317 multilineChildren.push(rawJsxWhitespace);
43319 } else if (children[i - 1] === "" && children[i - 2] === hardline$w) {
43320 // Whitespace after line break
43321 multilineChildren.push(rawJsxWhitespace);
43326 multilineChildren.push(child);
43328 if (willBreak$5(child)) {
43329 forcedBreak = true;
43331 } // If there is text we use `fill` to fit as much onto each line as possible.
43332 // When there is no text (just tags and expressions) we use `group`
43333 // to output each on a separate line.
43336 const content = containsText ? fill$8(multilineChildren) : group$x(multilineChildren, {
43344 const multiLineElem = group$x([openingLines, indent$r([hardline$w, content]), hardline$w, closingLines]);
43347 return multiLineElem;
43350 return conditionalGroup$4([group$x([openingLines, ...children, closingLines]), multiLineElem]);
43351 } // JSX Children are strange, mostly for two reasons:
43352 // 1. JSX reads newlines into string values, instead of skipping them like JS
43353 // 2. up to one whitespace between elements within a line is significant,
43354 // but not between lines.
43356 // Leading, trailing, and lone whitespace all need to
43357 // turn themselves into the rather ugly `{' '}` when breaking.
43359 // We print JSX using the `fill` doc primitive.
43360 // This requires that we give it an array of alternating
43361 // content and whitespace elements.
43362 // To ensure this we add dummy `""` content elements as needed.
43365 function printJsxChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag) {
43367 path.each((childPath, i, children) => {
43368 const child = childPath.getValue();
43370 if (isLiteral$2(child)) {
43371 const text = rawText$4(child); // Contains a non-whitespace character
43373 if (isMeaningfulJsxText(child)) {
43374 const words = text.split(matchJsxWhitespaceRegex); // Starts with whitespace
43376 if (words[0] === "") {
43380 if (/\n/.test(words[0])) {
43381 const next = children[i + 1];
43382 parts.push(separatorWithWhitespace(isFacebookTranslationTag, words[1], child, next));
43384 parts.push(jsxWhitespace);
43390 let endWhitespace; // Ends with whitespace
43392 if (getLast$g(words) === "") {
43394 endWhitespace = words.pop();
43395 } // This was whitespace only without a new line.
43398 if (words.length === 0) {
43402 for (const [i, word] of words.entries()) {
43404 parts.push(line$u);
43410 if (endWhitespace !== undefined) {
43411 if (/\n/.test(endWhitespace)) {
43412 const next = children[i + 1];
43413 parts.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$g(parts), child, next));
43415 parts.push(jsxWhitespace);
43418 const next = children[i + 1];
43419 parts.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$g(parts), child, next));
43421 } else if (/\n/.test(text)) {
43422 // Keep (up to one) blank line between tags/expressions/text.
43423 // Note: We don't keep blank lines between text elements.
43424 if (text.match(/\n/g).length > 1) {
43425 parts.push("", hardline$w);
43428 parts.push("", jsxWhitespace);
43431 const printedChild = print();
43432 parts.push(printedChild);
43433 const next = children[i + 1];
43434 const directlyFollowedByMeaningfulText = next && isMeaningfulJsxText(next);
43436 if (directlyFollowedByMeaningfulText) {
43437 const firstWord = trimJsxWhitespace(rawText$4(next)).split(matchJsxWhitespaceRegex)[0];
43438 parts.push(separatorNoWhitespace(isFacebookTranslationTag, firstWord, child, next));
43440 parts.push(hardline$w);
43447 function separatorNoWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
43448 if (isFacebookTranslationTag) {
43452 if (childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement) {
43453 return child.length === 1 ? softline$o : hardline$w;
43459 function separatorWithWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
43460 if (isFacebookTranslationTag) {
43464 if (child.length === 1) {
43465 return childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement ? hardline$w : softline$o;
43471 function maybeWrapJsxElementInParens(path, elem, options) {
43472 const parent = path.getParentNode();
43473 /* istanbul ignore next */
43479 const NO_WRAP_PARENTS = {
43480 ArrayExpression: true,
43481 JSXAttribute: true,
43483 JSXExpressionContainer: true,
43485 ExpressionStatement: true,
43486 CallExpression: true,
43487 OptionalCallExpression: true,
43488 ConditionalExpression: true,
43489 JsExpressionRoot: true
43492 if (NO_WRAP_PARENTS[parent.type]) {
43496 const shouldBreak = path.match(undefined, node => node.type === "ArrowFunctionExpression", isCallExpression$9, node => node.type === "JSXExpressionContainer");
43497 const needsParens = pathNeedsParens$5(path, options);
43498 return group$x([needsParens ? "" : ifBreak$l("("), indent$r([softline$o, elem]), softline$o, needsParens ? "" : ifBreak$l(")")], {
43503 function printJsxAttribute(path, options, print) {
43504 const node = path.getValue();
43506 parts.push(print("name"));
43511 if (isStringLiteral$4(node.value)) {
43512 const raw = rawText$4(node.value); // Remove enclosing quotes and unescape
43513 // all quotes so we get an accurate preferred quote
43515 let final = raw.slice(1, -1).replace(/'/g, "'").replace(/"/g, '"');
43520 } = getPreferredQuote$1(final, options.jsxSingleQuote ? "'" : '"');
43521 final = final.replace(regex, escaped);
43522 res = [quote, final, quote];
43524 res = print("value");
43527 parts.push("=", res);
43533 function printJsxExpressionContainer(path, options, print) {
43534 const node = path.getValue();
43535 const parent = path.getParentNode(0);
43536 const shouldInline = node.expression.type === "JSXEmptyExpression" || !hasComment$e(node.expression) && (node.expression.type === "ArrayExpression" || node.expression.type === "ObjectExpression" || node.expression.type === "ArrowFunctionExpression" || isCallExpression$9(node.expression) || node.expression.type === "FunctionExpression" || node.expression.type === "TemplateLiteral" || node.expression.type === "TaggedTemplateExpression" || node.expression.type === "DoExpression" || isJsxNode$4(parent) && (node.expression.type === "ConditionalExpression" || isBinaryish$2(node.expression)));
43538 if (shouldInline) {
43539 return group$x(["{", print("expression"), lineSuffixBoundary, "}"]);
43542 return group$x(["{", indent$r([softline$o, print("expression")]), softline$o, lineSuffixBoundary, "}"]);
43545 function printJsxOpeningElement(path, options, print) {
43546 const node = path.getValue();
43547 const nameHasComments = node.name && hasComment$e(node.name) || node.typeParameters && hasComment$e(node.typeParameters); // Don't break self-closing elements with no attributes and no comments
43549 if (node.selfClosing && node.attributes.length === 0 && !nameHasComments) {
43550 return ["<", print("name"), print("typeParameters"), " />"];
43551 } // don't break up opening elements with a single long text attribute
43554 if (node.attributes && node.attributes.length === 1 && node.attributes[0].value && isStringLiteral$4(node.attributes[0].value) && !node.attributes[0].value.value.includes("\n") && // We should break for the following cases:
43563 !nameHasComments && !hasComment$e(node.attributes[0])) {
43564 return group$x(["<", print("name"), print("typeParameters"), " ", ...path.map(print, "attributes"), node.selfClosing ? " />" : ">"]);
43567 const lastAttrHasTrailingComments = node.attributes.length > 0 && hasComment$e(getLast$g(node.attributes), CommentCheckFlags$c.Trailing);
43568 const bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
43569 // kept unbroken regardless of `bracketSameLine`.
43570 // jsxBracketSameLine is deprecated in favour of bracketSameLine,
43571 // but is still needed for backwards compatibility.
43572 node.attributes.length === 0 && !nameHasComments || (options.bracketSameLine || options.jsxBracketSameLine) && ( // We should print the bracket in a new line for the following cases:
43579 !nameHasComments || node.attributes.length > 0) && !lastAttrHasTrailingComments; // We should print the opening element expanded if any prop value is a
43580 // string literal with newlines
43582 const shouldBreak = node.attributes && node.attributes.some(attr => attr.value && isStringLiteral$4(attr.value) && attr.value.value.includes("\n"));
43583 return group$x(["<", print("name"), print("typeParameters"), indent$r(path.map(() => [line$u, print()], "attributes")), node.selfClosing ? line$u : bracketSameLine ? ">" : softline$o, node.selfClosing ? "/>" : bracketSameLine ? "" : ">"], {
43588 function printJsxClosingElement(path, options, print) {
43589 const node = path.getValue();
43592 const printed = print("name");
43594 if (hasComment$e(node.name, CommentCheckFlags$c.Leading | CommentCheckFlags$c.Line)) {
43595 parts.push(indent$r([hardline$w, printed]), hardline$w);
43596 } else if (hasComment$e(node.name, CommentCheckFlags$c.Leading | CommentCheckFlags$c.Block)) {
43597 parts.push(" ", printed);
43599 parts.push(printed);
43606 function printJsxOpeningClosingFragment(path, options
43609 const node = path.getValue();
43610 const nodeHasComment = hasComment$e(node);
43611 const hasOwnLineComment = hasComment$e(node, CommentCheckFlags$c.Line);
43612 const isOpeningFragment = node.type === "JSXOpeningFragment";
43613 return [isOpeningFragment ? "<" : "</", indent$r([hasOwnLineComment ? hardline$w : nodeHasComment && !isOpeningFragment ? " " : "", printDanglingComments$d(path, options, true)]), hasOwnLineComment ? hardline$w : "", ">"];
43616 function printJsxElement(path, options, print) {
43617 const elem = printComments$4(path, printJsxElementInternal(path, options, print), options);
43618 return maybeWrapJsxElementInParens(path, elem, options);
43621 function printJsxEmptyExpression(path, options
43624 const node = path.getValue();
43625 const requiresHardline = hasComment$e(node, CommentCheckFlags$c.Line);
43626 return [printDanglingComments$d(path, options,
43628 !requiresHardline), requiresHardline ? hardline$w : ""];
43629 } // `JSXSpreadAttribute` and `JSXSpreadChild`
43632 function printJsxSpreadAttribute(path, options, print) {
43633 const node = path.getValue();
43634 return ["{", path.call(p => {
43635 const printed = ["...", print()];
43636 const node = p.getValue();
43638 if (!hasComment$e(node) || !willPrintOwnComments(p)) {
43642 return [indent$r([softline$o, printComments$4(p, printed, options)]), softline$o];
43643 }, node.type === "JSXSpreadAttribute" ? "argument" : "expression"), "}"];
43646 function printJsx$1(path, options, print) {
43647 const node = path.getValue(); // JSX nodes always starts with `JSX`
43649 if (!node.type.startsWith("JSX")) {
43653 switch (node.type) {
43654 case "JSXAttribute":
43655 return printJsxAttribute(path, options, print);
43657 case "JSXIdentifier":
43658 return String(node.name);
43660 case "JSXNamespacedName":
43661 return join$p(":", [print("namespace"), print("name")]);
43663 case "JSXMemberExpression":
43664 return join$p(".", [print("object"), print("property")]);
43666 case "JSXSpreadAttribute":
43667 return printJsxSpreadAttribute(path, options, print);
43669 case "JSXSpreadChild":
43671 // Same as `printJsxSpreadAttribute`
43672 const printJsxSpreadChild = printJsxSpreadAttribute;
43673 return printJsxSpreadChild(path, options, print);
43676 case "JSXExpressionContainer":
43677 return printJsxExpressionContainer(path, options, print);
43679 case "JSXFragment":
43681 return printJsxElement(path, options, print);
43683 case "JSXOpeningElement":
43684 return printJsxOpeningElement(path, options, print);
43686 case "JSXClosingElement":
43687 return printJsxClosingElement(path, options, print);
43689 case "JSXOpeningFragment":
43690 case "JSXClosingFragment":
43691 return printJsxOpeningClosingFragment(path, options
43695 case "JSXEmptyExpression":
43696 return printJsxEmptyExpression(path, options
43701 /* istanbul ignore next */
43702 throw new Error("JSXTest should be handled by JSXElement");
43705 /* istanbul ignore next */
43706 throw new Error(`Unknown JSX node type: ${JSON.stringify(node.type)}.`);
43708 } // Only space, newline, carriage return, and tab are treated as whitespace
43712 const jsxWhitespaceChars = " \n\r\t";
43713 const matchJsxWhitespaceRegex = new RegExp("([" + jsxWhitespaceChars + "]+)");
43714 const containsNonJsxWhitespaceRegex = new RegExp("[^" + jsxWhitespaceChars + "]");
43716 const trimJsxWhitespace = text => text.replace(new RegExp("(?:^" + matchJsxWhitespaceRegex.source + "|" + matchJsxWhitespaceRegex.source + "$)"), "");
43718 * @param {JSXElement} node
43719 * @returns {boolean}
43723 function isEmptyJsxElement(node) {
43724 if (node.children.length === 0) {
43728 if (node.children.length > 1) {
43730 } // if there is one text child and does not contain any meaningful text
43731 // we can treat the element as empty.
43734 const child = node.children[0];
43735 return isLiteral$2(child) && !isMeaningfulJsxText(child);
43736 } // Meaningful if it contains non-whitespace characters,
43737 // or it contains whitespace without a new line.
43740 * @param {Node} node
43741 * @returns {boolean}
43745 function isMeaningfulJsxText(node) {
43746 return isLiteral$2(node) && (containsNonJsxWhitespaceRegex.test(rawText$4(node)) || !/\n/.test(rawText$4(node)));
43747 } // Detect an expression node representing `{" "}`
43750 function isJsxWhitespaceExpression(node) {
43751 return node.type === "JSXExpressionContainer" && isLiteral$2(node.expression) && node.expression.value === " " && !hasComment$e(node.expression);
43754 * @param {AstPath} path
43755 * @returns {boolean}
43759 function hasJsxIgnoreComment$1(path) {
43760 const node = path.getValue();
43761 const parent = path.getParentNode();
43763 if (!parent || !node || !isJsxNode$4(node) || !isJsxNode$4(parent)) {
43765 } // Lookup the previous sibling, ignoring any empty JSXText elements
43768 const index = parent.children.indexOf(node);
43769 let prevSibling = null;
43771 for (let i = index; i > 0; i--) {
43772 const candidate = parent.children[i - 1];
43774 if (candidate.type === "JSXText" && !isMeaningfulJsxText(candidate)) {
43778 prevSibling = candidate;
43782 return prevSibling && prevSibling.type === "JSXExpressionContainer" && prevSibling.expression.type === "JSXEmptyExpression" && hasNodeIgnoreComment(prevSibling.expression);
43786 hasJsxIgnoreComment: hasJsxIgnoreComment$1,
43787 printJsx: printJsx$1
43791 var flattenIntoArray = flattenIntoArray_1;
43792 var toObject = toObject$4;
43793 var lengthOfArrayLike = lengthOfArrayLike$6;
43794 var toIntegerOrInfinity = toIntegerOrInfinity$3;
43795 var arraySpeciesCreate = arraySpeciesCreate$2;
43797 // `Array.prototype.flat` method
43798 // https://tc39.es/ecma262/#sec-array.prototype.flat
43799 $({ target: 'Array', proto: true }, {
43800 flat: function flat(/* depthArg = 1 */) {
43801 var depthArg = arguments.length ? arguments[0] : undefined;
43802 var O = toObject(this);
43803 var sourceLen = lengthOfArrayLike(O);
43804 var A = arraySpeciesCreate(O, 0);
43805 A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
43810 var internalObjectKeys = objectKeysInternal;
43811 var enumBugKeys$1 = enumBugKeys$3;
43813 // `Object.keys` method
43814 // https://tc39.es/ecma262/#sec-object.keys
43815 // eslint-disable-next-line es/no-object-keys -- safe
43816 var objectKeys$1 = Object.keys || function keys(O) {
43817 return internalObjectKeys(O, enumBugKeys$1);
43820 var DESCRIPTORS = descriptors$1;
43821 var definePropertyModule$1 = objectDefineProperty;
43822 var anObject$1 = anObject$7;
43823 var toIndexedObject = toIndexedObject$4;
43824 var objectKeys = objectKeys$1;
43826 // `Object.defineProperties` method
43827 // https://tc39.es/ecma262/#sec-object.defineproperties
43828 // eslint-disable-next-line es/no-object-defineproperties -- safe
43829 var objectDefineProperties = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
43831 var props = toIndexedObject(Properties);
43832 var keys = objectKeys(Properties);
43833 var length = keys.length;
43836 while (length > index) definePropertyModule$1.f(O, key = keys[index++], props[key]);
43840 var getBuiltIn = getBuiltIn$5;
43842 var html$2 = getBuiltIn('document', 'documentElement');
43844 /* global ActiveXObject -- old IE, WSH */
43846 var anObject = anObject$7;
43847 var defineProperties = objectDefineProperties;
43848 var enumBugKeys = enumBugKeys$3;
43849 var hiddenKeys = hiddenKeys$4;
43850 var html$1 = html$2;
43851 var documentCreateElement = documentCreateElement$1;
43852 var sharedKey = sharedKey$2;
43856 var PROTOTYPE = 'prototype';
43857 var SCRIPT = 'script';
43858 var IE_PROTO = sharedKey('IE_PROTO');
43860 var EmptyConstructor = function () { /* empty */ };
43862 var scriptTag = function (content) {
43863 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
43866 // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
43867 var NullProtoObjectViaActiveX = function (activeXDocument) {
43868 activeXDocument.write(scriptTag(''));
43869 activeXDocument.close();
43870 var temp = activeXDocument.parentWindow.Object;
43871 activeXDocument = null; // avoid memory leak
43875 // Create object with fake `null` prototype: use iframe Object with cleared prototype
43876 var NullProtoObjectViaIFrame = function () {
43877 // Thrash, waste and sodomy: IE GC bug
43878 var iframe = documentCreateElement('iframe');
43879 var JS = 'java' + SCRIPT + ':';
43880 var iframeDocument;
43881 iframe.style.display = 'none';
43882 html$1.appendChild(iframe);
43883 // https://github.com/zloirock/core-js/issues/475
43884 iframe.src = String(JS);
43885 iframeDocument = iframe.contentWindow.document;
43886 iframeDocument.open();
43887 iframeDocument.write(scriptTag('document.F=Object'));
43888 iframeDocument.close();
43889 return iframeDocument.F;
43892 // Check for document.domain and active x support
43893 // No need to use active x approach when document.domain is not set
43894 // see https://github.com/es-shims/es5-shim/issues/150
43895 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
43897 var activeXDocument;
43898 var NullProtoObject = function () {
43900 activeXDocument = new ActiveXObject('htmlfile');
43901 } catch (error) { /* ignore */ }
43902 NullProtoObject = typeof document != 'undefined'
43903 ? document.domain && activeXDocument
43904 ? NullProtoObjectViaActiveX(activeXDocument) // old IE
43905 : NullProtoObjectViaIFrame()
43906 : NullProtoObjectViaActiveX(activeXDocument); // WSH
43907 var length = enumBugKeys.length;
43908 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
43909 return NullProtoObject();
43912 hiddenKeys[IE_PROTO] = true;
43914 // `Object.create` method
43915 // https://tc39.es/ecma262/#sec-object.create
43916 var objectCreate = Object.create || function create(O, Properties) {
43919 EmptyConstructor[PROTOTYPE] = anObject(O);
43920 result = new EmptyConstructor();
43921 EmptyConstructor[PROTOTYPE] = null;
43922 // add "__proto__" for Object.getPrototypeOf polyfill
43923 result[IE_PROTO] = O;
43924 } else result = NullProtoObject();
43925 return Properties === undefined ? result : defineProperties(result, Properties);
43928 var wellKnownSymbol = wellKnownSymbol$7;
43929 var create = objectCreate;
43930 var definePropertyModule = objectDefineProperty;
43932 var UNSCOPABLES = wellKnownSymbol('unscopables');
43933 var ArrayPrototype = Array.prototype;
43935 // Array.prototype[@@unscopables]
43936 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
43937 if (ArrayPrototype[UNSCOPABLES] == undefined) {
43938 definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {
43939 configurable: true,
43940 value: create(null)
43944 // add a key to Array.prototype[@@unscopables]
43945 var addToUnscopables$1 = function (key) {
43946 ArrayPrototype[UNSCOPABLES][key] = true;
43949 // this method was added to unscopables after implementation
43950 // in popular engines, so it's moved to a separate module
43951 var addToUnscopables = addToUnscopables$1;
43953 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
43954 addToUnscopables('flat');
43957 isNonEmptyArray: isNonEmptyArray$e
43967 isFlowAnnotationComment: isFlowAnnotationComment$1
43970 function printOptionalToken$9(path) {
43971 const node = path.getValue();
43973 if (!node.optional || // It's an optional computed method parsed by typescript-estree.
43974 // "?" is printed in `printMethod`.
43975 node.type === "Identifier" && node === path.getParentNode().key) {
43979 if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) {
43986 function printFunctionTypeParameters$4(path, options, print) {
43987 const fun = path.getValue();
43989 if (fun.typeArguments) {
43990 return print("typeArguments");
43993 if (fun.typeParameters) {
43994 return print("typeParameters");
44000 function printTypeAnnotation$5(path, options, print) {
44001 const node = path.getValue();
44003 if (!node.typeAnnotation) {
44007 const parentNode = path.getParentNode();
44008 const isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite;
44009 const isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node;
44011 if (isFlowAnnotationComment$1(options.originalText, node.typeAnnotation)) {
44012 return [" /*: ", print("typeAnnotation"), " */"];
44015 return [isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", print("typeAnnotation")];
44018 function printBindExpressionCallee$2(path, options, print) {
44019 return ["::", print("callee")];
44022 function printTypeScriptModifiers$2(path, options, print) {
44023 const node = path.getValue();
44025 if (!isNonEmptyArray$e(node.modifiers)) {
44029 return [join$o(" ", path.map(print, "modifiers")), " "];
44032 function adjustClause$1(node, clause, forceSpace) {
44033 if (node.type === "EmptyStatement") {
44037 if (node.type === "BlockStatement" || forceSpace) {
44038 return [" ", clause];
44041 return indent$q([line$t, clause]);
44044 function printRestSpread$2(path, options, print) {
44045 return ["...", print("argument"), printTypeAnnotation$5(path, options, print)];
44049 printOptionalToken: printOptionalToken$9,
44050 printFunctionTypeParameters: printFunctionTypeParameters$4,
44051 printBindExpressionCallee: printBindExpressionCallee$2,
44052 printTypeScriptModifiers: printTypeScriptModifiers$2,
44053 printTypeAnnotation: printTypeAnnotation$5,
44054 printRestSpread: printRestSpread$2,
44055 adjustClause: adjustClause$1
44059 printDanglingComments: printDanglingComments$c
44064 softline: softline$n,
44065 hardline: hardline$v,
44068 ifBreak: ifBreak$k,
44073 getLast: getLast$f,
44074 hasNewline: hasNewline$5
44077 shouldPrintComma: shouldPrintComma$a,
44078 hasComment: hasComment$d,
44079 CommentCheckFlags: CommentCheckFlags$b,
44080 isNextLineEmpty: isNextLineEmpty$b,
44081 isNumericLiteral: isNumericLiteral$4,
44082 isSignedNumericLiteral: isSignedNumericLiteral$1
44085 locStart: locStart$o
44088 printOptionalToken: printOptionalToken$8,
44089 printTypeAnnotation: printTypeAnnotation$4
44091 /** @typedef {import("../../document").Doc} Doc */
44093 function printArray$1(path, options, print) {
44094 const node = path.getValue();
44095 /** @type{Doc[]} */
44098 const openBracket = node.type === "TupleExpression" ? "#[" : "[";
44099 const closeBracket = "]";
44101 if (node.elements.length === 0) {
44102 if (!hasComment$d(node, CommentCheckFlags$b.Dangling)) {
44103 parts.push(openBracket, closeBracket);
44105 parts.push(group$w([openBracket, printDanglingComments$c(path, options), softline$n, closeBracket]));
44108 const lastElem = getLast$f(node.elements);
44109 const canHaveTrailingComma = !(lastElem && lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
44110 // changes its length based on the number of commas. The algorithm
44111 // is that if the last argument is null, we need to force insert
44112 // a comma to ensure JavaScript recognizes it.
44113 // [,].length === 1
44114 // [1,].length === 1
44115 // [1,,].length === 2
44117 // Note that getLast returns null if the array is empty, but
44118 // we already check for an empty array just above so we are safe
44120 const needsForcedTrailingComma = lastElem === null;
44121 const groupId = Symbol("array");
44122 const shouldBreak = !options.__inJestEach && node.elements.length > 1 && node.elements.every((element, i, elements) => {
44123 const elementType = element && element.type;
44125 if (elementType !== "ArrayExpression" && elementType !== "ObjectExpression") {
44129 const nextElement = elements[i + 1];
44131 if (nextElement && elementType !== nextElement.type) {
44135 const itemsKey = elementType === "ArrayExpression" ? "elements" : "properties";
44136 return element[itemsKey] && element[itemsKey].length > 1;
44138 const shouldUseConciseFormatting = isConciselyPrintedArray$1(node, options);
44139 const trailingComma = !canHaveTrailingComma ? "" : needsForcedTrailingComma ? "," : !shouldPrintComma$a(options) ? "" : shouldUseConciseFormatting ? ifBreak$k(",", "", {
44141 }) : ifBreak$k(",");
44142 parts.push(group$w([openBracket, indent$p([softline$n, shouldUseConciseFormatting ? printArrayItemsConcisely(path, options, print, trailingComma) : [printArrayItems$3(path, options, "elements", print), trailingComma], printDanglingComments$c(path, options,
44144 true)]), softline$n, closeBracket], {
44150 parts.push(printOptionalToken$8(path), printTypeAnnotation$4(path, options, print));
44154 function isConciselyPrintedArray$1(node, options) {
44155 return node.elements.length > 1 && node.elements.every(element => element && (isNumericLiteral$4(element) || isSignedNumericLiteral$1(element) && !hasComment$d(element.argument)) && !hasComment$d(element, CommentCheckFlags$b.Trailing | CommentCheckFlags$b.Line, comment => !hasNewline$5(options.originalText, locStart$o(comment), {
44160 function printArrayItems$3(path, options, printPath, print) {
44161 const printedElements = [];
44162 let separatorParts = [];
44163 path.each(childPath => {
44164 printedElements.push(separatorParts, group$w(print()));
44165 separatorParts = [",", line$s];
44167 if (childPath.getValue() && isNextLineEmpty$b(childPath.getValue(), options)) {
44168 separatorParts.push(softline$n);
44171 return printedElements;
44174 function printArrayItemsConcisely(path, options, print, trailingComma) {
44176 path.each((childPath, i, elements) => {
44177 const isLast = i === elements.length - 1;
44178 parts.push([print(), isLast ? trailingComma : ","]);
44181 parts.push(isNextLineEmpty$b(childPath.getValue(), options) ? [hardline$v, hardline$v] : hasComment$d(elements[i + 1], CommentCheckFlags$b.Leading | CommentCheckFlags$b.Line) ? hardline$v : line$s);
44184 return fill$7(parts);
44188 printArray: printArray$1,
44189 printArrayItems: printArrayItems$3,
44190 isConciselyPrintedArray: isConciselyPrintedArray$1
44194 printDanglingComments: printDanglingComments$b
44197 getLast: getLast$e,
44201 getFunctionParameters: getFunctionParameters$3,
44202 hasComment: hasComment$c,
44203 CommentCheckFlags: CommentCheckFlags$a,
44204 isFunctionCompositionArgs,
44205 isJsxNode: isJsxNode$3,
44206 isLongCurriedCallExpression: isLongCurriedCallExpression$1,
44207 shouldPrintComma: shouldPrintComma$9,
44208 getCallArguments: getCallArguments$3,
44209 iterateCallArgumentsPath: iterateCallArgumentsPath$1,
44210 isNextLineEmpty: isNextLineEmpty$a,
44211 isCallExpression: isCallExpression$8,
44212 isStringLiteral: isStringLiteral$3,
44213 isObjectProperty: isObjectProperty$1
44218 hardline: hardline$u,
44219 softline: softline$m,
44222 conditionalGroup: conditionalGroup$3,
44223 ifBreak: ifBreak$j,
44224 breakParent: breakParent$9
44227 willBreak: willBreak$4
44231 ArgExpansionBailout: ArgExpansionBailout$2
44234 isConciselyPrintedArray
44237 function printCallArguments$2(path, options, print) {
44238 const node = path.getValue();
44239 const isDynamicImport = node.type === "ImportExpression";
44240 const args = getCallArguments$3(node);
44242 if (args.length === 0) {
44243 return ["(", printDanglingComments$b(path, options,
44246 } // useEffect(() => { ... }, [foo, bar, baz])
44249 if (isReactHookCallWithDepsArray(args)) {
44250 return ["(", print(["arguments", 0]), ", ", print(["arguments", 1]), ")"];
44253 let anyArgEmptyLine = false;
44254 let hasEmptyLineFollowingFirstArg = false;
44255 const lastArgIndex = args.length - 1;
44256 const printedArguments = [];
44257 iterateCallArgumentsPath$1(path, (argPath, index) => {
44258 const arg = argPath.getNode();
44259 const parts = [print()];
44261 if (index === lastArgIndex) ; else if (isNextLineEmpty$a(arg, options)) {
44263 hasEmptyLineFollowingFirstArg = true;
44266 anyArgEmptyLine = true;
44267 parts.push(",", hardline$u, hardline$u);
44269 parts.push(",", line$r);
44272 printedArguments.push(parts);
44274 const maybeTrailingComma = // Dynamic imports cannot have trailing commas
44275 !(isDynamicImport || node.callee && node.callee.type === "Import") && shouldPrintComma$9(options, "all") ? "," : "";
44277 function allArgsBrokenOut() {
44278 return group$v(["(", indent$o([line$r, ...printedArguments]), maybeTrailingComma, line$r, ")"], {
44283 if (anyArgEmptyLine || path.getParentNode().type !== "Decorator" && isFunctionCompositionArgs(args)) {
44284 return allArgsBrokenOut();
44287 const shouldGroupFirst = shouldGroupFirstArg(args);
44288 const shouldGroupLast = shouldGroupLastArg(args, options);
44290 if (shouldGroupFirst || shouldGroupLast) {
44291 if (shouldGroupFirst ? printedArguments.slice(1).some(willBreak$4) : printedArguments.slice(0, -1).some(willBreak$4)) {
44292 return allArgsBrokenOut();
44293 } // We want to print the last argument with a special flag
44296 let printedExpanded = [];
44300 iterateCallArgumentsPath$1(path, (argPath, i) => {
44301 if (shouldGroupFirst && i === 0) {
44302 printedExpanded = [[print([], {
44303 expandFirstArg: true
44304 }), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$u : line$r, hasEmptyLineFollowingFirstArg ? hardline$u : ""], ...printedArguments.slice(1)];
44307 if (shouldGroupLast && i === lastArgIndex) {
44308 printedExpanded = [...printedArguments.slice(0, -1), print([], {
44309 expandLastArg: true
44315 if (caught instanceof ArgExpansionBailout$2) {
44316 return allArgsBrokenOut();
44318 /* istanbul ignore next */
44324 return [printedArguments.some(willBreak$4) ? breakParent$9 : "", conditionalGroup$3([["(", ...printedExpanded, ")"], shouldGroupFirst ? ["(", group$v(printedExpanded[0], {
44326 }), ...printedExpanded.slice(1), ")"] : ["(", ...printedArguments.slice(0, -1), group$v(getLast$e(printedExpanded), {
44328 }), ")"], allArgsBrokenOut()])];
44331 const contents = ["(", indent$o([softline$m, ...printedArguments]), ifBreak$j(maybeTrailingComma), softline$m, ")"];
44333 if (isLongCurriedCallExpression$1(path)) {
44334 // By not wrapping the arguments in a group, the printer prioritizes
44335 // breaking up these arguments rather than the args of the parent call.
44339 return group$v(contents, {
44340 shouldBreak: printedArguments.some(willBreak$4) || anyArgEmptyLine
44344 function couldGroupArg(arg, arrowChainRecursion = false) {
44345 return arg.type === "ObjectExpression" && (arg.properties.length > 0 || hasComment$c(arg)) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || hasComment$c(arg)) || arg.type === "TSTypeAssertion" && couldGroupArg(arg.expression) || arg.type === "TSAsExpression" && couldGroupArg(arg.expression) || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && ( // we want to avoid breaking inside composite return types but not simple keywords
44346 // https://github.com/prettier/prettier/issues/4070
44347 // export class Thing implements OtherThing {
44348 // do: (type: Type) => Provider<Prop> = memoize(
44349 // (type: ObjectType): Provider<Opts> => {}
44352 // https://github.com/prettier/prettier/issues/6099
44353 // app.get("/", (req, res): void => {
44354 // res.send("Hello World!");
44356 !arg.returnType || !arg.returnType.typeAnnotation || arg.returnType.typeAnnotation.type !== "TSTypeReference" || // https://github.com/prettier/prettier/issues/7542
44357 isNonEmptyBlockStatement(arg.body)) && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" && couldGroupArg(arg.body, true) || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || !arrowChainRecursion && (isCallExpression$8(arg.body) || arg.body.type === "ConditionalExpression") || isJsxNode$3(arg.body)) || arg.type === "DoExpression" || arg.type === "ModuleExpression";
44360 function shouldGroupLastArg(args, options) {
44361 const lastArg = getLast$e(args);
44362 const penultimateArg = getPenultimate(args);
44363 return !hasComment$c(lastArg, CommentCheckFlags$a.Leading) && !hasComment$c(lastArg, CommentCheckFlags$a.Trailing) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
44364 // disable last element expansion.
44365 !penultimateArg || penultimateArg.type !== lastArg.type) && ( // useMemo(() => func(), [foo, bar, baz])
44366 args.length !== 2 || penultimateArg.type !== "ArrowFunctionExpression" || lastArg.type !== "ArrayExpression") && !(args.length > 1 && lastArg.type === "ArrayExpression" && isConciselyPrintedArray(lastArg, options));
44369 function shouldGroupFirstArg(args) {
44370 if (args.length !== 2) {
44374 const [firstArg, secondArg] = args;
44376 if (firstArg.type === "ModuleExpression" && isTypeModuleObjectExpression(secondArg)) {
44380 return !hasComment$c(firstArg) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && secondArg.type !== "FunctionExpression" && secondArg.type !== "ArrowFunctionExpression" && secondArg.type !== "ConditionalExpression" && !couldGroupArg(secondArg);
44383 function isReactHookCallWithDepsArray(args) {
44384 return args.length === 2 && args[0].type === "ArrowFunctionExpression" && getFunctionParameters$3(args[0]).length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.some(arg => hasComment$c(arg));
44387 function isNonEmptyBlockStatement(node) {
44388 return node.type === "BlockStatement" && (node.body.some(node => node.type !== "EmptyStatement") || hasComment$c(node, CommentCheckFlags$a.Dangling));
44389 } // { type: "module" }
44392 function isTypeModuleObjectExpression(node) {
44393 return node.type === "ObjectExpression" && node.properties.length === 1 && isObjectProperty$1(node.properties[0]) && node.properties[0].key.type === "Identifier" && node.properties[0].key.name === "type" && isStringLiteral$3(node.properties[0].value) && node.properties[0].value.value === "module";
44396 var callArguments = printCallArguments$2;
44400 softline: softline$l,
44407 isNumericLiteral: isNumericLiteral$3,
44408 isMemberExpression: isMemberExpression$5,
44409 isCallExpression: isCallExpression$7
44412 printOptionalToken: printOptionalToken$7
44415 function printMemberExpression$1(path, options, print) {
44416 const node = path.getValue();
44417 const parent = path.getParentNode();
44418 let firstNonMemberParent;
44422 firstNonMemberParent = path.getParentNode(i);
44424 } while (firstNonMemberParent && (isMemberExpression$5(firstNonMemberParent) || firstNonMemberParent.type === "TSNonNullExpression"));
44426 const objectDoc = print("object");
44427 const lookupDoc = printMemberLookup$1(path, options, print);
44428 const shouldInline = firstNonMemberParent && (firstNonMemberParent.type === "NewExpression" || firstNonMemberParent.type === "BindExpression" || firstNonMemberParent.type === "AssignmentExpression" && firstNonMemberParent.left.type !== "Identifier") || node.computed || node.object.type === "Identifier" && node.property.type === "Identifier" && !isMemberExpression$5(parent) || (parent.type === "AssignmentExpression" || parent.type === "VariableDeclarator") && (isCallExpression$7(node.object) && node.object.arguments.length > 0 || node.object.type === "TSNonNullExpression" && isCallExpression$7(node.object.expression) && node.object.expression.arguments.length > 0 || objectDoc.label === "member-chain");
44429 return label$2(objectDoc.label === "member-chain" ? "member-chain" : "member", [objectDoc, shouldInline ? lookupDoc : group$u(indent$n([softline$l, lookupDoc]))]);
44432 function printMemberLookup$1(path, options, print) {
44433 const property = print("property");
44434 const node = path.getValue();
44435 const optional = printOptionalToken$7(path);
44437 if (!node.computed) {
44438 return [optional, ".", property];
44441 if (!node.property || isNumericLiteral$3(node.property)) {
44442 return [optional, "[", property, "]"];
44445 return group$u([optional, "[", indent$n([softline$l, property]), softline$l, "]"]);
44449 printMemberExpression: printMemberExpression$1,
44450 printMemberLookup: printMemberLookup$1
44454 printComments: printComments$3
44457 getLast: getLast$d,
44458 isNextLineEmptyAfterIndex,
44459 getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1
44461 const pathNeedsParens$4 = needsParens_1;
44463 isCallExpression: isCallExpression$6,
44464 isMemberExpression: isMemberExpression$4,
44465 isFunctionOrArrowExpression,
44466 isLongCurriedCallExpression,
44467 isMemberish: isMemberish$1,
44468 isNumericLiteral: isNumericLiteral$2,
44469 isSimpleCallArgument,
44470 hasComment: hasComment$b,
44471 CommentCheckFlags: CommentCheckFlags$9,
44472 isNextLineEmpty: isNextLineEmpty$9
44480 hardline: hardline$t,
44483 conditionalGroup: conditionalGroup$2,
44484 breakParent: breakParent$8,
44488 willBreak: willBreak$3
44491 const printCallArguments$1 = callArguments;
44496 printOptionalToken: printOptionalToken$6,
44497 printFunctionTypeParameters: printFunctionTypeParameters$3,
44498 printBindExpressionCallee: printBindExpressionCallee$1
44499 } = misc$1; // We detect calls on member expressions specially to format a
44500 // common pattern better. The pattern we are looking for is this:
44503 // .map(x => x + 1)
44504 // .filter(x => x > 10)
44505 // .some(x => x % 2)
44507 // The way it is structured in the AST is via a nested sequence of
44508 // MemberExpression and CallExpression. We need to traverse the AST
44509 // and make groups out of it to print it in the desired way.
44511 function printMemberChain$1(path, options, print) {
44512 const parent = path.getParentNode();
44513 const isExpressionStatement = !parent || parent.type === "ExpressionStatement"; // The first phase is to linearize the AST by traversing it down.
44516 // has the following AST structure:
44517 // CallExpression(MemberExpression(CallExpression(Identifier)))
44518 // and we transform it into
44519 // [Identifier, CallExpression, MemberExpression, CallExpression]
44521 const printedNodes = []; // Here we try to retain one typed empty line after each call expression or
44522 // the first group whether it is in parentheses or not
44524 function shouldInsertEmptyLineAfter(node) {
44528 const nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$1(originalText, node, locEnd$n);
44529 const nextChar = originalText.charAt(nextCharIndex); // if it is cut off by a parenthesis, we only account for one typed empty
44530 // line after that parenthesis
44532 if (nextChar === ")") {
44533 return nextCharIndex !== false && isNextLineEmptyAfterIndex(originalText, nextCharIndex + 1);
44536 return isNextLineEmpty$9(node, options);
44539 function rec(path) {
44540 const node = path.getValue();
44542 if (isCallExpression$6(node) && (isMemberish$1(node.callee) || isCallExpression$6(node.callee))) {
44543 printedNodes.unshift({
44545 printed: [printComments$3(path, [printOptionalToken$6(path), printFunctionTypeParameters$3(path, options, print), printCallArguments$1(path, options, print)], options), shouldInsertEmptyLineAfter(node) ? hardline$t : ""]
44547 path.call(callee => rec(callee), "callee");
44548 } else if (isMemberish$1(node)) {
44549 printedNodes.unshift({
44551 needsParens: pathNeedsParens$4(path, options),
44552 printed: printComments$3(path, isMemberExpression$4(node) ? printMemberLookup(path, options, print) : printBindExpressionCallee$1(path, options, print), options)
44554 path.call(object => rec(object), "object");
44555 } else if (node.type === "TSNonNullExpression") {
44556 printedNodes.unshift({
44558 printed: printComments$3(path, "!", options)
44560 path.call(expression => rec(expression), "expression");
44562 printedNodes.unshift({
44567 } // Note: the comments of the root node have already been printed, so we
44568 // need to extract this first call without printing them as they would
44569 // if handled inside of the recursive call.
44572 const node = path.getValue();
44573 printedNodes.unshift({
44575 printed: [printOptionalToken$6(path), printFunctionTypeParameters$3(path, options, print), printCallArguments$1(path, options, print)]
44579 path.call(callee => rec(callee), "callee");
44580 } // Once we have a linear list of printed nodes, we want to create groups out
44584 // will be grouped as
44586 // [Identifier, CallExpression],
44587 // [MemberExpression, MemberExpression, CallExpression],
44588 // [MemberExpression, CallExpression],
44589 // [MemberExpression],
44591 // so that we can print it as
44596 // The first group is the first node followed by
44597 // - as many CallExpression as possible
44598 // < fn()()() >.something()
44599 // - as many array accessors as possible
44600 // < fn()[0][1][2] >.something()
44601 // - then, as many MemberExpression as possible but the last one
44602 // < this.items >.something()
44606 let currentGroup = [printedNodes[0]];
44609 for (; i < printedNodes.length; ++i) {
44610 if (printedNodes[i].node.type === "TSNonNullExpression" || isCallExpression$6(printedNodes[i].node) || isMemberExpression$4(printedNodes[i].node) && printedNodes[i].node.computed && isNumericLiteral$2(printedNodes[i].node.property)) {
44611 currentGroup.push(printedNodes[i]);
44617 if (!isCallExpression$6(printedNodes[0].node)) {
44618 for (; i + 1 < printedNodes.length; ++i) {
44619 if (isMemberish$1(printedNodes[i].node) && isMemberish$1(printedNodes[i + 1].node)) {
44620 currentGroup.push(printedNodes[i]);
44627 groups.push(currentGroup);
44628 currentGroup = []; // Then, each following group is a sequence of MemberExpression followed by
44629 // a sequence of CallExpression. To compute it, we keep adding things to the
44630 // group until we has seen a CallExpression in the past and reach a
44631 // MemberExpression
44633 let hasSeenCallExpression = false;
44635 for (; i < printedNodes.length; ++i) {
44636 if (hasSeenCallExpression && isMemberish$1(printedNodes[i].node)) {
44637 // [0] should be appended at the end of the group instead of the
44638 // beginning of the next one
44639 if (printedNodes[i].node.computed && isNumericLiteral$2(printedNodes[i].node.property)) {
44640 currentGroup.push(printedNodes[i]);
44644 groups.push(currentGroup);
44646 hasSeenCallExpression = false;
44649 if (isCallExpression$6(printedNodes[i].node) || printedNodes[i].node.type === "ImportExpression") {
44650 hasSeenCallExpression = true;
44653 currentGroup.push(printedNodes[i]);
44655 if (hasComment$b(printedNodes[i].node, CommentCheckFlags$9.Trailing)) {
44656 groups.push(currentGroup);
44658 hasSeenCallExpression = false;
44662 if (currentGroup.length > 0) {
44663 groups.push(currentGroup);
44664 } // There are cases like Object.keys(), Observable.of(), _.values() where
44665 // they are the subject of all the chained calls and therefore should
44666 // be kept on the same line:
44668 // Object.keys(items)
44672 // In order to detect those cases, we use an heuristic: if the first
44673 // node is an identifier with the name starting with a capital
44674 // letter or just a sequence of _$. The rationale is that they are
44675 // likely to be factories.
44678 function isFactory(name) {
44679 return /^[A-Z]|^[$_]+$/.test(name);
44680 } // In case the Identifier is shorter than tab width, we can keep the
44681 // first call in a single line, if it's an ExpressionStatement.
44683 // d3.scaleLinear()
44684 // .domain([0, 100])
44685 // .range([0, width]);
44689 function isShort(name) {
44690 return name.length <= options.tabWidth;
44693 function shouldNotWrap(groups) {
44694 const hasComputed = groups[1].length > 0 && groups[1][0].node.computed;
44696 if (groups[0].length === 1) {
44697 const firstNode = groups[0][0].node;
44698 return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpressionStatement && isShort(firstNode.name) || hasComputed);
44701 const lastNode = getLast$d(groups[0]).node;
44702 return isMemberExpression$4(lastNode) && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
44705 const shouldMerge = groups.length >= 2 && !hasComment$b(groups[1][0].node) && shouldNotWrap(groups);
44707 function printGroup(printedGroup) {
44708 const printed = printedGroup.map(tuple => tuple.printed); // Checks if the last node (i.e. the parent node) needs parens and print
44711 if (printedGroup.length > 0 && getLast$d(printedGroup).needsParens) {
44712 return ["(", ...printed, ")"];
44718 function printIndentedGroup(groups) {
44719 /* istanbul ignore next */
44720 if (groups.length === 0) {
44724 return indent$m(group$t([hardline$t, join$n(hardline$t, groups.map(printGroup))]));
44727 const printedGroups = groups.map(printGroup);
44728 const oneLine = printedGroups;
44729 const cutoff = shouldMerge ? 3 : 2;
44730 const flatGroups = groups.flat();
44731 const nodeHasComment = flatGroups.slice(1, -1).some(node => hasComment$b(node.node, CommentCheckFlags$9.Leading)) || flatGroups.slice(0, -1).some(node => hasComment$b(node.node, CommentCheckFlags$9.Trailing)) || groups[cutoff] && hasComment$b(groups[cutoff][0].node, CommentCheckFlags$9.Leading); // If we only have a single `.`, we shouldn't do anything fancy and just
44732 // render everything concatenated together.
44734 if (groups.length <= cutoff && !nodeHasComment) {
44735 if (isLongCurriedCallExpression(path)) {
44739 return group$t(oneLine);
44740 } // Find out the last node in the first group and check if it has an
44741 // empty line after
44744 const lastNodeBeforeIndent = getLast$d(groups[shouldMerge ? 1 : 0]).node;
44745 const shouldHaveEmptyLineBeforeIndent = !isCallExpression$6(lastNodeBeforeIndent) && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
44746 const expanded = [printGroup(groups[0]), shouldMerge ? groups.slice(1, 2).map(printGroup) : "", shouldHaveEmptyLineBeforeIndent ? hardline$t : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))];
44747 const callExpressions = printedNodes.map(({
44749 }) => node).filter(isCallExpression$6);
44751 function lastGroupWillBreakAndOtherCallsHaveFunctionArguments() {
44752 const lastGroupNode = getLast$d(getLast$d(groups)).node;
44753 const lastGroupDoc = getLast$d(printedGroups);
44754 return isCallExpression$6(lastGroupNode) && willBreak$3(lastGroupDoc) && callExpressions.slice(0, -1).some(node => node.arguments.some(isFunctionOrArrowExpression));
44757 let result; // We don't want to print in one line if at least one of these conditions occurs:
44758 // * the chain has comments,
44759 // * the chain is an expression statement and all the arguments are literal-like ("fluent configuration" pattern),
44760 // * the chain is longer than 2 calls and has non-trivial arguments or more than 2 arguments in any call but the first one,
44761 // * any group but the last one has a hard line,
44762 // * the last call's arguments have a hard line and other calls have non-trivial arguments.
44764 if (nodeHasComment || callExpressions.length > 2 && callExpressions.some(expr => !expr.arguments.every(arg => isSimpleCallArgument(arg, 0))) || printedGroups.slice(0, -1).some(willBreak$3) || lastGroupWillBreakAndOtherCallsHaveFunctionArguments()) {
44765 result = group$t(expanded);
44767 result = [// We only need to check `oneLine` because if `expanded` is chosen
44768 // that means that the parent group has already been broken
44770 willBreak$3(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent$8 : "", conditionalGroup$2([oneLine, expanded])];
44773 return label$1("member-chain", result);
44776 var memberChain = printMemberChain$1;
44784 const pathNeedsParens$3 = needsParens_1;
44786 getCallArguments: getCallArguments$2,
44787 hasFlowAnnotationComment,
44788 isCallExpression: isCallExpression$5,
44790 isStringLiteral: isStringLiteral$2,
44791 isTemplateOnItsOwnLine: isTemplateOnItsOwnLine$1,
44792 isTestCall: isTestCall$2,
44793 iterateCallArgumentsPath
44795 const printMemberChain = memberChain;
44796 const printCallArguments = callArguments;
44798 printOptionalToken: printOptionalToken$5,
44799 printFunctionTypeParameters: printFunctionTypeParameters$2
44802 function printCallExpression$2(path, options, print) {
44803 const node = path.getValue();
44804 const parentNode = path.getParentNode();
44805 const isNew = node.type === "NewExpression";
44806 const isDynamicImport = node.type === "ImportExpression";
44807 const optional = printOptionalToken$5(path);
44808 const args = getCallArguments$2(node);
44810 if ( // Dangling comments are not handled, all these special cases should have arguments #9668
44811 args.length > 0 && ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
44812 // define calls, as a unit.
44813 // e.g. `define(["some/lib"], (lib) => {`
44814 !isDynamicImport && !isNew && isCommonsJsOrAmdCall(node, parentNode) || // Template literals as single arguments
44815 args.length === 1 && isTemplateOnItsOwnLine$1(args[0], options.originalText) || // Keep test declarations on a single line
44816 // e.g. `it('long name', () => {`
44817 !isNew && isTestCall$2(node, parentNode))) {
44818 const printed = [];
44819 iterateCallArgumentsPath(path, () => {
44820 printed.push(print());
44822 return [isNew ? "new " : "", print("callee"), optional, printFunctionTypeParameters$2(path, options, print), "(", join$m(", ", printed), ")"];
44823 } // Inline Flow annotation comments following Identifiers in Call nodes need to
44824 // stay with the Identifier. For example:
44826 // foo /*:: <SomeGeneric> */(bar);
44828 // Here, we ensure that such comments stay between the Identifier and the Callee.
44831 const isIdentifierWithFlowAnnotation = (options.parser === "babel" || options.parser === "babel-flow") && node.callee && node.callee.type === "Identifier" && hasFlowAnnotationComment(node.callee.trailingComments);
44833 if (isIdentifierWithFlowAnnotation) {
44834 node.callee.trailingComments[0].printed = true;
44835 } // We detect calls on member lookups and possibly print them in a
44836 // special chain format. See `printMemberChain` for more info.
44839 if (!isDynamicImport && !isNew && isMemberish(node.callee) && !path.call(path => pathNeedsParens$3(path, options), "callee")) {
44840 return printMemberChain(path, options, print);
44843 const contents = [isNew ? "new " : "", isDynamicImport ? "import" : print("callee"), optional, isIdentifierWithFlowAnnotation ? `/*:: ${node.callee.trailingComments[0].value.slice(2).trim()} */` : "", printFunctionTypeParameters$2(path, options, print), printCallArguments(path, options, print)]; // We group here when the callee is itself a call expression.
44844 // See `isLongCurriedCallExpression` for more info.
44846 if (isDynamicImport || isCallExpression$5(node.callee)) {
44847 return group$s(contents);
44853 function isCommonsJsOrAmdCall(node, parentNode) {
44854 if (node.callee.type !== "Identifier") {
44858 if (node.callee.name === "require") {
44862 if (node.callee.name === "define") {
44863 const args = getCallArguments$2(node);
44864 return parentNode.type === "ExpressionStatement" && (args.length === 1 || args.length === 2 && args[0].type === "ArrayExpression" || args.length === 3 && isStringLiteral$2(args[0]) && args[1].type === "ArrayExpression");
44870 var callExpression = {
44871 printCallExpression: printCallExpression$2
44875 isNonEmptyArray: isNonEmptyArray$d,
44876 getStringWidth: getStringWidth$1
44883 indentIfBreak: indentIfBreak$2
44886 cleanDoc: cleanDoc$1,
44887 willBreak: willBreak$2,
44892 hasLeadingOwnLineComment: hasLeadingOwnLineComment$2,
44893 isBinaryish: isBinaryish$1,
44894 isStringLiteral: isStringLiteral$1,
44895 isLiteral: isLiteral$1,
44896 isNumericLiteral: isNumericLiteral$1,
44897 isCallExpression: isCallExpression$4,
44898 isMemberExpression: isMemberExpression$3,
44899 getCallArguments: getCallArguments$1,
44900 rawText: rawText$3,
44901 hasComment: hasComment$a,
44902 isSignedNumericLiteral,
44906 shouldInlineLogicalExpression
44909 printCallExpression: printCallExpression$1
44910 } = callExpression;
44912 function printAssignment$3(path, options, print, leftDoc, operator, rightPropertyName) {
44913 const layout = chooseLayout(path, options, print, leftDoc, rightPropertyName);
44914 const rightDoc = print(rightPropertyName, {
44915 assignmentLayout: layout
44919 // First break after operator, then the sides are broken independently on their own lines
44920 case "break-after-operator":
44921 return group$r([group$r(leftDoc), operator, group$r(indent$l([line$q, rightDoc]))]);
44922 // First break right-hand side, then left-hand side
44924 case "never-break-after-operator":
44925 return group$r([group$r(leftDoc), operator, " ", rightDoc]);
44926 // First break right-hand side, then after operator
44930 const groupId = Symbol("assignment");
44931 return group$r([group$r(leftDoc), operator, group$r(indent$l(line$q), {
44933 }), indentIfBreak$2(rightDoc, {
44939 return group$r([leftDoc, operator, " ", group$r(rightDoc)]);
44940 // Parts of assignment chains aren't wrapped in groups.
44941 // Once one of them breaks, the chain breaks too.
44944 return [group$r(leftDoc), operator, line$q, rightDoc];
44947 return [group$r(leftDoc), operator, indent$l([line$q, rightDoc])];
44949 case "chain-tail-arrow-chain":
44950 return [group$r(leftDoc), operator, rightDoc];
44957 function printAssignmentExpression$1(path, options, print) {
44958 const node = path.getValue();
44959 return printAssignment$3(path, options, print, print("left"), [" ", node.operator], "right");
44962 function printVariableDeclarator$1(path, options, print) {
44963 return printAssignment$3(path, options, print, print("id"), " =", "init");
44966 function chooseLayout(path, options, print, leftDoc, rightPropertyName) {
44967 const node = path.getValue();
44968 const rightNode = node[rightPropertyName];
44971 return "only-left";
44972 } // Short assignment chains (only 2 segments) are NOT formatted as chains.
44973 // 1) a = b = c; (expression statements)
44974 // 2) var/let/const a = b = c;
44977 const isTail = !isAssignment(rightNode);
44978 const shouldUseChainFormatting = path.match(isAssignment, isAssignmentOrVariableDeclarator, node => !isTail || node.type !== "ExpressionStatement" && node.type !== "VariableDeclaration");
44980 if (shouldUseChainFormatting) {
44981 return !isTail ? "chain" : rightNode.type === "ArrowFunctionExpression" && rightNode.body.type === "ArrowFunctionExpression" ? "chain-tail-arrow-chain" : "chain-tail";
44984 const isHeadOfLongChain = !isTail && isAssignment(rightNode.right);
44986 if (isHeadOfLongChain || hasLeadingOwnLineComment$2(options.originalText, rightNode)) {
44987 return "break-after-operator";
44990 if (rightNode.type === "CallExpression" && rightNode.callee.name === "require" || // do not put values on a separate line from the key in json
44991 options.parser === "json5" || options.parser === "json") {
44992 return "never-break-after-operator";
44995 if (isComplexDestructuring(node) || isComplexTypeAliasParams(node) || hasComplexTypeAnnotation(node) || isArrowFunctionVariableDeclarator$1(node) && canBreak(leftDoc)) {
44996 return "break-lhs";
44997 } // wrapping object properties with very short keys usually doesn't add much value
45000 const hasShortKey = isObjectPropertyWithShortKey(node, leftDoc, options);
45002 if (path.call(() => shouldBreakAfterOperator(path, options, print, hasShortKey), rightPropertyName)) {
45003 return "break-after-operator";
45006 if (hasShortKey || rightNode.type === "TemplateLiteral" || rightNode.type === "TaggedTemplateExpression" || rightNode.type === "BooleanLiteral" || isNumericLiteral$1(rightNode) || rightNode.type === "ClassExpression") {
45007 return "never-break-after-operator";
45013 function shouldBreakAfterOperator(path, options, print, hasShortKey) {
45014 const rightNode = path.getValue();
45016 if (isBinaryish$1(rightNode) && !shouldInlineLogicalExpression(rightNode)) {
45020 switch (rightNode.type) {
45021 case "StringLiteralTypeAnnotation":
45022 case "SequenceExpression":
45025 case "ConditionalExpression":
45030 return isBinaryish$1(test) && !shouldInlineLogicalExpression(test);
45033 case "ClassExpression":
45034 return isNonEmptyArray$d(rightNode.decorators);
45041 let node = rightNode;
45042 const propertiesForPath = [];
45045 if (node.type === "UnaryExpression") {
45046 node = node.argument;
45047 propertiesForPath.push("argument");
45048 } else if (node.type === "TSNonNullExpression") {
45049 node = node.expression;
45050 propertiesForPath.push("expression");
45056 if (isStringLiteral$1(node) || path.call(() => isPoorlyBreakableMemberOrCallChain(path, options, print), ...propertiesForPath)) {
45061 } // prefer to break destructuring assignment
45062 // if it includes default values or non-shorthand properties
45065 function isComplexDestructuring(node) {
45066 if (isAssignmentOrVariableDeclarator(node)) {
45067 const leftNode = node.left || node.id;
45068 return leftNode.type === "ObjectPattern" && leftNode.properties.length > 2 && leftNode.properties.some(property => isObjectProperty(property) && (!property.shorthand || property.value && property.value.type === "AssignmentPattern"));
45074 function isAssignment(node) {
45075 return node.type === "AssignmentExpression";
45078 function isAssignmentOrVariableDeclarator(node) {
45079 return isAssignment(node) || node.type === "VariableDeclarator";
45082 function isComplexTypeAliasParams(node) {
45083 const typeParams = getTypeParametersFromTypeAlias(node);
45085 if (isNonEmptyArray$d(typeParams)) {
45086 const constraintPropertyName = node.type === "TSTypeAliasDeclaration" ? "constraint" : "bound";
45088 if (typeParams.length > 1 && typeParams.some(param => param[constraintPropertyName] || param.default)) {
45096 function getTypeParametersFromTypeAlias(node) {
45097 if (isTypeAlias(node) && node.typeParameters && node.typeParameters.params) {
45098 return node.typeParameters.params;
45104 function isTypeAlias(node) {
45105 return node.type === "TSTypeAliasDeclaration" || node.type === "TypeAlias";
45108 function hasComplexTypeAnnotation(node) {
45109 if (node.type !== "VariableDeclarator") {
45117 if (!typeAnnotation || !typeAnnotation.typeAnnotation) {
45121 const typeParams = getTypeParametersFromTypeReference(typeAnnotation.typeAnnotation);
45122 return isNonEmptyArray$d(typeParams) && typeParams.length > 1 && typeParams.some(param => isNonEmptyArray$d(getTypeParametersFromTypeReference(param)) || param.type === "TSConditionalType");
45125 function isArrowFunctionVariableDeclarator$1(node) {
45126 return node.type === "VariableDeclarator" && node.init && node.init.type === "ArrowFunctionExpression";
45129 function getTypeParametersFromTypeReference(node) {
45130 if (isTypeReference(node) && node.typeParameters && node.typeParameters.params) {
45131 return node.typeParameters.params;
45137 function isTypeReference(node) {
45138 return node.type === "TSTypeReference" || node.type === "GenericTypeAnnotation";
45141 * A chain with no calls at all or whose calls are all without arguments or with lone short arguments,
45142 * excluding chains printed by `printMemberChain`
45146 function isPoorlyBreakableMemberOrCallChain(path, options, print, deep = false) {
45147 const node = path.getValue();
45149 const goDeeper = () => isPoorlyBreakableMemberOrCallChain(path, options, print, true);
45151 if (node.type === "TSNonNullExpression") {
45152 return path.call(goDeeper, "expression");
45155 if (isCallExpression$4(node)) {
45156 /** @type {any} TODO */
45157 const doc = printCallExpression$1(path, options, print);
45159 if (doc.label === "member-chain") {
45163 const args = getCallArguments$1(node);
45164 const isPoorlyBreakableCall = args.length === 0 || args.length === 1 && isLoneShortArgument(args[0], options);
45166 if (!isPoorlyBreakableCall) {
45170 if (isCallExpressionWithComplexTypeArguments(node, print)) {
45174 return path.call(goDeeper, "callee");
45177 if (isMemberExpression$3(node)) {
45178 return path.call(goDeeper, "object");
45181 return deep && (node.type === "Identifier" || node.type === "ThisExpression");
45184 const LONE_SHORT_ARGUMENT_THRESHOLD_RATE = 0.25;
45186 function isLoneShortArgument(node, {
45189 if (hasComment$a(node)) {
45193 const threshold = printWidth * LONE_SHORT_ARGUMENT_THRESHOLD_RATE;
45195 if (node.type === "ThisExpression" || node.type === "Identifier" && node.name.length <= threshold || isSignedNumericLiteral(node) && !hasComment$a(node.argument)) {
45199 const regexpPattern = node.type === "Literal" && "regex" in node && node.regex.pattern || node.type === "RegExpLiteral" && node.pattern;
45201 if (regexpPattern) {
45202 return regexpPattern.length <= threshold;
45205 if (isStringLiteral$1(node)) {
45206 return rawText$3(node).length <= threshold;
45209 if (node.type === "TemplateLiteral") {
45210 return node.expressions.length === 0 && node.quasis[0].value.raw.length <= threshold && !node.quasis[0].value.raw.includes("\n");
45213 return isLiteral$1(node);
45216 function isObjectPropertyWithShortKey(node, keyDoc, options) {
45217 if (!isObjectProperty(node)) {
45219 } // TODO: for performance, it might make sense to use a more lightweight
45220 // version of cleanDoc, such that it would stop once it detects that
45221 // the doc can't be reduced to a string.
45224 keyDoc = cleanDoc$1(keyDoc);
45225 const MIN_OVERLAP_FOR_BREAK = 3; // ↓↓ - insufficient overlap for a line break
45226 // key1: longValue1,
45227 // ↓↓↓↓↓↓ - overlap is long enough to break
45231 return typeof keyDoc === "string" && getStringWidth$1(keyDoc) < options.tabWidth + MIN_OVERLAP_FOR_BREAK;
45234 function isCallExpressionWithComplexTypeArguments(node, print) {
45235 const typeArgs = getTypeArgumentsFromCallExpression(node);
45237 if (isNonEmptyArray$d(typeArgs)) {
45238 if (typeArgs.length > 1) {
45242 if (typeArgs.length === 1) {
45243 const firstArg = typeArgs[0];
45245 if (firstArg.type === "TSUnionType" || firstArg.type === "UnionTypeAnnotation" || firstArg.type === "TSIntersectionType" || firstArg.type === "IntersectionTypeAnnotation") {
45250 const typeArgsKeyName = node.typeParameters ? "typeParameters" : "typeArguments";
45252 if (willBreak$2(print(typeArgsKeyName))) {
45260 function getTypeArgumentsFromCallExpression(node) {
45261 return node.typeParameters && node.typeParameters.params || node.typeArguments && node.typeArguments.params;
45265 printVariableDeclarator: printVariableDeclarator$1,
45266 printAssignmentExpression: printAssignmentExpression$1,
45267 printAssignment: printAssignment$3,
45268 isArrowFunctionVariableDeclarator: isArrowFunctionVariableDeclarator$1
45272 getNextNonSpaceNonCommentCharacter
45275 printDanglingComments: printDanglingComments$a
45280 hardline: hardline$s,
45281 softline: softline$k,
45287 removeLines: removeLines$2,
45288 willBreak: willBreak$1
45292 getFunctionParameters: getFunctionParameters$2,
45293 iterateFunctionParametersPath,
45294 isSimpleType: isSimpleType$1,
45295 isTestCall: isTestCall$1,
45296 isTypeAnnotationAFunction,
45297 isObjectType: isObjectType$2,
45298 isObjectTypePropertyAFunction: isObjectTypePropertyAFunction$1,
45300 shouldPrintComma: shouldPrintComma$8,
45301 hasComment: hasComment$9,
45302 isNextLineEmpty: isNextLineEmpty$8
45308 ArgExpansionBailout: ArgExpansionBailout$1
45311 printFunctionTypeParameters: printFunctionTypeParameters$1
45314 function printFunctionParameters$3(path, print, options, expandArg, printTypeParams) {
45315 const functionNode = path.getValue();
45316 const parameters = getFunctionParameters$2(functionNode);
45317 const typeParams = printTypeParams ? printFunctionTypeParameters$1(path, options, print) : "";
45319 if (parameters.length === 0) {
45320 return [typeParams, "(", printDanglingComments$a(path, options,
45322 true, comment => getNextNonSpaceNonCommentCharacter(options.originalText, comment, locEnd$m) === ")"), ")"];
45325 const parent = path.getParentNode();
45326 const isParametersInTestCall = isTestCall$1(parent);
45327 const shouldHugParameters = shouldHugFunctionParameters$1(functionNode);
45328 const printed = [];
45329 iterateFunctionParametersPath(path, (parameterPath, index) => {
45330 const isLastParameter = index === parameters.length - 1;
45332 if (isLastParameter && functionNode.rest) {
45333 printed.push("...");
45336 printed.push(print());
45338 if (isLastParameter) {
45344 if (isParametersInTestCall || shouldHugParameters) {
45346 } else if (isNextLineEmpty$8(parameters[index], options)) {
45347 printed.push(hardline$s, hardline$s);
45349 printed.push(line$p);
45351 }); // If the parent is a call with the first/last argument expansion and this is the
45352 // params of the first/last argument, we don't want the arguments to break and instead
45353 // want the whole expression to be on a new line.
45356 // verylongcall( verylongcall((
45363 if (willBreak$1(typeParams) || willBreak$1(printed)) {
45364 // Removing lines in this case leads to broken or ugly output
45365 throw new ArgExpansionBailout$1();
45368 return group$q([removeLines$2(typeParams), "(", removeLines$2(printed), ")"]);
45369 } // Single object destructuring should hug
45378 const hasNotParameterDecorator = parameters.every(node => !node.decorators);
45380 if (shouldHugParameters && hasNotParameterDecorator) {
45381 return [typeParams, "(", ...printed, ")"];
45382 } // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
45385 if (isParametersInTestCall) {
45386 return [typeParams, "(", ...printed, ")"];
45389 const isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction$1(parent) || isTypeAnnotationAFunction(parent) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === functionNode) && parameters.length === 1 && parameters[0].name === null && // `type q = (this: string) => void;`
45390 functionNode.this !== parameters[0] && parameters[0].typeAnnotation && functionNode.typeParameters === null && isSimpleType$1(parameters[0].typeAnnotation) && !functionNode.rest;
45392 if (isFlowShorthandWithOneArg) {
45393 if (options.arrowParens === "always") {
45394 return ["(", ...printed, ")"];
45400 return [typeParams, "(", indent$k([softline$k, ...printed]), ifBreak$i(!hasRestParameter(functionNode) && shouldPrintComma$8(options, "all") ? "," : ""), softline$k, ")"];
45403 function shouldHugFunctionParameters$1(node) {
45408 const parameters = getFunctionParameters$2(node);
45410 if (parameters.length !== 1) {
45414 const [parameter] = parameters;
45415 return !hasComment$9(parameter) && (parameter.type === "ObjectPattern" || parameter.type === "ArrayPattern" || parameter.type === "Identifier" && parameter.typeAnnotation && (parameter.typeAnnotation.type === "TypeAnnotation" || parameter.typeAnnotation.type === "TSTypeAnnotation") && isObjectType$2(parameter.typeAnnotation.typeAnnotation) || parameter.type === "FunctionTypeParam" && isObjectType$2(parameter.typeAnnotation) || parameter.type === "AssignmentPattern" && (parameter.left.type === "ObjectPattern" || parameter.left.type === "ArrayPattern") && (parameter.right.type === "Identifier" || parameter.right.type === "ObjectExpression" && parameter.right.properties.length === 0 || parameter.right.type === "ArrayExpression" && parameter.right.elements.length === 0));
45418 function getReturnTypeNode(functionNode) {
45419 let returnTypeNode;
45421 if (functionNode.returnType) {
45422 returnTypeNode = functionNode.returnType;
45424 if (returnTypeNode.typeAnnotation) {
45425 returnTypeNode = returnTypeNode.typeAnnotation;
45427 } else if (functionNode.typeAnnotation) {
45428 returnTypeNode = functionNode.typeAnnotation;
45431 return returnTypeNode;
45432 } // When parameters are grouped, the return type annotation breaks first.
45435 function shouldGroupFunctionParameters$3(functionNode, returnTypeDoc) {
45436 const returnTypeNode = getReturnTypeNode(functionNode);
45438 if (!returnTypeNode) {
45442 const typeParameters = functionNode.typeParameters && functionNode.typeParameters.params;
45444 if (typeParameters) {
45445 if (typeParameters.length > 1) {
45449 if (typeParameters.length === 1) {
45450 const typeParameter = typeParameters[0];
45452 if (typeParameter.constraint || typeParameter.default) {
45458 return getFunctionParameters$2(functionNode).length === 1 && (isObjectType$2(returnTypeNode) || willBreak$1(returnTypeDoc));
45461 var functionParameters = {
45462 printFunctionParameters: printFunctionParameters$3,
45463 shouldHugFunctionParameters: shouldHugFunctionParameters$1,
45464 shouldGroupFunctionParameters: shouldGroupFunctionParameters$3
45468 printComments: printComments$2,
45469 printDanglingComments: printDanglingComments$9
45479 softline: softline$j,
45485 const pathNeedsParens$2 = needsParens_1;
45487 locStart: locStart$n
45491 isObjectType: isObjectType$1,
45492 hasLeadingOwnLineComment: hasLeadingOwnLineComment$1,
45493 isObjectTypePropertyAFunction,
45494 shouldPrintComma: shouldPrintComma$7
45497 printAssignment: printAssignment$2
45500 printFunctionParameters: printFunctionParameters$2,
45501 shouldGroupFunctionParameters: shouldGroupFunctionParameters$2
45502 } = functionParameters;
45504 printArrayItems: printArrayItems$2
45507 function shouldHugType$2(node) {
45508 if (isSimpleType(node) || isObjectType$1(node)) {
45512 if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") {
45513 const voidCount = node.types.filter(node => node.type === "VoidTypeAnnotation" || node.type === "TSVoidKeyword" || node.type === "NullLiteralTypeAnnotation" || node.type === "TSNullKeyword").length;
45514 const hasObject = node.types.some(node => node.type === "ObjectTypeAnnotation" || node.type === "TSTypeLiteral" || // This is a bit aggressive but captures Array<{x}>
45515 node.type === "GenericTypeAnnotation" || node.type === "TSTypeReference");
45517 if (node.types.length - 1 === voidCount && hasObject) {
45525 function printOpaqueType$1(path, options, print) {
45526 const semi = options.semi ? ";" : "";
45527 const node = path.getValue();
45529 parts.push("opaque type ", print("id"), print("typeParameters"));
45531 if (node.supertype) {
45532 parts.push(": ", print("supertype"));
45535 if (node.impltype) {
45536 parts.push(" = ", print("impltype"));
45543 function printTypeAlias$2(path, options, print) {
45544 const semi = options.semi ? ";" : "";
45545 const node = path.getValue();
45548 if (node.declare) {
45549 parts.push("declare ");
45552 parts.push("type ", print("id"), print("typeParameters"));
45553 const rightPropertyName = node.type === "TSTypeAliasDeclaration" ? "typeAnnotation" : "right";
45554 return [printAssignment$2(path, options, print, parts, " =", rightPropertyName), semi];
45555 } // `TSIntersectionType` and `IntersectionTypeAnnotation`
45558 function printIntersectionType$2(path, options, print) {
45559 const node = path.getValue();
45560 const types = path.map(print, "types");
45562 let wasIndented = false;
45564 for (let i = 0; i < types.length; ++i) {
45566 result.push(types[i]);
45567 } else if (isObjectType$1(node.types[i - 1]) && isObjectType$1(node.types[i])) {
45568 // If both are objects, don't indent
45569 result.push([" & ", wasIndented ? indent$j(types[i]) : types[i]]);
45570 } else if (!isObjectType$1(node.types[i - 1]) && !isObjectType$1(node.types[i])) {
45571 // If no object is involved, go to the next line if it breaks
45572 result.push(indent$j([" &", line$o, types[i]]));
45574 // If you go from object to non-object or vis-versa, then inline it
45576 wasIndented = true;
45579 result.push(" & ", i > 1 ? indent$j(types[i]) : types[i]);
45583 return group$p(result);
45584 } // `TSUnionType` and `UnionTypeAnnotation`
45587 function printUnionType$2(path, options, print) {
45588 const node = path.getValue(); // single-line variation
45590 // multi-line variation
45595 const parent = path.getParentNode(); // If there's a leading comment, the parent is doing the indentation
45597 const shouldIndent = parent.type !== "TypeParameterInstantiation" && parent.type !== "TSTypeParameterInstantiation" && parent.type !== "GenericTypeAnnotation" && parent.type !== "TSTypeReference" && parent.type !== "TSTypeAssertion" && parent.type !== "TupleTypeAnnotation" && parent.type !== "TSTupleType" && !(parent.type === "FunctionTypeParam" && !parent.name && path.getParentNode(1).this !== parent) && !((parent.type === "TypeAlias" || parent.type === "VariableDeclarator" || parent.type === "TSTypeAliasDeclaration") && hasLeadingOwnLineComment$1(options.originalText, node)); // {
45600 // should be inlined and not be printed in the multi-line variant
45602 const shouldHug = shouldHugType$2(node); // We want to align the children but without its comment, so it looks like
45607 const printed = path.map(typePath => {
45608 let printedType = print();
45611 printedType = align$3(2, printedType);
45614 return printComments$2(typePath, printedType, options);
45618 return join$l(" | ", printed);
45621 const shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment$1(options.originalText, node);
45622 const code = [ifBreak$h([shouldAddStartLine ? line$o : "", "| "]), join$l([line$o, "| "], printed)];
45624 if (pathNeedsParens$2(path, options)) {
45625 return group$p([indent$j(code), softline$j]);
45628 if (parent.type === "TupleTypeAnnotation" && parent.types.length > 1 || parent.type === "TSTupleType" && parent.elementTypes.length > 1) {
45629 return group$p([indent$j([ifBreak$h(["(", softline$j]), code]), softline$j, ifBreak$h(")")]);
45632 return group$p(shouldIndent ? indent$j(code) : code);
45633 } // `TSFunctionType` and `FunctionTypeAnnotation`
45636 function printFunctionType$2(path, options, print) {
45637 const node = path.getValue();
45638 const parts = []; // FunctionTypeAnnotation is ambiguous:
45639 // declare function foo(a: B): void; OR
45640 // var A: (a: B) => void;
45642 const parent = path.getParentNode(0);
45643 const parentParent = path.getParentNode(1);
45644 const parentParentParent = path.getParentNode(2);
45645 let isArrowFunctionTypeAnnotation = node.type === "TSFunctionType" || !((parent.type === "ObjectTypeProperty" || parent.type === "ObjectTypeInternalSlot") && !parent.variance && !parent.optional && locStart$n(parent) === locStart$n(node) || parent.type === "ObjectTypeCallProperty" || parentParentParent && parentParentParent.type === "DeclareFunction");
45646 let needsColon = isArrowFunctionTypeAnnotation && (parent.type === "TypeAnnotation" || parent.type === "TSTypeAnnotation"); // Sadly we can't put it inside of AstPath::needsColon because we are
45647 // printing ":" as part of the expression and it would put parenthesis
45650 const needsParens = needsColon && isArrowFunctionTypeAnnotation && (parent.type === "TypeAnnotation" || parent.type === "TSTypeAnnotation") && parentParent.type === "ArrowFunctionExpression";
45652 if (isObjectTypePropertyAFunction(parent)) {
45653 isArrowFunctionTypeAnnotation = true;
45661 const parametersDoc = printFunctionParameters$2(path, print, options,
45664 /* printTypeParams */
45665 true); // The returnType is not wrapped in a TypeAnnotation, so the colon
45666 // needs to be added separately.
45668 const returnTypeDoc = node.returnType || node.predicate || node.typeAnnotation ? [isArrowFunctionTypeAnnotation ? " => " : ": ", print("returnType"), print("predicate"), print("typeAnnotation")] : "";
45669 const shouldGroupParameters = shouldGroupFunctionParameters$2(node, returnTypeDoc);
45670 parts.push(shouldGroupParameters ? group$p(parametersDoc) : parametersDoc);
45672 if (returnTypeDoc) {
45673 parts.push(returnTypeDoc);
45680 return group$p(parts);
45681 } // `TSTupleType` and `TupleTypeAnnotation`
45684 function printTupleType$2(path, options, print) {
45685 const node = path.getValue();
45686 const typesField = node.type === "TSTupleType" ? "elementTypes" : "types";
45687 const hasRest = node[typesField].length > 0 && getLast$c(node[typesField]).type === "TSRestType";
45688 return group$p(["[", indent$j([softline$j, printArrayItems$2(path, options, typesField, print)]), ifBreak$h(shouldPrintComma$7(options, "all") && !hasRest ? "," : ""), printDanglingComments$9(path, options,
45690 true), softline$j, "]"]);
45691 } // `TSIndexedAccessType`, `IndexedAccessType`, and `OptionalIndexedAccessType`
45694 function printIndexedAccessType$2(path, options, print) {
45695 const node = path.getValue();
45696 const leftDelimiter = node.type === "OptionalIndexedAccessType" && node.optional ? "?.[" : "[";
45697 return [print("objectType"), leftDelimiter, print("indexType"), "]"];
45700 var typeAnnotation = {
45701 printOpaqueType: printOpaqueType$1,
45702 printTypeAlias: printTypeAlias$2,
45703 printIntersectionType: printIntersectionType$2,
45704 printUnionType: printUnionType$2,
45705 printFunctionType: printFunctionType$2,
45706 printTupleType: printTupleType$2,
45707 printIndexedAccessType: printIndexedAccessType$2,
45708 shouldHugType: shouldHugType$2
45712 printDanglingComments: printDanglingComments$8
45718 hardline: hardline$r,
45719 softline: softline$i,
45727 hasComment: hasComment$8,
45728 CommentCheckFlags: CommentCheckFlags$8,
45730 shouldPrintComma: shouldPrintComma$6,
45731 getFunctionParameters: getFunctionParameters$1,
45735 createGroupIdMapper: createGroupIdMapper$1
45738 shouldHugType: shouldHugType$1
45739 } = typeAnnotation;
45741 isArrowFunctionVariableDeclarator
45743 const getTypeParametersGroupId$2 = createGroupIdMapper$1("typeParameters");
45745 function printTypeParameters$2(path, options, print, paramsKey) {
45746 const node = path.getValue();
45748 if (!node[paramsKey]) {
45750 } // for TypeParameterDeclaration typeParameters is a single node
45753 if (!Array.isArray(node[paramsKey])) {
45754 return print(paramsKey);
45757 const grandparent = path.getNode(2);
45758 const isParameterInTestCall = grandparent && isTestCall(grandparent);
45759 const isArrowFunctionVariable = path.match(node => !(node[paramsKey].length === 1 && isObjectType(node[paramsKey][0])), undefined, (node, name) => name === "typeAnnotation", node => node.type === "Identifier", isArrowFunctionVariableDeclarator);
45760 const shouldInline = !isArrowFunctionVariable && (isParameterInTestCall || node[paramsKey].length === 0 || node[paramsKey].length === 1 && (node[paramsKey][0].type === "NullableTypeAnnotation" || shouldHugType$1(node[paramsKey][0])));
45762 if (shouldInline) {
45763 return ["<", join$k(", ", path.map(print, paramsKey)), printDanglingCommentsForInline(path, options), ">"];
45764 } // Keep comma if the file extension is .tsx and
45765 // has one type parameter that isn't extend with any types.
45766 // Because, otherwise formatted result will be invalid as tsx.
45769 const trailingComma = node.type === "TSTypeParameterInstantiation" // https://github.com/microsoft/TypeScript/issues/21984
45770 ? "" : getFunctionParameters$1(node).length === 1 && isTSXFile(options) && !node[paramsKey][0].constraint && path.getParentNode().type === "ArrowFunctionExpression" ? "," : shouldPrintComma$6(options, "all") ? ifBreak$g(",") : "";
45771 return group$o(["<", indent$i([softline$i, join$k([",", line$n], path.map(print, paramsKey))]), trailingComma, softline$i, ">"], {
45772 id: getTypeParametersGroupId$2(node)
45776 function printDanglingCommentsForInline(path, options) {
45777 const node = path.getValue();
45779 if (!hasComment$8(node, CommentCheckFlags$8.Dangling)) {
45783 const hasOnlyBlockComments = !hasComment$8(node, CommentCheckFlags$8.Line);
45784 const printed = printDanglingComments$8(path, options,
45786 hasOnlyBlockComments);
45788 if (hasOnlyBlockComments) {
45792 return [printed, hardline$r];
45795 function printTypeParameter$2(path, options, print) {
45796 const node = path.getValue();
45798 const parent = path.getParentNode();
45800 if (parent.type === "TSMappedType") {
45801 parts.push("[", print("name"));
45803 if (node.constraint) {
45804 parts.push(" in ", print("constraint"));
45807 if (parent.nameType) {
45808 parts.push(" as ", path.callParent(() => print("nameType")));
45815 if (node.variance) {
45816 parts.push(print("variance"));
45819 parts.push(print("name"));
45822 parts.push(": ", print("bound"));
45825 if (node.constraint) {
45826 parts.push(" extends ", print("constraint"));
45829 if (node.default) {
45830 parts.push(" = ", print("default"));
45836 var typeParameters = {
45837 printTypeParameter: printTypeParameter$2,
45838 printTypeParameters: printTypeParameters$2,
45839 getTypeParametersGroupId: getTypeParametersGroupId$2
45843 printComments: printComments$1
45846 printString: printString$3,
45847 printNumber: printNumber$3
45853 isStringPropSafeToUnquote,
45857 printAssignment: printAssignment$1
45859 const needsQuoteProps = new WeakMap();
45861 function printPropertyKey$4(path, options, print) {
45862 const node = path.getNode();
45864 if (node.computed) {
45865 return ["[", print("key"), "]"];
45868 const parent = path.getParentNode();
45871 } = node; // flow has `Identifier` key, other parsers use `PrivateIdentifier` (ESTree) or `PrivateName`
45873 if (node.type === "ClassPrivateProperty" && key.type === "Identifier") {
45874 return ["#", print("key")];
45877 if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
45878 const objectHasStringProp = (parent.properties || parent.body || parent.members).some(prop => !prop.computed && prop.key && isStringLiteral(prop.key) && !isStringPropSafeToUnquote(prop, options));
45879 needsQuoteProps.set(parent, objectHasStringProp);
45882 if ((key.type === "Identifier" || isNumericLiteral(key) && isSimpleNumber(printNumber$3(rawText$2(key))) && // Avoid converting 999999999999999999999 to 1e+21, 0.99999999999999999 to 1 and 1.0 to 1.
45883 String(key.value) === printNumber$3(rawText$2(key)) && // Quoting number keys is safe in JS and Flow, but not in TypeScript (as
45884 // mentioned in `isStringPropSafeToUnquote`).
45885 !(options.parser === "typescript" || options.parser === "babel-ts")) && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
45889 const prop = printString$3(JSON.stringify(key.type === "Identifier" ? key.name : key.value.toString()), options);
45890 return path.call(keyPath => printComments$1(keyPath, prop, options), "key");
45893 if (isStringPropSafeToUnquote(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
45897 return path.call(keyPath => printComments$1(keyPath, /^\d/.test(key.value) ? printNumber$3(key.value) : key.value, options), "key");
45900 return print("key");
45903 function printProperty$1(path, options, print) {
45904 const node = path.getValue();
45906 if (node.shorthand) {
45907 return print("value");
45910 return printAssignment$1(path, options, print, printPropertyKey$4(path, options, print), ":", "value");
45914 printProperty: printProperty$1,
45915 printPropertyKey: printPropertyKey$4
45918 /** @typedef {import("../../document/doc-builders").Doc} Doc */
45921 const assert$2 = require$$0__default$3["default"];
45923 printDanglingComments: printDanglingComments$7,
45924 printCommentsSeparately
45926 const getLast$b = getLast_1;
45928 getNextNonSpaceNonCommentCharacterIndex
45933 softline: softline$h,
45936 ifBreak: ifBreak$f,
45937 hardline: hardline$q,
45939 indentIfBreak: indentIfBreak$1
45942 removeLines: removeLines$1,
45947 ArgExpansionBailout
45950 getFunctionParameters,
45951 hasLeadingOwnLineComment,
45952 isFlowAnnotationComment,
45953 isJsxNode: isJsxNode$2,
45954 isTemplateOnItsOwnLine,
45955 shouldPrintComma: shouldPrintComma$5,
45956 startsWithNoLookaheadToken,
45958 isLineComment: isLineComment$2,
45959 hasComment: hasComment$7,
45960 getComments: getComments$2,
45961 CommentCheckFlags: CommentCheckFlags$7,
45962 isCallLikeExpression,
45963 isCallExpression: isCallExpression$3,
45965 hasNakedLeftSide: hasNakedLeftSide$1,
45972 printFunctionParameters: printFunctionParameters$1,
45973 shouldGroupFunctionParameters: shouldGroupFunctionParameters$1
45974 } = functionParameters;
45976 printPropertyKey: printPropertyKey$3
45979 printFunctionTypeParameters
45982 function printFunction$2(path, print, options, args) {
45983 const node = path.getValue();
45984 let expandArg = false;
45986 if ((node.type === "FunctionDeclaration" || node.type === "FunctionExpression") && args && args.expandLastArg) {
45987 const parent = path.getParentNode();
45989 if (isCallExpression$3(parent) && getCallArguments(parent).length > 1) {
45994 const parts = []; // For TypeScript the TSDeclareFunction node shares the AST
45995 // structure with FunctionDeclaration
45997 if (node.type === "TSDeclareFunction" && node.declare) {
45998 parts.push("declare ");
46002 parts.push("async ");
46005 if (node.generator) {
46006 parts.push("function* ");
46008 parts.push("function ");
46012 parts.push(print("id"));
46015 const parametersDoc = printFunctionParameters$1(path, print, options, expandArg);
46016 const returnTypeDoc = printReturnType(path, print, options);
46017 const shouldGroupParameters = shouldGroupFunctionParameters$1(node, returnTypeDoc);
46018 parts.push(printFunctionTypeParameters(path, options, print), group$n([shouldGroupParameters ? group$n(parametersDoc) : parametersDoc, returnTypeDoc]), node.body ? " " : "", print("body"));
46020 if (options.semi && (node.declare || !node.body)) {
46027 function printMethod$2(path, options, print) {
46028 const node = path.getNode();
46032 const value = node.value || node;
46035 if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
46037 parts.push("async ");
46040 assert$2.ok(kind === "get" || kind === "set");
46041 parts.push(kind, " ");
46042 } // A `getter`/`setter` can't be a generator, but it's recoverable
46045 if (value.generator) {
46049 parts.push(printPropertyKey$3(path, options, print), node.optional || node.key.optional ? "?" : "");
46051 if (node === value) {
46052 parts.push(printMethodInternal$1(path, options, print));
46053 } else if (value.type === "FunctionExpression") {
46054 parts.push(path.call(path => printMethodInternal$1(path, options, print), "value"));
46056 parts.push(print("value"));
46062 function printMethodInternal$1(path, options, print) {
46063 const node = path.getNode();
46064 const parametersDoc = printFunctionParameters$1(path, print, options);
46065 const returnTypeDoc = printReturnType(path, print, options);
46066 const shouldGroupParameters = shouldGroupFunctionParameters$1(node, returnTypeDoc);
46067 const parts = [printFunctionTypeParameters(path, options, print), group$n([shouldGroupParameters ? group$n(parametersDoc) : parametersDoc, returnTypeDoc])];
46070 parts.push(" ", print("body"));
46072 parts.push(options.semi ? ";" : "");
46078 function printArrowFunctionSignature(path, options, print, args) {
46079 const node = path.getValue();
46083 parts.push("async ");
46086 if (shouldPrintParamsWithoutParens$1(path, options)) {
46087 parts.push(print(["params", 0]));
46089 const expandArg = args && (args.expandLastArg || args.expandFirstArg);
46090 let returnTypeDoc = printReturnType(path, print, options);
46093 if (willBreak(returnTypeDoc)) {
46094 throw new ArgExpansionBailout();
46097 returnTypeDoc = group$n(removeLines$1(returnTypeDoc));
46100 parts.push(group$n([printFunctionParameters$1(path, print, options, expandArg,
46101 /* printTypeParams */
46102 true), returnTypeDoc]));
46105 const dangling = printDanglingComments$7(path, options,
46108 const nextCharacter = getNextNonSpaceNonCommentCharacterIndex(options.originalText, comment, locEnd$l);
46109 return nextCharacter !== false && options.originalText.slice(nextCharacter, nextCharacter + 2) === "=>";
46113 parts.push(" ", dangling);
46119 function printArrowChain(path, args, signatures, shouldBreak, bodyDoc, tailNode) {
46120 const name = path.getName();
46121 const parent = path.getParentNode();
46122 const isCallee = isCallLikeExpression(parent) && name === "callee";
46123 const isAssignmentRhs = Boolean(args && args.assignmentLayout);
46124 const shouldPutBodyOnSeparateLine = tailNode.body.type !== "BlockStatement" && tailNode.body.type !== "ObjectExpression" && tailNode.body.type !== "SequenceExpression";
46125 const shouldBreakBeforeChain = isCallee && shouldPutBodyOnSeparateLine || args && args.assignmentLayout === "chain-tail-arrow-chain";
46126 const groupId = Symbol("arrow-chain"); // We handle sequence expressions as the body of arrows specially,
46127 // so that the required parentheses end up on their own lines.
46129 if (tailNode.body.type === "SequenceExpression") {
46130 bodyDoc = group$n(["(", indent$h([softline$h, bodyDoc]), softline$h, ")"]);
46133 return group$n([group$n(indent$h([isCallee || isAssignmentRhs ? softline$h : "", group$n(join$j([" =>", line$m], signatures), {
46137 shouldBreak: shouldBreakBeforeChain
46138 }), " =>", indentIfBreak$1(shouldPutBodyOnSeparateLine ? indent$h([line$m, bodyDoc]) : [" ", bodyDoc], {
46140 }), isCallee ? ifBreak$f(softline$h, "", {
46145 function printArrowFunction$1(path, options, print, args) {
46146 let node = path.getValue();
46147 /** @type {Doc[]} */
46149 const signatures = [];
46151 let chainShouldBreak = false;
46154 const doc = printArrowFunctionSignature(path, options, print, args);
46156 if (signatures.length === 0) {
46157 signatures.push(doc);
46162 } = printCommentsSeparately(path, options);
46163 signatures.push([leading, doc]);
46164 body.unshift(trailing);
46167 chainShouldBreak = chainShouldBreak || // Always break the chain if:
46168 node.returnType && getFunctionParameters(node).length > 0 || node.typeParameters || getFunctionParameters(node).some(param => param.type !== "Identifier");
46170 if (node.body.type !== "ArrowFunctionExpression" || args && args.expandLastArg) {
46171 body.unshift(print("body", args));
46174 path.call(rec, "body");
46178 if (signatures.length > 1) {
46179 return printArrowChain(path, args, signatures, chainShouldBreak, body, node);
46182 const parts = signatures;
46183 parts.push(" =>"); // We want to always keep these types of nodes on the same line
46186 if (!hasLeadingOwnLineComment(options.originalText, node.body) && (node.body.type === "ArrayExpression" || node.body.type === "ObjectExpression" || node.body.type === "BlockStatement" || isJsxNode$2(node.body) || isTemplateOnItsOwnLine(node.body, options.originalText) || node.body.type === "ArrowFunctionExpression" || node.body.type === "DoExpression")) {
46187 return group$n([...parts, " ", body]);
46188 } // We handle sequence expressions as the body of arrows specially,
46189 // so that the required parentheses end up on their own lines.
46192 if (node.body.type === "SequenceExpression") {
46193 return group$n([...parts, group$n([" (", indent$h([softline$h, body]), softline$h, ")"])]);
46194 } // if the arrow function is expanded as last argument, we are adding a
46195 // level of indentation and need to add a softline to align the closing )
46196 // with the opening (, or if it's inside a JSXExpression (e.g. an attribute)
46197 // we should align the expression's closing } with the line with the opening {.
46200 const shouldAddSoftLine = (args && args.expandLastArg || path.getParentNode().type === "JSXExpressionContainer") && !hasComment$7(node);
46201 const printTrailingComma = args && args.expandLastArg && shouldPrintComma$5(options, "all"); // In order to avoid confusion between
46205 const shouldAddParens = node.body.type === "ConditionalExpression" && !startsWithNoLookaheadToken(node.body,
46206 /* forbidFunctionAndClass */
46208 return group$n([...parts, group$n([indent$h([line$m, shouldAddParens ? ifBreak$f("", "(") : "", body, shouldAddParens ? ifBreak$f("", ")") : ""]), shouldAddSoftLine ? [ifBreak$f(printTrailingComma ? "," : ""), softline$h] : ""])]);
46211 function canPrintParamsWithoutParens(node) {
46212 const parameters = getFunctionParameters(node);
46213 return parameters.length === 1 && !node.typeParameters && !hasComment$7(node, CommentCheckFlags$7.Dangling) && parameters[0].type === "Identifier" && !parameters[0].typeAnnotation && !hasComment$7(parameters[0]) && !parameters[0].optional && !node.predicate && !node.returnType;
46216 function shouldPrintParamsWithoutParens$1(path, options) {
46217 if (options.arrowParens === "always") {
46221 if (options.arrowParens === "avoid") {
46222 const node = path.getValue();
46223 return canPrintParamsWithoutParens(node);
46224 } // Fallback default; should be unreachable
46226 /* istanbul ignore next */
46231 /** @returns {Doc} */
46234 function printReturnType(path, print, options) {
46235 const node = path.getValue();
46236 const returnType = print("returnType");
46238 if (node.returnType && isFlowAnnotationComment(options.originalText, node.returnType)) {
46239 return [" /*: ", returnType, " */"];
46242 const parts = [returnType]; // prepend colon to TypeScript type annotation
46244 if (node.returnType && node.returnType.typeAnnotation) {
46245 parts.unshift(": ");
46248 if (node.predicate) {
46249 // The return type will already add the colon, but otherwise we
46250 // need to do it ourselves
46251 parts.push(node.returnType ? " " : ": ", print("predicate"));
46255 } // `ReturnStatement` and `ThrowStatement`
46258 function printReturnOrThrowArgument(path, options, print) {
46259 const node = path.getValue();
46260 const semi = options.semi ? ";" : "";
46263 if (node.argument) {
46264 if (returnArgumentHasLeadingComment(options, node.argument)) {
46265 parts.push([" (", indent$h([hardline$q, print("argument")]), hardline$q, ")"]);
46266 } else if (isBinaryish(node.argument) || node.argument.type === "SequenceExpression") {
46267 parts.push(group$n([ifBreak$f(" (", " "), indent$h([softline$h, print("argument")]), softline$h, ifBreak$f(")")]));
46269 parts.push(" ", print("argument"));
46273 const comments = getComments$2(node);
46274 const lastComment = getLast$b(comments);
46275 const isLastCommentLine = lastComment && isLineComment$2(lastComment);
46277 if (isLastCommentLine) {
46281 if (hasComment$7(node, CommentCheckFlags$7.Dangling)) {
46282 parts.push(" ", printDanglingComments$7(path, options,
46287 if (!isLastCommentLine) {
46294 function printReturnStatement$1(path, options, print) {
46295 return ["return", printReturnOrThrowArgument(path, options, print)];
46298 function printThrowStatement$1(path, options, print) {
46299 return ["throw", printReturnOrThrowArgument(path, options, print)];
46300 } // This recurses the return argument, looking for the first token
46301 // (the leftmost leaf node) and, if it (or its parents) has any
46302 // leadingComments, returns true (so it can be wrapped in parens).
46305 function returnArgumentHasLeadingComment(options, argument) {
46306 if (hasLeadingOwnLineComment(options.originalText, argument)) {
46310 if (hasNakedLeftSide$1(argument)) {
46311 let leftMost = argument;
46314 while (newLeftMost = getLeftSide(leftMost)) {
46315 leftMost = newLeftMost;
46317 if (hasLeadingOwnLineComment(options.originalText, leftMost)) {
46327 printFunction: printFunction$2,
46328 printArrowFunction: printArrowFunction$1,
46329 printMethod: printMethod$2,
46330 printReturnStatement: printReturnStatement$1,
46331 printThrowStatement: printThrowStatement$1,
46332 printMethodInternal: printMethodInternal$1,
46333 shouldPrintParamsWithoutParens: shouldPrintParamsWithoutParens$1
46337 isNonEmptyArray: isNonEmptyArray$c,
46338 hasNewline: hasNewline$4
46343 hardline: hardline$p,
46345 breakParent: breakParent$7,
46350 locStart: locStart$m,
46354 getParentExportDeclaration: getParentExportDeclaration$1
46357 function printClassMemberDecorators$1(path, options, print) {
46358 const node = path.getValue();
46359 return group$m([join$i(line$l, path.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators(node, options) ? hardline$p : line$l]);
46362 function printDecoratorsBeforeExport$1(path, options, print) {
46363 // Export declarations are responsible for printing any decorators
46364 // that logically apply to node.declaration.
46365 return [join$i(hardline$p, path.map(print, "declaration", "decorators")), hardline$p];
46368 function printDecorators$1(path, options, print) {
46369 const node = path.getValue();
46374 if (!isNonEmptyArray$c(decorators) || // If the parent node is an export declaration and the decorator
46375 // was written before the export, the export will be responsible
46376 // for printing the decorators.
46377 hasDecoratorsBeforeExport$1(path.getParentNode())) {
46381 const shouldBreak = node.type === "ClassExpression" || node.type === "ClassDeclaration" || hasNewlineBetweenOrAfterDecorators(node, options);
46382 return [getParentExportDeclaration$1(path) ? hardline$p : shouldBreak ? breakParent$7 : "", join$i(line$l, path.map(print, "decorators")), line$l];
46385 function hasNewlineBetweenOrAfterDecorators(node, options) {
46386 return node.decorators.some(decorator => hasNewline$4(options.originalText, locEnd$k(decorator)));
46389 function hasDecoratorsBeforeExport$1(node) {
46390 if (node.type !== "ExportDefaultDeclaration" && node.type !== "ExportNamedDeclaration" && node.type !== "DeclareExportDeclaration") {
46394 const decorators = node.declaration && node.declaration.decorators;
46395 return isNonEmptyArray$c(decorators) && locStart$m(node, {
46396 ignoreDecorators: true
46397 }) > locStart$m(decorators[0]);
46401 printDecorators: printDecorators$1,
46402 printClassMemberDecorators: printClassMemberDecorators$1,
46403 printDecoratorsBeforeExport: printDecoratorsBeforeExport$1,
46404 hasDecoratorsBeforeExport: hasDecoratorsBeforeExport$1
46408 isNonEmptyArray: isNonEmptyArray$b,
46409 createGroupIdMapper
46413 printDanglingComments: printDanglingComments$6
46419 hardline: hardline$o,
46420 softline: softline$g,
46427 hasComment: hasComment$6,
46428 CommentCheckFlags: CommentCheckFlags$6
46431 getTypeParametersGroupId: getTypeParametersGroupId$1
46432 } = typeParameters;
46434 printMethod: printMethod$1
46437 printOptionalToken: printOptionalToken$4,
46438 printTypeAnnotation: printTypeAnnotation$3
46441 printPropertyKey: printPropertyKey$2
46447 printClassMemberDecorators
46450 function printClass$2(path, options, print) {
46451 const node = path.getValue();
46454 if (node.declare) {
46455 parts.push("declare ");
46458 if (node.abstract) {
46459 parts.push("abstract ");
46462 parts.push("class"); // Keep old behaviour of extends in same line
46463 // If there is only on extends and there are not comments
46465 const groupMode = node.id && hasComment$6(node.id, CommentCheckFlags$6.Trailing) || node.superClass && hasComment$6(node.superClass) || isNonEmptyArray$b(node.extends) || // DeclareClass
46466 isNonEmptyArray$b(node.mixins) || isNonEmptyArray$b(node.implements);
46467 const partsGroup = [];
46468 const extendsParts = [];
46471 partsGroup.push(" ", print("id"));
46474 partsGroup.push(print("typeParameters"));
46476 if (node.superClass) {
46477 const printed = ["extends ", printSuperClass(path, options, print), print("superTypeParameters")];
46478 const printedWithComments = path.call(superClass => printComments(superClass, printed, options), "superClass");
46481 extendsParts.push(line$k, group$l(printedWithComments));
46483 extendsParts.push(" ", printedWithComments);
46486 extendsParts.push(printList(path, options, print, "extends"));
46489 extendsParts.push(printList(path, options, print, "mixins"), printList(path, options, print, "implements"));
46492 let printedPartsGroup;
46494 if (shouldIndentOnlyHeritageClauses(node)) {
46495 printedPartsGroup = [...partsGroup, indent$g(extendsParts)];
46497 printedPartsGroup = indent$g([...partsGroup, extendsParts]);
46500 parts.push(group$l(printedPartsGroup, {
46501 id: getHeritageGroupId(node)
46504 parts.push(...partsGroup, ...extendsParts);
46507 parts.push(" ", print("body"));
46511 const getHeritageGroupId = createGroupIdMapper("heritageGroup");
46513 function printHardlineAfterHeritage$2(node) {
46514 return ifBreak$e(hardline$o, "", {
46515 groupId: getHeritageGroupId(node)
46519 function hasMultipleHeritage(node) {
46520 return ["superClass", "extends", "mixins", "implements"].filter(key => Boolean(node[key])).length > 1;
46523 function shouldIndentOnlyHeritageClauses(node) {
46524 return node.typeParameters && !hasComment$6(node.typeParameters, CommentCheckFlags$6.Trailing | CommentCheckFlags$6.Line) && !hasMultipleHeritage(node);
46527 function printList(path, options, print, listName) {
46528 const node = path.getValue();
46530 if (!isNonEmptyArray$b(node[listName])) {
46534 const printedLeadingComments = printDanglingComments$6(path, options,
46538 }) => marker === listName);
46539 return [shouldIndentOnlyHeritageClauses(node) ? ifBreak$e(" ", line$k, {
46540 groupId: getTypeParametersGroupId$1(node.typeParameters)
46541 }) : line$k, printedLeadingComments, printedLeadingComments && hardline$o, listName, group$l(indent$g([line$k, join$h([",", line$k], path.map(print, listName))]))];
46544 function printSuperClass(path, options, print) {
46545 const printed = print("superClass");
46546 const parent = path.getParentNode();
46548 if (parent.type === "AssignmentExpression") {
46549 return group$l(ifBreak$e(["(", indent$g([softline$g, printed]), softline$g, ")"], printed));
46555 function printClassMethod$2(path, options, print) {
46556 const node = path.getValue();
46559 if (isNonEmptyArray$b(node.decorators)) {
46560 parts.push(printClassMemberDecorators(path, options, print));
46563 if (node.accessibility) {
46564 parts.push(node.accessibility + " ");
46565 } // "readonly" and "declare" are supported by only "babel-ts"
46566 // https://github.com/prettier/prettier/issues/9760
46569 if (node.readonly) {
46570 parts.push("readonly ");
46573 if (node.declare) {
46574 parts.push("declare ");
46578 parts.push("static ");
46581 if (node.type === "TSAbstractMethodDefinition" || node.abstract) {
46582 parts.push("abstract ");
46585 if (node.override) {
46586 parts.push("override ");
46589 parts.push(printMethod$1(path, options, print));
46593 function printClassProperty$2(path, options, print) {
46594 const node = path.getValue();
46596 const semi = options.semi ? ";" : "";
46598 if (isNonEmptyArray$b(node.decorators)) {
46599 parts.push(printClassMemberDecorators(path, options, print));
46602 if (node.accessibility) {
46603 parts.push(node.accessibility + " ");
46606 if (node.declare) {
46607 parts.push("declare ");
46611 parts.push("static ");
46614 if (node.type === "TSAbstractPropertyDefinition" || node.abstract) {
46615 parts.push("abstract ");
46618 if (node.override) {
46619 parts.push("override ");
46622 if (node.readonly) {
46623 parts.push("readonly ");
46626 if (node.variance) {
46627 parts.push(print("variance"));
46630 parts.push(printPropertyKey$2(path, options, print), printOptionalToken$4(path), printTypeAnnotation$3(path, options, print));
46631 return [printAssignment(path, options, print, parts, " =", "value"), semi];
46635 printClass: printClass$2,
46636 printClassMethod: printClassMethod$2,
46637 printClassProperty: printClassProperty$2,
46638 printHardlineAfterHeritage: printHardlineAfterHeritage$2
46642 isNonEmptyArray: isNonEmptyArray$a
46654 hasComment: hasComment$5,
46656 CommentCheckFlags: CommentCheckFlags$5
46659 getTypeParametersGroupId
46660 } = typeParameters;
46662 printTypeScriptModifiers: printTypeScriptModifiers$1
46665 function printInterface$2(path, options, print) {
46666 const node = path.getValue();
46669 if (node.declare) {
46670 parts.push("declare ");
46673 if (node.type === "TSInterfaceDeclaration") {
46674 parts.push(node.abstract ? "abstract " : "", printTypeScriptModifiers$1(path, options, print));
46677 parts.push("interface");
46678 const partsGroup = [];
46679 const extendsParts = [];
46681 if (node.type !== "InterfaceTypeAnnotation") {
46682 partsGroup.push(" ", print("id"), print("typeParameters"));
46685 const shouldIndentOnlyHeritageClauses = node.typeParameters && !hasComment$5(node.typeParameters, CommentCheckFlags$5.Trailing | CommentCheckFlags$5.Line);
46687 if (isNonEmptyArray$a(node.extends)) {
46688 extendsParts.push(shouldIndentOnlyHeritageClauses ? ifBreak$d(" ", line$j, {
46689 groupId: getTypeParametersGroupId(node.typeParameters)
46690 }) : line$j, "extends ", (node.extends.length === 1 ? identity : indent$f)(join$g([",", line$j], path.map(print, "extends"))));
46693 if (node.id && hasComment$5(node.id, CommentCheckFlags$5.Trailing) || isNonEmptyArray$a(node.extends)) {
46694 if (shouldIndentOnlyHeritageClauses) {
46695 parts.push(group$k([...partsGroup, indent$f(extendsParts)]));
46697 parts.push(group$k(indent$f([...partsGroup, ...extendsParts])));
46700 parts.push(...partsGroup, ...extendsParts);
46703 parts.push(" ", print("body"));
46704 return group$k(parts);
46708 printInterface: printInterface$2
46712 isNonEmptyArray: isNonEmptyArray$9
46716 softline: softline$f,
46721 ifBreak: ifBreak$c,
46722 hardline: hardline$n
46726 printDanglingComments: printDanglingComments$5
46729 hasComment: hasComment$4,
46730 CommentCheckFlags: CommentCheckFlags$4,
46731 shouldPrintComma: shouldPrintComma$4,
46732 needsHardlineAfterDanglingComment: needsHardlineAfterDanglingComment$1
46735 locStart: locStart$l,
46739 hasDecoratorsBeforeExport,
46740 printDecoratorsBeforeExport
46743 * @typedef {import("../../document").Doc} Doc
46746 function printImportDeclaration$1(path, options, print) {
46747 const node = path.getValue();
46748 const semi = options.semi ? ";" : "";
46749 /** @type{Doc[]} */
46755 parts.push("import");
46757 if (importKind && importKind !== "value") {
46758 parts.push(" ", importKind);
46761 parts.push(printModuleSpecifiers(path, options, print), printModuleSource(path, options, print), printImportAssertions(path, options, print), semi);
46765 function printExportDeclaration$2(path, options, print) {
46766 const node = path.getValue();
46767 /** @type{Doc[]} */
46769 const parts = []; // Only print decorators here if they were written before the export,
46770 // otherwise they are printed by the node.declaration
46772 if (hasDecoratorsBeforeExport(node)) {
46773 parts.push(printDecoratorsBeforeExport(path, options, print));
46781 parts.push("export");
46782 const isDefaultExport = node.default || type === "ExportDefaultDeclaration";
46784 if (isDefaultExport) {
46785 parts.push(" default");
46788 if (hasComment$4(node, CommentCheckFlags$4.Dangling)) {
46789 parts.push(" ", printDanglingComments$5(path, options,
46793 if (needsHardlineAfterDanglingComment$1(node)) {
46794 parts.push(hardline$n);
46799 parts.push(" ", print("declaration"));
46801 parts.push(exportKind === "type" ? " type" : "", printModuleSpecifiers(path, options, print), printModuleSource(path, options, print), printImportAssertions(path, options, print));
46804 if (shouldExportDeclarationPrintSemi(node, options)) {
46811 function printExportAllDeclaration$2(path, options, print) {
46812 const node = path.getValue();
46813 const semi = options.semi ? ";" : "";
46814 /** @type{Doc[]} */
46821 parts.push("export");
46823 if (exportKind === "type") {
46824 parts.push(" type");
46830 parts.push(" as ", print("exported"));
46833 parts.push(printModuleSource(path, options, print), printImportAssertions(path, options, print), semi);
46837 function shouldExportDeclarationPrintSemi(node, options) {
46838 if (!options.semi) {
46846 const isDefaultExport = node.default || type === "ExportDefaultDeclaration";
46848 if (!declaration) {
46853 type: declarationType
46856 if (isDefaultExport && declarationType !== "ClassDeclaration" && declarationType !== "FunctionDeclaration" && declarationType !== "TSInterfaceDeclaration" && declarationType !== "DeclareClass" && declarationType !== "DeclareFunction" && declarationType !== "TSDeclareFunction" && declarationType !== "EnumDeclaration") {
46863 function printModuleSource(path, options, print) {
46864 const node = path.getValue();
46866 if (!node.source) {
46869 /** @type{Doc[]} */
46874 if (!shouldNotPrintSpecifiers(node, options)) {
46875 parts.push(" from");
46878 parts.push(" ", print("source"));
46882 function printModuleSpecifiers(path, options, print) {
46883 const node = path.getValue();
46885 if (shouldNotPrintSpecifiers(node, options)) {
46888 /** @type{Doc[]} */
46891 const parts = [" "];
46893 if (isNonEmptyArray$9(node.specifiers)) {
46894 const standaloneSpecifiers = [];
46895 const groupedSpecifiers = [];
46897 const specifierType = path.getValue().type;
46899 if (specifierType === "ExportNamespaceSpecifier" || specifierType === "ExportDefaultSpecifier" || specifierType === "ImportNamespaceSpecifier" || specifierType === "ImportDefaultSpecifier") {
46900 standaloneSpecifiers.push(print());
46901 } else if (specifierType === "ExportSpecifier" || specifierType === "ImportSpecifier") {
46902 groupedSpecifiers.push(print());
46904 /* istanbul ignore next */
46905 throw new Error(`Unknown specifier type ${JSON.stringify(specifierType)}`);
46908 parts.push(join$f(", ", standaloneSpecifiers));
46910 if (groupedSpecifiers.length > 0) {
46911 if (standaloneSpecifiers.length > 0) {
46915 const canBreak = groupedSpecifiers.length > 1 || standaloneSpecifiers.length > 0 || node.specifiers.some(node => hasComment$4(node));
46918 parts.push(group$j(["{", indent$e([options.bracketSpacing ? line$i : softline$f, join$f([",", line$i], groupedSpecifiers)]), ifBreak$c(shouldPrintComma$4(options) ? "," : ""), options.bracketSpacing ? line$i : softline$f, "}"]));
46920 parts.push(["{", options.bracketSpacing ? " " : "", ...groupedSpecifiers, options.bracketSpacing ? " " : "", "}"]);
46930 function shouldNotPrintSpecifiers(node, options) {
46938 if (type !== "ImportDeclaration" || isNonEmptyArray$9(specifiers) || importKind === "type") {
46940 } // TODO: check tokens
46943 return !/{\s*}/.test(options.originalText.slice(locStart$l(node), locStart$l(source)));
46946 function printImportAssertions(path, options, print) {
46947 const node = path.getNode();
46949 if (isNonEmptyArray$9(node.assertions)) {
46950 return [" assert {", options.bracketSpacing ? " " : "", join$f(", ", path.map(print, "assertions")), options.bracketSpacing ? " " : "", "}"];
46956 function printModuleSpecifier$1(path, options, print) {
46957 const node = path.getNode();
46961 /** @type {Doc[]} */
46964 /** @type {"type" | "typeof" | "value"} */
46966 const kind = type === "ImportSpecifier" ? node.importKind : node.exportKind;
46968 if (kind && kind !== "value") {
46969 parts.push(kind, " ");
46972 const isImport = type.startsWith("Import");
46973 const leftSideProperty = isImport ? "imported" : "local";
46974 const rightSideProperty = isImport ? "local" : "exported";
46978 if (type === "ExportNamespaceSpecifier" || type === "ImportNamespaceSpecifier") {
46980 } else if (node[leftSideProperty]) {
46981 left = print(leftSideProperty);
46984 if (node[rightSideProperty] && (!node[leftSideProperty] || // import {a as a} from '.'
46985 !hasSameLoc(node[leftSideProperty], node[rightSideProperty]))) {
46986 right = print(rightSideProperty);
46989 parts.push(left, left && right ? " as " : "", right);
46994 printImportDeclaration: printImportDeclaration$1,
46995 printExportDeclaration: printExportDeclaration$2,
46996 printExportAllDeclaration: printExportAllDeclaration$2,
46997 printModuleSpecifier: printModuleSpecifier$1
47001 printDanglingComments: printDanglingComments$4
47006 softline: softline$e,
47009 ifBreak: ifBreak$b,
47010 hardline: hardline$m
47014 getLast: getLast$a,
47015 hasNewlineInRange: hasNewlineInRange$2,
47016 hasNewline: hasNewline$3,
47017 isNonEmptyArray: isNonEmptyArray$8
47020 shouldPrintComma: shouldPrintComma$3,
47021 hasComment: hasComment$3,
47022 getComments: getComments$1,
47023 CommentCheckFlags: CommentCheckFlags$3,
47024 isNextLineEmpty: isNextLineEmpty$7
47027 locStart: locStart$k,
47031 printOptionalToken: printOptionalToken$3,
47032 printTypeAnnotation: printTypeAnnotation$2
47035 shouldHugFunctionParameters
47036 } = functionParameters;
47039 } = typeAnnotation;
47041 printHardlineAfterHeritage: printHardlineAfterHeritage$1
47043 /** @typedef {import("../../document").Doc} Doc */
47045 function printObject$3(path, options, print) {
47046 const semi = options.semi ? ";" : "";
47047 const node = path.getValue();
47048 let propertiesField;
47050 if (node.type === "TSTypeLiteral") {
47051 propertiesField = "members";
47052 } else if (node.type === "TSInterfaceBody") {
47053 propertiesField = "body";
47055 propertiesField = "properties";
47058 const isTypeAnnotation = node.type === "ObjectTypeAnnotation";
47059 const fields = [propertiesField];
47061 if (isTypeAnnotation) {
47062 fields.push("indexers", "callProperties", "internalSlots");
47065 const firstProperty = fields.map(field => node[field][0]).sort((a, b) => locStart$k(a) - locStart$k(b))[0];
47066 const parent = path.getParentNode(0);
47067 const isFlowInterfaceLikeBody = isTypeAnnotation && parent && (parent.type === "InterfaceDeclaration" || parent.type === "DeclareInterface" || parent.type === "DeclareClass") && path.getName() === "body";
47068 const shouldBreak = node.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || node.type === "ObjectPattern" && parent.type !== "FunctionDeclaration" && parent.type !== "FunctionExpression" && parent.type !== "ArrowFunctionExpression" && parent.type !== "ObjectMethod" && parent.type !== "ClassMethod" && parent.type !== "ClassPrivateMethod" && parent.type !== "AssignmentPattern" && parent.type !== "CatchClause" && node.properties.some(property => property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern")) || node.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$2(options.originalText, locStart$k(node), locStart$k(firstProperty));
47069 const separator = isFlowInterfaceLikeBody ? ";" : node.type === "TSInterfaceBody" || node.type === "TSTypeLiteral" ? ifBreak$b(semi, ";") : ",";
47070 const leftBrace = node.type === "RecordExpression" ? "#{" : node.exact ? "{|" : "{";
47071 const rightBrace = node.exact ? "|}" : "}"; // Unfortunately, things are grouped together in the ast can be
47072 // interleaved in the source code. So we need to reorder them before
47075 const propsAndLoc = [];
47077 for (const field of fields) {
47078 path.each(childPath => {
47079 const node = childPath.getValue();
47083 loc: locStart$k(node)
47088 if (fields.length > 1) {
47089 propsAndLoc.sort((a, b) => a.loc - b.loc);
47091 /** @type {Doc[]} */
47094 let separatorParts = [];
47095 const props = propsAndLoc.map(prop => {
47096 const result = [...separatorParts, group$i(prop.printed)];
47097 separatorParts = [separator, line$h];
47099 if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignatureDeclaration") && hasComment$3(prop.node, CommentCheckFlags$3.PrettierIgnore)) {
47100 separatorParts.shift();
47103 if (isNextLineEmpty$7(prop.node, options)) {
47104 separatorParts.push(hardline$m);
47110 if (node.inexact) {
47113 if (hasComment$3(node, CommentCheckFlags$3.Dangling)) {
47114 const hasLineComments = hasComment$3(node, CommentCheckFlags$3.Line);
47115 const printedDanglingComments = printDanglingComments$4(path, options,
47118 printed = [printedDanglingComments, hasLineComments || hasNewline$3(options.originalText, locEnd$j(getLast$a(getComments$1(node)))) ? hardline$m : line$h, "..."];
47123 props.push([...separatorParts, ...printed]);
47126 const lastElem = getLast$a(node[propertiesField]);
47127 const canHaveTrailingSeparator = !(node.inexact || lastElem && lastElem.type === "RestElement" || lastElem && (lastElem.type === "TSPropertySignature" || lastElem.type === "TSCallSignatureDeclaration" || lastElem.type === "TSMethodSignature" || lastElem.type === "TSConstructSignatureDeclaration") && hasComment$3(lastElem, CommentCheckFlags$3.PrettierIgnore));
47130 if (props.length === 0) {
47131 if (!hasComment$3(node, CommentCheckFlags$3.Dangling)) {
47132 return [leftBrace, rightBrace, printTypeAnnotation$2(path, options, print)];
47135 content = group$i([leftBrace, printDanglingComments$4(path, options), softline$e, rightBrace, printOptionalToken$3(path), printTypeAnnotation$2(path, options, print)]);
47137 content = [isFlowInterfaceLikeBody && isNonEmptyArray$8(node.properties) ? printHardlineAfterHeritage$1(parent) : "", leftBrace, indent$d([options.bracketSpacing ? line$h : softline$e, ...props]), ifBreak$b(canHaveTrailingSeparator && (separator !== "," || shouldPrintComma$3(options)) ? separator : ""), options.bracketSpacing ? line$h : softline$e, rightBrace, printOptionalToken$3(path), printTypeAnnotation$2(path, options, print)];
47138 } // If we inline the object as first argument of the parent, we don't want
47139 // to create another group so that the object breaks before the return
47143 if (path.match(node => node.type === "ObjectPattern" && !node.decorators, (node, name, number) => shouldHugFunctionParameters(node) && (name === "params" || name === "parameters" || name === "this" || name === "rest") && number === 0) || path.match(shouldHugType, (node, name) => name === "typeAnnotation", (node, name) => name === "typeAnnotation", (node, name, number) => shouldHugFunctionParameters(node) && (name === "params" || name === "parameters" || name === "this" || name === "rest") && number === 0) || // Assignment printing logic (printAssignment) is responsible
47144 // for adding a group if needed
47145 !shouldBreak && path.match(node => node.type === "ObjectPattern", node => node.type === "AssignmentExpression" || node.type === "VariableDeclarator")) {
47149 return group$i(content, {
47155 printObject: printObject$3
47158 /** @typedef {import("../../document").Doc} Doc */
47161 const assert$1 = require$$0__default$3["default"];
47163 printDanglingComments: printDanglingComments$3
47166 printString: printString$2,
47167 printNumber: printNumber$2
47171 hardline: hardline$l,
47172 softline: softline$d,
47178 getParentExportDeclaration,
47179 isFunctionNotation,
47181 rawText: rawText$1,
47182 shouldPrintComma: shouldPrintComma$2
47185 locStart: locStart$j,
47189 printClass: printClass$1
47193 printTypeAlias: printTypeAlias$1,
47194 printIntersectionType: printIntersectionType$1,
47195 printUnionType: printUnionType$1,
47196 printFunctionType: printFunctionType$1,
47197 printTupleType: printTupleType$1,
47198 printIndexedAccessType: printIndexedAccessType$1
47199 } = typeAnnotation;
47201 printInterface: printInterface$1
47204 printTypeParameter: printTypeParameter$1,
47205 printTypeParameters: printTypeParameters$1
47206 } = typeParameters;
47208 printExportDeclaration: printExportDeclaration$1,
47209 printExportAllDeclaration: printExportAllDeclaration$1
47212 printArrayItems: printArrayItems$1
47215 printObject: printObject$2
47218 printPropertyKey: printPropertyKey$1
47221 printOptionalToken: printOptionalToken$2,
47222 printTypeAnnotation: printTypeAnnotation$1,
47223 printRestSpread: printRestSpread$1
47226 function printFlow$1(path, options, print) {
47227 const node = path.getValue();
47228 const semi = options.semi ? ";" : "";
47229 /** @type{Doc[]} */
47233 switch (node.type) {
47234 case "DeclareClass":
47235 return printFlowDeclaration(path, printClass$1(path, options, print));
47237 case "DeclareFunction":
47238 return printFlowDeclaration(path, ["function ", print("id"), node.predicate ? " " : "", print("predicate"), semi]);
47240 case "DeclareModule":
47241 return printFlowDeclaration(path, ["module ", print("id"), " ", print("body")]);
47243 case "DeclareModuleExports":
47244 return printFlowDeclaration(path, ["module.exports", ": ", print("typeAnnotation"), semi]);
47246 case "DeclareVariable":
47247 return printFlowDeclaration(path, ["var ", print("id"), semi]);
47249 case "DeclareOpaqueType":
47250 return printFlowDeclaration(path, printOpaqueType(path, options, print));
47252 case "DeclareInterface":
47253 return printFlowDeclaration(path, printInterface$1(path, options, print));
47255 case "DeclareTypeAlias":
47256 return printFlowDeclaration(path, printTypeAlias$1(path, options, print));
47258 case "DeclareExportDeclaration":
47259 return printFlowDeclaration(path, printExportDeclaration$1(path, options, print));
47261 case "DeclareExportAllDeclaration":
47262 return printFlowDeclaration(path, printExportAllDeclaration$1(path, options, print));
47265 return printOpaqueType(path, options, print);
47268 return printTypeAlias$1(path, options, print);
47270 case "IntersectionTypeAnnotation":
47271 return printIntersectionType$1(path, options, print);
47273 case "UnionTypeAnnotation":
47274 return printUnionType$1(path, options, print);
47276 case "FunctionTypeAnnotation":
47277 return printFunctionType$1(path, options, print);
47279 case "TupleTypeAnnotation":
47280 return printTupleType$1(path, options, print);
47282 case "GenericTypeAnnotation":
47283 return [print("id"), printTypeParameters$1(path, options, print, "typeParameters")];
47285 case "IndexedAccessType":
47286 case "OptionalIndexedAccessType":
47287 return printIndexedAccessType$1(path, options, print);
47288 // Type Annotations for Facebook Flow, typically stripped out or
47289 // transformed away before printing.
47291 case "TypeAnnotation":
47292 return print("typeAnnotation");
47294 case "TypeParameter":
47295 return printTypeParameter$1(path, options, print);
47297 case "TypeofTypeAnnotation":
47298 return ["typeof ", print("argument")];
47300 case "ExistsTypeAnnotation":
47303 case "EmptyTypeAnnotation":
47306 case "MixedTypeAnnotation":
47309 case "ArrayTypeAnnotation":
47310 return [print("elementType"), "[]"];
47312 case "BooleanLiteralTypeAnnotation":
47313 return String(node.value);
47315 case "EnumDeclaration":
47316 return ["enum ", print("id"), " ", print("body")];
47318 case "EnumBooleanBody":
47319 case "EnumNumberBody":
47320 case "EnumStringBody":
47321 case "EnumSymbolBody":
47323 if (node.type === "EnumSymbolBody" || node.explicitType) {
47326 switch (node.type) {
47327 case "EnumBooleanBody":
47331 case "EnumNumberBody":
47335 case "EnumStringBody":
47339 case "EnumSymbolBody":
47344 parts.push("of ", type, " ");
47347 if (node.members.length === 0 && !node.hasUnknownMembers) {
47348 parts.push(group$h(["{", printDanglingComments$3(path, options), softline$d, "}"]));
47350 const members = node.members.length > 0 ? [hardline$l, printArrayItems$1(path, options, "members", print), node.hasUnknownMembers || shouldPrintComma$2(options) ? "," : ""] : [];
47351 parts.push(group$h(["{", indent$c([...members, ...(node.hasUnknownMembers ? [hardline$l, "..."] : [])]), printDanglingComments$3(path, options,
47353 true), hardline$l, "}"]));
47359 case "EnumBooleanMember":
47360 case "EnumNumberMember":
47361 case "EnumStringMember":
47362 return [print("id"), " = ", typeof node.init === "object" ? print("init") : String(node.init)];
47364 case "EnumDefaultedMember":
47365 return print("id");
47367 case "FunctionTypeParam":
47369 const name = node.name ? print("name") : path.getParentNode().this === node ? "this" : "";
47370 return [name, printOptionalToken$2(path), name ? ": " : "", print("typeAnnotation")];
47373 case "InterfaceDeclaration":
47374 case "InterfaceTypeAnnotation":
47375 return printInterface$1(path, options, print);
47377 case "ClassImplements":
47378 case "InterfaceExtends":
47379 return [print("id"), print("typeParameters")];
47381 case "NullableTypeAnnotation":
47382 return ["?", print("typeAnnotation")];
47389 assert$1.ok(kind === "plus" || kind === "minus");
47390 return kind === "plus" ? "+" : "-";
47393 case "ObjectTypeCallProperty":
47395 parts.push("static ");
47398 parts.push(print("value"));
47401 case "ObjectTypeIndexer":
47403 return [node.variance ? print("variance") : "", "[", print("id"), node.id ? ": " : "", print("key"), "]: ", print("value")];
47406 case "ObjectTypeProperty":
47411 modifier = "proto ";
47412 } else if (node.static) {
47413 modifier = "static ";
47416 return [modifier, isGetterOrSetter(node) ? node.kind + " " : "", node.variance ? print("variance") : "", printPropertyKey$1(path, options, print), printOptionalToken$2(path), isFunctionNotation(node) ? "" : ": ", print("value")];
47419 case "ObjectTypeAnnotation":
47420 return printObject$2(path, options, print);
47422 case "ObjectTypeInternalSlot":
47423 return [node.static ? "static " : "", "[[", print("id"), "]]", printOptionalToken$2(path), node.method ? "" : ": ", print("value")];
47424 // Same as `RestElement`
47426 case "ObjectTypeSpreadProperty":
47427 return printRestSpread$1(path, options, print);
47429 case "QualifiedTypeIdentifier":
47430 return [print("qualification"), ".", print("id")];
47432 case "StringLiteralTypeAnnotation":
47433 return printString$2(rawText$1(node), options);
47435 case "NumberLiteralTypeAnnotation":
47436 assert$1.strictEqual(typeof node.value, "number");
47439 case "BigIntLiteralTypeAnnotation":
47441 return printNumber$2(node.extra.raw);
47444 return printNumber$2(node.raw);
47446 case "TypeCastExpression":
47448 return ["(", print("expression"), printTypeAnnotation$1(path, options, print), ")"];
47451 case "TypeParameterDeclaration":
47452 case "TypeParameterInstantiation":
47454 const printed = printTypeParameters$1(path, options, print, "params");
47456 if (options.parser === "flow") {
47457 const start = locStart$j(node);
47458 const end = locEnd$i(node);
47459 const commentStartIndex = options.originalText.lastIndexOf("/*", start);
47460 const commentEndIndex = options.originalText.indexOf("*/", end);
47462 if (commentStartIndex !== -1 && commentEndIndex !== -1) {
47463 const comment = options.originalText.slice(commentStartIndex + 2, commentEndIndex).trim();
47465 if (comment.startsWith("::") && !comment.includes("/*") && !comment.includes("*/")) {
47466 return ["/*:: ", printed, " */"];
47474 case "InferredPredicate":
47476 // Unhandled types below. If encountered, nodes of these types should
47477 // be either left alone or desugared into AST types that are fully
47478 // supported by the pretty-printer.
47480 case "DeclaredPredicate":
47481 return ["%checks(", print("value"), ")"];
47483 case "AnyTypeAnnotation":
47486 case "BooleanTypeAnnotation":
47489 case "BigIntTypeAnnotation":
47492 case "NullLiteralTypeAnnotation":
47495 case "NumberTypeAnnotation":
47498 case "SymbolTypeAnnotation":
47501 case "StringTypeAnnotation":
47504 case "VoidTypeAnnotation":
47507 case "ThisTypeAnnotation":
47509 // These types are unprintable because they serve as abstract
47510 // supertypes for other (printable) types.
47514 case "SourceLocation":
47520 case "Declaration":
47522 case "NamedSpecifier":
47524 case "MemberTypeAnnotation": // Flow
47527 /* istanbul ignore next */
47528 throw new Error("unprintable type: " + JSON.stringify(node.type));
47532 function printFlowDeclaration(path, printed) {
47533 const parentExportDecl = getParentExportDeclaration(path);
47535 if (parentExportDecl) {
47536 assert$1.strictEqual(parentExportDecl.type, "DeclareExportDeclaration");
47538 } // If the parent node has type DeclareExportDeclaration, then it
47539 // will be responsible for printing the "declare" token. Otherwise
47540 // it needs to be printed with this non-exported declaration node.
47543 return ["declare ", printed];
47547 printFlow: printFlow$1
47551 hasNewlineInRange: hasNewlineInRange$1
47554 isJsxNode: isJsxNode$1,
47555 isBlockComment: isBlockComment$2,
47557 isCallExpression: isCallExpression$2,
47558 isMemberExpression: isMemberExpression$2
47561 locStart: locStart$i,
47567 softline: softline$c,
47571 ifBreak: ifBreak$a,
47573 breakParent: breakParent$6
47577 * @typedef {import("../../document").Doc} Doc
47578 * @typedef {import("../../common/ast-path")} AstPath
47580 * @typedef {any} Options - Prettier options (TBD ...)
47582 // If we have nested conditional expressions, we want to print them in JSX mode
47583 // if there's at least one JSXElement somewhere in the tree.
47585 // A conditional expression chain like this should be printed in normal mode,
47586 // because there aren't JSXElements anywhere in it:
47588 // isA ? "A" : isB ? "B" : isC ? "C" : "Unknown";
47590 // But a conditional expression chain like this should be printed in JSX mode,
47591 // because there is a JSXElement in the last ConditionalExpression:
47593 // isA ? "A" : isB ? "B" : isC ? "C" : <span className="warning">Unknown</span>;
47595 // This type of ConditionalExpression chain is structured like this in the AST:
47597 // ConditionalExpression {
47599 // consequent: ...,
47600 // alternate: ConditionalExpression {
47602 // consequent: ...,
47603 // alternate: ConditionalExpression {
47605 // consequent: ...,
47611 function conditionalExpressionChainContainsJsx(node) {
47612 // Given this code:
47614 // // Using a ConditionalExpression as the consequent is uncommon, but should
47616 // A ? B : C ? D : E ? F ? G : H : I
47618 // which has this AST:
47620 // ConditionalExpression {
47621 // test: Identifier(A),
47622 // consequent: Identifier(B),
47623 // alternate: ConditionalExpression {
47624 // test: Identifier(C),
47625 // consequent: Identifier(D),
47626 // alternate: ConditionalExpression {
47627 // test: Identifier(E),
47628 // consequent: ConditionalExpression {
47629 // test: Identifier(F),
47630 // consequent: Identifier(G),
47631 // alternate: Identifier(H),
47633 // alternate: Identifier(I),
47638 // We don't care about whether each node was the test, consequent, or alternate
47639 // We are only checking if there's any JSXElements inside.
47640 const conditionalExpressions = [node];
47642 for (let index = 0; index < conditionalExpressions.length; index++) {
47643 const conditionalExpression = conditionalExpressions[index];
47645 for (const property of ["test", "consequent", "alternate"]) {
47646 const node = conditionalExpression[property];
47648 if (isJsxNode$1(node)) {
47652 if (node.type === "ConditionalExpression") {
47653 conditionalExpressions.push(node);
47661 function printTernaryTest(path, options, print) {
47662 const node = path.getValue();
47663 const isConditionalExpression = node.type === "ConditionalExpression";
47664 const alternateNodePropertyName = isConditionalExpression ? "alternate" : "falseType";
47665 const parent = path.getParentNode();
47666 const printed = isConditionalExpression ? print("test") : [print("checkType"), " ", "extends", " ", print("extendsType")];
47678 if (parent.type === node.type && parent[alternateNodePropertyName] === node) {
47679 return align$2(2, printed);
47685 const ancestorNameMap = new Map([["AssignmentExpression", "right"], ["VariableDeclarator", "init"], ["ReturnStatement", "argument"], ["ThrowStatement", "argument"], ["UnaryExpression", "argument"], ["YieldExpression", "argument"]]);
47687 function shouldExtraIndentForConditionalExpression(path) {
47688 const node = path.getValue();
47690 if (node.type !== "ConditionalExpression") {
47697 for (let ancestorCount = 0; !parent; ancestorCount++) {
47698 const node = path.getParentNode(ancestorCount);
47700 if (isCallExpression$2(node) && node.callee === child || isMemberExpression$2(node) && node.object === child || node.type === "TSNonNullExpression" && node.expression === child) {
47703 } // Reached chain root
47706 if (node.type === "NewExpression" && node.callee === child || node.type === "TSAsExpression" && node.expression === child) {
47707 parent = path.getParentNode(ancestorCount + 1);
47712 } // Do not add indent to direct `ConditionalExpression`
47715 if (child === node) {
47719 return parent[ancestorNameMap.get(parent.type)] === child;
47722 * The following is the shared logic for
47723 * ternary operators, namely ConditionalExpression
47724 * and TSConditionalType
47725 * @param {AstPath} path - The path to the ConditionalExpression/TSConditionalType node.
47726 * @param {Options} options - Prettier options
47727 * @param {Function} print - Print function to call recursively
47732 function printTernary$2(path, options, print) {
47733 const node = path.getValue();
47734 const isConditionalExpression = node.type === "ConditionalExpression";
47735 const consequentNodePropertyName = isConditionalExpression ? "consequent" : "trueType";
47736 const alternateNodePropertyName = isConditionalExpression ? "alternate" : "falseType";
47737 const testNodePropertyNames = isConditionalExpression ? ["test"] : ["checkType", "extendsType"];
47738 const consequentNode = node[consequentNodePropertyName];
47739 const alternateNode = node[alternateNodePropertyName];
47740 const parts = []; // We print a ConditionalExpression in either "JSX mode" or "normal mode".
47741 // See `tests/format/jsx/conditional-expression.js` for more info.
47743 let jsxMode = false;
47744 const parent = path.getParentNode();
47745 const isParentTest = parent.type === node.type && testNodePropertyNames.some(prop => parent[prop] === node);
47746 let forceNoIndent = parent.type === node.type && !isParentTest; // Find the outermost non-ConditionalExpression parent, and the outermost
47747 // ConditionalExpression parent. We'll use these to determine if we should
47748 // print in JSX mode.
47751 let previousParent;
47755 previousParent = currentParent || node;
47756 currentParent = path.getParentNode(i);
47758 } while (currentParent && currentParent.type === node.type && testNodePropertyNames.every(prop => currentParent[prop] !== previousParent));
47760 const firstNonConditionalParent = currentParent || parent;
47761 const lastConditionalParent = previousParent;
47763 if (isConditionalExpression && (isJsxNode$1(node[testNodePropertyNames[0]]) || isJsxNode$1(consequentNode) || isJsxNode$1(alternateNode) || conditionalExpressionChainContainsJsx(lastConditionalParent))) {
47765 forceNoIndent = true; // Even though they don't need parens, we wrap (almost) everything in
47766 // parens when using ?: within JSX, because the parens are analogous to
47767 // curly braces in an if statement.
47769 const wrap = doc => [ifBreak$a("("), indent$b([softline$c, doc]), softline$c, ifBreak$a(")")]; // The only things we don't wrap are:
47770 // * Nested conditional expressions in alternates
47775 const isNil = node => node.type === "NullLiteral" || node.type === "Literal" && node.value === null || node.type === "Identifier" && node.name === "undefined";
47777 parts.push(" ? ", isNil(consequentNode) ? print(consequentNodePropertyName) : wrap(print(consequentNodePropertyName)), " : ", alternateNode.type === node.type || isNil(alternateNode) ? print(alternateNodePropertyName) : wrap(print(alternateNodePropertyName)));
47780 const part = [line$g, "? ", consequentNode.type === node.type ? ifBreak$a("", "(") : "", align$2(2, print(consequentNodePropertyName)), consequentNode.type === node.type ? ifBreak$a("", ")") : "", line$g, ": ", alternateNode.type === node.type ? print(alternateNodePropertyName) : align$2(2, print(alternateNodePropertyName))];
47781 parts.push(parent.type !== node.type || parent[alternateNodePropertyName] === node || isParentTest ? part : options.useTabs ? dedent$3(indent$b(part)) : align$2(Math.max(0, options.tabWidth - 2), part));
47782 } // We want a whole chain of ConditionalExpressions to all
47783 // break if any of them break. That means we should only group around the
47784 // outer-most ConditionalExpression.
47787 const comments = [...testNodePropertyNames.map(propertyName => getComments(node[propertyName])), getComments(consequentNode), getComments(alternateNode)].flat();
47788 const shouldBreak = comments.some(comment => isBlockComment$2(comment) && hasNewlineInRange$1(options.originalText, locStart$i(comment), locEnd$h(comment)));
47790 const maybeGroup = doc => parent === firstNonConditionalParent ? group$g(doc, {
47792 }) : shouldBreak ? [doc, breakParent$6] : doc; // Break the closing paren to keep the chain right after it:
47799 const breakClosingParen = !jsxMode && (isMemberExpression$2(parent) || parent.type === "NGPipeExpression" && parent.left === node) && !parent.computed;
47800 const shouldExtraIndent = shouldExtraIndentForConditionalExpression(path);
47801 const result = maybeGroup([printTernaryTest(path, options, print), forceNoIndent ? parts : indent$b(parts), isConditionalExpression && breakClosingParen && !shouldExtraIndent ? softline$c : ""]);
47802 return isParentTest || shouldExtraIndent ? group$g([indent$b([softline$c, result]), softline$c]) : result;
47806 printTernary: printTernary$2
47811 hardline: hardline$k
47814 const pathNeedsParens$1 = needsParens_1;
47816 getLeftSidePathName,
47819 isTheOnlyJsxElementInMarkdown: isTheOnlyJsxElementInMarkdown$1,
47820 hasComment: hasComment$2,
47821 CommentCheckFlags: CommentCheckFlags$2,
47822 isNextLineEmpty: isNextLineEmpty$6
47825 shouldPrintParamsWithoutParens
47828 * @typedef {import("../../document").Doc} Doc
47829 * @typedef {import("../../common/ast-path")} AstPath
47832 function printStatementSequence(path, options, print, property) {
47833 const node = path.getValue();
47835 const isClassBody = node.type === "ClassBody";
47836 const lastStatement = getLastStatement(node[property]);
47837 path.each((path, index, statements) => {
47838 const node = path.getValue(); // Skip printing EmptyStatement nodes to avoid leaving stray
47839 // semicolons lying around.
47841 if (node.type === "EmptyStatement") {
47845 const printed = print(); // in no-semi mode, prepend statement with semicolon if it might break ASI
47846 // don't prepend the only JSX element in a program with semicolon
47848 if (!options.semi && !isClassBody && !isTheOnlyJsxElementInMarkdown$1(options, path) && statementNeedsASIProtection(path, options)) {
47849 if (hasComment$2(node, CommentCheckFlags$2.Leading)) {
47850 parts.push(print([], {
47854 parts.push(";", printed);
47857 parts.push(printed);
47860 if (!options.semi && isClassBody && isClassProperty(node) && // `ClassBody` don't allow `EmptyStatement`,
47861 // so we can use `statements` to get next node
47862 shouldPrintSemicolonAfterClassProperty(node, statements[index + 1])) {
47866 if (node !== lastStatement) {
47867 parts.push(hardline$k);
47869 if (isNextLineEmpty$6(node, options)) {
47870 parts.push(hardline$k);
47877 function getLastStatement(statements) {
47878 for (let i = statements.length - 1; i >= 0; i--) {
47879 const statement = statements[i];
47881 if (statement.type !== "EmptyStatement") {
47887 function statementNeedsASIProtection(path, options) {
47888 const node = path.getNode();
47890 if (node.type !== "ExpressionStatement") {
47894 return path.call(childPath => expressionNeedsASIProtection(childPath, options), "expression");
47897 function expressionNeedsASIProtection(path, options) {
47898 const node = path.getValue();
47900 switch (node.type) {
47901 case "ParenthesizedExpression":
47902 case "TypeCastExpression":
47903 case "ArrayExpression":
47904 case "ArrayPattern":
47905 case "TemplateLiteral":
47906 case "TemplateElement":
47907 case "RegExpLiteral":
47910 case "ArrowFunctionExpression":
47912 if (!shouldPrintParamsWithoutParens(path, options)) {
47919 case "UnaryExpression":
47926 if (prefix && (operator === "+" || operator === "-")) {
47933 case "BindExpression":
47935 if (!node.object) {
47953 if (isJsxNode(node)) {
47959 if (pathNeedsParens$1(path, options)) {
47963 if (!hasNakedLeftSide(node)) {
47967 return path.call(childPath => expressionNeedsASIProtection(childPath, options), ...getLeftSidePathName(path, node));
47970 function printBody$1(path, options, print) {
47971 return printStatementSequence(path, options, print, "body");
47974 function printSwitchCaseConsequent$1(path, options, print) {
47975 return printStatementSequence(path, options, print, "consequent");
47978 const isClassProperty = ({
47980 }) => type === "ClassProperty" || type === "PropertyDefinition" || type === "ClassPrivateProperty";
47982 * @returns {boolean}
47986 function shouldPrintSemicolonAfterClassProperty(node, nextNode) {
47987 const name = node.key && node.key.name; // this isn't actually possible yet with most parsers available today
47988 // so isn't properly tested yet.
47990 if ((name === "static" || name === "get" || name === "set") && !node.value && !node.typeAnnotation) {
47998 if (nextNode.static || nextNode.accessibility // TypeScript
48003 if (!nextNode.computed) {
48004 const name = nextNode.key && nextNode.key.name;
48006 if (name === "in" || name === "instanceof") {
48009 } // Flow variance sigil +/- requires semi if there's no
48010 // "declare" or "static" keyword before it.
48013 if (isClassProperty(nextNode) && nextNode.variance && !nextNode.static && !nextNode.declare) {
48017 switch (nextNode.type) {
48018 case "ClassProperty":
48019 case "PropertyDefinition":
48020 case "TSAbstractPropertyDefinition":
48021 return nextNode.computed;
48023 case "MethodDefinition": // Flow
48025 case "TSAbstractMethodDefinition": // TypeScript
48027 case "ClassMethod":
48028 case "ClassPrivateMethod":
48031 const isAsync = nextNode.value ? nextNode.value.async : nextNode.async;
48033 if (isAsync || nextNode.kind === "get" || nextNode.kind === "set") {
48037 const isGenerator = nextNode.value ? nextNode.value.generator : nextNode.generator;
48039 if (nextNode.computed || isGenerator) {
48046 case "TSIndexSignature":
48049 /* istanbul ignore next */
48056 printBody: printBody$1,
48057 printSwitchCaseConsequent: printSwitchCaseConsequent$1
48061 printDanglingComments: printDanglingComments$2
48064 isNonEmptyArray: isNonEmptyArray$7
48068 hardline: hardline$j,
48073 hasComment: hasComment$1,
48074 CommentCheckFlags: CommentCheckFlags$1,
48075 isNextLineEmpty: isNextLineEmpty$5
48078 printHardlineAfterHeritage
48083 /** @typedef {import("../../document").Doc} Doc */
48085 function printBlock$4(path, options, print) {
48086 const node = path.getValue();
48089 if (node.type === "StaticBlock") {
48090 parts.push("static ");
48093 if (node.type === "ClassBody" && isNonEmptyArray$7(node.body)) {
48094 const parent = path.getParentNode();
48095 parts.push(printHardlineAfterHeritage(parent));
48099 const printed = printBlockBody$1(path, options, print);
48102 parts.push(indent$a([hardline$j, printed]), hardline$j);
48104 const parent = path.getParentNode();
48105 const parentParent = path.getParentNode(1);
48107 if (!(parent.type === "ArrowFunctionExpression" || parent.type === "FunctionExpression" || parent.type === "FunctionDeclaration" || parent.type === "ObjectMethod" || parent.type === "ClassMethod" || parent.type === "ClassPrivateMethod" || parent.type === "ForStatement" || parent.type === "WhileStatement" || parent.type === "DoWhileStatement" || parent.type === "DoExpression" || parent.type === "CatchClause" && !parentParent.finalizer || parent.type === "TSModuleDeclaration" || parent.type === "TSDeclareFunction" || node.type === "StaticBlock" || node.type === "ClassBody")) {
48108 parts.push(hardline$j);
48116 function printBlockBody$1(path, options, print) {
48117 const node = path.getValue();
48118 const nodeHasDirectives = isNonEmptyArray$7(node.directives);
48119 const nodeHasBody = node.body.some(node => node.type !== "EmptyStatement");
48120 const nodeHasComment = hasComment$1(node, CommentCheckFlags$1.Dangling);
48122 if (!nodeHasDirectives && !nodeHasBody && !nodeHasComment) {
48126 const parts = []; // Babel 6
48128 if (nodeHasDirectives) {
48129 path.each((childPath, index, directives) => {
48130 parts.push(print());
48132 if (index < directives.length - 1 || nodeHasBody || nodeHasComment) {
48133 parts.push(hardline$j);
48135 if (isNextLineEmpty$5(childPath.getValue(), options)) {
48136 parts.push(hardline$j);
48143 parts.push(printBody(path, options, print));
48146 if (nodeHasComment) {
48147 parts.push(printDanglingComments$2(path, options,
48152 if (node.type === "Program") {
48153 const parent = path.getParentNode();
48155 if (!parent || parent.type !== "ModuleExpression") {
48156 parts.push(hardline$j);
48164 printBlock: printBlock$4,
48165 printBlockBody: printBlockBody$1
48169 printDanglingComments: printDanglingComments$1
48178 hardline: hardline$i,
48179 softline: softline$b,
48182 conditionalGroup: conditionalGroup$1,
48188 getTypeScriptMappedTypeModifier,
48189 shouldPrintComma: shouldPrintComma$1,
48190 isCallExpression: isCallExpression$1,
48191 isMemberExpression: isMemberExpression$1
48194 locStart: locStart$h,
48198 printOptionalToken: printOptionalToken$1,
48199 printTypeScriptModifiers
48202 printTernary: printTernary$1
48205 printFunctionParameters,
48206 shouldGroupFunctionParameters
48207 } = functionParameters;
48209 printTemplateLiteral: printTemplateLiteral$1
48210 } = templateLiteral;
48215 printObject: printObject$1
48218 printClassProperty: printClassProperty$1,
48219 printClassMethod: printClassMethod$1
48222 printTypeParameter,
48223 printTypeParameters
48224 } = typeParameters;
48229 printFunction: printFunction$1,
48230 printMethodInternal
48236 printBlock: printBlock$3
48240 printIntersectionType,
48244 printIndexedAccessType
48245 } = typeAnnotation;
48247 function printTypescript$1(path, options, print) {
48248 const node = path.getValue(); // TypeScript nodes always starts with `TS`
48250 if (!node.type.startsWith("TS")) {
48254 if (node.type.endsWith("Keyword")) {
48255 return node.type.slice(2, -7).toLowerCase();
48258 const semi = options.semi ? ";" : "";
48261 switch (node.type) {
48265 case "TSTypeAssertion":
48267 const shouldBreakAfterCast = !(node.expression.type === "ArrayExpression" || node.expression.type === "ObjectExpression");
48268 const castGroup = group$f(["<", indent$9([softline$b, print("typeAnnotation")]), softline$b, ">"]);
48269 const exprContents = [ifBreak$9("("), indent$9([softline$b, print("expression")]), softline$b, ifBreak$9(")")];
48271 if (shouldBreakAfterCast) {
48272 return conditionalGroup$1([[castGroup, print("expression")], [castGroup, group$f(exprContents, {
48274 })], [castGroup, print("expression")]]);
48277 return group$f([castGroup, print("expression")]);
48280 case "TSDeclareFunction":
48281 return printFunction$1(path, print, options);
48283 case "TSExportAssignment":
48284 return ["export = ", print("expression"), semi];
48286 case "TSModuleBlock":
48287 return printBlock$3(path, options, print);
48289 case "TSInterfaceBody":
48290 case "TSTypeLiteral":
48291 return printObject$1(path, options, print);
48293 case "TSTypeAliasDeclaration":
48294 return printTypeAlias(path, options, print);
48296 case "TSQualifiedName":
48297 return join$e(".", [print("left"), print("right")]);
48299 case "TSAbstractMethodDefinition":
48300 case "TSDeclareMethod":
48301 return printClassMethod$1(path, options, print);
48303 case "TSAbstractPropertyDefinition":
48304 return printClassProperty$1(path, options, print);
48306 case "TSInterfaceHeritage":
48307 case "TSExpressionWithTypeArguments":
48309 parts.push(print("expression"));
48311 if (node.typeParameters) {
48312 parts.push(print("typeParameters"));
48317 case "TSTemplateLiteralType":
48318 return printTemplateLiteral$1(path, print, options);
48320 case "TSNamedTupleMember":
48321 return [print("label"), node.optional ? "?" : "", ": ", print("elementType")];
48324 return ["...", print("typeAnnotation")];
48326 case "TSOptionalType":
48327 return [print("typeAnnotation"), "?"];
48329 case "TSInterfaceDeclaration":
48330 return printInterface(path, options, print);
48332 case "TSClassImplements":
48333 return [print("expression"), print("typeParameters")];
48335 case "TSTypeParameterDeclaration":
48336 case "TSTypeParameterInstantiation":
48337 return printTypeParameters(path, options, print, "params");
48339 case "TSTypeParameter":
48340 return printTypeParameter(path, options, print);
48342 case "TSAsExpression":
48344 parts.push(print("expression"), " as ", print("typeAnnotation"));
48345 const parent = path.getParentNode();
48347 if (isCallExpression$1(parent) && parent.callee === node || isMemberExpression$1(parent) && parent.object === node) {
48348 return group$f([indent$9([softline$b, ...parts]), softline$b]);
48354 case "TSArrayType":
48355 return [print("elementType"), "[]"];
48357 case "TSPropertySignature":
48359 if (node.readonly) {
48360 parts.push("readonly ");
48363 parts.push(printPropertyKey(path, options, print), printOptionalToken$1(path));
48365 if (node.typeAnnotation) {
48366 parts.push(": ", print("typeAnnotation"));
48367 } // This isn't valid semantically, but it's in the AST so we can print it.
48370 if (node.initializer) {
48371 parts.push(" = ", print("initializer"));
48377 case "TSParameterProperty":
48378 if (node.accessibility) {
48379 parts.push(node.accessibility + " ");
48383 parts.push("export ");
48387 parts.push("static ");
48390 if (node.override) {
48391 parts.push("override ");
48394 if (node.readonly) {
48395 parts.push("readonly ");
48398 parts.push(print("parameter"));
48401 case "TSTypeQuery":
48402 return ["typeof ", print("exprName")];
48404 case "TSIndexSignature":
48406 const parent = path.getParentNode(); // The typescript parser accepts multiple parameters here. If you're
48407 // using them, it makes sense to have a trailing comma. But if you
48408 // aren't, this is more like a computed property name than an array.
48409 // So we leave off the trailing comma when there's just one parameter.
48411 const trailingComma = node.parameters.length > 1 ? ifBreak$9(shouldPrintComma$1(options) ? "," : "") : "";
48412 const parametersGroup = group$f([indent$9([softline$b, join$e([", ", softline$b], path.map(print, "parameters"))]), trailingComma, softline$b]);
48413 return [node.export ? "export " : "", node.accessibility ? [node.accessibility, " "] : "", node.static ? "static " : "", node.readonly ? "readonly " : "", node.declare ? "declare " : "", "[", node.parameters ? parametersGroup : "", node.typeAnnotation ? "]: " : "]", node.typeAnnotation ? print("typeAnnotation") : "", parent.type === "ClassBody" ? semi : ""];
48416 case "TSTypePredicate":
48417 return [node.asserts ? "asserts " : "", print("parameterName"), node.typeAnnotation ? [" is ", print("typeAnnotation")] : ""];
48419 case "TSNonNullExpression":
48420 return [print("expression"), "!"];
48422 case "TSImportType":
48423 return [!node.isTypeOf ? "" : "typeof ", "import(", print(node.parameter ? "parameter" : "argument"), ")", !node.qualifier ? "" : [".", print("qualifier")], printTypeParameters(path, options, print, "typeParameters")];
48425 case "TSLiteralType":
48426 return print("literal");
48428 case "TSIndexedAccessType":
48429 return printIndexedAccessType(path, options, print);
48431 case "TSConstructSignatureDeclaration":
48432 case "TSCallSignatureDeclaration":
48433 case "TSConstructorType":
48435 if (node.type === "TSConstructorType" && node.abstract) {
48436 parts.push("abstract ");
48439 if (node.type !== "TSCallSignatureDeclaration") {
48440 parts.push("new ");
48443 parts.push(group$f(printFunctionParameters(path, print, options,
48446 /* printTypeParams */
48449 if (node.returnType || node.typeAnnotation) {
48450 const isType = node.type === "TSConstructorType";
48451 parts.push(isType ? " => " : ": ", print("returnType"), print("typeAnnotation"));
48457 case "TSTypeOperator":
48458 return [node.operator, " ", print("typeAnnotation")];
48460 case "TSMappedType":
48462 const shouldBreak = hasNewlineInRange(options.originalText, locStart$h(node), locEnd$g(node));
48463 return group$f(["{", indent$9([options.bracketSpacing ? line$f : softline$b, node.readonly ? [getTypeScriptMappedTypeModifier(node.readonly, "readonly"), " "] : "", printTypeScriptModifiers(path, options, print), print("typeParameter"), node.optional ? getTypeScriptMappedTypeModifier(node.optional, "?") : "", node.typeAnnotation ? ": " : "", print("typeAnnotation"), ifBreak$9(semi)]), printDanglingComments$1(path, options,
48465 true), options.bracketSpacing ? line$f : softline$b, "}"], {
48470 case "TSMethodSignature":
48472 const kind = node.kind && node.kind !== "method" ? `${node.kind} ` : "";
48473 parts.push(node.accessibility ? [node.accessibility, " "] : "", kind, node.export ? "export " : "", node.static ? "static " : "", node.readonly ? "readonly " : "", // "abstract" and "declare" are supported by only "babel-ts"
48474 // https://github.com/prettier/prettier/issues/9760
48475 node.abstract ? "abstract " : "", node.declare ? "declare " : "", node.computed ? "[" : "", print("key"), node.computed ? "]" : "", printOptionalToken$1(path));
48476 const parametersDoc = printFunctionParameters(path, print, options,
48479 /* printTypeParams */
48481 const returnTypePropertyName = node.returnType ? "returnType" : "typeAnnotation";
48482 const returnTypeNode = node[returnTypePropertyName];
48483 const returnTypeDoc = returnTypeNode ? print(returnTypePropertyName) : "";
48484 const shouldGroupParameters = shouldGroupFunctionParameters(node, returnTypeDoc);
48485 parts.push(shouldGroupParameters ? group$f(parametersDoc) : parametersDoc);
48487 if (returnTypeNode) {
48488 parts.push(": ", group$f(returnTypeDoc));
48491 return group$f(parts);
48494 case "TSNamespaceExportDeclaration":
48495 parts.push("export as namespace ", print("id"));
48497 if (options.semi) {
48501 return group$f(parts);
48503 case "TSEnumDeclaration":
48504 if (node.declare) {
48505 parts.push("declare ");
48508 if (node.modifiers) {
48509 parts.push(printTypeScriptModifiers(path, options, print));
48513 parts.push("const ");
48516 parts.push("enum ", print("id"), " ");
48518 if (node.members.length === 0) {
48519 parts.push(group$f(["{", printDanglingComments$1(path, options), softline$b, "}"]));
48521 parts.push(group$f(["{", indent$9([hardline$i, printArrayItems(path, options, "members", print), shouldPrintComma$1(options, "es5") ? "," : ""]), printDanglingComments$1(path, options,
48523 true), hardline$i, "}"]));
48528 case "TSEnumMember":
48529 parts.push(print("id"));
48531 if (node.initializer) {
48532 parts.push(" = ", print("initializer"));
48537 case "TSImportEqualsDeclaration":
48538 if (node.isExport) {
48539 parts.push("export ");
48542 parts.push("import ");
48544 if (node.importKind && node.importKind !== "value") {
48545 parts.push(node.importKind, " ");
48548 parts.push(print("id"), " = ", print("moduleReference"));
48550 if (options.semi) {
48554 return group$f(parts);
48556 case "TSExternalModuleReference":
48557 return ["require(", print("expression"), ")"];
48559 case "TSModuleDeclaration":
48561 const parent = path.getParentNode();
48562 const isExternalModule = isLiteral(node.id);
48563 const parentIsDeclaration = parent.type === "TSModuleDeclaration";
48564 const bodyIsDeclaration = node.body && node.body.type === "TSModuleDeclaration";
48566 if (parentIsDeclaration) {
48569 if (node.declare) {
48570 parts.push("declare ");
48573 parts.push(printTypeScriptModifiers(path, options, print));
48574 const textBetweenNodeAndItsId = options.originalText.slice(locStart$h(node), locStart$h(node.id)); // Global declaration looks like this:
48575 // (declare)? global { ... }
48577 const isGlobalDeclaration = node.id.type === "Identifier" && node.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
48579 if (!isGlobalDeclaration) {
48580 parts.push(isExternalModule || /(?:^|\s)module(?:\s|$)/.test(textBetweenNodeAndItsId) ? "module " : "namespace ");
48584 parts.push(print("id"));
48586 if (bodyIsDeclaration) {
48587 parts.push(print("body"));
48588 } else if (node.body) {
48589 parts.push(" ", group$f(print("body")));
48597 case "TSConditionalType":
48598 return printTernary$1(path, options, print);
48600 case "TSInferType":
48601 return ["infer", " ", print("typeParameter")];
48603 case "TSIntersectionType":
48604 return printIntersectionType(path, options, print);
48606 case "TSUnionType":
48607 return printUnionType(path, options, print);
48609 case "TSFunctionType":
48610 return printFunctionType(path, options, print);
48612 case "TSTupleType":
48613 return printTupleType(path, options, print);
48615 case "TSTypeReference":
48616 return [print("typeName"), printTypeParameters(path, options, print, "typeParameters")];
48618 case "TSTypeAnnotation":
48619 return print("typeAnnotation");
48621 case "TSEmptyBodyFunctionExpression":
48622 return printMethodInternal(path, options, print);
48623 // These are not valid TypeScript. Printing them just for the sake of error recovery.
48625 case "TSJSDocAllType":
48628 case "TSJSDocUnknownType":
48631 case "TSJSDocNullableType":
48632 return ["?", print("typeAnnotation")];
48634 case "TSJSDocNonNullableType":
48635 return ["!", print("typeAnnotation")];
48638 /* istanbul ignore next */
48639 throw new Error(`Unknown TypeScript node type: ${JSON.stringify(node.type)}.`);
48644 printTypescript: printTypescript$1
48648 hasNewline: hasNewline$2
48653 hardline: hardline$h
48656 replaceTextEndOfLine: replaceTextEndOfLine$a
48660 isLineComment: isLineComment$1,
48661 isBlockComment: isBlockComment$1
48664 locStart: locStart$g,
48668 function printComment$2(commentPath, options) {
48669 const comment = commentPath.getValue();
48671 if (isLineComment$1(comment)) {
48672 // Supports `//`, `#!`, `<!--`, and `-->`
48673 return options.originalText.slice(locStart$g(comment), locEnd$f(comment)).trimEnd();
48676 if (isBlockComment$1(comment)) {
48677 if (isIndentableBlockComment(comment)) {
48678 const printed = printIndentableBlockComment(comment); // We need to prevent an edge case of a previous trailing comment
48679 // printed as a `lineSuffix` which causes the comments to be
48680 // interleaved. See https://github.com/prettier/prettier/issues/4412
48682 if (comment.trailing && !hasNewline$2(options.originalText, locStart$g(comment), {
48685 return [hardline$h, printed];
48691 const commentEnd = locEnd$f(comment);
48692 const isInsideFlowComment = options.originalText.slice(commentEnd - 3, commentEnd) === "*-/";
48693 return ["/*", replaceTextEndOfLine$a(comment.value), isInsideFlowComment ? "*-/" : "*/"];
48695 /* istanbul ignore next */
48698 throw new Error("Not a comment: " + JSON.stringify(comment));
48701 function isIndentableBlockComment(comment) {
48702 // If the comment has multiple lines and every line starts with a star
48703 // we can fix the indentation of each line. The stars in the `/*` and
48704 // `*/` delimiters are not included in the comment value, so add them
48706 const lines = `*${comment.value}*`.split("\n");
48707 return lines.length > 1 && lines.every(line => line.trim()[0] === "*");
48710 function printIndentableBlockComment(comment) {
48711 const lines = comment.value.split("\n");
48712 return ["/*", join$d(hardline$h, lines.map((line, index) => index === 0 ? line.trimEnd() : " " + (index < lines.length - 1 ? line.trim() : line.trimStart()))), "*/"];
48716 printComment: printComment$2
48720 printString: printString$1,
48721 printNumber: printNumber$1
48724 function printLiteral$1(path, options
48727 const node = path.getNode();
48729 switch (node.type) {
48730 case "RegExpLiteral":
48731 // Babel 6 Literal split
48732 return printRegex(node);
48734 case "BigIntLiteral":
48735 // babel: node.extra.raw, flow: node.bigint
48736 return printBigInt(node.bigint || node.extra.raw);
48738 case "NumericLiteral":
48739 // Babel 6 Literal split
48740 return printNumber$1(node.extra.raw);
48742 case "StringLiteral":
48743 // Babel 6 Literal split
48744 return printString$1(node.extra.raw, options);
48746 case "NullLiteral":
48747 // Babel 6 Literal split
48750 case "BooleanLiteral":
48751 // Babel 6 Literal split
48752 return String(node.value);
48754 case "DecimalLiteral":
48755 return printNumber$1(node.value) + "m";
48760 return printRegex(node.regex);
48764 return printBigInt(node.raw);
48767 if (node.decimal) {
48768 return printNumber$1(node.decimal) + "m";
48775 if (typeof value === "number") {
48776 return printNumber$1(node.raw);
48779 if (typeof value === "string") {
48780 return printString$1(node.raw, options);
48783 return String(value);
48788 function printBigInt(raw) {
48789 return raw.toLowerCase();
48792 function printRegex({
48796 flags = [...flags].sort().join("");
48797 return `/${pattern}/${flags}`;
48801 printLiteral: printLiteral$1
48804 /** @typedef {import("../document").Doc} Doc */
48805 // TODO(azz): anything that imports from main shouldn't be in a `language-*` dir.
48809 printDanglingComments
48812 hasNewline: hasNewline$1
48818 hardline: hardline$g,
48819 softline: softline$a,
48824 replaceTextEndOfLine: replaceTextEndOfLine$9
48827 const embed$9 = embed_1$4;
48828 const clean$b = clean_1$4;
48830 insertPragma: insertPragma$9
48832 const handleComments = comments;
48833 const pathNeedsParens = needsParens_1;
48834 const preprocess$7 = printPreprocess$3;
48836 hasFlowShorthandAnnotationComment,
48839 isTheOnlyJsxElementInMarkdown,
48842 isNextLineEmpty: isNextLineEmpty$4,
48843 needsHardlineAfterDanglingComment,
48850 locStart: locStart$f,
48855 isVueEventBindingExpression: isVueEventBindingExpression$2
48862 hasJsxIgnoreComment
48871 printOptionalToken,
48872 printBindExpressionCallee,
48873 printTypeAnnotation,
48878 printImportDeclaration,
48879 printExportDeclaration,
48880 printExportAllDeclaration,
48881 printModuleSpecifier
48887 printTemplateLiteral
48888 } = templateLiteral;
48905 printArrowFunction,
48907 printReturnStatement,
48908 printThrowStatement
48911 printCallExpression
48912 } = callExpression;
48914 printVariableDeclarator,
48915 printAssignmentExpression
48918 printBinaryishExpression
48921 printSwitchCaseConsequent
48924 printMemberExpression
48927 printBlock: printBlock$2,
48931 printComment: printComment$1
48940 function genericPrint$6(path, options, print, args) {
48941 const printed = printPathNoParens(path, options, print, args);
48947 const node = path.getValue();
48950 } = node; // Their decorators are handled themselves, and they can't have parentheses
48952 if (type === "ClassMethod" || type === "ClassPrivateMethod" || type === "ClassProperty" || type === "PropertyDefinition" || type === "TSAbstractPropertyDefinition" || type === "ClassPrivateProperty" || type === "MethodDefinition" || type === "TSAbstractMethodDefinition" || type === "TSDeclareMethod") {
48956 const printedDecorators = printDecorators(path, options, print); // Nodes with decorators can't have parentheses and don't need leading semicolons
48958 if (printedDecorators) {
48959 return group$e([...printedDecorators, printed]);
48962 const needsParens = pathNeedsParens(path, options);
48964 if (!needsParens) {
48965 return args && args.needsSemi ? [";", printed] : printed;
48968 const parts = [args && args.needsSemi ? ";(" : "(", printed];
48970 if (hasFlowShorthandAnnotationComment(node)) {
48971 const [comment] = node.trailingComments;
48972 parts.push(" /*", comment.value.trimStart(), "*/");
48973 comment.printed = true;
48980 function printPathNoParens(path, options, print, args) {
48981 const node = path.getValue();
48982 const semi = options.semi ? ";" : "";
48988 if (typeof node === "string") {
48992 for (const printer of [printLiteral, printHtmlBinding, printAngular, printJsx, printFlow, printTypescript]) {
48993 const printed = printer(path, options, print);
48995 if (typeof printed !== "undefined") {
48999 /** @type{Doc[]} */
49004 switch (node.type) {
49005 case "JsExpressionRoot":
49006 return print("node");
49009 return [print("node"), hardline$g];
49012 // Print @babel/parser's InterpreterDirective here so that
49013 // leading comments on the `Program` node get printed after the hashbang.
49014 if (node.program && node.program.interpreter) {
49015 parts.push(print(["program", "interpreter"]));
49018 parts.push(print("program"));
49022 return printBlockBody(path, options, print);
49023 // Babel extension.
49025 case "EmptyStatement":
49028 case "ExpressionStatement":
49029 // Detect Flow and TypeScript directives
49030 if (node.directive) {
49031 return [printDirective(node.expression, options), semi];
49034 if (options.parser === "__vue_event_binding") {
49035 const parent = path.getParentNode();
49037 if (parent.type === "Program" && parent.body.length === 1 && parent.body[0] === node) {
49038 return [print("expression"), isVueEventBindingExpression$2(node.expression) ? ";" : ""];
49040 } // Do not append semicolon after the only JSX element in a program
49043 return [print("expression"), isTheOnlyJsxElementInMarkdown(options, path) ? "" : semi];
49044 // Babel non-standard node. Used for Closure-style type casts. See postprocess.js.
49046 case "ParenthesizedExpression":
49048 const shouldHug = !hasComment(node.expression) && (node.expression.type === "ObjectExpression" || node.expression.type === "ArrayExpression");
49051 return ["(", print("expression"), ")"];
49054 return group$e(["(", indent$8([softline$a, print("expression")]), softline$a, ")"]);
49057 case "AssignmentExpression":
49058 return printAssignmentExpression(path, options, print);
49060 case "VariableDeclarator":
49061 return printVariableDeclarator(path, options, print);
49063 case "BinaryExpression":
49064 case "LogicalExpression":
49065 return printBinaryishExpression(path, options, print);
49067 case "AssignmentPattern":
49068 return [print("left"), " = ", print("right")];
49070 case "OptionalMemberExpression":
49071 case "MemberExpression":
49073 return printMemberExpression(path, options, print);
49076 case "MetaProperty":
49077 return [print("meta"), ".", print("property")];
49079 case "BindExpression":
49081 parts.push(print("object"));
49084 parts.push(group$e(indent$8([softline$a, printBindExpressionCallee(path, options, print)])));
49089 return [node.name, printOptionalToken(path), printTypeAnnotation(path, options, print)];
49092 case "V8IntrinsicIdentifier":
49093 return ["%", node.name];
49095 case "SpreadElement":
49096 case "SpreadElementPattern":
49097 case "SpreadProperty":
49098 case "SpreadPropertyPattern":
49099 case "RestElement":
49100 return printRestSpread(path, options, print);
49102 case "FunctionDeclaration":
49103 case "FunctionExpression":
49104 return printFunction(path, print, options, args);
49106 case "ArrowFunctionExpression":
49107 return printArrowFunction(path, options, print, args);
49109 case "YieldExpression":
49110 parts.push("yield");
49112 if (node.delegate) {
49116 if (node.argument) {
49117 parts.push(" ", print("argument"));
49122 case "AwaitExpression":
49124 parts.push("await");
49126 if (node.argument) {
49127 parts.push(" ", print("argument"));
49128 const parent = path.getParentNode();
49130 if (isCallExpression(parent) && parent.callee === node || isMemberExpression(parent) && parent.object === node) {
49131 parts = [indent$8([softline$a, ...parts]), softline$a];
49132 const parentAwaitOrBlock = path.findAncestor(node => node.type === "AwaitExpression" || node.type === "BlockStatement");
49134 if (!parentAwaitOrBlock || parentAwaitOrBlock.type !== "AwaitExpression") {
49135 return group$e(parts);
49143 case "ExportDefaultDeclaration":
49144 case "ExportNamedDeclaration":
49145 return printExportDeclaration(path, options, print);
49147 case "ExportAllDeclaration":
49148 return printExportAllDeclaration(path, options, print);
49150 case "ImportDeclaration":
49151 return printImportDeclaration(path, options, print);
49153 case "ImportSpecifier":
49154 case "ExportSpecifier":
49155 case "ImportNamespaceSpecifier":
49156 case "ExportNamespaceSpecifier":
49157 case "ImportDefaultSpecifier":
49158 case "ExportDefaultSpecifier":
49159 return printModuleSpecifier(path, options, print);
49161 case "ImportAttribute":
49162 return [print("key"), ": ", print("value")];
49167 case "BlockStatement":
49168 case "StaticBlock":
49170 return printBlock$2(path, options, print);
49172 case "ThrowStatement":
49173 return printThrowStatement(path, options, print);
49175 case "ReturnStatement":
49176 return printReturnStatement(path, options, print);
49178 case "NewExpression":
49179 case "ImportExpression":
49180 case "OptionalCallExpression":
49181 case "CallExpression":
49182 return printCallExpression(path, options, print);
49184 case "ObjectExpression":
49185 case "ObjectPattern":
49186 case "RecordExpression":
49187 return printObject(path, options, print);
49190 case "ObjectProperty": // Non-standard AST node type.
49193 if (node.method || node.kind === "get" || node.kind === "set") {
49194 return printMethod(path, options, print);
49197 return printProperty(path, options, print);
49199 case "ObjectMethod":
49200 return printMethod(path, options, print);
49203 return ["@", print("expression")];
49205 case "ArrayExpression":
49206 case "ArrayPattern":
49207 case "TupleExpression":
49208 return printArray(path, options, print);
49210 case "SequenceExpression":
49212 const parent = path.getParentNode(0);
49214 if (parent.type === "ExpressionStatement" || parent.type === "ForStatement") {
49215 // For ExpressionStatements and for-loop heads, which are among
49216 // the few places a SequenceExpression appears unparenthesized, we want
49217 // to indent expressions after the first.
49219 path.each((expressionPath, index) => {
49221 parts.push(print());
49223 parts.push(",", indent$8([line$e, print()]));
49226 return group$e(parts);
49229 return group$e(join$c([",", line$e], path.map(print, "expressions")));
49232 case "ThisExpression":
49239 return [print("value"), semi];
49242 case "DirectiveLiteral":
49243 return printDirective(node, options);
49245 case "UnaryExpression":
49246 parts.push(node.operator);
49248 if (/[a-z]$/.test(node.operator)) {
49252 if (hasComment(node.argument)) {
49253 parts.push(group$e(["(", indent$8([softline$a, print("argument")]), softline$a, ")"]));
49255 parts.push(print("argument"));
49260 case "UpdateExpression":
49261 parts.push(print("argument"), node.operator);
49269 case "ConditionalExpression":
49270 return printTernary(path, options, print);
49272 case "VariableDeclaration":
49274 const printed = path.map(print, "declarations"); // We generally want to terminate all variable declarations with a
49275 // semicolon, except when they in the () part of for loops.
49277 const parentNode = path.getParentNode();
49278 const isParentForLoop = parentNode.type === "ForStatement" || parentNode.type === "ForInStatement" || parentNode.type === "ForOfStatement";
49279 const hasValue = node.declarations.some(decl => decl.init);
49282 if (printed.length === 1 && !hasComment(node.declarations[0])) {
49283 firstVariable = printed[0];
49284 } else if (printed.length > 0) {
49285 // Indent first var to comply with eslint one-var rule
49286 firstVariable = indent$8(printed[0]);
49289 parts = [node.declare ? "declare " : "", node.kind, firstVariable ? [" ", firstVariable] : "", indent$8(printed.slice(1).map(p => [",", hasValue && !isParentForLoop ? hardline$g : line$e, p]))];
49291 if (!(isParentForLoop && parentNode.body !== node)) {
49295 return group$e(parts);
49298 case "WithStatement":
49299 return group$e(["with (", print("object"), ")", adjustClause(node.body, print("body"))]);
49301 case "IfStatement":
49303 const con = adjustClause(node.consequent, print("consequent"));
49304 const opening = group$e(["if (", group$e([indent$8([softline$a, print("test")]), softline$a]), ")", con]);
49305 parts.push(opening);
49307 if (node.alternate) {
49308 const commentOnOwnLine = hasComment(node.consequent, CommentCheckFlags.Trailing | CommentCheckFlags.Line) || needsHardlineAfterDanglingComment(node);
49309 const elseOnSameLine = node.consequent.type === "BlockStatement" && !commentOnOwnLine;
49310 parts.push(elseOnSameLine ? " " : hardline$g);
49312 if (hasComment(node, CommentCheckFlags.Dangling)) {
49313 parts.push(printDanglingComments(path, options, true), commentOnOwnLine ? hardline$g : " ");
49316 parts.push("else", group$e(adjustClause(node.alternate, print("alternate"), node.alternate.type === "IfStatement")));
49322 case "ForStatement":
49324 const body = adjustClause(node.body, print("body")); // We want to keep dangling comments above the loop to stay consistent.
49325 // Any comment positioned between the for statement and the parentheses
49326 // is going to be printed before the statement.
49328 const dangling = printDanglingComments(path, options,
49331 const printedComments = dangling ? [dangling, softline$a] : "";
49333 if (!node.init && !node.test && !node.update) {
49334 return [printedComments, group$e(["for (;;)", body])];
49337 return [printedComments, group$e(["for (", group$e([indent$8([softline$a, print("init"), ";", line$e, print("test"), ";", line$e, print("update")]), softline$a]), ")", body])];
49340 case "WhileStatement":
49341 return group$e(["while (", group$e([indent$8([softline$a, print("test")]), softline$a]), ")", adjustClause(node.body, print("body"))]);
49343 case "ForInStatement":
49344 return group$e(["for (", print("left"), " in ", print("right"), ")", adjustClause(node.body, print("body"))]);
49346 case "ForOfStatement":
49347 return group$e(["for", node.await ? " await" : "", " (", print("left"), " of ", print("right"), ")", adjustClause(node.body, print("body"))]);
49349 case "DoWhileStatement":
49351 const clause = adjustClause(node.body, print("body"));
49352 const doBody = group$e(["do", clause]);
49355 if (node.body.type === "BlockStatement") {
49358 parts.push(hardline$g);
49361 parts.push("while (", group$e([indent$8([softline$a, print("test")]), softline$a]), ")", semi);
49365 case "DoExpression":
49366 return [node.async ? "async " : "", "do ", print("body")];
49368 case "BreakStatement":
49369 parts.push("break");
49372 parts.push(" ", print("label"));
49378 case "ContinueStatement":
49379 parts.push("continue");
49382 parts.push(" ", print("label"));
49388 case "LabeledStatement":
49389 if (node.body.type === "EmptyStatement") {
49390 return [print("label"), ":;"];
49393 return [print("label"), ": ", print("body")];
49395 case "TryStatement":
49396 return ["try ", print("block"), node.handler ? [" ", print("handler")] : "", node.finalizer ? [" finally ", print("finalizer")] : ""];
49398 case "CatchClause":
49400 const parameterHasComments = hasComment(node.param, comment => !isBlockComment(comment) || comment.leading && hasNewline$1(options.originalText, locEnd$e(comment)) || comment.trailing && hasNewline$1(options.originalText, locStart$f(comment), {
49403 const param = print("param");
49404 return ["catch ", parameterHasComments ? ["(", indent$8([softline$a, param]), softline$a, ") "] : ["(", param, ") "], print("body")];
49407 return ["catch ", print("body")];
49408 // Note: ignoring n.lexical because it has no printing consequences.
49410 case "SwitchStatement":
49411 return [group$e(["switch (", indent$8([softline$a, print("discriminant")]), softline$a, ")"]), " {", node.cases.length > 0 ? indent$8([hardline$g, join$c(hardline$g, path.map((casePath, index, cases) => {
49412 const caseNode = casePath.getValue();
49413 return [print(), index !== cases.length - 1 && isNextLineEmpty$4(caseNode, options) ? hardline$g : ""];
49414 }, "cases"))]) : "", hardline$g, "}"];
49419 parts.push("case ", print("test"), ":");
49421 parts.push("default:");
49424 const consequent = node.consequent.filter(node => node.type !== "EmptyStatement");
49426 if (consequent.length > 0) {
49427 const cons = printSwitchCaseConsequent(path, options, print);
49428 parts.push(consequent.length === 1 && consequent[0].type === "BlockStatement" ? [" ", cons] : indent$8([hardline$g, cons]));
49433 // JSX extensions below.
49435 case "DebuggerStatement":
49436 return ["debugger", semi];
49438 case "ClassDeclaration":
49439 case "ClassExpression":
49440 return printClass(path, options, print);
49442 case "ClassMethod":
49443 case "ClassPrivateMethod":
49444 case "MethodDefinition":
49445 return printClassMethod(path, options, print);
49447 case "ClassProperty":
49448 case "PropertyDefinition":
49449 case "ClassPrivateProperty":
49450 return printClassProperty(path, options, print);
49452 case "TemplateElement":
49453 return replaceTextEndOfLine$9(node.value.raw);
49455 case "TemplateLiteral":
49456 return printTemplateLiteral(path, print, options);
49458 case "TaggedTemplateExpression":
49459 return [print("tag"), print("typeParameters"), print("quasi")];
49461 case "PrivateIdentifier":
49462 return ["#", print("name")];
49464 case "PrivateName":
49465 return ["#", print("id")];
49467 case "InterpreterDirective":
49468 parts.push("#!", node.value, hardline$g);
49470 if (isNextLineEmpty$4(node, options)) {
49471 parts.push(hardline$g);
49475 // For hack-style pipeline
49477 case "TopicReference":
49480 case "ArgumentPlaceholder":
49483 case "ModuleExpression":
49485 parts.push("module {");
49486 const printed = print("body");
49489 parts.push(indent$8([hardline$g, printed]), hardline$g);
49497 /* istanbul ignore next */
49498 throw new Error("unknown type: " + JSON.stringify(node.type));
49502 function printDirective(node, options) {
49503 const raw = rawText(node);
49504 const rawContent = raw.slice(1, -1); // Check for the alternate quote, to determine if we're allowed to swap
49505 // the quotes on a DirectiveLiteral.
49507 if (rawContent.includes('"') || rawContent.includes("'")) {
49511 const enclosingQuote = options.singleQuote ? "'" : '"'; // Directives are exact code unit sequences, which means that you can't
49512 // change the escape sequences they use.
49513 // See https://github.com/prettier/prettier/issues/1555
49514 // and https://tc39.github.io/ecma262/#directive-prologue
49516 return enclosingQuote + rawContent + enclosingQuote;
49519 function canAttachComment$1(node) {
49520 return node.type && !isBlockComment(node) && !isLineComment(node) && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import" && // `babel-ts` don't have similar node for `class Foo { bar() /* bat */; }`
49521 node.type !== "TSEmptyBodyFunctionExpression";
49524 var printerEstree = {
49525 preprocess: preprocess$7,
49526 print: genericPrint$6,
49528 insertPragma: insertPragma$9,
49529 massageAstNode: clean$b,
49531 hasPrettierIgnore(path) {
49532 return hasIgnoreComment(path) || hasJsxIgnoreComment(path);
49535 willPrintOwnComments: handleComments.willPrintOwnComments,
49536 canAttachComment: canAttachComment$1,
49537 printComment: printComment$1,
49540 // TODO: Make this as default behavior
49541 avoidAstMutation: true,
49542 ownLine: handleComments.handleOwnLineComment,
49543 endOfLine: handleComments.handleEndOfLineComment,
49544 remaining: handleComments.handleRemainingComment
49546 getCommentChildNodes: handleComments.getCommentChildNodes
49551 hardline: hardline$f,
49556 const preprocess$6 = printPreprocess$3;
49558 function genericPrint$5(path, options, print) {
49559 const node = path.getValue();
49561 switch (node.type) {
49563 return [print("node"), hardline$f];
49565 case "ArrayExpression":
49567 if (node.elements.length === 0) {
49571 const printed = path.map(() => path.getValue() === null ? "null" : print(), "elements");
49572 return ["[", indent$7([hardline$f, join$b([",", hardline$f], printed)]), hardline$f, "]"];
49575 case "ObjectExpression":
49576 return node.properties.length === 0 ? "{}" : ["{", indent$7([hardline$f, join$b([",", hardline$f], path.map(print, "properties"))]), hardline$f, "}"];
49578 case "ObjectProperty":
49579 return [print("key"), ": ", print("value")];
49581 case "UnaryExpression":
49582 return [node.operator === "+" ? "" : node.operator, print("argument")];
49584 case "NullLiteral":
49587 case "BooleanLiteral":
49588 return node.value ? "true" : "false";
49590 case "StringLiteral":
49591 case "NumericLiteral":
49592 return JSON.stringify(node.value);
49596 const parent = path.getParentNode();
49598 if (parent && parent.type === "ObjectProperty" && parent.key === node) {
49599 return JSON.stringify(node.name);
49605 case "TemplateLiteral":
49606 // There is only one `TemplateElement`
49607 return print(["quasis", 0]);
49609 case "TemplateElement":
49610 return JSON.stringify(node.value.cooked);
49613 /* istanbul ignore next */
49614 throw new Error("unknown type: " + JSON.stringify(node.type));
49618 const ignoredProperties$3 = new Set(["start", "end", "extra", "loc", "comments", "leadingComments", "trailingComments", "innerComments", "errors", "range", "tokens"]);
49620 function clean$a(node, newNode
49625 } = node; // We print quoted key
49627 if (type === "ObjectProperty" && node.key.type === "Identifier") {
49629 type: "StringLiteral",
49630 value: node.key.name
49635 if (type === "UnaryExpression" && node.operator === "+") {
49636 return newNode.argument;
49637 } // We print holes in array as `null`
49640 if (type === "ArrayExpression") {
49641 for (const [index, element] of node.elements.entries()) {
49642 if (element === null) {
49643 newNode.elements.splice(index, 0, {
49644 type: "NullLiteral"
49650 } // We print `TemplateLiteral` as string
49653 if (type === "TemplateLiteral") {
49655 type: "StringLiteral",
49656 value: node.quasis[0].value.cooked
49661 clean$a.ignoredProperties = ignoredProperties$3;
49662 var printerEstreeJson = {
49663 preprocess: preprocess$6,
49664 print: genericPrint$5,
49665 massageAstNode: clean$a
49668 const CATEGORY_COMMON = "Common"; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
49670 var commonOptions$6 = {
49673 category: CATEGORY_COMMON,
49676 description: "Print spaces between brackets.",
49677 oppositeDescription: "Do not print spaces between brackets."
49681 category: CATEGORY_COMMON,
49684 description: "Use single quotes instead of double quotes."
49688 category: CATEGORY_COMMON,
49697 description: "How to wrap prose.",
49701 description: "Wrap prose if it exceeds the print width."
49705 description: "Do not wrap prose."
49709 description: "Wrap prose as-is."
49714 category: CATEGORY_COMMON,
49717 description: "Put > of opening tags on the last line instead of on a new line."
49721 const commonOptions$5 = commonOptions$6;
49722 const CATEGORY_JAVASCRIPT = "JavaScript"; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
49727 category: CATEGORY_JAVASCRIPT,
49736 description: "Include parentheses around a sole arrow function parameter.",
49739 description: "Always include parens. Example: `(x) => x`"
49742 description: "Omit parens when possible. Example: `x => x`"
49745 bracketSameLine: commonOptions$5.bracketSameLine,
49746 bracketSpacing: commonOptions$5.bracketSpacing,
49747 jsxBracketSameLine: {
49749 category: CATEGORY_JAVASCRIPT,
49751 description: "Put > on the last line instead of at a new line.",
49752 deprecated: "2.4.0"
49756 category: CATEGORY_JAVASCRIPT,
49759 description: "Print semicolons.",
49760 oppositeDescription: "Do not print semicolons, except at the beginning of lines which may need them."
49762 singleQuote: commonOptions$5.singleQuote,
49765 category: CATEGORY_JAVASCRIPT,
49768 description: "Use single quotes in JSX."
49772 category: CATEGORY_JAVASCRIPT,
49774 default: "as-needed",
49775 description: "Change when properties in objects are quoted.",
49777 value: "as-needed",
49778 description: "Only add quotes around object properties where required."
49780 value: "consistent",
49781 description: "If at least one property in an object requires quotes, quote all properties."
49784 description: "Respect the input use of quotes in object properties."
49789 category: CATEGORY_JAVASCRIPT,
49801 description: "Print trailing commas wherever possible when multi-line.",
49804 description: "Trailing commas where valid in ES5 (objects, arrays, etc.)"
49807 description: "No trailing commas."
49810 description: "Trailing commas wherever possible (including function arguments)."
49815 var require$$0$2 = require("./parser-babel.js");
49817 var require$$1$1 = require("./parser-flow.js");
49819 var require$$2$1 = require("./parser-typescript.js");
49821 var require$$3$1 = require("./parser-angular.js");
49823 var require$$4$6 = require("./parser-espree.js");
49825 var require$$5$3 = require("./parser-meriyah.js");
49830 return require$$0$2.parsers.babel;
49833 get "babel-flow"() {
49834 return require$$0$2.parsers["babel-flow"];
49838 return require$$0$2.parsers["babel-ts"];
49842 return require$$0$2.parsers.json;
49846 return require$$0$2.parsers.json5;
49849 get "json-stringify"() {
49850 return require$$0$2.parsers["json-stringify"];
49853 get __js_expression() {
49854 return require$$0$2.parsers.__js_expression;
49857 get __vue_expression() {
49858 return require$$0$2.parsers.__vue_expression;
49861 get __vue_event_binding() {
49862 return require$$0$2.parsers.__vue_event_binding;
49867 return require$$1$1.parsers.flow;
49872 return require$$2$1.parsers.typescript;
49875 // JS - Angular Action
49876 get __ng_action() {
49877 return require$$3$1.parsers.__ng_action;
49880 // JS - Angular Binding
49881 get __ng_binding() {
49882 return require$$3$1.parsers.__ng_binding;
49885 // JS - Angular Interpolation
49886 get __ng_interpolation() {
49887 return require$$3$1.parsers.__ng_interpolation;
49890 // JS - Angular Directive
49891 get __ng_directive() {
49892 return require$$3$1.parsers.__ng_directive;
49897 return require$$4$6.parsers.espree;
49902 return require$$5$3.parsers.meriyah;
49905 // JS - Babel Estree
49906 get __babel_estree() {
49907 return require$$0$2.parsers.__babel_estree;
49912 var name$f = "JavaScript";
49913 var type$f = "programming";
49914 var tmScope$f = "source.js";
49915 var aceMode$f = "javascript";
49916 var codemirrorMode$b = "javascript";
49917 var codemirrorMimeType$b = "text/javascript";
49918 var color$a = "#f1e05a";
49923 var extensions$f = [
49947 var filenames$4 = [
49950 var interpreters$1 = [
49962 var languageId$f = 183;
49963 var require$$5$2 = {
49966 tmScope: tmScope$f,
49967 aceMode: aceMode$f,
49968 codemirrorMode: codemirrorMode$b,
49969 codemirrorMimeType: codemirrorMimeType$b,
49971 aliases: aliases$6,
49972 extensions: extensions$f,
49973 filenames: filenames$4,
49974 interpreters: interpreters$1,
49975 languageId: languageId$f
49978 var name$e = "TypeScript";
49979 var type$e = "programming";
49980 var color$9 = "#2b7489";
49984 var interpreters = [
49988 var extensions$e = [
49991 var tmScope$e = "source.ts";
49992 var aceMode$e = "typescript";
49993 var codemirrorMode$a = "javascript";
49994 var codemirrorMimeType$a = "application/typescript";
49995 var languageId$e = 378;
49996 var require$$6$1 = {
50000 aliases: aliases$5,
50001 interpreters: interpreters,
50002 extensions: extensions$e,
50003 tmScope: tmScope$e,
50004 aceMode: aceMode$e,
50005 codemirrorMode: codemirrorMode$a,
50006 codemirrorMimeType: codemirrorMimeType$a,
50007 languageId: languageId$e
50010 var name$d = "TSX";
50011 var type$d = "programming";
50012 var group$d = "TypeScript";
50013 var extensions$d = [
50016 var tmScope$d = "source.tsx";
50017 var aceMode$d = "javascript";
50018 var codemirrorMode$9 = "jsx";
50019 var codemirrorMimeType$9 = "text/jsx";
50020 var languageId$d = 94901924;
50021 var require$$7$1 = {
50025 extensions: extensions$d,
50026 tmScope: tmScope$d,
50027 aceMode: aceMode$d,
50028 codemirrorMode: codemirrorMode$9,
50029 codemirrorMimeType: codemirrorMimeType$9,
50030 languageId: languageId$d
50033 var name$c = "JSON";
50034 var type$c = "data";
50035 var tmScope$c = "source.json";
50036 var aceMode$c = "json";
50037 var codemirrorMode$8 = "javascript";
50038 var codemirrorMimeType$8 = "application/json";
50039 var extensions$c = [
50046 ".JSON-tmLanguage",
50057 var filenames$3 = [
50068 var languageId$c = 174;
50072 tmScope: tmScope$c,
50073 aceMode: aceMode$c,
50074 codemirrorMode: codemirrorMode$8,
50075 codemirrorMimeType: codemirrorMimeType$8,
50076 extensions: extensions$c,
50077 filenames: filenames$3,
50078 languageId: languageId$c
50081 var name$b = "JSON with Comments";
50082 var type$b = "data";
50083 var group$c = "JSON";
50084 var tmScope$b = "source.js";
50085 var aceMode$b = "javascript";
50086 var codemirrorMode$7 = "javascript";
50087 var codemirrorMimeType$7 = "text/javascript";
50091 var extensions$b = [
50094 ".sublime-commands",
50095 ".sublime-completions",
50099 ".sublime-mousemap",
50100 ".sublime-project",
50101 ".sublime-settings",
50103 ".sublime-workspace",
50104 ".sublime_metrics",
50107 var filenames$2 = [
50113 "api-extractor.json",
50114 "devcontainer.json",
50116 "language-configuration.json",
50120 var languageId$b = 423;
50125 tmScope: tmScope$b,
50126 aceMode: aceMode$b,
50127 codemirrorMode: codemirrorMode$7,
50128 codemirrorMimeType: codemirrorMimeType$7,
50129 aliases: aliases$4,
50130 extensions: extensions$b,
50131 filenames: filenames$2,
50132 languageId: languageId$b
50135 var name$a = "JSON5";
50136 var type$a = "data";
50137 var extensions$a = [
50140 var tmScope$a = "source.js";
50141 var aceMode$a = "javascript";
50142 var codemirrorMode$6 = "javascript";
50143 var codemirrorMimeType$6 = "application/json";
50144 var languageId$a = 175;
50145 var require$$10 = {
50148 extensions: extensions$a,
50149 tmScope: tmScope$a,
50150 aceMode: aceMode$a,
50151 codemirrorMode: codemirrorMode$6,
50152 codemirrorMimeType: codemirrorMimeType$6,
50153 languageId: languageId$a
50156 const createLanguage$6 = createLanguage$7;
50157 const estreePrinter = printerEstree;
50158 const estreeJsonPrinter = printerEstreeJson;
50159 const options$a = options$b;
50160 const parsers$c = parsers$d;
50161 const languages$7 = [createLanguage$6(require$$5$2, data => ({
50163 parsers: ["babel", "espree", "meriyah", "babel-flow", "babel-ts", "flow", "typescript"],
50164 vscodeLanguageIds: ["javascript", "mongo"],
50165 interpreters: [...data.interpreters, // https://github.com/google/zx
50167 extensions: [...data.extensions.filter(extension => extension !== ".jsx"), // WeiXin Script (Weixin Mini Programs)
50168 // https://developers.weixin.qq.com/miniprogram/en/dev/framework/view/wxs/
50170 })), createLanguage$6(require$$5$2, () => ({
50173 parsers: ["flow", "babel-flow"],
50174 vscodeLanguageIds: ["javascript"],
50177 extensions: [".js.flow"]
50178 })), createLanguage$6(require$$5$2, () => ({
50181 parsers: ["babel", "babel-flow", "babel-ts", "flow", "typescript", "espree", "meriyah"],
50182 vscodeLanguageIds: ["javascriptreact"],
50183 aliases: undefined,
50184 filenames: undefined,
50185 extensions: [".jsx"],
50186 group: "JavaScript",
50187 interpreters: undefined,
50188 tmScope: "source.js.jsx",
50189 aceMode: "javascript",
50190 codemirrorMode: "jsx",
50191 codemirrorMimeType: "text/jsx",
50193 })), createLanguage$6(require$$6$1, data => ({
50195 parsers: ["typescript", "babel-ts"],
50196 vscodeLanguageIds: ["typescript"],
50197 extensions: [...data.extensions, ".mts", ".cts"]
50198 })), createLanguage$6(require$$7$1, () => ({
50200 parsers: ["typescript", "babel-ts"],
50201 vscodeLanguageIds: ["typescriptreact"]
50202 })), createLanguage$6(require$$8, () => ({
50203 name: "JSON.stringify",
50205 parsers: ["json-stringify"],
50206 vscodeLanguageIds: ["json"],
50208 // .json file defaults to json instead of json-stringify
50209 filenames: ["package.json", "package-lock.json", "composer.json"]
50210 })), createLanguage$6(require$$8, data => ({
50213 vscodeLanguageIds: ["json"],
50214 extensions: data.extensions.filter(extension => extension !== ".jsonl")
50215 })), createLanguage$6(require$$9, data => ({
50218 vscodeLanguageIds: ["jsonc"],
50219 filenames: [...data.filenames, ".eslintrc"]
50220 })), createLanguage$6(require$$10, () => ({
50222 parsers: ["json5"],
50223 vscodeLanguageIds: ["json5"]
50225 const printers$5 = {
50226 estree: estreePrinter,
50227 "estree-json": estreeJsonPrinter
50230 languages: languages$7,
50231 options: options$a,
50232 printers: printers$5,
50237 isFrontMatterNode: isFrontMatterNode$4
50239 const getLast$9 = getLast_1;
50240 const ignoredProperties$2 = new Set(["raw", // front-matter
50241 "raws", "sourceIndex", "source", "before", "after", "trailingComma"]);
50243 function clean$9(ast, newObj, parent) {
50244 if (isFrontMatterNode$4(ast) && ast.lang === "yaml") {
50245 delete newObj.value;
50248 if (ast.type === "css-comment" && parent.type === "css-root" && parent.nodes.length > 0) {
50250 // first non-front-matter comment
50251 if (parent.nodes[0] === ast || isFrontMatterNode$4(parent.nodes[0]) && parent.nodes[1] === ast) {
50257 delete newObj.text; // standalone pragma
50259 if (/^\*\s*@(?:format|prettier)\s*$/.test(ast.text)) {
50262 } // Last comment is not parsed, when omitting semicolon, #8675
50265 if (parent.type === "css-root" && getLast$9(parent.nodes) === ast) {
50270 if (ast.type === "value-root") {
50271 delete newObj.text;
50274 if (ast.type === "media-query" || ast.type === "media-query-list" || ast.type === "media-feature-expression") {
50275 delete newObj.value;
50278 if (ast.type === "css-rule") {
50279 delete newObj.params;
50282 if (ast.type === "selector-combinator") {
50283 newObj.value = newObj.value.replace(/\s+/g, " ");
50286 if (ast.type === "media-feature") {
50287 newObj.value = newObj.value.replace(/ /g, "");
50290 if (ast.type === "value-word" && (ast.isColor && ast.isHex || ["initial", "inherit", "unset", "revert"].includes(newObj.value.replace().toLowerCase())) || ast.type === "media-feature" || ast.type === "selector-root-invalid" || ast.type === "selector-pseudo") {
50291 newObj.value = newObj.value.toLowerCase();
50294 if (ast.type === "css-decl") {
50295 newObj.prop = newObj.prop.toLowerCase();
50298 if (ast.type === "css-atrule" || ast.type === "css-import") {
50299 newObj.name = newObj.name.toLowerCase();
50302 if (ast.type === "value-number") {
50303 newObj.unit = newObj.unit.toLowerCase();
50306 if ((ast.type === "media-feature" || ast.type === "media-keyword" || ast.type === "media-type" || ast.type === "media-unknown" || ast.type === "media-url" || ast.type === "media-value" || ast.type === "selector-attribute" || ast.type === "selector-string" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "value-string") && newObj.value) {
50307 newObj.value = cleanCSSStrings(newObj.value);
50310 if (ast.type === "selector-attribute") {
50311 newObj.attribute = newObj.attribute.trim();
50313 if (newObj.namespace) {
50314 if (typeof newObj.namespace === "string") {
50315 newObj.namespace = newObj.namespace.trim();
50317 if (newObj.namespace.length === 0) {
50318 newObj.namespace = true;
50323 if (newObj.value) {
50324 newObj.value = newObj.value.trim().replace(/^["']|["']$/g, "");
50325 delete newObj.quoted;
50329 if ((ast.type === "media-value" || ast.type === "media-type" || ast.type === "value-number" || ast.type === "selector-root-invalid" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "selector-tag") && newObj.value) {
50330 newObj.value = newObj.value.replace(/([\d+.Ee-]+)([A-Za-z]*)/g, (match, numStr, unit) => {
50331 const num = Number(numStr);
50332 return Number.isNaN(num) ? match : num + unit.toLowerCase();
50336 if (ast.type === "selector-tag") {
50337 const lowercasedValue = ast.value.toLowerCase();
50339 if (["from", "to"].includes(lowercasedValue)) {
50340 newObj.value = lowercasedValue;
50342 } // Workaround when `postcss-values-parser` parse `not`, `and` or `or` keywords as `value-func`
50345 if (ast.type === "css-atrule" && ast.name.toLowerCase() === "supports") {
50346 delete newObj.value;
50347 } // Workaround for SCSS nested properties
50350 if (ast.type === "selector-unknown") {
50351 delete newObj.value;
50355 clean$9.ignoredProperties = ignoredProperties$2;
50357 function cleanCSSStrings(value) {
50358 return value.replace(/'/g, '"').replace(/\\([^\dA-Fa-f])/g, "$1");
50361 var clean_1$3 = clean$9;
50365 hardline: hardline$e,
50366 markAsRoot: markAsRoot$3
50370 function print$1(node, textToDoc) {
50371 if (node.lang === "yaml") {
50372 const value = node.value.trim();
50373 const doc = value ? textToDoc(value, {
50376 stripTrailingHardline: true
50378 return markAsRoot$3([node.startDelimiter, hardline$e, doc, doc ? hardline$e : "", node.endDelimiter]);
50382 var print_1 = print$1;
50386 hardline: hardline$d
50389 const printFrontMatter$2 = print_1;
50391 function embed$8(path, print, textToDoc
50394 const node = path.getValue();
50396 if (node.type === "front-matter") {
50397 const doc = printFrontMatter$2(node, textToDoc);
50398 return doc ? [doc, hardline$d] : "";
50402 var embed_1$3 = embed$8;
50404 const frontMatterRegex = new RegExp("^(?<startDelimiter>-{3}|\\+{3})" + // trailing spaces after delimiters are allowed
50405 "(?<language>[^\\n]*)" + "\\n(?:|(?<value>.*?)\\n)" + // In some markdown processors such as pandoc,
50406 // "..." can be used as the end delimiter for YAML front-matter.
50407 // Adding `\.{3}` make the regex matches `+++\n...`, but we'll exclude it later
50408 "(?<endDelimiter>\\k<startDelimiter>|\\.{3})" + "[^\\S\\n]*(?:\\n|$)", "s");
50410 function parse(text) {
50411 const match = text.match(frontMatterRegex);
50425 let lang = language.trim() || "yaml";
50427 if (startDelimiter === "+++") {
50429 } // Only allow yaml to parse with a different end delimiter
50432 if (lang !== "yaml" && startDelimiter !== endDelimiter) {
50438 const [raw] = match;
50439 const frontMatter = {
50440 type: "front-matter",
50445 raw: raw.replace(/\n$/, "")
50449 content: raw.replace(/[^\n]/g, " ") + text.slice(raw.length)
50453 var parse_1 = parse;
50455 const jsPragma = pragma$5;
50456 const parseFrontMatter$1 = parse_1;
50458 function hasPragma$3(text) {
50459 return jsPragma.hasPragma(parseFrontMatter$1(text).content);
50462 function insertPragma$8(text) {
50466 } = parseFrontMatter$1(text);
50467 return (frontMatter ? frontMatter.raw + "\n\n" : "") + jsPragma.insertPragma(content);
50471 hasPragma: hasPragma$3,
50472 insertPragma: insertPragma$8
50476 isNonEmptyArray: isNonEmptyArray$6
50478 const colorAdjusterFunctions = new Set(["red", "green", "blue", "alpha", "a", "rgb", "hue", "h", "saturation", "s", "lightness", "l", "whiteness", "w", "blackness", "b", "tint", "shade", "blend", "blenda", "contrast", "hsl", "hsla", "hwb", "hwba"]);
50479 const moduleRuleNames = new Set(["import", "use", "forward"]);
50481 function getAncestorCounter$1(path, typeOrTypes) {
50482 const types = Array.isArray(typeOrTypes) ? typeOrTypes : [typeOrTypes];
50486 while (ancestorNode = path.getParentNode(++counter)) {
50487 if (types.includes(ancestorNode.type)) {
50495 function getAncestorNode$2(path, typeOrTypes) {
50496 const counter = getAncestorCounter$1(path, typeOrTypes);
50497 return counter === -1 ? null : path.getParentNode(counter);
50500 function getPropOfDeclNode$1(path) {
50501 const declAncestorNode = getAncestorNode$2(path, "css-decl");
50502 return declAncestorNode && declAncestorNode.prop && declAncestorNode.prop.toLowerCase();
50505 function hasSCSSInterpolation(groupList) {
50506 if (isNonEmptyArray$6(groupList)) {
50507 for (let i = groupList.length - 1; i > 0; i--) {
50508 // If we find `#{`, return true.
50509 if (groupList[i].type === "word" && groupList[i].value === "{" && groupList[i - 1].type === "word" && groupList[i - 1].value.endsWith("#")) {
50518 function hasStringOrFunction(groupList) {
50519 if (isNonEmptyArray$6(groupList)) {
50520 for (let i = 0; i < groupList.length; i++) {
50521 if (groupList[i].type === "string" || groupList[i].type === "func") {
50530 function isSCSS$1(parser, text) {
50531 const hasExplicitParserChoice = parser === "less" || parser === "scss";
50532 const IS_POSSIBLY_SCSS = /(?:\w\s*:\s*[^:}]+|#){|@import[^\n]+(?:url|,)/;
50533 return hasExplicitParserChoice ? parser === "scss" : IS_POSSIBLY_SCSS.test(text);
50536 function isSCSSVariable(node) {
50537 return Boolean(node && node.type === "word" && node.value.startsWith("$"));
50540 function isWideKeywords$1(value) {
50541 return ["initial", "inherit", "unset", "revert"].includes(value.toLowerCase());
50544 function isKeyframeAtRuleKeywords$1(path, value) {
50545 const atRuleAncestorNode = getAncestorNode$2(path, "css-atrule");
50546 return atRuleAncestorNode && atRuleAncestorNode.name && atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") && ["from", "to"].includes(value.toLowerCase());
50549 function maybeToLowerCase$1(value) {
50550 return value.includes("$") || value.includes("@") || value.includes("#") || value.startsWith("%") || value.startsWith("--") || value.startsWith(":--") || value.includes("(") && value.includes(")") ? value : value.toLowerCase();
50553 function insideValueFunctionNode$1(path, functionName) {
50554 const funcAncestorNode = getAncestorNode$2(path, "value-func");
50555 return funcAncestorNode && funcAncestorNode.value && funcAncestorNode.value.toLowerCase() === functionName;
50558 function insideICSSRuleNode$1(path) {
50559 const ruleAncestorNode = getAncestorNode$2(path, "css-rule");
50560 return ruleAncestorNode && ruleAncestorNode.raws && ruleAncestorNode.raws.selector && (ruleAncestorNode.raws.selector.startsWith(":import") || ruleAncestorNode.raws.selector.startsWith(":export"));
50563 function insideAtRuleNode$1(path, atRuleNameOrAtRuleNames) {
50564 const atRuleNames = Array.isArray(atRuleNameOrAtRuleNames) ? atRuleNameOrAtRuleNames : [atRuleNameOrAtRuleNames];
50565 const atRuleAncestorNode = getAncestorNode$2(path, "css-atrule");
50566 return atRuleAncestorNode && atRuleNames.includes(atRuleAncestorNode.name.toLowerCase());
50569 function insideURLFunctionInImportAtRuleNode$1(path) {
50570 const node = path.getValue();
50571 const atRuleAncestorNode = getAncestorNode$2(path, "css-atrule");
50572 return atRuleAncestorNode && atRuleAncestorNode.name === "import" && node.groups[0].value === "url" && node.groups.length === 2;
50575 function isURLFunctionNode$1(node) {
50576 return node.type === "value-func" && node.value.toLowerCase() === "url";
50579 function isLastNode$1(path, node) {
50580 const parentNode = path.getParentNode();
50581 /* istanbul ignore next */
50590 return nodes && nodes.indexOf(node) === nodes.length - 1;
50593 function isDetachedRulesetDeclarationNode$1(node) {
50594 // If a Less file ends up being parsed with the SCSS parser, Less
50595 // variable declarations will be parsed as atrules with names ending
50596 // with a colon, so keep the original case then.
50598 /* istanbul ignore next */
50599 if (!node.selector) {
50603 return typeof node.selector === "string" && /^@.+:.*$/.test(node.selector) || node.selector.value && /^@.+:.*$/.test(node.selector.value);
50606 function isForKeywordNode$1(node) {
50607 return node.type === "value-word" && ["from", "through", "end"].includes(node.value);
50610 function isIfElseKeywordNode$1(node) {
50611 return node.type === "value-word" && ["and", "or", "not"].includes(node.value);
50614 function isEachKeywordNode$1(node) {
50615 return node.type === "value-word" && node.value === "in";
50618 function isMultiplicationNode$1(node) {
50619 return node.type === "value-operator" && node.value === "*";
50622 function isDivisionNode$1(node) {
50623 return node.type === "value-operator" && node.value === "/";
50626 function isAdditionNode$1(node) {
50627 return node.type === "value-operator" && node.value === "+";
50630 function isSubtractionNode$1(node) {
50631 return node.type === "value-operator" && node.value === "-";
50634 function isModuloNode(node) {
50635 return node.type === "value-operator" && node.value === "%";
50638 function isMathOperatorNode$1(node) {
50639 return isMultiplicationNode$1(node) || isDivisionNode$1(node) || isAdditionNode$1(node) || isSubtractionNode$1(node) || isModuloNode(node);
50642 function isEqualityOperatorNode$1(node) {
50643 return node.type === "value-word" && ["==", "!="].includes(node.value);
50646 function isRelationalOperatorNode$1(node) {
50647 return node.type === "value-word" && ["<", ">", "<=", ">="].includes(node.value);
50650 function isSCSSControlDirectiveNode$1(node) {
50651 return node.type === "css-atrule" && ["if", "else", "for", "each", "while"].includes(node.name);
50654 function isSCSSNestedPropertyNode(node) {
50655 /* istanbul ignore next */
50656 if (!node.selector) {
50660 return node.selector.replace(/\/\*.*?\*\//, "").replace(/\/\/.*?\n/, "").trim().endsWith(":");
50663 function isDetachedRulesetCallNode$1(node) {
50664 return node.raws && node.raws.params && /^\(\s*\)$/.test(node.raws.params);
50667 function isTemplatePlaceholderNode$1(node) {
50668 return node.name.startsWith("prettier-placeholder");
50671 function isTemplatePropNode$1(node) {
50672 return node.prop.startsWith("@prettier-placeholder");
50675 function isPostcssSimpleVarNode$1(currentNode, nextNode) {
50676 return currentNode.value === "$$" && currentNode.type === "value-func" && nextNode && nextNode.type === "value-word" && !nextNode.raws.before;
50679 function hasComposesNode$1(node) {
50680 return node.value && node.value.type === "value-root" && node.value.group && node.value.group.type === "value-value" && node.prop.toLowerCase() === "composes";
50683 function hasParensAroundNode$1(node) {
50684 return node.value && node.value.group && node.value.group.group && node.value.group.group.type === "value-paren_group" && node.value.group.group.open !== null && node.value.group.group.close !== null;
50687 function hasEmptyRawBefore$1(node) {
50688 return node.raws && node.raws.before === "";
50691 function isKeyValuePairNode$1(node) {
50692 return node.type === "value-comma_group" && node.groups && node.groups[1] && node.groups[1].type === "value-colon";
50695 function isKeyValuePairInParenGroupNode(node) {
50696 return node.type === "value-paren_group" && node.groups && node.groups[0] && isKeyValuePairNode$1(node.groups[0]);
50699 function isSCSSMapItemNode$1(path) {
50700 const node = path.getValue(); // Ignore empty item (i.e. `$key: ()`)
50702 if (node.groups.length === 0) {
50706 const parentParentNode = path.getParentNode(1); // Check open parens contain key/value pair (i.e. `(key: value)` and `(key: (value, other-value)`)
50708 if (!isKeyValuePairInParenGroupNode(node) && !(parentParentNode && isKeyValuePairInParenGroupNode(parentParentNode))) {
50712 const declNode = getAncestorNode$2(path, "css-decl"); // SCSS map declaration (i.e. `$map: (key: value, other-key: other-value)`)
50714 if (declNode && declNode.prop && declNode.prop.startsWith("$")) {
50716 } // List as value of key inside SCSS map (i.e. `$map: (key: (value other-value other-other-value))`)
50719 if (isKeyValuePairInParenGroupNode(parentParentNode)) {
50721 } // SCSS Map is argument of function (i.e. `func((key: value, other-key: other-value))`)
50724 if (parentParentNode.type === "value-func") {
50731 function isInlineValueCommentNode$1(node) {
50732 return node.type === "value-comment" && node.inline;
50735 function isHashNode$1(node) {
50736 return node.type === "value-word" && node.value === "#";
50739 function isLeftCurlyBraceNode$1(node) {
50740 return node.type === "value-word" && node.value === "{";
50743 function isRightCurlyBraceNode$1(node) {
50744 return node.type === "value-word" && node.value === "}";
50747 function isWordNode$1(node) {
50748 return ["value-word", "value-atword"].includes(node.type);
50751 function isColonNode$1(node) {
50752 return node && node.type === "value-colon";
50755 function isKeyInValuePairNode$1(node, parentNode) {
50756 if (!isKeyValuePairNode$1(parentNode)) {
50763 const index = groups.indexOf(node);
50765 if (index === -1) {
50769 return isColonNode$1(groups[index + 1]);
50772 function isMediaAndSupportsKeywords$1(node) {
50773 return node.value && ["not", "and", "or"].includes(node.value.toLowerCase());
50776 function isColorAdjusterFuncNode$1(node) {
50777 if (node.type !== "value-func") {
50781 return colorAdjusterFunctions.has(node.value.toLowerCase());
50782 } // TODO: only check `less` when we don't use `less` to parse `css`
50785 function isLessParser$1(options) {
50786 return options.parser === "css" || options.parser === "less";
50789 function lastLineHasInlineComment$1(text) {
50790 return /\/\//.test(text.split(/[\n\r]/).pop());
50793 function stringifyNode(node) {
50795 const open = node.open && node.open.value ? node.open.value : "";
50796 const groups = node.groups.reduce((previousValue, currentValue, index) => previousValue + stringifyNode(currentValue) + (node.groups[0].type === "comma_group" && index !== node.groups.length - 1 ? "," : ""), "");
50797 const close = node.close && node.close.value ? node.close.value : "";
50798 return open + groups + close;
50801 const before = node.raws && node.raws.before ? node.raws.before : "";
50802 const quote = node.raws && node.raws.quote ? node.raws.quote : "";
50803 const atword = node.type === "atword" ? "@" : "";
50804 const value = node.value ? node.value : "";
50805 const unit = node.unit ? node.unit : "";
50806 const group = node.group ? stringifyNode(node.group) : "";
50807 const after = node.raws && node.raws.after ? node.raws.after : "";
50808 return before + quote + atword + value + quote + unit + group + after;
50811 function isAtWordPlaceholderNode$1(node) {
50812 return node && node.type === "value-atword" && node.value.startsWith("prettier-placeholder-");
50815 function isModuleRuleName(name) {
50816 return moduleRuleNames.has(name);
50819 function isConfigurationNode$1(node, parentNode) {
50820 if (!node.open || node.open.value !== "(" || !node.close || node.close.value !== ")" || node.groups.some(group => group.type !== "value-comma_group")) {
50824 if (parentNode.type === "value-comma_group") {
50825 const prevIdx = parentNode.groups.indexOf(node) - 1;
50826 const maybeWithNode = parentNode.groups[prevIdx];
50828 if (maybeWithNode && maybeWithNode.type === "value-word" && maybeWithNode.value === "with") {
50836 function isParenGroupNode$1(node) {
50837 return node.type === "value-paren_group" && node.open && node.open.value === "(" && node.close && node.close.value === ")";
50841 getAncestorCounter: getAncestorCounter$1,
50842 getAncestorNode: getAncestorNode$2,
50843 getPropOfDeclNode: getPropOfDeclNode$1,
50844 hasSCSSInterpolation,
50845 hasStringOrFunction,
50846 maybeToLowerCase: maybeToLowerCase$1,
50847 insideValueFunctionNode: insideValueFunctionNode$1,
50848 insideICSSRuleNode: insideICSSRuleNode$1,
50849 insideAtRuleNode: insideAtRuleNode$1,
50850 insideURLFunctionInImportAtRuleNode: insideURLFunctionInImportAtRuleNode$1,
50851 isKeyframeAtRuleKeywords: isKeyframeAtRuleKeywords$1,
50852 isWideKeywords: isWideKeywords$1,
50855 isLastNode: isLastNode$1,
50856 isLessParser: isLessParser$1,
50857 isSCSSControlDirectiveNode: isSCSSControlDirectiveNode$1,
50858 isDetachedRulesetDeclarationNode: isDetachedRulesetDeclarationNode$1,
50859 isRelationalOperatorNode: isRelationalOperatorNode$1,
50860 isEqualityOperatorNode: isEqualityOperatorNode$1,
50861 isMultiplicationNode: isMultiplicationNode$1,
50862 isDivisionNode: isDivisionNode$1,
50863 isAdditionNode: isAdditionNode$1,
50864 isSubtractionNode: isSubtractionNode$1,
50866 isMathOperatorNode: isMathOperatorNode$1,
50867 isEachKeywordNode: isEachKeywordNode$1,
50868 isForKeywordNode: isForKeywordNode$1,
50869 isURLFunctionNode: isURLFunctionNode$1,
50870 isIfElseKeywordNode: isIfElseKeywordNode$1,
50871 hasComposesNode: hasComposesNode$1,
50872 hasParensAroundNode: hasParensAroundNode$1,
50873 hasEmptyRawBefore: hasEmptyRawBefore$1,
50874 isSCSSNestedPropertyNode,
50875 isDetachedRulesetCallNode: isDetachedRulesetCallNode$1,
50876 isTemplatePlaceholderNode: isTemplatePlaceholderNode$1,
50877 isTemplatePropNode: isTemplatePropNode$1,
50878 isPostcssSimpleVarNode: isPostcssSimpleVarNode$1,
50879 isKeyValuePairNode: isKeyValuePairNode$1,
50880 isKeyValuePairInParenGroupNode,
50881 isKeyInValuePairNode: isKeyInValuePairNode$1,
50882 isSCSSMapItemNode: isSCSSMapItemNode$1,
50883 isInlineValueCommentNode: isInlineValueCommentNode$1,
50884 isHashNode: isHashNode$1,
50885 isLeftCurlyBraceNode: isLeftCurlyBraceNode$1,
50886 isRightCurlyBraceNode: isRightCurlyBraceNode$1,
50887 isWordNode: isWordNode$1,
50888 isColonNode: isColonNode$1,
50889 isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
50890 isColorAdjusterFuncNode: isColorAdjusterFuncNode$1,
50891 lastLineHasInlineComment: lastLineHasInlineComment$1,
50893 isAtWordPlaceholderNode: isAtWordPlaceholderNode$1,
50895 isConfigurationNode: isConfigurationNode$1,
50896 isParenGroupNode: isParenGroupNode$1
50899 var lineColumnToIndex$1 = function (lineColumn, text) {
50902 for (let i = 0; i < lineColumn.line - 1; ++i) {
50903 index = text.indexOf("\n", index) + 1;
50906 return index + lineColumn.column;
50909 const lineColumnToIndex = lineColumnToIndex$1;
50911 getLast: getLast$8,
50912 skipEverythingButNewLine
50915 function calculateLocStart(node, text) {
50916 // value-* nodes have this
50917 if (typeof node.sourceIndex === "number") {
50918 return node.sourceIndex;
50921 return node.source ? lineColumnToIndex(node.source.start, text) - 1 : null;
50924 function calculateLocEnd(node, text) {
50925 if (node.type === "css-comment" && node.inline) {
50926 return skipEverythingButNewLine(text, node.source.startOffset);
50929 const endNode = node.nodes && getLast$8(node.nodes);
50931 if (endNode && node.source && !node.source.end) {
50935 if (node.source && node.source.end) {
50936 return lineColumnToIndex(node.source.end, text);
50942 function calculateLoc(node, text) {
50944 node.source.startOffset = calculateLocStart(node, text);
50945 node.source.endOffset = calculateLocEnd(node, text);
50948 for (const key in node) {
50949 const child = node[key];
50951 if (key === "source" || !child || typeof child !== "object") {
50955 if (child.type === "value-root" || child.type === "value-unknown") {
50956 calculateValueNodeLoc(child, getValueRootOffset(node), child.text || child.value);
50958 calculateLoc(child, text);
50963 function calculateValueNodeLoc(node, rootOffset, text) {
50965 node.source.startOffset = calculateLocStart(node, text) + rootOffset;
50966 node.source.endOffset = calculateLocEnd(node, text) + rootOffset;
50969 for (const key in node) {
50970 const child = node[key];
50972 if (key === "source" || !child || typeof child !== "object") {
50976 calculateValueNodeLoc(child, rootOffset, text);
50980 function getValueRootOffset(node) {
50981 let result = node.source.startOffset;
50983 if (typeof node.prop === "string") {
50984 result += node.prop.length;
50987 if (node.type === "css-atrule" && typeof node.name === "string") {
50988 result += 1 + node.name.length + node.raws.afterName.match(/^\s*:?\s*/)[0].length;
50991 if (node.type !== "css-atrule" && node.raws && typeof node.raws.between === "string") {
50992 result += node.raws.between.length;
50998 * Workaround for a bug: quotes and asterisks in inline comments corrupt loc data of subsequent nodes.
50999 * This function replaces the quotes and asterisks with spaces. Later, when the comments are printed,
51000 * their content is extracted from the original text.
51001 * - https://github.com/prettier/prettier/issues/7780
51002 * - https://github.com/shellscape/postcss-less/issues/145
51003 * - https://github.com/prettier/prettier/issues/8130
51004 * @param text {string}
51008 function replaceQuotesInInlineComments(text) {
51009 /** @typedef { 'initial' | 'single-quotes' | 'double-quotes' | 'url' | 'comment-block' | 'comment-inline' } State */
51011 /** @type {State} */
51012 let state = "initial";
51013 /** @type {State} */
51015 let stateToReturnFromQuotes = "initial";
51016 let inlineCommentStartIndex;
51017 let inlineCommentContainsQuotes = false;
51018 const inlineCommentsToReplace = [];
51020 for (let i = 0; i < text.length; i++) {
51026 state = "single-quotes";
51031 state = "double-quotes";
51035 if ((c === "u" || c === "U") && text.slice(i, i + 4).toLowerCase() === "url(") {
51041 if (c === "*" && text[i - 1] === "/") {
51042 state = "comment-block";
51046 if (c === "/" && text[i - 1] === "/") {
51047 state = "comment-inline";
51048 inlineCommentStartIndex = i - 1;
51054 case "single-quotes":
51055 if (c === "'" && text[i - 1] !== "\\") {
51056 state = stateToReturnFromQuotes;
51057 stateToReturnFromQuotes = "initial";
51060 if (c === "\n" || c === "\r") {
51061 return text; // invalid input
51066 case "double-quotes":
51067 if (c === '"' && text[i - 1] !== "\\") {
51068 state = stateToReturnFromQuotes;
51069 stateToReturnFromQuotes = "initial";
51072 if (c === "\n" || c === "\r") {
51073 return text; // invalid input
51083 if (c === "\n" || c === "\r") {
51084 return text; // invalid input
51088 state = "single-quotes";
51089 stateToReturnFromQuotes = "url";
51094 state = "double-quotes";
51095 stateToReturnFromQuotes = "url";
51101 case "comment-block":
51102 if (c === "/" && text[i - 1] === "*") {
51108 case "comment-inline":
51109 if (c === '"' || c === "'" || c === "*") {
51110 inlineCommentContainsQuotes = true;
51113 if (c === "\n" || c === "\r") {
51114 if (inlineCommentContainsQuotes) {
51115 inlineCommentsToReplace.push([inlineCommentStartIndex, i]);
51119 inlineCommentContainsQuotes = false;
51126 for (const [start, end] of inlineCommentsToReplace) {
51127 text = text.slice(0, start) + text.slice(start, end).replace(/["'*]/g, " ") + text.slice(end);
51133 function locStart$e(node) {
51134 return node.source.startOffset;
51137 function locEnd$d(node) {
51138 return node.source.endOffset;
51142 locStart: locStart$e,
51145 replaceQuotesInInlineComments
51148 const getLast$7 = getLast_1;
51153 isFrontMatterNode: isFrontMatterNode$3,
51154 isNextLineEmpty: isNextLineEmpty$3,
51155 isNonEmptyArray: isNonEmptyArray$5
51161 hardline: hardline$c,
51162 softline: softline$9,
51167 ifBreak: ifBreak$8,
51168 breakParent: breakParent$5
51172 getDocParts: getDocParts$5
51175 const clean$8 = clean_1$3;
51176 const embed$7 = embed_1$3;
51178 insertPragma: insertPragma$7
51181 getAncestorNode: getAncestorNode$1,
51184 insideValueFunctionNode,
51185 insideICSSRuleNode,
51187 insideURLFunctionInImportAtRuleNode,
51188 isKeyframeAtRuleKeywords,
51193 isSCSSControlDirectiveNode,
51194 isDetachedRulesetDeclarationNode,
51195 isRelationalOperatorNode,
51196 isEqualityOperatorNode,
51197 isMultiplicationNode,
51201 isMathOperatorNode,
51205 isIfElseKeywordNode,
51207 hasParensAroundNode,
51209 isKeyValuePairNode,
51210 isKeyInValuePairNode,
51211 isDetachedRulesetCallNode,
51212 isTemplatePlaceholderNode,
51213 isTemplatePropNode,
51214 isPostcssSimpleVarNode,
51216 isInlineValueCommentNode,
51218 isLeftCurlyBraceNode,
51219 isRightCurlyBraceNode,
51222 isMediaAndSupportsKeywords,
51223 isColorAdjusterFuncNode,
51224 lastLineHasInlineComment,
51225 isAtWordPlaceholderNode,
51226 isConfigurationNode,
51230 locStart: locStart$d,
51234 function shouldPrintComma(options) {
51235 return options.trailingComma === "es5" || options.trailingComma === "all";
51238 function genericPrint$4(path, options, print) {
51239 const node = path.getValue();
51240 /* istanbul ignore if */
51246 if (typeof node === "string") {
51250 switch (node.type) {
51251 case "front-matter":
51252 return [node.raw, hardline$c];
51256 const nodes = printNodeSequence(path, options, print);
51257 const after = node.raws.after.trim();
51258 return [nodes, after ? ` ${after}` : "", getDocParts$5(nodes).length > 0 ? hardline$c : ""];
51261 case "css-comment":
51263 const isInlineComment = node.inline || node.raws.inline;
51264 const text = options.originalText.slice(locStart$d(node), locEnd$c(node));
51265 return isInlineComment ? text.trimEnd() : text;
51270 return [print("selector"), node.important ? " !important" : "", node.nodes ? [node.selector && node.selector.type === "selector-unknown" && lastLineHasInlineComment(node.selector.value) ? line$d : " ", "{", node.nodes.length > 0 ? indent$6([hardline$c, printNodeSequence(path, options, print)]) : "", hardline$c, "}", isDetachedRulesetDeclarationNode(node) ? ";" : ""] : ";"];
51275 const parentNode = path.getParentNode();
51277 between: rawBetween
51279 const trimmedBetween = rawBetween.trim();
51280 const isColon = trimmedBetween === ":";
51281 let value = hasComposesNode(node) ? removeLines(print("value")) : print("value");
51283 if (!isColon && lastLineHasInlineComment(trimmedBetween)) {
51284 value = indent$6([hardline$c, dedent$2(value)]);
51287 return [node.raws.before.replace(/[\s;]/g, ""), insideICSSRuleNode(path) ? node.prop : maybeToLowerCase(node.prop), trimmedBetween.startsWith("//") ? " " : "", trimmedBetween, node.extend ? "" : " ", isLessParser(options) && node.extend && node.selector ? ["extend(", print("selector"), ")"] : "", value, node.raws.important ? node.raws.important.replace(/\s*!\s*important/i, " !important") : node.important ? " !important" : "", node.raws.scssDefault ? node.raws.scssDefault.replace(/\s*!default/i, " !default") : node.scssDefault ? " !default" : "", node.raws.scssGlobal ? node.raws.scssGlobal.replace(/\s*!global/i, " !global") : node.scssGlobal ? " !global" : "", node.nodes ? [" {", indent$6([softline$9, printNodeSequence(path, options, print)]), softline$9, "}"] : isTemplatePropNode(node) && !parentNode.raws.semicolon && options.originalText[locEnd$c(node) - 1] !== ";" ? "" : options.__isHTMLStyleAttribute && isLastNode(path, node) ? ifBreak$8(";") : ";"];
51292 const parentNode = path.getParentNode();
51293 const isTemplatePlaceholderNodeWithoutSemiColon = isTemplatePlaceholderNode(node) && !parentNode.raws.semicolon && options.originalText[locEnd$c(node) - 1] !== ";";
51295 if (isLessParser(options)) {
51297 return [print("selector"), node.important ? " !important" : "", isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"];
51300 if (node.function) {
51301 return [node.name, print("params"), isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"];
51304 if (node.variable) {
51305 return ["@", node.name, ": ", node.value ? print("value") : "", node.raws.between.trim() ? node.raws.between.trim() + " " : "", node.nodes ? ["{", indent$6([node.nodes.length > 0 ? softline$9 : "", printNodeSequence(path, options, print)]), softline$9, "}"] : "", isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"];
51309 return ["@", // If a Less file ends up being parsed with the SCSS parser, Less
51310 // variable declarations will be parsed as at-rules with names ending
51311 // with a colon, so keep the original case then.
51312 isDetachedRulesetCallNode(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase(node.name), node.params ? [isDetachedRulesetCallNode(node) ? "" : isTemplatePlaceholderNode(node) ? node.raws.afterName === "" ? "" : node.name.endsWith(":") ? " " : /^\s*\n\s*\n/.test(node.raws.afterName) ? [hardline$c, hardline$c] : /^\s*\n/.test(node.raws.afterName) ? hardline$c : " " : " ", print("params")] : "", node.selector ? indent$6([" ", print("selector")]) : "", node.value ? group$b([" ", print("value"), isSCSSControlDirectiveNode(node) ? hasParensAroundNode(node) ? " " : line$d : ""]) : node.name === "else" ? " " : "", node.nodes ? [isSCSSControlDirectiveNode(node) ? "" : node.selector && !node.selector.nodes && typeof node.selector.value === "string" && lastLineHasInlineComment(node.selector.value) || !node.selector && typeof node.params === "string" && lastLineHasInlineComment(node.params) ? line$d : " ", "{", indent$6([node.nodes.length > 0 ? softline$9 : "", printNodeSequence(path, options, print)]), softline$9, "}"] : isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"];
51314 // postcss-media-query-parser
51316 case "media-query-list":
51319 path.each(childPath => {
51320 const node = childPath.getValue();
51322 if (node.type === "media-query" && node.value === "") {
51326 parts.push(print());
51328 return group$b(indent$6(join$a(line$d, parts)));
51331 case "media-query":
51333 return [join$a(" ", path.map(print, "nodes")), isLastNode(path, node) ? "" : ","];
51338 return adjustNumbers(adjustStrings(node.value, options));
51341 case "media-feature-expression":
51347 return ["(", ...path.map(print, "nodes"), ")"];
51350 case "media-feature":
51352 return maybeToLowerCase(adjustStrings(node.value.replace(/ +/g, " "), options));
51355 case "media-colon":
51357 return [node.value, " "];
51360 case "media-value":
51362 return adjustNumbers(adjustStrings(node.value, options));
51365 case "media-keyword":
51367 return adjustStrings(node.value, options);
51372 return adjustStrings(node.value.replace(/^url\(\s+/gi, "url(").replace(/\s+\)$/g, ")"), options);
51375 case "media-unknown":
51379 // postcss-selector-parser
51381 case "selector-root":
51383 return group$b([insideAtRuleNode(path, "custom-selector") ? [getAncestorNode$1(path, "css-atrule").customSelector, line$d] : "", join$a([",", insideAtRuleNode(path, ["extend", "custom-selector", "nest"]) ? line$d : hardline$c], path.map(print, "nodes"))]);
51386 case "selector-selector":
51388 return group$b(indent$6(path.map(print, "nodes")));
51391 case "selector-comment":
51396 case "selector-string":
51398 return adjustStrings(node.value, options);
51401 case "selector-tag":
51403 const parentNode = path.getParentNode();
51404 const index = parentNode && parentNode.nodes.indexOf(node);
51405 const prevNode = index && parentNode.nodes[index - 1];
51406 return [node.namespace ? [node.namespace === true ? "" : node.namespace.trim(), "|"] : "", prevNode.type === "selector-nesting" ? node.value : adjustNumbers(isKeyframeAtRuleKeywords(path, node.value) ? node.value.toLowerCase() : node.value)];
51409 case "selector-id":
51411 return ["#", node.value];
51414 case "selector-class":
51416 return [".", adjustNumbers(adjustStrings(node.value, options))];
51419 case "selector-attribute":
51421 return ["[", node.namespace ? [node.namespace === true ? "" : node.namespace.trim(), "|"] : "", node.attribute.trim(), node.operator ? node.operator : "", node.value ? quoteAttributeValue(adjustStrings(node.value.trim(), options), options) : "", node.insensitive ? " i" : "", "]"];
51424 case "selector-combinator":
51426 if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") {
51427 const parentNode = path.getParentNode();
51428 const leading = parentNode.type === "selector-selector" && parentNode.nodes[0] === node ? "" : line$d;
51429 return [leading, node.value, isLastNode(path, node) ? "" : " "];
51432 const leading = node.value.trim().startsWith("(") ? line$d : "";
51433 const value = adjustNumbers(adjustStrings(node.value.trim(), options)) || line$d;
51434 return [leading, value];
51437 case "selector-universal":
51439 return [node.namespace ? [node.namespace === true ? "" : node.namespace.trim(), "|"] : "", node.value];
51442 case "selector-pseudo":
51444 return [maybeToLowerCase(node.value), isNonEmptyArray$5(node.nodes) ? ["(", join$a(", ", path.map(print, "nodes")), ")"] : ""];
51447 case "selector-nesting":
51452 case "selector-unknown":
51454 const ruleAncestorNode = getAncestorNode$1(path, "css-rule"); // Nested SCSS property
51456 if (ruleAncestorNode && ruleAncestorNode.isSCSSNesterProperty) {
51457 return adjustNumbers(adjustStrings(maybeToLowerCase(node.value), options));
51458 } // originalText has to be used for Less, see replaceQuotesInInlineComments in loc.js
51461 const parentNode = path.getParentNode();
51463 if (parentNode.raws && parentNode.raws.selector) {
51464 const start = locStart$d(parentNode);
51465 const end = start + parentNode.raws.selector.length;
51466 return options.originalText.slice(start, end).trim();
51467 } // Same reason above
51470 const grandParent = path.getParentNode(1);
51472 if (parentNode.type === "value-paren_group" && grandParent && grandParent.type === "value-func" && grandParent.value === "selector") {
51473 const start = locStart$d(parentNode.open) + 1;
51474 const end = locEnd$c(parentNode.close) - 1;
51475 const selector = options.originalText.slice(start, end).trim();
51476 return lastLineHasInlineComment(selector) ? [breakParent$5, selector] : selector;
51481 // postcss-values-parser
51483 case "value-value":
51486 return print("group");
51489 case "value-comment":
51491 return options.originalText.slice(locStart$d(node), locEnd$c(node));
51494 case "value-comma_group":
51496 const parentNode = path.getParentNode();
51497 const parentParentNode = path.getParentNode(1);
51498 const declAncestorProp = getPropOfDeclNode(path);
51499 const isGridValue = declAncestorProp && parentNode.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
51500 const atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
51501 const isControlDirective = atRuleAncestorNode && isSCSSControlDirectiveNode(atRuleAncestorNode);
51502 const hasInlineComment = node.groups.some(node => isInlineValueCommentNode(node));
51503 const printed = path.map(print, "groups");
51505 const insideURLFunction = insideValueFunctionNode(path, "url");
51506 let insideSCSSInterpolationInString = false;
51507 let didBreak = false;
51509 for (let i = 0; i < node.groups.length; ++i) {
51510 parts.push(printed[i]);
51511 const iPrevNode = node.groups[i - 1];
51512 const iNode = node.groups[i];
51513 const iNextNode = node.groups[i + 1];
51514 const iNextNextNode = node.groups[i + 2];
51516 if (insideURLFunction) {
51517 if (iNextNode && isAdditionNode(iNextNode) || isAdditionNode(iNode)) {
51522 } // Ignore SCSS @forward wildcard suffix
51525 if (insideAtRuleNode(path, "forward") && iNode.type === "value-word" && iNode.value && iPrevNode !== undefined && iPrevNode.type === "value-word" && iPrevNode.value === "as" && iNextNode.type === "value-operator" && iNextNode.value === "*") {
51527 } // Ignore after latest node (i.e. before semicolon)
51532 } // styled.div` background: var(--${one}); `
51535 if (iNode.type === "value-word" && iNode.value.endsWith("-") && isAtWordPlaceholderNode(iNextNode)) {
51537 } // Ignore spaces before/after string interpolation (i.e. `"#{my-fn("_")}"`)
51540 const isStartSCSSInterpolationInString = iNode.type === "value-string" && iNode.value.startsWith("#{");
51541 const isEndingSCSSInterpolationInString = insideSCSSInterpolationInString && iNextNode.type === "value-string" && iNextNode.value.endsWith("}");
51543 if (isStartSCSSInterpolationInString || isEndingSCSSInterpolationInString) {
51544 insideSCSSInterpolationInString = !insideSCSSInterpolationInString;
51548 if (insideSCSSInterpolationInString) {
51550 } // Ignore colon (i.e. `:`)
51553 if (isColonNode(iNode) || isColonNode(iNextNode)) {
51555 } // Ignore `@` in Less (i.e. `@@var;`)
51558 if (iNode.type === "value-atword" && iNode.value === "") {
51560 } // Ignore `~` in Less (i.e. `content: ~"^//* some horrible but needed css hack";`)
51563 if (iNode.value === "~") {
51565 } // Ignore escape `\`
51568 if (iNode.value && iNode.value.includes("\\") && iNextNode && iNextNode.type !== "value-comment") {
51570 } // Ignore escaped `/`
51573 if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") {
51575 } // Ignore `\` (i.e. `$variable: \@small;`)
51578 if (iNode.value === "\\") {
51580 } // Ignore `$$` (i.e. `background-color: $$(style)Color;`)
51583 if (isPostcssSimpleVarNode(iNode, iNextNode)) {
51585 } // Ignore spaces after `#` and after `{` and before `}` in SCSS interpolation (i.e. `#{variable}`)
51588 if (isHashNode(iNode) || isLeftCurlyBraceNode(iNode) || isRightCurlyBraceNode(iNextNode) || isLeftCurlyBraceNode(iNextNode) && hasEmptyRawBefore(iNextNode) || isRightCurlyBraceNode(iNode) && hasEmptyRawBefore(iNextNode)) {
51590 } // Ignore css variables and interpolation in SCSS (i.e. `--#{$var}`)
51593 if (iNode.value === "--" && isHashNode(iNextNode)) {
51595 } // Formatting math operations
51598 const isMathOperator = isMathOperatorNode(iNode);
51599 const isNextMathOperator = isMathOperatorNode(iNextNode); // Print spaces before and after math operators beside SCSS interpolation as is
51600 // (i.e. `#{$var}+5`, `#{$var} +5`, `#{$var}+ 5`, `#{$var} + 5`)
51601 // (i.e. `5+#{$var}`, `5 +#{$var}`, `5+ #{$var}`, `5 + #{$var}`)
51603 if ((isMathOperator && isHashNode(iNextNode) || isNextMathOperator && isRightCurlyBraceNode(iNode)) && hasEmptyRawBefore(iNextNode)) {
51605 } // absolute paths are only parsed as one token if they are part of url(/abs/path) call
51606 // but if you have custom -fb-url(/abs/path/) then it is parsed as "division /" and rest
51607 // of the path. We don't want to put a space after that first division in this case.
51610 if (!iPrevNode && isDivisionNode(iNode)) {
51612 } // Print spaces before and after addition and subtraction math operators as is in `calc` function
51613 // due to the fact that it is not valid syntax
51614 // (i.e. `calc(1px+1px)`, `calc(1px+ 1px)`, `calc(1px +1px)`, `calc(1px + 1px)`)
51617 if (insideValueFunctionNode(path, "calc") && (isAdditionNode(iNode) || isAdditionNode(iNextNode) || isSubtractionNode(iNode) || isSubtractionNode(iNextNode)) && hasEmptyRawBefore(iNextNode)) {
51619 } // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`)
51620 // Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is.
51623 const isColorAdjusterNode = (isAdditionNode(iNode) || isSubtractionNode(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode(parentParentNode) && !hasEmptyRawBefore(iNextNode);
51624 const requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode(iNextNextNode) || iNode.type === "value-func" || isWordNode(iNode);
51625 const requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode(iPrevNode); // Formatting `/`, `+`, `-` sign
51627 if (!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) && !insideValueFunctionNode(path, "calc") && !isColorAdjusterNode && (isDivisionNode(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode(iNode) && !requireSpaceAfterOperator || isAdditionNode(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode(iNode) && !requireSpaceAfterOperator || isSubtractionNode(iNextNode) || isSubtractionNode(iNode)) && (hasEmptyRawBefore(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode(iPrevNode)))) {
51629 } // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
51632 if (isInlineValueCommentNode(iNode)) {
51633 if (parentNode.type === "value-paren_group") {
51634 parts.push(dedent$2(hardline$c));
51638 parts.push(hardline$c);
51640 } // Handle keywords in SCSS control directive
51643 if (isControlDirective && (isEqualityOperatorNode(iNextNode) || isRelationalOperatorNode(iNextNode) || isIfElseKeywordNode(iNextNode) || isEachKeywordNode(iNode) || isForKeywordNode(iNode))) {
51646 } // At-rule `namespace` should be in one line
51649 if (atRuleAncestorNode && atRuleAncestorNode.name.toLowerCase() === "namespace") {
51652 } // Formatting `grid` property
51656 if (iNode.source && iNextNode.source && iNode.source.start.line !== iNextNode.source.start.line) {
51657 parts.push(hardline$c);
51664 } // Add `space` before next math operation
51665 // Note: `grip` property have `/` delimiter and it is not math operation, so
51666 // `grid` property handles above
51669 if (isNextMathOperator) {
51672 } // allow function(returns-list($list)...)
51675 if (iNextNode && iNextNode.value === "...") {
51679 if (isAtWordPlaceholderNode(iNode) && isAtWordPlaceholderNode(iNextNode) && locEnd$c(iNode) === locStart$d(iNextNode)) {
51683 if (isAtWordPlaceholderNode(iNode) && isParenGroupNode(iNextNode) && locEnd$c(iNode) === locStart$d(iNextNode.open)) {
51684 parts.push(softline$9);
51688 if (iNode.value === "with" && isParenGroupNode(iNextNode)) {
51691 } // Be default all values go through `line`
51694 parts.push(line$d);
51697 if (hasInlineComment) {
51698 parts.push(breakParent$5);
51702 parts.unshift(hardline$c);
51705 if (isControlDirective) {
51706 return group$b(indent$6(parts));
51707 } // Indent is not needed for import url when url is very long
51708 // and node has two groups
51709 // when type is value-comma_group
51710 // example @import url("verylongurl") projection,tv
51713 if (insideURLFunctionInImportAtRuleNode(path)) {
51714 return group$b(fill$6(parts));
51717 return group$b(indent$6(fill$6(parts)));
51720 case "value-paren_group":
51722 const parentNode = path.getParentNode();
51724 if (parentNode && isURLFunctionNode(parentNode) && (node.groups.length === 1 || node.groups.length > 0 && node.groups[0].type === "value-comma_group" && node.groups[0].groups.length > 0 && node.groups[0].groups[0].type === "value-word" && node.groups[0].groups[0].value.startsWith("data:"))) {
51725 return [node.open ? print("open") : "", join$a(",", path.map(print, "groups")), node.close ? print("close") : ""];
51729 const printed = path.map(print, "groups");
51732 for (let i = 0; i < printed.length; i++) {
51734 res.push([",", line$d]);
51737 res.push(printed[i]);
51740 return group$b(indent$6(fill$6(res)));
51743 const isSCSSMapItem = isSCSSMapItemNode(path);
51744 const lastItem = getLast$7(node.groups);
51745 const isLastItemComment = lastItem && lastItem.type === "value-comment";
51746 const isKey = isKeyInValuePairNode(node, parentNode);
51747 const isConfiguration = isConfigurationNode(node, parentNode);
51748 const shouldBreak = isConfiguration || isSCSSMapItem && !isKey;
51749 const shouldDedent = isConfiguration || isKey;
51750 const printed = group$b([node.open ? print("open") : "", indent$6([softline$9, join$a([",", line$d], path.map(childPath => {
51751 const node = childPath.getValue();
51752 const printed = print(); // Key/Value pair in open paren already indented
51754 if (isKeyValuePairNode(node) && node.type === "value-comma_group" && node.groups && node.groups[0].type !== "value-paren_group" && node.groups[2] && node.groups[2].type === "value-paren_group") {
51755 const parts = getDocParts$5(printed.contents.contents);
51756 parts[1] = group$b(parts[1]);
51757 return group$b(dedent$2(printed));
51761 }, "groups"))]), ifBreak$8(!isLastItemComment && isSCSS(options.parser, options.originalText) && isSCSSMapItem && shouldPrintComma(options) ? "," : ""), softline$9, node.close ? print("close") : ""], {
51764 return shouldDedent ? dedent$2(printed) : printed;
51769 return [node.value, insideAtRuleNode(path, "supports") && isMediaAndSupportsKeywords(node) ? " " : "", print("group")];
51772 case "value-paren":
51777 case "value-number":
51779 return [printCssNumber(node.value), maybeToLowerCase(node.unit)];
51782 case "value-operator":
51789 if (node.isColor && node.isHex || isWideKeywords(node.value)) {
51790 return node.value.toLowerCase();
51796 case "value-colon":
51798 const parentNode = path.getParentNode();
51799 const index = parentNode && parentNode.groups.indexOf(node);
51800 const prevNode = index && parentNode.groups[index - 1];
51801 return [node.value, // Don't add spaces on escaped colon `:`, e.g: grid-template-rows: [row-1-00\:00] auto;
51802 prevNode && typeof prevNode.value === "string" && getLast$7(prevNode.value) === "\\" || // Don't add spaces on `:` in `url` function (i.e. `url(fbglyph: cross-outline, fig-white)`)
51803 insideValueFunctionNode(path, "url") ? "" : line$d];
51805 // TODO: confirm this code is dead
51807 /* istanbul ignore next */
51809 case "value-comma":
51811 return [node.value, " "];
51814 case "value-string":
51816 return printString(node.raws.quote + node.value + node.raws.quote, options);
51819 case "value-atword":
51821 return ["@", node.value];
51824 case "value-unicode-range":
51829 case "value-unknown":
51835 /* istanbul ignore next */
51836 throw new Error(`Unknown postcss type ${JSON.stringify(node.type)}`);
51840 function printNodeSequence(path, options, print) {
51842 path.each((pathChild, i, nodes) => {
51843 const prevNode = nodes[i - 1];
51845 if (prevNode && prevNode.type === "css-comment" && prevNode.text.trim() === "prettier-ignore") {
51846 const childNode = pathChild.getValue();
51847 parts.push(options.originalText.slice(locStart$d(childNode), locEnd$c(childNode)));
51849 parts.push(print());
51852 if (i !== nodes.length - 1) {
51853 if (nodes[i + 1].type === "css-comment" && !hasNewline(options.originalText, locStart$d(nodes[i + 1]), {
51855 }) && !isFrontMatterNode$3(nodes[i]) || nodes[i + 1].type === "css-atrule" && nodes[i + 1].name === "else" && nodes[i].type !== "css-comment") {
51858 parts.push(options.__isHTMLStyleAttribute ? line$d : hardline$c);
51860 if (isNextLineEmpty$3(options.originalText, pathChild.getValue(), locEnd$c) && !isFrontMatterNode$3(nodes[i])) {
51861 parts.push(hardline$c);
51869 const STRING_REGEX = /(["'])(?:(?!\1)[^\\]|\\.)*\1/gs;
51870 const NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[Ee][+-]?\d+)?/g;
51871 const STANDARD_UNIT_REGEX = /[A-Za-z]+/g;
51872 const WORD_PART_REGEX = /[$@]?[A-Z_a-z\u0080-\uFFFF][\w\u0080-\uFFFF-]*/g;
51873 const ADJUST_NUMBERS_REGEX = new RegExp(STRING_REGEX.source + "|" + `(${WORD_PART_REGEX.source})?` + `(${NUMBER_REGEX.source})` + `(${STANDARD_UNIT_REGEX.source})?`, "g");
51875 function adjustStrings(value, options) {
51876 return value.replace(STRING_REGEX, match => printString(match, options));
51879 function quoteAttributeValue(value, options) {
51880 const quote = options.singleQuote ? "'" : '"';
51881 return value.includes('"') || value.includes("'") ? value : quote + value + quote;
51884 function adjustNumbers(value) {
51885 return value.replace(ADJUST_NUMBERS_REGEX, (match, quote, wordPart, number, unit) => !wordPart && number ? printCssNumber(number) + maybeToLowerCase(unit || "") : match);
51888 function printCssNumber(rawNumber) {
51889 return printNumber(rawNumber) // Remove trailing `.0`.
51890 .replace(/\.0(?=$|e)/, "");
51893 var printerPostcss = {
51894 print: genericPrint$4,
51896 insertPragma: insertPragma$7,
51897 massageAstNode: clean$8
51900 const commonOptions$4 = commonOptions$6; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
51903 singleQuote: commonOptions$4.singleQuote
51907 // TODO: switch these to just `postcss` and use `language` instead.
51909 return require("./parser-postcss.js").parsers.css;
51913 return require("./parser-postcss.js").parsers.less;
51917 return require("./parser-postcss.js").parsers.scss;
51922 var name$9 = "CSS";
51923 var type$9 = "markup";
51924 var tmScope$9 = "source.css";
51925 var aceMode$9 = "css";
51926 var codemirrorMode$5 = "css";
51927 var codemirrorMimeType$5 = "text/css";
51928 var color$8 = "#563d7c";
51929 var extensions$9 = [
51932 var languageId$9 = 50;
51933 var require$$4$5 = {
51936 tmScope: tmScope$9,
51937 aceMode: aceMode$9,
51938 codemirrorMode: codemirrorMode$5,
51939 codemirrorMimeType: codemirrorMimeType$5,
51941 extensions: extensions$9,
51942 languageId: languageId$9
51945 var name$8 = "PostCSS";
51946 var type$8 = "markup";
51947 var tmScope$8 = "source.postcss";
51948 var group$a = "CSS";
51949 var extensions$8 = [
51953 var aceMode$8 = "text";
51954 var languageId$8 = 262764437;
51955 var require$$5$1 = {
51958 tmScope: tmScope$8,
51960 extensions: extensions$8,
51961 aceMode: aceMode$8,
51962 languageId: languageId$8
51965 var name$7 = "Less";
51966 var type$7 = "markup";
51967 var color$7 = "#1d365d";
51968 var extensions$7 = [
51971 var tmScope$7 = "source.css.less";
51972 var aceMode$7 = "less";
51973 var codemirrorMode$4 = "css";
51974 var codemirrorMimeType$4 = "text/css";
51975 var languageId$7 = 198;
51980 extensions: extensions$7,
51981 tmScope: tmScope$7,
51982 aceMode: aceMode$7,
51983 codemirrorMode: codemirrorMode$4,
51984 codemirrorMimeType: codemirrorMimeType$4,
51985 languageId: languageId$7
51988 var name$6 = "SCSS";
51989 var type$6 = "markup";
51990 var color$6 = "#c6538c";
51991 var tmScope$6 = "source.css.scss";
51992 var aceMode$6 = "scss";
51993 var codemirrorMode$3 = "css";
51994 var codemirrorMimeType$3 = "text/x-scss";
51995 var extensions$6 = [
51998 var languageId$6 = 329;
52003 tmScope: tmScope$6,
52004 aceMode: aceMode$6,
52005 codemirrorMode: codemirrorMode$3,
52006 codemirrorMimeType: codemirrorMimeType$3,
52007 extensions: extensions$6,
52008 languageId: languageId$6
52011 const createLanguage$5 = createLanguage$7;
52012 const printer$5 = printerPostcss;
52013 const options$8 = options$9;
52014 const parsers$a = parsers$b;
52015 const languages$6 = [createLanguage$5(require$$4$5, data => ({
52018 vscodeLanguageIds: ["css"],
52019 extensions: [...data.extensions, // `WeiXin Style Sheets`(Weixin Mini Programs)
52020 // https://developers.weixin.qq.com/miniprogram/en/dev/framework/view/wxs/
52022 })), createLanguage$5(require$$5$1, () => ({
52025 vscodeLanguageIds: ["postcss"]
52026 })), createLanguage$5(require$$6, () => ({
52029 vscodeLanguageIds: ["less"]
52030 })), createLanguage$5(require$$7, () => ({
52033 vscodeLanguageIds: ["scss"]
52035 const printers$4 = {
52038 var languageCss = {
52039 languages: languages$6,
52040 options: options$8,
52041 printers: printers$4,
52045 function locStart$c(node) {
52046 return node.loc.start.offset;
52049 function locEnd$b(node) {
52050 return node.loc.end.offset;
52054 locStart: locStart$c,
52058 function clean$7(ast, newNode
52061 // (Glimmer/HTML) ignore TextNode
52062 if (ast.type === "TextNode") {
52063 const trimmed = ast.chars.trim();
52069 newNode.chars = trimmed.replace(/[\t\n\f\r ]+/g, " ");
52070 } // `class` is reformatted
52073 if (ast.type === "AttrNode" && ast.name.toLowerCase() === "class") {
52074 delete newNode.value;
52078 clean$7.ignoredProperties = new Set(["loc", "selfClosing"]);
52079 var clean_1$2 = clean$7;
52081 var require$$0$1 = [
52107 const htmlVoidElements = require$$0$1;
52108 const getLast$6 = getLast_1;
52110 function isLastNodeOfSiblings$1(path) {
52111 const node = path.getValue();
52112 const parentNode = path.getParentNode(0);
52114 if (isParentOfSomeType$1(path, ["ElementNode"]) && getLast$6(parentNode.children) === node) {
52118 if (isParentOfSomeType$1(path, ["Block"]) && getLast$6(parentNode.body) === node) {
52125 function isUppercase(string) {
52126 return string.toUpperCase() === string;
52129 function isGlimmerComponent(node) {
52130 return isNodeOfSomeType$1(node, ["ElementNode"]) && typeof node.tag === "string" && (isUppercase(node.tag[0]) || node.tag.includes("."));
52133 const voidTags = new Set(htmlVoidElements);
52135 function isVoid$1(node) {
52136 return isGlimmerComponent(node) && node.children.every(node => isWhitespaceNode$1(node)) || voidTags.has(node.tag);
52139 function isWhitespaceNode$1(node) {
52140 return isNodeOfSomeType$1(node, ["TextNode"]) && !/\S/.test(node.chars);
52143 function isNodeOfSomeType$1(node, types) {
52144 return node && types.includes(node.type);
52147 function isParentOfSomeType$1(path, types) {
52148 const parentNode = path.getParentNode(0);
52149 return isNodeOfSomeType$1(parentNode, types);
52152 function isPreviousNodeOfSomeType$1(path, types) {
52153 const previousNode = getPreviousNode$1(path);
52154 return isNodeOfSomeType$1(previousNode, types);
52157 function isNextNodeOfSomeType$1(path, types) {
52158 const nextNode = getNextNode$1(path);
52159 return isNodeOfSomeType$1(nextNode, types);
52162 function getSiblingNode(path, offset) {
52163 const node = path.getValue();
52164 const parentNode = path.getParentNode(0) || {};
52165 const children = parentNode.children || parentNode.body || parentNode.parts || [];
52166 const index = children.indexOf(node);
52167 return index !== -1 && children[index + offset];
52170 function getPreviousNode$1(path, lookBack = 1) {
52171 return getSiblingNode(path, -lookBack);
52174 function getNextNode$1(path) {
52175 return getSiblingNode(path, 1);
52178 function isPrettierIgnoreNode(node) {
52179 return isNodeOfSomeType$1(node, ["MustacheCommentStatement"]) && typeof node.value === "string" && node.value.trim() === "prettier-ignore";
52182 function hasPrettierIgnore$8(path) {
52183 const node = path.getValue();
52184 const previousPreviousNode = getPreviousNode$1(path, 2);
52185 return isPrettierIgnoreNode(node) || isPrettierIgnoreNode(previousPreviousNode);
52189 getNextNode: getNextNode$1,
52190 getPreviousNode: getPreviousNode$1,
52191 hasPrettierIgnore: hasPrettierIgnore$8,
52192 isLastNodeOfSiblings: isLastNodeOfSiblings$1,
52193 isNextNodeOfSomeType: isNextNodeOfSomeType$1,
52194 isNodeOfSomeType: isNodeOfSomeType$1,
52195 isParentOfSomeType: isParentOfSomeType$1,
52196 isPreviousNodeOfSomeType: isPreviousNodeOfSomeType$1,
52198 isWhitespaceNode: isWhitespaceNode$1
52206 hardline: hardline$b,
52207 ifBreak: ifBreak$7,
52211 softline: softline$8
52214 getDocParts: getDocParts$4,
52215 replaceTextEndOfLine: replaceTextEndOfLine$8
52220 isNonEmptyArray: isNonEmptyArray$4
52223 locStart: locStart$b,
52226 const clean$6 = clean_1$2;
52230 hasPrettierIgnore: hasPrettierIgnore$7,
52231 isLastNodeOfSiblings,
52232 isNextNodeOfSomeType,
52234 isParentOfSomeType,
52235 isPreviousNodeOfSomeType,
52239 const NEWLINES_TO_PRESERVE_MAX = 2; // Formatter based on @glimmerjs/syntax's built-in test formatter:
52240 // https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/generation/print.ts
52242 function print(path, options, print) {
52243 const node = path.getValue();
52244 /* istanbul ignore if*/
52250 if (hasPrettierIgnore$7(path)) {
52251 return options.originalText.slice(locStart$b(node), locEnd$a(node));
52254 const favoriteQuote = options.singleQuote ? "'" : '"';
52256 switch (node.type) {
52261 return group$9(path.map(print, "body"));
52264 case "ElementNode":
52266 const startingTag = group$9(printStartingTag(path, print));
52267 const escapeNextElementNode = options.htmlWhitespaceSensitivity === "ignore" && isNextNodeOfSomeType(path, ["ElementNode"]) ? softline$8 : "";
52269 if (isVoid(node)) {
52270 return [startingTag, escapeNextElementNode];
52273 const endingTag = ["</", node.tag, ">"];
52275 if (node.children.length === 0) {
52276 return [startingTag, indent$5(endingTag), escapeNextElementNode];
52279 if (options.htmlWhitespaceSensitivity === "ignore") {
52280 return [startingTag, indent$5(printChildren$5(path, options, print)), hardline$b, indent$5(endingTag), escapeNextElementNode];
52283 return [startingTag, indent$5(group$9(printChildren$5(path, options, print))), indent$5(endingTag), escapeNextElementNode];
52286 case "BlockStatement":
52288 const pp = path.getParentNode(1);
52289 const isElseIf = pp && pp.inverse && pp.inverse.body.length === 1 && pp.inverse.body[0] === node && pp.inverse.body[0].path.parts[0] === "if";
52292 return [printElseIfBlock(path, print), printProgram(path, print, options), printInverse(path, print, options)];
52295 return [printOpenBlock(path, print), group$9([printProgram(path, print, options), printInverse(path, print, options), printCloseBlock(path, print, options)])];
52298 case "ElementModifierStatement":
52300 return group$9(["{{", printPathAndParams(path, print), "}}"]);
52303 case "MustacheStatement":
52305 return group$9([printOpeningMustache(node), printPathAndParams(path, print), printClosingMustache(node)]);
52308 case "SubExpression":
52310 return group$9(["(", printSubExpressionPathAndParams(path, print), softline$8, ")"]);
52315 const isText = node.value.type === "TextNode";
52316 const isEmptyText = isText && node.value.chars === ""; // If the text is empty and the value's loc start and end offsets are the
52317 // same, there is no value for this AttrNode and it should be printed
52318 // without the `=""`. Example: `<img data-test>` -> `<img data-test>`
52320 if (isEmptyText && locStart$b(node.value) === locEnd$a(node.value)) {
52322 } // Let's assume quotes inside the content of text nodes are already
52323 // properly escaped with entities, otherwise the parse wouldn't have parsed them.
52326 const quote = isText ? getPreferredQuote(node.value.chars, favoriteQuote).quote : node.value.type === "ConcatStatement" ? getPreferredQuote(node.value.parts.filter(part => part.type === "TextNode").map(part => part.chars).join(""), favoriteQuote).quote : "";
52327 const valueDoc = print("value");
52328 return [node.name, "=", quote, node.name === "class" && quote ? group$9(indent$5(valueDoc)) : valueDoc, quote];
52331 case "ConcatStatement":
52333 return path.map(print, "parts");
52338 return join$9(line$c, path.map(print, "pairs"));
52343 return [node.key, "=", print("value")];
52348 /* if `{{my-component}}` (or any text containing "{{")
52349 * makes it to the TextNode, it means it was escaped,
52350 * so let's print it escaped, ie.; `\{{my-component}}` */
52351 let text = node.chars.replace(/{{/g, "\\{{");
52352 const attrName = getCurrentAttributeName(path);
52355 // TODO: format style and srcset attributes
52356 if (attrName === "class") {
52357 const formattedClasses = text.trim().split(/\s+/).join(" ");
52358 let leadingSpace = false;
52359 let trailingSpace = false;
52361 if (isParentOfSomeType(path, ["ConcatStatement"])) {
52362 if (isPreviousNodeOfSomeType(path, ["MustacheStatement"]) && /^\s/.test(text)) {
52363 leadingSpace = true;
52366 if (isNextNodeOfSomeType(path, ["MustacheStatement"]) && /\s$/.test(text) && formattedClasses !== "") {
52367 trailingSpace = true;
52371 return [leadingSpace ? line$c : "", formattedClasses, trailingSpace ? line$c : ""];
52374 return replaceTextEndOfLine$8(text);
52377 const whitespacesOnlyRE = /^[\t\n\f\r ]*$/;
52378 const isWhitespaceOnly = whitespacesOnlyRE.test(text);
52379 const isFirstElement = !getPreviousNode(path);
52380 const isLastElement = !getNextNode(path);
52382 if (options.htmlWhitespaceSensitivity !== "ignore") {
52383 // https://infra.spec.whatwg.org/#ascii-whitespace
52384 const leadingWhitespacesRE = /^[\t\n\f\r ]*/;
52385 const trailingWhitespacesRE = /[\t\n\f\r ]*$/; // let's remove the file's final newline
52386 // https://github.com/ember-cli/ember-new-output/blob/1a04c67ddd02ccb35e0ff41bb5cbce34b31173ef/.editorconfig#L16
52388 const shouldTrimTrailingNewlines = isLastElement && isParentOfSomeType(path, ["Template"]);
52389 const shouldTrimLeadingNewlines = isFirstElement && isParentOfSomeType(path, ["Template"]);
52391 if (isWhitespaceOnly) {
52392 if (shouldTrimLeadingNewlines || shouldTrimTrailingNewlines) {
52396 let breaks = [line$c];
52397 const newlines = countNewLines(text);
52400 breaks = generateHardlines(newlines);
52403 if (isLastNodeOfSiblings(path)) {
52404 breaks = breaks.map(newline => dedent$1(newline));
52410 const [lead] = text.match(leadingWhitespacesRE);
52411 const [tail] = text.match(trailingWhitespacesRE);
52412 let leadBreaks = [];
52415 leadBreaks = [line$c];
52416 const leadingNewlines = countNewLines(lead);
52418 if (leadingNewlines) {
52419 leadBreaks = generateHardlines(leadingNewlines);
52422 text = text.replace(leadingWhitespacesRE, "");
52425 let trailBreaks = [];
52428 if (!shouldTrimTrailingNewlines) {
52429 trailBreaks = [line$c];
52430 const trailingNewlines = countNewLines(tail);
52432 if (trailingNewlines) {
52433 trailBreaks = generateHardlines(trailingNewlines);
52436 if (isLastNodeOfSiblings(path)) {
52437 trailBreaks = trailBreaks.map(hardline => dedent$1(hardline));
52441 text = text.replace(trailingWhitespacesRE, "");
52444 return [...leadBreaks, fill$5(getTextValueParts$3(text)), ...trailBreaks];
52447 const lineBreaksCount = countNewLines(text);
52448 let leadingLineBreaksCount = countLeadingNewLines(text);
52449 let trailingLineBreaksCount = countTrailingNewLines(text);
52451 if ((isFirstElement || isLastElement) && isWhitespaceOnly && isParentOfSomeType(path, ["Block", "ElementNode", "Template"])) {
52455 if (isWhitespaceOnly && lineBreaksCount) {
52456 leadingLineBreaksCount = Math.min(lineBreaksCount, NEWLINES_TO_PRESERVE_MAX);
52457 trailingLineBreaksCount = 0;
52459 if (isNextNodeOfSomeType(path, ["BlockStatement", "ElementNode"])) {
52460 trailingLineBreaksCount = Math.max(trailingLineBreaksCount, 1);
52463 if (isPreviousNodeOfSomeType(path, ["BlockStatement", "ElementNode"])) {
52464 leadingLineBreaksCount = Math.max(leadingLineBreaksCount, 1);
52468 let leadingSpace = "";
52469 let trailingSpace = "";
52471 if (trailingLineBreaksCount === 0 && isNextNodeOfSomeType(path, ["MustacheStatement"])) {
52472 trailingSpace = " ";
52475 if (leadingLineBreaksCount === 0 && isPreviousNodeOfSomeType(path, ["MustacheStatement"])) {
52476 leadingSpace = " ";
52479 if (isFirstElement) {
52480 leadingLineBreaksCount = 0;
52484 if (isLastElement) {
52485 trailingLineBreaksCount = 0;
52486 trailingSpace = "";
52489 text = text.replace(/^[\t\n\f\r ]+/g, leadingSpace).replace(/[\t\n\f\r ]+$/, trailingSpace);
52490 return [...generateHardlines(leadingLineBreaksCount), fill$5(getTextValueParts$3(text)), ...generateHardlines(trailingLineBreaksCount)];
52493 case "MustacheCommentStatement":
52495 const start = locStart$b(node);
52496 const end = locEnd$a(node); // Starts with `{{~`
52498 const isLeftWhiteSpaceSensitive = options.originalText.charAt(start + 2) === "~"; // Ends with `{{~`
52500 const isRightWhitespaceSensitive = options.originalText.charAt(end - 3) === "~";
52501 const dashes = node.value.includes("}}") ? "--" : "";
52502 return ["{{", isLeftWhiteSpaceSensitive ? "~" : "", "!", dashes, node.value, dashes, isRightWhitespaceSensitive ? "~" : "", "}}"];
52505 case "PathExpression":
52507 return node.original;
52510 case "BooleanLiteral":
52512 return String(node.value);
52515 case "CommentStatement":
52517 return ["<!--", node.value, "-->"];
52520 case "StringLiteral":
52522 if (needsOppositeQuote(path)) {
52523 const printFavoriteQuote = !options.singleQuote ? "'" : '"';
52524 return printStringLiteral(node.value, printFavoriteQuote);
52527 return printStringLiteral(node.value, favoriteQuote);
52530 case "NumberLiteral":
52532 return String(node.value);
52535 case "UndefinedLiteral":
52537 return "undefined";
52540 case "NullLiteral":
52545 /* istanbul ignore next */
52548 throw new Error("unknown glimmer type: " + JSON.stringify(node.type));
52551 /* ElementNode print helpers */
52554 function sortByLoc(a, b) {
52555 return locStart$b(a) - locStart$b(b);
52558 function printStartingTag(path, print) {
52559 const node = path.getValue();
52560 const types = ["attributes", "modifiers", "comments"].filter(property => isNonEmptyArray$4(node[property]));
52561 const attributes = types.flatMap(type => node[type]).sort(sortByLoc);
52563 for (const attributeType of types) {
52564 path.each(attributePath => {
52565 const index = attributes.indexOf(attributePath.getValue());
52566 attributes.splice(index, 1, [line$c, print()]);
52570 if (isNonEmptyArray$4(node.blockParams)) {
52571 attributes.push(line$c, printBlockParams(node));
52574 return ["<", node.tag, indent$5(attributes), printStartingTagEndMarker(node)];
52577 function printChildren$5(path, options, print) {
52578 const node = path.getValue();
52579 const isEmpty = node.children.every(node => isWhitespaceNode(node));
52581 if (options.htmlWhitespaceSensitivity === "ignore" && isEmpty) {
52585 return path.map((childPath, childIndex) => {
52586 const printedChild = print();
52588 if (childIndex === 0 && options.htmlWhitespaceSensitivity === "ignore") {
52589 return [softline$8, printedChild];
52592 return printedChild;
52596 function printStartingTagEndMarker(node) {
52597 if (isVoid(node)) {
52598 return ifBreak$7([softline$8, "/>"], [" />", softline$8]);
52601 return ifBreak$7([softline$8, ">"], ">");
52603 /* MustacheStatement print helpers */
52606 function printOpeningMustache(node) {
52607 const mustache = node.escaped === false ? "{{{" : "{{";
52608 const strip = node.strip && node.strip.open ? "~" : "";
52609 return [mustache, strip];
52612 function printClosingMustache(node) {
52613 const mustache = node.escaped === false ? "}}}" : "}}";
52614 const strip = node.strip && node.strip.close ? "~" : "";
52615 return [strip, mustache];
52617 /* BlockStatement print helpers */
52620 function printOpeningBlockOpeningMustache(node) {
52621 const opening = printOpeningMustache(node);
52622 const strip = node.openStrip.open ? "~" : "";
52623 return [opening, strip, "#"];
52626 function printOpeningBlockClosingMustache(node) {
52627 const closing = printClosingMustache(node);
52628 const strip = node.openStrip.close ? "~" : "";
52629 return [strip, closing];
52632 function printClosingBlockOpeningMustache(node) {
52633 const opening = printOpeningMustache(node);
52634 const strip = node.closeStrip.open ? "~" : "";
52635 return [opening, strip, "/"];
52638 function printClosingBlockClosingMustache(node) {
52639 const closing = printClosingMustache(node);
52640 const strip = node.closeStrip.close ? "~" : "";
52641 return [strip, closing];
52644 function printInverseBlockOpeningMustache(node) {
52645 const opening = printOpeningMustache(node);
52646 const strip = node.inverseStrip.open ? "~" : "";
52647 return [opening, strip];
52650 function printInverseBlockClosingMustache(node) {
52651 const closing = printClosingMustache(node);
52652 const strip = node.inverseStrip.close ? "~" : "";
52653 return [strip, closing];
52656 function printOpenBlock(path, print) {
52657 const node = path.getValue();
52658 const openingMustache = printOpeningBlockOpeningMustache(node);
52659 const closingMustache = printOpeningBlockClosingMustache(node);
52660 const attributes = [printPath(path, print)];
52661 const params = printParams(path, print);
52664 attributes.push(line$c, params);
52667 if (isNonEmptyArray$4(node.program.blockParams)) {
52668 const block = printBlockParams(node.program);
52669 attributes.push(line$c, block);
52672 return group$9([openingMustache, indent$5(attributes), softline$8, closingMustache]);
52675 function printElseBlock(node, options) {
52676 return [options.htmlWhitespaceSensitivity === "ignore" ? hardline$b : "", printInverseBlockOpeningMustache(node), "else", printInverseBlockClosingMustache(node)];
52679 function printElseIfBlock(path, print) {
52680 const parentNode = path.getParentNode(1);
52681 return [printInverseBlockOpeningMustache(parentNode), "else if ", printParams(path, print), printInverseBlockClosingMustache(parentNode)];
52684 function printCloseBlock(path, print, options) {
52685 const node = path.getValue();
52687 if (options.htmlWhitespaceSensitivity === "ignore") {
52688 const escape = blockStatementHasOnlyWhitespaceInProgram(node) ? softline$8 : hardline$b;
52689 return [escape, printClosingBlockOpeningMustache(node), print("path"), printClosingBlockClosingMustache(node)];
52692 return [printClosingBlockOpeningMustache(node), print("path"), printClosingBlockClosingMustache(node)];
52695 function blockStatementHasOnlyWhitespaceInProgram(node) {
52696 return isNodeOfSomeType(node, ["BlockStatement"]) && node.program.body.every(node => isWhitespaceNode(node));
52699 function blockStatementHasElseIf(node) {
52700 return blockStatementHasElse(node) && node.inverse.body.length === 1 && isNodeOfSomeType(node.inverse.body[0], ["BlockStatement"]) && node.inverse.body[0].path.parts[0] === "if";
52703 function blockStatementHasElse(node) {
52704 return isNodeOfSomeType(node, ["BlockStatement"]) && node.inverse;
52707 function printProgram(path, print, options) {
52708 const node = path.getValue();
52710 if (blockStatementHasOnlyWhitespaceInProgram(node)) {
52714 const program = print("program");
52716 if (options.htmlWhitespaceSensitivity === "ignore") {
52717 return indent$5([hardline$b, program]);
52720 return indent$5(program);
52723 function printInverse(path, print, options) {
52724 const node = path.getValue();
52725 const inverse = print("inverse");
52726 const printed = options.htmlWhitespaceSensitivity === "ignore" ? [hardline$b, inverse] : inverse;
52728 if (blockStatementHasElseIf(node)) {
52732 if (blockStatementHasElse(node)) {
52733 return [printElseBlock(node, options), indent$5(printed)];
52738 /* TextNode print helpers */
52741 function getTextValueParts$3(value) {
52742 return getDocParts$4(join$9(line$c, splitByHtmlWhitespace$1(value)));
52745 function splitByHtmlWhitespace$1(string) {
52746 return string.split(/[\t\n\f\r ]+/);
52749 function getCurrentAttributeName(path) {
52750 for (let depth = 0; depth < 2; depth++) {
52751 const parentNode = path.getParentNode(depth);
52753 if (parentNode && parentNode.type === "AttrNode") {
52754 return parentNode.name.toLowerCase();
52759 function countNewLines(string) {
52760 /* istanbul ignore next */
52761 string = typeof string === "string" ? string : "";
52762 return string.split("\n").length - 1;
52765 function countLeadingNewLines(string) {
52766 /* istanbul ignore next */
52767 string = typeof string === "string" ? string : "";
52768 const newLines = (string.match(/^([^\S\n\r]*[\n\r])+/g) || [])[0] || "";
52769 return countNewLines(newLines);
52772 function countTrailingNewLines(string) {
52773 /* istanbul ignore next */
52774 string = typeof string === "string" ? string : "";
52775 const newLines = (string.match(/([\n\r][^\S\n\r]*)+$/g) || [])[0] || "";
52776 return countNewLines(newLines);
52779 function generateHardlines(number = 0) {
52780 return Array.from({
52781 length: Math.min(number, NEWLINES_TO_PRESERVE_MAX)
52782 }).fill(hardline$b);
52784 /* StringLiteral print helpers */
52786 /** @typedef {import("../common/util").Quote} Quote */
52789 * Prints a string literal with the correct surrounding quotes based on
52790 * `options.singleQuote` and the number of escaped quotes contained in
52791 * the string literal. This function is the glimmer equivalent of `printString`
52792 * in `common/util`, but has differences because of the way escaped characters
52793 * are treated in hbs string literals.
52794 * @param {string} stringLiteral - the string literal value
52795 * @param {Quote} favoriteQuote - the user's preferred quote: `'` or `"`
52799 function printStringLiteral(stringLiteral, favoriteQuote) {
52803 } = getPreferredQuote(stringLiteral, favoriteQuote);
52804 return [quote, stringLiteral.replace(regex, `\\${quote}`), quote];
52807 function needsOppositeQuote(path) {
52809 let parentNode = path.getParentNode(index);
52811 while (parentNode && isNodeOfSomeType(parentNode, ["SubExpression"])) {
52813 parentNode = path.getParentNode(index);
52816 if (parentNode && isNodeOfSomeType(path.getParentNode(index + 1), ["ConcatStatement"]) && isNodeOfSomeType(path.getParentNode(index + 2), ["AttrNode"])) {
52822 /* SubExpression print helpers */
52825 function printSubExpressionPathAndParams(path, print) {
52826 const p = printPath(path, print);
52827 const params = printParams(path, print);
52833 return indent$5([p, line$c, group$9(params)]);
52835 /* misc. print helpers */
52838 function printPathAndParams(path, print) {
52839 const p = printPath(path, print);
52840 const params = printParams(path, print);
52846 return [indent$5([p, line$c, params]), softline$8];
52849 function printPath(path, print) {
52850 return print("path");
52853 function printParams(path, print) {
52854 const node = path.getValue();
52857 if (node.params.length > 0) {
52858 const params = path.map(print, "params");
52859 parts.push(...params);
52862 if (node.hash && node.hash.pairs.length > 0) {
52863 const hash = print("hash");
52867 if (parts.length === 0) {
52871 return join$9(line$c, parts);
52874 function printBlockParams(node) {
52875 return ["as |", node.blockParams.join(" "), "|"];
52878 var printerGlimmer = {
52880 massageAstNode: clean$6
52885 return require("./parser-glimmer.js").parsers.glimmer;
52890 var name$5 = "Handlebars";
52891 var type$5 = "markup";
52892 var color$5 = "#f7931e";
52897 var extensions$5 = [
52901 var tmScope$5 = "text.html.handlebars";
52902 var aceMode$5 = "handlebars";
52903 var languageId$5 = 155;
52908 aliases: aliases$3,
52909 extensions: extensions$5,
52910 tmScope: tmScope$5,
52911 aceMode: aceMode$5,
52912 languageId: languageId$5
52915 const createLanguage$4 = createLanguage$7;
52916 const printer$4 = printerGlimmer;
52917 const parsers$8 = parsers$9;
52918 const languages$5 = [createLanguage$4(require$$3, () => ({
52920 parsers: ["glimmer"],
52921 vscodeLanguageIds: ["handlebars"]
52923 const printers$3 = {
52926 var languageHandlebars = {
52927 languages: languages$5,
52928 printers: printers$3,
52932 function hasPragma$2(text) {
52933 return /^\s*#[^\S\n]*@(?:format|prettier)\s*(?:\n|$)/.test(text);
52936 function insertPragma$6(text) {
52937 return "# @format\n\n" + text;
52941 hasPragma: hasPragma$2,
52942 insertPragma: insertPragma$6
52945 function locStart$a(node) {
52946 if (typeof node.start === "number") {
52950 return node.loc && node.loc.start;
52953 function locEnd$9(node) {
52954 if (typeof node.end === "number") {
52958 return node.loc && node.loc.end;
52962 locStart: locStart$a,
52969 hardline: hardline$a,
52971 softline: softline$7,
52978 isNextLineEmpty: isNextLineEmpty$2,
52979 isNonEmptyArray: isNonEmptyArray$3
52982 insertPragma: insertPragma$5
52985 locStart: locStart$9,
52989 function genericPrint$3(path, options, print) {
52990 const node = path.getValue();
52996 if (typeof node === "string") {
53000 switch (node.kind) {
53004 path.each((pathChild, index, definitions) => {
53005 parts.push(print());
53007 if (index !== definitions.length - 1) {
53008 parts.push(hardline$a);
53010 if (isNextLineEmpty$2(options.originalText, pathChild.getValue(), locEnd$8)) {
53011 parts.push(hardline$a);
53015 return [...parts, hardline$a];
53018 case "OperationDefinition":
53020 const hasOperation = options.originalText[locStart$9(node)] !== "{";
53021 const hasName = Boolean(node.name);
53022 return [hasOperation ? node.operation : "", hasOperation && hasName ? [" ", print("name")] : "", hasOperation && !hasName && isNonEmptyArray$3(node.variableDefinitions) ? " " : "", isNonEmptyArray$3(node.variableDefinitions) ? group$8(["(", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.map(print, "variableDefinitions"))]), softline$7, ")"]) : "", printDirectives(path, print, node), node.selectionSet ? !hasOperation && !hasName ? "" : " " : "", print("selectionSet")];
53025 case "FragmentDefinition":
53027 return ["fragment ", print("name"), isNonEmptyArray$3(node.variableDefinitions) ? group$8(["(", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.map(print, "variableDefinitions"))]), softline$7, ")"]) : "", " on ", print("typeCondition"), printDirectives(path, print, node), " ", print("selectionSet")];
53030 case "SelectionSet":
53032 return ["{", indent$4([hardline$a, join$8(hardline$a, path.call(selectionsPath => printSequence(selectionsPath, options, print), "selections"))]), hardline$a, "}"];
53037 return group$8([node.alias ? [print("alias"), ": "] : "", print("name"), node.arguments.length > 0 ? group$8(["(", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.call(argsPath => printSequence(argsPath, options, print), "arguments"))]), softline$7, ")"]) : "", printDirectives(path, print, node), node.selectionSet ? " " : "", print("selectionSet")]);
53045 case "StringValue":
53048 return ['"""', hardline$a, join$8(hardline$a, node.value.replace(/"""/g, "\\$&").split("\n")), hardline$a, '"""'];
53051 return ['"', node.value.replace(/["\\]/g, "\\$&").replace(/\n/g, "\\n"), '"'];
53061 case "BooleanValue":
53063 return node.value ? "true" : "false";
53073 return ["$", print("name")];
53078 return group$8(["[", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.map(print, "values"))]), softline$7, "]"]);
53081 case "ObjectValue":
53083 return group$8(["{", options.bracketSpacing && node.fields.length > 0 ? " " : "", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.map(print, "fields"))]), softline$7, ifBreak$6("", options.bracketSpacing && node.fields.length > 0 ? " " : ""), "}"]);
53086 case "ObjectField":
53089 return [print("name"), ": ", print("value")];
53094 return ["@", print("name"), node.arguments.length > 0 ? group$8(["(", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.call(argsPath => printSequence(argsPath, options, print), "arguments"))]), softline$7, ")"]) : ""];
53099 return print("name");
53102 case "VariableDefinition":
53104 return [print("variable"), ": ", print("type"), node.defaultValue ? [" = ", print("defaultValue")] : "", printDirectives(path, print, node)];
53107 case "ObjectTypeExtension":
53108 case "ObjectTypeDefinition":
53110 return [print("description"), node.description ? hardline$a : "", node.kind === "ObjectTypeExtension" ? "extend " : "", "type ", print("name"), node.interfaces.length > 0 ? [" implements ", ...printInterfaces(path, options, print)] : "", printDirectives(path, print, node), node.fields.length > 0 ? [" {", indent$4([hardline$a, join$8(hardline$a, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))]), hardline$a, "}"] : ""];
53113 case "FieldDefinition":
53115 return [print("description"), node.description ? hardline$a : "", print("name"), node.arguments.length > 0 ? group$8(["(", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.call(argsPath => printSequence(argsPath, options, print), "arguments"))]), softline$7, ")"]) : "", ": ", print("type"), printDirectives(path, print, node)];
53118 case "DirectiveDefinition":
53120 return [print("description"), node.description ? hardline$a : "", "directive ", "@", print("name"), node.arguments.length > 0 ? group$8(["(", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.call(argsPath => printSequence(argsPath, options, print), "arguments"))]), softline$7, ")"]) : "", node.repeatable ? " repeatable" : "", " on ", join$8(" | ", path.map(print, "locations"))];
53123 case "EnumTypeExtension":
53124 case "EnumTypeDefinition":
53126 return [print("description"), node.description ? hardline$a : "", node.kind === "EnumTypeExtension" ? "extend " : "", "enum ", print("name"), printDirectives(path, print, node), node.values.length > 0 ? [" {", indent$4([hardline$a, join$8(hardline$a, path.call(valuesPath => printSequence(valuesPath, options, print), "values"))]), hardline$a, "}"] : ""];
53129 case "EnumValueDefinition":
53131 return [print("description"), node.description ? hardline$a : "", print("name"), printDirectives(path, print, node)];
53134 case "InputValueDefinition":
53136 return [print("description"), node.description ? node.description.block ? hardline$a : line$b : "", print("name"), ": ", print("type"), node.defaultValue ? [" = ", print("defaultValue")] : "", printDirectives(path, print, node)];
53139 case "InputObjectTypeExtension":
53140 case "InputObjectTypeDefinition":
53142 return [print("description"), node.description ? hardline$a : "", node.kind === "InputObjectTypeExtension" ? "extend " : "", "input ", print("name"), printDirectives(path, print, node), node.fields.length > 0 ? [" {", indent$4([hardline$a, join$8(hardline$a, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))]), hardline$a, "}"] : ""];
53145 case "SchemaDefinition":
53147 return ["schema", printDirectives(path, print, node), " {", node.operationTypes.length > 0 ? indent$4([hardline$a, join$8(hardline$a, path.call(opsPath => printSequence(opsPath, options, print), "operationTypes"))]) : "", hardline$a, "}"];
53150 case "OperationTypeDefinition":
53152 return [print("operation"), ": ", print("type")];
53155 case "InterfaceTypeExtension":
53156 case "InterfaceTypeDefinition":
53158 return [print("description"), node.description ? hardline$a : "", node.kind === "InterfaceTypeExtension" ? "extend " : "", "interface ", print("name"), node.interfaces.length > 0 ? [" implements ", ...printInterfaces(path, options, print)] : "", printDirectives(path, print, node), node.fields.length > 0 ? [" {", indent$4([hardline$a, join$8(hardline$a, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))]), hardline$a, "}"] : ""];
53161 case "FragmentSpread":
53163 return ["...", print("name"), printDirectives(path, print, node)];
53166 case "InlineFragment":
53168 return ["...", node.typeCondition ? [" on ", print("typeCondition")] : "", printDirectives(path, print, node), " ", print("selectionSet")];
53171 case "UnionTypeExtension":
53172 case "UnionTypeDefinition":
53174 return group$8([print("description"), node.description ? hardline$a : "", group$8([node.kind === "UnionTypeExtension" ? "extend " : "", "union ", print("name"), printDirectives(path, print, node), node.types.length > 0 ? [" =", ifBreak$6("", " "), indent$4([ifBreak$6([line$b, " "]), join$8([line$b, "| "], path.map(print, "types"))])] : ""])]);
53177 case "ScalarTypeExtension":
53178 case "ScalarTypeDefinition":
53180 return [print("description"), node.description ? hardline$a : "", node.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", print("name"), printDirectives(path, print, node)];
53183 case "NonNullType":
53185 return [print("type"), "!"];
53190 return ["[", print("type"), "]"];
53194 /* istanbul ignore next */
53195 throw new Error("unknown graphql type: " + JSON.stringify(node.kind));
53199 function printDirectives(path, print, node) {
53200 if (node.directives.length === 0) {
53204 const printed = join$8(line$b, path.map(print, "directives"));
53206 if (node.kind === "FragmentDefinition" || node.kind === "OperationDefinition") {
53207 return group$8([line$b, printed]);
53210 return [" ", group$8(indent$4([softline$7, printed]))];
53213 function printSequence(sequencePath, options, print) {
53214 const count = sequencePath.getValue().length;
53215 return sequencePath.map((path, i) => {
53216 const printed = print();
53218 if (isNextLineEmpty$2(options.originalText, path.getValue(), locEnd$8) && i < count - 1) {
53219 return [printed, hardline$a];
53226 function canAttachComment(node) {
53227 return node.kind && node.kind !== "Comment";
53230 function printComment(commentPath) {
53231 const comment = commentPath.getValue();
53233 if (comment.kind === "Comment") {
53234 return "#" + comment.value.trimEnd();
53236 /* istanbul ignore next */
53239 throw new Error("Not a comment: " + JSON.stringify(comment));
53242 function printInterfaces(path, options, print) {
53243 const node = path.getNode();
53248 const printed = path.map(node => print(node), "interfaces");
53250 for (let index = 0; index < interfaces.length; index++) {
53251 const interfaceNode = interfaces[index];
53252 parts.push(printed[index]);
53253 const nextInterfaceNode = interfaces[index + 1];
53255 if (nextInterfaceNode) {
53256 const textBetween = options.originalText.slice(interfaceNode.loc.end, nextInterfaceNode.loc.start);
53257 const hasComment = textBetween.includes("#");
53258 const separator = textBetween.replace(/#.*/g, "").trim();
53259 parts.push(separator === "," ? "," : " &", hasComment ? line$b : " ");
53267 /*node, newNode , parent*/
53270 clean$5.ignoredProperties = new Set(["loc", "comments"]);
53272 function hasPrettierIgnore$6(path) {
53273 const node = path.getValue();
53274 return node && Array.isArray(node.comments) && node.comments.some(comment => comment.value.trim() === "prettier-ignore");
53277 var printerGraphql = {
53278 print: genericPrint$3,
53279 massageAstNode: clean$5,
53280 hasPrettierIgnore: hasPrettierIgnore$6,
53281 insertPragma: insertPragma$5,
53286 const commonOptions$3 = commonOptions$6; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
53289 bracketSpacing: commonOptions$3.bracketSpacing
53294 return require("./parser-graphql.js").parsers.graphql;
53299 var name$4 = "GraphQL";
53300 var type$4 = "data";
53301 var color$4 = "#e10098";
53302 var extensions$4 = [
53307 var tmScope$4 = "source.graphql";
53308 var aceMode$4 = "text";
53309 var languageId$4 = 139;
53310 var require$$4$4 = {
53314 extensions: extensions$4,
53315 tmScope: tmScope$4,
53316 aceMode: aceMode$4,
53317 languageId: languageId$4
53320 const createLanguage$3 = createLanguage$7;
53321 const printer$3 = printerGraphql;
53322 const options$6 = options$7;
53323 const parsers$6 = parsers$7;
53324 const languages$4 = [createLanguage$3(require$$4$4, () => ({
53326 parsers: ["graphql"],
53327 vscodeLanguageIds: ["graphql"]
53329 const printers$2 = {
53332 var languageGraphql = {
53333 languages: languages$4,
53334 options: options$6,
53335 printers: printers$2,
53339 function locStart$8(node) {
53340 return node.position.start.offset;
53343 function locEnd$7(node) {
53344 return node.position.end.offset;
53348 locStart: locStart$8,
53353 "cjkPattern": "(?:[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u2ff0-\\u303f\\u3041-\\u3096\\u3099-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fef\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufe10-\\ufe1f\\ufe30-\\ufe6f\\uff00-\\uffef]|[\\ud840-\\ud868\\ud86a-\\ud86c\\ud86f-\\ud872\\ud874-\\ud879][\\udc00-\\udfff]|\\ud82c[\\udc00-\\udd1e\\udd50-\\udd52\\udd64-\\udd67]|\\ud83c[\\ude00\\ude50-\\ude51]|\\ud869[\\udc00-\\uded6\\udf00-\\udfff]|\\ud86d[\\udc00-\\udf34\\udf40-\\udfff]|\\ud86e[\\udc00-\\udc1d\\udc20-\\udfff]|\\ud873[\\udc00-\\udea1\\udeb0-\\udfff]|\\ud87a[\\udc00-\\udfe0]|\\ud87e[\\udc00-\\ude1d])(?:[\\ufe00-\\ufe0f]|\\udb40[\\udd00-\\uddef])?",
53354 "kPattern": "[\\u1100-\\u11ff\\u3001-\\u3003\\u3008-\\u3011\\u3013-\\u301f\\u302e-\\u3030\\u3037\\u30fb\\u3131-\\u318e\\u3200-\\u321e\\u3260-\\u327e\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\ufe45-\\ufe46\\uff61-\\uff65\\uffa0-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc]",
53355 "punctuationPattern": "[\\u0021-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e\\u00a1\\u00a7\\u00ab\\u00b6-\\u00b7\\u00bb\\u00bf\\u037e\\u0387\\u055a-\\u055f\\u0589-\\u058a\\u05be\\u05c0\\u05c3\\u05c6\\u05f3-\\u05f4\\u0609-\\u060a\\u060c-\\u060d\\u061b\\u061e-\\u061f\\u066a-\\u066d\\u06d4\\u0700-\\u070d\\u07f7-\\u07f9\\u0830-\\u083e\\u085e\\u0964-\\u0965\\u0970\\u09fd\\u0a76\\u0af0\\u0c77\\u0c84\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166e\\u169b-\\u169c\\u16eb-\\u16ed\\u1735-\\u1736\\u17d4-\\u17d6\\u17d8-\\u17da\\u1800-\\u180a\\u1944-\\u1945\\u1a1e-\\u1a1f\\u1aa0-\\u1aa6\\u1aa8-\\u1aad\\u1b5a-\\u1b60\\u1bfc-\\u1bff\\u1c3b-\\u1c3f\\u1c7e-\\u1c7f\\u1cc0-\\u1cc7\\u1cd3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205e\\u207d-\\u207e\\u208d-\\u208e\\u2308-\\u230b\\u2329-\\u232a\\u2768-\\u2775\\u27c5-\\u27c6\\u27e6-\\u27ef\\u2983-\\u2998\\u29d8-\\u29db\\u29fc-\\u29fd\\u2cf9-\\u2cfc\\u2cfe-\\u2cff\\u2d70\\u2e00-\\u2e2e\\u2e30-\\u2e4f\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301f\\u3030\\u303d\\u30a0\\u30fb\\ua4fe-\\ua4ff\\ua60d-\\ua60f\\ua673\\ua67e\\ua6f2-\\ua6f7\\ua874-\\ua877\\ua8ce-\\ua8cf\\ua8f8-\\ua8fa\\ua8fc\\ua92e-\\ua92f\\ua95f\\ua9c1-\\ua9cd\\ua9de-\\ua9df\\uaa5c-\\uaa5f\\uaade-\\uaadf\\uaaf0-\\uaaf1\\uabeb\\ufd3e-\\ufd3f\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe61\\ufe63\\ufe68\\ufe6a-\\ufe6b\\uff01-\\uff03\\uff05-\\uff0a\\uff0c-\\uff0f\\uff1a-\\uff1b\\uff1f-\\uff20\\uff3b-\\uff3d\\uff3f\\uff5b\\uff5d\\uff5f-\\uff65]|\\ud800[\\udd00-\\udd02\\udf9f\\udfd0]|\\ud801[\\udd6f]|\\ud802[\\udc57\\udd1f\\udd3f\\ude50-\\ude58\\ude7f\\udef0-\\udef6\\udf39-\\udf3f\\udf99-\\udf9c]|\\ud803[\\udf55-\\udf59]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc8\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\udc3b\\udde2\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71\\udef7-\\udef8\\udfff]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud81b[\\ude97-\\ude9a\\udfe2]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"
53362 locStart: locStart$7,
53368 punctuationPattern: punctuationPattern$1
53370 const INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "esComment", "strong", "delete", "wikiLink", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
53371 const INLINE_NODE_WRAPPER_TYPES$1 = [...INLINE_NODE_TYPES$1, "tableCell", "paragraph", "heading"];
53372 const kRegex = new RegExp(kPattern);
53373 const punctuationRegex = new RegExp(punctuationPattern$1);
53375 * split text into whitespaces and words
53376 * @param {string} text
53379 function splitText$2(text, options) {
53380 const KIND_NON_CJK = "non-cjk";
53381 const KIND_CJ_LETTER = "cj-letter";
53382 const KIND_K_LETTER = "k-letter";
53383 const KIND_CJK_PUNCTUATION = "cjk-punctuation";
53384 /** @type {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} */
53387 const tokens = (options.proseWrap === "preserve" ? text : text.replace(new RegExp(`(${cjkPattern})\n(${cjkPattern})`, "g"), "$1$2")).split(/([\t\n ]+)/);
53389 for (const [index, token] of tokens.entries()) {
53391 if (index % 2 === 1) {
53393 type: "whitespace",
53394 value: /\n/.test(token) ? "\n" : " "
53397 } // word separated by whitespace
53400 if ((index === 0 || index === tokens.length - 1) && token === "") {
53404 const innerTokens = token.split(new RegExp(`(${cjkPattern})`));
53406 for (const [innerIndex, innerToken] of innerTokens.entries()) {
53407 if ((innerIndex === 0 || innerIndex === innerTokens.length - 1) && innerToken === "") {
53412 if (innerIndex % 2 === 0) {
53413 if (innerToken !== "") {
53417 kind: KIND_NON_CJK,
53418 hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
53419 hasTrailingPunctuation: punctuationRegex.test(getLast$5(innerToken))
53427 appendNode(punctuationRegex.test(innerToken) ? {
53430 kind: KIND_CJK_PUNCTUATION,
53431 hasLeadingPunctuation: true,
53432 hasTrailingPunctuation: true
53436 kind: kRegex.test(innerToken) ? KIND_K_LETTER : KIND_CJ_LETTER,
53437 hasLeadingPunctuation: false,
53438 hasTrailingPunctuation: false
53445 function appendNode(node) {
53446 const lastNode = getLast$5(nodes);
53448 if (lastNode && lastNode.type === "word") {
53449 if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJ_LETTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJ_LETTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunctuation) {
53451 type: "whitespace",
53454 } else if (!isBetween(KIND_NON_CJK, KIND_CJK_PUNCTUATION) && // disallow leading/trailing full-width whitespace
53455 ![lastNode.value, node.value].some(value => /\u3000/.test(value))) {
53457 type: "whitespace",
53465 function isBetween(kind1, kind2) {
53466 return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1;
53471 function getOrderedListItemInfo$1(orderListItem, originalText) {
53472 const [, numberText, marker, leadingSpaces] = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/);
53480 function hasGitDiffFriendlyOrderedList$1(node, options) {
53481 if (!node.ordered) {
53485 if (node.children.length < 2) {
53489 const firstNumber = Number(getOrderedListItemInfo$1(node.children[0], options.originalText).numberText);
53490 const secondNumber = Number(getOrderedListItemInfo$1(node.children[1], options.originalText).numberText);
53492 if (firstNumber === 0 && node.children.length > 2) {
53493 const thirdNumber = Number(getOrderedListItemInfo$1(node.children[2], options.originalText).numberText);
53494 return secondNumber === 1 && thirdNumber === 1;
53497 return secondNumber === 1;
53498 } // The final new line should not include in value
53499 // https://github.com/remarkjs/remark/issues/512
53502 function getFencedCodeBlockValue$2(node, originalText) {
53507 if (node.position.end.offset === originalText.length && value.endsWith("\n") && // Code block has no end mark
53508 originalText.endsWith("\n")) {
53509 return value.slice(0, -1);
53515 function mapAst$1(ast, handler) {
53516 return function preorder(node, index, parentStack) {
53517 const newNode = Object.assign({}, handler(node, index, parentStack));
53519 if (newNode.children) {
53520 newNode.children = newNode.children.map((child, index) => preorder(child, index, [newNode, ...parentStack]));
53527 function isAutolink$1(node) {
53528 if (!node || node.type !== "link" || node.children.length !== 1) {
53532 const child = node.children[0];
53533 return child && locStart$7(node) === locStart$7(child) && locEnd$6(node) === locEnd$6(child);
53538 splitText: splitText$2,
53539 punctuationPattern: punctuationPattern$1,
53540 getFencedCodeBlockValue: getFencedCodeBlockValue$2,
53541 getOrderedListItemInfo: getOrderedListItemInfo$1,
53542 hasGitDiffFriendlyOrderedList: hasGitDiffFriendlyOrderedList$1,
53543 INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
53544 INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1,
53545 isAutolink: isAutolink$1
53549 inferParserByLanguage: inferParserByLanguage$1,
53550 getMaxContinuousCount: getMaxContinuousCount$1
53554 hardline: hardline$9,
53555 markAsRoot: markAsRoot$2
53561 const printFrontMatter$1 = print_1;
53563 getFencedCodeBlockValue: getFencedCodeBlockValue$1
53566 function embed$6(path, print, textToDoc, options) {
53567 const node = path.getValue();
53569 if (node.type === "code" && node.lang !== null) {
53570 const parser = inferParserByLanguage$1(node.lang, options);
53573 const styleUnit = options.__inJsTemplate ? "~" : "`";
53574 const style = styleUnit.repeat(Math.max(3, getMaxContinuousCount$1(node.value, styleUnit) + 1));
53575 const newOptions = {
53579 if (node.lang === "tsx") {
53580 newOptions.filepath = "dummy.tsx";
53583 const doc = textToDoc(getFencedCodeBlockValue$1(node, options.originalText), newOptions, {
53584 stripTrailingHardline: true
53586 return markAsRoot$2([style, node.lang, node.meta ? " " + node.meta : "", hardline$9, replaceEndOfLine(doc), hardline$9, style]);
53590 switch (node.type) {
53591 case "front-matter":
53592 return printFrontMatter$1(node, textToDoc);
53595 case "importExport":
53596 return [textToDoc(node.value, {
53599 stripTrailingHardline: true
53603 return textToDoc(`<$>${node.value}</$>`, {
53604 parser: "__js_expression",
53607 stripTrailingHardline: true
53614 var embed_1$2 = embed$6;
53616 const parseFrontMatter = parse_1;
53617 const pragmas = ["format", "prettier"];
53619 function startWithPragma$1(text) {
53620 const pragma = `@(${pragmas.join("|")})`;
53621 const regex = new RegExp([`<!--\\s*${pragma}\\s*-->`, `{\\s*\\/\\*\\s*${pragma}\\s*\\*\\/\\s*}`, `<!--.*\r?\n[\\s\\S]*(^|\n)[^\\S\n]*${pragma}[^\\S\n]*($|\n)[\\s\\S]*\n.*-->`].join("|"), "m");
53622 const matched = text.match(regex);
53623 return matched && matched.index === 0;
53627 startWithPragma: startWithPragma$1,
53628 hasPragma: text => startWithPragma$1(parseFrontMatter(text).content.trimStart()),
53629 insertPragma: text => {
53630 const extracted = parseFrontMatter(text);
53631 const pragma = `<!-- @${pragmas[0]} -->`;
53632 return extracted.frontMatter ? `${extracted.frontMatter.raw}\n\n${pragma}\n\n${extracted.content}` : `${pragma}\n\n${extracted.content}`;
53636 const getLast$4 = getLast_1;
53638 getOrderedListItemInfo,
53640 splitText: splitText$1
53641 } = utils$2; // 0x0 ~ 0x10ffff
53643 const isSingleCharRegex = /^.$/su;
53645 function preprocess$5(ast, options) {
53646 ast = restoreUnescapedCharacter(ast, options);
53647 ast = mergeContinuousTexts(ast);
53648 ast = transformInlineCode(ast);
53649 ast = transformIndentedCodeblockAndMarkItsParentList(ast, options);
53650 ast = markAlignedList(ast, options);
53651 ast = splitTextIntoSentences(ast, options);
53652 ast = transformImportExport(ast);
53653 ast = mergeContinuousImportExport(ast);
53657 function transformImportExport(ast) {
53658 return mapAst(ast, node => {
53659 if (node.type !== "import" && node.type !== "export") {
53663 return Object.assign(Object.assign({}, node), {}, {
53664 type: "importExport"
53669 function transformInlineCode(ast) {
53670 return mapAst(ast, node => {
53671 if (node.type !== "inlineCode") {
53675 return Object.assign(Object.assign({}, node), {}, {
53676 value: node.value.replace(/\s+/g, " ")
53681 function restoreUnescapedCharacter(ast, options) {
53682 return mapAst(ast, node => node.type !== "text" || node.value === "*" || node.value === "_" || // handle these cases in printer
53683 !isSingleCharRegex.test(node.value) || node.position.end.offset - node.position.start.offset === node.value.length ? node : Object.assign(Object.assign({}, node), {}, {
53684 value: options.originalText.slice(node.position.start.offset, node.position.end.offset)
53688 function mergeContinuousImportExport(ast) {
53689 return mergeChildren(ast, (prevNode, node) => prevNode.type === "importExport" && node.type === "importExport", (prevNode, node) => ({
53690 type: "importExport",
53691 value: prevNode.value + "\n\n" + node.value,
53693 start: prevNode.position.start,
53694 end: node.position.end
53699 function mergeChildren(ast, shouldMerge, mergeNode) {
53700 return mapAst(ast, node => {
53701 if (!node.children) {
53705 const children = node.children.reduce((current, child) => {
53706 const lastChild = getLast$4(current);
53708 if (lastChild && shouldMerge(lastChild, child)) {
53709 current.splice(-1, 1, mergeNode(lastChild, child));
53711 current.push(child);
53716 return Object.assign(Object.assign({}, node), {}, {
53722 function mergeContinuousTexts(ast) {
53723 return mergeChildren(ast, (prevNode, node) => prevNode.type === "text" && node.type === "text", (prevNode, node) => ({
53725 value: prevNode.value + node.value,
53727 start: prevNode.position.start,
53728 end: node.position.end
53733 function splitTextIntoSentences(ast, options) {
53734 return mapAst(ast, (node, index, [parentNode]) => {
53735 if (node.type !== "text") {
53743 if (parentNode.type === "paragraph") {
53745 value = value.trimStart();
53748 if (index === parentNode.children.length - 1) {
53749 value = value.trimEnd();
53755 position: node.position,
53756 children: splitText$1(value, options)
53761 function transformIndentedCodeblockAndMarkItsParentList(ast, options) {
53762 return mapAst(ast, (node, index, parentStack) => {
53763 if (node.type === "code") {
53764 // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it
53765 const isIndented = /^\n?(?: {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset));
53766 node.isIndented = isIndented;
53769 for (let i = 0; i < parentStack.length; i++) {
53770 const parent = parentStack[i]; // no need to check checked items
53772 if (parent.hasIndentedCodeblock) {
53776 if (parent.type === "list") {
53777 parent.hasIndentedCodeblock = true;
53787 function markAlignedList(ast, options) {
53788 return mapAst(ast, (node, index, parentStack) => {
53789 if (node.type === "list" && node.children.length > 0) {
53790 // if one of its parents is not aligned, it's not possible to be aligned in sub-lists
53791 for (let i = 0; i < parentStack.length; i++) {
53792 const parent = parentStack[i];
53794 if (parent.type === "list" && !parent.isAligned) {
53795 node.isAligned = false;
53800 node.isAligned = isAligned(node);
53806 function getListItemStart(listItem) {
53807 return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1;
53810 function isAligned(list) {
53811 if (!list.ordered) {
53819 const [firstItem, secondItem] = list.children;
53820 const firstInfo = getOrderedListItemInfo(firstItem, options.originalText);
53822 if (firstInfo.leadingSpaces.length > 1) {
53832 const firstStart = getListItemStart(firstItem);
53834 if (firstStart === -1) {
53844 if (list.children.length === 1) {
53854 return firstStart % options.tabWidth === 0;
53857 const secondStart = getListItemStart(secondItem);
53859 if (firstStart !== secondStart) {
53870 if (firstStart % options.tabWidth === 0) {
53890 const secondInfo = getOrderedListItemInfo(secondItem, options.originalText);
53891 return secondInfo.leadingSpaces.length > 1;
53895 var printPreprocess$2 = preprocess$5;
53898 isFrontMatterNode: isFrontMatterNode$2
53903 const ignoredProperties$1 = new Set(["position", "raw" // front-matter
53906 function clean$4(ast, newObj, parent) {
53908 if (ast.type === "front-matter" || ast.type === "code" || ast.type === "yaml" || ast.type === "import" || ast.type === "export" || ast.type === "jsx") {
53909 delete newObj.value;
53912 if (ast.type === "list") {
53913 delete newObj.isAligned;
53916 if (ast.type === "list" || ast.type === "listItem") {
53917 delete newObj.spread;
53918 delete newObj.loose;
53919 } // texts can be splitted or merged
53922 if (ast.type === "text") {
53926 if (ast.type === "inlineCode") {
53927 newObj.value = ast.value.replace(/[\t\n ]+/g, " ");
53930 if (ast.type === "wikiLink") {
53931 newObj.value = ast.value.trim().replace(/[\t\n]+/g, " ");
53934 if (ast.type === "definition" || ast.type === "linkReference") {
53935 newObj.label = ast.label.trim().replace(/[\t\n ]+/g, " ").toLowerCase();
53938 if ((ast.type === "definition" || ast.type === "link" || ast.type === "image") && ast.title) {
53939 newObj.title = ast.title.replace(/\\(["')])/g, "$1");
53940 } // for insert pragma
53943 if (parent && parent.type === "root" && parent.children.length > 0 && (parent.children[0] === ast || isFrontMatterNode$2(parent.children[0]) && parent.children[1] === ast) && ast.type === "html" && startWithPragma(ast.value)) {
53948 clean$4.ignoredProperties = ignoredProperties$1;
53949 var clean_1$1 = clean$4;
53952 getLast: getLast$3,
53953 getMinNotPresentContinuousCount,
53954 getMaxContinuousCount,
53956 isNonEmptyArray: isNonEmptyArray$2
53960 breakParent: breakParent$4,
53963 literalline: literalline$3,
53964 markAsRoot: markAsRoot$1,
53965 hardline: hardline$8,
53966 softline: softline$6,
53967 ifBreak: ifBreak$5,
53972 hardlineWithoutBreakParent
53976 replaceTextEndOfLine: replaceTextEndOfLine$7
53982 const embed$5 = embed_1$2;
53984 insertPragma: insertPragma$4
53987 locStart: locStart$6,
53990 const preprocess$4 = printPreprocess$2;
53991 const clean$3 = clean_1$1;
53993 getFencedCodeBlockValue,
53994 hasGitDiffFriendlyOrderedList,
53996 punctuationPattern,
53998 INLINE_NODE_WRAPPER_TYPES,
54002 * @typedef {import("../document").Doc} Doc
54005 const TRAILING_HARDLINE_NODES = new Set(["importExport"]);
54006 const SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link", "wikiLink"];
54007 const SIBLING_NODE_TYPES = new Set(["listItem", "definition", "footnoteDefinition"]);
54009 function genericPrint$2(path, options, print) {
54010 const node = path.getValue();
54012 if (shouldRemainTheSameContent(path)) {
54013 return splitText(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(node => node.type === "word" ? node.value : node.value === "" ? "" : printLine(path, node.value, options));
54016 switch (node.type) {
54017 case "front-matter":
54018 return options.originalText.slice(node.position.start.offset, node.position.end.offset);
54021 if (node.children.length === 0) {
54025 return [normalizeDoc(printRoot(path, options, print)), !TRAILING_HARDLINE_NODES.has(getLastDescendantNode$2(node).type) ? hardline$8 : ""];
54028 return printChildren$4(path, options, print, {
54029 postprocessor: fill$4
54033 return printChildren$4(path, options, print);
54037 let escapedValue = node.value.replace(/\*/g, "\\$&") // escape all `*`
54038 .replace(new RegExp([`(^|${punctuationPattern})(_+)`, `(_+)(${punctuationPattern}|$)`].join("|"), "g"), (_, text1, underscore1, underscore2, text2) => (underscore1 ? `${text1}${underscore1}` : `${underscore2}${text2}`).replace(/_/g, "\\_")); // escape all `_` except concating with non-punctuation, e.g. `1_2_3` is not considered emphasis
54040 const isFirstSentence = (node, name, index) => node.type === "sentence" && index === 0;
54042 const isLastChildAutolink = (node, name, index) => isAutolink(node.children[index - 1]);
54044 if (escapedValue !== node.value && (path.match(undefined, isFirstSentence, isLastChildAutolink) || path.match(undefined, isFirstSentence, (node, name, index) => node.type === "emphasis" && index === 0, isLastChildAutolink))) {
54045 // backslash is parsed as part of autolinks, so we need to remove it
54046 escapedValue = escapedValue.replace(/^(\\?[*_])+/, prefix => prefix.replace(/\\/g, ""));
54049 return escapedValue;
54054 const parentNode = path.getParentNode();
54055 const index = parentNode.children.indexOf(node);
54056 const nextNode = parentNode.children[index + 1];
54057 const proseWrap = // leading char that may cause different syntax
54058 nextNode && /^>|^(?:[*+-]|#{1,6}|\d+[).])$/.test(nextNode.value) ? "never" : options.proseWrap;
54059 return printLine(path, node.value, {
54068 if (isAutolink(node.children[0])) {
54069 style = options.originalText[node.position.start.offset];
54071 const parentNode = path.getParentNode();
54072 const index = parentNode.children.indexOf(node);
54073 const prevNode = parentNode.children[index - 1];
54074 const nextNode = parentNode.children[index + 1];
54075 const hasPrevOrNextWord = // `1*2*3` is considered emphasis but `1_2_3` is not
54076 prevNode && prevNode.type === "sentence" && prevNode.children.length > 0 && getLast$3(prevNode.children).type === "word" && !getLast$3(prevNode.children).hasTrailingPunctuation || nextNode && nextNode.type === "sentence" && nextNode.children.length > 0 && nextNode.children[0].type === "word" && !nextNode.children[0].hasLeadingPunctuation;
54077 style = hasPrevOrNextWord || getAncestorNode(path, "emphasis") ? "*" : "_";
54080 return [style, printChildren$4(path, options, print), style];
54084 return ["**", printChildren$4(path, options, print), "**"];
54087 return ["~~", printChildren$4(path, options, print), "~~"];
54091 const backtickCount = getMinNotPresentContinuousCount(node.value, "`");
54092 const style = "`".repeat(backtickCount || 1);
54093 const gap = backtickCount && !/^\s/.test(node.value) ? " " : "";
54094 return [style, gap, node.value, gap, style];
54101 if (options.proseWrap === "preserve") {
54102 contents = node.value;
54104 contents = node.value.replace(/[\t\n]+/g, " ");
54107 return ["[[", contents, "]]"];
54111 switch (options.originalText[node.position.start.offset]) {
54114 const mailto = "mailto:";
54115 const url = // <hello@example.com> is parsed as { url: "mailto:hello@example.com" }
54116 node.url.startsWith(mailto) && options.originalText.slice(node.position.start.offset + 1, node.position.start.offset + 1 + mailto.length) !== mailto ? node.url.slice(mailto.length) : node.url;
54117 return ["<", url, ">"];
54121 return ["[", printChildren$4(path, options, print), "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"];
54124 return options.originalText.slice(node.position.start.offset, node.position.end.offset);
54128 return ["![", node.alt || "", "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"];
54131 return ["> ", align$1("> ", printChildren$4(path, options, print))];
54134 return ["#".repeat(node.depth) + " ", printChildren$4(path, options, print)];
54138 if (node.isIndented) {
54139 // indented code block
54140 const alignment = " ".repeat(4);
54141 return align$1(alignment, [alignment, ...replaceTextEndOfLine$7(node.value, hardline$8)]);
54142 } // fenced code block
54145 const styleUnit = options.__inJsTemplate ? "~" : "`";
54146 const style = styleUnit.repeat(Math.max(3, getMaxContinuousCount(node.value, styleUnit) + 1));
54147 return [style, node.lang || "", node.meta ? " " + node.meta : "", hardline$8, ...replaceTextEndOfLine$7(getFencedCodeBlockValue(node, options.originalText), hardline$8), hardline$8, style];
54152 const parentNode = path.getParentNode();
54153 const value = parentNode.type === "root" && getLast$3(parentNode.children) === node ? node.value.trimEnd() : node.value;
54154 const isHtmlComment = /^<!--.*-->$/s.test(value);
54155 return replaceTextEndOfLine$7(value, // @ts-expect-error
54156 isHtmlComment ? hardline$8 : markAsRoot$1(literalline$3));
54161 const nthSiblingIndex = getNthListSiblingIndex(node, path.getParentNode());
54162 const isGitDiffFriendlyOrderedList = hasGitDiffFriendlyOrderedList(node, options);
54163 return printChildren$4(path, options, print, {
54164 processor: (childPath, index) => {
54165 const prefix = getPrefix();
54166 const childNode = childPath.getValue();
54168 if (childNode.children.length === 2 && childNode.children[1].type === "html" && childNode.children[0].position.start.column !== childNode.children[1].position.start.column) {
54169 return [prefix, printListItem(childPath, options, print, prefix)];
54172 return [prefix, align$1(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))];
54174 function getPrefix() {
54175 const rawPrefix = node.ordered ? (index === 0 ? node.start : isGitDiffFriendlyOrderedList ? 1 : node.start + index) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") : nthSiblingIndex % 2 === 0 ? "- " : "* ";
54176 return node.isAligned ||
54177 /* workaround for https://github.com/remarkjs/remark/issues/315 */
54178 node.hasIndentedCodeblock ? alignListPrefix(rawPrefix, options) : rawPrefix;
54184 case "thematicBreak":
54186 const counter = getAncestorCounter(path, "list");
54188 if (counter === -1) {
54192 const nthSiblingIndex = getNthListSiblingIndex(path.getParentNode(counter), path.getParentNode(counter + 1));
54193 return nthSiblingIndex % 2 === 0 ? "***" : "---";
54196 case "linkReference":
54197 return ["[", printChildren$4(path, options, print), "]", node.referenceType === "full" ? ["[", node.identifier, "]"] : node.referenceType === "collapsed" ? "[]" : ""];
54199 case "imageReference":
54200 switch (node.referenceType) {
54202 return ["![", node.alt || "", "][", node.identifier, "]"];
54205 return ["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""];
54210 const lineOrSpace = options.proseWrap === "always" ? line$a : " ";
54211 return group$7(["[", node.identifier, "]:", indent$3([lineOrSpace, printUrl(node.url), node.title === null ? "" : [lineOrSpace, printTitle(node.title, options, false)]])]);
54213 // `footnote` requires `.use(footnotes, {inlineNotes: true})`, we are not using this option
54214 // https://github.com/remarkjs/remark-footnotes#optionsinlinenotes
54216 /* istanbul ignore next */
54219 return ["[^", printChildren$4(path, options, print), "]"];
54221 case "footnoteReference":
54222 return ["[^", node.identifier, "]"];
54224 case "footnoteDefinition":
54226 const nextNode = path.getParentNode().children[path.getName() + 1];
54227 const shouldInlineFootnote = node.children.length === 1 && node.children[0].type === "paragraph" && (options.proseWrap === "never" || options.proseWrap === "preserve" && node.children[0].position.start.line === node.children[0].position.end.line);
54228 return ["[^", node.identifier, "]: ", shouldInlineFootnote ? printChildren$4(path, options, print) : group$7([align$1(" ".repeat(4), printChildren$4(path, options, print, {
54229 processor: (childPath, index) => index === 0 ? group$7([softline$6, print()]) : print()
54230 })), nextNode && nextNode.type === "footnoteDefinition" ? softline$6 : ""])];
54234 return printTable(path, options, print);
54237 return printChildren$4(path, options, print);
54240 return /\s/.test(options.originalText[node.position.start.offset]) ? [" ", markAsRoot$1(literalline$3)] : ["\\", hardline$8];
54243 return replaceTextEndOfLine$7(node.value, hardline$8);
54245 // fallback to the original text if multiparser failed
54246 // or `embeddedLanguageFormatting: "off"`
54248 case "importExport":
54249 return [node.value, hardline$8];
54252 return ["{/* ", node.value, " */}"];
54258 return ["$$", hardline$8, node.value ? [...replaceTextEndOfLine$7(node.value, hardline$8), hardline$8] : "", "$$"];
54262 // remark-math trims content but we don't want to remove whitespaces
54263 // since it's very possible that it's recognized as math accidentally
54264 return options.originalText.slice(locStart$6(node), locEnd$5(node));
54267 case "tableRow": // handled in "table"
54269 case "listItem": // handled in "list"
54272 /* istanbul ignore next */
54273 throw new Error(`Unknown markdown type ${JSON.stringify(node.type)}`);
54277 function printListItem(path, options, print, listPrefix) {
54278 const node = path.getValue();
54279 const prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
54280 return [prefix, printChildren$4(path, options, print, {
54281 processor: (childPath, index) => {
54282 if (index === 0 && childPath.getValue().type !== "list") {
54283 return align$1(" ".repeat(prefix.length), print());
54286 const alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
54288 return [alignment, align$1(alignment, print())];
54293 function alignListPrefix(prefix, options) {
54294 const additionalSpaces = getAdditionalSpaces();
54295 return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
54298 function getAdditionalSpaces() {
54299 const restSpaces = prefix.length % options.tabWidth;
54300 return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
54304 function getNthListSiblingIndex(node, parentNode) {
54305 return getNthSiblingIndex(node, parentNode, siblingNode => siblingNode.ordered === node.ordered);
54308 function getNthSiblingIndex(node, parentNode, condition) {
54311 for (const childNode of parentNode.children) {
54312 if (childNode.type === node.type && condition(childNode)) {
54318 if (childNode === node) {
54324 function getAncestorCounter(path, typeOrTypes) {
54325 const types = Array.isArray(typeOrTypes) ? typeOrTypes : [typeOrTypes];
54329 while (ancestorNode = path.getParentNode(++counter)) {
54330 if (types.includes(ancestorNode.type)) {
54338 function getAncestorNode(path, typeOrTypes) {
54339 const counter = getAncestorCounter(path, typeOrTypes);
54340 return counter === -1 ? null : path.getParentNode(counter);
54343 function printLine(path, value, options) {
54344 if (options.proseWrap === "preserve" && value === "\n") {
54348 const isBreakable = options.proseWrap === "always" && !getAncestorNode(path, SINGLE_LINE_NODE_TYPES);
54349 return value !== "" ? isBreakable ? line$a : " " : isBreakable ? softline$6 : "";
54352 function printTable(path, options, print) {
54353 const node = path.getValue();
54354 const columnMaxWidths = []; // { [rowIndex: number]: { [columnIndex: number]: {text: string, width: number} } }
54356 const contents = path.map(rowPath => rowPath.map((cellPath, columnIndex) => {
54357 const text = printDocToString(print(), options).formatted;
54358 const width = getStringWidth(text);
54359 columnMaxWidths[columnIndex] = Math.max(columnMaxWidths[columnIndex] || 3, // minimum width = 3 (---, :--, :-:, --:)
54365 }, "children"), "children");
54366 const alignedTable = printTableContents(
54370 if (options.proseWrap !== "never") {
54371 return [breakParent$4, alignedTable];
54372 } // Only if the --prose-wrap never is set and it exceeds the print width.
54375 const compactTable = printTableContents(
54378 return [breakParent$4, group$7(ifBreak$5(compactTable, alignedTable))];
54380 function printTableContents(isCompact) {
54381 /** @type{Doc[]} */
54382 const parts = [printRow(contents[0], isCompact), printAlign(isCompact)];
54384 if (contents.length > 1) {
54385 parts.push(join$7(hardlineWithoutBreakParent, contents.slice(1).map(rowContents => printRow(rowContents, isCompact))));
54388 return join$7(hardlineWithoutBreakParent, parts);
54391 function printAlign(isCompact) {
54392 const align = columnMaxWidths.map((width, index) => {
54393 const align = node.align[index];
54394 const first = align === "center" || align === "left" ? ":" : "-";
54395 const last = align === "center" || align === "right" ? ":" : "-";
54396 const middle = isCompact ? "-" : "-".repeat(width - 2);
54397 return `${first}${middle}${last}`;
54399 return `| ${align.join(" | ")} |`;
54402 function printRow(rowContents, isCompact) {
54403 const columns = rowContents.map(({
54406 }, columnIndex) => {
54411 const spaces = columnMaxWidths[columnIndex] - width;
54412 const align = node.align[columnIndex];
54415 if (align === "right") {
54417 } else if (align === "center") {
54418 before = Math.floor(spaces / 2);
54421 const after = spaces - before;
54422 return `${" ".repeat(before)}${text}${" ".repeat(after)}`;
54424 return `| ${columns.join(" | ")} |`;
54428 function printRoot(path, options, print) {
54429 /** @typedef {{ index: number, offset: number }} IgnorePosition */
54431 /** @type {Array<{start: IgnorePosition, end: IgnorePosition}>} */
54432 const ignoreRanges = [];
54433 /** @type {IgnorePosition | null} */
54435 let ignoreStart = null;
54438 } = path.getValue();
54440 for (const [index, childNode] of children.entries()) {
54441 switch (isPrettierIgnore$2(childNode)) {
54443 if (ignoreStart === null) {
54446 offset: childNode.position.end.offset
54453 if (ignoreStart !== null) {
54454 ignoreRanges.push({
54455 start: ignoreStart,
54458 offset: childNode.position.start.offset
54461 ignoreStart = null;
54468 return printChildren$4(path, options, print, {
54469 processor: (childPath, index) => {
54470 if (ignoreRanges.length > 0) {
54471 const ignoreRange = ignoreRanges[0];
54473 if (index === ignoreRange.start.index) {
54474 return [children[ignoreRange.start.index].value, options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), children[ignoreRange.end.index].value];
54477 if (ignoreRange.start.index < index && index < ignoreRange.end.index) {
54481 if (index === ignoreRange.end.index) {
54482 ignoreRanges.shift();
54492 function printChildren$4(path, options, print, events = {}) {
54497 const processor = events.processor || (() => print());
54499 const node = path.getValue();
54502 path.each((childPath, index) => {
54503 const childNode = childPath.getValue();
54504 const result = processor(childPath, index);
54506 if (result !== false) {
54509 prevNode: lastChildNode,
54514 if (shouldPrePrintHardline(childNode, data)) {
54515 parts.push(hardline$8); // Can't find a case to pass `shouldPrePrintTripleHardline`
54517 /* istanbul ignore next */
54519 if (lastChildNode && TRAILING_HARDLINE_NODES.has(lastChildNode.type)) {
54520 if (shouldPrePrintTripleHardline(childNode, data)) {
54521 parts.push(hardline$8);
54524 if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) {
54525 parts.push(hardline$8);
54528 if (shouldPrePrintTripleHardline(childNode, data)) {
54529 parts.push(hardline$8);
54534 parts.push(result);
54535 lastChildNode = childNode;
54538 return postprocessor ? postprocessor(parts) : parts;
54541 function getLastDescendantNode$2(node) {
54542 let current = node;
54544 while (isNonEmptyArray$2(current.children)) {
54545 current = getLast$3(current.children);
54550 /** @return {false | 'next' | 'start' | 'end'} */
54553 function isPrettierIgnore$2(node) {
54556 if (node.type === "html") {
54557 match = node.value.match(/^<!--\s*prettier-ignore(?:-(start|end))?\s*-->$/);
54561 if (node.type === "esComment") {
54563 } else if (node.type === "paragraph" && node.children.length === 1 && node.children[0].type === "esComment") {
54564 comment = node.children[0];
54568 match = comment.value.match(/^prettier-ignore(?:-(start|end))?$/);
54572 return match ? match[1] ? match[1] : "next" : false;
54575 function shouldPrePrintHardline(node, data) {
54576 const isFirstNode = data.parts.length === 0;
54577 const isInlineNode = INLINE_NODE_TYPES.includes(node.type);
54578 const isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES.includes(data.parentNode.type);
54579 return !isFirstNode && !isInlineNode && !isInlineHTML;
54582 function shouldPrePrintDoubleHardline(node, data) {
54583 const isSequence = (data.prevNode && data.prevNode.type) === node.type;
54584 const isSiblingNode = isSequence && SIBLING_NODE_TYPES.has(node.type);
54585 const isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
54586 const isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
54587 const isPrevNodePrettierIgnore = isPrettierIgnore$2(data.prevNode) === "next";
54588 const isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
54589 const isHtmlDirectAfterListItem = node.type === "html" && data.parentNode.type === "listItem" && data.prevNode && data.prevNode.type === "paragraph" && data.prevNode.position.end.line + 1 === node.position.start.line;
54590 return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml || isHtmlDirectAfterListItem);
54593 function shouldPrePrintTripleHardline(node, data) {
54594 const isPrevNodeList = data.prevNode && data.prevNode.type === "list";
54595 const isIndentedCode = node.type === "code" && node.isIndented;
54596 return isPrevNodeList && isIndentedCode;
54599 function shouldRemainTheSameContent(path) {
54600 const ancestorNode = getAncestorNode(path, ["linkReference", "imageReference"]);
54601 return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full");
54604 * @param {string} url
54605 * @param {string[] | string} [dangerousCharOrChars]
54606 * @returns {string}
54610 function printUrl(url, dangerousCharOrChars = []) {
54611 const dangerousChars = [" ", ...(Array.isArray(dangerousCharOrChars) ? dangerousCharOrChars : [dangerousCharOrChars])];
54612 return new RegExp(dangerousChars.map(x => `\\${x}`).join("|")).test(url) ? `<${url}>` : url;
54615 function printTitle(title, options, printSpace = true) {
54621 return " " + printTitle(title, options, false);
54622 } // title is escaped after `remark-parse` v7
54625 title = title.replace(/\\(["')])/g, "$1");
54627 if (title.includes('"') && title.includes("'") && !title.includes(")")) {
54628 return `(${title})`; // avoid escaped quotes
54629 } // faster than using RegExps: https://jsperf.com/performance-of-match-vs-split
54632 const singleCount = title.split("'").length - 1;
54633 const doubleCount = title.split('"').length - 1;
54634 const quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
54635 title = title.replace(/\\/, "\\\\");
54636 title = title.replace(new RegExp(`(${quote})`, "g"), "\\$1");
54637 return `${quote}${title}${quote}`;
54640 function clamp(value, min, max) {
54641 return value < min ? min : value > max ? max : value;
54644 function hasPrettierIgnore$5(path) {
54645 const index = Number(path.getName());
54651 const prevNode = path.getParentNode().children[index - 1];
54652 return isPrettierIgnore$2(prevNode) === "next";
54655 var printerMarkdown = {
54656 preprocess: preprocess$4,
54657 print: genericPrint$2,
54659 massageAstNode: clean$3,
54660 hasPrettierIgnore: hasPrettierIgnore$5,
54661 insertPragma: insertPragma$4
54664 const commonOptions$2 = commonOptions$6; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
54667 proseWrap: commonOptions$2.proseWrap,
54668 singleQuote: commonOptions$2.singleQuote
54672 /* istanbul ignore next */
54674 return require("./parser-markdown.js").parsers.remark;
54678 return require("./parser-markdown.js").parsers.remark;
54682 return require("./parser-markdown.js").parsers.mdx;
54687 var name$3 = "Markdown";
54688 var type$3 = "prose";
54689 var color$3 = "#083fa1";
54693 var aceMode$3 = "markdown";
54694 var codemirrorMode$2 = "gfm";
54695 var codemirrorMimeType$2 = "text/x-gfm";
54697 var extensions$3 = [
54710 var filenames$1 = [
54713 var tmScope$3 = "source.gfm";
54714 var languageId$3 = 222;
54715 var require$$4$3 = {
54719 aliases: aliases$2,
54720 aceMode: aceMode$3,
54721 codemirrorMode: codemirrorMode$2,
54722 codemirrorMimeType: codemirrorMimeType$2,
54724 extensions: extensions$3,
54725 filenames: filenames$1,
54726 tmScope: tmScope$3,
54727 languageId: languageId$3
54730 const createLanguage$2 = createLanguage$7;
54731 const printer$2 = printerMarkdown;
54732 const options$4 = options$5;
54733 const parsers$4 = parsers$5;
54734 const languages$3 = [createLanguage$2(require$$4$3, data => ({
54736 parsers: ["markdown"],
54737 vscodeLanguageIds: ["markdown"],
54738 filenames: [...data.filenames, "README"],
54739 extensions: data.extensions.filter(extension => extension !== ".mdx")
54740 })), createLanguage$2(require$$4$3, () => ({
54744 vscodeLanguageIds: ["mdx"],
54746 extensions: [".mdx"]
54748 const printers$1 = {
54751 var languageMarkdown = {
54752 languages: languages$3,
54753 options: options$4,
54754 printers: printers$1,
54759 isFrontMatterNode: isFrontMatterNode$1
54761 const ignoredProperties = new Set(["sourceSpan", "startSourceSpan", "endSourceSpan", "nameSpan", "valueSpan"]);
54763 function clean$2(ast, newNode) {
54764 if (ast.type === "text" || ast.type === "comment") {
54766 } // may be formatted by multiparser
54769 if (isFrontMatterNode$1(ast) || ast.type === "yaml" || ast.type === "toml") {
54773 if (ast.type === "attribute") {
54774 delete newNode.value;
54777 if (ast.type === "docType") {
54778 delete newNode.value;
54782 clean$2.ignoredProperties = ignoredProperties;
54783 var clean_1 = clean$2;
55159 "allowpaymentrequest",
55544 basefont: basefont,
55546 blockquote: blockquote,
55553 colgroup: colgroup,
55563 fieldset: fieldset,
55567 frameset: frameset,
55592 optgroup: optgroup,
55598 progress: progress,
55608 textarea: textarea,
55619 var require$$4$2 = {
55620 "CSS_DISPLAY_TAGS": {
55623 "basefont": "none",
55624 "datalist": "none",
55629 "noframes": "none",
55635 "template": "inline",
55640 "address": "block",
55641 "blockquote": "block",
55645 "figcaption": "block",
55651 "listing": "block",
55654 "plaintext": "block",
55657 "slot": "contents",
55660 "article": "block",
55670 "section": "block",
55679 "caption": "table-caption",
55680 "colgroup": "table-column-group",
55681 "col": "table-column",
55682 "thead": "table-header-group",
55683 "tbody": "table-row-group",
55684 "tfoot": "table-footer-group",
55686 "td": "table-cell",
55687 "th": "table-cell",
55688 "fieldset": "block",
55689 "button": "inline-block",
55690 "details": "block",
55691 "summary": "block",
55693 "meter": "inline-block",
55694 "progress": "inline-block",
55695 "object": "inline-block",
55696 "video": "inline-block",
55697 "audio": "inline-block",
55698 "select": "inline-block",
55700 "optgroup": "block"
55702 "CSS_DISPLAY_DEFAULT": "inline",
55703 "CSS_WHITE_SPACE_TAGS": {
55705 "plaintext": "pre",
55709 "table": "initial",
55710 "textarea": "pre-wrap"
55712 "CSS_WHITE_SPACE_DEFAULT": "normal"
55716 * @typedef {import("../common/ast-path")} AstPath
55720 const htmlTagNames = require$$0;
55721 const htmlElementAttributes = require$$1;
55723 inferParserByLanguage,
55729 hardline: hardline$7,
55733 getDocParts: getDocParts$3,
55734 replaceTextEndOfLine: replaceTextEndOfLine$6
55739 CSS_DISPLAY_DEFAULT,
55740 CSS_WHITE_SPACE_TAGS,
55741 CSS_WHITE_SPACE_DEFAULT
55743 const HTML_TAGS = arrayToMap(htmlTagNames);
55744 const HTML_ELEMENT_ATTRIBUTES = mapObject(htmlElementAttributes, arrayToMap); // https://infra.spec.whatwg.org/#ascii-whitespace
55746 const HTML_WHITESPACE = new Set(["\t", "\n", "\f", "\r", " "]);
55748 const htmlTrimStart = string => string.replace(/^[\t\n\f\r ]+/, "");
55750 const htmlTrimEnd = string => string.replace(/[\t\n\f\r ]+$/, "");
55752 const htmlTrim$1 = string => htmlTrimStart(htmlTrimEnd(string));
55754 const htmlTrimLeadingBlankLines = string => string.replace(/^[\t\f\r ]*?\n/g, "");
55756 const htmlTrimPreserveIndentation$1 = string => htmlTrimLeadingBlankLines(htmlTrimEnd(string));
55758 const splitByHtmlWhitespace = string => string.split(/[\t\n\f\r ]+/);
55760 const getLeadingHtmlWhitespace = string => string.match(/^[\t\n\f\r ]*/)[0];
55762 const getLeadingAndTrailingHtmlWhitespace$1 = string => {
55763 const [, leadingWhitespace, text, trailingWhitespace] = string.match(/^([\t\n\f\r ]*)(.*?)([\t\n\f\r ]*)$/s);
55766 trailingWhitespace,
55771 const hasHtmlWhitespace$1 = string => /[\t\n\f\r ]/.test(string);
55773 function arrayToMap(array) {
55774 const map = Object.create(null);
55776 for (const value of array) {
55783 function mapObject(object, fn) {
55784 const newObject = Object.create(null);
55786 for (const [key, value] of Object.entries(object)) {
55787 newObject[key] = fn(value, key);
55793 function shouldPreserveContent$2(node, options) {
55794 // unterminated node in ie conditional comment
55795 // e.g. <!--[if lt IE 9]><html><![endif]-->
55796 if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) {
55798 } // incomplete html in ie conditional comment
55799 // e.g. <!--[if lt IE 9]></div><![endif]-->
55802 if (node.type === "ieConditionalComment" && !node.complete) {
55804 } // TODO: handle non-text children in <pre>
55807 if (isPreLikeNode$1(node) && node.children.some(child => child.type !== "text" && child.type !== "interpolation")) {
55811 if (isVueNonHtmlBlock$1(node, options) && !isScriptLikeTag$2(node) && node.type !== "interpolation") {
55818 function hasPrettierIgnore$4(node) {
55819 /* istanbul ignore next */
55820 if (node.type === "attribute") {
55823 /* istanbul ignore next */
55826 if (!node.parent) {
55830 if (typeof node.index !== "number" || node.index === 0) {
55834 const prevNode = node.parent.children[node.index - 1];
55835 return isPrettierIgnore$1(prevNode);
55838 function isPrettierIgnore$1(node) {
55839 return node.type === "comment" && node.value.trim() === "prettier-ignore";
55841 /** there's no opening/closing tag or it's considered not breakable */
55844 function isTextLikeNode$2(node) {
55845 return node.type === "text" || node.type === "comment";
55848 function isScriptLikeTag$2(node) {
55849 return node.type === "element" && (node.fullName === "script" || node.fullName === "style" || node.fullName === "svg:style" || isUnknownNamespace(node) && (node.name === "script" || node.name === "style"));
55852 function canHaveInterpolation$1(node) {
55853 return node.children && !isScriptLikeTag$2(node);
55856 function isWhitespaceSensitiveNode$1(node) {
55857 return isScriptLikeTag$2(node) || node.type === "interpolation" || isIndentationSensitiveNode$1(node);
55860 function isIndentationSensitiveNode$1(node) {
55861 return getNodeCssStyleWhiteSpace(node).startsWith("pre");
55864 function isLeadingSpaceSensitiveNode$1(node, options) {
55865 const isLeadingSpaceSensitive = _isLeadingSpaceSensitiveNode();
55867 if (isLeadingSpaceSensitive && !node.prev && node.parent && node.parent.tagDefinition && node.parent.tagDefinition.ignoreFirstLf) {
55868 return node.type === "interpolation";
55871 return isLeadingSpaceSensitive;
55873 function _isLeadingSpaceSensitiveNode() {
55874 if (isFrontMatterNode(node)) {
55878 if ((node.type === "text" || node.type === "interpolation") && node.prev && (node.prev.type === "text" || node.prev.type === "interpolation")) {
55882 if (!node.parent || node.parent.cssDisplay === "none") {
55886 if (isPreLikeNode$1(node.parent)) {
55890 if (!node.prev && (node.parent.type === "root" || isPreLikeNode$1(node) && node.parent || isScriptLikeTag$2(node.parent) || isVueCustomBlock$1(node.parent, options) || !isFirstChildLeadingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
55894 if (node.prev && !isNextLeadingSpaceSensitiveCssDisplay(node.prev.cssDisplay)) {
55902 function isTrailingSpaceSensitiveNode$1(node, options) {
55903 if (isFrontMatterNode(node)) {
55907 if ((node.type === "text" || node.type === "interpolation") && node.next && (node.next.type === "text" || node.next.type === "interpolation")) {
55911 if (!node.parent || node.parent.cssDisplay === "none") {
55915 if (isPreLikeNode$1(node.parent)) {
55919 if (!node.next && (node.parent.type === "root" || isPreLikeNode$1(node) && node.parent || isScriptLikeTag$2(node.parent) || isVueCustomBlock$1(node.parent, options) || !isLastChildTrailingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
55923 if (node.next && !isPrevTrailingSpaceSensitiveCssDisplay(node.next.cssDisplay)) {
55930 function isDanglingSpaceSensitiveNode$1(node) {
55931 return isDanglingSpaceSensitiveCssDisplay(node.cssDisplay) && !isScriptLikeTag$2(node);
55934 function forceNextEmptyLine$1(node) {
55935 return isFrontMatterNode(node) || node.next && node.sourceSpan.end && node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line;
55937 /** firstChild leadingSpaces and lastChild trailingSpaces */
55940 function forceBreakContent$1(node) {
55941 return forceBreakChildren$1(node) || node.type === "element" && node.children.length > 0 && (["body", "script", "style"].includes(node.name) || node.children.some(child => hasNonTextChild(child))) || node.firstChild && node.firstChild === node.lastChild && node.firstChild.type !== "text" && hasLeadingLineBreak(node.firstChild) && (!node.lastChild.isTrailingSpaceSensitive || hasTrailingLineBreak(node.lastChild));
55943 /** spaces between children */
55946 function forceBreakChildren$1(node) {
55947 return node.type === "element" && node.children.length > 0 && (["html", "head", "ul", "ol", "select"].includes(node.name) || node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell");
55950 function preferHardlineAsLeadingSpaces$1(node) {
55951 return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) || hasSurroundingLineBreak(node);
55954 function preferHardlineAsTrailingSpaces(node) {
55955 return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" || hasSurroundingLineBreak(node);
55958 function hasSurroundingLineBreak(node) {
55959 return hasLeadingLineBreak(node) && hasTrailingLineBreak(node);
55962 function hasLeadingLineBreak(node) {
55963 return node.hasLeadingSpaces && (node.prev ? node.prev.sourceSpan.end.line < node.sourceSpan.start.line : node.parent.type === "root" || node.parent.startSourceSpan.end.line < node.sourceSpan.start.line);
55966 function hasTrailingLineBreak(node) {
55967 return node.hasTrailingSpaces && (node.next ? node.next.sourceSpan.start.line > node.sourceSpan.end.line : node.parent.type === "root" || node.parent.endSourceSpan && node.parent.endSourceSpan.start.line > node.sourceSpan.end.line);
55970 function preferHardlineAsSurroundingSpaces(node) {
55971 switch (node.type) {
55972 case "ieConditionalComment":
55978 return ["script", "select"].includes(node.name);
55984 function getLastDescendant$1(node) {
55985 return node.lastChild ? getLastDescendant$1(node.lastChild) : node;
55988 function hasNonTextChild(node) {
55989 return node.children && node.children.some(child => child.type !== "text");
55992 function _inferScriptParser(node) {
55998 if (type === "module" || type === "text/javascript" || type === "text/babel" || type === "application/javascript" || lang === "jsx") {
56002 if (type === "application/x-typescript" || lang === "ts" || lang === "tsx") {
56003 return "typescript";
56006 if (type === "text/markdown") {
56010 if (type === "text/html") {
56014 if (type && (type.endsWith("json") || type.endsWith("importmap"))) {
56018 if (type === "text/x-handlebars-template") {
56023 function inferStyleParser(node) {
56028 if (!lang || lang === "postcss" || lang === "css") {
56032 if (lang === "scss") {
56036 if (lang === "less") {
56041 function inferScriptParser$1(node, options) {
56042 if (node.name === "script" && !node.attrMap.src) {
56043 if (!node.attrMap.lang && !node.attrMap.type) {
56047 return _inferScriptParser(node);
56050 if (node.name === "style") {
56051 return inferStyleParser(node);
56054 if (options && isVueNonHtmlBlock$1(node, options)) {
56055 return _inferScriptParser(node) || !("src" in node.attrMap) && inferParserByLanguage(node.attrMap.lang, options);
56059 function isBlockLikeCssDisplay(cssDisplay) {
56060 return cssDisplay === "block" || cssDisplay === "list-item" || cssDisplay.startsWith("table");
56063 function isFirstChildLeadingSpaceSensitiveCssDisplay(cssDisplay) {
56064 return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
56067 function isLastChildTrailingSpaceSensitiveCssDisplay(cssDisplay) {
56068 return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
56071 function isPrevTrailingSpaceSensitiveCssDisplay(cssDisplay) {
56072 return !isBlockLikeCssDisplay(cssDisplay);
56075 function isNextLeadingSpaceSensitiveCssDisplay(cssDisplay) {
56076 return !isBlockLikeCssDisplay(cssDisplay);
56079 function isDanglingSpaceSensitiveCssDisplay(cssDisplay) {
56080 return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
56083 function isPreLikeNode$1(node) {
56084 return getNodeCssStyleWhiteSpace(node).startsWith("pre");
56087 * @param {AstPath} path
56088 * @param {(any) => boolean} predicate
56092 function countParents$1(path, predicate) {
56095 for (let i = path.stack.length - 1; i >= 0; i--) {
56096 const value = path.stack[i];
56098 if (value && typeof value === "object" && !Array.isArray(value) && predicate(value)) {
56106 function hasParent(node, fn) {
56107 let current = node;
56114 current = current.parent;
56120 function getNodeCssStyleDisplay$1(node, options) {
56121 if (node.prev && node.prev.type === "comment") {
56122 // <!-- display: block -->
56123 const match = node.prev.value.match(/^\s*display:\s*([a-z]+)\s*$/);
56130 let isInSvgForeignObject = false;
56132 if (node.type === "element" && node.namespace === "svg") {
56133 if (hasParent(node, parent => parent.fullName === "svg:foreignObject")) {
56134 isInSvgForeignObject = true;
56136 return node.name === "svg" ? "inline-block" : "block";
56140 switch (options.htmlWhitespaceSensitivity) {
56149 // See https://github.com/prettier/prettier/issues/8151
56150 if (options.parser === "vue" && node.parent && node.parent.type === "root") {
56154 return node.type === "element" && (!node.namespace || isInSvgForeignObject || isUnknownNamespace(node)) && CSS_DISPLAY_TAGS[node.name] || CSS_DISPLAY_DEFAULT;
56159 function isUnknownNamespace(node) {
56160 return node.type === "element" && !node.hasExplicitNamespace && !["html", "svg"].includes(node.namespace);
56163 function getNodeCssStyleWhiteSpace(node) {
56164 return node.type === "element" && (!node.namespace || isUnknownNamespace(node)) && CSS_WHITE_SPACE_TAGS[node.name] || CSS_WHITE_SPACE_DEFAULT;
56167 function getMinIndentation(text) {
56168 let minIndentation = Number.POSITIVE_INFINITY;
56170 for (const lineText of text.split("\n")) {
56171 if (lineText.length === 0) {
56175 if (!HTML_WHITESPACE.has(lineText[0])) {
56179 const indentation = getLeadingHtmlWhitespace(lineText).length;
56181 if (lineText.length === indentation) {
56185 if (indentation < minIndentation) {
56186 minIndentation = indentation;
56190 return minIndentation === Number.POSITIVE_INFINITY ? 0 : minIndentation;
56193 function dedentString$1(text, minIndent = getMinIndentation(text)) {
56194 return minIndent === 0 ? text : text.split("\n").map(lineText => lineText.slice(minIndent)).join("\n");
56197 function countChars$1(text, char) {
56200 for (let i = 0; i < text.length; i++) {
56201 if (text[i] === char) {
56209 function unescapeQuoteEntities$2(text) {
56210 return text.replace(/'/g, "'").replace(/"/g, '"');
56211 } // top-level elements (excluding <template>, <style> and <script>) in Vue SFC are considered custom block
56212 // See https://vue-loader.vuejs.org/spec.html for detail
56215 const vueRootElementsSet = new Set(["template", "style", "script"]);
56217 function isVueCustomBlock$1(node, options) {
56218 return isVueSfcBlock(node, options) && !vueRootElementsSet.has(node.fullName);
56221 function isVueSfcBlock(node, options) {
56222 return options.parser === "vue" && node.type === "element" && node.parent.type === "root" && node.fullName.toLowerCase() !== "html";
56225 function isVueNonHtmlBlock$1(node, options) {
56226 return isVueSfcBlock(node, options) && (isVueCustomBlock$1(node, options) || node.attrMap.lang && node.attrMap.lang !== "html");
56229 function isVueSlotAttribute$1(attribute) {
56230 const attributeName = attribute.fullName;
56231 return attributeName.charAt(0) === "#" || attributeName === "slot-scope" || attributeName === "v-slot" || attributeName.startsWith("v-slot:");
56234 function isVueSfcBindingsAttribute$1(attribute, options) {
56235 const element = attribute.parent;
56237 if (!isVueSfcBlock(element, options)) {
56241 const tagName = element.fullName;
56242 const attributeName = attribute.fullName;
56243 return (// https://github.com/vuejs/rfcs/blob/sfc-improvements/active-rfcs/0000-sfc-script-setup.md
56244 tagName === "script" && attributeName === "setup" || // https://github.com/vuejs/rfcs/blob/sfc-improvements/active-rfcs/0000-sfc-style-variables.md
56245 tagName === "style" && attributeName === "vars"
56249 function getTextValueParts$2(node, value = node.value) {
56250 return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceTextEndOfLine$6(value) : replaceTextEndOfLine$6(dedentString$1(htmlTrimPreserveIndentation$1(value)), hardline$7) : getDocParts$3(join$6(line$9, splitByHtmlWhitespace(value)));
56254 HTML_ELEMENT_ATTRIBUTES,
56256 htmlTrim: htmlTrim$1,
56257 htmlTrimPreserveIndentation: htmlTrimPreserveIndentation$1,
56258 hasHtmlWhitespace: hasHtmlWhitespace$1,
56259 getLeadingAndTrailingHtmlWhitespace: getLeadingAndTrailingHtmlWhitespace$1,
56260 canHaveInterpolation: canHaveInterpolation$1,
56261 countChars: countChars$1,
56262 countParents: countParents$1,
56263 dedentString: dedentString$1,
56264 forceBreakChildren: forceBreakChildren$1,
56265 forceBreakContent: forceBreakContent$1,
56266 forceNextEmptyLine: forceNextEmptyLine$1,
56267 getLastDescendant: getLastDescendant$1,
56268 getNodeCssStyleDisplay: getNodeCssStyleDisplay$1,
56269 getNodeCssStyleWhiteSpace,
56270 hasPrettierIgnore: hasPrettierIgnore$4,
56271 inferScriptParser: inferScriptParser$1,
56272 isVueCustomBlock: isVueCustomBlock$1,
56273 isVueNonHtmlBlock: isVueNonHtmlBlock$1,
56274 isVueSlotAttribute: isVueSlotAttribute$1,
56275 isVueSfcBindingsAttribute: isVueSfcBindingsAttribute$1,
56276 isDanglingSpaceSensitiveNode: isDanglingSpaceSensitiveNode$1,
56277 isIndentationSensitiveNode: isIndentationSensitiveNode$1,
56278 isLeadingSpaceSensitiveNode: isLeadingSpaceSensitiveNode$1,
56279 isPreLikeNode: isPreLikeNode$1,
56280 isScriptLikeTag: isScriptLikeTag$2,
56281 isTextLikeNode: isTextLikeNode$2,
56282 isTrailingSpaceSensitiveNode: isTrailingSpaceSensitiveNode$1,
56283 isWhitespaceSensitiveNode: isWhitespaceSensitiveNode$1,
56284 isUnknownNamespace,
56285 preferHardlineAsLeadingSpaces: preferHardlineAsLeadingSpaces$1,
56286 preferHardlineAsTrailingSpaces,
56287 shouldPreserveContent: shouldPreserveContent$2,
56288 unescapeQuoteEntities: unescapeQuoteEntities$2,
56289 getTextValueParts: getTextValueParts$2
56292 var parse_util = {};
56296 (function (exports) {
56299 * Copyright Google Inc. All Rights Reserved.
56301 * Use of this source code is governed by an MIT-style license that can be
56302 * found in the LICENSE file at https://angular.io/license
56305 Object.defineProperty(exports, "__esModule", {
56309 exports.$BSPACE = 8;
56312 exports.$VTAB = 11;
56315 exports.$SPACE = 32;
56316 exports.$BANG = 33;
56318 exports.$HASH = 35;
56320 exports.$PERCENT = 37;
56321 exports.$AMPERSAND = 38;
56323 exports.$LPAREN = 40;
56324 exports.$RPAREN = 41;
56325 exports.$STAR = 42;
56326 exports.$PLUS = 43;
56327 exports.$COMMA = 44;
56328 exports.$MINUS = 45;
56329 exports.$PERIOD = 46;
56330 exports.$SLASH = 47;
56331 exports.$COLON = 58;
56332 exports.$SEMICOLON = 59;
56336 exports.$QUESTION = 63;
56345 exports.$LBRACKET = 91;
56346 exports.$BACKSLASH = 92;
56347 exports.$RBRACKET = 93;
56348 exports.$CARET = 94;
56361 exports.$LBRACE = 123;
56362 exports.$BAR = 124;
56363 exports.$RBRACE = 125;
56364 exports.$NBSP = 160;
56365 exports.$PIPE = 124;
56366 exports.$TILDA = 126;
56370 function isWhitespace(code) {
56371 return code >= exports.$TAB && code <= exports.$SPACE || code == exports.$NBSP;
56374 exports.isWhitespace = isWhitespace;
56376 function isDigit(code) {
56377 return exports.$0 <= code && code <= exports.$9;
56380 exports.isDigit = isDigit;
56382 function isAsciiLetter(code) {
56383 return code >= exports.$a && code <= exports.$z || code >= exports.$A && code <= exports.$Z;
56386 exports.isAsciiLetter = isAsciiLetter;
56388 function isAsciiHexDigit(code) {
56389 return code >= exports.$a && code <= exports.$f || code >= exports.$A && code <= exports.$F || isDigit(code);
56392 exports.isAsciiHexDigit = isAsciiHexDigit;
56394 function isNewLine(code) {
56395 return code === exports.$LF || code === exports.$CR;
56398 exports.isNewLine = isNewLine;
56400 function isOctalDigit(code) {
56401 return exports.$0 <= code && code <= exports.$7;
56404 exports.isOctalDigit = isOctalDigit;
56407 var compile_metadata = {};
56409 var static_symbol = {};
56413 * Copyright Google Inc. All Rights Reserved.
56415 * Use of this source code is governed by an MIT-style license that can be
56416 * found in the LICENSE file at https://angular.io/license
56420 Object.defineProperty(static_symbol, "__esModule", {
56424 * A token representing the a reference to a static type.
56426 * This token is unique for a filePath and name and can be used as a hash table key.
56429 class StaticSymbol {
56430 constructor(filePath, name, members) {
56431 this.filePath = filePath;
56433 this.members = members;
56436 assertNoMembers() {
56437 if (this.members.length) {
56438 throw new Error(`Illegal state: symbol without members expected, but got ${JSON.stringify(this)}.`);
56444 static_symbol.StaticSymbol = StaticSymbol;
56446 * A cache of static symbol used by the StaticReflector to return the same symbol for the
56447 * same symbol values.
56450 class StaticSymbolCache {
56452 this.cache = new Map();
56455 get(declarationFile, name, members) {
56456 members = members || [];
56457 const memberSuffix = members.length ? `.${members.join('.')}` : '';
56458 const key = `"${declarationFile}".${name}${memberSuffix}`;
56459 let result = this.cache.get(key);
56462 result = new StaticSymbol(declarationFile, name, members);
56463 this.cache.set(key, result);
56471 static_symbol.StaticSymbolCache = StaticSymbolCache;
56477 * Copyright Google Inc. All Rights Reserved.
56479 * Use of this source code is governed by an MIT-style license that can be
56480 * found in the LICENSE file at https://angular.io/license
56484 Object.defineProperty(util, "__esModule", {
56487 const DASH_CASE_REGEXP = /-+([a-z0-9])/g;
56489 function dashCaseToCamelCase(input) {
56490 return input.replace(DASH_CASE_REGEXP, (...m) => m[1].toUpperCase());
56493 util.dashCaseToCamelCase = dashCaseToCamelCase;
56495 function splitAtColon(input, defaultValues) {
56496 return _splitAt(input, ':', defaultValues);
56499 util.splitAtColon = splitAtColon;
56501 function splitAtPeriod(input, defaultValues) {
56502 return _splitAt(input, '.', defaultValues);
56505 util.splitAtPeriod = splitAtPeriod;
56507 function _splitAt(input, character, defaultValues) {
56508 const characterIndex = input.indexOf(character);
56509 if (characterIndex == -1) return defaultValues;
56510 return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()];
56513 function visitValue(value, visitor, context) {
56514 if (Array.isArray(value)) {
56515 return visitor.visitArray(value, context);
56518 if (isStrictStringMap(value)) {
56519 return visitor.visitStringMap(value, context);
56522 if (value == null || typeof value == 'string' || typeof value == 'number' || typeof value == 'boolean') {
56523 return visitor.visitPrimitive(value, context);
56526 return visitor.visitOther(value, context);
56529 util.visitValue = visitValue;
56531 function isDefined(val) {
56532 return val !== null && val !== undefined;
56535 util.isDefined = isDefined;
56537 function noUndefined(val) {
56538 return val === undefined ? null : val;
56541 util.noUndefined = noUndefined;
56543 class ValueTransformer {
56544 visitArray(arr, context) {
56545 return arr.map(value => visitValue(value, this, context));
56548 visitStringMap(map, context) {
56550 Object.keys(map).forEach(key => {
56551 result[key] = visitValue(map[key], this, context);
56556 visitPrimitive(value, context) {
56560 visitOther(value, context) {
56566 util.ValueTransformer = ValueTransformer;
56568 assertSync: value => {
56569 if (isPromise(value)) {
56570 throw new Error(`Illegal state: value cannot be a promise`);
56575 then: (value, cb) => {
56576 return isPromise(value) ? value.then(cb) : cb(value);
56578 all: syncAsyncValues => {
56579 return syncAsyncValues.some(isPromise) ? Promise.all(syncAsyncValues) : syncAsyncValues;
56583 function error(msg) {
56584 throw new Error(`Internal Error: ${msg}`);
56587 util.error = error;
56589 function syntaxError(msg, parseErrors) {
56590 const error = Error(msg);
56591 error[ERROR_SYNTAX_ERROR] = true;
56592 if (parseErrors) error[ERROR_PARSE_ERRORS] = parseErrors;
56596 util.syntaxError = syntaxError;
56597 const ERROR_SYNTAX_ERROR = 'ngSyntaxError';
56598 const ERROR_PARSE_ERRORS = 'ngParseErrors';
56600 function isSyntaxError(error) {
56601 return error[ERROR_SYNTAX_ERROR];
56604 util.isSyntaxError = isSyntaxError;
56606 function getParseErrors(error) {
56607 return error[ERROR_PARSE_ERRORS] || [];
56610 util.getParseErrors = getParseErrors; // Escape characters that have a special meaning in Regular Expressions
56612 function escapeRegExp(s) {
56613 return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
56616 util.escapeRegExp = escapeRegExp;
56617 const STRING_MAP_PROTO = Object.getPrototypeOf({});
56619 function isStrictStringMap(obj) {
56620 return typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
56623 function utf8Encode(str) {
56626 for (let index = 0; index < str.length; index++) {
56627 let codePoint = str.charCodeAt(index); // decode surrogate
56628 // see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
56630 if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > index + 1) {
56631 const low = str.charCodeAt(index + 1);
56633 if (low >= 0xdc00 && low <= 0xdfff) {
56635 codePoint = (codePoint - 0xd800 << 10) + low - 0xdc00 + 0x10000;
56639 if (codePoint <= 0x7f) {
56640 encoded += String.fromCharCode(codePoint);
56641 } else if (codePoint <= 0x7ff) {
56642 encoded += String.fromCharCode(codePoint >> 6 & 0x1F | 0xc0, codePoint & 0x3f | 0x80);
56643 } else if (codePoint <= 0xffff) {
56644 encoded += String.fromCharCode(codePoint >> 12 | 0xe0, codePoint >> 6 & 0x3f | 0x80, codePoint & 0x3f | 0x80);
56645 } else if (codePoint <= 0x1fffff) {
56646 encoded += String.fromCharCode(codePoint >> 18 & 0x07 | 0xf0, codePoint >> 12 & 0x3f | 0x80, codePoint >> 6 & 0x3f | 0x80, codePoint & 0x3f | 0x80);
56653 util.utf8Encode = utf8Encode;
56655 function stringify(token) {
56656 if (typeof token === 'string') {
56660 if (token instanceof Array) {
56661 return '[' + token.map(stringify).join(', ') + ']';
56664 if (token == null) {
56668 if (token.overriddenName) {
56669 return `${token.overriddenName}`;
56673 return `${token.name}`;
56676 if (!token.toString) {
56678 } // WARNING: do not try to `JSON.stringify(token)` here
56679 // see https://github.com/angular/angular/issues/23440
56682 const res = token.toString();
56688 const newLineIndex = res.indexOf('\n');
56689 return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
56692 util.stringify = stringify;
56694 * Lazily retrieves the reference value from a forwardRef.
56697 function resolveForwardRef(type) {
56698 if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__')) {
56705 util.resolveForwardRef = resolveForwardRef;
56707 * Determine if the argument is shaped like a Promise
56710 function isPromise(obj) {
56711 // allow any Promise/A+ compliant thenable.
56712 // It's up to the caller to ensure that obj.then conforms to the spec
56713 return !!obj && typeof obj.then === 'function';
56716 util.isPromise = isPromise;
56719 constructor(full) {
56721 const splits = full.split('.');
56722 this.major = splits[0];
56723 this.minor = splits[1];
56724 this.patch = splits.slice(2).join('.');
56729 util.Version = Version;
56731 const __window = typeof window !== 'undefined' && window;
56733 const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope && self;
56735 const __global = typeof global$1 !== 'undefined' && global$1; // Check __global first, because in Node tests both __global and __window may be defined and _global
56736 // should be __global in that case.
56739 const _global = __global || __window || __self;
56741 var global$1 = util.global = _global;
56743 (function (exports) {
56746 * Copyright Google Inc. All Rights Reserved.
56748 * Use of this source code is governed by an MIT-style license that can be
56749 * found in the LICENSE file at https://angular.io/license
56752 Object.defineProperty(exports, "__esModule", {
56755 const static_symbol_1 = static_symbol;
56756 const util_1 = util; // group 0: "[prop] or (event) or @trigger"
56757 // group 1: "prop" from "[prop]"
56758 // group 2: "event" from "(event)"
56759 // group 3: "@trigger" from "@trigger"
56761 const HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/;
56763 function sanitizeIdentifier(name) {
56764 return name.replace(/\W/g, '_');
56767 exports.sanitizeIdentifier = sanitizeIdentifier;
56768 let _anonymousTypeIndex = 0;
56770 function identifierName(compileIdentifier) {
56771 if (!compileIdentifier || !compileIdentifier.reference) {
56775 const ref = compileIdentifier.reference;
56777 if (ref instanceof static_symbol_1.StaticSymbol) {
56781 if (ref['__anonymousType']) {
56782 return ref['__anonymousType'];
56785 let identifier = util_1.stringify(ref);
56787 if (identifier.indexOf('(') >= 0) {
56788 // case: anonymous functions!
56789 identifier = `anonymous_${_anonymousTypeIndex++}`;
56790 ref['__anonymousType'] = identifier;
56792 identifier = sanitizeIdentifier(identifier);
56798 exports.identifierName = identifierName;
56800 function identifierModuleUrl(compileIdentifier) {
56801 const ref = compileIdentifier.reference;
56803 if (ref instanceof static_symbol_1.StaticSymbol) {
56804 return ref.filePath;
56808 return `./${util_1.stringify(ref)}`;
56811 exports.identifierModuleUrl = identifierModuleUrl;
56813 function viewClassName(compType, embeddedTemplateIndex) {
56814 return `View_${identifierName({
56815 reference: compType
56816 })}_${embeddedTemplateIndex}`;
56819 exports.viewClassName = viewClassName;
56821 function rendererTypeName(compType) {
56822 return `RenderType_${identifierName({
56823 reference: compType
56827 exports.rendererTypeName = rendererTypeName;
56829 function hostViewClassName(compType) {
56830 return `HostView_${identifierName({
56831 reference: compType
56835 exports.hostViewClassName = hostViewClassName;
56837 function componentFactoryName(compType) {
56838 return `${identifierName({
56839 reference: compType
56843 exports.componentFactoryName = componentFactoryName;
56844 var CompileSummaryKind;
56846 (function (CompileSummaryKind) {
56847 CompileSummaryKind[CompileSummaryKind["Pipe"] = 0] = "Pipe";
56848 CompileSummaryKind[CompileSummaryKind["Directive"] = 1] = "Directive";
56849 CompileSummaryKind[CompileSummaryKind["NgModule"] = 2] = "NgModule";
56850 CompileSummaryKind[CompileSummaryKind["Injectable"] = 3] = "Injectable";
56851 })(CompileSummaryKind = exports.CompileSummaryKind || (exports.CompileSummaryKind = {}));
56853 function tokenName(token) {
56854 return token.value != null ? sanitizeIdentifier(token.value) : identifierName(token.identifier);
56857 exports.tokenName = tokenName;
56859 function tokenReference(token) {
56860 if (token.identifier != null) {
56861 return token.identifier.reference;
56863 return token.value;
56867 exports.tokenReference = tokenReference;
56869 * Metadata about a stylesheet
56872 class CompileStylesheetMetadata {
56878 this.moduleUrl = moduleUrl || null;
56879 this.styles = _normalizeArray(styles);
56880 this.styleUrls = _normalizeArray(styleUrls);
56885 exports.CompileStylesheetMetadata = CompileStylesheetMetadata;
56887 * Metadata regarding compilation of a template.
56890 class CompileTemplateMetadata {
56898 externalStylesheets,
56900 ngContentSelectors,
56903 preserveWhitespaces
56905 this.encapsulation = encapsulation;
56906 this.template = template;
56907 this.templateUrl = templateUrl;
56908 this.htmlAst = htmlAst;
56909 this.styles = _normalizeArray(styles);
56910 this.styleUrls = _normalizeArray(styleUrls);
56911 this.externalStylesheets = _normalizeArray(externalStylesheets);
56912 this.animations = animations ? flatten(animations) : [];
56913 this.ngContentSelectors = ngContentSelectors || [];
56915 if (interpolation && interpolation.length != 2) {
56916 throw new Error(`'interpolation' should have a start and an end symbol.`);
56919 this.interpolation = interpolation;
56920 this.isInline = isInline;
56921 this.preserveWhitespaces = preserveWhitespaces;
56926 ngContentSelectors: this.ngContentSelectors,
56927 encapsulation: this.encapsulation,
56928 styles: this.styles,
56929 animations: this.animations
56935 exports.CompileTemplateMetadata = CompileTemplateMetadata;
56937 * Metadata regarding compilation of a directive.
56940 class CompileDirectiveMetadata {
56962 const hostListeners = {};
56963 const hostProperties = {};
56964 const hostAttributes = {};
56966 if (host != null) {
56967 Object.keys(host).forEach(key => {
56968 const value = host[key];
56969 const matches = key.match(HOST_REG_EXP);
56971 if (matches === null) {
56972 hostAttributes[key] = value;
56973 } else if (matches[1] != null) {
56974 hostProperties[matches[1]] = value;
56975 } else if (matches[2] != null) {
56976 hostListeners[matches[2]] = value;
56981 const inputsMap = {};
56983 if (inputs != null) {
56984 inputs.forEach(bindConfig => {
56985 // canonical syntax: `dirProp: elProp`
56986 // if there is no `:`, use dirProp = elProp
56987 const parts = util_1.splitAtColon(bindConfig, [bindConfig, bindConfig]);
56988 inputsMap[parts[0]] = parts[1];
56992 const outputsMap = {};
56994 if (outputs != null) {
56995 outputs.forEach(bindConfig => {
56996 // canonical syntax: `dirProp: elProp`
56997 // if there is no `:`, use dirProp = elProp
56998 const parts = util_1.splitAtColon(bindConfig, [bindConfig, bindConfig]);
56999 outputsMap[parts[0]] = parts[1];
57003 return new CompileDirectiveMetadata({
57006 isComponent: !!isComponent,
57011 outputs: outputsMap,
57051 this.isHost = !!isHost;
57053 this.isComponent = isComponent;
57054 this.selector = selector;
57055 this.exportAs = exportAs;
57056 this.changeDetection = changeDetection;
57057 this.inputs = inputs;
57058 this.outputs = outputs;
57059 this.hostListeners = hostListeners;
57060 this.hostProperties = hostProperties;
57061 this.hostAttributes = hostAttributes;
57062 this.providers = _normalizeArray(providers);
57063 this.viewProviders = _normalizeArray(viewProviders);
57064 this.queries = _normalizeArray(queries);
57065 this.guards = guards;
57066 this.viewQueries = _normalizeArray(viewQueries);
57067 this.entryComponents = _normalizeArray(entryComponents);
57068 this.template = template;
57069 this.componentViewType = componentViewType;
57070 this.rendererType = rendererType;
57071 this.componentFactory = componentFactory;
57076 summaryKind: CompileSummaryKind.Directive,
57078 isComponent: this.isComponent,
57079 selector: this.selector,
57080 exportAs: this.exportAs,
57081 inputs: this.inputs,
57082 outputs: this.outputs,
57083 hostListeners: this.hostListeners,
57084 hostProperties: this.hostProperties,
57085 hostAttributes: this.hostAttributes,
57086 providers: this.providers,
57087 viewProviders: this.viewProviders,
57088 queries: this.queries,
57089 guards: this.guards,
57090 viewQueries: this.viewQueries,
57091 entryComponents: this.entryComponents,
57092 changeDetection: this.changeDetection,
57093 template: this.template && this.template.toSummary(),
57094 componentViewType: this.componentViewType,
57095 rendererType: this.rendererType,
57096 componentFactory: this.componentFactory
57102 exports.CompileDirectiveMetadata = CompileDirectiveMetadata;
57104 class CompilePipeMetadata {
57112 this.pure = !!pure;
57117 summaryKind: CompileSummaryKind.Pipe,
57126 exports.CompilePipeMetadata = CompilePipeMetadata;
57128 class CompileShallowModuleMetadata {}
57130 exports.CompileShallowModuleMetadata = CompileShallowModuleMetadata;
57132 * Metadata regarding compilation of a module.
57135 class CompileNgModuleMetadata {
57139 declaredDirectives,
57140 exportedDirectives,
57144 bootstrapComponents,
57151 this.type = type || null;
57152 this.declaredDirectives = _normalizeArray(declaredDirectives);
57153 this.exportedDirectives = _normalizeArray(exportedDirectives);
57154 this.declaredPipes = _normalizeArray(declaredPipes);
57155 this.exportedPipes = _normalizeArray(exportedPipes);
57156 this.providers = _normalizeArray(providers);
57157 this.entryComponents = _normalizeArray(entryComponents);
57158 this.bootstrapComponents = _normalizeArray(bootstrapComponents);
57159 this.importedModules = _normalizeArray(importedModules);
57160 this.exportedModules = _normalizeArray(exportedModules);
57161 this.schemas = _normalizeArray(schemas);
57162 this.id = id || null;
57163 this.transitiveModule = transitiveModule || null;
57167 const module = this.transitiveModule;
57169 summaryKind: CompileSummaryKind.NgModule,
57171 entryComponents: module.entryComponents,
57172 providers: module.providers,
57173 modules: module.modules,
57174 exportedDirectives: module.exportedDirectives,
57175 exportedPipes: module.exportedPipes
57181 exports.CompileNgModuleMetadata = CompileNgModuleMetadata;
57183 class TransitiveCompileNgModuleMetadata {
57185 this.directivesSet = new Set();
57186 this.directives = [];
57187 this.exportedDirectivesSet = new Set();
57188 this.exportedDirectives = [];
57189 this.pipesSet = new Set();
57191 this.exportedPipesSet = new Set();
57192 this.exportedPipes = [];
57193 this.modulesSet = new Set();
57195 this.entryComponentsSet = new Set();
57196 this.entryComponents = [];
57197 this.providers = [];
57200 addProvider(provider, module) {
57201 this.providers.push({
57202 provider: provider,
57208 if (!this.directivesSet.has(id.reference)) {
57209 this.directivesSet.add(id.reference);
57210 this.directives.push(id);
57214 addExportedDirective(id) {
57215 if (!this.exportedDirectivesSet.has(id.reference)) {
57216 this.exportedDirectivesSet.add(id.reference);
57217 this.exportedDirectives.push(id);
57222 if (!this.pipesSet.has(id.reference)) {
57223 this.pipesSet.add(id.reference);
57224 this.pipes.push(id);
57228 addExportedPipe(id) {
57229 if (!this.exportedPipesSet.has(id.reference)) {
57230 this.exportedPipesSet.add(id.reference);
57231 this.exportedPipes.push(id);
57236 if (!this.modulesSet.has(id.reference)) {
57237 this.modulesSet.add(id.reference);
57238 this.modules.push(id);
57242 addEntryComponent(ec) {
57243 if (!this.entryComponentsSet.has(ec.componentType)) {
57244 this.entryComponentsSet.add(ec.componentType);
57245 this.entryComponents.push(ec);
57251 exports.TransitiveCompileNgModuleMetadata = TransitiveCompileNgModuleMetadata;
57253 function _normalizeArray(obj) {
57257 class ProviderMeta {
57258 constructor(token, {
57266 this.token = token;
57267 this.useClass = useClass || null;
57268 this.useValue = useValue;
57269 this.useExisting = useExisting;
57270 this.useFactory = useFactory || null;
57271 this.dependencies = deps || null;
57272 this.multi = !!multi;
57277 exports.ProviderMeta = ProviderMeta;
57279 function flatten(list) {
57280 return list.reduce((flat, item) => {
57281 const flatItem = Array.isArray(item) ? flatten(item) : item;
57282 return flat.concat(flatItem);
57286 exports.flatten = flatten;
57288 function jitSourceUrl(url) {
57289 // Note: We need 3 "/" so that ng shows up as a separate domain
57290 // in the chrome dev tools.
57291 return url.replace(/(\w+:\/\/[\w:-]+)?(\/+)?/, 'ng:///');
57294 function templateSourceUrl(ngModuleType, compMeta, templateMeta) {
57297 if (templateMeta.isInline) {
57298 if (compMeta.type.reference instanceof static_symbol_1.StaticSymbol) {
57299 // Note: a .ts file might contain multiple components with inline templates,
57300 // so we need to give them unique urls, as these will be used for sourcemaps.
57301 url = `${compMeta.type.reference.filePath}.${compMeta.type.reference.name}.html`;
57303 url = `${identifierName(ngModuleType)}/${identifierName(compMeta.type)}.html`;
57306 url = templateMeta.templateUrl;
57309 return compMeta.type.reference instanceof static_symbol_1.StaticSymbol ? url : jitSourceUrl(url);
57312 exports.templateSourceUrl = templateSourceUrl;
57314 function sharedStylesheetJitUrl(meta, id) {
57315 const pathParts = meta.moduleUrl.split(/\/\\/g);
57316 const baseName = pathParts[pathParts.length - 1];
57317 return jitSourceUrl(`css/${id}${baseName}.ngstyle.js`);
57320 exports.sharedStylesheetJitUrl = sharedStylesheetJitUrl;
57322 function ngModuleJitUrl(moduleMeta) {
57323 return jitSourceUrl(`${identifierName(moduleMeta.type)}/module.ngfactory.js`);
57326 exports.ngModuleJitUrl = ngModuleJitUrl;
57328 function templateJitUrl(ngModuleType, compMeta) {
57329 return jitSourceUrl(`${identifierName(ngModuleType)}/${identifierName(compMeta.type)}.ngfactory.js`);
57332 exports.templateJitUrl = templateJitUrl;
57333 })(compile_metadata);
57335 (function (exports) {
57337 Object.defineProperty(exports, "__esModule", {
57342 * Copyright Google Inc. All Rights Reserved.
57344 * Use of this source code is governed by an MIT-style license that can be
57345 * found in the LICENSE file at https://angular.io/license
57348 const chars$1 = chars;
57349 const compile_metadata_1 = compile_metadata;
57351 class ParseLocation {
57352 constructor(file, offset, line, col) {
57354 this.offset = offset;
57360 return this.offset != null ? `${this.file.url}@${this.line}:${this.col}` : this.file.url;
57364 const source = this.file.content;
57365 const len = source.length;
57366 let offset = this.offset;
57367 let line = this.line;
57368 let col = this.col;
57370 while (offset > 0 && delta < 0) {
57373 const ch = source.charCodeAt(offset);
57375 if (ch == chars$1.$LF) {
57377 const priorLine = source.substr(0, offset - 1).lastIndexOf(String.fromCharCode(chars$1.$LF));
57378 col = priorLine > 0 ? offset - priorLine : offset;
57384 while (offset < len && delta > 0) {
57385 const ch = source.charCodeAt(offset);
57389 if (ch == chars$1.$LF) {
57397 return new ParseLocation(this.file, offset, line, col);
57398 } // Return the source around the location
57399 // Up to `maxChars` or `maxLines` on each side of the location
57402 getContext(maxChars, maxLines) {
57403 const content = this.file.content;
57404 let startOffset = this.offset;
57406 if (startOffset != null) {
57407 if (startOffset > content.length - 1) {
57408 startOffset = content.length - 1;
57411 let endOffset = startOffset;
57415 while (ctxChars < maxChars && startOffset > 0) {
57419 if (content[startOffset] == '\n') {
57420 if (++ctxLines == maxLines) {
57429 while (ctxChars < maxChars && endOffset < content.length - 1) {
57433 if (content[endOffset] == '\n') {
57434 if (++ctxLines == maxLines) {
57441 before: content.substring(startOffset, this.offset),
57442 after: content.substring(this.offset, endOffset + 1)
57451 exports.ParseLocation = ParseLocation;
57453 class ParseSourceFile {
57454 constructor(content, url) {
57455 this.content = content;
57461 exports.ParseSourceFile = ParseSourceFile;
57463 class ParseSourceSpan {
57464 constructor(start, end, details = null) {
57465 this.start = start;
57467 this.details = details;
57471 return this.start.file.content.substring(this.start.offset, this.end.offset);
57476 exports.ParseSourceSpan = ParseSourceSpan;
57477 exports.EMPTY_PARSE_LOCATION = new ParseLocation(new ParseSourceFile('', ''), 0, 0, 0);
57478 exports.EMPTY_SOURCE_SPAN = new ParseSourceSpan(exports.EMPTY_PARSE_LOCATION, exports.EMPTY_PARSE_LOCATION);
57479 var ParseErrorLevel;
57481 (function (ParseErrorLevel) {
57482 ParseErrorLevel[ParseErrorLevel["WARNING"] = 0] = "WARNING";
57483 ParseErrorLevel[ParseErrorLevel["ERROR"] = 1] = "ERROR";
57484 })(ParseErrorLevel = exports.ParseErrorLevel || (exports.ParseErrorLevel = {}));
57487 constructor(span, msg, level = ParseErrorLevel.ERROR) {
57490 this.level = level;
57493 contextualMessage() {
57494 const ctx = this.span.start.getContext(100, 3);
57495 return ctx ? `${this.msg} ("${ctx.before}[${ParseErrorLevel[this.level]} ->]${ctx.after}")` : this.msg;
57499 const details = this.span.details ? `, ${this.span.details}` : '';
57500 return `${this.contextualMessage()}: ${this.span.start}${details}`;
57505 exports.ParseError = ParseError;
57507 function typeSourceSpan(kind, type) {
57508 const moduleUrl = compile_metadata_1.identifierModuleUrl(type);
57509 const sourceFileName = moduleUrl != null ? `in ${kind} ${compile_metadata_1.identifierName(type)} in ${moduleUrl}` : `in ${kind} ${compile_metadata_1.identifierName(type)}`;
57510 const sourceFile = new ParseSourceFile('', sourceFileName);
57511 return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1));
57514 exports.typeSourceSpan = typeSourceSpan;
57516 * Generates Source Span object for a given R3 Type for JIT mode.
57518 * @param kind Component or Directive.
57519 * @param typeName name of the Component or Directive.
57520 * @param sourceUrl reference to Component or Directive source.
57521 * @returns instance of ParseSourceSpan that represent a given Component or Directive.
57524 function r3JitTypeSourceSpan(kind, typeName, sourceUrl) {
57525 const sourceFileName = `in ${kind} ${typeName} in ${sourceUrl}`;
57526 const sourceFile = new ParseSourceFile('', sourceFileName);
57527 return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1));
57530 exports.r3JitTypeSourceSpan = r3JitTypeSourceSpan;
57536 const getLast$2 = getLast_1;
57539 getLeadingAndTrailingHtmlWhitespace,
57541 canHaveInterpolation,
57542 getNodeCssStyleDisplay,
57543 isDanglingSpaceSensitiveNode,
57544 isIndentationSensitiveNode,
57545 isLeadingSpaceSensitiveNode,
57546 isTrailingSpaceSensitiveNode,
57547 isWhitespaceSensitiveNode
57549 const PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeIeConditonalStartEndCommentIntoElementOpeningTag, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addHasHtmComponentClosingTag, addIsSpaceSensitive, mergeSimpleElementIntoText];
57551 function preprocess$3(ast, options) {
57552 const res = ast.map(node => node);
57554 for (const fn of PREPROCESS_PIPELINE) {
57561 function removeIgnorableFirstLf(ast
57565 if (node.type === "element" && node.tagDefinition.ignoreFirstLf && node.children.length > 0 && node.children[0].type === "text" && node.children[0].value[0] === "\n") {
57566 const [text, ...rest] = node.children;
57567 node.setChildren(text.value.length === 1 ? rest : [text.clone({
57568 value: text.value.slice(1)
57574 function mergeIeConditonalStartEndCommentIntoElementOpeningTag(ast
57578 * <!--[if ...]><!--><target><!--<![endif]-->
57580 const isTarget = node => node.type === "element" && node.prev && node.prev.type === "ieConditionalStartComment" && node.prev.sourceSpan.end.offset === node.startSourceSpan.start.offset && node.firstChild && node.firstChild.type === "ieConditionalEndComment" && node.firstChild.sourceSpan.start.offset === node.startSourceSpan.end.offset;
57583 if (node.children) {
57584 const isTargetResults = node.children.map(isTarget);
57586 if (isTargetResults.some(Boolean)) {
57587 const newChildren = [];
57589 for (let i = 0; i < node.children.length; i++) {
57590 const child = node.children[i];
57592 if (isTargetResults[i + 1]) {
57593 // ieConditionalStartComment
57597 if (isTargetResults[i]) {
57598 const ieConditionalStartComment = child.prev;
57599 const ieConditionalEndComment = child.firstChild;
57600 const startSourceSpan = new ParseSourceSpan(ieConditionalStartComment.sourceSpan.start, ieConditionalEndComment.sourceSpan.end);
57601 const sourceSpan = new ParseSourceSpan(startSourceSpan.start, child.sourceSpan.end);
57602 newChildren.push(child.clone({
57603 condition: ieConditionalStartComment.condition,
57606 children: child.children.slice(1)
57611 newChildren.push(child);
57614 node.setChildren(newChildren);
57620 function mergeNodeIntoText(ast, shouldMerge, getValue) {
57622 if (node.children) {
57623 const shouldMergeResults = node.children.map(shouldMerge);
57625 if (shouldMergeResults.some(Boolean)) {
57626 const newChildren = [];
57628 for (let i = 0; i < node.children.length; i++) {
57629 const child = node.children[i];
57631 if (child.type !== "text" && !shouldMergeResults[i]) {
57632 newChildren.push(child);
57636 const newChild = child.type === "text" ? child : child.clone({
57638 value: getValue(child)
57641 if (newChildren.length === 0 || getLast$2(newChildren).type !== "text") {
57642 newChildren.push(newChild);
57646 const lastChild = newChildren.pop();
57647 newChildren.push(lastChild.clone({
57648 value: lastChild.value + newChild.value,
57649 sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, newChild.sourceSpan.end)
57653 node.setChildren(newChildren);
57659 function mergeCdataIntoText(ast
57662 return mergeNodeIntoText(ast, node => node.type === "cdata", node => `<![CDATA[${node.value}]]>`);
57665 function mergeSimpleElementIntoText(ast
57668 const isSimpleElement = node => node.type === "element" && node.attrs.length === 0 && node.children.length === 1 && node.firstChild.type === "text" && !hasHtmlWhitespace(node.children[0].value) && !node.firstChild.hasLeadingSpaces && !node.firstChild.hasTrailingSpaces && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces && node.prev && node.prev.type === "text" && node.next && node.next.type === "text";
57671 if (node.children) {
57672 const isSimpleElementResults = node.children.map(isSimpleElement);
57674 if (isSimpleElementResults.some(Boolean)) {
57675 const newChildren = [];
57677 for (let i = 0; i < node.children.length; i++) {
57678 const child = node.children[i];
57680 if (isSimpleElementResults[i]) {
57681 const lastChild = newChildren.pop();
57682 const nextChild = node.children[++i];
57684 isTrailingSpaceSensitive,
57687 newChildren.push(lastChild.clone({
57688 value: lastChild.value + `<${child.rawName}>` + child.firstChild.value + `</${child.rawName}>` + nextChild.value,
57689 sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, nextChild.sourceSpan.end),
57690 isTrailingSpaceSensitive,
57694 newChildren.push(child);
57698 node.setChildren(newChildren);
57704 function extractInterpolation(ast, options) {
57705 if (options.parser === "html") {
57709 const interpolationRegex = /{{(.+?)}}/s;
57711 if (!canHaveInterpolation(node)) {
57715 const newChildren = [];
57717 for (const child of node.children) {
57718 if (child.type !== "text") {
57719 newChildren.push(child);
57723 let startSourceSpan = child.sourceSpan.start;
57724 let endSourceSpan = null;
57725 const components = child.value.split(interpolationRegex);
57727 for (let i = 0; i < components.length; i++, startSourceSpan = endSourceSpan) {
57728 const value = components[i];
57731 endSourceSpan = startSourceSpan.moveBy(value.length);
57733 if (value.length > 0) {
57737 sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan)
57744 endSourceSpan = startSourceSpan.moveBy(value.length + 4); // `{{` + `}}`
57747 type: "interpolation",
57748 sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan),
57749 children: value.length === 0 ? [] : [{
57752 sourceSpan: new ParseSourceSpan(startSourceSpan.moveBy(2), endSourceSpan.moveBy(-2))
57758 node.setChildren(newChildren);
57762 * - add `hasLeadingSpaces` field
57763 * - add `hasTrailingSpaces` field
57764 * - add `hasDanglingSpaces` field for parent nodes
57765 * - add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
57766 * - remove insensitive whitespaces
57770 const WHITESPACE_NODE = {
57774 function extractWhitespaces(ast
57778 if (!node.children) {
57782 if (node.children.length === 0 || node.children.length === 1 && node.children[0].type === "text" && htmlTrim(node.children[0].value).length === 0) {
57783 node.hasDanglingSpaces = node.children.length > 0;
57784 node.children = [];
57788 const isWhitespaceSensitive = isWhitespaceSensitiveNode(node);
57789 const isIndentationSensitive = isIndentationSensitiveNode(node);
57790 node.setChildren(node.children // extract whitespace nodes
57791 .flatMap(child => {
57792 if (child.type !== "text" || isWhitespaceSensitive) {
57796 const localChildren = [];
57801 } = getLeadingAndTrailingHtmlWhitespace(child.value);
57803 if (leadingWhitespace) {
57804 localChildren.push(WHITESPACE_NODE);
57808 localChildren.push({
57811 sourceSpan: new ParseSourceSpan(child.sourceSpan.start.moveBy(leadingWhitespace.length), child.sourceSpan.end.moveBy(-trailingWhitespace.length))
57815 if (trailingWhitespace) {
57816 localChildren.push(WHITESPACE_NODE);
57819 return localChildren;
57820 }) // set hasLeadingSpaces/hasTrailingSpaces
57821 .map((child, index, children) => {
57822 if (child === WHITESPACE_NODE) {
57826 return Object.assign(Object.assign({}, child), {}, {
57827 hasLeadingSpaces: children[index - 1] === WHITESPACE_NODE,
57828 hasTrailingSpaces: children[index + 1] === WHITESPACE_NODE
57830 }) // filter whitespace nodes
57832 node.isWhitespaceSensitive = isWhitespaceSensitive;
57833 node.isIndentationSensitive = isIndentationSensitive;
57837 function addIsSelfClosing(ast
57840 ast.walk(node => Object.assign(node, {
57841 isSelfClosing: !node.children || node.type === "element" && (node.tagDefinition.isVoid || // self-closing
57842 node.startSourceSpan === node.endSourceSpan)
57846 function addHasHtmComponentClosingTag(ast, options) {
57847 ast.walk(node => node.type !== "element" ? node : Object.assign(node, {
57848 hasHtmComponentClosingTag: node.endSourceSpan && /^<\s*\/\s*\/\s*>$/.test(options.originalText.slice(node.endSourceSpan.start.offset, node.endSourceSpan.end.offset))
57852 function addCssDisplay(ast, options) {
57853 ast.walk(node => Object.assign(node, {
57854 cssDisplay: getNodeCssStyleDisplay(node, options)
57858 * - add `isLeadingSpaceSensitive` field
57859 * - add `isTrailingSpaceSensitive` field
57860 * - add `isDanglingSpaceSensitive` field for parent nodes
57864 function addIsSpaceSensitive(ast, options) {
57866 if (!node.children) {
57870 if (node.children.length === 0) {
57871 node.isDanglingSpaceSensitive = isDanglingSpaceSensitiveNode(node);
57875 node.setChildren(node.children.map(child => Object.assign(Object.assign({}, child), {}, {
57876 isLeadingSpaceSensitive: isLeadingSpaceSensitiveNode(child, options),
57877 isTrailingSpaceSensitive: isTrailingSpaceSensitiveNode(child, options)
57878 })).map((child, index, children) => Object.assign(Object.assign({}, child), {}, {
57879 isLeadingSpaceSensitive: index === 0 ? child.isLeadingSpaceSensitive : children[index - 1].isTrailingSpaceSensitive && child.isLeadingSpaceSensitive,
57880 isTrailingSpaceSensitive: index === children.length - 1 ? child.isTrailingSpaceSensitive : children[index + 1].isLeadingSpaceSensitive && child.isTrailingSpaceSensitive
57885 var printPreprocess$1 = preprocess$3;
57887 function hasPragma$1(text) {
57888 return /^\s*<!--\s*@(?:format|prettier)\s*-->/.test(text);
57891 function insertPragma$3(text) {
57892 return "<!-- @format -->\n\n" + text.replace(/^\s*\n/, "");
57896 hasPragma: hasPragma$1,
57897 insertPragma: insertPragma$3
57900 function locStart$5(node) {
57901 return node.sourceSpan.start.offset;
57904 function locEnd$4(node) {
57905 return node.sourceSpan.end.offset;
57909 locStart: locStart$5,
57914 * @typedef {import("../../document").Doc} Doc
57918 const assert = require$$0__default$3["default"];
57920 isNonEmptyArray: isNonEmptyArray$1
57927 softline: softline$5
57930 replaceTextEndOfLine: replaceTextEndOfLine$5
57934 locStart: locStart$4,
57938 isTextLikeNode: isTextLikeNode$1,
57941 hasPrettierIgnore: hasPrettierIgnore$3,
57942 shouldPreserveContent: shouldPreserveContent$1
57945 function printClosingTag$2(node, options) {
57946 return [node.isSelfClosing ? "" : printClosingTagStart(node, options), printClosingTagEnd$1(node, options)];
57949 function printClosingTagStart(node, options) {
57950 return node.lastChild && needsToBorrowParentClosingTagStartMarker$2(node.lastChild) ? "" : [printClosingTagPrefix(node, options), printClosingTagStartMarker$1(node, options)];
57953 function printClosingTagEnd$1(node, options) {
57954 return (node.next ? needsToBorrowPrevClosingTagEndMarker$3(node.next) : needsToBorrowLastChildClosingTagEndMarker$2(node.parent)) ? "" : [printClosingTagEndMarker$2(node, options), printClosingTagSuffix$4(node, options)];
57957 function printClosingTagPrefix(node, options) {
57958 return needsToBorrowLastChildClosingTagEndMarker$2(node) ? printClosingTagEndMarker$2(node.lastChild, options) : "";
57961 function printClosingTagSuffix$4(node, options) {
57962 return needsToBorrowParentClosingTagStartMarker$2(node) ? printClosingTagStartMarker$1(node.parent, options) : needsToBorrowNextOpeningTagStartMarker$1(node) ? printOpeningTagStartMarker$1(node.next) : "";
57965 function printClosingTagStartMarker$1(node, options) {
57966 assert(!node.isSelfClosing);
57967 /* istanbul ignore next */
57969 if (shouldNotPrintClosingTag(node, options)) {
57973 switch (node.type) {
57974 case "ieConditionalComment":
57978 if (node.hasHtmComponentClosingTag) {
57985 return `</${node.rawName}`;
57989 function printClosingTagEndMarker$2(node, options) {
57990 if (shouldNotPrintClosingTag(node, options)) {
57994 switch (node.type) {
57995 case "ieConditionalComment":
57996 case "ieConditionalEndComment":
57997 return "[endif]-->";
57999 case "ieConditionalStartComment":
58002 case "interpolation":
58006 if (node.isSelfClosing) {
58017 function shouldNotPrintClosingTag(node, options) {
58018 return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$3(node) || shouldPreserveContent$1(node.parent, options));
58021 function needsToBorrowPrevClosingTagEndMarker$3(node) {
58031 return node.prev && node.prev.type !== "docType" && !isTextLikeNode$1(node.prev) && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
58034 function needsToBorrowLastChildClosingTagEndMarker$2(node) {
58042 return node.lastChild && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces && !isTextLikeNode$1(getLastDescendant(node.lastChild)) && !isPreLikeNode(node);
58045 function needsToBorrowParentClosingTagStartMarker$2(node) {
58057 return !node.next && !node.hasTrailingSpaces && node.isTrailingSpaceSensitive && isTextLikeNode$1(getLastDescendant(node));
58060 function needsToBorrowNextOpeningTagStartMarker$1(node) {
58066 return node.next && !isTextLikeNode$1(node.next) && isTextLikeNode$1(node) && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces;
58069 function getPrettierIgnoreAttributeCommentData(value) {
58070 const match = value.trim().match(/^prettier-ignore-attribute(?:\s+(.+))?$/s);
58080 return match[1].split(/\s+/);
58083 function needsToBorrowParentOpeningTagEndMarker$1(node) {
58093 return !node.prev && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
58096 function printAttributes(path, options, print) {
58097 const node = path.getValue();
58099 if (!isNonEmptyArray$1(node.attrs)) {
58100 return node.isSelfClosing ?
58108 const ignoreAttributeData = node.prev && node.prev.type === "comment" && getPrettierIgnoreAttributeCommentData(node.prev.value);
58109 const hasPrettierIgnoreAttribute = typeof ignoreAttributeData === "boolean" ? () => ignoreAttributeData : Array.isArray(ignoreAttributeData) ? attribute => ignoreAttributeData.includes(attribute.rawName) : () => false;
58110 const printedAttributes = path.map(attributePath => {
58111 const attribute = attributePath.getValue();
58112 return hasPrettierIgnoreAttribute(attribute) ? replaceTextEndOfLine$5(options.originalText.slice(locStart$4(attribute), locEnd$3(attribute))) : print();
58114 const forceNotToBreakAttrContent = node.type === "element" && node.fullName === "script" && node.attrs.length === 1 && node.attrs[0].fullName === "src" && node.children.length === 0;
58115 /** @type {Doc[]} */
58117 const parts = [indent$2([forceNotToBreakAttrContent ? " " : line$8, join$5(line$8, printedAttributes)])];
58126 node.firstChild && needsToBorrowParentOpeningTagEndMarker$1(node.firstChild) ||
58133 node.isSelfClosing && needsToBorrowLastChildClosingTagEndMarker$2(node.parent) || forceNotToBreakAttrContent) {
58134 parts.push(node.isSelfClosing ? " " : "");
58136 parts.push(options.bracketSameLine ? node.isSelfClosing ? " " : "" : node.isSelfClosing ? line$8 : softline$5);
58142 function printOpeningTagEnd(node) {
58143 return node.firstChild && needsToBorrowParentOpeningTagEndMarker$1(node.firstChild) ? "" : printOpeningTagEndMarker$1(node);
58146 function printOpeningTag$2(path, options, print) {
58147 const node = path.getValue();
58148 return [printOpeningTagStart$1(node, options), printAttributes(path, options, print), node.isSelfClosing ? "" : printOpeningTagEnd(node)];
58151 function printOpeningTagStart$1(node, options) {
58152 return node.prev && needsToBorrowNextOpeningTagStartMarker$1(node.prev) ? "" : [printOpeningTagPrefix$4(node, options), printOpeningTagStartMarker$1(node)];
58155 function printOpeningTagPrefix$4(node, options) {
58156 return needsToBorrowParentOpeningTagEndMarker$1(node) ? printOpeningTagEndMarker$1(node.parent) : needsToBorrowPrevClosingTagEndMarker$3(node) ? printClosingTagEndMarker$2(node.prev, options) : "";
58159 function printOpeningTagStartMarker$1(node) {
58160 switch (node.type) {
58161 case "ieConditionalComment":
58162 case "ieConditionalStartComment":
58163 return `<!--[if ${node.condition}`;
58165 case "ieConditionalEndComment":
58168 case "interpolation":
58172 return "<!DOCTYPE";
58175 if (node.condition) {
58176 return `<!--[if ${node.condition}]><!--><${node.rawName}`;
58182 return `<${node.rawName}`;
58186 function printOpeningTagEndMarker$1(node) {
58187 assert(!node.isSelfClosing);
58189 switch (node.type) {
58190 case "ieConditionalComment":
58194 if (node.condition) {
58195 return "><!--<![endif]-->";
58206 printClosingTag: printClosingTag$2,
58207 printClosingTagStart,
58208 printClosingTagStartMarker: printClosingTagStartMarker$1,
58209 printClosingTagEndMarker: printClosingTagEndMarker$2,
58210 printClosingTagSuffix: printClosingTagSuffix$4,
58211 printClosingTagEnd: printClosingTagEnd$1,
58212 needsToBorrowLastChildClosingTagEndMarker: needsToBorrowLastChildClosingTagEndMarker$2,
58213 needsToBorrowParentClosingTagStartMarker: needsToBorrowParentClosingTagStartMarker$2,
58214 needsToBorrowPrevClosingTagEndMarker: needsToBorrowPrevClosingTagEndMarker$3,
58215 printOpeningTag: printOpeningTag$2,
58216 printOpeningTagStart: printOpeningTagStart$1,
58217 printOpeningTagPrefix: printOpeningTagPrefix$4,
58218 printOpeningTagStartMarker: printOpeningTagStartMarker$1,
58219 printOpeningTagEndMarker: printOpeningTagEndMarker$1,
58220 needsToBorrowNextOpeningTagStartMarker: needsToBorrowNextOpeningTagStartMarker$1,
58221 needsToBorrowParentOpeningTagEndMarker: needsToBorrowParentOpeningTagEndMarker$1
58224 var parseSrcset$1 = {exports: {}};
58229 * By Alex Bell | MIT License
58231 * JS Parser for the string value that appears in markup <img srcset="here">
58233 * @returns Array [{url: _, d: _, w: _, h:_}, ...]
58235 * Based super duper closely on the reference algorithm at:
58236 * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute
58238 * Most comments are copied in directly from the spec
58239 * (except for comments in parens).
58242 (function (module) {
58243 (function (root, factory) {
58244 if (module.exports) {
58245 // Node. Does not work with strict CommonJS, but
58246 // only CommonJS-like environments that support module.exports,
58248 module.exports = factory();
58250 // Browser globals (root is window)
58251 root.parseSrcset = factory();
58253 })(this, function () {
58254 // 1. Let input be the value passed to this algorithm.
58255 return function (input, options) {
58256 var logger = options && options.logger || console; // UTILITY FUNCTIONS
58257 // Manual is faster than RegEx
58258 // http://bjorn.tipling.com/state-and-regular-expressions-in-javascript
58259 // http://jsperf.com/whitespace-character/5
58261 function isSpace(c) {
58262 return c === "\u0020" || // space
58263 c === "\u0009" || // horizontal tab
58264 c === "\u000A" || // new line
58265 c === "\u000C" || // form feed
58266 c === "\u000D"; // carriage return
58269 function collectCharacters(regEx) {
58271 match = regEx.exec(input.substring(pos));
58275 pos += chars.length;
58280 var inputLength = input.length,
58281 // (Don't use \s, to avoid matching non-breaking space)
58282 regexLeadingSpaces = /^[ \t\n\r\u000c]+/,
58283 regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/,
58284 regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/,
58285 regexTrailingCommas = /[,]+$/,
58286 regexNonNegativeInteger = /^\d+$/,
58287 // ( Positive or negative or unsigned integers or decimals, without or without exponents.
58288 // Must include at least one digit.
58289 // According to spec tests any decimal point must be followed by a digit.
58290 // No leading plus sign is allowed.)
58291 // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number
58292 regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,
58298 // 2. Let position be a pointer into input, initially pointing at the start
58301 // 3. Let candidates be an initially empty source set.
58302 candidates = []; // 4. Splitting loop: Collect a sequence of characters that are space
58303 // characters or U+002C COMMA characters. If any U+002C COMMA characters
58304 // were collected, that is a parse error.
58307 collectCharacters(regexLeadingCommasOrSpaces); // 5. If position is past the end of input, return candidates and abort these steps.
58309 if (pos >= inputLength) {
58310 return candidates; // (we're done, this is the sole return path)
58311 } // 6. Collect a sequence of characters that are not space characters,
58312 // and let that be url.
58315 url = collectCharacters(regexLeadingNotSpaces); // 7. Let descriptors be a new empty list.
58317 descriptors = []; // 8. If url ends with a U+002C COMMA character (,), follow these substeps:
58318 // (1). Remove all trailing U+002C COMMA characters from url. If this removed
58319 // more than one character, that is a parse error.
58321 if (url.slice(-1) === ",") {
58322 url = url.replace(regexTrailingCommas, ""); // (Jump ahead to step 9 to skip tokenization and just push the candidate).
58324 parseDescriptors(); // Otherwise, follow these substeps:
58327 } // (close else of step 8)
58328 // 16. Return to the step labeled splitting loop.
58330 } // (Close of big while loop.)
58333 * Tokenizes descriptor properties prior to parsing
58334 * Returns undefined.
58338 function tokenize() {
58339 // 8.1. Descriptor tokeniser: Skip whitespace
58340 collectCharacters(regexLeadingSpaces); // 8.2. Let current descriptor be the empty string.
58342 currentDescriptor = ""; // 8.3. Let state be in descriptor.
58344 state = "in descriptor";
58347 // 8.4. Let c be the character at position.
58348 c = input.charAt(pos); // Do the following depending on the value of state.
58349 // For the purpose of this step, "EOF" is a special character representing
58350 // that position is past the end of input.
58353 if (state === "in descriptor") {
58354 // Do the following, depending on the value of c:
58356 // If current descriptor is not empty, append current descriptor to
58357 // descriptors and let current descriptor be the empty string.
58358 // Set state to after descriptor.
58360 if (currentDescriptor) {
58361 descriptors.push(currentDescriptor);
58362 currentDescriptor = "";
58363 state = "after descriptor";
58364 } // U+002C COMMA (,)
58365 // Advance position to the next character in input. If current descriptor
58366 // is not empty, append current descriptor to descriptors. Jump to the step
58367 // labeled descriptor parser.
58369 } else if (c === ",") {
58372 if (currentDescriptor) {
58373 descriptors.push(currentDescriptor);
58376 parseDescriptors();
58377 return; // U+0028 LEFT PARENTHESIS (()
58378 // Append c to current descriptor. Set state to in parens.
58379 } else if (c === "\u0028") {
58380 currentDescriptor = currentDescriptor + c;
58381 state = "in parens"; // EOF
58382 // If current descriptor is not empty, append current descriptor to
58383 // descriptors. Jump to the step labeled descriptor parser.
58384 } else if (c === "") {
58385 if (currentDescriptor) {
58386 descriptors.push(currentDescriptor);
58389 parseDescriptors();
58390 return; // Anything else
58391 // Append c to current descriptor.
58393 currentDescriptor = currentDescriptor + c;
58394 } // (end "in descriptor"
58397 } else if (state === "in parens") {
58398 // U+0029 RIGHT PARENTHESIS ())
58399 // Append c to current descriptor. Set state to in descriptor.
58401 currentDescriptor = currentDescriptor + c;
58402 state = "in descriptor"; // EOF
58403 // Append current descriptor to descriptors. Jump to the step labeled
58404 // descriptor parser.
58405 } else if (c === "") {
58406 descriptors.push(currentDescriptor);
58407 parseDescriptors();
58408 return; // Anything else
58409 // Append c to current descriptor.
58411 currentDescriptor = currentDescriptor + c;
58412 } // After descriptor
58414 } else if (state === "after descriptor") {
58415 // Do the following, depending on the value of c:
58416 // Space character: Stay in this state.
58417 if (isSpace(c)) ; else if (c === "") {
58418 parseDescriptors();
58419 return; // Anything else
58420 // Set state to in descriptor. Set position to the previous character in input.
58422 state = "in descriptor";
58425 } // Advance position to the next character in input.
58428 pos += 1; // Repeat this step.
58429 } // (close while true loop)
58433 * Adds descriptor properties to a candidate, pushes to the candidates array
58434 * @return undefined
58436 // Declared outside of the while loop so that it's only created once.
58439 function parseDescriptors() {
58440 // 9. Descriptor parser: Let error be no.
58441 var pError = false,
58442 // 10. Let width be absent.
58443 // 11. Let density be absent.
58444 // 12. Let future-compat-h be absent. (We're implementing it now as h)
58454 floatVal; // 13. For each descriptor in descriptors, run the appropriate set of steps
58455 // from the following list:
58457 for (i = 0; i < descriptors.length; i++) {
58458 desc = descriptors[i];
58459 lastChar = desc[desc.length - 1];
58460 value = desc.substring(0, desc.length - 1);
58461 intVal = parseInt(value, 10);
58462 floatVal = parseFloat(value); // If the descriptor consists of a valid non-negative integer followed by
58463 // a U+0077 LATIN SMALL LETTER W character
58465 if (regexNonNegativeInteger.test(value) && lastChar === "w") {
58466 // If width and density are not both absent, then let error be yes.
58469 } // Apply the rules for parsing non-negative integers to the descriptor.
58470 // If the result is zero, let error be yes.
58471 // Otherwise, let width be the result.
58474 if (intVal === 0) {
58478 } // If the descriptor consists of a valid floating-point number followed by
58479 // a U+0078 LATIN SMALL LETTER X character
58481 } else if (regexFloatingPoint.test(value) && lastChar === "x") {
58482 // If width, density and future-compat-h are not all absent, then let error
58486 } // Apply the rules for parsing floating-point number values to the descriptor.
58487 // If the result is less than zero, let error be yes. Otherwise, let density
58491 if (floatVal < 0) {
58495 } // If the descriptor consists of a valid non-negative integer followed by
58496 // a U+0068 LATIN SMALL LETTER H character
58498 } else if (regexNonNegativeInteger.test(value) && lastChar === "h") {
58499 // If height and density are not both absent, then let error be yes.
58502 } // Apply the rules for parsing non-negative integers to the descriptor.
58503 // If the result is zero, let error be yes. Otherwise, let future-compat-h
58507 if (intVal === 0) {
58511 } // Anything else, Let error be yes.
58516 } // (close step 13 for loop)
58517 // 15. If error is still no, then append a new image source to candidates whose
58518 // URL is url, associated with a width width if not absent and a pixel
58519 // density density if not absent. Otherwise, there is a parse error.
58523 candidate.url = url;
58537 candidates.push(candidate);
58538 } else if (logger && logger.error) {
58539 logger.error("Invalid srcset descriptor found in '" + input + "' at '" + desc + "'.");
58541 } // (close parseDescriptors fn)
58547 const parseSrcset = parseSrcset$1.exports;
58550 ifBreak: ifBreak$4,
58556 function printImgSrcset$1(value) {
58557 const srcset = parseSrcset(value, {
58560 throw new Error(message);
58565 const hasW = srcset.some(({
58568 const hasH = srcset.some(({
58571 const hasX = srcset.some(({
58575 if (hasW + hasH + hasX > 1) {
58576 throw new Error("Mixed descriptor in srcset is not supported");
58579 const key = hasW ? "w" : hasH ? "h" : "d";
58580 const unit = hasW ? "w" : hasH ? "h" : "x";
58582 const getMax = values => Math.max(...values);
58584 const urls = srcset.map(src => src.url);
58585 const maxUrlLength = getMax(urls.map(url => url.length));
58586 const descriptors = srcset.map(src => src[key]).map(descriptor => descriptor ? descriptor.toString() : "");
58587 const descriptorLeftLengths = descriptors.map(descriptor => {
58588 const index = descriptor.indexOf(".");
58589 return index === -1 ? descriptor.length : index;
58591 const maxDescriptorLeftLength = getMax(descriptorLeftLengths);
58592 return join$4([",", line$7], urls.map((url, index) => {
58593 const parts = [url];
58594 const descriptor = descriptors[index];
58597 const urlPadding = maxUrlLength - url.length + 1;
58598 const descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index];
58599 const alignment = " ".repeat(urlPadding + descriptorPadding);
58600 parts.push(ifBreak$4(alignment, " "), descriptor + unit);
58607 function printClassNames$1(value) {
58608 return value.trim().split(/\s+/).join(" ");
58611 var syntaxAttribute = {
58612 printImgSrcset: printImgSrcset$1,
58613 printClassNames: printClassNames$1
58622 * v-for="... in ..."
58623 * v-for="... of ..."
58624 * v-for="(..., ...) in ..."
58625 * v-for="(..., ...) of ..."
58628 function printVueFor$1(value, textToDoc) {
58633 } = parseVueFor(value);
58634 return [group$6(textToDoc(`function _(${left}) {}`, {
58636 __isVueForBindingLeft: true
58637 })), " ", operator, " ", textToDoc(right, {
58638 parser: "__js_expression"
58640 stripTrailingHardline: true
58642 } // modified from https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/parser/index.js#L370-L387
58645 function parseVueFor(value) {
58646 const forAliasRE = /(.*?)\s+(in|of)\s+(.*)/s;
58647 const forIteratorRE = /,([^,\]}]*)(?:,([^,\]}]*))?$/;
58648 const stripParensRE = /^\(|\)$/g;
58649 const inMatch = value.match(forAliasRE);
58656 res.for = inMatch[3].trim();
58657 const alias = inMatch[1].trim().replace(stripParensRE, "");
58658 const iteratorMatch = alias.match(forIteratorRE);
58660 if (iteratorMatch) {
58661 res.alias = alias.replace(forIteratorRE, "");
58662 res.iterator1 = iteratorMatch[1].trim();
58664 if (iteratorMatch[2]) {
58665 res.iterator2 = iteratorMatch[2].trim();
58672 left: `${[res.alias, res.iterator1, res.iterator2].filter(Boolean).join(",")}`,
58673 operator: inMatch[2],
58678 function printVueBindings$1(value, textToDoc) {
58679 return textToDoc(`function _(${value}) {}`, {
58681 __isVueBindings: true
58685 function isVueEventBindingExpression$1(eventBindingValue) {
58686 // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/codegen/events.js#L3-L4
58687 // arrow function or anonymous function
58688 const fnExpRE = /^(?:[\w$]+|\([^)]*?\))\s*=>|^function\s*\(/; // simple member expression chain (a, a.b, a['b'], a["b"], a[0], a[b])
58690 const simplePathRE = /^[$A-Z_a-z][\w$]*(?:\.[$A-Z_a-z][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[$A-Z_a-z][\w$]*])*$/; // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104
58692 const value = eventBindingValue.trim();
58693 return fnExpRE.test(value) || simplePathRE.test(value);
58697 isVueEventBindingExpression: isVueEventBindingExpression$1,
58698 printVueFor: printVueFor$1,
58699 printVueBindings: printVueBindings$1
58703 needsToBorrowParentClosingTagStartMarker: needsToBorrowParentClosingTagStartMarker$1,
58704 printClosingTagStartMarker,
58705 needsToBorrowLastChildClosingTagEndMarker: needsToBorrowLastChildClosingTagEndMarker$1,
58706 printClosingTagEndMarker: printClosingTagEndMarker$1,
58707 needsToBorrowParentOpeningTagEndMarker,
58708 printOpeningTagEndMarker
58711 function getNodeContent$2(node, options) {
58712 let start = node.startSourceSpan.end.offset;
58714 if (node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild)) {
58715 start -= printOpeningTagEndMarker(node).length;
58718 let end = node.endSourceSpan.start.offset;
58720 if (node.lastChild && needsToBorrowParentClosingTagStartMarker$1(node.lastChild)) {
58721 end += printClosingTagStartMarker(node, options).length;
58722 } else if (needsToBorrowLastChildClosingTagEndMarker$1(node)) {
58723 end -= printClosingTagEndMarker$1(node.lastChild, options).length;
58726 return options.originalText.slice(start, end);
58729 var getNodeContent_1 = getNodeContent$2;
58733 breakParent: breakParent$3,
58735 hardline: hardline$6,
58739 softline: softline$4
58743 replaceTextEndOfLine: replaceTextEndOfLine$4
58746 const printFrontMatter = print_1;
58748 printClosingTag: printClosingTag$1,
58749 printClosingTagSuffix: printClosingTagSuffix$3,
58750 needsToBorrowPrevClosingTagEndMarker: needsToBorrowPrevClosingTagEndMarker$2,
58751 printOpeningTagPrefix: printOpeningTagPrefix$3,
58752 printOpeningTag: printOpeningTag$1
58757 } = syntaxAttribute;
58761 isVueEventBindingExpression
58764 isScriptLikeTag: isScriptLikeTag$1,
58767 htmlTrimPreserveIndentation,
58769 unescapeQuoteEntities: unescapeQuoteEntities$1,
58770 isVueSlotAttribute,
58771 isVueSfcBindingsAttribute,
58772 getTextValueParts: getTextValueParts$1
58774 const getNodeContent$1 = getNodeContent_1;
58776 function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
58777 const isKeyMatched = patterns => new RegExp(patterns.join("|")).test(node.fullName);
58779 const getValue = () => unescapeQuoteEntities$1(node.value);
58781 let shouldHug = false;
58783 const __onHtmlBindingRoot = (root, options) => {
58784 const rootNode = root.type === "NGRoot" ? root.node.type === "NGMicrosyntax" && root.node.body.length === 1 && root.node.body[0].type === "NGMicrosyntaxExpression" ? root.node.body[0].expression : root.node : root.type === "JsExpressionRoot" ? root.node : root;
58786 if (rootNode && (rootNode.type === "ObjectExpression" || rootNode.type === "ArrayExpression" || options.parser === "__vue_expression" && (rootNode.type === "TemplateLiteral" || rootNode.type === "StringLiteral"))) {
58791 const printHug = doc => group$5(doc);
58793 const printExpand = (doc, canHaveTrailingWhitespace = true) => group$5([indent$1([softline$4, doc]), canHaveTrailingWhitespace ? softline$4 : ""]);
58795 const printMaybeHug = doc => shouldHug ? printHug(doc) : printExpand(doc);
58797 const attributeTextToDoc = (code, opts) => originalTextToDoc(code, Object.assign({
58798 __onHtmlBindingRoot,
58799 __embeddedInHtml: true
58801 stripTrailingHardline: true
58804 if (node.fullName === "srcset" && (node.parent.fullName === "img" || node.parent.fullName === "source")) {
58805 return printExpand(printImgSrcset(getValue()));
58808 if (node.fullName === "class" && !options.parentParser) {
58809 const value = getValue();
58811 if (!value.includes("{{")) {
58812 return printClassNames(value);
58816 if (node.fullName === "style" && !options.parentParser) {
58817 const value = getValue();
58819 if (!value.includes("{{")) {
58820 return printExpand(attributeTextToDoc(value, {
58822 __isHTMLStyleAttribute: true
58827 if (options.parser === "vue") {
58828 if (node.fullName === "v-for") {
58829 return printVueFor(getValue(), attributeTextToDoc);
58832 if (isVueSlotAttribute(node) || isVueSfcBindingsAttribute(node, options)) {
58833 return printVueBindings(getValue(), attributeTextToDoc);
58836 * @click="jsStatement"
58837 * @click="jsExpression"
58838 * v-on:click="jsStatement"
58839 * v-on:click="jsExpression"
58843 const vueEventBindingPatterns = ["^@", "^v-on:"];
58845 * :class="vueExpression"
58846 * v-bind:id="vueExpression"
58849 const vueExpressionBindingPatterns = ["^:", "^v-bind:"];
58851 * v-if="jsExpression"
58854 const jsExpressionBindingPatterns = ["^v-"];
58856 if (isKeyMatched(vueEventBindingPatterns)) {
58857 const value = getValue();
58858 return printMaybeHug(attributeTextToDoc(value, {
58859 parser: isVueEventBindingExpression(value) ? "__js_expression" : "__vue_event_binding"
58863 if (isKeyMatched(vueExpressionBindingPatterns)) {
58864 return printMaybeHug(attributeTextToDoc(getValue(), {
58865 parser: "__vue_expression"
58869 if (isKeyMatched(jsExpressionBindingPatterns)) {
58870 return printMaybeHug(attributeTextToDoc(getValue(), {
58871 parser: "__js_expression"
58876 if (options.parser === "angular") {
58877 const ngTextToDoc = (code, opts) => // angular does not allow trailing comma
58878 attributeTextToDoc(code, Object.assign(Object.assign({}, opts), {}, {
58879 trailingComma: "none"
58882 * *directive="angularDirective"
58886 const ngDirectiveBindingPatterns = ["^\\*"];
58888 * (click)="angularStatement"
58889 * on-click="angularStatement"
58892 const ngStatementBindingPatterns = ["^\\(.+\\)$", "^on-"];
58894 * [target]="angularExpression"
58895 * bind-target="angularExpression"
58896 * [(target)]="angularExpression"
58897 * bindon-target="angularExpression"
58900 const ngExpressionBindingPatterns = ["^\\[.+\\]$", "^bind(on)?-", // Unofficial rudimentary support for some of the most used directives of AngularJS 1.x
58901 "^ng-(if|show|hide|class|style)$"];
58903 * i18n="longDescription"
58904 * i18n-attr="longDescription"
58907 const ngI18nPatterns = ["^i18n(-.+)?$"];
58909 if (isKeyMatched(ngStatementBindingPatterns)) {
58910 return printMaybeHug(ngTextToDoc(getValue(), {
58911 parser: "__ng_action"
58915 if (isKeyMatched(ngExpressionBindingPatterns)) {
58916 return printMaybeHug(ngTextToDoc(getValue(), {
58917 parser: "__ng_binding"
58921 if (isKeyMatched(ngI18nPatterns)) {
58922 const value = getValue().trim();
58923 return printExpand(fill$3(getTextValueParts$1(node, value)), !value.includes("@@"));
58926 if (isKeyMatched(ngDirectiveBindingPatterns)) {
58927 return printMaybeHug(ngTextToDoc(getValue(), {
58928 parser: "__ng_directive"
58932 const interpolationRegex = /{{(.+?)}}/s;
58933 const value = getValue();
58935 if (interpolationRegex.test(value)) {
58938 for (const [index, part] of value.split(interpolationRegex).entries()) {
58939 if (index % 2 === 0) {
58940 parts.push(replaceTextEndOfLine$4(part));
58943 parts.push(group$5(["{{", indent$1([line$6, ngTextToDoc(part, {
58944 parser: "__ng_interpolation",
58945 __isInHtmlInterpolation: true // to avoid unexpected `}}`
58947 })]), line$6, "}}"]));
58949 parts.push("{{", replaceTextEndOfLine$4(part), "}}");
58954 return group$5(parts);
58961 function embed$3(path, print, textToDoc, options) {
58962 const node = path.getValue();
58964 switch (node.type) {
58967 if (isScriptLikeTag$1(node) || node.type === "interpolation") {
58968 // Fall through to "text"
58972 if (!node.isSelfClosing && isVueNonHtmlBlock(node, options)) {
58973 const parser = inferScriptParser(node, options);
58979 const content = getNodeContent$1(node, options);
58980 let isEmpty = /^\s*$/.test(content);
58984 doc = textToDoc(htmlTrimPreserveIndentation(content), {
58986 __embeddedInHtml: true
58988 stripTrailingHardline: true
58990 isEmpty = doc === "";
58993 return [printOpeningTagPrefix$3(node, options), group$5(printOpeningTag$1(path, options, print)), isEmpty ? "" : hardline$6, doc, isEmpty ? "" : hardline$6, printClosingTag$1(node, options), printClosingTagSuffix$3(node, options)];
59001 if (isScriptLikeTag$1(node.parent)) {
59002 const parser = inferScriptParser(node.parent);
59005 const value = parser === "markdown" ? dedentString(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
59006 const textToDocOptions = {
59008 __embeddedInHtml: true
59011 if (options.parser === "html" && parser === "babel") {
59012 let sourceType = "script";
59017 if (attrMap && (attrMap.type === "module" || attrMap.type === "text/babel" && attrMap["data-type"] === "module")) {
59018 sourceType = "module";
59021 textToDocOptions.__babelSourceType = sourceType;
59024 return [breakParent$3, printOpeningTagPrefix$3(node, options), textToDoc(value, textToDocOptions, {
59025 stripTrailingHardline: true
59026 }), printClosingTagSuffix$3(node, options)];
59028 } else if (node.parent.type === "interpolation") {
59029 const textToDocOptions = {
59030 __isInHtmlInterpolation: true,
59031 // to avoid unexpected `}}`
59032 __embeddedInHtml: true
59035 if (options.parser === "angular") {
59036 textToDocOptions.parser = "__ng_interpolation";
59037 textToDocOptions.trailingComma = "none";
59038 } else if (options.parser === "vue") {
59039 textToDocOptions.parser = "__vue_expression";
59041 textToDocOptions.parser = "__js_expression";
59044 return [indent$1([line$6, textToDoc(node.value, textToDocOptions, {
59045 stripTrailingHardline: true
59046 })]), node.parent.next && needsToBorrowPrevClosingTagEndMarker$2(node.parent.next) ? " " : line$6];
59056 } // lit-html: html`<my-element obj=${obj}></my-element>`
59059 if (/^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
59060 return [node.rawName, "=", node.value];
59061 } // lwc: html`<my-element data-for={value}></my-element>`
59064 if (options.parser === "lwc") {
59065 const interpolationRegex = /^{.*}$/s;
59067 if (interpolationRegex.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
59068 return [node.rawName, "=", node.value];
59072 const embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, (code, opts) => // strictly prefer single quote to avoid unnecessary html entity escape
59073 textToDoc(code, Object.assign({
59074 __isInHtmlAttribute: true,
59075 __embeddedInHtml: true
59077 stripTrailingHardline: true
59080 if (embeddedAttributeValueDoc) {
59081 return [node.rawName, '="', group$5(mapDoc(embeddedAttributeValueDoc, doc => typeof doc === "string" ? doc.replace(/"/g, """) : doc)), '"'];
59087 case "front-matter":
59088 return printFrontMatter(node, textToDoc);
59092 var embed_1$1 = embed$3;
59096 breakParent: breakParent$2,
59098 ifBreak: ifBreak$3,
59100 softline: softline$3,
59101 hardline: hardline$5
59104 replaceTextEndOfLine: replaceTextEndOfLine$3
59108 locStart: locStart$3,
59112 forceBreakChildren,
59113 forceNextEmptyLine,
59115 hasPrettierIgnore: hasPrettierIgnore$2,
59116 preferHardlineAsLeadingSpaces
59119 printOpeningTagPrefix: printOpeningTagPrefix$2,
59120 needsToBorrowNextOpeningTagStartMarker,
59121 printOpeningTagStartMarker,
59122 needsToBorrowPrevClosingTagEndMarker: needsToBorrowPrevClosingTagEndMarker$1,
59123 printClosingTagEndMarker,
59124 printClosingTagSuffix: printClosingTagSuffix$2,
59125 needsToBorrowParentClosingTagStartMarker
59128 function printChild(childPath, options, print) {
59129 const child = childPath.getValue();
59131 if (hasPrettierIgnore$2(child)) {
59132 return [printOpeningTagPrefix$2(child, options), ...replaceTextEndOfLine$3(options.originalText.slice(locStart$3(child) + (child.prev && needsToBorrowNextOpeningTagStartMarker(child.prev) ? printOpeningTagStartMarker(child).length : 0), locEnd$2(child) - (child.next && needsToBorrowPrevClosingTagEndMarker$1(child.next) ? printClosingTagEndMarker(child, options).length : 0))), printClosingTagSuffix$2(child, options)];
59138 function printBetweenLine(prevNode, nextNode) {
59139 return isTextLikeNode(prevNode) && isTextLikeNode(nextNode) ? prevNode.isTrailingSpaceSensitive ? prevNode.hasTrailingSpaces ? preferHardlineAsLeadingSpaces(nextNode) ? hardline$5 : line$5 : "" : preferHardlineAsLeadingSpaces(nextNode) ? hardline$5 : softline$3 : needsToBorrowNextOpeningTagStartMarker(prevNode) && (hasPrettierIgnore$2(nextNode) ||
59145 nextNode.firstChild ||
59151 nextNode.isSelfClosing ||
59157 nextNode.type === "element" && nextNode.attrs.length > 0) ||
59164 prevNode.type === "element" && prevNode.isSelfClosing && needsToBorrowPrevClosingTagEndMarker$1(nextNode) ? "" : !nextNode.isLeadingSpaceSensitive || preferHardlineAsLeadingSpaces(nextNode) ||
59166 * Want to write us a letter? Use our<a
59167 * ><b><a>mailing address</a></b></a
59171 needsToBorrowPrevClosingTagEndMarker$1(nextNode) && prevNode.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild) && prevNode.lastChild.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild.lastChild) ? hardline$5 : nextNode.hasLeadingSpaces ? line$5 : softline$3;
59174 function printChildren$3(path, options, print) {
59175 const node = path.getValue();
59177 if (forceBreakChildren(node)) {
59178 return [breakParent$2, ...path.map(childPath => {
59179 const childNode = childPath.getValue();
59180 const prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode);
59181 return [!prevBetweenLine ? "" : [prevBetweenLine, forceNextEmptyLine(childNode.prev) ? hardline$5 : ""], printChild(childPath, options, print)];
59185 const groupIds = node.children.map(() => Symbol(""));
59186 return path.map((childPath, childIndex) => {
59187 const childNode = childPath.getValue();
59189 if (isTextLikeNode(childNode)) {
59190 if (childNode.prev && isTextLikeNode(childNode.prev)) {
59191 const prevBetweenLine = printBetweenLine(childNode.prev, childNode);
59193 if (prevBetweenLine) {
59194 if (forceNextEmptyLine(childNode.prev)) {
59195 return [hardline$5, hardline$5, printChild(childPath, options, print)];
59198 return [prevBetweenLine, printChild(childPath, options, print)];
59202 return printChild(childPath, options, print);
59205 const prevParts = [];
59206 const leadingParts = [];
59207 const trailingParts = [];
59208 const nextParts = [];
59209 const prevBetweenLine = childNode.prev ? printBetweenLine(childNode.prev, childNode) : "";
59210 const nextBetweenLine = childNode.next ? printBetweenLine(childNode, childNode.next) : "";
59212 if (prevBetweenLine) {
59213 if (forceNextEmptyLine(childNode.prev)) {
59214 prevParts.push(hardline$5, hardline$5);
59215 } else if (prevBetweenLine === hardline$5) {
59216 prevParts.push(hardline$5);
59218 if (isTextLikeNode(childNode.prev)) {
59219 leadingParts.push(prevBetweenLine);
59221 leadingParts.push(ifBreak$3("", softline$3, {
59222 groupId: groupIds[childIndex - 1]
59228 if (nextBetweenLine) {
59229 if (forceNextEmptyLine(childNode)) {
59230 if (isTextLikeNode(childNode.next)) {
59231 nextParts.push(hardline$5, hardline$5);
59233 } else if (nextBetweenLine === hardline$5) {
59234 if (isTextLikeNode(childNode.next)) {
59235 nextParts.push(hardline$5);
59238 trailingParts.push(nextBetweenLine);
59242 return [...prevParts, group$4([...leadingParts, group$4([printChild(childPath, options, print), ...trailingParts], {
59243 id: groupIds[childIndex]
59244 })]), ...nextParts];
59249 printChildren: printChildren$3
59254 breakParent: breakParent$1,
59255 dedentToRoot: dedentToRoot$1,
59257 ifBreak: ifBreak$2,
59261 softline: softline$2
59264 replaceTextEndOfLine: replaceTextEndOfLine$2
59267 const getNodeContent = getNodeContent_1;
59269 shouldPreserveContent,
59276 printOpeningTagPrefix: printOpeningTagPrefix$1,
59278 printClosingTagSuffix: printClosingTagSuffix$1,
59280 needsToBorrowPrevClosingTagEndMarker,
59281 needsToBorrowLastChildClosingTagEndMarker
59284 printChildren: printChildren$2
59287 function printElement$1(path, options, print) {
59288 const node = path.getValue();
59290 if (shouldPreserveContent(node, options)) {
59291 return [printOpeningTagPrefix$1(node, options), group$3(printOpeningTag(path, options, print)), ...replaceTextEndOfLine$2(getNodeContent(node, options)), ...printClosingTag(node, options), printClosingTagSuffix$1(node, options)];
59302 * exception: break if the opening tag breaks
59315 const shouldHugContent = node.children.length === 1 && node.firstChild.type === "interpolation" && node.firstChild.isLeadingSpaceSensitive && !node.firstChild.hasLeadingSpaces && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces;
59316 const attrGroupId = Symbol("element-attr-group-id");
59318 const printTag = doc => group$3([group$3(printOpeningTag(path, options, print), {
59320 }), doc, printClosingTag(node, options)]);
59322 const printChildrenDoc = childrenDoc => {
59323 if (shouldHugContent) {
59324 return indentIfBreak(childrenDoc, {
59325 groupId: attrGroupId
59329 if ((isScriptLikeTag(node) || isVueCustomBlock(node, options)) && node.parent.type === "root" && options.parser === "vue" && !options.vueIndentScriptAndStyle) {
59330 return childrenDoc;
59333 return indent(childrenDoc);
59336 const printLineBeforeChildren = () => {
59337 if (shouldHugContent) {
59338 return ifBreak$2(softline$2, "", {
59339 groupId: attrGroupId
59343 if (node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive) {
59347 if (node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) {
59348 return dedentToRoot$1(softline$2);
59354 const printLineAfterChildren = () => {
59355 const needsToBorrow = node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent);
59357 if (needsToBorrow) {
59358 if (node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive) {
59365 if (shouldHugContent) {
59366 return ifBreak$2(softline$2, "", {
59367 groupId: attrGroupId
59371 if (node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive) {
59375 if ((node.lastChild.type === "comment" || node.lastChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) && new RegExp(`\\n[\\t ]{${options.tabWidth * countParents(path, node => node.parent && node.parent.type !== "root")}}$`).test(node.lastChild.value)) {
59382 if (node.children.length === 0) {
59383 return printTag(node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$4 : "");
59386 return printTag([forceBreakContent(node) ? breakParent$1 : "", printChildrenDoc([printLineBeforeChildren(), printChildren$2(path, options, print)]), printLineAfterChildren()]);
59390 printElement: printElement$1
59394 * @typedef {import("../document").Doc} Doc
59402 hardline: hardline$4,
59403 literalline: literalline$2
59407 getDocParts: getDocParts$2,
59409 replaceTextEndOfLine: replaceTextEndOfLine$1
59412 const clean$1 = clean_1;
59415 unescapeQuoteEntities,
59418 const preprocess$2 = printPreprocess$1;
59420 insertPragma: insertPragma$2
59423 locStart: locStart$2,
59426 const embed$2 = embed_1$1;
59428 printClosingTagSuffix,
59429 printClosingTagEnd,
59430 printOpeningTagPrefix,
59431 printOpeningTagStart
59437 printChildren: printChildren$1
59440 function genericPrint$1(path, options, print) {
59441 const node = path.getValue();
59443 switch (node.type) {
59444 case "front-matter":
59445 return replaceTextEndOfLine$1(node.raw);
59448 if (options.__onHtmlRoot) {
59449 options.__onHtmlRoot(node);
59450 } // use original concat to not break stripTrailingHardline
59453 return [group$2(printChildren$1(path, options, print)), hardline$4];
59456 case "ieConditionalComment":
59458 return printElement(path, options, print);
59461 case "ieConditionalStartComment":
59462 case "ieConditionalEndComment":
59463 return [printOpeningTagStart(node), printClosingTagEnd(node)];
59465 case "interpolation":
59466 return [printOpeningTagStart(node, options), ...path.map(print, "children"), printClosingTagEnd(node, options)];
59470 if (node.parent.type === "interpolation") {
59471 // replace the trailing literalline with hardline for better readability
59472 const trailingNewlineRegex = /\n[^\S\n]*?$/;
59473 const hasTrailingNewline = trailingNewlineRegex.test(node.value);
59474 const value = hasTrailingNewline ? node.value.replace(trailingNewlineRegex, "") : node.value;
59475 return [...replaceTextEndOfLine$1(value), hasTrailingNewline ? hardline$4 : ""];
59478 const printed = cleanDoc([printOpeningTagPrefix(node, options), ...getTextValueParts(node), printClosingTagSuffix(node, options)]);
59480 if (isConcat(printed) || printed.type === "fill") {
59481 return fill$2(getDocParts$2(printed));
59483 /* istanbul ignore next */
59490 return [group$2([printOpeningTagStart(node, options), " ", node.value.replace(/^html\b/i, "html").replace(/\s+/g, " ")]), printClosingTagEnd(node, options)];
59494 return [printOpeningTagPrefix(node, options), ...replaceTextEndOfLine$1(options.originalText.slice(locStart$2(node), locEnd$1(node)), literalline$2), printClosingTagSuffix(node, options)];
59499 if (node.value === null) {
59500 return node.rawName;
59503 const value = unescapeQuoteEntities(node.value);
59504 const singleQuoteCount = countChars(value, "'");
59505 const doubleQuoteCount = countChars(value, '"');
59506 const quote = singleQuoteCount < doubleQuoteCount ? "'" : '"';
59507 return [node.rawName, "=", quote, ...replaceTextEndOfLine$1(quote === '"' ? value.replace(/"/g, """) : value.replace(/'/g, "'")), quote];
59511 /* istanbul ignore next */
59512 throw new Error(`Unexpected node type ${node.type}`);
59516 var printerHtml = {
59517 preprocess: preprocess$2,
59518 print: genericPrint$1,
59519 insertPragma: insertPragma$2,
59520 massageAstNode: clean$1,
59524 const commonOptions$1 = commonOptions$6;
59525 const CATEGORY_HTML = "HTML"; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
59528 bracketSameLine: commonOptions$1.bracketSameLine,
59529 htmlWhitespaceSensitivity: {
59531 category: CATEGORY_HTML,
59534 description: "How to handle whitespaces in HTML.",
59537 description: "Respect the default value of CSS display property."
59540 description: "Whitespaces are considered sensitive."
59543 description: "Whitespaces are considered insensitive."
59546 vueIndentScriptAndStyle: {
59548 category: CATEGORY_HTML,
59551 description: "Indent script and style tags in Vue files."
59558 return require("./parser-html.js").parsers.html;
59563 return require("./parser-html.js").parsers.vue;
59568 return require("./parser-html.js").parsers.angular;
59571 // Lightning Web Components
59573 return require("./parser-html.js").parsers.lwc;
59578 var name$2 = "HTML";
59579 var type$2 = "markup";
59580 var tmScope$2 = "text.html.basic";
59581 var aceMode$2 = "html";
59582 var codemirrorMode$1 = "htmlmixed";
59583 var codemirrorMimeType$1 = "text/html";
59584 var color$2 = "#e34c26";
59588 var extensions$2 = [
59596 var languageId$2 = 146;
59597 var require$$4$1 = {
59600 tmScope: tmScope$2,
59601 aceMode: aceMode$2,
59602 codemirrorMode: codemirrorMode$1,
59603 codemirrorMimeType: codemirrorMimeType$1,
59605 aliases: aliases$1,
59606 extensions: extensions$2,
59607 languageId: languageId$2
59610 var name$1 = "Vue";
59611 var type$1 = "markup";
59612 var color$1 = "#41b883";
59613 var extensions$1 = [
59616 var tmScope$1 = "text.html.vue";
59617 var aceMode$1 = "html";
59618 var languageId$1 = 391;
59623 extensions: extensions$1,
59624 tmScope: tmScope$1,
59625 aceMode: aceMode$1,
59626 languageId: languageId$1
59629 const createLanguage$1 = createLanguage$7;
59630 const printer$1 = printerHtml;
59631 const options$2 = options$3;
59632 const parsers$2 = parsers$3;
59633 const languages$2 = [createLanguage$1(require$$4$1, () => ({
59636 parsers: ["angular"],
59637 vscodeLanguageIds: ["html"],
59638 extensions: [".component.html"],
59640 })), createLanguage$1(require$$4$1, data => ({
59643 vscodeLanguageIds: ["html"],
59644 extensions: [...data.extensions, ".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
59646 })), createLanguage$1(require$$4$1, () => ({
59647 name: "Lightning Web Components",
59650 vscodeLanguageIds: ["html"],
59653 })), createLanguage$1(require$$5, () => ({
59656 vscodeLanguageIds: ["vue"]
59661 var languageHtml = {
59662 languages: languages$2,
59664 options: options$2,
59668 function isPragma$1(text) {
59669 return /^\s*@(?:prettier|format)\s*$/.test(text);
59672 function hasPragma(text) {
59673 return /^\s*#[^\S\n]*@(?:prettier|format)\s*?(?:\n|$)/.test(text);
59676 function insertPragma$1(text) {
59677 return `# @format\n\n${text}`;
59681 isPragma: isPragma$1,
59683 insertPragma: insertPragma$1
59686 function locStart$1(node) {
59687 return node.position.start.offset;
59690 function locEnd(node) {
59691 return node.position.end.offset;
59695 locStart: locStart$1,
59699 function embed$1(path, print, textToDoc, options) {
59700 const node = path.getValue(); // Try to format `.prettierrc` and `.stylelintrc` as `json` first
59702 if (node.type === "root" && options.filepath && /(?:[/\\]|^)\.(?:prettier|stylelint)rc$/.test(options.filepath)) {
59703 return textToDoc(options.originalText, Object.assign(Object.assign({}, options), {}, {
59709 var embed_1 = embed$1;
59712 getLast: getLast$1,
59716 function getAncestorCount$1(path, filter) {
59718 const pathStackLength = path.stack.length - 1;
59720 for (let i = 0; i < pathStackLength; i++) {
59721 const value = path.stack[i];
59723 if (isNode$4(value) && filter(value)) {
59731 * @param {any} value
59732 * @param {string[]=} types
59736 function isNode$4(value, types) {
59737 return value && typeof value.type === "string" && (!types || types.includes(value.type));
59740 function mapNode$1(node, callback, parent) {
59741 return callback("children" in node ? Object.assign(Object.assign({}, node), {}, {
59742 children: node.children.map(childNode => mapNode$1(childNode, callback, node))
59743 }) : node, parent);
59746 function defineShortcut$1(x, key, getter) {
59747 Object.defineProperty(x, key, {
59753 function isNextLineEmpty$1(node, text) {
59754 let newlineCount = 0;
59755 const textLength = text.length;
59757 for (let i = node.position.end.offset - 1; i < textLength; i++) {
59758 const char = text[i];
59760 if (char === "\n") {
59764 if (newlineCount === 1 && /\S/.test(char)) {
59768 if (newlineCount === 2) {
59776 function isLastDescendantNode$2(path) {
59777 const node = path.getValue();
59779 switch (node.type) {
59786 const pathStackLength = path.stack.length;
59788 for (let i = 1; i < pathStackLength; i++) {
59789 const item = path.stack[i];
59790 const parentItem = path.stack[i - 1];
59792 if (Array.isArray(parentItem) && typeof item === "number" && item !== parentItem.length - 1) {
59800 function getLastDescendantNode$1(node) {
59801 return isNonEmptyArray(node.children) ? getLastDescendantNode$1(getLast$1(node.children)) : node;
59804 function isPrettierIgnore(comment) {
59805 return comment.value.trim() === "prettier-ignore";
59808 function hasPrettierIgnore$1(path) {
59809 const node = path.getValue();
59811 if (node.type === "documentBody") {
59812 const document = path.getParentNode();
59813 return hasEndComments$4(document.head) && isPrettierIgnore(getLast$1(document.head.endComments));
59816 return hasLeadingComments$2(node) && isPrettierIgnore(getLast$1(node.leadingComments));
59819 function isEmptyNode$2(node) {
59820 return !isNonEmptyArray(node.children) && !hasComments(node);
59823 function hasComments(node) {
59824 return hasLeadingComments$2(node) || hasMiddleComments$2(node) || hasIndicatorComment$1(node) || hasTrailingComment$2(node) || hasEndComments$4(node);
59827 function hasLeadingComments$2(node) {
59828 return node && isNonEmptyArray(node.leadingComments);
59831 function hasMiddleComments$2(node) {
59832 return node && isNonEmptyArray(node.middleComments);
59835 function hasIndicatorComment$1(node) {
59836 return node && node.indicatorComment;
59839 function hasTrailingComment$2(node) {
59840 return node && node.trailingComment;
59843 function hasEndComments$4(node) {
59844 return node && isNonEmptyArray(node.endComments);
59847 * " a b c d e f " -> [" a b", "c d", "e f "]
59851 function splitWithSingleSpace(text) {
59855 for (const part of text.split(/( +)/)) {
59856 /* istanbul ignore else */
59857 if (part !== " ") {
59858 if (lastPart === " ") {
59861 parts.push((parts.pop() || "") + part);
59863 } else if (lastPart === undefined) {
59869 /* istanbul ignore next */
59872 if (lastPart === " ") {
59873 parts.push((parts.pop() || "") + " ");
59876 if (parts[0] === "") {
59878 parts.unshift(" " + (parts.shift() || ""));
59884 function getFlowScalarLineContents$1(nodeType, content, options) {
59885 const rawLineContents = content.split("\n").map((lineContent, index, lineContents) => index === 0 && index === lineContents.length - 1 ? lineContent : index !== 0 && index !== lineContents.length - 1 ? lineContent.trim() : index === 0 ? lineContent.trimEnd() : lineContent.trimStart());
59887 if (options.proseWrap === "preserve") {
59888 return rawLineContents.map(lineContent => lineContent.length === 0 ? [] : [lineContent]);
59891 return rawLineContents.map(lineContent => lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent)).reduce((reduced, lineContentWords, index) => index !== 0 && rawLineContents[index - 1].length > 0 && lineContentWords.length > 0 && !( // trailing backslash in quoteDouble should be preserved
59892 nodeType === "quoteDouble" && getLast$1(getLast$1(reduced)).endsWith("\\")) ? [...reduced.slice(0, -1), [...getLast$1(reduced), ...lineContentWords]] : [...reduced, lineContentWords], []).map(lineContentWords => options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords);
59895 function getBlockValueLineContents$1(node, {
59900 const content = node.position.start.line === node.position.end.line ? "" : options.originalText.slice(node.position.start.offset, node.position.end.offset) // exclude open line `>` or `|`
59901 .match(/^[^\n]*?\n(.*)$/s)[1];
59902 const leadingSpaceCount = node.indent === null ? (match => match ? match[1].length : Number.POSITIVE_INFINITY)(content.match(/^( *)\S/m)) : node.indent - 1 + parentIndent;
59903 const rawLineContents = content.split("\n").map(lineContent => lineContent.slice(leadingSpaceCount));
59905 if (options.proseWrap === "preserve" || node.type === "blockLiteral") {
59906 return removeUnnecessaryTrailingNewlines(rawLineContents.map(lineContent => lineContent.length === 0 ? [] : [lineContent]));
59909 return removeUnnecessaryTrailingNewlines(rawLineContents.map(lineContent => lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent)).reduce((reduced, lineContentWords, index) => index !== 0 && rawLineContents[index - 1].length > 0 && lineContentWords.length > 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$1(reduced)) ? [...reduced.slice(0, -1), [...getLast$1(reduced), ...lineContentWords]] : [...reduced, lineContentWords], []).map(lineContentWords => lineContentWords.reduce((reduced, word) => // disallow trailing spaces
59910 reduced.length > 0 && /\s$/.test(getLast$1(reduced)) ? [...reduced.slice(0, -1), getLast$1(reduced) + " " + word] : [...reduced, word], [])).map(lineContentWords => options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords));
59912 function removeUnnecessaryTrailingNewlines(lineContents) {
59913 if (node.chomping === "keep") {
59914 return getLast$1(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
59917 let trailingNewlineCount = 0;
59919 for (let i = lineContents.length - 1; i >= 0; i--) {
59920 if (lineContents[i].length === 0) {
59921 trailingNewlineCount++;
59927 return trailingNewlineCount === 0 ? lineContents : trailingNewlineCount >= 2 && !isLastDescendant ? // next empty line
59928 lineContents.slice(0, -(trailingNewlineCount - 1)) : lineContents.slice(0, -trailingNewlineCount);
59932 function isInlineNode$2(node) {
59933 /* istanbul ignore next */
59938 switch (node.type) {
59940 case "quoteDouble":
59941 case "quoteSingle":
59943 case "flowMapping":
59944 case "flowSequence":
59953 getLast: getLast$1,
59954 getAncestorCount: getAncestorCount$1,
59956 isEmptyNode: isEmptyNode$2,
59957 isInlineNode: isInlineNode$2,
59958 mapNode: mapNode$1,
59959 defineShortcut: defineShortcut$1,
59960 isNextLineEmpty: isNextLineEmpty$1,
59961 isLastDescendantNode: isLastDescendantNode$2,
59962 getBlockValueLineContents: getBlockValueLineContents$1,
59963 getFlowScalarLineContents: getFlowScalarLineContents$1,
59964 getLastDescendantNode: getLastDescendantNode$1,
59965 hasPrettierIgnore: hasPrettierIgnore$1,
59966 hasLeadingComments: hasLeadingComments$2,
59967 hasMiddleComments: hasMiddleComments$2,
59968 hasIndicatorComment: hasIndicatorComment$1,
59969 hasTrailingComment: hasTrailingComment$2,
59970 hasEndComments: hasEndComments$4
59978 function preprocess$1(ast) {
59979 return mapNode(ast, defineShortcuts);
59982 function defineShortcuts(node) {
59983 switch (node.type) {
59985 defineShortcut(node, "head", () => node.children[0]);
59986 defineShortcut(node, "body", () => node.children[1]);
59989 case "documentBody":
59990 case "sequenceItem":
59991 case "flowSequenceItem":
59993 case "mappingValue":
59994 defineShortcut(node, "content", () => node.children[0]);
59997 case "mappingItem":
59998 case "flowMappingItem":
59999 defineShortcut(node, "key", () => node.children[0]);
60000 defineShortcut(node, "value", () => node.children[1]);
60007 var printPreprocess = preprocess$1;
60011 softline: softline$1,
60016 hasEndComments: hasEndComments$3,
60020 const printedEmptyLineCache = new WeakMap();
60022 function printNextEmptyLine$2(path, originalText) {
60023 const node = path.getValue();
60024 const root = path.stack[0];
60025 let isNextEmptyLinePrintedSet;
60027 if (printedEmptyLineCache.has(root)) {
60028 isNextEmptyLinePrintedSet = printedEmptyLineCache.get(root);
60030 isNextEmptyLinePrintedSet = new Set();
60031 printedEmptyLineCache.set(root, isNextEmptyLinePrintedSet);
60034 if (!isNextEmptyLinePrintedSet.has(node.position.end.line)) {
60035 isNextEmptyLinePrintedSet.add(node.position.end.line);
60037 if (isNextLineEmpty(node, originalText) && !shouldPrintEndComments$1(path.getParentNode())) {
60045 function shouldPrintEndComments$1(node) {
60046 return hasEndComments$3(node) && !isNode$3(node, ["documentHead", "documentBody", "flowMapping", "flowSequence"]);
60049 function alignWithSpaces$4(width, doc) {
60050 return align(" ".repeat(width), doc);
60054 alignWithSpaces: alignWithSpaces$4,
60055 shouldPrintEndComments: shouldPrintEndComments$1,
60056 printNextEmptyLine: printNextEmptyLine$2
60061 ifBreak: ifBreak$1,
60064 hardline: hardline$3,
60069 isEmptyNode: isEmptyNode$1,
60071 hasEndComments: hasEndComments$2
60074 printNextEmptyLine: printNextEmptyLine$1,
60075 alignWithSpaces: alignWithSpaces$3
60078 function printFlowMapping$1(path, print, options) {
60079 const node = path.getValue();
60080 const isMapping = node.type === "flowMapping";
60081 const openMarker = isMapping ? "{" : "[";
60082 const closeMarker = isMapping ? "}" : "]";
60083 /** @type {softline | line} */
60085 let bracketSpacing = softline;
60087 if (isMapping && node.children.length > 0 && options.bracketSpacing) {
60088 bracketSpacing = line$3;
60091 const lastItem = getLast(node.children);
60092 const isLastItemEmptyMappingItem = lastItem && lastItem.type === "flowMappingItem" && isEmptyNode$1(lastItem.key) && isEmptyNode$1(lastItem.value);
60093 return [openMarker, alignWithSpaces$3(options.tabWidth, [bracketSpacing, printChildren(path, print, options), options.trailingComma === "none" ? "" : ifBreak$1(","), hasEndComments$2(node) ? [hardline$3, join$3(hardline$3, path.map(print, "endComments"))] : ""]), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker];
60096 function printChildren(path, print, options) {
60097 const node = path.getValue();
60098 const parts = path.map((childPath, index) => [print(), index === node.children.length - 1 ? "" : [",", line$3, node.children[index].position.start.line !== node.children[index + 1].position.start.line ? printNextEmptyLine$1(childPath, options.originalText) : ""]], "children");
60102 var flowMappingSequence = {
60103 printFlowMapping: printFlowMapping$1,
60105 printFlowSequence: printFlowMapping$1
60108 /** @typedef {import("../../document").Doc} Doc */
60115 hardline: hardline$2,
60122 hasLeadingComments: hasLeadingComments$1,
60123 hasMiddleComments: hasMiddleComments$1,
60124 hasTrailingComment: hasTrailingComment$1,
60125 hasEndComments: hasEndComments$1,
60128 isInlineNode: isInlineNode$1
60131 alignWithSpaces: alignWithSpaces$2
60134 function printMappingItem$1(node, parentNode, path, print, options) {
60139 const isEmptyMappingKey = isEmptyNode(key);
60140 const isEmptyMappingValue = isEmptyNode(value);
60142 if (isEmptyMappingKey && isEmptyMappingValue) {
60146 const printedKey = print("key");
60147 const spaceBeforeColon = needsSpaceInFrontOfMappingValue(node) ? " " : "";
60149 if (isEmptyMappingValue) {
60150 if (node.type === "flowMappingItem" && parentNode.type === "flowMapping") {
60154 if (node.type === "mappingItem" && isAbsolutelyPrintedAsSingleLineNode(key.content, options) && !hasTrailingComment$1(key.content) && (!parentNode.tag || parentNode.tag.value !== "tag:yaml.org,2002:set")) {
60155 return [printedKey, spaceBeforeColon, ":"];
60158 return ["? ", alignWithSpaces$2(2, printedKey)];
60161 const printedValue = print("value");
60163 if (isEmptyMappingKey) {
60164 return [": ", alignWithSpaces$2(2, printedValue)];
60165 } // force explicit Key
60168 if (hasLeadingComments$1(value) || !isInlineNode$1(key.content)) {
60169 return ["? ", alignWithSpaces$2(2, printedKey), hardline$2, join$2("", path.map(print, "value", "leadingComments").map(comment => [comment, hardline$2])), ": ", alignWithSpaces$2(2, printedValue)];
60170 } // force singleline
60173 if (isSingleLineNode(key.content) && !hasLeadingComments$1(key.content) && !hasMiddleComments$1(key.content) && !hasTrailingComment$1(key.content) && !hasEndComments$1(key) && !hasLeadingComments$1(value.content) && !hasMiddleComments$1(value.content) && !hasEndComments$1(value) && isAbsolutelyPrintedAsSingleLineNode(value.content, options)) {
60174 return [printedKey, spaceBeforeColon, ": ", printedValue];
60177 const groupId = Symbol("mappingKey");
60178 const groupedKey = group$1([ifBreak("? "), group$1(alignWithSpaces$2(2, printedKey), {
60180 })]); // Construct both explicit and implicit mapping values.
60182 const explicitMappingValue = [hardline$2, ": ", alignWithSpaces$2(2, printedValue)];
60183 /** @type {Doc[]} */
60184 // In the implicit case, it's convenient to treat everything from the key's colon
60185 // as part of the mapping value
60187 const implicitMappingValueParts = [spaceBeforeColon, ":"];
60189 if (hasLeadingComments$1(value.content) || hasEndComments$1(value) && value.content && !isNode$2(value.content, ["mapping", "sequence"]) || parentNode.type === "mapping" && hasTrailingComment$1(key.content) && isInlineNode$1(value.content) || isNode$2(value.content, ["mapping", "sequence"]) && value.content.tag === null && value.content.anchor === null) {
60190 implicitMappingValueParts.push(hardline$2);
60191 } else if (value.content) {
60192 implicitMappingValueParts.push(line$2);
60195 implicitMappingValueParts.push(printedValue);
60196 const implicitMappingValue = alignWithSpaces$2(options.tabWidth, implicitMappingValueParts); // If a key is definitely single-line, forcibly use implicit style to avoid edge cases (very long
60197 // keys) that would otherwise trigger explicit style as if it was multiline.
60198 // In those cases, explicit style makes the line even longer and causes confusion.
60200 if (isAbsolutelyPrintedAsSingleLineNode(key.content, options) && !hasLeadingComments$1(key.content) && !hasMiddleComments$1(key.content) && !hasEndComments$1(key)) {
60201 return conditionalGroup([[printedKey, implicitMappingValue]]);
60202 } // Use explicit mapping syntax if the key breaks, implicit otherwise
60205 return conditionalGroup([[groupedKey, ifBreak(explicitMappingValue, implicitMappingValue, {
60210 function isAbsolutelyPrintedAsSingleLineNode(node, options) {
60215 switch (node.type) {
60217 case "quoteSingle":
60218 case "quoteDouble":
60228 if (options.proseWrap === "preserve") {
60229 return node.position.start.line === node.position.end.line;
60232 if ( // backslash-newline
60233 /\\$/m.test(options.originalText.slice(node.position.start.offset, node.position.end.offset))) {
60237 switch (options.proseWrap) {
60239 return !node.value.includes("\n");
60242 return !/[\n ]/.test(node.value);
60243 // istanbul ignore next
60250 function needsSpaceInFrontOfMappingValue(node) {
60251 return node.key.content && node.key.content.type === "alias";
60254 function isSingleLineNode(node) {
60255 /* istanbul ignore next */
60260 switch (node.type) {
60262 case "quoteDouble":
60263 case "quoteSingle":
60264 return node.position.start.line === node.position.end.line;
60274 var mappingItem = printMappingItem$1;
60276 /** @typedef {import("../../document").Doc} Doc */
60284 hardline: hardline$1,
60287 literalline: literalline$1,
60291 getDocParts: getDocParts$1
60296 getBlockValueLineContents,
60297 hasIndicatorComment,
60298 isLastDescendantNode: isLastDescendantNode$1,
60302 alignWithSpaces: alignWithSpaces$1
60305 function printBlock$1(path, print, options) {
60306 const node = path.getValue();
60307 const parentIndent = getAncestorCount(path, ancestorNode => isNode$1(ancestorNode, ["sequence", "mapping"]));
60308 const isLastDescendant = isLastDescendantNode$1(path);
60309 /** @type {Doc[]} */
60311 const parts = [node.type === "blockFolded" ? ">" : "|"];
60313 if (node.indent !== null) {
60314 parts.push(node.indent.toString());
60317 if (node.chomping !== "clip") {
60318 parts.push(node.chomping === "keep" ? "+" : "-");
60321 if (hasIndicatorComment(node)) {
60322 parts.push(" ", print("indicatorComment"));
60325 const lineContents = getBlockValueLineContents(node, {
60330 /** @type {Doc[]} */
60332 const contentsParts = [];
60334 for (const [index, lineWords] of lineContents.entries()) {
60336 contentsParts.push(hardline$1);
60339 contentsParts.push(fill$1(getDocParts$1(join$1(line$1, lineWords))));
60341 if (index !== lineContents.length - 1) {
60342 contentsParts.push(lineWords.length === 0 ? hardline$1 : markAsRoot(literalline$1));
60343 } else if (node.chomping === "keep" && isLastDescendant) {
60344 contentsParts.push(dedentToRoot(lineWords.length === 0 ? hardline$1 : literalline$1));
60348 if (node.indent === null) {
60349 parts.push(dedent(alignWithSpaces$1(options.tabWidth, contentsParts)));
60351 parts.push(dedentToRoot(alignWithSpaces$1(node.indent - 1 + parentIndent, contentsParts)));
60357 var block = printBlock$1;
60359 /** @typedef {import("../document").Doc} Doc */
60375 replaceTextEndOfLine
60379 isPreviousLineEmpty
60388 const embed = embed_1;
60390 getFlowScalarLineContents,
60391 getLastDescendantNode,
60392 hasLeadingComments,
60394 hasTrailingComment,
60397 isLastDescendantNode,
60401 const preprocess = printPreprocess;
60404 printNextEmptyLine,
60405 shouldPrintEndComments
60410 } = flowMappingSequence;
60411 const printMappingItem = mappingItem;
60412 const printBlock = block;
60414 function genericPrint(path, options, print) {
60415 const node = path.getValue();
60416 /** @type {Doc[]} */
60420 if (node.type !== "mappingValue" && hasLeadingComments(node)) {
60421 parts.push([join(hardline, path.map(print, "leadingComments")), hardline]);
60430 parts.push(print("tag"));
60433 if (tag && anchor) {
60438 parts.push(print("anchor"));
60443 let nextEmptyLine = "";
60445 if (isNode(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path)) {
60446 nextEmptyLine = printNextEmptyLine(path, options.originalText);
60449 if (tag || anchor) {
60450 if (isNode(node, ["sequence", "mapping"]) && !hasMiddleComments(node)) {
60451 parts.push(hardline);
60457 if (hasMiddleComments(node)) {
60458 parts.push([node.middleComments.length === 1 ? "" : hardline, join(hardline, path.map(print, "middleComments")), hardline]);
60461 const parentNode = path.getParentNode();
60463 if (hasPrettierIgnore(path)) {
60464 parts.push(replaceTextEndOfLine(options.originalText.slice(node.position.start.offset, node.position.end.offset).trimEnd(), literalline));
60466 parts.push(group(printNode(node, parentNode, path, options, print)));
60469 if (hasTrailingComment(node) && !isNode(node, ["document", "documentHead"])) {
60470 parts.push(lineSuffix([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent, print("trailingComment")]));
60473 if (shouldPrintEndComments(node)) {
60474 parts.push(alignWithSpaces(node.type === "sequenceItem" ? 2 : 0, [hardline, join(hardline, path.map(path => [isPreviousLineEmpty(options.originalText, path.getValue(), locStart) ? hardline : "", print()], "endComments"))]));
60477 parts.push(nextEmptyLine);
60481 function printNode(node, parentNode, path, options, print) {
60482 switch (node.type) {
60489 path.each((childPath, index) => {
60490 const document = children[index];
60491 const nextDocument = children[index + 1];
60494 parts.push(hardline);
60497 parts.push(print());
60499 if (shouldPrintDocumentEndMarker(document, nextDocument)) {
60500 parts.push(hardline, "...");
60502 if (hasTrailingComment(document)) {
60503 parts.push(" ", print("trailingComment"));
60505 } else if (nextDocument && !hasTrailingComment(nextDocument.head)) {
60506 parts.push(hardline, "---");
60509 const lastDescendantNode = getLastDescendantNode(node);
60511 if (!isNode(lastDescendantNode, ["blockLiteral", "blockFolded"]) || lastDescendantNode.chomping !== "keep") {
60512 parts.push(hardline);
60520 const nextDocument = parentNode.children[path.getName() + 1];
60523 if (shouldPrintDocumentHeadEndMarker(node, nextDocument, parentNode, options) === "head") {
60524 if (node.head.children.length > 0 || node.head.endComments.length > 0) {
60525 parts.push(print("head"));
60528 if (hasTrailingComment(node.head)) {
60529 parts.push(["---", " ", print(["head", "trailingComment"])]);
60535 if (shouldPrintDocumentBody(node)) {
60536 parts.push(print("body"));
60539 return join(hardline, parts);
60542 case "documentHead":
60543 return join(hardline, [...path.map(print, "children"), ...path.map(print, "endComments")]);
60545 case "documentBody":
60553 let separator = "";
60555 if (children.length > 0 && endComments.length > 0) {
60556 const lastDescendantNode = getLastDescendantNode(node); // there's already a newline printed at the end of blockValue (chomping=keep, lastDescendant=true)
60558 if (isNode(lastDescendantNode, ["blockFolded", "blockLiteral"])) {
60559 // an extra newline for better readability
60560 if (lastDescendantNode.chomping !== "keep") {
60561 separator = [hardline, hardline];
60564 separator = hardline;
60568 return [join(hardline, path.map(print, "children")), separator, join(hardline, path.map(print, "endComments"))];
60572 return ["%", join(" ", [node.name, ...node.parameters])];
60575 return ["#", node.value];
60578 return ["*", node.value];
60581 return options.originalText.slice(node.position.start.offset, node.position.end.offset);
60584 return ["&", node.value];
60587 return printFlowScalarContent(node.type, options.originalText.slice(node.position.start.offset, node.position.end.offset), options);
60589 case "quoteDouble":
60590 case "quoteSingle":
60592 const singleQuote = "'";
60593 const doubleQuote = '"';
60594 const raw = options.originalText.slice(node.position.start.offset + 1, node.position.end.offset - 1);
60596 if (node.type === "quoteSingle" && raw.includes("\\") || node.type === "quoteDouble" && /\\[^"]/.test(raw)) {
60597 // only quoteDouble can use escape chars
60598 // and quoteSingle do not need to escape backslashes
60599 const originalQuote = node.type === "quoteDouble" ? doubleQuote : singleQuote;
60600 return [originalQuote, printFlowScalarContent(node.type, raw, options), originalQuote];
60603 if (raw.includes(doubleQuote)) {
60604 return [singleQuote, printFlowScalarContent(node.type, node.type === "quoteDouble" ? raw // double quote needs to be escaped by backslash in quoteDouble
60605 .replace(/\\"/g, doubleQuote).replace(/'/g, singleQuote.repeat(2)) : raw, options), singleQuote];
60608 if (raw.includes(singleQuote)) {
60609 return [doubleQuote, printFlowScalarContent(node.type, node.type === "quoteSingle" ? // single quote needs to be escaped by 2 single quotes in quoteSingle
60610 raw.replace(/''/g, singleQuote) : raw, options), doubleQuote];
60613 const quote = options.singleQuote ? singleQuote : doubleQuote;
60614 return [quote, printFlowScalarContent(node.type, raw, options), quote];
60617 case "blockFolded":
60618 case "blockLiteral":
60620 return printBlock(path, print, options);
60625 return join(hardline, path.map(print, "children"));
60627 case "sequenceItem":
60628 return ["- ", alignWithSpaces(2, !node.content ? "" : print("content"))];
60631 case "mappingValue":
60632 return !node.content ? "" : print("content");
60634 case "mappingItem":
60635 case "flowMappingItem":
60637 return printMappingItem(node, parentNode, path, print, options);
60640 case "flowMapping":
60641 return printFlowMapping(path, print, options);
60643 case "flowSequence":
60644 return printFlowSequence(path, print, options);
60646 case "flowSequenceItem":
60647 return print("content");
60648 // istanbul ignore next
60651 throw new Error(`Unexpected node type ${node.type}`);
60655 function shouldPrintDocumentBody(document) {
60656 return document.body.children.length > 0 || hasEndComments(document.body);
60659 function shouldPrintDocumentEndMarker(document, nextDocument) {
60662 *... # trailingComment
60664 hasTrailingComment(document) || nextDocument && (
60670 nextDocument.head.children.length > 0 ||
60676 hasEndComments(nextDocument.head))
60680 function shouldPrintDocumentHeadEndMarker(document, nextDocument, root, options) {
60684 * preserve the first document head end marker
60686 root.children[0] === document && /---(?:\s|$)/.test(options.originalText.slice(locStart(document), locStart(document) + 4)) ||
60691 document.head.children.length > 0 ||
60696 hasEndComments(document.head) ||
60698 * --- # trailing comment
60700 hasTrailingComment(document.head)) {
60704 if (shouldPrintDocumentEndMarker(document, nextDocument)) {
60708 return nextDocument ? "root" : false;
60711 function printFlowScalarContent(nodeType, content, options) {
60712 const lineContents = getFlowScalarLineContents(nodeType, content, options);
60713 return join(hardline, lineContents.map(lineContentWords => fill(getDocParts(join(line, lineContentWords)))));
60716 function clean(node, newNode
60719 if (isNode(newNode)) {
60720 delete newNode.position;
60722 switch (newNode.type) {
60725 if (isPragma(newNode.value)) {
60731 case "quoteDouble":
60732 case "quoteSingle":
60733 newNode.type = "quote";
60739 var printerYaml = {
60742 print: genericPrint,
60743 massageAstNode: clean,
60747 const commonOptions = commonOptions$6; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
60750 bracketSpacing: commonOptions.bracketSpacing,
60751 singleQuote: commonOptions.singleQuote,
60752 proseWrap: commonOptions.proseWrap
60757 return require("./parser-yaml.js").parsers.yaml;
60764 var color = "#cb171e";
60765 var tmScope = "source.yaml";
60777 ".yaml-tmlanguage",
60788 var aceMode = "yaml";
60789 var codemirrorMode = "yaml";
60790 var codemirrorMimeType = "text/x-yaml";
60791 var languageId = 407;
60798 extensions: extensions,
60799 filenames: filenames,
60801 codemirrorMode: codemirrorMode,
60802 codemirrorMimeType: codemirrorMimeType,
60803 languageId: languageId
60806 const createLanguage = createLanguage$7;
60807 const printer = printerYaml;
60808 const options = options$1;
60809 const parsers = parsers$1;
60810 const languages$1 = [createLanguage(require$$4, data => ({
60813 vscodeLanguageIds: ["yaml", "ansible", "home-assistant"],
60814 // yarn.lock is not YAML: https://github.com/yarnpkg/yarn/issues/5629
60815 filenames: [...data.filenames.filter(filename => filename !== "yarn.lock"), ".prettierrc", ".stylelintrc"]
60817 var languageYaml = {
60818 languages: languages$1,
60826 var languages = [// JS
60828 languageCss, // Handlebars
60829 languageHandlebars, // GraphQL
60830 languageGraphql, // Markdown
60831 languageMarkdown, // HTML
60832 languageHtml, // YAML
60835 const fs = require$$0__default["default"];
60836 const path = require$$0__default$2["default"];
60837 const uniqBy = uniqBy_1;
60838 const partition = partition_1;
60839 const globby = globby$2.exports;
60840 const mem = dist$1;
60841 const internalPlugins = languages;
60842 const thirdParty = require$$7$2;
60843 const resolve = resolve_1;
60844 const memoizedLoad = mem(load, {
60845 cacheKey: JSON.stringify
60847 const memoizedSearch = mem(findPluginsInNodeModules);
60849 const clearCache = () => {
60850 mem.clear(memoizedLoad);
60851 mem.clear(memoizedSearch);
60854 function load(plugins, pluginSearchDirs) {
60859 if (!pluginSearchDirs) {
60860 pluginSearchDirs = [];
60861 } // unless pluginSearchDirs are provided, auto-load plugins from node_modules that are parent to Prettier
60864 if (pluginSearchDirs.length === 0) {
60865 const autoLoadDir = thirdParty.findParentDir(__dirname, "node_modules");
60868 pluginSearchDirs = [autoLoadDir];
60872 const [externalPluginNames, externalPluginInstances] = partition(plugins, plugin => typeof plugin === "string");
60873 const externalManualLoadPluginInfos = externalPluginNames.map(pluginName => {
60878 requirePath = resolve(path.resolve(process.cwd(), pluginName));
60880 // try node modules
60881 requirePath = resolve(pluginName, {
60882 paths: [process.cwd()]
60891 const externalAutoLoadPluginInfos = pluginSearchDirs.flatMap(pluginSearchDir => {
60892 const resolvedPluginSearchDir = path.resolve(process.cwd(), pluginSearchDir);
60893 const nodeModulesDir = path.resolve(resolvedPluginSearchDir, "node_modules"); // In some fringe cases (ex: files "mounted" as virtual directories), the
60894 // isDirectory(resolvedPluginSearchDir) check might be false even though
60895 // the node_modules actually exists.
60897 if (!isDirectory(nodeModulesDir) && !isDirectory(resolvedPluginSearchDir)) {
60898 throw new Error(`${pluginSearchDir} does not exist or is not a directory`);
60901 return memoizedSearch(nodeModulesDir).map(pluginName => ({
60903 requirePath: resolve(pluginName, {
60904 paths: [resolvedPluginSearchDir]
60908 const externalPlugins = [...uniqBy([...externalManualLoadPluginInfos, ...externalAutoLoadPluginInfos], "requirePath").map(externalPluginInfo => Object.assign({
60909 name: externalPluginInfo.name
60910 }, require(externalPluginInfo.requirePath))), ...externalPluginInstances];
60911 return [...internalPlugins, ...externalPlugins];
60914 function findPluginsInNodeModules(nodeModulesDir) {
60915 const pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@*/prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
60916 cwd: nodeModulesDir,
60917 expandDirectories: false
60919 return pluginPackageJsonPaths.map(path.dirname);
60922 function isDirectory(dir) {
60924 return fs.statSync(dir).isDirectory();
60930 var loadPlugins = {
60931 loadPlugins: memoizedLoad,
60938 const core = core$2;
60942 const getFileInfo = getFileInfo_1;
60943 const sharedUtil = utilShared;
60944 const plugins = loadPlugins;
60945 const config = resolveConfig_1;
60946 const doc = require$$7$3;
60948 function _withPlugins(fn, optsArgIdx = 1 // Usually `opts` is the 2nd argument
60950 return (...args) => {
60951 const opts = args[optsArgIdx] || {};
60952 args[optsArgIdx] = Object.assign(Object.assign({}, opts), {}, {
60953 plugins: plugins.loadPlugins(opts.plugins, opts.pluginSearchDirs)
60955 return fn(...args);
60959 function withPlugins(fn, optsArgIdx) {
60960 const resultingFn = _withPlugins(fn, optsArgIdx);
60963 // @ts-expect-error
60964 resultingFn.sync = _withPlugins(fn.sync, optsArgIdx);
60967 return resultingFn;
60970 const formatWithCursor = withPlugins(core.formatWithCursor);
60974 format(text, opts) {
60975 return formatWithCursor(text, opts).formatted;
60978 check(text, opts) {
60981 } = formatWithCursor(text, opts);
60982 return formatted === text;
60986 resolveConfig: config.resolveConfig,
60987 resolveConfigFile: config.resolveConfigFile,
60989 clearConfigCache() {
60990 config.clearCache();
60991 plugins.clearCache();
60994 /** @type {typeof getFileInfo} */
60995 getFileInfo: withPlugins(getFileInfo),
60997 /** @type {typeof getSupportInfo} */
60998 getSupportInfo: withPlugins(getSupportInfo, 0),
61004 coreOptions: coreOptions$1,
61005 createIgnorer: createIgnorer_1,
61006 optionsModule: options$d,
61007 optionsNormalizer: optionsNormalizer,
61009 arrayify: arrayify$1
61013 /* istanbul ignore next */
61015 parse: withPlugins(core.parse),
61016 formatAST: withPlugins(core.formatAST),
61017 formatDoc: withPlugins(core.formatDoc),
61018 printToDoc: withPlugins(core.printToDoc),
61019 printDocToString: withPlugins(core.printDocToString)
61023 module.exports = src;