From abf3e02f965500c40e6dca4ee8d5c2002842203f Mon Sep 17 00:00:00 2001 From: coderiaser Date: Wed, 23 Oct 2024 14:42:14 +0300 Subject: [PATCH] chore: @putout/bundle: v3.17.1 --- ChangeLog | 5 + bundle/putout.js | 190525 ++++++++++++++++++++-------------------- bundle/putout.min.js | 2 +- package.json | 2 +- 4 files changed, 94035 insertions(+), 96499 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3d4649..e30a969 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024.10.23, v3.17.1 + +fix: +- 28c057d @putout/bundle: commonjs: strictRequires + 2024.10.23, v3.17.0 feature: diff --git a/bundle/putout.js b/bundle/putout.js index 577e7c8..f9d7852 100644 --- a/bundle/putout.js +++ b/bundle/putout.js @@ -174,15 +174,15 @@ var versions = {}; var release$1 = {}; var config = {}; -function noop() {} +function noop$4() {} -var on = noop; -var addListener = noop; -var once$1 = noop; -var off = noop; -var removeListener = noop; -var removeAllListeners = noop; -var emit = noop; +var on = noop$4; +var addListener = noop$4; +var once$a = noop$4; +var off = noop$4; +var removeListener = noop$4; +var removeAllListeners = noop$4; +var emit = noop$4; function binding(name) { throw new Error('process.binding is not supported'); @@ -237,7 +237,7 @@ var browser$1$1 = { versions: versions, on: on, addListener: addListener, - once: once$1, + once: once$a, off: off, removeListener: removeListener, removeAllListeners: removeAllListeners, @@ -257,7 +257,7 @@ var lookup = []; var revLookup = []; var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; var inited = false; -function init () { +function init$2 () { inited = true; var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for (var i = 0, len = code.length; i < len; ++i) { @@ -271,7 +271,7 @@ function init () { function toByteArray (b64) { if (!inited) { - init(); + init$2(); } var i, j, l, tmp, placeHolders, arr; var len = b64.length; @@ -330,7 +330,7 @@ function encodeChunk (uint8, start, end) { function fromByteArray (uint8) { if (!inited) { - init(); + init$2(); } var tmp; var len = uint8.length; @@ -450,7 +450,7 @@ function write (buffer, value, offset, isLE, mLen, nBytes) { var toString = {}.toString; -var isArray$1 = Array.isArray || function (arr) { +var isArray$g = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; @@ -734,7 +734,7 @@ function fromObject (that, obj) { return fromArrayLike(that, obj) } - if (obj.type === 'Buffer' && isArray$1(obj.data)) { + if (obj.type === 'Buffer' && isArray$g(obj.data)) { return fromArrayLike(that, obj.data) } } @@ -799,7 +799,7 @@ Buffer.isEncoding = function isEncoding (encoding) { }; Buffer.concat = function concat (list, length) { - if (!isArray$1(list)) { + if (!isArray$g(list)) { throw new TypeError('"list" argument must be an Array of Buffers') } @@ -2334,7 +2334,7 @@ function cpus() { return []; } -function type() { +function type$1() { return 'Browser'; } @@ -2382,7 +2382,7 @@ var _polyfillNode_os = { networkInterfaces:networkInterfaces, getNetworkInterfaces: getNetworkInterfaces, release: release, - type: type, + type: type$1, cpus: cpus, totalmem: totalmem, freemem: freemem, @@ -2410,15 +2410,15 @@ var _polyfillNode_os$1 = /*#__PURE__*/Object.freeze({ tmpDir: tmpDir, tmpdir: tmpdir, totalmem: totalmem, - type: type, + type: type$1, uptime: uptime }); var require$$4 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_os$1); -var inherits; +var inherits$1; if (typeof Object.create === 'function'){ - inherits = function inherits(ctor, superCtor) { + inherits$1 = function inherits(ctor, superCtor) { // implementation from standard node.js 'util' module ctor.super_ = superCtor; ctor.prototype = Object.create(superCtor.prototype, { @@ -2431,7 +2431,7 @@ if (typeof Object.create === 'function'){ }); }; } else { - inherits = function inherits(ctor, superCtor) { + inherits$1 = function inherits(ctor, superCtor) { ctor.super_ = superCtor; var TempCtor = function () {}; TempCtor.prototype = superCtor.prototype; @@ -2452,7 +2452,7 @@ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || var formatRegExp = /%[sdj%]/g; function format(f) { - if (!isString(f)) { + if (!isString$c(f)) { var objects = []; for (var i = 0; i < arguments.length; i++) { objects.push(inspect(arguments[i])); @@ -2480,7 +2480,7 @@ function format(f) { } }); for (var x = args[i]; i < len; x = args[++i]) { - if (isNull(x) || !isObject(x)) { + if (isNull$1(x) || !isObject$6(x)) { str += ' ' + x; } else { str += ' ' + inspect(x); @@ -2639,13 +2639,13 @@ function formatValue(ctx, value, recurseTimes) { // Check that value is an object with an inspect function on it if (ctx.customInspect && value && - isFunction(value.inspect) && + isFunction$5(value.inspect) && // Filter out the util module, it's inspect function is special value.inspect !== inspect && // Also filter out any prototype objects using the circular check. !(value.constructor && value.constructor.prototype === value)) { var ret = value.inspect(recurseTimes, ctx); - if (!isString(ret)) { + if (!isString$c(ret)) { ret = formatValue(ctx, ret, recurseTimes); } return ret; @@ -2674,11 +2674,11 @@ function formatValue(ctx, value, recurseTimes) { // Some type of object without properties can be shortcutted. if (keys.length === 0) { - if (isFunction(value)) { + if (isFunction$5(value)) { var name = value.name ? ': ' + value.name : ''; return ctx.stylize('[Function' + name + ']', 'special'); } - if (isRegExp(value)) { + if (isRegExp$1(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } if (isDate(value)) { @@ -2692,19 +2692,19 @@ function formatValue(ctx, value, recurseTimes) { var base = '', array = false, braces = ['{', '}']; // Make Array say that they are Array - if (isArray(value)) { + if (isArray$f(value)) { array = true; braces = ['[', ']']; } // Make functions say that they are functions - if (isFunction(value)) { + if (isFunction$5(value)) { var n = value.name ? ': ' + value.name : ''; base = ' [Function' + n + ']'; } // Make RegExps say that they are RegExps - if (isRegExp(value)) { + if (isRegExp$1(value)) { base = ' ' + RegExp.prototype.toString.call(value); } @@ -2723,7 +2723,7 @@ function formatValue(ctx, value, recurseTimes) { } if (recurseTimes < 0) { - if (isRegExp(value)) { + if (isRegExp$1(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } else { return ctx.stylize('[Object]', 'special'); @@ -2750,18 +2750,18 @@ function formatValue(ctx, value, recurseTimes) { function formatPrimitive(ctx, value) { if (isUndefined(value)) return ctx.stylize('undefined', 'undefined'); - if (isString(value)) { + if (isString$c(value)) { var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') .replace(/'/g, "\\'") .replace(/\\"/g, '"') + '\''; return ctx.stylize(simple, 'string'); } - if (isNumber(value)) + if (isNumber$3(value)) return ctx.stylize('' + value, 'number'); if (isBoolean(value)) return ctx.stylize('' + value, 'boolean'); // For some reason typeof null is "object", so special case here. - if (isNull(value)) + if (isNull$1(value)) return ctx.stylize('null', 'null'); } @@ -2810,7 +2810,7 @@ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { } if (!str) { if (ctx.seen.indexOf(desc.value) < 0) { - if (isNull(recurseTimes)) { + if (isNull$1(recurseTimes)) { str = formatValue(ctx, desc.value, null); } else { str = formatValue(ctx, desc.value, recurseTimes - 1); @@ -2871,7 +2871,7 @@ function reduceToSingleString(output, base, braces) { // NOTE: These type checking functions intentionally don't use `instanceof` // because it is fragile and can be easily faked with `Object.create()`. -function isArray(ar) { +function isArray$f(ar) { return Array.isArray(ar); } @@ -2879,7 +2879,7 @@ function isBoolean(arg) { return typeof arg === 'boolean'; } -function isNull(arg) { +function isNull$1(arg) { return arg === null; } @@ -2887,11 +2887,11 @@ function isNullOrUndefined(arg) { return arg == null; } -function isNumber(arg) { +function isNumber$3(arg) { return typeof arg === 'number'; } -function isString(arg) { +function isString$c(arg) { return typeof arg === 'string'; } @@ -2903,28 +2903,28 @@ function isUndefined(arg) { return arg === void 0; } -function isRegExp(re) { - return isObject(re) && objectToString(re) === '[object RegExp]'; +function isRegExp$1(re) { + return isObject$6(re) && objectToString$1(re) === '[object RegExp]'; } -function isObject(arg) { +function isObject$6(arg) { return typeof arg === 'object' && arg !== null; } function isDate(d) { - return isObject(d) && objectToString(d) === '[object Date]'; + return isObject$6(d) && objectToString$1(d) === '[object Date]'; } function isError(e) { - return isObject(e) && - (objectToString(e) === '[object Error]' || e instanceof Error); + return isObject$6(e) && + (objectToString$1(e) === '[object Error]' || e instanceof Error); } -function isFunction(arg) { +function isFunction$5(arg) { return typeof arg === 'function'; } -function isPrimitive(arg) { +function isPrimitive$1(arg) { return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || @@ -2937,7 +2937,7 @@ function isBuffer(maybeBuf) { return Array.isArray(maybeBuf); } -function objectToString(o) { +function objectToString$1(o) { return Object.prototype.toString.call(o); } @@ -2961,13 +2961,13 @@ function timestamp() { // log is just a thin wrapper to console.log that prepends a timestamp -function log$1() { +function log$6() { console.log('%s - %s', timestamp(), format.apply(null, arguments)); } function _extend(origin, add) { // Don't do anything if add isn't an object - if (!add || !isObject(add)) return origin; + if (!add || !isObject$6(add)) return origin; var keys = Object.keys(add); var i = keys.length; @@ -3086,24 +3086,24 @@ function callbackify(original) { } var _polyfillNode_util = { - inherits: inherits, + inherits: inherits$1, _extend: _extend, - log: log$1, + log: log$6, isBuffer: isBuffer, - isPrimitive: isPrimitive, - isFunction: isFunction, + isPrimitive: isPrimitive$1, + isFunction: isFunction$5, isError: isError, isDate: isDate, - isObject: isObject, - isRegExp: isRegExp, + isObject: isObject$6, + isRegExp: isRegExp$1, isUndefined: isUndefined, isSymbol: isSymbol, - isString: isString, - isNumber: isNumber, + isString: isString$c, + isNumber: isNumber$3, isNullOrUndefined: isNullOrUndefined, - isNull: isNull, + isNull: isNull$1, isBoolean: isBoolean, - isArray: isArray, + isArray: isArray$f, inspect: inspect, deprecate: deprecate, format: format, @@ -3120,84163 +3120,82737 @@ var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({ default: _polyfillNode_util, deprecate: deprecate, format: format, - inherits: inherits, + inherits: inherits$1, inspect: inspect, - isArray: isArray, + isArray: isArray$f, isBoolean: isBoolean, isBuffer: isBuffer, isDate: isDate, isError: isError, - isFunction: isFunction, - isNull: isNull, + isFunction: isFunction$5, + isNull: isNull$1, isNullOrUndefined: isNullOrUndefined, - isNumber: isNumber, - isObject: isObject, - isPrimitive: isPrimitive, - isRegExp: isRegExp, - isString: isString, + isNumber: isNumber$3, + isObject: isObject$6, + isPrimitive: isPrimitive$1, + isRegExp: isRegExp$1, + isString: isString$c, isSymbol: isSymbol, isUndefined: isUndefined, - log: log$1, + log: log$6, promisify: promisify }); var require$$2$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1); -var bundle; -var hasRequiredBundle; - -function requireBundle () { - if (hasRequiredBundle) return bundle; - hasRequiredBundle = 1; - function _array_like_to_array(arr, len) { - if (len == null || len > arr.length) len = arr.length; - for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; - return arr2; - } - function _array_with_holes(arr) { - if (Array.isArray(arr)) return arr; - } - function _array_without_holes(arr) { - if (Array.isArray(arr)) return _array_like_to_array(arr); - } - function _assert_this_initialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - return self; - } - function _class_call_check(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - function _defineProperties(target, props) { - for(var i = 0; i < props.length; i++){ - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - function _create_class(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; - } - function _define_property(obj, key, value1) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value1, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value1; - } - return obj; - } - function _get(target, property, receiver) { - if (typeof Reflect !== "undefined" && Reflect.get) { - _get = Reflect.get; - } else { - _get = function get(target, property, receiver) { - var base = _super_prop_base(target, property); - if (!base) return; - var desc = Object.getOwnPropertyDescriptor(base, property); - if (desc.get) { - return desc.get.call(receiver || target); - } - return desc.value; - }; - } - return _get(target, property, receiver || target); - } - function _get_prototype_of(o) { - _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _get_prototype_of(o); - } - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - if (superClass) _set_prototype_of(subClass, superClass); - } - function _instanceof(left, right) { - if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { - return !!right[Symbol.hasInstance](left); - } else { - return left instanceof right; - } - } - function _iterable_to_array(iter) { - if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); - } - function _iterable_to_array_limit(arr, i) { - var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; - if (_i == null) return; - var _arr = []; - var _n = true; - var _d = false; - var _s, _e; - try { - for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){ - _arr.push(_s.value); - if (i && _arr.length === i) break; - } - } catch (err) { - _d = true; - _e = err; - } finally{ - try { - if (!_n && _i["return"] != null) _i["return"](); - } finally{ - if (_d) throw _e; - } - } - return _arr; - } - function _non_iterable_rest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - function _non_iterable_spread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - function _possible_constructor_return(self, call) { - if (call && (_type_of(call) === "object" || typeof call === "function")) { - return call; - } - return _assert_this_initialized(self); - } - function _set_prototype_of(o, p) { - _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - return _set_prototype_of(o, p); - } - function _sliced_to_array(arr, i) { - return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest(); - } - function _super_prop_base(object, property) { - while(!Object.prototype.hasOwnProperty.call(object, property)){ - object = _get_prototype_of(object); - if (object === null) break; - } - return object; - } - function _tagged_template_literal(strings, raw) { - if (!raw) { - raw = strings.slice(0); - } - return Object.freeze(Object.defineProperties(strings, { - raw: { - value: Object.freeze(raw) - } - })); - } - function _to_consumable_array(arr) { - return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread(); - } - function _type_of(obj) { - "@swc/helpers - typeof"; - return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; - } - function _unsupported_iterable_to_array(o, minLen) { - if (!o) return; - if (typeof o === "string") return _array_like_to_array(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(n); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen); - } - function _is_native_reflect_construct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - try { - Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); - return true; - } catch (e) { - return false; - } - } - function _create_super(Derived) { - var hasNativeReflectConstruct = _is_native_reflect_construct(); - return function _createSuperInternal() { - var Super = _get_prototype_of(Derived), result; - if (hasNativeReflectConstruct) { - var NewTarget = _get_prototype_of(this).constructor; - result = Reflect.construct(Super, arguments, NewTarget); - } else { - result = Super.apply(this, arguments); - } - return _possible_constructor_return(this, result); - }; - } - function _ts_generator(thisArg, body) { - var f, y, t, g, _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }; - return g = { - next: verb(0), - "throw": verb(1), - "return": verb(2) - }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { - return this; - }), g; - function verb(n) { - return function(v) { - return step([ - n, - v - ]); - }; - } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while(_)try { - 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; - if (y = 0, t) op = [ - op[0] & 2, - t.value - ]; - switch(op[0]){ - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { - value: op[1], - done: false - }; - case 5: - _.label++; - y = op[1]; - op = [ - 0 - ]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [ - 6, - e - ]; - y = 0; - } finally{ - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { - value: op[0] ? op[1] : void 0, - done: true - }; - } - } - function _templateObject() { - var data = _tagged_template_literal([ - "pipelineOperator" - ]); - _templateObject = function _templateObject() { - return data; - }; - return data; - } - function _templateObject1() { - var data = _tagged_template_literal([ - "flow" - ]); - _templateObject1 = function _templateObject() { - return data; - }; - return data; - } - function _templateObject2() { - var data = _tagged_template_literal([ - "jsx" - ]); - _templateObject2 = function _templateObject() { - return data; - }; - return data; - } - function _templateObject3() { - var data = _tagged_template_literal([ - "typescript" - ]); - _templateObject3 = function _templateObject() { - return data; - }; - return data; - } - function _templateObject4() { - var data = _tagged_template_literal([ - "placeholders" - ]); - _templateObject4 = function _templateObject() { - return data; - }; - return data; - } - function _templateObject5() { - var data = _tagged_template_literal([ - "\n (function (", - ") {\n function ", - "(", - ") {\n return ", - ".apply(this, arguments);\n }\n\n ", - ".toString = function () {\n return ", - ".toString();\n }\n\n return ", - ";\n })(", - ")\n " - ]); - _templateObject5 = function _templateObject() { - return data; - }; - return data; - } - var __create = Object.create; - var __defProp = Object.defineProperty; - var __getOwnPropDesc = Object.getOwnPropertyDescriptor; - var __getOwnPropNames = Object.getOwnPropertyNames; - var __getProtoOf = Object.getPrototypeOf; - var __hasOwnProp = Object.prototype.hasOwnProperty; - var __defNormalProp = function(obj, key, value1) { - return key in obj ? __defProp(obj, key, { - enumerable: true, - configurable: true, - writable: true, - value: value1 - }) : obj[key] = value1; - }; - var __commonJS = function(cb, mod) { - return function __require() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { - exports: {} - }).exports, mod), mod.exports; - }; - }; - var __export = function(target, all) { - for(var name in all)__defProp(target, name, { - get: all[name], - enumerable: true - }); - }; - var __copyProps = function(to, from, except, desc) { - if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") { - var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - try { - var _loop = function() { - var key = _step.value; - if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { - get: function() { - return from[key]; - }, - enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable - }); - }; - for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop(); - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally{ - try { - if (!_iteratorNormalCompletion && _iterator.return != null) { - _iterator.return(); - } - } finally{ - if (_didIteratorError) { - throw _iteratorError; - } - } - } - } - return to; - }; - var __toESM = function(mod, isNodeMode, target) { - return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - __defProp(target, "default", { - value: mod, - enumerable: true - }) , mod); - }; - var __toCommonJS = function(mod) { - return __copyProps(__defProp({}, "__esModule", { - value: true - }), mod); - }; - var __publicField = function(obj, key, value1) { - return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value1); - }; - // node_modules/to-fast-properties/index.js - var require_to_fast_properties = __commonJS({ - "node_modules/to-fast-properties/index.js": function(exports2, module2) { - var fastProto = null; - function FastObject(o) { - if (fastProto !== null && _type_of(fastProto.property)) { - var result = fastProto; - fastProto = FastObject.prototype = null; - return result; - } - fastProto = FastObject.prototype = o == null ? /* @__PURE__ */ Object.create(null) : o; - return new FastObject(); - } - var inlineCacheCutoff = 10; - for(var i = 0; i <= inlineCacheCutoff; i++){ - FastObject(); - } - module2.exports = function toFastproperties(o) { - return FastObject(o); - }; - } - }); - // node_modules/js-tokens/index.js - var require_js_tokens = __commonJS({ - "node_modules/js-tokens/index.js": function(exports2, module2) { - var Identifier2; - var JSXIdentifier2; - var JSXPunctuator; - var JSXString; - var JSXText2; - var KeywordsWithExpressionAfter; - var KeywordsWithNoLineTerminatorAfter; - var LineTerminatorSequence; - var MultiLineComment; - var Newline; - var NumericLiteral3; - var Punctuator; - var RegularExpressionLiteral; - var SingleLineComment; - var StringLiteral3; - var Template; - var TokensNotPrecedingObjectLiteral; - var TokensPrecedingExpression; - var WhiteSpace; - RegularExpressionLiteral = RegExp("\\/(?![*\\/])(?:\\[(?:[^\\]\\\\\\n\\r\\u2028\\u2029]+|\\\\.)*\\]|[^\\/\\\\\\n\\r\\u2028\\u2029]+|\\\\.)*(\\/[$_\\u200C\\u200D\\p{ID_Continue}]*|\\\\)?", "yu"); - Punctuator = RegExp("--|\\+\\+|=>|\\.{3}|\\??\\.(?!\\d)|(?:&&|\\|\\||\\?\\?|[+\\-%&|^]|\\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\\/(?![\\/*]))=?|[?~,:;[\\](){}]", "y"); - Identifier2 = RegExp("(\\x23?)(?=[$_\\p{ID_Start}\\\\])(?:[$_\\u200C\\u200D\\p{ID_Continue}]+|\\\\u[\\da-fA-F]{4}|\\\\u\\{[\\da-fA-F]+\\})+", "yu"); - StringLiteral3 = RegExp("(['\"])(?:[^'\"\\\\\\n\\r]+|(?!\\1)['\"]|\\\\(?:\\r\\n|[^]))*(\\1)?", "y"); - NumericLiteral3 = RegExp("(?:0[xX][\\da-fA-F](?:_?[\\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\\d)*n|(?:(?:0(?!\\d)|0\\d*[89]\\d*|[1-9](?:_?\\d)*)(?:\\.(?:\\d(?:_?\\d)*)?)?|\\.\\d(?:_?\\d)*)(?:[eE][+-]?\\d(?:_?\\d)*)?|0[0-7]+", "y"); - Template = RegExp("[`}](?:[^`\\\\$]+|\\\\[^]|\\$(?!\\{))*(`|\\$\\{)?", "y"); - WhiteSpace = RegExp("[\\t\\v\\f\\ufeff\\p{Zs}]+", "yu"); - LineTerminatorSequence = RegExp("\\r?\\n|[\\r\\u2028\\u2029]", "y"); - MultiLineComment = RegExp("\\/\\*(?:[^*]+|\\*(?!\\/))*(\\*\\/)?", "y"); - SingleLineComment = RegExp("\\/\\/.*", "y"); - JSXPunctuator = RegExp("[<>.:={}]|\\/(?![\\/*])", "y"); - JSXIdentifier2 = RegExp("[$_\\p{ID_Start}][$_\\u200C\\u200D\\p{ID_Continue}-]*", "yu"); - JSXString = RegExp("(['\"])(?:[^'\"]+|(?!\\1)['\"])*(\\1)?", "y"); - JSXText2 = RegExp("[^<>{}]+", "y"); - TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/; - TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/; - KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/; - KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/; - Newline = RegExp(LineTerminatorSequence.source); - module2.exports = function jsTokens2(input) { - var _ref, tmp, jsx2, braces, firstCodePoint, isExpression3, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack, _, _1, _2; - var _arguments = arguments; - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - _ref = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, tmp = _ref.jsx, jsx2 = tmp === void 0 ? false : tmp; - length = input.length; - lastIndex = 0; - lastSignificantToken = ""; - stack = [ - { - tag: "JS" - } - ]; - braces = []; - parenNesting = 0; - postfixIncDec = false; - _state.label = 1; - case 1: - if (!(lastIndex < length)) return [ - 3, - 62 - ]; - mode = stack[stack.length - 1]; - _ = mode.tag; - switch(_){ - case "JS": - return [ - 3, - 2 - ]; - case "JSNonExpressionParen": - return [ - 3, - 2 - ]; - case "InterpolationInTemplate": - return [ - 3, - 2 - ]; - case "InterpolationInJSX": - return [ - 3, - 2 - ]; - case "JSXTag": - return [ - 3, - 38 - ]; - case "JSXTagEnd": - return [ - 3, - 38 - ]; - case "JSXChildren": - return [ - 3, - 45 - ]; - } - return [ - 3, - 52 - ]; - case 2: - if (!(input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken)))) return [ - 3, - 4 - ]; - RegularExpressionLiteral.lastIndex = lastIndex; - if (!(match = RegularExpressionLiteral.exec(input))) return [ - 3, - 4 - ]; - lastIndex = RegularExpressionLiteral.lastIndex; - lastSignificantToken = match[0]; - postfixIncDec = true; - return [ - 4, - { - type: "RegularExpressionLiteral", - value: match[0], - closed: match[1] !== void 0 && match[1] !== "\\" - } - ]; - case 3: - _state.sent(); - return [ - 3, - 1 - ]; - case 4: - Punctuator.lastIndex = lastIndex; - if (!(match = Punctuator.exec(input))) return [ - 3, - 26 - ]; - punctuator = match[0]; - nextLastIndex = Punctuator.lastIndex; - nextLastSignificantToken = punctuator; - switch(punctuator){ - case "(": - return [ - 3, - 5 - ]; - case ")": - return [ - 3, - 6 - ]; - case "{": - return [ - 3, - 7 - ]; - case "}": - return [ - 3, - 8 - ]; - case "]": - return [ - 3, - 18 - ]; - case "++": - return [ - 3, - 19 - ]; - case "--": - return [ - 3, - 19 - ]; - case "<": - return [ - 3, - 20 - ]; - } - return [ - 3, - 23 - ]; - case 5: - if (lastSignificantToken === "?NonExpressionParenKeyword") { - stack.push({ - tag: "JSNonExpressionParen", - nesting: parenNesting - }); - } - parenNesting++; - postfixIncDec = false; - return [ - 3, - 24 - ]; - case 6: - parenNesting--; - postfixIncDec = true; - if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) { - stack.pop(); - nextLastSignificantToken = "?NonExpressionParenEnd"; - postfixIncDec = false; - } - return [ - 3, - 24 - ]; - case 7: - Punctuator.lastIndex = 0; - isExpression3 = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken)); - braces.push(isExpression3); - postfixIncDec = false; - return [ - 3, - 24 - ]; - case 8: - _1 = mode.tag; - switch(_1){ - case "InterpolationInTemplate": - return [ - 3, - 9 - ]; - case "InterpolationInJSX": - return [ - 3, - 15 - ]; - } - return [ - 3, - 17 - ]; - case 9: - if (!(braces.length === mode.nesting)) return [ - 3, - 14 - ]; - Template.lastIndex = lastIndex; - match = Template.exec(input); - lastIndex = Template.lastIndex; - lastSignificantToken = match[0]; - if (!(match[1] === "${")) return [ - 3, - 11 - ]; - lastSignificantToken = "?InterpolationInTemplate"; - postfixIncDec = false; - return [ - 4, - { - type: "TemplateMiddle", - value: match[0] - } - ]; - case 10: - _state.sent(); - return [ - 3, - 13 - ]; - case 11: - stack.pop(); - postfixIncDec = true; - return [ - 4, - { - type: "TemplateTail", - value: match[0], - closed: match[1] === "`" - } - ]; - case 12: - _state.sent(); - _state.label = 13; - case 13: - return [ - 3, - 1 - ]; - case 14: - return [ - 3, - 17 - ]; - case 15: - if (!(braces.length === mode.nesting)) return [ - 3, - 17 - ]; - stack.pop(); - lastIndex += 1; - lastSignificantToken = "}"; - return [ - 4, - { - type: "JSXPunctuator", - value: "}" - } - ]; - case 16: - _state.sent(); - return [ - 3, - 1 - ]; - case 17: - postfixIncDec = braces.pop(); - nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}"; - return [ - 3, - 24 - ]; - case 18: - postfixIncDec = true; - return [ - 3, - 24 - ]; - case 19: - nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec"; - return [ - 3, - 24 - ]; - case 20: - if (!(jsx2 && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken)))) return [ - 3, - 22 - ]; - stack.push({ - tag: "JSXTag" - }); - lastIndex += 1; - lastSignificantToken = "<"; - return [ - 4, - { - type: "JSXPunctuator", - value: punctuator - } - ]; - case 21: - _state.sent(); - return [ - 3, - 1 - ]; - case 22: - postfixIncDec = false; - return [ - 3, - 24 - ]; - case 23: - postfixIncDec = false; - _state.label = 24; - case 24: - lastIndex = nextLastIndex; - lastSignificantToken = nextLastSignificantToken; - return [ - 4, - { - type: "Punctuator", - value: punctuator - } - ]; - case 25: - _state.sent(); - return [ - 3, - 1 - ]; - case 26: - Identifier2.lastIndex = lastIndex; - if (!(match = Identifier2.exec(input))) return [ - 3, - 28 - ]; - lastIndex = Identifier2.lastIndex; - nextLastSignificantToken = match[0]; - switch(match[0]){ - case "for": - case "if": - case "while": - case "with": - if (lastSignificantToken !== "." && lastSignificantToken !== "?.") { - nextLastSignificantToken = "?NonExpressionParenKeyword"; - } - } - lastSignificantToken = nextLastSignificantToken; - postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]); - return [ - 4, - { - type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName", - value: match[0] - } - ]; - case 27: - _state.sent(); - return [ - 3, - 1 - ]; - case 28: - StringLiteral3.lastIndex = lastIndex; - if (!(match = StringLiteral3.exec(input))) return [ - 3, - 30 - ]; - lastIndex = StringLiteral3.lastIndex; - lastSignificantToken = match[0]; - postfixIncDec = true; - return [ - 4, - { - type: "StringLiteral", - value: match[0], - closed: match[2] !== void 0 - } - ]; - case 29: - _state.sent(); - return [ - 3, - 1 - ]; - case 30: - NumericLiteral3.lastIndex = lastIndex; - if (!(match = NumericLiteral3.exec(input))) return [ - 3, - 32 - ]; - lastIndex = NumericLiteral3.lastIndex; - lastSignificantToken = match[0]; - postfixIncDec = true; - return [ - 4, - { - type: "NumericLiteral", - value: match[0] - } - ]; - case 31: - _state.sent(); - return [ - 3, - 1 - ]; - case 32: - Template.lastIndex = lastIndex; - if (!(match = Template.exec(input))) return [ - 3, - 37 - ]; - lastIndex = Template.lastIndex; - lastSignificantToken = match[0]; - if (!(match[1] === "${")) return [ - 3, - 34 - ]; - lastSignificantToken = "?InterpolationInTemplate"; - stack.push({ - tag: "InterpolationInTemplate", - nesting: braces.length - }); - postfixIncDec = false; - return [ - 4, - { - type: "TemplateHead", - value: match[0] - } - ]; - case 33: - _state.sent(); - return [ - 3, - 36 - ]; - case 34: - postfixIncDec = true; - return [ - 4, - { - type: "NoSubstitutionTemplate", - value: match[0], - closed: match[1] === "`" - } - ]; - case 35: - _state.sent(); - _state.label = 36; - case 36: - return [ - 3, - 1 - ]; - case 37: - return [ - 3, - 52 - ]; - case 38: - JSXPunctuator.lastIndex = lastIndex; - if (!(match = JSXPunctuator.exec(input))) return [ - 3, - 40 - ]; - lastIndex = JSXPunctuator.lastIndex; - nextLastSignificantToken = match[0]; - switch(match[0]){ - case "<": - stack.push({ - tag: "JSXTag" - }); - break; - case ">": - stack.pop(); - if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") { - nextLastSignificantToken = "?JSX"; - postfixIncDec = true; - } else { - stack.push({ - tag: "JSXChildren" - }); - } - break; - case "{": - stack.push({ - tag: "InterpolationInJSX", - nesting: braces.length - }); - nextLastSignificantToken = "?InterpolationInJSX"; - postfixIncDec = false; - break; - case "/": - if (lastSignificantToken === "<") { - stack.pop(); - if (stack[stack.length - 1].tag === "JSXChildren") { - stack.pop(); - } - stack.push({ - tag: "JSXTagEnd" - }); - } - } - lastSignificantToken = nextLastSignificantToken; - return [ - 4, - { - type: "JSXPunctuator", - value: match[0] - } - ]; - case 39: - _state.sent(); - return [ - 3, - 1 - ]; - case 40: - JSXIdentifier2.lastIndex = lastIndex; - if (!(match = JSXIdentifier2.exec(input))) return [ - 3, - 42 - ]; - lastIndex = JSXIdentifier2.lastIndex; - lastSignificantToken = match[0]; - return [ - 4, - { - type: "JSXIdentifier", - value: match[0] - } - ]; - case 41: - _state.sent(); - return [ - 3, - 1 - ]; - case 42: - JSXString.lastIndex = lastIndex; - if (!(match = JSXString.exec(input))) return [ - 3, - 44 - ]; - lastIndex = JSXString.lastIndex; - lastSignificantToken = match[0]; - return [ - 4, - { - type: "JSXString", - value: match[0], - closed: match[2] !== void 0 - } - ]; - case 43: - _state.sent(); - return [ - 3, - 1 - ]; - case 44: - return [ - 3, - 52 - ]; - case 45: - JSXText2.lastIndex = lastIndex; - if (!(match = JSXText2.exec(input))) return [ - 3, - 47 - ]; - lastIndex = JSXText2.lastIndex; - lastSignificantToken = match[0]; - return [ - 4, - { - type: "JSXText", - value: match[0] - } - ]; - case 46: - _state.sent(); - return [ - 3, - 1 - ]; - case 47: - _2 = input[lastIndex]; - switch(_2){ - case "<": - return [ - 3, - 48 - ]; - case "{": - return [ - 3, - 50 - ]; - } - return [ - 3, - 52 - ]; - case 48: - stack.push({ - tag: "JSXTag" - }); - lastIndex++; - lastSignificantToken = "<"; - return [ - 4, - { - type: "JSXPunctuator", - value: "<" - } - ]; - case 49: - _state.sent(); - return [ - 3, - 1 - ]; - case 50: - stack.push({ - tag: "InterpolationInJSX", - nesting: braces.length - }); - lastIndex++; - lastSignificantToken = "?InterpolationInJSX"; - postfixIncDec = false; - return [ - 4, - { - type: "JSXPunctuator", - value: "{" - } - ]; - case 51: - _state.sent(); - return [ - 3, - 1 - ]; - case 52: - WhiteSpace.lastIndex = lastIndex; - if (!(match = WhiteSpace.exec(input))) return [ - 3, - 54 - ]; - lastIndex = WhiteSpace.lastIndex; - return [ - 4, - { - type: "WhiteSpace", - value: match[0] - } - ]; - case 53: - _state.sent(); - return [ - 3, - 1 - ]; - case 54: - LineTerminatorSequence.lastIndex = lastIndex; - if (!(match = LineTerminatorSequence.exec(input))) return [ - 3, - 56 - ]; - lastIndex = LineTerminatorSequence.lastIndex; - postfixIncDec = false; - if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) { - lastSignificantToken = "?NoLineTerminatorHere"; - } - return [ - 4, - { - type: "LineTerminatorSequence", - value: match[0] - } - ]; - case 55: - _state.sent(); - return [ - 3, - 1 - ]; - case 56: - MultiLineComment.lastIndex = lastIndex; - if (!(match = MultiLineComment.exec(input))) return [ - 3, - 58 - ]; - lastIndex = MultiLineComment.lastIndex; - if (Newline.test(match[0])) { - postfixIncDec = false; - if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) { - lastSignificantToken = "?NoLineTerminatorHere"; - } - } - return [ - 4, - { - type: "MultiLineComment", - value: match[0], - closed: match[1] !== void 0 - } - ]; - case 57: - _state.sent(); - return [ - 3, - 1 - ]; - case 58: - SingleLineComment.lastIndex = lastIndex; - if (!(match = SingleLineComment.exec(input))) return [ - 3, - 60 - ]; - lastIndex = SingleLineComment.lastIndex; - postfixIncDec = false; - return [ - 4, - { - type: "SingleLineComment", - value: match[0] - } - ]; - case 59: - _state.sent(); - return [ - 3, - 1 - ]; - case 60: - firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex)); - lastIndex += firstCodePoint.length; - lastSignificantToken = firstCodePoint; - postfixIncDec = false; - return [ - 4, - { - type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid", - value: firstCodePoint - } - ]; - case 61: - _state.sent(); - return [ - 3, - 1 - ]; - case 62: - return [ - 2, - void 0 - ]; - } - }); - }; - } - }); - // node_modules/picocolors/picocolors.js - var require_picocolors = __commonJS({ - "node_modules/picocolors/picocolors.js": function(exports2, module2) { - var argv = browser$1$1.argv || []; - var env = {}; - var isColorSupported = !("NO_COLOR" in env || argv.includes("--no-color")) && ("FORCE_COLOR" in env || argv.includes("--color") || "unix" === "win32" || commonjsRequire != null && require$$0$5.isatty(1) && env.TERM !== "dumb" || "CI" in env); - var formatter = function(open, close) { - var replace = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : open; - return function(input) { - var string = "" + input; - var index2 = string.indexOf(close, open.length); - return ~index2 ? open + replaceClose(string, close, replace, index2) + close : open + string + close; - }; - }; - var replaceClose = function(string, close, replace, index2) { - var result = ""; - var cursor = 0; - do { - result += string.substring(cursor, index2) + replace; - cursor = index2 + close.length; - index2 = string.indexOf(close, cursor); - }while (~index2); - return result + string.substring(cursor); - }; - var createColors3 = function() { - var enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : isColorSupported; - var init = enabled ? formatter : function() { - return String; - }; - return { - isColorSupported: enabled, - reset: init("\x1B[0m", "\x1B[0m"), - bold: init("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"), - dim: init("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"), - italic: init("\x1B[3m", "\x1B[23m"), - underline: init("\x1B[4m", "\x1B[24m"), - inverse: init("\x1B[7m", "\x1B[27m"), - hidden: init("\x1B[8m", "\x1B[28m"), - strikethrough: init("\x1B[9m", "\x1B[29m"), - black: init("\x1B[30m", "\x1B[39m"), - red: init("\x1B[31m", "\x1B[39m"), - green: init("\x1B[32m", "\x1B[39m"), - yellow: init("\x1B[33m", "\x1B[39m"), - blue: init("\x1B[34m", "\x1B[39m"), - magenta: init("\x1B[35m", "\x1B[39m"), - cyan: init("\x1B[36m", "\x1B[39m"), - white: init("\x1B[37m", "\x1B[39m"), - gray: init("\x1B[90m", "\x1B[39m"), - bgBlack: init("\x1B[40m", "\x1B[49m"), - bgRed: init("\x1B[41m", "\x1B[49m"), - bgGreen: init("\x1B[42m", "\x1B[49m"), - bgYellow: init("\x1B[43m", "\x1B[49m"), - bgBlue: init("\x1B[44m", "\x1B[49m"), - bgMagenta: init("\x1B[45m", "\x1B[49m"), - bgCyan: init("\x1B[46m", "\x1B[49m"), - bgWhite: init("\x1B[47m", "\x1B[49m") - }; - }; - module2.exports = createColors3(); - module2.exports.createColors = createColors3; - } - }); - // node_modules/jsesc/jsesc.js - var require_jsesc = __commonJS({ - "node_modules/jsesc/jsesc.js": function(exports2, module2) { - var object = {}; - var hasOwnProperty = object.hasOwnProperty; - var forOwn = function(object2, callback) { - for(var key in object2){ - if (hasOwnProperty.call(object2, key)) { - callback(key, object2[key]); - } - } - }; - var extend = function(destination, source) { - if (!source) { - return destination; - } - forOwn(source, function(key, value1) { - destination[key] = value1; - }); - return destination; - }; - var forEach = function(array, callback) { - var length = array.length; - var index2 = -1; - while(++index2 < length){ - callback(array[index2]); - } - }; - var fourHexEscape = function(hex) { - return "\\u" + ("0000" + hex).slice(-4); - }; - var hexadecimal = function(code2, lowercase) { - var hexadecimal2 = code2.toString(16); - if (lowercase) return hexadecimal2; - return hexadecimal2.toUpperCase(); - }; - var toString = object.toString; - var isArray = Array.isArray; - var isBuffer = function(value1) { - return typeof Buffer === "function" && Array.isArray(value1); - }; - var isObject = function(value1) { - return toString.call(value1) == "[object Object]"; - }; - var isString = function(value1) { - return typeof value1 == "string" || toString.call(value1) == "[object String]"; - }; - var isNumber2 = function(value1) { - return typeof value1 == "number" || toString.call(value1) == "[object Number]"; - }; - var isFunction5 = function(value1) { - return typeof value1 == "function"; - }; - var isMap = function(value1) { - return toString.call(value1) == "[object Map]"; - }; - var isSet = function(value1) { - return toString.call(value1) == "[object Set]"; - }; - var singleEscapes = { - "\\": "\\\\", - "\b": "\\b", - "\f": "\\f", - "\n": "\\n", - "\r": "\\r", - " ": "\\t" - }; - var regexSingleEscape = /[\\\b\f\n\r\t]/; - var regexDigit = /[0-9]/; - var regexWhitespace = /[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/; - var escapeEverythingRegex = /([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^]/g; - var escapeNonAsciiRegex = /([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^ !#-&\(-\[\]-_a-~]/g; - var jsesc2 = function(argument, options) { - var increaseIndentation = function() { - oldIndent = indent; - ++options.indentLevel; - indent = options.indent.repeat(options.indentLevel); - }; - var defaults = { - "escapeEverything": false, - "minimal": false, - "isScriptContext": false, - "quotes": "single", - "wrap": false, - "es6": false, - "json": false, - "compact": true, - "lowercaseHex": false, - "numbers": "decimal", - "indent": " ", - "indentLevel": 0, - "__inline1__": false, - "__inline2__": false - }; - var json = options && options.json; - if (json) { - defaults.quotes = "double"; - defaults.wrap = true; - } - options = extend(defaults, options); - if (options.quotes != "single" && options.quotes != "double" && options.quotes != "backtick") { - options.quotes = "single"; - } - var quote = options.quotes == "double" ? '"' : options.quotes == "backtick" ? "`" : "'"; - var compact = options.compact; - var lowercaseHex = options.lowercaseHex; - var indent = options.indent.repeat(options.indentLevel); - var oldIndent = ""; - var inline1 = options.__inline1__; - var inline2 = options.__inline2__; - var newLine = compact ? "" : "\n"; - var result; - var isEmpty = true; - var useBinNumbers = options.numbers == "binary"; - var useOctNumbers = options.numbers == "octal"; - var useDecNumbers = options.numbers == "decimal"; - var useHexNumbers = options.numbers == "hexadecimal"; - if (json && argument && isFunction5(argument.toJSON)) { - argument = argument.toJSON(); - } - if (!isString(argument)) { - if (isMap(argument)) { - if (argument.size == 0) { - return "new Map()"; - } - if (!compact) { - options.__inline1__ = true; - options.__inline2__ = false; - } - return "new Map(" + jsesc2(Array.from(argument), options) + ")"; - } - if (isSet(argument)) { - if (argument.size == 0) { - return "new Set()"; - } - return "new Set(" + jsesc2(Array.from(argument), options) + ")"; - } - if (isBuffer(argument)) { - if (argument.length == 0) { - return "Buffer.from([])"; - } - return "Buffer.from(" + jsesc2(Array.from(argument), options) + ")"; - } - if (isArray(argument)) { - result = []; - options.wrap = true; - if (inline1) { - options.__inline1__ = false; - options.__inline2__ = true; - } - if (!inline2) { - increaseIndentation(); - } - forEach(argument, function(value1) { - isEmpty = false; - if (inline2) { - options.__inline2__ = false; - } - result.push((compact || inline2 ? "" : indent) + jsesc2(value1, options)); - }); - if (isEmpty) { - return "[]"; - } - if (inline2) { - return "[" + result.join(", ") + "]"; - } - return "[" + newLine + result.join("," + newLine) + newLine + (compact ? "" : oldIndent) + "]"; - } else if (isNumber2(argument)) { - if (json) { - return JSON.stringify(argument); - } - if (useDecNumbers) { - return String(argument); - } - if (useHexNumbers) { - var hexadecimal2 = argument.toString(16); - if (!lowercaseHex) { - hexadecimal2 = hexadecimal2.toUpperCase(); - } - return "0x" + hexadecimal2; - } - if (useBinNumbers) { - return "0b" + argument.toString(2); - } - if (useOctNumbers) { - return "0o" + argument.toString(8); - } - } else if (!isObject(argument)) { - if (json) { - return JSON.stringify(argument) || "null"; - } - return String(argument); - } else { - result = []; - options.wrap = true; - increaseIndentation(); - forOwn(argument, function(key, value1) { - isEmpty = false; - result.push((compact ? "" : indent) + jsesc2(key, options) + ":" + (compact ? "" : " ") + jsesc2(value1, options)); - }); - if (isEmpty) { - return "{}"; - } - return "{" + newLine + result.join("," + newLine) + newLine + (compact ? "" : oldIndent) + "}"; - } - } - var regex = options.escapeEverything ? escapeEverythingRegex : escapeNonAsciiRegex; - result = argument.replace(regex, function(char, pair, lone, quoteChar, index2, string) { - if (pair) { - if (options.minimal) return pair; - var first = pair.charCodeAt(0); - var second = pair.charCodeAt(1); - if (options.es6) { - var codePoint = (first - 55296) * 1024 + second - 56320 + 65536; - var hex2 = hexadecimal(codePoint, lowercaseHex); - return "\\u{" + hex2 + "}"; - } - return fourHexEscape(hexadecimal(first, lowercaseHex)) + fourHexEscape(hexadecimal(second, lowercaseHex)); - } - if (lone) { - return fourHexEscape(hexadecimal(lone.charCodeAt(0), lowercaseHex)); - } - if (char == "\0" && !json && !regexDigit.test(string.charAt(index2 + 1))) { - return "\\0"; - } - if (quoteChar) { - if (quoteChar == quote || options.escapeEverything) { - return "\\" + quoteChar; - } - return quoteChar; - } - if (regexSingleEscape.test(char)) { - return singleEscapes[char]; - } - if (options.minimal && !regexWhitespace.test(char)) { - return char; - } - var hex = hexadecimal(char.charCodeAt(0), lowercaseHex); - if (json || hex.length > 2) { - return fourHexEscape(hex); - } - return "\\x" + ("00" + hex).slice(-2); - }); - if (quote == "`") { - result = result.replace(/\$\{/g, "\\${"); - } - if (options.isScriptContext) { - result = result.replace(/<\/(script|style)/gi, "<\\/$1").replace(/' is a single-line comment - this.index += 3; - var comment = this.skipSingleLineComment(3); - if (this.trackComment) { - comments = comments.concat(comment); - } - } - else { - break; - } - } - else if (ch === 0x3C && !this.isModule) { - if (this.source.slice(this.index + 1, this.index + 4) === '!--') { - this.index += 4; // `' is a single-line comment + this.index += 3; + var comment = this.skipSingleLineComment(3); + if (this.trackComment) { + comments = comments.concat(comment); + } + } + else { + break; + } + } + else if (ch === 0x3C && !this.isModule) { + if (this.source.slice(this.index + 1, this.index + 4) === '!--') { + this.index += 4; // ` [out] - */ +/** + * The MIT License (MIT) + * Copyright (c) 2017-present Dmitry Soshnikov + */ +/** + * A generic FA State class (base for NFA and DFA). + * + * Maintains the transition map, and the flag whether + * the state is accepting. + */ - function char(c) { - var inState = new NFAState(); - var outState = new NFAState({ - accepting: true - }); +var _createClass$2 = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - return new NFA(inState.addTransition(c, outState), outState); - } +function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - // ----------------------------------------------------------------------------- - // Epsilon NFA fragment +var State$1 = function () { + function State() { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref$accepting = _ref.accepting, + accepting = _ref$accepting === undefined ? false : _ref$accepting; - /** - * Epsilon factory. - * - * Creates an NFA fragment for ε (recognizes an empty string). - * - * [in] --ε--> [out] - */ - function e() { - return char(EPSILON); - } + _classCallCheck$2(this, State); - // ----------------------------------------------------------------------------- - // Alteration NFA fragment: `abc` + /** + * Outgoing transitions to other states. + */ + this._transitions = new Map(); - /** - * Creates a connection between two NFA fragments on epsilon transition. - * - * [in-a] --a--> [out-a] --ε--> [in-b] --b--> [out-b] - */ - function altPair(first, second) { - first.out.accepting = false; - second.out.accepting = true; + /** + * Whether the state is accepting. + */ + this.accepting = accepting; + } - first.out.addTransition(EPSILON, second.in); + /** + * Returns transitions for this state. + */ - return new NFA(first.in, second.out); - } - /** - * Alteration factory. - * - * Creates a alteration NFA for (at least) two NFA-fragments. - */ - function alt(first) { - for (var _len = arguments.length, fragments = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - fragments[_key - 1] = arguments[_key]; - } + _createClass$2(State, [{ + key: 'getTransitions', + value: function getTransitions() { + return this._transitions; + } - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; + /** + * Creates a transition on symbol. + */ - try { - for (var _iterator = fragments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var fragment = _step.value; + }, { + key: 'addTransition', + value: function addTransition(symbol, toState) { + this.getTransitionsOnSymbol(symbol).add(toState); + return this; + } - first = altPair(first, fragment); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } + /** + * Returns transitions set on symbol. + */ - return first; - } + }, { + key: 'getTransitionsOnSymbol', + value: function getTransitionsOnSymbol(symbol) { + var transitions = this._transitions.get(symbol); - // ----------------------------------------------------------------------------- - // Disjunction NFA fragment: `a|b` + if (!transitions) { + transitions = new Set(); + this._transitions.set(symbol, transitions); + } - /** - * Creates a disjunction choice between two fragments. - */ - function orPair(first, second) { - var inState = new NFAState(); - var outState = new NFAState(); + return transitions; + } + }]); - inState.addTransition(EPSILON, first.in); - inState.addTransition(EPSILON, second.in); + return State; +}(); - outState.accepting = true; - first.out.accepting = false; - second.out.accepting = false; +var state = State$1; - first.out.addTransition(EPSILON, outState); - second.out.addTransition(EPSILON, outState); +state.default; - return new NFA(inState, outState); - } +/** + * The MIT License (MIT) + * Copyright (c) 2017-present Dmitry Soshnikov + */ - /** - * Disjunction factory. - * - * Creates a disjunction NFA for (at least) two NFA-fragments. - */ - function or(first) { - for (var _len2 = arguments.length, fragments = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - fragments[_key2 - 1] = arguments[_key2]; - } +var _createClass$1 = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; +function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - try { - for (var _iterator2 = fragments[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var fragment = _step2.value; +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - first = orPair(first, fragment); - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - return first; - } +var State = state; - // ----------------------------------------------------------------------------- - // Kleene-closure +var _require$3 = specialSymbols, + EPSILON$1 = _require$3.EPSILON; - /** - * Kleene star/closure. - * - * a* - */ - function repExplicit(fragment) { - var inState = new NFAState(); - var outState = new NFAState({ - accepting: true - }); +/** + * NFA state. + * + * Allows nondeterministic transitions to several states on the + * same symbol, and also epsilon-transitions. + */ - // 0 or more. - inState.addTransition(EPSILON, fragment.in); - inState.addTransition(EPSILON, outState); - fragment.out.accepting = false; - fragment.out.addTransition(EPSILON, outState); - outState.addTransition(EPSILON, fragment.in); +var NFAState$1 = function (_State) { + _inherits(NFAState, _State); - return new NFA(inState, outState); - } + function NFAState() { + _classCallCheck$1(this, NFAState); - /** - * Optimized Kleene-star: just adds ε-transitions from - * input to the output, and back. - */ - function rep(fragment) { - fragment.in.addTransition(EPSILON, fragment.out); - fragment.out.addTransition(EPSILON, fragment.in); - return fragment; - } + return _possibleConstructorReturn(this, (NFAState.__proto__ || Object.getPrototypeOf(NFAState)).apply(this, arguments)); + } - /** - * Optimized Plus: just adds ε-transitions from - * the output to the input. - */ - function plusRep(fragment) { - fragment.out.addTransition(EPSILON, fragment.in); - return fragment; - } + _createClass$1(NFAState, [{ + key: 'matches', + + + /** + * Whether this state matches a string. + * + * We maintain set of visited epsilon-states to avoid infinite loops + * when an epsilon-transition goes eventually to itself. + * + * NOTE: this function is rather "educational", since we use DFA for strings + * matching. DFA is built on top of NFA, and uses fast transition table. + */ + value: function matches(string) { + var visited = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set(); + + // An epsilon-state has been visited, stop to avoid infinite loop. + if (visited.has(this)) { + return false; + } - /** - * Optimized ? repetition: just adds ε-transitions from - * the input to the output. - */ - function questionRep(fragment) { - fragment.in.addTransition(EPSILON, fragment.out); - return fragment; - } + visited.add(this); - builders = { - alt: alt, - char: char, - e: e, - or: or, - rep: rep, - repExplicit: repExplicit, - plusRep: plusRep, - questionRep: questionRep - }; - return builders; -} + // No symbols left.. + if (string.length === 0) { + // .. and we're in the accepting state. + if (this.accepting) { + return true; + } -/** - * The MIT License (MIT) - * Copyright (c) 2017-present Dmitry Soshnikov - */ + // Check if we can reach any accepting state from + // on the epsilon transitions. + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = this.getTransitionsOnSymbol(EPSILON$1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var nextState = _step.value; -var nfaFromRegexp; -var hasRequiredNfaFromRegexp; + if (nextState.matches('', visited)) { + return true; + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } -function requireNfaFromRegexp () { - if (hasRequiredNfaFromRegexp) return nfaFromRegexp; - hasRequiredNfaFromRegexp = 1; + return false; + } - function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + // Else, we get some symbols. + var symbol = string[0]; + var rest = string.slice(1); - var parser = requireParser(); + var symbolTransitions = this.getTransitionsOnSymbol(symbol); + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; - var _require = requireBuilders(), - alt = _require.alt, - char = _require.char, - or = _require.or, - rep = _require.rep, - plusRep = _require.plusRep, - questionRep = _require.questionRep; + try { + for (var _iterator2 = symbolTransitions[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var _nextState = _step2.value; - /** - * Helper `gen` function calls node type handler. - */ + if (_nextState.matches(rest)) { + return true; + } + } + // If we couldn't match on symbol, check still epsilon-transitions + // without consuming the symbol (i.e. continue from `string`, not `rest`). + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } - function gen(node) { - if (node && !generator[node.type]) { - throw new Error(node.type + ' is not supported in NFA/DFA interpreter.'); - } + var _iteratorNormalCompletion3 = true; + var _didIteratorError3 = false; + var _iteratorError3 = undefined; - return node ? generator[node.type](node) : ''; - } + try { + for (var _iterator3 = this.getTransitionsOnSymbol(EPSILON$1)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + var _nextState2 = _step3.value; - /** - * AST handler. - */ - var generator = { - RegExp: function RegExp(node) { - if (node.flags !== '') { - throw new Error('NFA/DFA: Flags are not supported yet.'); - } + if (_nextState2.matches(string, visited)) { + return true; + } + } + } catch (err) { + _didIteratorError3 = true; + _iteratorError3 = err; + } finally { + try { + if (!_iteratorNormalCompletion3 && _iterator3.return) { + _iterator3.return(); + } + } finally { + if (_didIteratorError3) { + throw _iteratorError3; + } + } + } - return gen(node.body); - }, - Alternative: function Alternative(node) { - var fragments = (node.expressions || []).map(gen); - return alt.apply(undefined, _toConsumableArray(fragments)); - }, - Disjunction: function Disjunction(node) { - return or(gen(node.left), gen(node.right)); - }, - Repetition: function Repetition(node) { - switch (node.quantifier.kind) { - case '*': - return rep(gen(node.expression)); - case '+': - return plusRep(gen(node.expression)); - case '?': - return questionRep(gen(node.expression)); - default: - throw new Error('Unknown repeatition: ' + node.quantifier.kind + '.'); - } - }, - Char: function Char(node) { - if (node.kind !== 'simple') { - throw new Error('NFA/DFA: Only simple chars are supported yet.'); - } + return false; + } - return char(node.value); - }, - Group: function Group(node) { - return gen(node.expression); - } - }; + /** + * Returns an ε-closure for this state: + * self + all states following ε-transitions. + */ + + }, { + key: 'getEpsilonClosure', + value: function getEpsilonClosure() { + var _this2 = this; + + if (!this._epsilonClosure) { + (function () { + var epsilonTransitions = _this2.getTransitionsOnSymbol(EPSILON$1); + var closure = _this2._epsilonClosure = new Set(); + closure.add(_this2); + var _iteratorNormalCompletion4 = true; + var _didIteratorError4 = false; + var _iteratorError4 = undefined; + + try { + for (var _iterator4 = epsilonTransitions[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { + var nextState = _step4.value; + + if (!closure.has(nextState)) { + closure.add(nextState); + var nextClosure = nextState.getEpsilonClosure(); + nextClosure.forEach(function (state) { + return closure.add(state); + }); + } + } + } catch (err) { + _didIteratorError4 = true; + _iteratorError4 = err; + } finally { + try { + if (!_iteratorNormalCompletion4 && _iterator4.return) { + _iterator4.return(); + } + } finally { + if (_didIteratorError4) { + throw _iteratorError4; + } + } + } + })(); + } - nfaFromRegexp = { - /** - * Builds an NFA from the passed regexp. - */ - build: function build(regexp) { - var ast = regexp; + return this._epsilonClosure; + } + }]); - if (regexp instanceof RegExp) { - regexp = '' + regexp; - } + return NFAState; +}(State); - if (typeof regexp === 'string') { - ast = parser.parse(regexp, { - captureLocations: true - }); - } +var nfaState = NFAState$1; - return gen(ast); - } - }; - return nfaFromRegexp; -} +nfaState.default; /** * The MIT License (MIT) * Copyright (c) 2017-present Dmitry Soshnikov */ -var finiteAutomaton; -var hasRequiredFiniteAutomaton; +var NFA$1 = nfa; +var NFAState = nfaState; -function requireFiniteAutomaton () { - if (hasRequiredFiniteAutomaton) return finiteAutomaton; - hasRequiredFiniteAutomaton = 1; +var _require$2 = specialSymbols, + EPSILON = _require$2.EPSILON; - var NFA = requireNfa(); - var DFA = requireDfa(); +// ----------------------------------------------------------------------------- +// Char NFA fragment: `c` - var nfaFromRegExp = requireNfaFromRegexp(); - var builders = requireBuilders(); +/** + * Char factory. + * + * Creates an NFA fragment for a single char. + * + * [in] --c--> [out] + */ - finiteAutomaton = { - /** - * Export NFA and DFA classes. - */ - NFA: NFA, - DFA: DFA, +function char$1(c) { + var inState = new NFAState(); + var outState = new NFAState({ + accepting: true + }); - /** - * Expose builders. - */ - builders: builders, + return new NFA$1(inState.addTransition(c, outState), outState); +} - /** - * Builds an NFA for the passed regexp. - * - * @param string | AST | RegExp: - * - * a regular expression in different representations: a string, - * a RegExp object, or an AST. - */ - toNFA: function toNFA(regexp) { - return nfaFromRegExp.build(regexp); - }, +// ----------------------------------------------------------------------------- +// Epsilon NFA fragment +/** + * Epsilon factory. + * + * Creates an NFA fragment for ε (recognizes an empty string). + * + * [in] --ε--> [out] + */ +function e() { + return char$1(EPSILON); +} - /** - * Builds DFA for the passed regexp. - * - * @param string | AST | RegExp: - * - * a regular expression in different representations: a string, - * a RegExp object, or an AST. - */ - toDFA: function toDFA(regexp) { - return new DFA(this.toNFA(regexp)); - }, +// ----------------------------------------------------------------------------- +// Alteration NFA fragment: `abc` +/** + * Creates a connection between two NFA fragments on epsilon transition. + * + * [in-a] --a--> [out-a] --ε--> [in-b] --b--> [out-b] + */ +function altPair(first, second) { + first.out.accepting = false; + second.out.accepting = true; - /** - * Returns true if regexp accepts the string. - */ - test: function test(regexp, string) { - return this.toDFA(regexp).matches(string); - } - }; - return finiteAutomaton; + first.out.addTransition(EPSILON, second.in); + + return new NFA$1(first.in, second.out); } /** - * The MIT License (MIT) - * Copyright (c) 2017-present Dmitry Soshnikov + * Alteration factory. + * + * Creates a alteration NFA for (at least) two NFA-fragments. */ +function alt$1(first) { + for (var _len = arguments.length, fragments = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + fragments[_key - 1] = arguments[_key]; + } -var runtime; -var hasRequiredRuntime; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; -function requireRuntime () { - if (hasRequiredRuntime) return runtime; - hasRequiredRuntime = 1; + try { + for (var _iterator = fragments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var fragment = _step.value; - /** - * The `RegExpTree` class provides runtime support for `compat-transpiler` - * module from `regexp-tree`. - * - * E.g. it tracks names of the capturing groups, in order to access the - * names on the matched result. - * - * It's a thin-wrapper on top of original regexp. - */ + first = altPair(first, fragment); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + return first; +} - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +// ----------------------------------------------------------------------------- +// Disjunction NFA fragment: `a|b` - var RegExpTree = function () { - /** - * Initializes a `RegExpTree` instance. - * - * @param RegExp - a regular expression - * - * @param Object state: - * - * An extra state which may store any related to transformation - * data, for example, names of the groups. - * - * - flags - original flags - * - groups - names of the groups, and their indices - * - source - original source - */ - function RegExpTree(re, _ref) { - var flags = _ref.flags, - groups = _ref.groups, - source = _ref.source; - - _classCallCheck(this, RegExpTree); - - this._re = re; - this._groups = groups; - - // Original props. - this.flags = flags; - this.source = source || re.source; - this.dotAll = flags.includes('s'); - - // Inherited directly from `re`. - this.global = re.global; - this.ignoreCase = re.ignoreCase; - this.multiline = re.multiline; - this.sticky = re.sticky; - this.unicode = re.unicode; - } +/** + * Creates a disjunction choice between two fragments. + */ +function orPair(first, second) { + var inState = new NFAState(); + var outState = new NFAState(); - /** - * Facade wrapper for RegExp `test` method. - */ + inState.addTransition(EPSILON, first.in); + inState.addTransition(EPSILON, second.in); + outState.accepting = true; + first.out.accepting = false; + second.out.accepting = false; - _createClass(RegExpTree, [{ - key: 'test', - value: function test(string) { - return this._re.test(string); - } + first.out.addTransition(EPSILON, outState); + second.out.addTransition(EPSILON, outState); - /** - * Facade wrapper for RegExp `compile` method. - */ + return new NFA$1(inState, outState); +} - }, { - key: 'compile', - value: function compile(string) { - return this._re.compile(string); - } +/** + * Disjunction factory. + * + * Creates a disjunction NFA for (at least) two NFA-fragments. + */ +function or$1(first) { + for (var _len2 = arguments.length, fragments = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + fragments[_key2 - 1] = arguments[_key2]; + } - /** - * Facade wrapper for RegExp `toString` method. - */ + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; - }, { - key: 'toString', - value: function toString() { - if (!this._toStringResult) { - this._toStringResult = '/' + this.source + '/' + this.flags; - } - return this._toStringResult; - } + try { + for (var _iterator2 = fragments[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var fragment = _step2.value; - /** - * Facade wrapper for RegExp `exec` method. - */ + first = orPair(first, fragment); + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } - }, { - key: 'exec', - value: function exec(string) { - var result = this._re.exec(string); + return first; +} - if (!this._groups || !result) { - return result; - } +// ----------------------------------------------------------------------------- +// Kleene-closure - result.groups = {}; +/** + * Kleene star/closure. + * + * a* + */ +function repExplicit(fragment) { + var inState = new NFAState(); + var outState = new NFAState({ + accepting: true + }); - for (var group in this._groups) { - var groupNumber = this._groups[group]; - result.groups[group] = result[groupNumber]; - } + // 0 or more. + inState.addTransition(EPSILON, fragment.in); + inState.addTransition(EPSILON, outState); - return result; - } - }]); + fragment.out.accepting = false; + fragment.out.addTransition(EPSILON, outState); + outState.addTransition(EPSILON, fragment.in); - return RegExpTree; - }(); + return new NFA$1(inState, outState); +} - runtime = { - RegExpTree: RegExpTree - }; - return runtime; +/** + * Optimized Kleene-star: just adds ε-transitions from + * input to the output, and back. + */ +function rep$1(fragment) { + fragment.in.addTransition(EPSILON, fragment.out); + fragment.out.addTransition(EPSILON, fragment.in); + return fragment; +} + +/** + * Optimized Plus: just adds ε-transitions from + * the output to the input. + */ +function plusRep$1(fragment) { + fragment.out.addTransition(EPSILON, fragment.in); + return fragment; } +/** + * Optimized ? repetition: just adds ε-transitions from + * the input to the output. + */ +function questionRep$1(fragment) { + fragment.in.addTransition(EPSILON, fragment.out); + return fragment; +} + +var builders$1 = { + alt: alt$1, + char: char$1, + e: e, + or: or$1, + rep: rep$1, + repExplicit: repExplicit, + plusRep: plusRep$1, + questionRep: questionRep$1 +}; + /** * The MIT License (MIT) * Copyright (c) 2017-present Dmitry Soshnikov */ -var regexpTree_1; -var hasRequiredRegexpTree$1; +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } -function requireRegexpTree$1 () { - if (hasRequiredRegexpTree$1) return regexpTree_1; - hasRequiredRegexpTree$1 = 1; +var parser$1 = parser$4; - var compatTranspiler = requireCompatTranspiler(); - var generator = requireGenerator(); - var optimizer = requireOptimizer(); - var parser = requireParser(); - var _transform = requireTransform(); - var _traverse = requireTraverse(); - var fa = requireFiniteAutomaton(); +var _require$1 = builders$1, + alt = _require$1.alt, + char = _require$1.char, + or = _require$1.or, + rep = _require$1.rep, + plusRep = _require$1.plusRep, + questionRep = _require$1.questionRep; - var _require = requireRuntime(), - RegExpTree = _require.RegExpTree; +/** + * Helper `gen` function calls node type handler. + */ - /** - * An API object for RegExp processing (parsing/transform/generation). - */ +function gen(node) { + if (node && !generator$1[node.type]) { + throw new Error(node.type + ' is not supported in NFA/DFA interpreter.'); + } - var regexpTree = { - /** - * Parser module exposed. - */ - parser: parser, + return node ? generator$1[node.type](node) : ''; +} - /** - * Expose finite-automaton module. - */ - fa: fa, +/** + * AST handler. + */ +var generator$1 = { + RegExp: function RegExp(node) { + if (node.flags !== '') { + throw new Error('NFA/DFA: Flags are not supported yet.'); + } - /** - * `TransformResult` exposed. - */ - TransformResult: _transform.TransformResult, + return gen(node.body); + }, + Alternative: function Alternative(node) { + var fragments = (node.expressions || []).map(gen); + return alt.apply(undefined, _toConsumableArray(fragments)); + }, + Disjunction: function Disjunction(node) { + return or(gen(node.left), gen(node.right)); + }, + Repetition: function Repetition(node) { + switch (node.quantifier.kind) { + case '*': + return rep(gen(node.expression)); + case '+': + return plusRep(gen(node.expression)); + case '?': + return questionRep(gen(node.expression)); + default: + throw new Error('Unknown repeatition: ' + node.quantifier.kind + '.'); + } + }, + Char: function Char(node) { + if (node.kind !== 'simple') { + throw new Error('NFA/DFA: Only simple chars are supported yet.'); + } + + return char(node.value); + }, + Group: function Group(node) { + return gen(node.expression); + } +}; + +var nfaFromRegexp = { + /** + * Builds an NFA from the passed regexp. + */ + build: function build(regexp) { + var ast = regexp; + + if (regexp instanceof RegExp) { + regexp = '' + regexp; + } + + if (typeof regexp === 'string') { + ast = parser$1.parse(regexp, { + captureLocations: true + }); + } + + return gen(ast); + } +}; + +/** + * The MIT License (MIT) + * Copyright (c) 2017-present Dmitry Soshnikov + */ + +var NFA = nfa; +var DFA = dfa; + +var nfaFromRegExp = nfaFromRegexp; +var builders = builders$1; + +var finiteAutomaton = { + + /** + * Export NFA and DFA classes. + */ + NFA: NFA, + DFA: DFA, + + /** + * Expose builders. + */ + builders: builders, + + /** + * Builds an NFA for the passed regexp. + * + * @param string | AST | RegExp: + * + * a regular expression in different representations: a string, + * a RegExp object, or an AST. + */ + toNFA: function toNFA(regexp) { + return nfaFromRegExp.build(regexp); + }, + + + /** + * Builds DFA for the passed regexp. + * + * @param string | AST | RegExp: + * + * a regular expression in different representations: a string, + * a RegExp object, or an AST. + */ + toDFA: function toDFA(regexp) { + return new DFA(this.toNFA(regexp)); + }, + + + /** + * Returns true if regexp accepts the string. + */ + test: function test(regexp, string) { + return this.toDFA(regexp).matches(string); + } +}; - /** - * Parses a regexp string, producing an AST. - * - * @param string regexp - * - * a regular expression in different formats: string, AST, RegExp. - * - * @param Object options - * - * parsing options for this parse call. Default are: - * - * - captureLocations: boolean - * - any other custom options - * - * @return Object AST - */ - parse: function parse(regexp, options) { - return parser.parse('' + regexp, options); - }, +/** + * The MIT License (MIT) + * Copyright (c) 2017-present Dmitry Soshnikov + */ +/** + * The `RegExpTree` class provides runtime support for `compat-transpiler` + * module from `regexp-tree`. + * + * E.g. it tracks names of the capturing groups, in order to access the + * names on the matched result. + * + * It's a thin-wrapper on top of original regexp. + */ - /** - * Traverses a RegExp AST. - * - * @param Object ast - * @param Object | Array handlers - * - * Each `handler` is an object containing handler function for needed - * node types. Example: - * - * regexpTree.traverse(ast, { - * onChar(node) { - * ... - * }, - * }); - * - * The value for a node type may also be an object with functions pre and post. - * This enables more context-aware analyses, e.g. measuring star height. - */ - traverse: function traverse(ast, handlers, options) { - return _traverse.traverse(ast, handlers, options); - }, +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var RegExpTree$1 = function () { + /** + * Initializes a `RegExpTree` instance. + * + * @param RegExp - a regular expression + * + * @param Object state: + * + * An extra state which may store any related to transformation + * data, for example, names of the groups. + * + * - flags - original flags + * - groups - names of the groups, and their indices + * - source - original source + */ + function RegExpTree(re, _ref) { + var flags = _ref.flags, + groups = _ref.groups, + source = _ref.source; + + _classCallCheck(this, RegExpTree); + + this._re = re; + this._groups = groups; + + // Original props. + this.flags = flags; + this.source = source || re.source; + this.dotAll = flags.includes('s'); + + // Inherited directly from `re`. + this.global = re.global; + this.ignoreCase = re.ignoreCase; + this.multiline = re.multiline; + this.sticky = re.sticky; + this.unicode = re.unicode; + } + /** + * Facade wrapper for RegExp `test` method. + */ - /** - * Transforms a regular expression. - * - * A regexp can be passed in different formats (string, regexp or AST), - * applying a set of transformations. It is a convenient wrapper - * on top of "parse-traverse-generate" tool chain. - * - * @param string | AST | RegExp regexp - a regular expression; - * @param Object | Array handlers - a list of handlers. - * - * @return TransformResult - a transformation result. - */ - transform: function transform(regexp, handlers) { - return _transform.transform(regexp, handlers); - }, + _createClass(RegExpTree, [{ + key: 'test', + value: function test(string) { + return this._re.test(string); + } - /** - * Generates a RegExp string from an AST. - * - * @param Object ast - * - * Invariant: - * - * regexpTree.generate(regexpTree.parse('/[a-z]+/i')); // '/[a-z]+/i' - */ - generate: function generate(ast) { - return generator.generate(ast); - }, + /** + * Facade wrapper for RegExp `compile` method. + */ + }, { + key: 'compile', + value: function compile(string) { + return this._re.compile(string); + } - /** - * Creates a RegExp object from a regexp string. - * - * @param string regexp - */ - toRegExp: function toRegExp(regexp) { - var compat = this.compatTranspile(regexp); - return new RegExp(compat.getSource(), compat.getFlags()); - }, + /** + * Facade wrapper for RegExp `toString` method. + */ + }, { + key: 'toString', + value: function toString() { + if (!this._toStringResult) { + this._toStringResult = '/' + this.source + '/' + this.flags; + } + return this._toStringResult; + } - /** - * Optimizes a regular expression by replacing some - * sub-expressions with their idiomatic patterns. - * - * @param string regexp - * - * @return TransformResult object - */ - optimize: function optimize(regexp, whitelist) { - var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, - blacklist = _ref.blacklist; + /** + * Facade wrapper for RegExp `exec` method. + */ - return optimizer.optimize(regexp, { whitelist: whitelist, blacklist: blacklist }); - }, + }, { + key: 'exec', + value: function exec(string) { + var result = this._re.exec(string); + if (!this._groups || !result) { + return result; + } - /** - * Translates a regular expression in new syntax or in new format - * into equivalent expressions in old syntax. - * - * @param string regexp - * - * @return TransformResult object - */ - compatTranspile: function compatTranspile(regexp, whitelist) { - return compatTranspiler.transform(regexp, whitelist); - }, + result.groups = {}; + for (var group in this._groups) { + var groupNumber = this._groups[group]; + result.groups[group] = result[groupNumber]; + } - /** - * Executes a regular expression on a string. - * - * @param RegExp|string re - a regular expression. - * @param string string - a testing string. - */ - exec: function exec(re, string) { - if (typeof re === 'string') { - var compat = this.compatTranspile(re); - var extra = compat.getExtra(); - - if (extra.namedCapturingGroups) { - re = new RegExpTree(compat.toRegExp(), { - flags: compat.getFlags(), - source: compat.getSource(), - groups: extra.namedCapturingGroups - }); - } else { - re = compat.toRegExp(); - } - } + return result; + } + }]); - return re.exec(string); - } - }; + return RegExpTree; +}(); - regexpTree_1 = regexpTree; - return regexpTree_1; -} +var runtime = { + RegExpTree: RegExpTree$1 +}; /** * The MIT License (MIT) * Copyright (c) 2017-present Dmitry Soshnikov */ -var regexpTree; -var hasRequiredRegexpTree; +var compatTranspiler = compatTranspiler$1; +var generator = generator_1; +var optimizer = optimizer$1; +var parser = parser$4; +var _transform = transform$3; +var _traverse = traverse$3; +var fa = finiteAutomaton; -function requireRegexpTree () { - if (hasRequiredRegexpTree) return regexpTree; - hasRequiredRegexpTree = 1; +var _require = runtime, + RegExpTree = _require.RegExpTree; - regexpTree = requireRegexpTree$1(); - return regexpTree; -} +/** + * An API object for RegExp processing (parsing/transform/generation). + */ -var isSimpleRegexp; -var hasRequiredIsSimpleRegexp; -function requireIsSimpleRegexp () { - if (hasRequiredIsSimpleRegexp) return isSimpleRegexp; - hasRequiredIsSimpleRegexp = 1; +var regexpTree$2 = { + /** + * Parser module exposed. + */ + parser: parser, + + /** + * Expose finite-automaton module. + */ + fa: fa, + + /** + * `TransformResult` exposed. + */ + TransformResult: _transform.TransformResult, + + /** + * Parses a regexp string, producing an AST. + * + * @param string regexp + * + * a regular expression in different formats: string, AST, RegExp. + * + * @param Object options + * + * parsing options for this parse call. Default are: + * + * - captureLocations: boolean + * - any other custom options + * + * @return Object AST + */ + parse: function parse(regexp, options) { + return parser.parse('' + regexp, options); + }, + + + /** + * Traverses a RegExp AST. + * + * @param Object ast + * @param Object | Array handlers + * + * Each `handler` is an object containing handler function for needed + * node types. Example: + * + * regexpTree.traverse(ast, { + * onChar(node) { + * ... + * }, + * }); + * + * The value for a node type may also be an object with functions pre and post. + * This enables more context-aware analyses, e.g. measuring star height. + */ + traverse: function traverse(ast, handlers, options) { + return _traverse.traverse(ast, handlers, options); + }, + + + /** + * Transforms a regular expression. + * + * A regexp can be passed in different formats (string, regexp or AST), + * applying a set of transformations. It is a convenient wrapper + * on top of "parse-traverse-generate" tool chain. + * + * @param string | AST | RegExp regexp - a regular expression; + * @param Object | Array handlers - a list of handlers. + * + * @return TransformResult - a transformation result. + */ + transform: function transform(regexp, handlers) { + return _transform.transform(regexp, handlers); + }, + + + /** + * Generates a RegExp string from an AST. + * + * @param Object ast + * + * Invariant: + * + * regexpTree.generate(regexpTree.parse('/[a-z]+/i')); // '/[a-z]+/i' + */ + generate: function generate(ast) { + return generator.generate(ast); + }, + + + /** + * Creates a RegExp object from a regexp string. + * + * @param string regexp + */ + toRegExp: function toRegExp(regexp) { + var compat = this.compatTranspile(regexp); + return new RegExp(compat.getSource(), compat.getFlags()); + }, + + + /** + * Optimizes a regular expression by replacing some + * sub-expressions with their idiomatic patterns. + * + * @param string regexp + * + * @return TransformResult object + */ + optimize: function optimize(regexp, whitelist) { + var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + blacklist = _ref.blacklist; + + return optimizer.optimize(regexp, { whitelist: whitelist, blacklist: blacklist }); + }, + + + /** + * Translates a regular expression in new syntax or in new format + * into equivalent expressions in old syntax. + * + * @param string regexp + * + * @return TransformResult object + */ + compatTranspile: function compatTranspile(regexp, whitelist) { + return compatTranspiler.transform(regexp, whitelist); + }, + + + /** + * Executes a regular expression on a string. + * + * @param RegExp|string re - a regular expression. + * @param string string - a testing string. + */ + exec: function exec(re, string) { + if (typeof re === 'string') { + var compat = this.compatTranspile(re); + var extra = compat.getExtra(); + + if (extra.namedCapturingGroups) { + re = new RegExpTree(compat.toRegExp(), { + flags: compat.getFlags(), + source: compat.getSource(), + groups: extra.namedCapturingGroups + }); + } else { + re = compat.toRegExp(); + } + } - const regexpTree = requireRegexpTree(); + return re.exec(string); + } +}; - const notSimpleChar = ({type, kind}) => type !== 'Char' || kind !== 'simple'; +var regexpTree_1 = regexpTree$2; - isSimpleRegexp = (regexp) => { - let containsMoreThenSimpleChars = false; - const ast = regexpTree.parse(regexp); - - if (ast.body.type !== 'Alternative') - return false; - - regexpTree.traverse(ast, { - RegExp({node}) { - const {expressions} = node.body; - containsMoreThenSimpleChars = Boolean(expressions.find(notSimpleChar)); - }, - }); - - return !containsMoreThenSimpleChars; - }; - return isSimpleRegexp; -} +/** + * The MIT License (MIT) + * Copyright (c) 2017-present Dmitry Soshnikov + */ -var regexp; -var hasRequiredRegexp; +var regexpTree$1 = regexpTree_1; -function requireRegexp () { - if (hasRequiredRegexp) return regexp; - hasRequiredRegexp = 1; +const regexpTree = regexpTree$1; - const isSimpleRegExp = requireIsSimpleRegexp(); +const notSimpleChar = ({type, kind}) => type !== 'Char' || kind !== 'simple'; - regexp = { - isSimpleRegExp, - }; - return regexp; -} +var isSimpleRegexp = (regexp) => { + let containsMoreThenSimpleChars = false; + const ast = regexpTree.parse(regexp); + + if (ast.body.type !== 'Alternative') + return false; + + regexpTree.traverse(ast, { + RegExp({node}) { + const {expressions} = node.body; + containsMoreThenSimpleChars = Boolean(expressions.find(notSimpleChar)); + }, + }); + + return !containsMoreThenSimpleChars; +}; -var addArgs = {}; +isSimpleRegexp.default; -var hasRequiredAddArgs; +const isSimpleRegExp = isSimpleRegexp; -function requireAddArgs () { - if (hasRequiredAddArgs) return addArgs; - hasRequiredAddArgs = 1; +var regexp = { + isSimpleRegExp, +}; - const {compareAny} = requireCompare(); - const {template} = requireParser$1(); - const {types} = requireBundle(); - const { - ObjectPattern, - ObjectProperty, - isBlockStatement, - isFunction, - isLabeledStatement, - isObjectPattern, - isCallExpression, - } = types; +var addArgs = {}; - const {entries} = Object; +const {compareAny} = compare$5; +const {template: template$1} = parser$6; +const {types: types$2} = bundle; +const { + ObjectPattern, + ObjectProperty, + isBlockStatement, + isFunction, + isLabeledStatement, + isObjectPattern, + isCallExpression, +} = types$2; - const COMPUTED = true; - const SHORTHAND = true; +const {entries: entries$1} = Object; - const isCallOrStatement = (path) => path.isCallExpression() || path.isStatement(); +const COMPUTED = true; +const SHORTHAND = true; - const isCall = (path) => { - return isCallExpression(path.find(isCallOrStatement)); - }; +const isCallOrStatement = (path) => path.isCallExpression() || path.isStatement(); - const report = ({name}) => `Argument '${name}' is missing`; +const isCall = (path) => { + return isCallExpression(path.find(isCallOrStatement)); +}; - addArgs.addArgs = (args) => ({ - report, - fix, - traverse: traverse(args), - }); +const report$2 = ({name}) => `Argument '${name}' is missing`; - const fix = ({declaration, path, pattern, params, index}) => { - const declarationNode = template.ast.fresh(declaration); - - if (isBlockStatement(declarationNode)) { - const prop = createProperty(declarationNode.body[0]); - pattern.properties.push(prop); - - if (!isObjectPattern(params[index])) - return params.push(pattern); - - return; - } - - path.scope.block.params = [ - declarationNode, - ]; - }; +addArgs.addArgs = (args) => ({ + report: report$2, + fix: fix$2, + traverse: traverse$1(args), +}); - const traverse = (args) => ({push, options}) => { - const allArgs = { - ...options.args, - ...args, - }; - - return { - ReferencedIdentifier(path) { - for (const [name, [declaration, pattern]] of entries(allArgs)) { - if (path.node.name !== name) - continue; - - if (path.scope.hasBinding(name)) - continue; - - if (!isCall(path)) - continue; - - const fnPath = path.find(isFunction); - - if (!fnPath) - continue; - - const {block} = fnPath.scope; - - if (!compareAny(path.scope.path, pattern)) - continue; - - const {params} = block; - - const [index, lastParam] = getObjectPattern(params); - - if (isObjectPattern(lastParam)) { - push({ - name, - index, - declaration, - path, - params, - pattern: lastParam, - }); - return; - } - - if (params.length >= 3) - return; - - push({ - name, - index, - declaration, - path, - params, - pattern: ObjectPattern([]), - }); - } - }, - }; - }; +const fix$2 = ({declaration, path, pattern, params, index}) => { + const declarationNode = template$1.ast.fresh(declaration); + + if (isBlockStatement(declarationNode)) { + const prop = createProperty(declarationNode.body[0]); + pattern.properties.push(prop); + + if (!isObjectPattern(params[index])) + return params.push(pattern); + + return; + } + + path.scope.block.params = [ + declarationNode, + ]; +}; - function createProperty(node) { - if (!isLabeledStatement(node)) { - const {expression} = node; - return ObjectProperty(expression, expression, !COMPUTED, SHORTHAND); - } - - const {label, body} = node; - - return ObjectProperty(label, body.expression, !COMPUTED, SHORTHAND); - } +const traverse$1 = (args) => ({push, options}) => { + const allArgs = { + ...options.args, + ...args, + }; + + return { + ReferencedIdentifier(path) { + for (const [name, [declaration, pattern]] of entries$1(allArgs)) { + if (path.node.name !== name) + continue; + + if (path.scope.hasBinding(name)) + continue; + + if (!isCall(path)) + continue; + + const fnPath = path.find(isFunction); + + if (!fnPath) + continue; + + const {block} = fnPath.scope; + + if (!compareAny(path.scope.path, pattern)) + continue; + + const {params} = block; + + const [index, lastParam] = getObjectPattern(params); + + if (isObjectPattern(lastParam)) { + push({ + name, + index, + declaration, + path, + params, + pattern: lastParam, + }); + return; + } + + if (params.length >= 3) + return; + + push({ + name, + index, + declaration, + path, + params, + pattern: ObjectPattern([]), + }); + } + }, + }; +}; - function getObjectPattern(params) { - for (const [i, param] of params.entries()) { - if (isObjectPattern(param)) - return [i, param]; - } - - return [ - -1, - null, - ]; - } - return addArgs; +function createProperty(node) { + if (!isLabeledStatement(node)) { + const {expression} = node; + return ObjectProperty(expression, expression, !COMPUTED, SHORTHAND); + } + + const {label, body} = node; + + return ObjectProperty(label, body.expression, !COMPUTED, SHORTHAND); +} + +function getObjectPattern(params) { + for (const [i, param] of params.entries()) { + if (isObjectPattern(param)) + return [i, param]; + } + + return [ + -1, + null, + ]; } var matchFiles = {}; -var ignore$1; -var hasRequiredIgnore$1; - -function requireIgnore$1 () { - if (hasRequiredIgnore$1) return ignore$1; - hasRequiredIgnore$1 = 1; - // A simple implementation of make-array - function makeArray (subject) { - return Array.isArray(subject) - ? subject - : [subject] - } +// A simple implementation of make-array +function makeArray (subject) { + return Array.isArray(subject) + ? subject + : [subject] +} + +const EMPTY = ''; +const SPACE = ' '; +const ESCAPE = '\\'; +const REGEX_TEST_BLANK_LINE = /^\s+$/; +const REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/; +const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/; +const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/; +const REGEX_SPLITALL_CRLF = /\r?\n/g; +// /foo, +// ./foo, +// ../foo, +// . +// .. +const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/; + +const SLASH = '/'; + +// Do not use ternary expression here, since "istanbul ignore next" is buggy +let TMP_KEY_IGNORE = 'node-ignore'; +/* istanbul ignore else */ +if (typeof Symbol !== 'undefined') { + TMP_KEY_IGNORE = Symbol.for('node-ignore'); +} +const KEY_IGNORE = TMP_KEY_IGNORE; + +const define = (object, key, value) => + Object.defineProperty(object, key, {value}); + +const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; + +const RETURN_FALSE = () => false; + +// Sanitize the range of a regular expression +// The cases are complicated, see test cases for details +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 + // fatal for JavaScript regular expression, so eliminate it. + : EMPTY +); + +// See fixtures #59 +const cleanRangeBackSlash = slashes => { + const {length} = slashes; + return slashes.slice(0, length - length % 2) +}; - const EMPTY = ''; - const SPACE = ' '; - const ESCAPE = '\\'; - const REGEX_TEST_BLANK_LINE = /^\s+$/; - const REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/; - const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/; - const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/; - const REGEX_SPLITALL_CRLF = /\r?\n/g; - // /foo, - // ./foo, - // ../foo, - // . - // .. - const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/; - - const SLASH = '/'; - - // Do not use ternary expression here, since "istanbul ignore next" is buggy - let TMP_KEY_IGNORE = 'node-ignore'; - /* istanbul ignore else */ - if (typeof Symbol !== 'undefined') { - TMP_KEY_IGNORE = Symbol.for('node-ignore'); - } - const KEY_IGNORE = TMP_KEY_IGNORE; - - const define = (object, key, value) => - Object.defineProperty(object, key, {value}); - - const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; - - const RETURN_FALSE = () => false; - - // Sanitize the range of a regular expression - // The cases are complicated, see test cases for details - 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 - // fatal for JavaScript regular expression, so eliminate it. - : EMPTY - ); - - // See fixtures #59 - const cleanRangeBackSlash = slashes => { - const {length} = slashes; - return slashes.slice(0, length - length % 2) - }; +// > If the pattern ends with a slash, +// > it is removed for the purpose of the following description, +// > but it would only find a match with a directory. +// > In other words, foo/ will match a directory foo and paths underneath it, +// > but will not match a regular file or a symbolic link foo +// > (this is consistent with the way how pathspec works in general in Git). +// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`' +// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call +// you could use option `mark: true` with `glob` + +// '`foo/`' should not continue with the '`..`' +const REPLACERS = [ + + [ + // remove BOM + // TODO: + // Other similar zero-width characters? + /^\uFEFF/, + () => EMPTY + ], + + // > Trailing spaces are ignored unless they are quoted with backslash ("\") + [ + // (a\ ) -> (a ) + // (a ) -> (a) + // (a ) -> (a) + // (a \ ) -> (a ) + /((?:\\\\)*?)(\\?\s+)$/, + (_, m1, m2) => m1 + ( + m2.indexOf('\\') === 0 + ? SPACE + : EMPTY + ) + ], + + // replace (\ ) with ' ' + // (\ ) -> ' ' + // (\\ ) -> '\\ ' + // (\\\ ) -> '\\ ' + [ + /(\\+?)\s/g, + (_, m1) => { + const {length} = m1; + return m1.slice(0, length - length % 2) + SPACE + } + ], + + // Escape metacharacters + // which is written down by users but means special for regular expressions. + + // > There are 12 characters with special meanings: + // > - the backslash \, + // > - the caret ^, + // > - the dollar sign $, + // > - the period or dot ., + // > - the vertical bar or pipe symbol |, + // > - the question mark ?, + // > - the asterisk or star *, + // > - the plus sign +, + // > - the opening parenthesis (, + // > - the closing parenthesis ), + // > - and the opening square bracket [, + // > - the opening curly brace {, + // > These special characters are often called "metacharacters". + [ + /[\\$.|*+(){^]/g, + match => `\\${match}` + ], + + [ + // > a question mark (?) matches a single character + /(?!\\)\?/g, + () => '[^/]' + ], + + // leading slash + [ + + // > A leading slash matches the beginning of the pathname. + // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". + // A leading slash matches the beginning of the pathname + /^\//, + () => '^' + ], + + // replace special metacharacter slash after the leading slash + [ + /\//g, + () => '\\/' + ], + + [ + // > A leading "**" followed by a slash means match in all directories. + // > For example, "**/foo" matches file or directory "foo" anywhere, + // > the same as pattern "foo". + // > "**/foo/bar" matches file or directory "bar" anywhere that is directly + // > under directory "foo". + // Notice that the '*'s have been replaced as '\\*' + /^\^*\\\*\\\*\\\//, + + // '**/foo' <-> 'foo' + () => '^(?:.*\\/)?' + ], + + // starting + [ + // there will be no leading '/' + // (which has been replaced by section "leading slash") + // If starts with '**', adding a '^' to the regular expression also works + /^(?=[^^])/, + function startingReplacer () { + // If has a slash `/` at the beginning or middle + return !/\/(?!$)/.test(this) + // > Prior to 2.22.1 + // > If the pattern does not contain a slash /, + // > Git treats it as a shell glob pattern + // Actually, if there is only a trailing slash, + // git also treats it as a shell glob pattern + + // After 2.22.1 (compatible but clearer) + // > If there is a separator at the beginning or middle (or both) + // > of the pattern, then the pattern is relative to the directory + // > level of the particular .gitignore file itself. + // > Otherwise the pattern may also match at any level below + // > the .gitignore level. + ? '(?:^|\\/)' + + // > Otherwise, Git treats the pattern as a shell glob suitable for + // > consumption by fnmatch(3) + : '^' + } + ], + + // two globstars + [ + // Use lookahead assertions so that we could match more than one `'/**'` + /\\\/\\\*\\\*(?=\\\/|$)/g, + + // Zero, one or several directories + // should not use '*', or it will be replaced by the next replacer + + // Check if it is not the last `'/**'` + (_, index, str) => index + 6 < str.length + + // case: /**/ + // > A slash followed by two consecutive asterisks then a slash matches + // > zero or more directories. + // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on. + // '/**/' + ? '(?:\\/[^\\/]+)*' + + // case: /** + // > A trailing `"/**"` matches everything inside. + + // #21: everything inside but it should not include the current folder + : '\\/.+' + ], + + // normal intermediate wildcards + [ + // Never replace escaped '*' + // ignore rule '\*' will match the path '*' + + // 'abc.*/' -> go + // 'abc.*' -> skip this rule, + // coz trailing single wildcard will be handed by [trailing wildcard] + /(^|[^\\]+)(\\\*)+(?=.+)/g, + + // '*.js' matches '.js' + // '*.js' doesn't match 'abc' + (_, p1, p2) => { + // 1. + // > An asterisk "*" matches anything except a slash. + // 2. + // > Other consecutive asterisks are considered regular asterisks + // > and will match according to the previous rules. + const unescaped = p2.replace(/\\\*/g, '[^\\/]*'); + return p1 + unescaped + } + ], + + [ + // unescape, revert step 3 except for back slash + // For example, if a user escape a '\\*', + // after step 3, the result will be '\\\\\\*' + /\\\\\\(?=[$.|*+(){^])/g, + () => ESCAPE + ], + + [ + // '\\\\' -> '\\' + /\\\\/g, + () => ESCAPE + ], + + [ + // > The range notation, e.g. [a-zA-Z], + // > can be used to match one of the characters in a range. + + // `\` is escaped by step 3 + /(\\)?\[([^\]/]*?)(\\*)($|\])/g, + (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE + // '\\[bar]' -> '\\\\[bar\\]' + ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` + : close === ']' + ? endEscape.length % 2 === 0 + // A normal case, and it is a range notation + // '[bar]' + // '[bar\\\\]' + ? `[${sanitizeRange(range)}${endEscape}]` + // Invalid range notaton + // '[bar\\]' -> '[bar\\\\]' + : '[]' + : '[]' + ], + + // ending + [ + // 'js' will not match 'js.' + // 'ab' will not match 'abc' + /(?:[^*])$/, + + // WTF! + // https://git-scm.com/docs/gitignore + // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1) + // which re-fixes #24, #38 + + // > If there is a separator at the end of the pattern then the pattern + // > will only match directories, otherwise the pattern can match both + // > files and directories. + + // 'js*' will not match 'a.js' + // 'js/' will not match 'a.js' + // 'js' will match 'a.js' and 'a.js/' + match => /\/$/.test(match) + // foo/ will not match 'foo' + ? `${match}$` + // foo matches 'foo' and 'foo/' + : `${match}(?=$|\\/$)` + ], + + // trailing wildcard + [ + /(\^|\\\/)?\\\*$/, + (_, p1) => { + const prefix = p1 + // '\^': + // '/*' does not match EMPTY + // '/*' does not match everything + + // '\\\/': + // 'abc/*' does not match 'abc/' + ? `${p1}[^/]+` + + // 'a*' matches 'a' + // 'a*' matches 'aa' + : '[^/]*'; + + return `${prefix}(?=$|\\/$)` + } + ], +]; - // > If the pattern ends with a slash, - // > it is removed for the purpose of the following description, - // > but it would only find a match with a directory. - // > In other words, foo/ will match a directory foo and paths underneath it, - // > but will not match a regular file or a symbolic link foo - // > (this is consistent with the way how pathspec works in general in Git). - // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`' - // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call - // you could use option `mark: true` with `glob` - - // '`foo/`' should not continue with the '`..`' - const REPLACERS = [ - - [ - // remove BOM - // TODO: - // Other similar zero-width characters? - /^\uFEFF/, - () => EMPTY - ], - - // > Trailing spaces are ignored unless they are quoted with backslash ("\") - [ - // (a\ ) -> (a ) - // (a ) -> (a) - // (a ) -> (a) - // (a \ ) -> (a ) - /((?:\\\\)*?)(\\?\s+)$/, - (_, m1, m2) => m1 + ( - m2.indexOf('\\') === 0 - ? SPACE - : EMPTY - ) - ], - - // replace (\ ) with ' ' - // (\ ) -> ' ' - // (\\ ) -> '\\ ' - // (\\\ ) -> '\\ ' - [ - /(\\+?)\s/g, - (_, m1) => { - const {length} = m1; - return m1.slice(0, length - length % 2) + SPACE - } - ], - - // Escape metacharacters - // which is written down by users but means special for regular expressions. - - // > There are 12 characters with special meanings: - // > - the backslash \, - // > - the caret ^, - // > - the dollar sign $, - // > - the period or dot ., - // > - the vertical bar or pipe symbol |, - // > - the question mark ?, - // > - the asterisk or star *, - // > - the plus sign +, - // > - the opening parenthesis (, - // > - the closing parenthesis ), - // > - and the opening square bracket [, - // > - the opening curly brace {, - // > These special characters are often called "metacharacters". - [ - /[\\$.|*+(){^]/g, - match => `\\${match}` - ], - - [ - // > a question mark (?) matches a single character - /(?!\\)\?/g, - () => '[^/]' - ], - - // leading slash - [ - - // > A leading slash matches the beginning of the pathname. - // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". - // A leading slash matches the beginning of the pathname - /^\//, - () => '^' - ], - - // replace special metacharacter slash after the leading slash - [ - /\//g, - () => '\\/' - ], - - [ - // > A leading "**" followed by a slash means match in all directories. - // > For example, "**/foo" matches file or directory "foo" anywhere, - // > the same as pattern "foo". - // > "**/foo/bar" matches file or directory "bar" anywhere that is directly - // > under directory "foo". - // Notice that the '*'s have been replaced as '\\*' - /^\^*\\\*\\\*\\\//, - - // '**/foo' <-> 'foo' - () => '^(?:.*\\/)?' - ], - - // starting - [ - // there will be no leading '/' - // (which has been replaced by section "leading slash") - // If starts with '**', adding a '^' to the regular expression also works - /^(?=[^^])/, - function startingReplacer () { - // If has a slash `/` at the beginning or middle - return !/\/(?!$)/.test(this) - // > Prior to 2.22.1 - // > If the pattern does not contain a slash /, - // > Git treats it as a shell glob pattern - // Actually, if there is only a trailing slash, - // git also treats it as a shell glob pattern - - // After 2.22.1 (compatible but clearer) - // > If there is a separator at the beginning or middle (or both) - // > of the pattern, then the pattern is relative to the directory - // > level of the particular .gitignore file itself. - // > Otherwise the pattern may also match at any level below - // > the .gitignore level. - ? '(?:^|\\/)' - - // > Otherwise, Git treats the pattern as a shell glob suitable for - // > consumption by fnmatch(3) - : '^' - } - ], - - // two globstars - [ - // Use lookahead assertions so that we could match more than one `'/**'` - /\\\/\\\*\\\*(?=\\\/|$)/g, - - // Zero, one or several directories - // should not use '*', or it will be replaced by the next replacer - - // Check if it is not the last `'/**'` - (_, index, str) => index + 6 < str.length - - // case: /**/ - // > A slash followed by two consecutive asterisks then a slash matches - // > zero or more directories. - // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on. - // '/**/' - ? '(?:\\/[^\\/]+)*' - - // case: /** - // > A trailing `"/**"` matches everything inside. - - // #21: everything inside but it should not include the current folder - : '\\/.+' - ], - - // normal intermediate wildcards - [ - // Never replace escaped '*' - // ignore rule '\*' will match the path '*' - - // 'abc.*/' -> go - // 'abc.*' -> skip this rule, - // coz trailing single wildcard will be handed by [trailing wildcard] - /(^|[^\\]+)(\\\*)+(?=.+)/g, - - // '*.js' matches '.js' - // '*.js' doesn't match 'abc' - (_, p1, p2) => { - // 1. - // > An asterisk "*" matches anything except a slash. - // 2. - // > Other consecutive asterisks are considered regular asterisks - // > and will match according to the previous rules. - const unescaped = p2.replace(/\\\*/g, '[^\\/]*'); - return p1 + unescaped - } - ], - - [ - // unescape, revert step 3 except for back slash - // For example, if a user escape a '\\*', - // after step 3, the result will be '\\\\\\*' - /\\\\\\(?=[$.|*+(){^])/g, - () => ESCAPE - ], - - [ - // '\\\\' -> '\\' - /\\\\/g, - () => ESCAPE - ], - - [ - // > The range notation, e.g. [a-zA-Z], - // > can be used to match one of the characters in a range. - - // `\` is escaped by step 3 - /(\\)?\[([^\]/]*?)(\\*)($|\])/g, - (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE - // '\\[bar]' -> '\\\\[bar\\]' - ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` - : close === ']' - ? endEscape.length % 2 === 0 - // A normal case, and it is a range notation - // '[bar]' - // '[bar\\\\]' - ? `[${sanitizeRange(range)}${endEscape}]` - // Invalid range notaton - // '[bar\\]' -> '[bar\\\\]' - : '[]' - : '[]' - ], - - // ending - [ - // 'js' will not match 'js.' - // 'ab' will not match 'abc' - /(?:[^*])$/, - - // WTF! - // https://git-scm.com/docs/gitignore - // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1) - // which re-fixes #24, #38 - - // > If there is a separator at the end of the pattern then the pattern - // > will only match directories, otherwise the pattern can match both - // > files and directories. - - // 'js*' will not match 'a.js' - // 'js/' will not match 'a.js' - // 'js' will match 'a.js' and 'a.js/' - match => /\/$/.test(match) - // foo/ will not match 'foo' - ? `${match}$` - // foo matches 'foo' and 'foo/' - : `${match}(?=$|\\/$)` - ], - - // trailing wildcard - [ - /(\^|\\\/)?\\\*$/, - (_, p1) => { - const prefix = p1 - // '\^': - // '/*' does not match EMPTY - // '/*' does not match everything - - // '\\\/': - // 'abc/*' does not match 'abc/' - ? `${p1}[^/]+` - - // 'a*' matches 'a' - // 'a*' matches 'aa' - : '[^/]*'; - - return `${prefix}(?=$|\\/$)` - } - ], - ]; +// A simple cache, because an ignore rule only has only one certain meaning +const regexCache = Object.create(null); - // A simple cache, because an ignore rule only has only one certain meaning - const regexCache = Object.create(null); +// @param {pattern} +const makeRegex = (pattern, ignoreCase) => { + let source = regexCache[pattern]; - // @param {pattern} - const makeRegex = (pattern, ignoreCase) => { - let source = regexCache[pattern]; + if (!source) { + source = REPLACERS.reduce( + (prev, [matcher, replacer]) => + prev.replace(matcher, replacer.bind(pattern)), + pattern + ); + regexCache[pattern] = source; + } - if (!source) { - source = REPLACERS.reduce( - (prev, [matcher, replacer]) => - prev.replace(matcher, replacer.bind(pattern)), - pattern - ); - regexCache[pattern] = source; - } + return ignoreCase + ? new RegExp(source, 'i') + : new RegExp(source) +}; - return ignoreCase - ? new RegExp(source, 'i') - : new RegExp(source) - }; +const isString$1 = subject => typeof subject === 'string'; + +// > A blank line matches no files, so it can serve as a separator for readability. +const checkPattern = pattern => pattern + && isString$1(pattern) + && !REGEX_TEST_BLANK_LINE.test(pattern) + && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) + + // > A line starting with # serves as a comment. + && pattern.indexOf('#') !== 0; + +const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF); + +class IgnoreRule { + constructor ( + origin, + pattern, + negative, + regex + ) { + this.origin = origin; + this.pattern = pattern; + this.negative = negative; + this.regex = regex; + } +} - const isString = subject => typeof subject === 'string'; - - // > A blank line matches no files, so it can serve as a separator for readability. - const checkPattern = pattern => pattern - && isString(pattern) - && !REGEX_TEST_BLANK_LINE.test(pattern) - && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) - - // > A line starting with # serves as a comment. - && pattern.indexOf('#') !== 0; - - const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF); - - class IgnoreRule { - constructor ( - origin, - pattern, - negative, - regex - ) { - this.origin = origin; - this.pattern = pattern; - this.negative = negative; - this.regex = regex; - } - } +const createRule = (pattern, ignoreCase) => { + const origin = pattern; + let negative = false; - const createRule = (pattern, ignoreCase) => { - const origin = pattern; - let negative = false; + // > An optional prefix "!" which negates the pattern; + if (pattern.indexOf('!') === 0) { + negative = true; + pattern = pattern.substr(1); + } - // > An optional prefix "!" which negates the pattern; - if (pattern.indexOf('!') === 0) { - negative = true; - pattern = pattern.substr(1); - } + pattern = pattern + // > Put a backslash ("\") in front of the first "!" for patterns that + // > begin with a literal "!", for example, `"\!important!.txt"`. + .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!') + // > Put a backslash ("\") in front of the first hash for patterns that + // > begin with a hash. + .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#'); + + const regex = makeRegex(pattern, ignoreCase); + + return new IgnoreRule( + origin, + pattern, + negative, + regex + ) +}; - pattern = pattern - // > Put a backslash ("\") in front of the first "!" for patterns that - // > begin with a literal "!", for example, `"\!important!.txt"`. - .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!') - // > Put a backslash ("\") in front of the first hash for patterns that - // > begin with a hash. - .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#'); - - const regex = makeRegex(pattern, ignoreCase); - - return new IgnoreRule( - origin, - pattern, - negative, - regex - ) - }; +const throwError = (message, Ctor) => { + throw new Ctor(message) +}; - const throwError = (message, Ctor) => { - throw new Ctor(message) - }; +const checkPath = (path, originalPath, doThrow) => { + if (!isString$1(path)) { + return doThrow( + `path must be a string, but got \`${originalPath}\``, + TypeError + ) + } - const checkPath = (path, originalPath, doThrow) => { - if (!isString(path)) { - return doThrow( - `path must be a string, but got \`${originalPath}\``, - TypeError - ) - } + // We don't know if we should ignore EMPTY, so throw + if (!path) { + return doThrow(`path must not be empty`, TypeError) + } - // We don't know if we should ignore EMPTY, so throw - if (!path) { - return doThrow(`path must not be empty`, TypeError) - } + // Check if it is a relative path + if (checkPath.isNotRelative(path)) { + const r = '`path.relative()`d'; + return doThrow( + `path should be a ${r} string, but got "${originalPath}"`, + RangeError + ) + } - // Check if it is a relative path - if (checkPath.isNotRelative(path)) { - const r = '`path.relative()`d'; - return doThrow( - `path should be a ${r} string, but got "${originalPath}"`, - RangeError - ) - } + return true +}; - return true - }; +const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path); - const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path); +checkPath.isNotRelative = isNotRelative; +checkPath.convert = p => p; - checkPath.isNotRelative = isNotRelative; - checkPath.convert = p => p; +class Ignore { + constructor ({ + ignorecase = true, + ignoreCase = ignorecase, + allowRelativePaths = false + } = {}) { + define(this, KEY_IGNORE, true); - class Ignore { - constructor ({ - ignorecase = true, - ignoreCase = ignorecase, - allowRelativePaths = false - } = {}) { - define(this, KEY_IGNORE, true); + this._rules = []; + this._ignoreCase = ignoreCase; + this._allowRelativePaths = allowRelativePaths; + this._initCache(); + } - this._rules = []; - this._ignoreCase = ignoreCase; - this._allowRelativePaths = allowRelativePaths; - this._initCache(); - } + _initCache () { + this._ignoreCache = Object.create(null); + this._testCache = Object.create(null); + } - _initCache () { - this._ignoreCache = Object.create(null); - this._testCache = Object.create(null); - } + _addPattern (pattern) { + // #32 + if (pattern && pattern[KEY_IGNORE]) { + this._rules = this._rules.concat(pattern._rules); + this._added = true; + return + } - _addPattern (pattern) { - // #32 - if (pattern && pattern[KEY_IGNORE]) { - this._rules = this._rules.concat(pattern._rules); - this._added = true; - return - } + if (checkPattern(pattern)) { + const rule = createRule(pattern, this._ignoreCase); + this._added = true; + this._rules.push(rule); + } + } - if (checkPattern(pattern)) { - const rule = createRule(pattern, this._ignoreCase); - this._added = true; - this._rules.push(rule); - } - } + // @param {Array | string | Ignore} pattern + add (pattern) { + this._added = false; - // @param {Array | string | Ignore} pattern - add (pattern) { - this._added = false; + makeArray( + isString$1(pattern) + ? splitPattern(pattern) + : pattern + ).forEach(this._addPattern, this); - makeArray( - isString(pattern) - ? splitPattern(pattern) - : pattern - ).forEach(this._addPattern, this); + // Some rules have just added to the ignore, + // making the behavior changed. + if (this._added) { + this._initCache(); + } - // Some rules have just added to the ignore, - // making the behavior changed. - if (this._added) { - this._initCache(); - } + return this + } - return this - } + // legacy + addPattern (pattern) { + return this.add(pattern) + } - // legacy - addPattern (pattern) { - return this.add(pattern) - } + // | ignored : unignored + // negative | 0:0 | 0:1 | 1:0 | 1:1 + // -------- | ------- | ------- | ------- | -------- + // 0 | TEST | TEST | SKIP | X + // 1 | TESTIF | SKIP | TEST | X + + // - SKIP: always skip + // - TEST: always test + // - TESTIF: only test if checkUnignored + // - X: that never happen + + // @param {boolean} whether should check if the path is unignored, + // setting `checkUnignored` to `false` could reduce additional + // path matching. + + // @returns {TestResult} true if a file is ignored + _testOne (path, checkUnignored) { + let ignored = false; + let unignored = false; + + this._rules.forEach(rule => { + const {negative} = rule; + if ( + unignored === negative && ignored !== unignored + || negative && !ignored && !unignored && !checkUnignored + ) { + return + } - // | ignored : unignored - // negative | 0:0 | 0:1 | 1:0 | 1:1 - // -------- | ------- | ------- | ------- | -------- - // 0 | TEST | TEST | SKIP | X - // 1 | TESTIF | SKIP | TEST | X - - // - SKIP: always skip - // - TEST: always test - // - TESTIF: only test if checkUnignored - // - X: that never happen - - // @param {boolean} whether should check if the path is unignored, - // setting `checkUnignored` to `false` could reduce additional - // path matching. - - // @returns {TestResult} true if a file is ignored - _testOne (path, checkUnignored) { - let ignored = false; - let unignored = false; - - this._rules.forEach(rule => { - const {negative} = rule; - if ( - unignored === negative && ignored !== unignored - || negative && !ignored && !unignored && !checkUnignored - ) { - return - } + const matched = rule.regex.test(path); - const matched = rule.regex.test(path); + if (matched) { + ignored = !negative; + unignored = negative; + } + }); - if (matched) { - ignored = !negative; - unignored = negative; - } - }); + return { + ignored, + unignored + } + } - return { - ignored, - unignored - } - } + // @returns {TestResult} + _test (originalPath, cache, checkUnignored, slices) { + const path = originalPath + // Supports nullable path + && checkPath.convert(originalPath); + + checkPath( + path, + originalPath, + this._allowRelativePaths + ? RETURN_FALSE + : throwError + ); - // @returns {TestResult} - _test (originalPath, cache, checkUnignored, slices) { - const path = originalPath - // Supports nullable path - && checkPath.convert(originalPath); - - checkPath( - path, - originalPath, - this._allowRelativePaths - ? RETURN_FALSE - : throwError - ); + return this._t(path, cache, checkUnignored, slices) + } - return this._t(path, cache, checkUnignored, slices) - } + _t (path, cache, checkUnignored, slices) { + if (path in cache) { + return cache[path] + } - _t (path, cache, checkUnignored, slices) { - if (path in cache) { - return cache[path] - } + if (!slices) { + // path/to/a.js + // ['path', 'to', 'a.js'] + slices = path.split(SLASH); + } - if (!slices) { - // path/to/a.js - // ['path', 'to', 'a.js'] - slices = path.split(SLASH); - } + slices.pop(); - slices.pop(); + // If the path has no parent directory, just test it + if (!slices.length) { + return cache[path] = this._testOne(path, checkUnignored) + } - // If the path has no parent directory, just test it - if (!slices.length) { - return cache[path] = this._testOne(path, checkUnignored) - } + const parent = this._t( + slices.join(SLASH) + SLASH, + cache, + checkUnignored, + slices + ); - const parent = this._t( - slices.join(SLASH) + SLASH, - cache, - checkUnignored, - slices - ); + // If the path contains a parent directory, check the parent first + return cache[path] = parent.ignored + // > It is not possible to re-include a file if a parent directory of + // > that file is excluded. + ? parent + : this._testOne(path, checkUnignored) + } - // If the path contains a parent directory, check the parent first - return cache[path] = parent.ignored - // > It is not possible to re-include a file if a parent directory of - // > that file is excluded. - ? parent - : this._testOne(path, checkUnignored) - } + ignores (path) { + return this._test(path, this._ignoreCache, false).ignored + } - ignores (path) { - return this._test(path, this._ignoreCache, false).ignored - } + createFilter () { + return path => !this.ignores(path) + } - createFilter () { - return path => !this.ignores(path) - } + filter (paths) { + return makeArray(paths).filter(this.createFilter()) + } - filter (paths) { - return makeArray(paths).filter(this.createFilter()) - } + // @returns {TestResult} + test (path) { + return this._test(path, this._testCache, true) + } +} - // @returns {TestResult} - test (path) { - return this._test(path, this._testCache, true) - } - } +const factory = options => new Ignore(options); - const factory = options => new Ignore(options); +const isPathValid = path => + checkPath(path && checkPath.convert(path), path, RETURN_FALSE); - const isPathValid = path => - checkPath(path && checkPath.convert(path), path, RETURN_FALSE); +factory.isPathValid = isPathValid; - factory.isPathValid = isPathValid; +// Fixes typescript +factory.default = factory; - // Fixes typescript - factory.default = factory; +var ignore$2 = factory; - ignore$1 = factory; +// Windows +// -------------------------------------------------------------- +/* istanbul ignore if */ +if ( + // Detect `process` so that it can run in browsers. + typeof browser$1$1 !== 'undefined' + && ( + {} && browser$1$1.env.IGNORE_TEST_WIN32 + || "unix" === 'win32' + ) +) { + /* eslint no-control-regex: "off" */ + const makePosix = str => /^\\\\\?\\/.test(str) + || /["<>|\u0000-\u001F]+/u.test(str) + ? str + : str.replace(/\\/g, '/'); - // Windows - // -------------------------------------------------------------- - /* istanbul ignore if */ - if ( - // Detect `process` so that it can run in browsers. - typeof browser$1$1 !== 'undefined' - && ( - {} && browser$1$1.env.IGNORE_TEST_WIN32 - || "unix" === 'win32' - ) - ) { - /* eslint no-control-regex: "off" */ - const makePosix = str => /^\\\\\?\\/.test(str) - || /["<>|\u0000-\u001F]+/u.test(str) - ? str - : str.replace(/\\/g, '/'); - - checkPath.convert = makePosix; - - // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/' - // 'd:\\foo' - const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i; - checkPath.isNotRelative = path => - REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) - || isNotRelative(path); - } - return ignore$1; -} + checkPath.convert = makePosix; -var ignores; -var hasRequiredIgnores; + // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/' + // 'd:\\foo' + const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i; + checkPath.isNotRelative = path => + REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) + || isNotRelative(path); +} -function requireIgnores () { - if (hasRequiredIgnores) return ignores; - hasRequiredIgnores = 1; +ignore$2.default; - const {relative} = require$$0$2; - const ignore = requireIgnore$1(); +const {relative} = require$$0$2; +const ignore$1 = ignore$2; - const isNegative = (a) => !a.indexOf('!'); - const positive = (a) => a.replace(/^!/, ''); +const isNegative = (a) => !a.indexOf('!'); +const positive = (a) => a.replace(/^!/, ''); - ignores = (dirOpt, resolvedName, options = {}) => { - const relativeName = relative(dirOpt, resolvedName); - const ignorer = ignore(); - const ignoreList = mergeIgnores(options.ignore || []); - - ignorer.add(ignoreList); - - return dirOpt && ignorer.ignores(relativeName); - }; +var ignores$2 = (dirOpt, resolvedName, options = {}) => { + const relativeName = relative(dirOpt, resolvedName); + const ignorer = ignore$1(); + const ignoreList = mergeIgnores(options.ignore || []); + + ignorer.add(ignoreList); + + return dirOpt && ignorer.ignores(relativeName); +}; - function mergeIgnores(ignores) { - for (const [i, str] of ignores.entries()) { - const positiveIndex = ignores.indexOf(positive(str)); - - if (isNegative(str) && positiveIndex > i) - ignores[positiveIndex] = str; - } - - const noDuplicates = new Set(ignores); - - return Array.from(noDuplicates); - } - return ignores; +function mergeIgnores(ignores) { + for (const [i, str] of ignores.entries()) { + const positiveIndex = ignores.indexOf(positive(str)); + + if (isNegative(str) && positiveIndex > i) + ignores[positiveIndex] = str; + } + + const noDuplicates = new Set(ignores); + + return Array.from(noDuplicates); } -var hasRequiredMatchFiles; +ignores$2.default; -function requireMatchFiles () { - if (hasRequiredMatchFiles) return matchFiles; - hasRequiredMatchFiles = 1; +const path = require$$0$2; - const path = require$$0$2; +const {parse: parse$2, print: print$1} = parser$6; +const {transform: transform$1} = transform$5; +const {findPlaces: findPlaces$1} = findPlaces$2; +const ignores$1 = ignores$2; - const {parse, print} = requireParser$1(); - const {transform} = requireTransform$1(); - const {findPlaces} = requireFindPlaces(); - const ignores = requireIgnores(); +const {toJS, fromJS} = json; - const {toJS, fromJS} = requireJson$1(); - - const { - readFileContent, - findFile, - writeFileContent, - getFilename, - createFile, - removeFile, - getParentDirectory, - } = requireFilesystem(); - - const {join} = path; - - const isObject = (a) => a && typeof a === 'object'; - const {entries} = Object; - const report = (path, {message}) => message; - - matchFiles.matchFiles = (files) => { - check(files); - const scan = createScan(files); - - return { - fix, - scan, - report, - }; - }; +const { + readFileContent: readFileContent$1, + findFile: findFile$1, + writeFileContent, + getFilename: getFilename$1, + createFile, + removeFile, + getParentDirectory: getParentDirectory$1, +} = filesystem; - function fix(inputFile, {dirPath, mainPath, matchInputFilename, outputFilename, matchedJS, matchedAST, options}) { - transform(matchedAST, matchedJS, options); - - const matchedJSON = magicPrint(outputFilename, matchedAST); - const outputFile = getOutputFile(mainPath, { - dirPath, - matchInputFilename, - outputFilename, - inputFile, - }); - - writeFileContent(outputFile, matchedJSON); - - if (inputFile !== outputFile) - removeFile(inputFile); - } +const {join: join$1} = path; - const createScan = (files) => (mainPath, {push, progress, options}) => { - const allFiles = []; - const cwd = getFilename(mainPath); - - for (const [filename, rawOptions] of entries(files)) { - const [matchInputFilename, outputFilename = matchInputFilename] = parseMatcher(filename, options); - const inputFiles = findFile(mainPath, matchInputFilename); - - for (const inputFile of inputFiles) { - const dirPath = getParentDirectory(inputFile); - const inputFilename = getFilename(inputFile); - - if (ignores(cwd, inputFilename, options)) - continue; - - allFiles.push({ - mainPath, - dirPath, - matchInputFilename, - rawOptions, - inputFile, - inputFilename, - outputFilename, - }); - } - } - - const n = allFiles.length; - - for (const [i, current] of allFiles.entries()) { - const { - dirPath, - matchInputFilename, - inputFile, - inputFilename, - outputFilename, - rawOptions, - mainPath, - } = current; - - progress({ - i, - n, - }); - - const fileContent = readFileContent(inputFile) || '{}'; - const [matchedJS, matchedAST] = magicParse(inputFilename, fileContent); - - const options = parseOptions(inputFilename, rawOptions); - const places = findPlaces(matchedAST, matchedJS, options); - - if (!places.length) - continue; - - const {message} = places[0]; - - push(inputFile, { - dirPath, - mainPath, - matchInputFilename, - - outputFilename, - message, - options, - - matchedAST, - matchedJS, - }); - } - }; +const isObject = (a) => a && typeof a === 'object'; +const {entries} = Object; +const report$1 = (path, {message}) => message; - function magicParse(name, content) { - if (/\.json$/.test(name)) { - const js = toJS(content); - const ast = parse(js); - - return [js, ast]; - } - - if (/\.(c|m)?ts(x)?$/.test(name)) { - const ast = parse(content, { - isTS: true, - }); - - return [content, ast]; - } - - return [content, parse(content)]; - } +matchFiles.matchFiles = (files) => { + check$1(files); + const scan = createScan(files); + + return { + fix: fix$1, + scan, + report: report$1, + }; +}; - function magicPrint(name, ast) { - if (/\.json$/.test(name)) { - const js = print(ast); - - return fromJS(js); - } - - return print(ast); - } +function fix$1(inputFile, {dirPath, mainPath, matchInputFilename, outputFilename, matchedJS, matchedAST, options}) { + transform$1(matchedAST, matchedJS, options); + + const matchedJSON = magicPrint(outputFilename, matchedAST); + const outputFile = getOutputFile(mainPath, { + dirPath, + matchInputFilename, + outputFilename, + inputFile, + }); + + writeFileContent(outputFile, matchedJSON); + + if (inputFile !== outputFile) + removeFile(inputFile); +} - function check(files) { - for (const [, plugin] of entries(files)) { - if (!isObject(plugin)) - throw Error(`☝️ Looks like provided to 'matchFiles()' typeof of plugin is not an 'object' but '${typeof plugin}'`); - } - } +const createScan = (files) => (mainPath, {push, progress, options}) => { + const allFiles = []; + const cwd = getFilename$1(mainPath); + + for (const [filename, rawOptions] of entries(files)) { + const [matchInputFilename, outputFilename = matchInputFilename] = parseMatcher(filename, options); + const inputFiles = findFile$1(mainPath, matchInputFilename); + + for (const inputFile of inputFiles) { + const dirPath = getParentDirectory$1(inputFile); + const inputFilename = getFilename$1(inputFile); + + if (ignores$1(cwd, inputFilename, options)) + continue; + + allFiles.push({ + mainPath, + dirPath, + matchInputFilename, + rawOptions, + inputFile, + inputFilename, + outputFilename, + }); + } + } + + const n = allFiles.length; + + for (const [i, current] of allFiles.entries()) { + const { + dirPath, + matchInputFilename, + inputFile, + inputFilename, + outputFilename, + rawOptions, + mainPath, + } = current; + + progress({ + i, + n, + }); + + const fileContent = readFileContent$1(inputFile) || '{}'; + const [matchedJS, matchedAST] = magicParse(inputFilename, fileContent); + + const options = parseOptions(inputFilename, rawOptions); + const places = findPlaces$1(matchedAST, matchedJS, options); + + if (!places.length) + continue; + + const {message} = places[0]; + + push(inputFile, { + dirPath, + mainPath, + matchInputFilename, + + outputFilename, + message, + options, + + matchedAST, + matchedJS, + }); + } +}; - function getOutputFile(path, {dirPath, matchInputFilename, outputFilename, inputFile}) { - if (matchInputFilename === outputFilename) - return inputFile; - - const name = join(getFilename(dirPath), outputFilename); - const [outputFile] = findFile(dirPath, name); - - if (outputFile) - return outputFile; - - return createFile(dirPath, outputFilename); - } +function magicParse(name, content) { + if (/\.json$/.test(name)) { + const js = toJS(content); + const ast = parse$2(js); + + return [js, ast]; + } + + if (/\.(c|m)?ts(x)?$/.test(name)) { + const ast = parse$2(content, { + isTS: true, + }); + + return [content, ast]; + } + + return [content, parse$2(content)]; +} - function parseMatcher(matcher, options) { - const {filename} = options; - - if (!filename) - return matcher.split(' -> '); - - const {ext, name} = path.parse(filename); - - matcher = matcher.replaceAll(`__name`, name); - matcher = matcher.replaceAll(`__ext`, ext); - - return matcher.split(' -> '); - } +function magicPrint(name, ast) { + if (/\.json$/.test(name)) { + const js = print$1(ast); + + return fromJS(js); + } + + return print$1(ast); +} - function parseOptions(inputFilename, rawOptions) { - if (rawOptions.plugins) - return rawOptions; - - const name = `match-file: ${inputFilename}`; - - const plugins = [ - [name, rawOptions], - ]; - - return { - plugins, - }; - } - return matchFiles; +function check$1(files) { + for (const [, plugin] of entries(files)) { + if (!isObject(plugin)) + throw Error(`☝️ Looks like provided to 'matchFiles()' typeof of plugin is not an 'object' but '${typeof plugin}'`); + } } -var renameFiles = {}; +function getOutputFile(path, {dirPath, matchInputFilename, outputFilename, inputFile}) { + if (matchInputFilename === outputFilename) + return inputFile; + + const name = join$1(getFilename$1(dirPath), outputFilename); + const [outputFile] = findFile$1(dirPath, name); + + if (outputFile) + return outputFile; + + return createFile(dirPath, outputFilename); +} -var hasRequiredRenameFiles; +function parseMatcher(matcher, options) { + const {filename} = options; + + if (!filename) + return matcher.split(' -> '); + + const {ext, name} = path.parse(filename); + + matcher = matcher.replaceAll(`__name`, name); + matcher = matcher.replaceAll(`__ext`, ext); + + return matcher.split(' -> '); +} -function requireRenameFiles () { - if (hasRequiredRenameFiles) return renameFiles; - hasRequiredRenameFiles = 1; +function parseOptions(inputFilename, rawOptions) { + if (rawOptions.plugins) + return rawOptions; + + const name = `match-file: ${inputFilename}`; + + const plugins = [ + [name, rawOptions], + ]; + + return { + plugins, + }; +} - const {join} = require$$0$2; +var renameFiles = {}; - const { - getParentDirectory, - getFilename, - readFileContent, - findFile, - renameFile, - } = requireFilesystem(); - - const {parse} = JSON; - - renameFiles.renameFiles = ({type, mask, rename}) => ({ - report, - fix, - scan: scan({ - type, - mask, - rename, - }), - }); +const {join} = require$$0$2; + +const { + getParentDirectory, + getFilename, + readFileContent, + findFile, + renameFile, +} = filesystem; + +const {parse: parse$1} = JSON; + +renameFiles.renameFiles = ({type, mask, rename}) => ({ + report, + fix, + scan: scan({ + type, + mask, + rename, + }), +}); - const report = (file, {from, to}) => `Rename '${from}' to '${to}'`; +const report = (file, {from, to}) => `Rename '${from}' to '${to}'`; - const fix = (file, {to}) => { - renameFile(file, to); - }; +const fix = (file, {to}) => { + renameFile(file, to); +}; - const scan = ({type, mask, rename}) => (path, {push, trackFile}) => { - for (const file of trackFile(path, mask)) { - if (type && !checkType(type, file)) - continue; - - const from = getFilename(file); - const to = rename(from); - - push(file, { - from, - to, - }); - } - }; +const scan = ({type, mask, rename}) => (path, {push, trackFile}) => { + for (const file of trackFile(path, mask)) { + if (type && !checkType(type, file)) + continue; + + const from = getFilename(file); + const to = rename(from); + + push(file, { + from, + to, + }); + } +}; - function checkType(type, file) { - const packagePath = findUpPackage(file); - - if (type === 'commonjs' && !packagePath) - return true; - - if (!packagePath) - return false; - - const packageContent = readFileContent(packagePath); - - if (!packageContent) - return false; - - const info = parse(packageContent); - const infoType = info.type || 'commonjs'; - - return infoType === type; - } +function checkType(type, file) { + const packagePath = findUpPackage(file); + + if (type === 'commonjs' && !packagePath) + return true; + + if (!packagePath) + return false; + + const packageContent = readFileContent(packagePath); + + if (!packageContent) + return false; + + const info = parse$1(packageContent); + const infoType = info.type || 'commonjs'; + + return infoType === type; +} - function findUpPackage(file) { - let packageJSON; - let dirPath = getParentDirectory(file); - - do { - const dir = getFilename(dirPath); - [packageJSON] = findFile(dirPath, join(dir, 'package.json')); - } while (!packageJSON && (dirPath = getParentDirectory(dirPath))); - - return packageJSON; - } - return renameFiles; +function findUpPackage(file) { + let packageJSON; + let dirPath = getParentDirectory(file); + + do { + const dir = getFilename(dirPath); + [packageJSON] = findFile(dirPath, join(dir, 'package.json')); + } while (!packageJSON && (dirPath = getParentDirectory(dirPath))); + + return packageJSON; } var ignore = {}; -var hasRequiredIgnore; - -function requireIgnore () { - if (hasRequiredIgnore) return ignore; - hasRequiredIgnore = 1; - - const {types} = requireBundle(); - const {traverseProperties} = requireOperate(); - const {StringLiteral} = types; - const getValue = ({value}) => value; - - ignore.ignore = (type, {name, property, list}) => { - const [, collector] = type.split(/\(|\)/); - - return { - report: createReport(name), - match: createMatch({ - type, - property, - collector, - list, - }), - replace: createReplace({ - type, - property, - collector, - list, - }), - }; - }; +const {types: types$1} = bundle; +const {traverseProperties} = operate; +const {StringLiteral} = types$1; +const getValue = ({value}) => value; - const createReport = (name) => () => `Add dotfiles to '${name}'`; +ignore.ignore = (type, {name, property, list}) => { + const [, collector] = type.split(/\(|\)/); + + return { + report: createReport(name), + match: createMatch({ + type, + property, + collector, + list, + }), + replace: createReplace({ + type, + property, + collector, + list, + }), + }; +}; - const createMatch = ({type, property, collector, list}) => ({options}) => { - const {dismiss = []} = options; - const newNames = filterNames(list, dismiss); - - return { - [type]: (vars) => { - const elements = parseElements(vars, { - property, - collector, - }); - - if (!elements) - return false; - - const list = elements.map(getValue); - - for (const name of newNames) { - if (!list.includes(name)) - return true; - } - - return false; - }, - }; - }; +const createReport = (name) => () => `Add dotfiles to '${name}'`; - const createReplace = ({type, property, collector, list}) => ({options}) => { - const {dismiss = []} = options; - const newNames = filterNames(list, dismiss); - - return { - [type]: (vars, path) => { - const elements = parseElements(vars, { - property, - collector, - }); - - const list = elements.map(getValue); - - for (const name of newNames) { - if (!list.includes(name)) - elements.push(StringLiteral(name)); - } - - return path; - }, - }; - }; +const createMatch = ({type, property, collector, list}) => ({options}) => { + const {dismiss = []} = options; + const newNames = filterNames(list, dismiss); + + return { + [type]: (vars) => { + const elements = parseElements(vars, { + property, + collector, + }); + + if (!elements) + return false; + + const list = elements.map(getValue); + + for (const name of newNames) { + if (!list.includes(name)) + return true; + } + + return false; + }, + }; +}; - function filterNames(names, dismiss) { - const newNames = []; - - for (const name of names) { - if (dismiss.includes(name)) - continue; - - newNames.push(name); - } - - return newNames; - } +const createReplace = ({type, property, collector, list}) => ({options}) => { + const {dismiss = []} = options; + const newNames = filterNames(list, dismiss); + + return { + [type]: (vars, path) => { + const elements = parseElements(vars, { + property, + collector, + }); + + const list = elements.map(getValue); + + for (const name of newNames) { + if (!list.includes(name)) + elements.push(StringLiteral(name)); + } + + return path; + }, + }; +}; - function parseElements(vars, {property, collector}) { - const node = vars[collector]; - - if (!property) - return node.elements; - - const [prop] = traverseProperties(node, property); - - if (!prop) - return null; - - return prop.node.value.elements; - } - return ignore; +function filterNames(names, dismiss) { + const newNames = []; + + for (const name of names) { + if (dismiss.includes(name)) + continue; + + newNames.push(name); + } + + return newNames; } -var codeframe; -var hasRequiredCodeframe; - -function requireCodeframe () { - if (hasRequiredCodeframe) return codeframe; - hasRequiredCodeframe = 1; - - const {codeFrameColumns} = requireBundle(); - - codeframe = ({source, error, highlightCode = true}) => { - const {message, loc} = error; - - if (!loc) - return message; - - const location = { - start: loc, - }; - - return codeFrameColumns(source, location, { - highlightCode, - message, - }); - }; - return codeframe; +function parseElements(vars, {property, collector}) { + const node = vars[collector]; + + if (!property) + return node.elements; + + const [prop] = traverseProperties(node, property); + + if (!prop) + return null; + + return prop.node.value.elements; } -var hasRequiredPutout; +const {codeFrameColumns} = bundle; + +var codeframe$1 = ({source, error, highlightCode = true}) => { + const {message, loc} = error; + + if (!loc) + return message; + + const location = { + start: loc, + }; + + return codeFrameColumns(source, location, { + highlightCode, + message, + }); +}; -function requirePutout () { - if (hasRequiredPutout) return putout$1.exports; - hasRequiredPutout = 1; +codeframe$1.default; - const {traverse, types} = requireBundle(); - const { - parse, - print, - generate, - template, - } = requireParser$1(); +const {traverse, types} = bundle; +const { + parse, + print, + generate, + template, +} = parser$6; - const {cutShebang, mergeShebang} = requireShebang(); - const {defaultOptions} = requireDefaultOptions(); - const {transform, transformAsync} = requireTransform$1(); +const {cutShebang, mergeShebang} = shebang; +const {defaultOptions} = defaultOptions$4; +const {transform, transformAsync} = transform$5; - const { - findPlaces, - findPlacesAsync, - } = requireFindPlaces(); +const { + findPlaces, + findPlacesAsync, +} = findPlaces$2; - const isString = (a) => typeof a === 'string'; +const isString = (a) => typeof a === 'string'; - putout$1.exports = putout; - putout$1.exports.putout = putout; +putout$1.exports = putout; +var putout_2 = putout$1.exports.putout = putout; - function putout(source, opts) { - check(source); - opts = defaultOptions(opts); - - const { - parser, - isTS, - isFlow, - isJSX, - sourceFileName, - sourceMapName, - printer, - } = opts; - - const [clearSource, shebang] = cutShebang(source); - - const ast = parse(clearSource, { - sourceFileName, - parser, - isTS, - isFlow, - isJSX, - printer, - }); - - const places = transform(ast, source, opts); - - if (!opts.fix) - return { - code: source, - places, - }; - - const printed = print(ast, { - sourceMapName, - printer, - }); - - const code = mergeShebang(shebang, printed); - - return { - code, - places, - }; - } +function putout(source, opts) { + check(source); + opts = defaultOptions(opts); + + const { + parser, + isTS, + isFlow, + isJSX, + sourceFileName, + sourceMapName, + printer, + } = opts; + + const [clearSource, shebang] = cutShebang(source); + + const ast = parse(clearSource, { + sourceFileName, + parser, + isTS, + isFlow, + isJSX, + printer, + }); + + const places = transform(ast, source, opts); + + if (!opts.fix) + return { + code: source, + places, + }; + + const printed = print(ast, { + sourceMapName, + printer, + }); + + const code = mergeShebang(shebang, printed); + + return { + code, + places, + }; +} - putout$1.exports.putoutAsync = async (source, opts) => { - check(source); - opts = defaultOptions(opts); - - const { - parser, - isTS, - isFlow, - isJSX, - sourceFileName, - sourceMapName, - printer, - } = opts; - - const [clearSource, shebang] = cutShebang(source); - - const ast = parse(clearSource, { - sourceFileName, - parser, - isTS, - isFlow, - isJSX, - printer, - }); - - const places = await transformAsync(ast, source, opts); - - if (!opts.fix) - return { - code: source, - places, - }; - - const printed = print(ast, { - sourceMapName, - printer, - }); - - const code = mergeShebang(shebang, printed); - - return { - code, - places, - }; - }; +var putoutAsync = putout$1.exports.putoutAsync = async (source, opts) => { + check(source); + opts = defaultOptions(opts); + + const { + parser, + isTS, + isFlow, + isJSX, + sourceFileName, + sourceMapName, + printer, + } = opts; + + const [clearSource, shebang] = cutShebang(source); + + const ast = parse(clearSource, { + sourceFileName, + parser, + isTS, + isFlow, + isJSX, + printer, + }); + + const places = await transformAsync(ast, source, opts); + + if (!opts.fix) + return { + code: source, + places, + }; + + const printed = print(ast, { + sourceMapName, + printer, + }); + + const code = mergeShebang(shebang, printed); + + return { + code, + places, + }; +}; - putout$1.exports.transform = transform; - putout$1.exports.transformAsync = transformAsync; - - putout$1.exports.findPlaces = findPlaces; - putout$1.exports.findPlacesAsync = findPlacesAsync; - - putout$1.exports.parse = parse; - putout$1.exports.print = print; - putout$1.exports.traverse = traverse; - putout$1.exports.types = types; - putout$1.exports.template = template; - putout$1.exports.generate = generate; - putout$1.exports.initReport = requireReport(); - - putout$1.exports.operator = { - ...requireOperate(), - ...requireCompare(), - ...requireTraverse$1(), - ...requireJson$1(), - ...requireDeclare$1(), - ...requireRegexp(), - ...requireAddArgs(), - ...requireFilesystem(), - ...requireMatchFiles(), - ...requireRenameFiles(), - ...requireIgnore(), - }; +var transform_1 = putout$1.exports.transform = transform; +var transformAsync_1 = putout$1.exports.transformAsync = transformAsync; + +var findPlaces_1 = putout$1.exports.findPlaces = findPlaces; +var findPlacesAsync_1 = putout$1.exports.findPlacesAsync = findPlacesAsync; + +var parse_1 = putout$1.exports.parse = parse; +var print_1 = putout$1.exports.print = print; +var traverse_1 = putout$1.exports.traverse = traverse; +var types_1 = putout$1.exports.types = types; +var template_1 = putout$1.exports.template = template; +var generate_1 = putout$1.exports.generate = generate; +var initReport = putout$1.exports.initReport = report$3; + +var operator = putout$1.exports.operator = { + ...operate, + ...compare$5, + ...traverse$5, + ...json, + ...declare$2, + ...regexp, + ...addArgs, + ...filesystem, + ...matchFiles, + ...renameFiles, + ...ignore, +}; - putout$1.exports.ignores = requireIgnores(); - putout$1.exports.codeframe = requireCodeframe(); +var ignores = putout$1.exports.ignores = ignores$2; +var codeframe = putout$1.exports.codeframe = codeframe$1; - function check(source) { - if (!isString(source)) - throw Error(`☝️ Looks like 'source' has type '${typeof source}', expected: 'string'`); - } - return putout$1.exports; +function check(source) { + if (!isString(source)) + throw Error(`☝️ Looks like 'source' has type '${typeof source}', expected: 'string'`); } -var putoutExports = requirePutout(); -var putout = putoutExports.default; +var putoutExports = putout$1.exports; -export { putout as default }; +export { codeframe, putoutExports as default, findPlaces_1 as findPlaces, findPlacesAsync_1 as findPlacesAsync, generate_1 as generate, ignores, initReport, operator, parse_1 as parse, print_1 as print, putout_2 as putout, putoutAsync, template_1 as template, transform_1 as transform, transformAsync_1 as transformAsync, traverse_1 as traverse, types_1 as types }; diff --git a/bundle/putout.min.js b/bundle/putout.min.js index 26ba55e..534df21 100644 --- a/bundle/putout.min.js +++ b/bundle/putout.min.js @@ -1 +1 @@ -var A="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(A){if(A.__esModule)return A;var e=A.default;if("function"==typeof e){var t=function A(){return this instanceof A?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(A).forEach((function(e){var r=Object.getOwnPropertyDescriptor(A,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:function(){return A[e]}})})),t}var t={exports:{}},r="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function i(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}var a=i,s=n;function o(A){if(a===setTimeout)return setTimeout(A,0);if((a===i||!a)&&setTimeout)return a=setTimeout,setTimeout(A,0);try{return a(A,0)}catch(e){try{return a.call(null,A,0)}catch(e){return a.call(this,A,0)}}}"function"==typeof r.setTimeout&&(a=setTimeout),"function"==typeof r.clearTimeout&&(s=clearTimeout);var g,I=[],C=!1,u=-1;function c(){C&&g&&(C=!1,g.length?I=g.concat(I):u=-1,I.length&&l())}function l(){if(!C){var A=o(c);C=!0;for(var e=I.length;e;){for(g=I,I=[];++u1)for(var t=1;t>18&63]+k[i>>12&63]+k[i>>6&63]+k[63&i]);return n.join("")}function R(A){var e;b||F();for(var t=A.length,r=t%3,i="",n=[],a=16383,s=0,o=t-r;so?o:s+a));return 1===r?(e=A[t-1],i+=k[e>>2],i+=k[e<<4&63],i+="=="):2===r&&(e=(A[t-2]<<8)+A[t-1],i+=k[e>>10],i+=k[e>>4&63],i+=k[e<<2&63],i+="="),n.push(i),n.join("")}function T(A,e,t,r,i){var n,a,s=8*i-r-1,o=(1<>1,I=-7,C=t?i-1:0,u=t?-1:1,c=A[e+C];for(C+=u,n=c&(1<<-I)-1,c>>=-I,I+=s;I>0;n=256*n+A[e+C],C+=u,I-=8);for(a=n&(1<<-I)-1,n>>=-I,I+=r;I>0;a=256*a+A[e+C],C+=u,I-=8);if(0===n)n=1-g;else{if(n===o)return a?NaN:1/0*(c?-1:1);a+=Math.pow(2,r),n-=g}return(c?-1:1)*a*Math.pow(2,n-r)}function G(A,e,t,r,i,n){var a,s,o,g=8*n-i-1,I=(1<>1,u=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,c=r?0:n-1,l=r?1:-1,B=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=I):(a=Math.floor(Math.log(e)/Math.LN2),e*(o=Math.pow(2,-a))<1&&(a--,o*=2),(e+=a+C>=1?u/o:u*Math.pow(2,1-C))*o>=2&&(a++,o/=2),a+C>=I?(s=0,a=I):a+C>=1?(s=(e*o-1)*Math.pow(2,i),a+=C):(s=e*Math.pow(2,C-1)*Math.pow(2,i),a=0));i>=8;A[t+c]=255&s,c+=l,s/=256,i-=8);for(a=a<0;A[t+c]=255&a,c+=l,a/=256,g-=8);A[t+c-l]|=128*B}var M={}.toString,L=Array.isArray||function(A){return"[object Array]"==M.call(A)};function U(){return J.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function P(A,e){if(U()=U())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+U().toString(16)+" bytes");return 0|A}function z(A){return!(null==A||!A._isBuffer)}function q(A,e){if(z(A))return A.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(A)||A instanceof ArrayBuffer))return A.byteLength;"string"!=typeof A&&(A=""+A);var t=A.length;if(0===t)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return fA(A).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*t;case"hex":return t>>>1;case"base64":return yA(A).length;default:if(r)return fA(A).length;e=(""+e).toLowerCase(),r=!0}}function V(A,e,t){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===t||t>this.length)&&(t=this.length),t<=0)return"";if((t>>>=0)<=(e>>>=0))return"";for(A||(A="utf8");;)switch(A){case"hex":return IA(this,e,t);case"utf8":case"utf-8":return aA(this,e,t);case"ascii":return oA(this,e,t);case"latin1":case"binary":return gA(this,e,t);case"base64":return nA(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return CA(this,e,t);default:if(r)throw new TypeError("Unknown encoding: "+A);A=(A+"").toLowerCase(),r=!0}}function W(A,e,t){var r=A[e];A[e]=A[t],A[t]=r}function X(A,e,t,r,i){if(0===A.length)return-1;if("string"==typeof t?(r=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=i?0:A.length-1),t<0&&(t=A.length+t),t>=A.length){if(i)return-1;t=A.length-1}else if(t<0){if(!i)return-1;t=0}if("string"==typeof e&&(e=J.from(e,r)),z(e))return 0===e.length?-1:Z(A,e,t,r,i);if("number"==typeof e)return e&=255,J.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(A,e,t):Uint8Array.prototype.lastIndexOf.call(A,e,t):Z(A,[e],t,r,i);throw new TypeError("val must be string, number or Buffer")}function Z(A,e,t,r,i){var n,a=1,s=A.length,o=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(A.length<2||e.length<2)return-1;a=2,s/=2,o/=2,t/=2}function g(A,e){return 1===a?A[e]:A.readUInt16BE(e*a)}if(i){var I=-1;for(n=t;ns&&(t=s-o),n=t;n>=0;n--){for(var C=!0,u=0;ui&&(r=i):r=i;var n=e.length;if(n%2!=0)throw new TypeError("Invalid hex string");r>n/2&&(r=n/2);for(var a=0;a>8,i=t%256,n.push(i),n.push(r);return n}(e,A.length-t),A,t,r)}function nA(A,e,t){return 0===e&&t===A.length?R(A):R(A.slice(e,t))}function aA(A,e,t){t=Math.min(A.length,t);for(var r=[],i=e;i239?4:g>223?3:g>191?2:1;if(i+C<=t)switch(C){case 1:g<128&&(I=g);break;case 2:128==(192&(n=A[i+1]))&&(o=(31&g)<<6|63&n)>127&&(I=o);break;case 3:n=A[i+1],a=A[i+2],128==(192&n)&&128==(192&a)&&(o=(15&g)<<12|(63&n)<<6|63&a)>2047&&(o<55296||o>57343)&&(I=o);break;case 4:n=A[i+1],a=A[i+2],s=A[i+3],128==(192&n)&&128==(192&a)&&128==(192&s)&&(o=(15&g)<<18|(63&n)<<12|(63&a)<<6|63&s)>65535&&o<1114112&&(I=o)}null===I?(I=65533,C=1):I>65535&&(I-=65536,r.push(I>>>10&1023|55296),I=56320|1023&I),r.push(I),i+=C}return function(A){var e=A.length;if(e<=sA)return String.fromCharCode.apply(String,A);var t="",r=0;for(;r0&&(A=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(A+=" ... ")),""},J.prototype.compare=function(A,e,t,r,i){if(!z(A))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===t&&(t=A?A.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||t>A.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=t)return 0;if(r>=i)return-1;if(e>=t)return 1;if(this===A)return 0;for(var n=(i>>>=0)-(r>>>=0),a=(t>>>=0)-(e>>>=0),s=Math.min(n,a),o=this.slice(r,i),g=A.slice(e,t),I=0;Ii)&&(t=i),A.length>0&&(t<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var n=!1;;)switch(r){case"hex":return $(this,A,e,t);case"utf8":case"utf-8":return AA(this,A,e,t);case"ascii":return eA(this,A,e,t);case"latin1":case"binary":return tA(this,A,e,t);case"base64":return rA(this,A,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return iA(this,A,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),n=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var sA=4096;function oA(A,e,t){var r="";t=Math.min(A.length,t);for(var i=e;ir)&&(t=r);for(var i="",n=e;nt)throw new RangeError("Trying to access beyond buffer length")}function cA(A,e,t,r,i,n){if(!z(A))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||eA.length)throw new RangeError("Index out of range")}function lA(A,e,t,r){e<0&&(e=65535+e+1);for(var i=0,n=Math.min(A.length-t,2);i>>8*(r?i:1-i)}function BA(A,e,t,r){e<0&&(e=4294967295+e+1);for(var i=0,n=Math.min(A.length-t,4);i>>8*(r?i:3-i)&255}function EA(A,e,t,r,i,n){if(t+r>A.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function QA(A,e,t,r,i){return i||EA(A,0,t,4),G(A,e,t,r,23,4),t+4}function hA(A,e,t,r,i){return i||EA(A,0,t,8),G(A,e,t,r,52,8),t+8}J.prototype.slice=function(A,e){var t,r=this.length;if((A=~~A)<0?(A+=r)<0&&(A=0):A>r&&(A=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(i*=256);)r+=this[A+--e]*i;return r},J.prototype.readUInt8=function(A,e){return e||uA(A,1,this.length),this[A]},J.prototype.readUInt16LE=function(A,e){return e||uA(A,2,this.length),this[A]|this[A+1]<<8},J.prototype.readUInt16BE=function(A,e){return e||uA(A,2,this.length),this[A]<<8|this[A+1]},J.prototype.readUInt32LE=function(A,e){return e||uA(A,4,this.length),(this[A]|this[A+1]<<8|this[A+2]<<16)+16777216*this[A+3]},J.prototype.readUInt32BE=function(A,e){return e||uA(A,4,this.length),16777216*this[A]+(this[A+1]<<16|this[A+2]<<8|this[A+3])},J.prototype.readIntLE=function(A,e,t){A|=0,e|=0,t||uA(A,e,this.length);for(var r=this[A],i=1,n=0;++n=(i*=128)&&(r-=Math.pow(2,8*e)),r},J.prototype.readIntBE=function(A,e,t){A|=0,e|=0,t||uA(A,e,this.length);for(var r=e,i=1,n=this[A+--r];r>0&&(i*=256);)n+=this[A+--r]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},J.prototype.readInt8=function(A,e){return e||uA(A,1,this.length),128&this[A]?-1*(255-this[A]+1):this[A]},J.prototype.readInt16LE=function(A,e){e||uA(A,2,this.length);var t=this[A]|this[A+1]<<8;return 32768&t?4294901760|t:t},J.prototype.readInt16BE=function(A,e){e||uA(A,2,this.length);var t=this[A+1]|this[A]<<8;return 32768&t?4294901760|t:t},J.prototype.readInt32LE=function(A,e){return e||uA(A,4,this.length),this[A]|this[A+1]<<8|this[A+2]<<16|this[A+3]<<24},J.prototype.readInt32BE=function(A,e){return e||uA(A,4,this.length),this[A]<<24|this[A+1]<<16|this[A+2]<<8|this[A+3]},J.prototype.readFloatLE=function(A,e){return e||uA(A,4,this.length),T(this,A,!0,23,4)},J.prototype.readFloatBE=function(A,e){return e||uA(A,4,this.length),T(this,A,!1,23,4)},J.prototype.readDoubleLE=function(A,e){return e||uA(A,8,this.length),T(this,A,!0,52,8)},J.prototype.readDoubleBE=function(A,e){return e||uA(A,8,this.length),T(this,A,!1,52,8)},J.prototype.writeUIntLE=function(A,e,t,r){(A=+A,e|=0,t|=0,r)||cA(this,A,e,t,Math.pow(2,8*t)-1,0);var i=1,n=0;for(this[e]=255&A;++n=0&&(n*=256);)this[e+i]=A/n&255;return e+t},J.prototype.writeUInt8=function(A,e,t){return A=+A,e|=0,t||cA(this,A,e,1,255,0),J.TYPED_ARRAY_SUPPORT||(A=Math.floor(A)),this[e]=255&A,e+1},J.prototype.writeUInt16LE=function(A,e,t){return A=+A,e|=0,t||cA(this,A,e,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[e]=255&A,this[e+1]=A>>>8):lA(this,A,e,!0),e+2},J.prototype.writeUInt16BE=function(A,e,t){return A=+A,e|=0,t||cA(this,A,e,2,65535,0),J.TYPED_ARRAY_SUPPORT?(this[e]=A>>>8,this[e+1]=255&A):lA(this,A,e,!1),e+2},J.prototype.writeUInt32LE=function(A,e,t){return A=+A,e|=0,t||cA(this,A,e,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[e+3]=A>>>24,this[e+2]=A>>>16,this[e+1]=A>>>8,this[e]=255&A):BA(this,A,e,!0),e+4},J.prototype.writeUInt32BE=function(A,e,t){return A=+A,e|=0,t||cA(this,A,e,4,4294967295,0),J.TYPED_ARRAY_SUPPORT?(this[e]=A>>>24,this[e+1]=A>>>16,this[e+2]=A>>>8,this[e+3]=255&A):BA(this,A,e,!1),e+4},J.prototype.writeIntLE=function(A,e,t,r){if(A=+A,e|=0,!r){var i=Math.pow(2,8*t-1);cA(this,A,e,t,i-1,-i)}var n=0,a=1,s=0;for(this[e]=255&A;++n=0&&(a*=256);)A<0&&0===s&&0!==this[e+n+1]&&(s=1),this[e+n]=(A/a|0)-s&255;return e+t},J.prototype.writeInt8=function(A,e,t){return A=+A,e|=0,t||cA(this,A,e,1,127,-128),J.TYPED_ARRAY_SUPPORT||(A=Math.floor(A)),A<0&&(A=255+A+1),this[e]=255&A,e+1},J.prototype.writeInt16LE=function(A,e,t){return A=+A,e|=0,t||cA(this,A,e,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[e]=255&A,this[e+1]=A>>>8):lA(this,A,e,!0),e+2},J.prototype.writeInt16BE=function(A,e,t){return A=+A,e|=0,t||cA(this,A,e,2,32767,-32768),J.TYPED_ARRAY_SUPPORT?(this[e]=A>>>8,this[e+1]=255&A):lA(this,A,e,!1),e+2},J.prototype.writeInt32LE=function(A,e,t){return A=+A,e|=0,t||cA(this,A,e,4,2147483647,-2147483648),J.TYPED_ARRAY_SUPPORT?(this[e]=255&A,this[e+1]=A>>>8,this[e+2]=A>>>16,this[e+3]=A>>>24):BA(this,A,e,!0),e+4},J.prototype.writeInt32BE=function(A,e,t){return A=+A,e|=0,t||cA(this,A,e,4,2147483647,-2147483648),A<0&&(A=4294967295+A+1),J.TYPED_ARRAY_SUPPORT?(this[e]=A>>>24,this[e+1]=A>>>16,this[e+2]=A>>>8,this[e+3]=255&A):BA(this,A,e,!1),e+4},J.prototype.writeFloatLE=function(A,e,t){return QA(this,A,e,!0,t)},J.prototype.writeFloatBE=function(A,e,t){return QA(this,A,e,!1,t)},J.prototype.writeDoubleLE=function(A,e,t){return hA(this,A,e,!0,t)},J.prototype.writeDoubleBE=function(A,e,t){return hA(this,A,e,!1,t)},J.prototype.copy=function(A,e,t,r){if(t||(t=0),r||0===r||(r=this.length),e>=A.length&&(e=A.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),A.length-e=0;--i)A[i+e]=this[i+t];else if(n<1e3||!J.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,t=void 0===t?this.length:t>>>0,A||(A=0),"number"==typeof A)for(n=e;n55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&n.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&n.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&n.push(239,191,189),i=t;continue}t=65536+(i-55296<<10|t-56320)}else i&&(e-=3)>-1&&n.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;n.push(t)}else if(t<2048){if((e-=2)<0)break;n.push(t>>6|192,63&t|128)}else if(t<65536){if((e-=3)<0)break;n.push(t>>12|224,t>>6&63|128,63&t|128)}else{if(!(t<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;n.push(t>>18|240,t>>12&63|128,t>>6&63|128,63&t|128)}}return n}function yA(A){return function(A){var e,t,r,i,n,a;b||F();var s=A.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");n="="===A[s-2]?2:"="===A[s-1]?1:0,a=new x(3*s/4-n),r=n>0?s-4:s;var o=0;for(e=0,t=0;e>16&255,a[o++]=i>>8&255,a[o++]=255&i;return 2===n?(i=v[A.charCodeAt(e)]<<2|v[A.charCodeAt(e+1)]>>4,a[o++]=255&i):1===n&&(i=v[A.charCodeAt(e)]<<10|v[A.charCodeAt(e+1)]<<4|v[A.charCodeAt(e+2)]>>2,a[o++]=i>>8&255,a[o++]=255&i),a}(function(A){if((A=function(A){return A.trim?A.trim():A.replace(/^\s+|\s+$/g,"")}(A).replace(pA,"")).length<2)return"";for(;A.length%4!=0;)A+="=";return A}(A))}function mA(A,e,t,r){for(var i=0;i=e.length||i>=A.length);++i)e[i+t]=A[i];return i}function DA(A){return!!A.constructor&&"function"==typeof A.constructor.isBuffer&&A.constructor.isBuffer(A)}function wA(A){throw new Error('Could not dynamically require "'+A+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}function SA(){return!1}function NA(){throw new Error("tty.ReadStream is not implemented")}function kA(){throw new Error("tty.ReadStream is not implemented")}var vA,xA={isatty:SA,ReadStream:NA,WriteStream:kA},bA=e(Object.freeze({__proto__:null,ReadStream:NA,WriteStream:kA,default:xA,isatty:SA}));function FA(){if(void 0===vA){var A=new ArrayBuffer(2),e=new Uint8Array(A),t=new Uint16Array(A);if(e[0]=1,e[1]=2,258===t[0])vA="BE";else{if(513!==t[0])throw new Error("unable to figure out endianess");vA="LE"}}return vA}function YA(){return void 0!==r.location?r.location.hostname:""}function RA(){return[]}function TA(){return 0}function GA(){return Number.MAX_VALUE}function MA(){return Number.MAX_VALUE}function LA(){return[]}function UA(){return"Browser"}function PA(){return void 0!==r.navigator?r.navigator.appVersion:""}function JA(){return{}}function KA(){return{}}function HA(){return"javascript"}function OA(){return"browser"}function jA(){return"/tmp"}var _A=jA;function zA(){return"$HOME"}var qA,VA={homedir:zA,EOL:"\n",arch:HA,platform:OA,tmpdir:_A,tmpDir:jA,networkInterfaces:JA,getNetworkInterfaces:KA,release:PA,type:UA,cpus:LA,totalmem:MA,freemem:GA,uptime:TA,loadavg:RA,hostname:YA,endianness:FA},WA=e(Object.freeze({__proto__:null,EOL:"\n",arch:HA,cpus:LA,default:VA,endianness:FA,freemem:GA,getNetworkInterfaces:KA,homedir:zA,hostname:YA,loadavg:RA,networkInterfaces:JA,platform:OA,release:PA,tmpDir:jA,tmpdir:_A,totalmem:MA,type:UA,uptime:TA}));qA="function"==typeof Object.create?function(A,e){A.super_=e,A.prototype=Object.create(e.prototype,{constructor:{value:A,enumerable:!1,writable:!0,configurable:!0}})}:function(A,e){A.super_=e;var t=function(){};t.prototype=e.prototype,A.prototype=new t,A.prototype.constructor=A};var XA=Object.getOwnPropertyDescriptors||function(A){for(var e=Object.keys(A),t={},r=0;r=i)return A;switch(A){case"%s":return String(r[t++]);case"%d":return Number(r[t++]);case"%j":try{return JSON.stringify(r[t++])}catch(A){return"[Circular]"}default:return A}})),a=r[t];t=3&&(t.depth=arguments[2]),arguments.length>=4&&(t.colors=arguments[3]),Ce(e)?t.showHidden=e:e&&ve(t,e),Qe(t.showHidden)&&(t.showHidden=!1),Qe(t.depth)&&(t.depth=2),Qe(t.colors)&&(t.colors=!1),Qe(t.customInspect)&&(t.customInspect=!0),t.colors&&(t.stylize=ne),se(t,A,t.depth)}function ne(A,e){var t=ie.styles[e];return t?"["+ie.colors[t][0]+"m"+A+"["+ie.colors[t][1]+"m":A}function ae(A,e){return A}function se(A,e,t){if(A.customInspect&&e&&ye(e.inspect)&&e.inspect!==ie&&(!e.constructor||e.constructor.prototype!==e)){var r=e.inspect(t,A);return Be(r)||(r=se(A,r,t)),r}var i=function(A,e){if(Qe(e))return A.stylize("undefined","undefined");if(Be(e)){var t="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return A.stylize(t,"string")}if(le(e))return A.stylize(""+e,"number");if(Ce(e))return A.stylize(""+e,"boolean");if(ue(e))return A.stylize("null","null")}(A,e);if(i)return i;var n=Object.keys(e),a=function(A){var e={};return A.forEach((function(A,t){e[A]=!0})),e}(n);if(A.showHidden&&(n=Object.getOwnPropertyNames(e)),fe(e)&&(n.indexOf("message")>=0||n.indexOf("description")>=0))return oe(e);if(0===n.length){if(ye(e)){var s=e.name?": "+e.name:"";return A.stylize("[Function"+s+"]","special")}if(he(e))return A.stylize(RegExp.prototype.toString.call(e),"regexp");if(de(e))return A.stylize(Date.prototype.toString.call(e),"date");if(fe(e))return oe(e)}var o,g="",I=!1,C=["{","}"];(Ie(e)&&(I=!0,C=["[","]"]),ye(e))&&(g=" [Function"+(e.name?": "+e.name:"")+"]");return he(e)&&(g=" "+RegExp.prototype.toString.call(e)),de(e)&&(g=" "+Date.prototype.toUTCString.call(e)),fe(e)&&(g=" "+oe(e)),0!==n.length||I&&0!=e.length?t<0?he(e)?A.stylize(RegExp.prototype.toString.call(e),"regexp"):A.stylize("[Object]","special"):(A.seen.push(e),o=I?function(A,e,t,r,i){for(var n=[],a=0,s=e.length;a60)return t[0]+(""===e?"":e+"\n ")+" "+A.join(",\n ")+" "+t[1];return t[0]+e+" "+A.join(", ")+" "+t[1]}(o,g,C)):C[0]+g+C[1]}function oe(A){return"["+Error.prototype.toString.call(A)+"]"}function ge(A,e,t,r,i,n){var a,s,o;if((o=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=o.set?A.stylize("[Getter/Setter]","special"):A.stylize("[Getter]","special"):o.set&&(s=A.stylize("[Setter]","special")),xe(r,i)||(a="["+i+"]"),s||(A.seen.indexOf(o.value)<0?(s=ue(t)?se(A,o.value,null):se(A,o.value,t-1)).indexOf("\n")>-1&&(s=n?s.split("\n").map((function(A){return" "+A})).join("\n").substr(2):"\n"+s.split("\n").map((function(A){return" "+A})).join("\n")):s=A.stylize("[Circular]","special")),Qe(a)){if(n&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=A.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=A.stylize(a,"string"))}return a+": "+s}function Ie(A){return Array.isArray(A)}function Ce(A){return"boolean"==typeof A}function ue(A){return null===A}function ce(A){return null==A}function le(A){return"number"==typeof A}function Be(A){return"string"==typeof A}function Ee(A){return"symbol"==typeof A}function Qe(A){return void 0===A}function he(A){return pe(A)&&"[object RegExp]"===we(A)}function pe(A){return"object"==typeof A&&null!==A}function de(A){return pe(A)&&"[object Date]"===we(A)}function fe(A){return pe(A)&&("[object Error]"===we(A)||A instanceof Error)}function ye(A){return"function"==typeof A}function me(A){return null===A||"boolean"==typeof A||"number"==typeof A||"string"==typeof A||"symbol"==typeof A||void 0===A}function De(A){return J.isBuffer(A)}function we(A){return Object.prototype.toString.call(A)}function Se(A){return A<10?"0"+A.toString(10):A.toString(10)}ie.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},ie.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var Ne=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ke(){var A,e;console.log("%s - %s",(A=new Date,e=[Se(A.getHours()),Se(A.getMinutes()),Se(A.getSeconds())].join(":"),[A.getDate(),Ne[A.getMonth()],e].join(" ")),$A.apply(null,arguments))}function ve(A,e){if(!e||!pe(e))return A;for(var t=Object.keys(e),r=t.length;r--;)A[t[r]]=e[t[r]];return A}function xe(A,e){return Object.prototype.hasOwnProperty.call(A,e)}var be="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function Fe(A){if("function"!=typeof A)throw new TypeError('The "original" argument must be of type Function');if(be&&A[be]){var e;if("function"!=typeof(e=A[be]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,be,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,t,r=new Promise((function(A,r){e=A,t=r})),i=[],n=0;nA.length)&&(e=A.length);for(var t=0,r=new Array(e);t0&&i[i.length-1])||6!==n[0]&&2!==n[0])){a=0;continue}if(3===n[0]&&(!i||n[1]>i[0]&&n[1]|\\.{3}|\\??\\.(?!\\d)|(?:&&|\\|\\||\\?\\?|[+\\-%&|^]|\\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\\/(?![\\/*]))=?|[?~,:;[\\](){}]","y"),t=RegExp("(\\x23?)(?=[$_\\p{ID_Start}\\\\])(?:[$_\\u200C\\u200D\\p{ID_Continue}]+|\\\\u[\\da-fA-F]{4}|\\\\u\\{[\\da-fA-F]+\\})+","yu"),E=RegExp("(['\"])(?:[^'\"\\\\\\n\\r]+|(?!\\1)['\"]|\\\\(?:\\r\\n|[^]))*(\\1)?","y"),u=RegExp("(?:0[xX][\\da-fA-F](?:_?[\\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\\d)*n|(?:(?:0(?!\\d)|0\\d*[89]\\d*|[1-9](?:_?\\d)*)(?:\\.(?:\\d(?:_?\\d)*)?)?|\\.\\d(?:_?\\d)*)(?:[eE][+-]?\\d(?:_?\\d)*)?|0[0-7]+","y"),Q=RegExp("[`}](?:[^`\\\\$]+|\\\\[^]|\\$(?!\\{))*(`|\\$\\{)?","y"),f=RegExp("[\\t\\v\\f\\ufeff\\p{Zs}]+","yu"),g=RegExp("\\r?\\n|[\\r\\u2028\\u2029]","y"),I=RegExp("\\/\\*(?:[^*]+|\\*(?!\\/))*(\\*\\/)?","y"),B=RegExp("\\/\\/.*","y"),i=RegExp("[<>.:={}]|\\/(?![\\/*])","y"),r=RegExp("[$_\\p{ID_Start}][$_\\u200C\\u200D\\p{ID_Continue}-]*","yu"),n=RegExp("(['\"])(?:[^'\"]+|(?!\\1)['\"])*(\\1)?","y"),a=RegExp("[^<>{}]+","y"),d=/^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/,p=/^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/,s=/^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/,o=/^(?:return|throw|yield)$/,C=RegExp(g.source),e.exports=function(A){var e,y,m,D,w,S,N,k,v,x,b,F,Y,R,T,G,M=arguments;return h(this,(function(h){switch(h.label){case 0:e=(M.length>1&&void 0!==M[1]?M[1]:{}).jsx,y=void 0!==e&&e,k=A.length,S=0,N="",G=[{tag:"JS"}],m=[],Y=0,R=!1,h.label=1;case 1:if(!(S":G.pop(),"/"===N||"JSXTagEnd"===x.tag?(F="?JSX",R=!0):G.push({tag:"JSXChildren"});break;case"{":G.push({tag:"InterpolationInJSX",nesting:m.length}),F="?InterpolationInJSX",R=!1;break;case"/":"<"===N&&(G.pop(),"JSXChildren"===G[G.length-1].tag&&G.pop(),G.push({tag:"JSXTagEnd"}))}return N=F,[4,{type:"JSXPunctuator",value:v[0]}];case 39:return h.sent(),[3,1];case 40:return r.lastIndex=S,(v=r.exec(A))?(S=r.lastIndex,N=v[0],[4,{type:"JSXIdentifier",value:v[0]}]):[3,42];case 41:return h.sent(),[3,1];case 42:return n.lastIndex=S,(v=n.exec(A))?(S=n.lastIndex,N=v[0],[4,{type:"JSXString",value:v[0],closed:void 0!==v[2]}]):[3,44];case 43:return h.sent(),[3,1];case 44:return[3,52];case 45:return a.lastIndex=S,(v=a.exec(A))?(S=a.lastIndex,N=v[0],[4,{type:"JSXText",value:v[0]}]):[3,47];case 46:return h.sent(),[3,1];case 47:switch(A[S]){case"<":return[3,48];case"{":return[3,50]}return[3,52];case 48:return G.push({tag:"JSXTag"}),S++,N="<",[4,{type:"JSXPunctuator",value:"<"}];case 49:return h.sent(),[3,1];case 50:return G.push({tag:"InterpolationInJSX",nesting:m.length}),S++,N="?InterpolationInJSX",R=!1,[4,{type:"JSXPunctuator",value:"{"}];case 51:return h.sent(),[3,1];case 52:return f.lastIndex=S,(v=f.exec(A))?(S=f.lastIndex,[4,{type:"WhiteSpace",value:v[0]}]):[3,54];case 53:return h.sent(),[3,1];case 54:return g.lastIndex=S,(v=g.exec(A))?(S=g.lastIndex,R=!1,o.test(N)&&(N="?NoLineTerminatorHere"),[4,{type:"LineTerminatorSequence",value:v[0]}]):[3,56];case 55:return h.sent(),[3,1];case 56:return I.lastIndex=S,(v=I.exec(A))?(S=I.lastIndex,C.test(v[0])&&(R=!1,o.test(N)&&(N="?NoLineTerminatorHere")),[4,{type:"MultiLineComment",value:v[0],closed:void 0!==v[1]}]):[3,58];case 57:return h.sent(),[3,1];case 58:return B.lastIndex=S,(v=B.exec(A))?(S=B.lastIndex,R=!1,[4,{type:"SingleLineComment",value:v[0]}]):[3,60];case 59:return h.sent(),[3,1];case 60:return D=String.fromCodePoint(A.codePointAt(S)),S+=D.length,N=D,R=!1,[4,{type:x.tag.startsWith("JSX")?"JSXInvalid":"Invalid",value:D}];case 61:return h.sent(),[3,1];case 62:return[2,void 0]}}))}}}),P=Y({"node_modules/picocolors/picocolors.js":function(A,e){var t=N.argv||[],r={},i=!("NO_COLOR"in r||t.includes("--no-color"))&&("FORCE_COLOR"in r||t.includes("--color")||null!=wA&&bA.isatty(1)&&"dumb"!==r.TERM||"CI"in r),n=function(A,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:A;return function(r){var i=""+r,n=i.indexOf(e,A.length);return~n?A+a(i,e,t,n)+e:A+i+e}},a=function(A,e,t,r){var i="",n=0;do{i+=A.substring(n,r)+t,n=r+e.length,r=A.indexOf(e,n)}while(~r);return i+A.substring(n)},s=function(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,e=A?n:function(){return String};return{isColorSupported:A,reset:e("",""),bold:e("","",""),dim:e("","",""),italic:e("",""),underline:e("",""),inverse:e("",""),hidden:e("",""),strikethrough:e("",""),black:e("",""),red:e("",""),green:e("",""),yellow:e("",""),blue:e("",""),magenta:e("",""),cyan:e("",""),white:e("",""),gray:e("",""),bgBlack:e("",""),bgRed:e("",""),bgGreen:e("",""),bgYellow:e("",""),bgBlue:e("",""),bgMagenta:e("",""),bgCyan:e("",""),bgWhite:e("","")}};e.exports=s(),e.exports.createColors=s}}),K=Y({"node_modules/jsesc/jsesc.js":function(A,e){var t={},r=t.hasOwnProperty,i=function(A,e){for(var t in A)r.call(A,t)&&e(t,A[t])},n=function(A){return"\\u"+("0000"+A).slice(-4)},a=function(A,e){var t=A.toString(16);return e?t:t.toUpperCase()},s=t.toString,o=Array.isArray,g={"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},I=/[\\\b\f\n\r\t]/,C=/[0-9]/,u=/[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,c=/([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^]/g,l=/([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^ !#-&\(-\[\]-_a-~]/g,B=function(A,e){var t,r,E=function(){D=m,++e.indentLevel,m=e.indent.repeat(e.indentLevel)},Q={escapeEverything:!1,minimal:!1,isScriptContext:!1,quotes:"single",wrap:!1,es6:!1,json:!1,compact:!0,lowercaseHex:!1,numbers:"decimal",indent:"\t",indentLevel:0,__inline1__:!1,__inline2__:!1},h=e&&e.json;h&&(Q.quotes="double",Q.wrap=!0),t=Q,e=(r=e)?(i(r,(function(A,e){t[A]=e})),t):t,"single"!=e.quotes&&"double"!=e.quotes&&"backtick"!=e.quotes&&(e.quotes="single");var p,d="double"==e.quotes?'"':"backtick"==e.quotes?"`":"'",f=e.compact,y=e.lowercaseHex,m=e.indent.repeat(e.indentLevel),D="",w=e.__inline1__,S=e.__inline2__,N=f?"":"\n",k=!0,v="binary"==e.numbers,x="octal"==e.numbers,b="decimal"==e.numbers,F="hexadecimal"==e.numbers;if(h&&A&&"function"==typeof A.toJSON&&(A=A.toJSON()),!function(A){return"string"==typeof A||"[object String]"==s.call(A)}(A)){if(function(A){return"[object Map]"==s.call(A)}(A))return 0==A.size?"new Map()":(f||(e.__inline1__=!0,e.__inline2__=!1),"new Map("+B(Array.from(A),e)+")");if(function(A){return"[object Set]"==s.call(A)}(A))return 0==A.size?"new Set()":"new Set("+B(Array.from(A),e)+")";if(function(A){return Array.isArray(A)}(A))return 0==A.length?"Buffer.from([])":"Buffer.from("+B(Array.from(A),e)+")";if(o(A))return p=[],e.wrap=!0,w&&(e.__inline1__=!1,e.__inline2__=!0),S||E(),function(A,e){for(var t=A.length,r=-1;++r2?n(B):"\\x"+("00"+B).slice(-2)})),"`"==d&&(p=p.replace(/\$\{/g,"\\${")),e.isScriptContext&&(p=p.replace(/<\/(script|style)/gi,"<\\/$1").replace(/