From 17237df82caa95e69c17db144c84a1bf708a70b5 Mon Sep 17 00:00:00 2001 From: Amir Ziarati <120395967+amirziaratii@users.noreply.github.com> Date: Mon, 15 May 2023 12:59:55 -0400 Subject: [PATCH 1/4] Update splitter.js --- splitter.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/splitter.js b/splitter.js index 8cec572..9d22f87 100644 --- a/splitter.js +++ b/splitter.js @@ -31,6 +31,13 @@ let split = function (testPath, nodeIndex, nodeTotal, filesToExlude = []) { }; let isTestFilesOnSyncWithTestResults = function (testFiles, testResultFiles) { + if(testFiles == null && testResultFiles == null) { + return true + } + else if(testFiles == null || testResultFiles == null) { + return false + } + let missingTests = []; let testResultFilesMap = new Map(); testResultFiles.forEach((testResultFile) => { From 1f737df1134ad6ef0298cb66d4c663324fe0e165 Mon Sep 17 00:00:00 2001 From: Amir Ziarati <120395967+amirziaratii@users.noreply.github.com> Date: Mon, 15 May 2023 13:19:28 -0400 Subject: [PATCH 2/4] Update splitter.js --- splitter.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/splitter.js b/splitter.js index 9d22f87..2c8f092 100644 --- a/splitter.js +++ b/splitter.js @@ -31,10 +31,10 @@ let split = function (testPath, nodeIndex, nodeTotal, filesToExlude = []) { }; let isTestFilesOnSyncWithTestResults = function (testFiles, testResultFiles) { - if(testFiles == null && testResultFiles == null) { - return true - } - else if(testFiles == null || testResultFiles == null) { + if(testFiles == null || testResultFiles == null) { + core.info( + `couldnt find test files or test results` + ); return false } From dbfa295d615c97b1c63ded0289e961d4ec6e34a8 Mon Sep 17 00:00:00 2001 From: Amir Ziarati <120395967+amirziaratii@users.noreply.github.com> Date: Mon, 15 May 2023 13:29:09 -0400 Subject: [PATCH 3/4] add logs --- splitter.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/splitter.js b/splitter.js index 2c8f092..ea557b6 100644 --- a/splitter.js +++ b/splitter.js @@ -31,6 +31,10 @@ let split = function (testPath, nodeIndex, nodeTotal, filesToExlude = []) { }; let isTestFilesOnSyncWithTestResults = function (testFiles, testResultFiles) { + core.info( + `test files: ${testFiles} ---- test results: ${testResultFiles}` + ); + if(testFiles == null || testResultFiles == null) { core.info( `couldnt find test files or test results` @@ -57,7 +61,11 @@ let isTestFilesOnSyncWithTestResults = function (testFiles, testResultFiles) { let fileData = fs.readFileSync(testFile, "UTF-8"); let regex = /^(\s+)?package(\s+)?([a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_])/; let fileName = path.parse(testFile).name; - let packageName = fileData.match(regex)[3]; + let matchedPackageNames = fileData.match(regex) + core.info( + `matched package names: ${matchedPackageNames}` + ); + let packageName = matchedPackageNames[3]; if (testResultFilesMap.has(fileName)) { let testResultFilePackages = testResultFilesMap.get(fileName); if (testResultFilePackages.includes(packageName)) { From e24c18983bc95ededb1ce17de57c75ec8baa2c7a Mon Sep 17 00:00:00 2001 From: amirziarati Date: Mon, 15 May 2023 14:13:45 -0400 Subject: [PATCH 4/4] build the project --- dist/index.js | 2978 ++++++++++++++++++++++++--- dist/index.js.map | 2 +- dist/licenses.txt | 63 + dist/sourcemap-register.js | 3911 +----------------------------------- package-lock.json | 77 +- 5 files changed, 2735 insertions(+), 4296 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7cd549e..244fa8c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,86 +1,34 @@ -require('./sourcemap-register.js');module.exports = -/******/ (() => { // webpackBootstrap +require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ 2932: -/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { - -const core = __webpack_require__(2186); -const split = __webpack_require__(5907).split; -const splitWithTiming = __webpack_require__(5907).splitWithTiming; -const buildTestPattern = __webpack_require__(5907).buildTestPattern; -const path = __webpack_require__(5622); -const glob = __webpack_require__(1957); - -// most @actions toolkit packages have async methods -async function run() { - try { - const testPath = path.resolve(core.getInput("test-path", true)); - const nodeIndex = parseInt(core.getInput("node-index", true)); - const nodeTotal = parseInt(core.getInput("node-total", true)); - const testResultPath = path.resolve(core.getInput("test-result-path")); - const testExclude = getInputAsArray("test-exclude"); - - core.info( - `Creating ${testPath} tests for index ${nodeIndex} of total ${nodeTotal} with files to ignore: ${testExclude}` - ); - - var tests = ""; - if (glob.sync(buildTestPattern(testPath)).length === 0) { - core.setFailed(`ERROR: Test path does not exist: ${testPath}`); - return; - } - if (glob.sync(`${testResultPath}/**/*.xml`).length === 0) { - core.info( - `TestResult[${testResultPath}] does not exist, using split without timings` - ); - tests = await split(testPath, nodeIndex, nodeTotal, testExclude).catch( - core.setFailed - ); - } else { - tests = await splitWithTiming( - testPath, - testResultPath, - nodeIndex, - nodeTotal, - testExclude - ).catch(core.setFailed); - } - - core.setOutput("tests", tests); - } catch (error) { - core.setFailed(error.message); - } -} - -function getInputAsArray(name, isRequired = false) { - return core - .getInput(name, isRequired) - .split("\n") - .map((s) => s.trim()) - .filter((x) => x !== ""); -} - -run(); - - -/***/ }), - /***/ 7351: -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -const os = __importStar(__webpack_require__(2087)); -const utils_1 = __webpack_require__(5278); +exports.issue = exports.issueCommand = void 0; +const os = __importStar(__nccwpck_require__(2037)); +const utils_1 = __nccwpck_require__(5278); /** * Commands * @@ -153,10 +101,29 @@ function escapeProperty(s) { /***/ }), /***/ 2186: -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -166,19 +133,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", ({ value: true })); -const command_1 = __webpack_require__(7351); -const file_command_1 = __webpack_require__(717); -const utils_1 = __webpack_require__(5278); -const os = __importStar(__webpack_require__(2087)); -const path = __importStar(__webpack_require__(5622)); +exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0; +const command_1 = __nccwpck_require__(7351); +const file_command_1 = __nccwpck_require__(717); +const utils_1 = __nccwpck_require__(5278); +const os = __importStar(__nccwpck_require__(2037)); +const path = __importStar(__nccwpck_require__(1017)); +const oidc_utils_1 = __nccwpck_require__(8041); /** * The code to exit an action */ @@ -207,13 +169,9 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - const delimiter = '_GitHubActionsFileCommandDelimeter_'; - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); + return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); } + command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -231,7 +189,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueCommand('PATH', inputPath); + file_command_1.issueFileCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -240,7 +198,9 @@ function addPath(inputPath) { } exports.addPath = addPath; /** - * Gets the value of an input. The value is also trimmed. + * Gets the value of an input. + * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed. + * Returns an empty string if the value is not defined. * * @param name name of the input to get * @param options optional. See InputOptions. @@ -251,9 +211,52 @@ function getInput(name, options) { if (options && options.required && !val) { throw new Error(`Input required and not supplied: ${name}`); } + if (options && options.trimWhitespace === false) { + return val; + } return val.trim(); } exports.getInput = getInput; +/** + * Gets the values of an multiline input. Each value is also trimmed. + * + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns string[] + * + */ +function getMultilineInput(name, options) { + const inputs = getInput(name, options) + .split('\n') + .filter(x => x !== ''); + if (options && options.trimWhitespace === false) { + return inputs; + } + return inputs.map(input => input.trim()); +} +exports.getMultilineInput = getMultilineInput; +/** + * Gets the input value of the boolean type in the YAML 1.2 "core schema" specification. + * Support boolean input list: `true | True | TRUE | false | False | FALSE` . + * The return value is also in boolean type. + * ref: https://yaml.org/spec/1.2/spec.html#id2804923 + * + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns boolean + */ +function getBooleanInput(name, options) { + const trueValue = ['true', 'True', 'TRUE']; + const falseValue = ['false', 'False', 'FALSE']; + const val = getInput(name, options); + if (trueValue.includes(val)) + return true; + if (falseValue.includes(val)) + return false; + throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` + + `Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); +} +exports.getBooleanInput = getBooleanInput; /** * Sets the value of an output. * @@ -262,7 +265,12 @@ exports.getInput = getInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { - command_1.issueCommand('set-output', { name }, value); + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); + } + process.stdout.write(os.EOL); + command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput; /** @@ -308,19 +316,30 @@ exports.debug = debug; /** * Adds an error issue * @param message error issue message. Errors will be converted to string via toString() + * @param properties optional properties to add to the annotation. */ -function error(message) { - command_1.issue('error', message instanceof Error ? message.toString() : message); +function error(message, properties = {}) { + command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); } exports.error = error; /** - * Adds an warning issue + * Adds a warning issue * @param message warning issue message. Errors will be converted to string via toString() + * @param properties optional properties to add to the annotation. */ -function warning(message) { - command_1.issue('warning', message instanceof Error ? message.toString() : message); +function warning(message, properties = {}) { + command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); } exports.warning = warning; +/** + * Adds a notice issue + * @param message notice issue message. Errors will be converted to string via toString() + * @param properties optional properties to add to the annotation. + */ +function notice(message, properties = {}) { + command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); +} +exports.notice = notice; /** * Writes info to log with console.log. * @param message info message @@ -380,7 +399,11 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + const filePath = process.env['GITHUB_STATE'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; /** @@ -393,69 +416,1995 @@ function getState(name) { return process.env[`STATE_${name}`] || ''; } exports.getState = getState; +function getIDToken(aud) { + return __awaiter(this, void 0, void 0, function* () { + return yield oidc_utils_1.OidcClient.getIDToken(aud); + }); +} +exports.getIDToken = getIDToken; +/** + * Summary exports + */ +var summary_1 = __nccwpck_require__(1327); +Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } })); +/** + * @deprecated use core.summary + */ +var summary_2 = __nccwpck_require__(1327); +Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } })); +/** + * Path exports + */ +var path_utils_1 = __nccwpck_require__(2981); +Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } })); +Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } })); +Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } })); //# sourceMappingURL=core.js.map /***/ }), /***/ 717: -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; // For internal use, subject to change. +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ -const fs = __importStar(__webpack_require__(5747)); -const os = __importStar(__webpack_require__(2087)); -const utils_1 = __webpack_require__(5278); -function issueCommand(command, message) { +const fs = __importStar(__nccwpck_require__(7147)); +const os = __importStar(__nccwpck_require__(2037)); +const uuid_1 = __nccwpck_require__(8974); +const utils_1 = __nccwpck_require__(5278); +function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); } - if (!fs.existsSync(filePath)) { - throw new Error(`Missing file at path: ${filePath}`); + if (!fs.existsSync(filePath)) { + throw new Error(`Missing file at path: ${filePath}`); + } + fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, { + encoding: 'utf8' + }); +} +exports.issueFileCommand = issueFileCommand; +function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + // These should realistically never happen, but just in case someone finds a + // way to exploit uuid generation let's not allow keys or values that contain + // the delimiter. + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; +} +exports.prepareKeyValueMessage = prepareKeyValueMessage; +//# sourceMappingURL=file-command.js.map + +/***/ }), + +/***/ 8041: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.OidcClient = void 0; +const http_client_1 = __nccwpck_require__(6255); +const auth_1 = __nccwpck_require__(5526); +const core_1 = __nccwpck_require__(2186); +class OidcClient { + static createHttpClient(allowRetry = true, maxRetry = 10) { + const requestOptions = { + allowRetries: allowRetry, + maxRetries: maxRetry + }; + return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions); + } + static getRequestToken() { + const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN']; + if (!token) { + throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable'); + } + return token; + } + static getIDTokenUrl() { + const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL']; + if (!runtimeUrl) { + throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable'); + } + return runtimeUrl; + } + static getCall(id_token_url) { + var _a; + return __awaiter(this, void 0, void 0, function* () { + const httpclient = OidcClient.createHttpClient(); + const res = yield httpclient + .getJson(id_token_url) + .catch(error => { + throw new Error(`Failed to get ID Token. \n + Error Code : ${error.statusCode}\n + Error Message: ${error.result.message}`); + }); + const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; + if (!id_token) { + throw new Error('Response json body do not have ID Token field'); + } + return id_token; + }); + } + static getIDToken(audience) { + return __awaiter(this, void 0, void 0, function* () { + try { + // New ID Token is requested from action service + let id_token_url = OidcClient.getIDTokenUrl(); + if (audience) { + const encodedAudience = encodeURIComponent(audience); + id_token_url = `${id_token_url}&audience=${encodedAudience}`; + } + core_1.debug(`ID token url is ${id_token_url}`); + const id_token = yield OidcClient.getCall(id_token_url); + core_1.setSecret(id_token); + return id_token; + } + catch (error) { + throw new Error(`Error message: ${error.message}`); + } + }); + } +} +exports.OidcClient = OidcClient; +//# sourceMappingURL=oidc-utils.js.map + +/***/ }), + +/***/ 2981: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; +const path = __importStar(__nccwpck_require__(1017)); +/** + * toPosixPath converts the given path to the posix form. On Windows, \\ will be + * replaced with /. + * + * @param pth. Path to transform. + * @return string Posix path. + */ +function toPosixPath(pth) { + return pth.replace(/[\\]/g, '/'); +} +exports.toPosixPath = toPosixPath; +/** + * toWin32Path converts the given path to the win32 form. On Linux, / will be + * replaced with \\. + * + * @param pth. Path to transform. + * @return string Win32 path. + */ +function toWin32Path(pth) { + return pth.replace(/[/]/g, '\\'); +} +exports.toWin32Path = toWin32Path; +/** + * toPlatformPath converts the given path to a platform-specific path. It does + * this by replacing instances of / and \ with the platform-specific path + * separator. + * + * @param pth The path to platformize. + * @return string The platform-specific path. + */ +function toPlatformPath(pth) { + return pth.replace(/[/\\]/g, path.sep); +} +exports.toPlatformPath = toPlatformPath; +//# sourceMappingURL=path-utils.js.map + +/***/ }), + +/***/ 1327: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; +const os_1 = __nccwpck_require__(2037); +const fs_1 = __nccwpck_require__(7147); +const { access, appendFile, writeFile } = fs_1.promises; +exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY'; +exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary'; +class Summary { + constructor() { + this._buffer = ''; + } + /** + * Finds the summary file path from the environment, rejects if env var is not found or file does not exist + * Also checks r/w permissions. + * + * @returns step summary file path + */ + filePath() { + return __awaiter(this, void 0, void 0, function* () { + if (this._filePath) { + return this._filePath; + } + const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR]; + if (!pathFromEnv) { + throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); + } + try { + yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK); + } + catch (_a) { + throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`); + } + this._filePath = pathFromEnv; + return this._filePath; + }); + } + /** + * Wraps content in an HTML tag, adding any HTML attributes + * + * @param {string} tag HTML tag to wrap + * @param {string | null} content content within the tag + * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add + * + * @returns {string} content wrapped in HTML element + */ + wrap(tag, content, attrs = {}) { + const htmlAttrs = Object.entries(attrs) + .map(([key, value]) => ` ${key}="${value}"`) + .join(''); + if (!content) { + return `<${tag}${htmlAttrs}>`; + } + return `<${tag}${htmlAttrs}>${content}`; + } + /** + * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. + * + * @param {SummaryWriteOptions} [options] (optional) options for write operation + * + * @returns {Promise} summary instance + */ + write(options) { + return __awaiter(this, void 0, void 0, function* () { + const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); + const filePath = yield this.filePath(); + const writeFunc = overwrite ? writeFile : appendFile; + yield writeFunc(filePath, this._buffer, { encoding: 'utf8' }); + return this.emptyBuffer(); + }); + } + /** + * Clears the summary buffer and wipes the summary file + * + * @returns {Summary} summary instance + */ + clear() { + return __awaiter(this, void 0, void 0, function* () { + return this.emptyBuffer().write({ overwrite: true }); + }); + } + /** + * Returns the current summary buffer as a string + * + * @returns {string} string of summary buffer + */ + stringify() { + return this._buffer; + } + /** + * If the summary buffer is empty + * + * @returns {boolen} true if the buffer is empty + */ + isEmptyBuffer() { + return this._buffer.length === 0; + } + /** + * Resets the summary buffer without writing to summary file + * + * @returns {Summary} summary instance + */ + emptyBuffer() { + this._buffer = ''; + return this; + } + /** + * Adds raw text to the summary buffer + * + * @param {string} text content to add + * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) + * + * @returns {Summary} summary instance + */ + addRaw(text, addEOL = false) { + this._buffer += text; + return addEOL ? this.addEOL() : this; + } + /** + * Adds the operating system-specific end-of-line marker to the buffer + * + * @returns {Summary} summary instance + */ + addEOL() { + return this.addRaw(os_1.EOL); + } + /** + * Adds an HTML codeblock to the summary buffer + * + * @param {string} code content to render within fenced code block + * @param {string} lang (optional) language to syntax highlight code + * + * @returns {Summary} summary instance + */ + addCodeBlock(code, lang) { + const attrs = Object.assign({}, (lang && { lang })); + const element = this.wrap('pre', this.wrap('code', code), attrs); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML list to the summary buffer + * + * @param {string[]} items list of items to render + * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) + * + * @returns {Summary} summary instance + */ + addList(items, ordered = false) { + const tag = ordered ? 'ol' : 'ul'; + const listItems = items.map(item => this.wrap('li', item)).join(''); + const element = this.wrap(tag, listItems); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML table to the summary buffer + * + * @param {SummaryTableCell[]} rows table rows + * + * @returns {Summary} summary instance + */ + addTable(rows) { + const tableBody = rows + .map(row => { + const cells = row + .map(cell => { + if (typeof cell === 'string') { + return this.wrap('td', cell); + } + const { header, data, colspan, rowspan } = cell; + const tag = header ? 'th' : 'td'; + const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })); + return this.wrap(tag, data, attrs); + }) + .join(''); + return this.wrap('tr', cells); + }) + .join(''); + const element = this.wrap('table', tableBody); + return this.addRaw(element).addEOL(); + } + /** + * Adds a collapsable HTML details element to the summary buffer + * + * @param {string} label text for the closed state + * @param {string} content collapsable content + * + * @returns {Summary} summary instance + */ + addDetails(label, content) { + const element = this.wrap('details', this.wrap('summary', label) + content); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML image tag to the summary buffer + * + * @param {string} src path to the image you to embed + * @param {string} alt text description of the image + * @param {SummaryImageOptions} options (optional) addition image attributes + * + * @returns {Summary} summary instance + */ + addImage(src, alt, options) { + const { width, height } = options || {}; + const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height })); + const element = this.wrap('img', null, Object.assign({ src, alt }, attrs)); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML section heading element + * + * @param {string} text heading text + * @param {number | string} [level=1] (optional) the heading level, default: 1 + * + * @returns {Summary} summary instance + */ + addHeading(text, level) { + const tag = `h${level}`; + const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag) + ? tag + : 'h1'; + const element = this.wrap(allowedTag, text); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML thematic break (
) to the summary buffer + * + * @returns {Summary} summary instance + */ + addSeparator() { + const element = this.wrap('hr', null); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML line break (
) to the summary buffer + * + * @returns {Summary} summary instance + */ + addBreak() { + const element = this.wrap('br', null); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML blockquote to the summary buffer + * + * @param {string} text quote text + * @param {string} cite (optional) citation url + * + * @returns {Summary} summary instance + */ + addQuote(text, cite) { + const attrs = Object.assign({}, (cite && { cite })); + const element = this.wrap('blockquote', text, attrs); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML anchor tag to the summary buffer + * + * @param {string} text link text/content + * @param {string} href hyperlink + * + * @returns {Summary} summary instance + */ + addLink(text, href) { + const element = this.wrap('a', text, { href }); + return this.addRaw(element).addEOL(); + } +} +const _summary = new Summary(); +/** + * @deprecated use `core.summary` + */ +exports.markdownSummary = _summary; +exports.summary = _summary; +//# sourceMappingURL=summary.js.map + +/***/ }), + +/***/ 5278: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +// We use any as a valid input type +/* eslint-disable @typescript-eslint/no-explicit-any */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.toCommandProperties = exports.toCommandValue = void 0; +/** + * Sanitizes an input into a string so it can be passed into issueCommand safely + * @param input input to sanitize into a string + */ +function toCommandValue(input) { + if (input === null || input === undefined) { + return ''; + } + else if (typeof input === 'string' || input instanceof String) { + return input; + } + return JSON.stringify(input); +} +exports.toCommandValue = toCommandValue; +/** + * + * @param annotationProperties + * @returns The command properties to send with the actual annotation command + * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646 + */ +function toCommandProperties(annotationProperties) { + if (!Object.keys(annotationProperties).length) { + return {}; + } + return { + title: annotationProperties.title, + file: annotationProperties.file, + line: annotationProperties.startLine, + endLine: annotationProperties.endLine, + col: annotationProperties.startColumn, + endColumn: annotationProperties.endColumn + }; +} +exports.toCommandProperties = toCommandProperties; +//# sourceMappingURL=utils.js.map + +/***/ }), + +/***/ 8974: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +Object.defineProperty(exports, "v1", ({ + enumerable: true, + get: function () { + return _v.default; + } +})); +Object.defineProperty(exports, "v3", ({ + enumerable: true, + get: function () { + return _v2.default; + } +})); +Object.defineProperty(exports, "v4", ({ + enumerable: true, + get: function () { + return _v3.default; + } +})); +Object.defineProperty(exports, "v5", ({ + enumerable: true, + get: function () { + return _v4.default; + } +})); +Object.defineProperty(exports, "NIL", ({ + enumerable: true, + get: function () { + return _nil.default; + } +})); +Object.defineProperty(exports, "version", ({ + enumerable: true, + get: function () { + return _version.default; + } +})); +Object.defineProperty(exports, "validate", ({ + enumerable: true, + get: function () { + return _validate.default; + } +})); +Object.defineProperty(exports, "stringify", ({ + enumerable: true, + get: function () { + return _stringify.default; + } +})); +Object.defineProperty(exports, "parse", ({ + enumerable: true, + get: function () { + return _parse.default; + } +})); + +var _v = _interopRequireDefault(__nccwpck_require__(1595)); + +var _v2 = _interopRequireDefault(__nccwpck_require__(6993)); + +var _v3 = _interopRequireDefault(__nccwpck_require__(1472)); + +var _v4 = _interopRequireDefault(__nccwpck_require__(6217)); + +var _nil = _interopRequireDefault(__nccwpck_require__(2381)); + +var _version = _interopRequireDefault(__nccwpck_require__(427)); + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +var _parse = _interopRequireDefault(__nccwpck_require__(6385)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/***/ }), + +/***/ 5842: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function md5(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + + return _crypto.default.createHash('md5').update(bytes).digest(); +} + +var _default = md5; +exports["default"] = _default; + +/***/ }), + +/***/ 2381: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = '00000000-0000-0000-0000-000000000000'; +exports["default"] = _default; + +/***/ }), + +/***/ 6385: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function parse(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } + + let v; + const arr = new Uint8Array(16); // Parse ########-....-....-....-............ + + arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; + arr[1] = v >>> 16 & 0xff; + arr[2] = v >>> 8 & 0xff; + arr[3] = v & 0xff; // Parse ........-####-....-....-............ + + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 0xff; // Parse ........-....-####-....-............ + + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 0xff; // Parse ........-....-....-####-............ + + arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; + arr[9] = v & 0xff; // Parse ........-....-....-....-############ + // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) + + arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; + arr[11] = v / 0x100000000 & 0xff; + arr[12] = v >>> 24 & 0xff; + arr[13] = v >>> 16 & 0xff; + arr[14] = v >>> 8 & 0xff; + arr[15] = v & 0xff; + return arr; +} + +var _default = parse; +exports["default"] = _default; + +/***/ }), + +/***/ 6230: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; +exports["default"] = _default; + +/***/ }), + +/***/ 9784: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = rng; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate + +let poolPtr = rnds8Pool.length; + +function rng() { + if (poolPtr > rnds8Pool.length - 16) { + _crypto.default.randomFillSync(rnds8Pool); + + poolPtr = 0; + } + + return rnds8Pool.slice(poolPtr, poolPtr += 16); +} + +/***/ }), + +/***/ 8844: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function sha1(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + + return _crypto.default.createHash('sha1').update(bytes).digest(); +} + +var _default = sha1; +exports["default"] = _default; + +/***/ }), + +/***/ 1458: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ +const byteToHex = []; + +for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 0x100).toString(16).substr(1)); +} + +function stringify(arr, offset = 0) { + // Note: Be careful editing this code! It's been tuned for performance + // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 + const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one + // of the following: + // - One or more input array values don't map to a hex octet (leading to + // "undefined" in the uuid) + // - Invalid input values for the RFC `version` or `variant` fields + + if (!(0, _validate.default)(uuid)) { + throw TypeError('Stringified UUID is invalid'); + } + + return uuid; +} + +var _default = stringify; +exports["default"] = _default; + +/***/ }), + +/***/ 1595: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _rng = _interopRequireDefault(__nccwpck_require__(9784)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// **`v1()` - Generate time-based UUID** +// +// Inspired by https://github.com/LiosK/UUID.js +// and http://docs.python.org/library/uuid.html +let _nodeId; + +let _clockseq; // Previous uuid creation time + + +let _lastMSecs = 0; +let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details + +function v1(options, buf, offset) { + let i = buf && offset || 0; + const b = buf || new Array(16); + options = options || {}; + let node = options.node || _nodeId; + let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not + // specified. We do this lazily to minimize issues related to insufficient + // system entropy. See #189 + + if (node == null || clockseq == null) { + const seedBytes = options.random || (options.rng || _rng.default)(); + + if (node == null) { + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) + node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; + } + + if (clockseq == null) { + // Per 4.2.2, randomize (14 bit) clockseq + clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; + } + } // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + + + let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + + let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) + + const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression + + if (dt < 0 && options.clockseq === undefined) { + clockseq = clockseq + 1 & 0x3fff; + } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + + + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { + nsecs = 0; + } // Per 4.2.1.2 Throw error if too many uuids are requested + + + if (nsecs >= 10000) { + throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + + msecs += 12219292800000; // `time_low` + + const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; // `time_mid` + + const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; // `time_high_and_version` + + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + + b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + + b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` + + b[i++] = clockseq & 0xff; // `node` + + for (let n = 0; n < 6; ++n) { + b[i + n] = node[n]; + } + + return buf || (0, _stringify.default)(b); +} + +var _default = v1; +exports["default"] = _default; + +/***/ }), + +/***/ 6993: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _v = _interopRequireDefault(__nccwpck_require__(5920)); + +var _md = _interopRequireDefault(__nccwpck_require__(5842)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const v3 = (0, _v.default)('v3', 0x30, _md.default); +var _default = v3; +exports["default"] = _default; + +/***/ }), + +/***/ 5920: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = _default; +exports.URL = exports.DNS = void 0; + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +var _parse = _interopRequireDefault(__nccwpck_require__(6385)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); // UTF8 escape + + const bytes = []; + + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); + } + + return bytes; +} + +const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +exports.DNS = DNS; +const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +exports.URL = URL; + +function _default(name, version, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + if (typeof value === 'string') { + value = stringToBytes(value); + } + + if (typeof namespace === 'string') { + namespace = (0, _parse.default)(namespace); + } + + if (namespace.length !== 16) { + throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); + } // Compute hash of namespace and value, Per 4.3 + // Future: Use spread syntax when supported on all platforms, e.g. `bytes = + // hashfunc([...namespace, ... value])` + + + let bytes = new Uint8Array(16 + value.length); + bytes.set(namespace); + bytes.set(value, namespace.length); + bytes = hashfunc(bytes); + bytes[6] = bytes[6] & 0x0f | version; + bytes[8] = bytes[8] & 0x3f | 0x80; + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + + return buf; + } + + return (0, _stringify.default)(bytes); + } // Function#name is not settable on some platforms (#270) + + + try { + generateUUID.name = name; // eslint-disable-next-line no-empty + } catch (err) {} // For CommonJS default export support + + + generateUUID.DNS = DNS; + generateUUID.URL = URL; + return generateUUID; +} + +/***/ }), + +/***/ 1472: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _rng = _interopRequireDefault(__nccwpck_require__(9784)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function v4(options, buf, offset) { + options = options || {}; + + const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + + + rnds[6] = rnds[6] & 0x0f | 0x40; + rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = rnds[i]; + } + + return buf; + } + + return (0, _stringify.default)(rnds); +} + +var _default = v4; +exports["default"] = _default; + +/***/ }), + +/***/ 6217: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _v = _interopRequireDefault(__nccwpck_require__(5920)); + +var _sha = _interopRequireDefault(__nccwpck_require__(8844)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const v5 = (0, _v.default)('v5', 0x50, _sha.default); +var _default = v5; +exports["default"] = _default; + +/***/ }), + +/***/ 2609: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _regex = _interopRequireDefault(__nccwpck_require__(6230)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function validate(uuid) { + return typeof uuid === 'string' && _regex.default.test(uuid); +} + +var _default = validate; +exports["default"] = _default; + +/***/ }), + +/***/ 427: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function version(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } + + return parseInt(uuid.substr(14, 1), 16); +} + +var _default = version; +exports["default"] = _default; + +/***/ }), + +/***/ 5526: +/***/ (function(__unused_webpack_module, exports) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0; +class BasicCredentialHandler { + constructor(username, password) { + this.username = username; + this.password = password; + } + prepareRequest(options) { + if (!options.headers) { + throw Error('The request has no headers'); + } + options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`; + } + // This handler cannot handle 401 + canHandleAuthentication() { + return false; + } + handleAuthentication() { + return __awaiter(this, void 0, void 0, function* () { + throw new Error('not implemented'); + }); + } +} +exports.BasicCredentialHandler = BasicCredentialHandler; +class BearerCredentialHandler { + constructor(token) { + this.token = token; + } + // currently implements pre-authorization + // TODO: support preAuth = false where it hooks on 401 + prepareRequest(options) { + if (!options.headers) { + throw Error('The request has no headers'); + } + options.headers['Authorization'] = `Bearer ${this.token}`; + } + // This handler cannot handle 401 + canHandleAuthentication() { + return false; + } + handleAuthentication() { + return __awaiter(this, void 0, void 0, function* () { + throw new Error('not implemented'); + }); + } +} +exports.BearerCredentialHandler = BearerCredentialHandler; +class PersonalAccessTokenCredentialHandler { + constructor(token) { + this.token = token; + } + // currently implements pre-authorization + // TODO: support preAuth = false where it hooks on 401 + prepareRequest(options) { + if (!options.headers) { + throw Error('The request has no headers'); + } + options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`; + } + // This handler cannot handle 401 + canHandleAuthentication() { + return false; + } + handleAuthentication() { + return __awaiter(this, void 0, void 0, function* () { + throw new Error('not implemented'); + }); + } +} +exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; +//# sourceMappingURL=auth.js.map + +/***/ }), + +/***/ 6255: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +/* eslint-disable @typescript-eslint/no-explicit-any */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0; +const http = __importStar(__nccwpck_require__(3685)); +const https = __importStar(__nccwpck_require__(5687)); +const pm = __importStar(__nccwpck_require__(9835)); +const tunnel = __importStar(__nccwpck_require__(4294)); +var HttpCodes; +(function (HttpCodes) { + HttpCodes[HttpCodes["OK"] = 200] = "OK"; + HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; + HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; + HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; + HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; + HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; + HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; + HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; + HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; + HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; + HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; + HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; + HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; + HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; + HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; + HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; + HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; + HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; + HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; + HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; + HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; + HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; + HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; + HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; + HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; + HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; + HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; +})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); +var Headers; +(function (Headers) { + Headers["Accept"] = "accept"; + Headers["ContentType"] = "content-type"; +})(Headers = exports.Headers || (exports.Headers = {})); +var MediaTypes; +(function (MediaTypes) { + MediaTypes["ApplicationJson"] = "application/json"; +})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); +/** + * Returns the proxy URL, depending upon the supplied url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ +function getProxyUrl(serverUrl) { + const proxyUrl = pm.getProxyUrl(new URL(serverUrl)); + return proxyUrl ? proxyUrl.href : ''; +} +exports.getProxyUrl = getProxyUrl; +const HttpRedirectCodes = [ + HttpCodes.MovedPermanently, + HttpCodes.ResourceMoved, + HttpCodes.SeeOther, + HttpCodes.TemporaryRedirect, + HttpCodes.PermanentRedirect +]; +const HttpResponseRetryCodes = [ + HttpCodes.BadGateway, + HttpCodes.ServiceUnavailable, + HttpCodes.GatewayTimeout +]; +const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; +const ExponentialBackoffCeiling = 10; +const ExponentialBackoffTimeSlice = 5; +class HttpClientError extends Error { + constructor(message, statusCode) { + super(message); + this.name = 'HttpClientError'; + this.statusCode = statusCode; + Object.setPrototypeOf(this, HttpClientError.prototype); + } +} +exports.HttpClientError = HttpClientError; +class HttpClientResponse { + constructor(message) { + this.message = message; + } + readBody() { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { + let output = Buffer.alloc(0); + this.message.on('data', (chunk) => { + output = Buffer.concat([output, chunk]); + }); + this.message.on('end', () => { + resolve(output.toString()); + }); + })); + }); + } +} +exports.HttpClientResponse = HttpClientResponse; +function isHttps(requestUrl) { + const parsedUrl = new URL(requestUrl); + return parsedUrl.protocol === 'https:'; +} +exports.isHttps = isHttps; +class HttpClient { + constructor(userAgent, handlers, requestOptions) { + this._ignoreSslError = false; + this._allowRedirects = true; + this._allowRedirectDowngrade = false; + this._maxRedirects = 50; + this._allowRetries = false; + this._maxRetries = 1; + this._keepAlive = false; + this._disposed = false; + this.userAgent = userAgent; + this.handlers = handlers || []; + this.requestOptions = requestOptions; + if (requestOptions) { + if (requestOptions.ignoreSslError != null) { + this._ignoreSslError = requestOptions.ignoreSslError; + } + this._socketTimeout = requestOptions.socketTimeout; + if (requestOptions.allowRedirects != null) { + this._allowRedirects = requestOptions.allowRedirects; + } + if (requestOptions.allowRedirectDowngrade != null) { + this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; + } + if (requestOptions.maxRedirects != null) { + this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); + } + if (requestOptions.keepAlive != null) { + this._keepAlive = requestOptions.keepAlive; + } + if (requestOptions.allowRetries != null) { + this._allowRetries = requestOptions.allowRetries; + } + if (requestOptions.maxRetries != null) { + this._maxRetries = requestOptions.maxRetries; + } + } + } + options(requestUrl, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); + }); + } + get(requestUrl, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('GET', requestUrl, null, additionalHeaders || {}); + }); + } + del(requestUrl, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('DELETE', requestUrl, null, additionalHeaders || {}); + }); + } + post(requestUrl, data, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('POST', requestUrl, data, additionalHeaders || {}); + }); + } + patch(requestUrl, data, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('PATCH', requestUrl, data, additionalHeaders || {}); + }); + } + put(requestUrl, data, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('PUT', requestUrl, data, additionalHeaders || {}); + }); + } + head(requestUrl, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('HEAD', requestUrl, null, additionalHeaders || {}); + }); + } + sendStream(verb, requestUrl, stream, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request(verb, requestUrl, stream, additionalHeaders); + }); + } + /** + * Gets a typed object from an endpoint + * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise + */ + getJson(requestUrl, additionalHeaders = {}) { + return __awaiter(this, void 0, void 0, function* () { + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + const res = yield this.get(requestUrl, additionalHeaders); + return this._processResponse(res, this.requestOptions); + }); + } + postJson(requestUrl, obj, additionalHeaders = {}) { + return __awaiter(this, void 0, void 0, function* () { + const data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + const res = yield this.post(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + }); + } + putJson(requestUrl, obj, additionalHeaders = {}) { + return __awaiter(this, void 0, void 0, function* () { + const data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + const res = yield this.put(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + }); + } + patchJson(requestUrl, obj, additionalHeaders = {}) { + return __awaiter(this, void 0, void 0, function* () { + const data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + const res = yield this.patch(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + }); + } + /** + * Makes a raw http request. + * All other methods such as get, post, patch, and request ultimately call this. + * Prefer get, del, post and patch + */ + request(verb, requestUrl, data, headers) { + return __awaiter(this, void 0, void 0, function* () { + if (this._disposed) { + throw new Error('Client has already been disposed.'); + } + const parsedUrl = new URL(requestUrl); + let info = this._prepareRequest(verb, parsedUrl, headers); + // Only perform retries on reads since writes may not be idempotent. + const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) + ? this._maxRetries + 1 + : 1; + let numTries = 0; + let response; + do { + response = yield this.requestRaw(info, data); + // Check if it's an authentication challenge + if (response && + response.message && + response.message.statusCode === HttpCodes.Unauthorized) { + let authenticationHandler; + for (const handler of this.handlers) { + if (handler.canHandleAuthentication(response)) { + authenticationHandler = handler; + break; + } + } + if (authenticationHandler) { + return authenticationHandler.handleAuthentication(this, info, data); + } + else { + // We have received an unauthorized response but have no handlers to handle it. + // Let the response return to the caller. + return response; + } + } + let redirectsRemaining = this._maxRedirects; + while (response.message.statusCode && + HttpRedirectCodes.includes(response.message.statusCode) && + this._allowRedirects && + redirectsRemaining > 0) { + const redirectUrl = response.message.headers['location']; + if (!redirectUrl) { + // if there's no location to redirect to, we won't + break; + } + const parsedRedirectUrl = new URL(redirectUrl); + if (parsedUrl.protocol === 'https:' && + parsedUrl.protocol !== parsedRedirectUrl.protocol && + !this._allowRedirectDowngrade) { + throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); + } + // we need to finish reading the response before reassigning response + // which will leak the open socket. + yield response.readBody(); + // strip authorization header if redirected to a different hostname + if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { + for (const header in headers) { + // header names are case insensitive + if (header.toLowerCase() === 'authorization') { + delete headers[header]; + } + } + } + // let's make the request with the new redirectUrl + info = this._prepareRequest(verb, parsedRedirectUrl, headers); + response = yield this.requestRaw(info, data); + redirectsRemaining--; + } + if (!response.message.statusCode || + !HttpResponseRetryCodes.includes(response.message.statusCode)) { + // If not a retry code, return immediately instead of retrying + return response; + } + numTries += 1; + if (numTries < maxTries) { + yield response.readBody(); + yield this._performExponentialBackoff(numTries); + } + } while (numTries < maxTries); + return response; + }); + } + /** + * Needs to be called if keepAlive is set to true in request options. + */ + dispose() { + if (this._agent) { + this._agent.destroy(); + } + this._disposed = true; + } + /** + * Raw request. + * @param info + * @param data + */ + requestRaw(info, data) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve, reject) => { + function callbackForResult(err, res) { + if (err) { + reject(err); + } + else if (!res) { + // If `err` is not passed, then `res` must be passed. + reject(new Error('Unknown error')); + } + else { + resolve(res); + } + } + this.requestRawWithCallback(info, data, callbackForResult); + }); + }); + } + /** + * Raw request with callback. + * @param info + * @param data + * @param onResult + */ + requestRawWithCallback(info, data, onResult) { + if (typeof data === 'string') { + if (!info.options.headers) { + info.options.headers = {}; + } + info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); + } + let callbackCalled = false; + function handleResult(err, res) { + if (!callbackCalled) { + callbackCalled = true; + onResult(err, res); + } + } + const req = info.httpModule.request(info.options, (msg) => { + const res = new HttpClientResponse(msg); + handleResult(undefined, res); + }); + let socket; + req.on('socket', sock => { + socket = sock; + }); + // If we ever get disconnected, we want the socket to timeout eventually + req.setTimeout(this._socketTimeout || 3 * 60000, () => { + if (socket) { + socket.end(); + } + handleResult(new Error(`Request timeout: ${info.options.path}`)); + }); + req.on('error', function (err) { + // err has statusCode property + // res should have headers + handleResult(err); + }); + if (data && typeof data === 'string') { + req.write(data, 'utf8'); + } + if (data && typeof data !== 'string') { + data.on('close', function () { + req.end(); + }); + data.pipe(req); + } + else { + req.end(); + } + } + /** + * Gets an http agent. This function is useful when you need an http agent that handles + * routing through a proxy server - depending upon the url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ + getAgent(serverUrl) { + const parsedUrl = new URL(serverUrl); + return this._getAgent(parsedUrl); + } + _prepareRequest(method, requestUrl, headers) { + const info = {}; + info.parsedUrl = requestUrl; + const usingSsl = info.parsedUrl.protocol === 'https:'; + info.httpModule = usingSsl ? https : http; + const defaultPort = usingSsl ? 443 : 80; + info.options = {}; + info.options.host = info.parsedUrl.hostname; + info.options.port = info.parsedUrl.port + ? parseInt(info.parsedUrl.port) + : defaultPort; + info.options.path = + (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); + info.options.method = method; + info.options.headers = this._mergeHeaders(headers); + if (this.userAgent != null) { + info.options.headers['user-agent'] = this.userAgent; + } + info.options.agent = this._getAgent(info.parsedUrl); + // gives handlers an opportunity to participate + if (this.handlers) { + for (const handler of this.handlers) { + handler.prepareRequest(info.options); + } + } + return info; + } + _mergeHeaders(headers) { + if (this.requestOptions && this.requestOptions.headers) { + return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {})); + } + return lowercaseKeys(headers || {}); + } + _getExistingOrDefaultHeader(additionalHeaders, header, _default) { + let clientHeader; + if (this.requestOptions && this.requestOptions.headers) { + clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; + } + return additionalHeaders[header] || clientHeader || _default; + } + _getAgent(parsedUrl) { + let agent; + const proxyUrl = pm.getProxyUrl(parsedUrl); + const useProxy = proxyUrl && proxyUrl.hostname; + if (this._keepAlive && useProxy) { + agent = this._proxyAgent; + } + if (this._keepAlive && !useProxy) { + agent = this._agent; + } + // if agent is already assigned use that agent. + if (agent) { + return agent; + } + const usingSsl = parsedUrl.protocol === 'https:'; + let maxSockets = 100; + if (this.requestOptions) { + maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; + } + // This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis. + if (proxyUrl && proxyUrl.hostname) { + const agentOptions = { + maxSockets, + keepAlive: this._keepAlive, + proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && { + proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` + })), { host: proxyUrl.hostname, port: proxyUrl.port }) + }; + let tunnelAgent; + const overHttps = proxyUrl.protocol === 'https:'; + if (usingSsl) { + tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; + } + else { + tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; + } + agent = tunnelAgent(agentOptions); + this._proxyAgent = agent; + } + // if reusing agent across request and tunneling agent isn't assigned create a new agent + if (this._keepAlive && !agent) { + const options = { keepAlive: this._keepAlive, maxSockets }; + agent = usingSsl ? new https.Agent(options) : new http.Agent(options); + this._agent = agent; + } + // if not using private agent and tunnel agent isn't setup then use global agent + if (!agent) { + agent = usingSsl ? https.globalAgent : http.globalAgent; + } + if (usingSsl && this._ignoreSslError) { + // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process + // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options + // we have to cast it to any and change it directly + agent.options = Object.assign(agent.options || {}, { + rejectUnauthorized: false + }); + } + return agent; + } + _performExponentialBackoff(retryNumber) { + return __awaiter(this, void 0, void 0, function* () { + retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); + const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); + return new Promise(resolve => setTimeout(() => resolve(), ms)); + }); + } + _processResponse(res, options) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { + const statusCode = res.message.statusCode || 0; + const response = { + statusCode, + result: null, + headers: {} + }; + // not found leads to null obj returned + if (statusCode === HttpCodes.NotFound) { + resolve(response); + } + // get the result from the body + function dateTimeDeserializer(key, value) { + if (typeof value === 'string') { + const a = new Date(value); + if (!isNaN(a.valueOf())) { + return a; + } + } + return value; + } + let obj; + let contents; + try { + contents = yield res.readBody(); + if (contents && contents.length > 0) { + if (options && options.deserializeDates) { + obj = JSON.parse(contents, dateTimeDeserializer); + } + else { + obj = JSON.parse(contents); + } + response.result = obj; + } + response.headers = res.message.headers; + } + catch (err) { + // Invalid resource (contents not json); leaving result obj null + } + // note that 3xx redirects are handled by the http layer. + if (statusCode > 299) { + let msg; + // if exception/error in body, attempt to get better error + if (obj && obj.message) { + msg = obj.message; + } + else if (contents && contents.length > 0) { + // it may be the case that the exception is in the body message as string + msg = contents; + } + else { + msg = `Failed request: (${statusCode})`; + } + const err = new HttpClientError(msg, statusCode); + err.result = response.result; + reject(err); + } + else { + resolve(response); + } + })); + }); } - fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, { - encoding: 'utf8' - }); } -exports.issueCommand = issueCommand; -//# sourceMappingURL=file-command.js.map +exports.HttpClient = HttpClient; +const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); +//# sourceMappingURL=index.js.map /***/ }), -/***/ 5278: +/***/ 9835: /***/ ((__unused_webpack_module, exports) => { "use strict"; -// We use any as a valid input type -/* eslint-disable @typescript-eslint/no-explicit-any */ Object.defineProperty(exports, "__esModule", ({ value: true })); -/** - * Sanitizes an input into a string so it can be passed into issueCommand safely - * @param input input to sanitize into a string - */ -function toCommandValue(input) { - if (input === null || input === undefined) { - return ''; +exports.checkBypass = exports.getProxyUrl = void 0; +function getProxyUrl(reqUrl) { + const usingSsl = reqUrl.protocol === 'https:'; + if (checkBypass(reqUrl)) { + return undefined; } - else if (typeof input === 'string' || input instanceof String) { - return input; + const proxyVar = (() => { + if (usingSsl) { + return process.env['https_proxy'] || process.env['HTTPS_PROXY']; + } + else { + return process.env['http_proxy'] || process.env['HTTP_PROXY']; + } + })(); + if (proxyVar) { + return new URL(proxyVar); + } + else { + return undefined; } - return JSON.stringify(input); } -exports.toCommandValue = toCommandValue; -//# sourceMappingURL=utils.js.map +exports.getProxyUrl = getProxyUrl; +function checkBypass(reqUrl) { + if (!reqUrl.hostname) { + return false; + } + const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; + if (!noProxy) { + return false; + } + // Determine the request port + let reqPort; + if (reqUrl.port) { + reqPort = Number(reqUrl.port); + } + else if (reqUrl.protocol === 'http:') { + reqPort = 80; + } + else if (reqUrl.protocol === 'https:') { + reqPort = 443; + } + // Format the request hostname and hostname with port + const upperReqHosts = [reqUrl.hostname.toUpperCase()]; + if (typeof reqPort === 'number') { + upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); + } + // Compare request host against noproxy + for (const upperNoProxyItem of noProxy + .split(',') + .map(x => x.trim().toUpperCase()) + .filter(x => x)) { + if (upperReqHosts.some(x => x === upperNoProxyItem)) { + return true; + } + } + return false; +} +exports.checkBypass = checkBypass; +//# sourceMappingURL=proxy.js.map /***/ }), @@ -527,10 +2476,10 @@ function range(a, b, str) { /***/ }), /***/ 3717: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var concatMap = __webpack_require__(6891); -var balanced = __webpack_require__(9417); +var concatMap = __nccwpck_require__(6891); +var balanced = __nccwpck_require__(9417); module.exports = expandTop; @@ -735,14 +2684,14 @@ function expand(str, isTop) { /***/ }), /***/ 3171: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var Shim = __webpack_require__(9179); -var GenericCollection = __webpack_require__(8488); -var GenericMap = __webpack_require__(2049); +var Shim = __nccwpck_require__(9179); +var GenericCollection = __nccwpck_require__(8488); +var GenericMap = __nccwpck_require__(2049); // Burgled from https://github.com/domenic/dict @@ -949,17 +2898,17 @@ Dict.prototype.toJSON = function () { /***/ }), /***/ 7307: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var Shim = __webpack_require__(9179); -var Dict = __webpack_require__(3171); -var List = __webpack_require__(3135); -var GenericCollection = __webpack_require__(8488); -var GenericSet = __webpack_require__(9918); -var TreeLog = __webpack_require__(1783); +var Shim = __nccwpck_require__(9179); +var Dict = __nccwpck_require__(3171); +var List = __nccwpck_require__(3135); +var GenericCollection = __nccwpck_require__(8488); +var GenericSet = __nccwpck_require__(9918); +var TreeLog = __nccwpck_require__(1783); var object_has = Object.prototype.hasOwnProperty; @@ -1190,16 +3139,16 @@ FastSet.prototype.logNode = function (node, write) { /***/ }), /***/ 3135: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; module.exports = List; -var Shim = __webpack_require__(9179); -var GenericCollection = __webpack_require__(8488); -var GenericOrder = __webpack_require__(1650); +var Shim = __nccwpck_require__(9179); +var GenericCollection = __nccwpck_require__(8488); +var GenericOrder = __nccwpck_require__(1650); function List(values, equals, getDefault) { return List._init(List, this, values, equals, getDefault); @@ -1592,13 +3541,13 @@ Node.prototype.addAfter = function (node) { /***/ }), /***/ 4410: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var Shim = __webpack_require__(9179); -var GenericCollection = __webpack_require__(8488); +var Shim = __nccwpck_require__(9179); +var GenericCollection = __nccwpck_require__(8488); var Map, GlobalMap, CollectionsMap; if((global.Map !== void 0) && (typeof global.Set.prototype.values === "function")) { @@ -1843,8 +3792,8 @@ if((global.Map !== void 0) && (typeof global.Set.prototype.values === "function" var ChangeDispatchMap = Object.create(Map.prototype, observableMapProperties); } - var Set = __webpack_require__(5917).CollectionsSet; - var GenericMap = __webpack_require__(2049); + var Set = (__nccwpck_require__(5917).CollectionsSet); + var GenericMap = __nccwpck_require__(2049); CollectionsMap = Map = function Map(values, equals, hash, getDefault) { if (!(this instanceof Map)) { @@ -1910,14 +3859,14 @@ if((global.Map !== void 0) && (typeof global.Set.prototype.values === "function" /***/ }), /***/ 5917: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var Shim = __webpack_require__(9179); -var GenericCollection = __webpack_require__(8488); -var GenericSet = __webpack_require__(9918); +var Shim = __nccwpck_require__(9179); +var GenericCollection = __nccwpck_require__(8488); +var GenericSet = __nccwpck_require__(9918); var Set, GlobalSet, CollectionsSet; @@ -2018,9 +3967,9 @@ if((global.Set !== void 0) && (typeof global.Set.prototype.values === "function" - var List = __webpack_require__(3135); - var FastSet = __webpack_require__(7307); - var Iterator = __webpack_require__(6387); + var List = __nccwpck_require__(3135); + var FastSet = __nccwpck_require__(7307); + var Iterator = __nccwpck_require__(6387); CollectionsSet = function CollectionsSet(values, equals, hash, getDefault) { return CollectionsSet._init(CollectionsSet, this, values, equals, hash, getDefault); @@ -2200,15 +4149,15 @@ else { /***/ }), /***/ 2045: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -__webpack_require__(5138); -var GenericCollection = __webpack_require__(8488); -var GenericOrder = __webpack_require__(1650); -var RangeChanges = __webpack_require__(1843); +__nccwpck_require__(5138); +var GenericCollection = __nccwpck_require__(8488); +var GenericOrder = __nccwpck_require__(1650); +var RangeChanges = __nccwpck_require__(1843); // by Petka Antonov // https://github.com/petkaantonov/deque/blob/master/js/deque.js @@ -2673,7 +4622,7 @@ function pow2AtLeast(n) { /***/ }), /***/ 8488: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; @@ -2999,19 +4948,19 @@ GenericCollection._sizePropertyDescriptor = { Object.defineProperty(GenericCollection.prototype,"size",GenericCollection._sizePropertyDescriptor); -__webpack_require__(8475); +__nccwpck_require__(8475); /***/ }), /***/ 2049: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var Object = __webpack_require__(5138); -var Iterator = __webpack_require__(6387); +var Object = __nccwpck_require__(5138); +var Iterator = __nccwpck_require__(6387); module.exports = GenericMap; function GenericMap() { @@ -3224,10 +5173,10 @@ Item.prototype.compare = function (that) { /***/ }), /***/ 1650: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var Object = __webpack_require__(5138); +var Object = __nccwpck_require__(5138); module.exports = GenericOrder; function GenericOrder() { @@ -3385,15 +5334,15 @@ GenericSet.prototype.entriesArray = function() { /***/ }), /***/ 6387: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; module.exports = Iterator; -var Object = __webpack_require__(5138); -var GenericCollection = __webpack_require__(8488); +var Object = __nccwpck_require__(5138); +var GenericCollection = __nccwpck_require__(8488); // upgrades an iterable to a Iterator function Iterator(iterable, standardMode) { @@ -3773,7 +5722,7 @@ Iterator.repeat = function (value, times) { /***/ }), /***/ 375: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { /* Copyright (c) 2016, Montage Studio Inc. All Rights Reserved. @@ -3781,7 +5730,7 @@ Iterator.repeat = function (value, times) { https://github.com/montagejs/montage/blob/master/LICENSE.md */ -var Map = __webpack_require__(4410); +var Map = __nccwpck_require__(4410); var ObjectChangeDescriptor = module.exports.ObjectChangeDescriptor = function ObjectChangeDescriptor(name) { this.name = name; @@ -3921,14 +5870,14 @@ WillChangeListenersRecord.prototype.genericHandlerMethodName = "handlePropertyWi /***/ }), /***/ 3971: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var WeakMap = __webpack_require__(491), - Map = __webpack_require__(4410), - ChangeDescriptor = __webpack_require__(375), +var WeakMap = __nccwpck_require__(491), + Map = __nccwpck_require__(4410), + ChangeDescriptor = __nccwpck_require__(375), ObjectChangeDescriptor = ChangeDescriptor.ObjectChangeDescriptor, ChangeListenersRecord = ChangeDescriptor.ChangeListenersRecord, ListenerGhost = ChangeDescriptor.ListenerGhost; @@ -4191,7 +6140,7 @@ MapChanges.prototype.dispatchBeforeMapChange = function (key, value) { /***/ }), /***/ 4570: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { /* Based in part on observable arrays from Motorola Mobility’s Montage @@ -4257,10 +6206,10 @@ function PropertyChanges() { throw new Error("This is an abstract interface. Mix it. Don't construct it"); } -__webpack_require__(9179); -var Map = __webpack_require__(4410); -var WeakMap = __webpack_require__(491); -var ChangeDescriptor = __webpack_require__(375), +__nccwpck_require__(9179); +var Map = __nccwpck_require__(4410); +var WeakMap = __nccwpck_require__(491); +var ChangeDescriptor = __nccwpck_require__(375), ObjectChangeDescriptor = ChangeDescriptor.ObjectChangeDescriptor, ListenerGhost = ChangeDescriptor.ListenerGhost; @@ -4679,7 +6628,7 @@ PropertyChanges.makePropertyObservable = function (object, key) { /***/ }), /***/ 1843: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; @@ -4689,9 +6638,9 @@ PropertyChanges.makePropertyObservable = function (object, key) { //Use ObjectChangeDescriptor to avoid creating useless arrays and benefit from similar gains made in property-changes -var WeakMap = __webpack_require__(491), - Map = __webpack_require__(4410), - ChangeDescriptor = __webpack_require__(375), +var WeakMap = __nccwpck_require__(491), + Map = __nccwpck_require__(4410), + ChangeDescriptor = __nccwpck_require__(375), ObjectChangeDescriptor = ChangeDescriptor.ObjectChangeDescriptor, ChangeListenersRecord = ChangeDescriptor.ChangeListenersRecord, ListenerGhost = ChangeDescriptor.ListenerGhost; @@ -4954,14 +6903,14 @@ RangeChanges.prototype.dispatchBeforeRangeChange = function (plus, minus, index) /***/ }), /***/ 3857: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var Map = __webpack_require__(4410); -var PropertyChanges = __webpack_require__(4570); -var MapChanges = __webpack_require__(3971); +var Map = __nccwpck_require__(4410); +var PropertyChanges = __nccwpck_require__(4570); +var MapChanges = __nccwpck_require__(3971); module.exports = Map; @@ -4978,7 +6927,7 @@ else { /***/ }), /***/ 8475: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; @@ -4990,23 +6939,27 @@ else { https://github.com/motorola-mobility/montage/blob/master/LICENSE.md */ -var Function = __webpack_require__(1381); -var GenericCollection = __webpack_require__(8488); -var GenericOrder = __webpack_require__(1650); -var WeakMap = __webpack_require__(491); +var Function = __nccwpck_require__(1381); +var GenericCollection = __nccwpck_require__(8488); +var GenericOrder = __nccwpck_require__(1650); +var WeakMap = __nccwpck_require__(491); module.exports = Array; var array_splice = Array.prototype.splice; var array_slice = Array.prototype.slice; -Array.empty = []; +if (!Array.empty) { + Array.empty = []; -if (Object.freeze) { - Object.freeze(Array.empty); + if (Object.freeze) { + Object.freeze(Array.empty); + } } -Array.nativeFrom = Array.from; +if(!Array.nativeFrom ) { + Array.nativeFrom = Array.from; +} var isSymbolDefined = typeof Symbol !== "undefined"; Array.from = function (values, mapFn, thisArg) { @@ -5515,14 +7468,14 @@ Function.get = function (key) { /***/ }), /***/ 5138: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var WeakMap = __webpack_require__(491); +var WeakMap = __nccwpck_require__(491); -__webpack_require__(1381); +__nccwpck_require__(1381); module.exports = Object; @@ -6145,13 +8098,13 @@ if (!RegExp.escape) { /***/ }), /***/ 9179: -/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((__unused_webpack_module, __unused_webpack_exports, __nccwpck_require__) => { -var Array = __webpack_require__(8475); -var Object = __webpack_require__(5138); -var Function = __webpack_require__(1381); -var RegExp = __webpack_require__(2755); +var Array = __nccwpck_require__(8475); +var Object = __nccwpck_require__(5138); +var Function = __nccwpck_require__(1381); +var RegExp = __nccwpck_require__(2755); @@ -6206,10 +8159,10 @@ TreeLog.unicodeSharp = { /***/ }), /***/ 491: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -module.exports = (typeof WeakMap !== 'undefined') ? WeakMap : __webpack_require__(2414); +module.exports = (typeof WeakMap !== 'undefined') ? WeakMap : __nccwpck_require__(2414); /***/ }), @@ -6235,7 +8188,7 @@ var isArray = Array.isArray || function (xs) { /***/ }), /***/ 6863: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { module.exports = realpath realpath.realpath = realpath @@ -6244,13 +8197,13 @@ realpath.realpathSync = realpathSync realpath.monkeypatch = monkeypatch realpath.unmonkeypatch = unmonkeypatch -var fs = __webpack_require__(5747) +var fs = __nccwpck_require__(7147) var origRealpath = fs.realpath var origRealpathSync = fs.realpathSync var version = process.version var ok = /^v[0-5]\./.test(version) -var old = __webpack_require__(1734) +var old = __nccwpck_require__(1734) function newError (er) { return er && er.syscall === 'realpath' && ( @@ -6308,7 +8261,7 @@ function unmonkeypatch () { /***/ }), /***/ 1734: -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { // Copyright Joyent, Inc. and other Node contributors. // @@ -6331,9 +8284,9 @@ function unmonkeypatch () { // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -var pathModule = __webpack_require__(5622); +var pathModule = __nccwpck_require__(1017); var isWindows = process.platform === 'win32'; -var fs = __webpack_require__(5747); +var fs = __nccwpck_require__(7147); // JavaScript implementation of realpath, ported from node pre-v6 @@ -6618,7 +8571,7 @@ exports.realpath = function realpath(p, cache, cb) { /***/ }), /***/ 7625: -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { exports.alphasort = alphasort exports.alphasorti = alphasorti @@ -6634,9 +8587,9 @@ function ownProp (obj, field) { return Object.prototype.hasOwnProperty.call(obj, field) } -var path = __webpack_require__(5622) -var minimatch = __webpack_require__(3973) -var isAbsolute = __webpack_require__(8714) +var path = __nccwpck_require__(1017) +var minimatch = __nccwpck_require__(3973) +var isAbsolute = __nccwpck_require__(8714) var Minimatch = minimatch.Minimatch function alphasorti (a, b) { @@ -6865,7 +8818,7 @@ function childrenIgnored (self, path) { /***/ }), /***/ 1957: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { // Approach: // @@ -6909,27 +8862,27 @@ function childrenIgnored (self, path) { module.exports = glob -var fs = __webpack_require__(5747) -var rp = __webpack_require__(6863) -var minimatch = __webpack_require__(3973) +var fs = __nccwpck_require__(7147) +var rp = __nccwpck_require__(6863) +var minimatch = __nccwpck_require__(3973) var Minimatch = minimatch.Minimatch -var inherits = __webpack_require__(4124) -var EE = __webpack_require__(8614).EventEmitter -var path = __webpack_require__(5622) -var assert = __webpack_require__(2357) -var isAbsolute = __webpack_require__(8714) -var globSync = __webpack_require__(9010) -var common = __webpack_require__(7625) +var inherits = __nccwpck_require__(4124) +var EE = (__nccwpck_require__(2361).EventEmitter) +var path = __nccwpck_require__(1017) +var assert = __nccwpck_require__(9491) +var isAbsolute = __nccwpck_require__(8714) +var globSync = __nccwpck_require__(9010) +var common = __nccwpck_require__(7625) var alphasort = common.alphasort var alphasorti = common.alphasorti var setopts = common.setopts var ownProp = common.ownProp -var inflight = __webpack_require__(2492) -var util = __webpack_require__(1669) +var inflight = __nccwpck_require__(2492) +var util = __nccwpck_require__(3837) var childrenIgnored = common.childrenIgnored var isIgnored = common.isIgnored -var once = __webpack_require__(1223) +var once = __nccwpck_require__(1223) function glob (pattern, options, cb) { if (typeof options === 'function') cb = options, options = {} @@ -7662,21 +9615,21 @@ Glob.prototype._stat2 = function (f, abs, er, stat, cb) { /***/ }), /***/ 9010: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { module.exports = globSync globSync.GlobSync = GlobSync -var fs = __webpack_require__(5747) -var rp = __webpack_require__(6863) -var minimatch = __webpack_require__(3973) +var fs = __nccwpck_require__(7147) +var rp = __nccwpck_require__(6863) +var minimatch = __nccwpck_require__(3973) var Minimatch = minimatch.Minimatch -var Glob = __webpack_require__(1957).Glob -var util = __webpack_require__(1669) -var path = __webpack_require__(5622) -var assert = __webpack_require__(2357) -var isAbsolute = __webpack_require__(8714) -var common = __webpack_require__(7625) +var Glob = (__nccwpck_require__(1957).Glob) +var util = __nccwpck_require__(3837) +var path = __nccwpck_require__(1017) +var assert = __nccwpck_require__(9491) +var isAbsolute = __nccwpck_require__(8714) +var common = __nccwpck_require__(7625) var alphasort = common.alphasort var alphasorti = common.alphasorti var setopts = common.setopts @@ -8155,11 +10108,11 @@ GlobSync.prototype._makeAbs = function (f) { /***/ }), /***/ 2492: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var wrappy = __webpack_require__(2940) +var wrappy = __nccwpck_require__(2940) var reqs = Object.create(null) -var once = __webpack_require__(1223) +var once = __nccwpck_require__(1223) module.exports = wrappy(inflight) @@ -8216,16 +10169,16 @@ function slice (args) { /***/ }), /***/ 4124: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { try { - var util = __webpack_require__(1669); + var util = __nccwpck_require__(3837); /* istanbul ignore next */ if (typeof util.inherits !== 'function') throw ''; module.exports = util.inherits; } catch (e) { /* istanbul ignore next */ - module.exports = __webpack_require__(8544); + module.exports = __nccwpck_require__(8544); } @@ -8266,18 +10219,18 @@ if (typeof Object.create === 'function') { /***/ }), /***/ 3973: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { module.exports = minimatch minimatch.Minimatch = Minimatch var path = { sep: '/' } try { - path = __webpack_require__(5622) + path = __nccwpck_require__(1017) } catch (er) {} var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} -var expand = __webpack_require__(3717) +var expand = __nccwpck_require__(3717) var plTypes = { '!': { open: '(?:(?!(?:', close: '))[^/]*?)'}, @@ -9196,9 +11149,9 @@ function regExpEscape (s) { /***/ }), /***/ 1223: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var wrappy = __webpack_require__(2940) +var wrappy = __nccwpck_require__(2940) module.exports = wrappy(once) module.exports.strict = wrappy(onceStrict) @@ -9273,7 +11226,7 @@ module.exports.win32 = win32; /***/ }), /***/ 2043: -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { ;(function (sax) { // wrapper for non-node envs sax.parser = function (strict, opt) { return new SAXParser(strict, opt) } @@ -9437,7 +11390,7 @@ module.exports.win32 = win32; var Stream try { - Stream = __webpack_require__(2413).Stream + Stream = (__nccwpck_require__(2781).Stream) } catch (ex) { Stream = function () {} } @@ -9507,7 +11460,7 @@ module.exports.win32 = win32; typeof Buffer.isBuffer === 'function' && Buffer.isBuffer(data)) { if (!this._decoder) { - var SD = __webpack_require__(4304).StringDecoder + var SD = (__nccwpck_require__(1576).StringDecoder) this._decoder = new SD('utf8') } data = this._decoder.write(data) @@ -10842,6 +12795,286 @@ module.exports.win32 = win32; })( false ? 0 : exports) +/***/ }), + +/***/ 4294: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +module.exports = __nccwpck_require__(4219); + + +/***/ }), + +/***/ 4219: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +var net = __nccwpck_require__(1808); +var tls = __nccwpck_require__(4404); +var http = __nccwpck_require__(3685); +var https = __nccwpck_require__(5687); +var events = __nccwpck_require__(2361); +var assert = __nccwpck_require__(9491); +var util = __nccwpck_require__(3837); + + +exports.httpOverHttp = httpOverHttp; +exports.httpsOverHttp = httpsOverHttp; +exports.httpOverHttps = httpOverHttps; +exports.httpsOverHttps = httpsOverHttps; + + +function httpOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + return agent; +} + +function httpsOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} + +function httpOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + return agent; +} + +function httpsOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} + + +function TunnelingAgent(options) { + var self = this; + self.options = options || {}; + self.proxyOptions = self.options.proxy || {}; + self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; + self.requests = []; + self.sockets = []; + + self.on('free', function onFree(socket, host, port, localAddress) { + var options = toOptions(host, port, localAddress); + for (var i = 0, len = self.requests.length; i < len; ++i) { + var pending = self.requests[i]; + if (pending.host === options.host && pending.port === options.port) { + // Detect the request to connect same origin server, + // reuse the connection. + self.requests.splice(i, 1); + pending.request.onSocket(socket); + return; + } + } + socket.destroy(); + self.removeSocket(socket); + }); +} +util.inherits(TunnelingAgent, events.EventEmitter); + +TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { + var self = this; + var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); + + if (self.sockets.length >= this.maxSockets) { + // We are over limit so we'll add it to the queue. + self.requests.push(options); + return; + } + + // If we are under maxSockets create a new one. + self.createSocket(options, function(socket) { + socket.on('free', onFree); + socket.on('close', onCloseOrRemove); + socket.on('agentRemove', onCloseOrRemove); + req.onSocket(socket); + + function onFree() { + self.emit('free', socket, options); + } + + function onCloseOrRemove(err) { + self.removeSocket(socket); + socket.removeListener('free', onFree); + socket.removeListener('close', onCloseOrRemove); + socket.removeListener('agentRemove', onCloseOrRemove); + } + }); +}; + +TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { + var self = this; + var placeholder = {}; + self.sockets.push(placeholder); + + var connectOptions = mergeOptions({}, self.proxyOptions, { + method: 'CONNECT', + path: options.host + ':' + options.port, + agent: false, + headers: { + host: options.host + ':' + options.port + } + }); + if (options.localAddress) { + connectOptions.localAddress = options.localAddress; + } + if (connectOptions.proxyAuth) { + connectOptions.headers = connectOptions.headers || {}; + connectOptions.headers['Proxy-Authorization'] = 'Basic ' + + new Buffer(connectOptions.proxyAuth).toString('base64'); + } + + debug('making CONNECT request'); + var connectReq = self.request(connectOptions); + connectReq.useChunkedEncodingByDefault = false; // for v0.6 + connectReq.once('response', onResponse); // for v0.6 + connectReq.once('upgrade', onUpgrade); // for v0.6 + connectReq.once('connect', onConnect); // for v0.7 or later + connectReq.once('error', onError); + connectReq.end(); + + function onResponse(res) { + // Very hacky. This is necessary to avoid http-parser leaks. + res.upgrade = true; + } + + function onUpgrade(res, socket, head) { + // Hacky. + process.nextTick(function() { + onConnect(res, socket, head); + }); + } + + function onConnect(res, socket, head) { + connectReq.removeAllListeners(); + socket.removeAllListeners(); + + if (res.statusCode !== 200) { + debug('tunneling socket could not be established, statusCode=%d', + res.statusCode); + socket.destroy(); + var error = new Error('tunneling socket could not be established, ' + + 'statusCode=' + res.statusCode); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + if (head.length > 0) { + debug('got illegal response body from proxy'); + socket.destroy(); + var error = new Error('got illegal response body from proxy'); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + debug('tunneling connection has established'); + self.sockets[self.sockets.indexOf(placeholder)] = socket; + return cb(socket); + } + + function onError(cause) { + connectReq.removeAllListeners(); + + debug('tunneling socket could not be established, cause=%s\n', + cause.message, cause.stack); + var error = new Error('tunneling socket could not be established, ' + + 'cause=' + cause.message); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + } +}; + +TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { + var pos = this.sockets.indexOf(socket) + if (pos === -1) { + return; + } + this.sockets.splice(pos, 1); + + var pending = this.requests.shift(); + if (pending) { + // If we have pending requests and a socket gets closed a new one + // needs to be created to take over in the pool for the one that closed. + this.createSocket(pending, function(socket) { + pending.request.onSocket(socket); + }); + } +}; + +function createSecureSocket(options, cb) { + var self = this; + TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { + var hostHeader = options.request.getHeader('host'); + var tlsOptions = mergeOptions({}, self.options, { + socket: socket, + servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host + }); + + // 0 is dummy port for v0.6 + var secureSocket = tls.connect(0, tlsOptions); + self.sockets[self.sockets.indexOf(socket)] = secureSocket; + cb(secureSocket); + }); +} + + +function toOptions(host, port, localAddress) { + if (typeof host === 'string') { // since v0.10 + return { + host: host, + port: port, + localAddress: localAddress + }; + } + return host; // for v0.11 or later +} + +function mergeOptions(target) { + for (var i = 1, len = arguments.length; i < len; ++i) { + var overrides = arguments[i]; + if (typeof overrides === 'object') { + var keys = Object.keys(overrides); + for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { + var k = keys[j]; + if (overrides[k] !== undefined) { + target[k] = overrides[k]; + } + } + } + } + return target; +} + + +var debug; +if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { + debug = function() { + var args = Array.prototype.slice.call(arguments); + if (typeof args[0] === 'string') { + args[0] = 'TUNNEL: ' + args[0]; + } else { + args.unshift('TUNNEL:'); + } + console.error.apply(console, args); + } +} else { + debug = function() {}; +} +exports.debug = debug; // for test + + /***/ }), /***/ 2414: @@ -11595,14 +13828,14 @@ module.exports = { /***/ }), /***/ 8821: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { /*jslint node:true */ -var xml2js = __webpack_require__(2903); -var xml2json = __webpack_require__(8919); -var js2xml = __webpack_require__(4453); -var json2xml = __webpack_require__(1900); +var xml2js = __nccwpck_require__(2903); +var xml2json = __nccwpck_require__(8919); +var js2xml = __nccwpck_require__(4453); +var json2xml = __nccwpck_require__(1900); module.exports = { xml2js: xml2js, @@ -11615,10 +13848,10 @@ module.exports = { /***/ }), /***/ 4453: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var helper = __webpack_require__(6717); -var isArray = __webpack_require__(1709).isArray; +var helper = __nccwpck_require__(6717); +var isArray = (__nccwpck_require__(1709).isArray); var currentElement, currentElementName; @@ -11942,9 +14175,9 @@ module.exports = function (js, options) { /***/ }), /***/ 1900: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var js2xml = __webpack_require__(4453); +var js2xml = __nccwpck_require__(4453); module.exports = function (json, options) { if (json instanceof Buffer) { @@ -11967,9 +14200,9 @@ module.exports = function (json, options) { /***/ }), /***/ 6717: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var isArray = __webpack_require__(1709).isArray; +var isArray = (__nccwpck_require__(1709).isArray); module.exports = { @@ -12017,12 +14250,12 @@ module.exports = { /***/ }), /***/ 2903: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var sax = __webpack_require__(2043); +var sax = __nccwpck_require__(2043); var expat /*= require('node-expat');*/ = { on: function () { }, parse: function () { } }; -var helper = __webpack_require__(6717); -var isArray = __webpack_require__(1709).isArray; +var helper = __nccwpck_require__(6717); +var isArray = (__nccwpck_require__(1709).isArray); var options; var pureJsParser = true; @@ -12386,10 +14619,10 @@ module.exports = function (xml, userOptions) { /***/ }), /***/ 8919: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var helper = __webpack_require__(6717); -var xml2js = __webpack_require__(2903); +var helper = __nccwpck_require__(6717); +var xml2js = __nccwpck_require__(2903); function validateOptions (userOptions) { var options = helper.copyOptions(userOptions); @@ -12415,16 +14648,16 @@ module.exports = function(xml, userOptions) { /***/ }), /***/ 5907: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var fsPromise = __webpack_require__(5747).promises; -var fs = __webpack_require__(5747); -var convert = __webpack_require__(8821); -var glob = __webpack_require__(1957); -var path = __webpack_require__(5622); -var Deque = __webpack_require__(2045); -var Map = __webpack_require__(3857); -const core = __webpack_require__(2186); +var fsPromise = (__nccwpck_require__(7147).promises); +var fs = __nccwpck_require__(7147); +var convert = __nccwpck_require__(8821); +var glob = __nccwpck_require__(1957); +var path = __nccwpck_require__(1017); +var Deque = __nccwpck_require__(2045); +var Map = __nccwpck_require__(3857); +const core = __nccwpck_require__(2186); let split = function (testPath, nodeIndex, nodeTotal, filesToExlude = []) { verify(testPath, nodeIndex, nodeTotal); @@ -12450,6 +14683,17 @@ let split = function (testPath, nodeIndex, nodeTotal, filesToExlude = []) { }; let isTestFilesOnSyncWithTestResults = function (testFiles, testResultFiles) { + core.info( + `test files: ${testFiles} ---- test results: ${testResultFiles}` + ); + + if(testFiles == null || testResultFiles == null) { + core.info( + `couldnt find test files or test results` + ); + return false + } + let missingTests = []; let testResultFilesMap = new Map(); testResultFiles.forEach((testResultFile) => { @@ -12464,13 +14708,16 @@ let isTestFilesOnSyncWithTestResults = function (testFiles, testResultFiles) { testResultFilePackages.push(packageName); testResultFilesMap.add(testResultFilePackages, fileName); } - testResultFilesMap.get(fileName); }); testFiles.forEach((testFile) => { let fileData = fs.readFileSync(testFile, "UTF-8"); let regex = /^(\s+)?package(\s+)?([a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_])/; let fileName = path.parse(testFile).name; - let packageName = fileData.match(regex)[3]; + let matchedPackageNames = fileData.match(regex) + core.info( + `matched package names: ${matchedPackageNames}` + ); + let packageName = matchedPackageNames[3]; if (testResultFilesMap.has(fileName)) { let testResultFilePackages = testResultFilesMap.get(fileName); if (testResultFilePackages.includes(packageName)) { @@ -12645,67 +14892,107 @@ module.exports = { /***/ }), -/***/ 2357: +/***/ 9491: +/***/ ((module) => { + +"use strict"; +module.exports = require("assert"); + +/***/ }), + +/***/ 6113: +/***/ ((module) => { + +"use strict"; +module.exports = require("crypto"); + +/***/ }), + +/***/ 2361: +/***/ ((module) => { + +"use strict"; +module.exports = require("events"); + +/***/ }), + +/***/ 7147: +/***/ ((module) => { + +"use strict"; +module.exports = require("fs"); + +/***/ }), + +/***/ 3685: +/***/ ((module) => { + +"use strict"; +module.exports = require("http"); + +/***/ }), + +/***/ 5687: /***/ ((module) => { "use strict"; -module.exports = require("assert");; +module.exports = require("https"); /***/ }), -/***/ 8614: +/***/ 1808: /***/ ((module) => { "use strict"; -module.exports = require("events");; +module.exports = require("net"); /***/ }), -/***/ 5747: +/***/ 2037: /***/ ((module) => { "use strict"; -module.exports = require("fs");; +module.exports = require("os"); /***/ }), -/***/ 2087: +/***/ 1017: /***/ ((module) => { "use strict"; -module.exports = require("os");; +module.exports = require("path"); /***/ }), -/***/ 5622: +/***/ 2781: /***/ ((module) => { "use strict"; -module.exports = require("path");; +module.exports = require("stream"); /***/ }), -/***/ 2413: +/***/ 1576: /***/ ((module) => { "use strict"; -module.exports = require("stream");; +module.exports = require("string_decoder"); /***/ }), -/***/ 4304: +/***/ 4404: /***/ ((module) => { "use strict"; -module.exports = require("string_decoder");; +module.exports = require("tls"); /***/ }), -/***/ 1669: +/***/ 3837: /***/ ((module) => { "use strict"; -module.exports = require("util");; +module.exports = require("util"); /***/ }) @@ -12715,10 +15002,11 @@ module.exports = require("util");; /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function -/******/ function __webpack_require__(moduleId) { +/******/ function __nccwpck_require__(moduleId) { /******/ // Check if module is in cache -/******/ if(__webpack_module_cache__[moduleId]) { -/******/ return __webpack_module_cache__[moduleId].exports; +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { @@ -12730,7 +15018,7 @@ module.exports = require("util");; /******/ // Execute the module function /******/ var threw = true; /******/ try { -/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __nccwpck_require__); /******/ threw = false; /******/ } finally { /******/ if(threw) delete __webpack_module_cache__[moduleId]; @@ -12743,11 +15031,73 @@ module.exports = require("util");; /************************************************************************/ /******/ /* webpack/runtime/compat */ /******/ -/******/ __webpack_require__.ab = __dirname + "/";/************************************************************************/ -/******/ // module exports must be returned from runtime so entry inlining is disabled -/******/ // startup -/******/ // Load entry module and return exports -/******/ return __webpack_require__(2932); +/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +(() => { +const core = __nccwpck_require__(2186); +const split = (__nccwpck_require__(5907).split); +const splitWithTiming = (__nccwpck_require__(5907).splitWithTiming); +const buildTestPattern = (__nccwpck_require__(5907).buildTestPattern); +const path = __nccwpck_require__(1017); +const glob = __nccwpck_require__(1957); + +// most @actions toolkit packages have async methods +async function run() { + try { + const testPath = path.resolve(core.getInput("test-path", true)); + const nodeIndex = parseInt(core.getInput("node-index", true)); + const nodeTotal = parseInt(core.getInput("node-total", true)); + const testResultPath = path.resolve(core.getInput("test-result-path")); + const testExclude = getInputAsArray("test-exclude"); + + core.info( + `Creating ${testPath} tests for index ${nodeIndex} of total ${nodeTotal} with files to ignore: ${testExclude}` + ); + + var tests = ""; + if (glob.sync(buildTestPattern(testPath)).length === 0) { + core.setFailed(`ERROR: Test path does not exist: ${testPath}`); + return; + } + if (glob.sync(`${testResultPath}/**/*.xml`).length === 0) { + core.info( + `TestResult[${testResultPath}] does not exist, using split without timings` + ); + tests = await split(testPath, nodeIndex, nodeTotal, testExclude).catch( + core.setFailed + ); + } else { + tests = await splitWithTiming( + testPath, + testResultPath, + nodeIndex, + nodeTotal, + testExclude + ).catch(core.setFailed); + } + + core.setOutput("tests", tests); + } catch (error) { + core.setFailed(error.message); + } +} + +function getInputAsArray(name, isRequired = false) { + return core + .getInput(name, isRequired) + .split("\n") + .map((s) => s.trim()) + .filter((x) => x !== ""); +} + +run(); + +})(); + +module.exports = __webpack_exports__; /******/ })() ; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map index 802cc06..6873d1d 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../webpack://javascript-action/./index.js","../webpack://javascript-action/./node_modules/@actions/core/lib/command.js","../webpack://javascript-action/./node_modules/@actions/core/lib/core.js","../webpack://javascript-action/./node_modules/@actions/core/lib/file-command.js","../webpack://javascript-action/./node_modules/@actions/core/lib/utils.js","../webpack://javascript-action/./node_modules/balanced-match/index.js","../webpack://javascript-action/./node_modules/brace-expansion/index.js","../webpack://javascript-action/./node_modules/collections/_dict.js","../webpack://javascript-action/./node_modules/collections/_fast-set.js","../webpack://javascript-action/./node_modules/collections/_list.js","../webpack://javascript-action/./node_modules/collections/_map.js","../webpack://javascript-action/./node_modules/collections/_set.js","../webpack://javascript-action/./node_modules/collections/deque.js","../webpack://javascript-action/./node_modules/collections/generic-collection.js","../webpack://javascript-action/./node_modules/collections/generic-map.js","../webpack://javascript-action/./node_modules/collections/generic-order.js","../webpack://javascript-action/./node_modules/collections/generic-set.js","../webpack://javascript-action/./node_modules/collections/iterator.js","../webpack://javascript-action/./node_modules/collections/listen/change-descriptor.js","../webpack://javascript-action/./node_modules/collections/listen/map-changes.js","../webpack://javascript-action/./node_modules/collections/listen/property-changes.js","../webpack://javascript-action/./node_modules/collections/listen/range-changes.js","../webpack://javascript-action/./node_modules/collections/map.js","../webpack://javascript-action/./node_modules/collections/shim-array.js","../webpack://javascript-action/./node_modules/collections/shim-function.js","../webpack://javascript-action/./node_modules/collections/shim-object.js","../webpack://javascript-action/./node_modules/collections/shim-regexp.js","../webpack://javascript-action/./node_modules/collections/shim.js","../webpack://javascript-action/./node_modules/collections/tree-log.js","../webpack://javascript-action/./node_modules/collections/weak-map.js","../webpack://javascript-action/./node_modules/concat-map/index.js","../webpack://javascript-action/./node_modules/fs.realpath/index.js","../webpack://javascript-action/./node_modules/fs.realpath/old.js","../webpack://javascript-action/./node_modules/glob/common.js","../webpack://javascript-action/./node_modules/glob/glob.js","../webpack://javascript-action/./node_modules/glob/sync.js","../webpack://javascript-action/./node_modules/inflight/inflight.js","../webpack://javascript-action/./node_modules/inherits/inherits.js","../webpack://javascript-action/./node_modules/inherits/inherits_browser.js","../webpack://javascript-action/./node_modules/minimatch/minimatch.js","../webpack://javascript-action/./node_modules/once/once.js","../webpack://javascript-action/./node_modules/path-is-absolute/index.js","../webpack://javascript-action/./node_modules/sax/lib/sax.js","../webpack://javascript-action/./node_modules/weak-map/weak-map.js","../webpack://javascript-action/./node_modules/wrappy/wrappy.js","../webpack://javascript-action/./node_modules/xml-js/lib/array-helper.js","../webpack://javascript-action/./node_modules/xml-js/lib/index.js","../webpack://javascript-action/./node_modules/xml-js/lib/js2xml.js","../webpack://javascript-action/./node_modules/xml-js/lib/json2xml.js","../webpack://javascript-action/./node_modules/xml-js/lib/options-helper.js","../webpack://javascript-action/./node_modules/xml-js/lib/xml2js.js","../webpack://javascript-action/./node_modules/xml-js/lib/xml2json.js","../webpack://javascript-action/./splitter.js","../webpack://javascript-action/external \"assert\"","../webpack://javascript-action/external \"events\"","../webpack://javascript-action/external \"fs\"","../webpack://javascript-action/external \"os\"","../webpack://javascript-action/external \"path\"","../webpack://javascript-action/external \"stream\"","../webpack://javascript-action/external \"string_decoder\"","../webpack://javascript-action/external \"util\"","../webpack://javascript-action/webpack/bootstrap","../webpack://javascript-action/webpack/runtime/compat","../webpack://javascript-action/webpack/startup"],"sourcesContent":["const core = require(\"@actions/core\");\nconst split = require(\"./splitter\").split;\nconst splitWithTiming = require(\"./splitter\").splitWithTiming;\nconst buildTestPattern = require(\"./splitter\").buildTestPattern;\nconst path = require(\"path\");\nconst glob = require(\"glob\");\n\n// most @actions toolkit packages have async methods\nasync function run() {\n try {\n const testPath = path.resolve(core.getInput(\"test-path\", true));\n const nodeIndex = parseInt(core.getInput(\"node-index\", true));\n const nodeTotal = parseInt(core.getInput(\"node-total\", true));\n const testResultPath = path.resolve(core.getInput(\"test-result-path\"));\n const testExclude = getInputAsArray(\"test-exclude\");\n\n core.info(\n `Creating ${testPath} tests for index ${nodeIndex} of total ${nodeTotal} with files to ignore: ${testExclude}`\n );\n\n var tests = \"\";\n if (glob.sync(buildTestPattern(testPath)).length === 0) {\n core.setFailed(`ERROR: Test path does not exist: ${testPath}`);\n return;\n }\n if (glob.sync(`${testResultPath}/**/*.xml`).length === 0) {\n core.info(\n `TestResult[${testResultPath}] does not exist, using split without timings`\n );\n tests = await split(testPath, nodeIndex, nodeTotal, testExclude).catch(\n core.setFailed\n );\n } else {\n tests = await splitWithTiming(\n testPath,\n testResultPath,\n nodeIndex,\n nodeTotal,\n testExclude\n ).catch(core.setFailed);\n }\n\n core.setOutput(\"tests\", tests);\n } catch (error) {\n core.setFailed(error.message);\n }\n}\n\nfunction getInputAsArray(name, isRequired = false) {\n return core\n .getInput(name, isRequired)\n .split(\"\\n\")\n .map((s) => s.trim())\n .filter((x) => x !== \"\");\n}\n\nrun();\n","\"use strict\";\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst os = __importStar(require(\"os\"));\nconst utils_1 = require(\"./utils\");\n/**\n * Commands\n *\n * Command Format:\n * ::name key=value,key=value::message\n *\n * Examples:\n * ::warning::This is the message\n * ::set-env name=MY_VAR::some value\n */\nfunction issueCommand(command, properties, message) {\n const cmd = new Command(command, properties, message);\n process.stdout.write(cmd.toString() + os.EOL);\n}\nexports.issueCommand = issueCommand;\nfunction issue(name, message = '') {\n issueCommand(name, {}, message);\n}\nexports.issue = issue;\nconst CMD_STRING = '::';\nclass Command {\n constructor(command, properties, message) {\n if (!command) {\n command = 'missing.command';\n }\n this.command = command;\n this.properties = properties;\n this.message = message;\n }\n toString() {\n let cmdStr = CMD_STRING + this.command;\n if (this.properties && Object.keys(this.properties).length > 0) {\n cmdStr += ' ';\n let first = true;\n for (const key in this.properties) {\n if (this.properties.hasOwnProperty(key)) {\n const val = this.properties[key];\n if (val) {\n if (first) {\n first = false;\n }\n else {\n cmdStr += ',';\n }\n cmdStr += `${key}=${escapeProperty(val)}`;\n }\n }\n }\n }\n cmdStr += `${CMD_STRING}${escapeData(this.message)}`;\n return cmdStr;\n }\n}\nfunction escapeData(s) {\n return utils_1.toCommandValue(s)\n .replace(/%/g, '%25')\n .replace(/\\r/g, '%0D')\n .replace(/\\n/g, '%0A');\n}\nfunction escapeProperty(s) {\n return utils_1.toCommandValue(s)\n .replace(/%/g, '%25')\n .replace(/\\r/g, '%0D')\n .replace(/\\n/g, '%0A')\n .replace(/:/g, '%3A')\n .replace(/,/g, '%2C');\n}\n//# sourceMappingURL=command.js.map","\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst command_1 = require(\"./command\");\nconst file_command_1 = require(\"./file-command\");\nconst utils_1 = require(\"./utils\");\nconst os = __importStar(require(\"os\"));\nconst path = __importStar(require(\"path\"));\n/**\n * The code to exit an action\n */\nvar ExitCode;\n(function (ExitCode) {\n /**\n * A code indicating that the action was successful\n */\n ExitCode[ExitCode[\"Success\"] = 0] = \"Success\";\n /**\n * A code indicating that the action was a failure\n */\n ExitCode[ExitCode[\"Failure\"] = 1] = \"Failure\";\n})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));\n//-----------------------------------------------------------------------\n// Variables\n//-----------------------------------------------------------------------\n/**\n * Sets env variable for this action and future actions in the job\n * @param name the name of the variable to set\n * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction exportVariable(name, val) {\n const convertedVal = utils_1.toCommandValue(val);\n process.env[name] = convertedVal;\n const filePath = process.env['GITHUB_ENV'] || '';\n if (filePath) {\n const delimiter = '_GitHubActionsFileCommandDelimeter_';\n const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;\n file_command_1.issueCommand('ENV', commandValue);\n }\n else {\n command_1.issueCommand('set-env', { name }, convertedVal);\n }\n}\nexports.exportVariable = exportVariable;\n/**\n * Registers a secret which will get masked from logs\n * @param secret value of the secret\n */\nfunction setSecret(secret) {\n command_1.issueCommand('add-mask', {}, secret);\n}\nexports.setSecret = setSecret;\n/**\n * Prepends inputPath to the PATH (for this action and future actions)\n * @param inputPath\n */\nfunction addPath(inputPath) {\n const filePath = process.env['GITHUB_PATH'] || '';\n if (filePath) {\n file_command_1.issueCommand('PATH', inputPath);\n }\n else {\n command_1.issueCommand('add-path', {}, inputPath);\n }\n process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;\n}\nexports.addPath = addPath;\n/**\n * Gets the value of an input. The value is also trimmed.\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns string\n */\nfunction getInput(name, options) {\n const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';\n if (options && options.required && !val) {\n throw new Error(`Input required and not supplied: ${name}`);\n }\n return val.trim();\n}\nexports.getInput = getInput;\n/**\n * Sets the value of an output.\n *\n * @param name name of the output to set\n * @param value value to store. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction setOutput(name, value) {\n command_1.issueCommand('set-output', { name }, value);\n}\nexports.setOutput = setOutput;\n/**\n * Enables or disables the echoing of commands into stdout for the rest of the step.\n * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.\n *\n */\nfunction setCommandEcho(enabled) {\n command_1.issue('echo', enabled ? 'on' : 'off');\n}\nexports.setCommandEcho = setCommandEcho;\n//-----------------------------------------------------------------------\n// Results\n//-----------------------------------------------------------------------\n/**\n * Sets the action status to failed.\n * When the action exits it will be with an exit code of 1\n * @param message add error issue message\n */\nfunction setFailed(message) {\n process.exitCode = ExitCode.Failure;\n error(message);\n}\nexports.setFailed = setFailed;\n//-----------------------------------------------------------------------\n// Logging Commands\n//-----------------------------------------------------------------------\n/**\n * Gets whether Actions Step Debug is on or not\n */\nfunction isDebug() {\n return process.env['RUNNER_DEBUG'] === '1';\n}\nexports.isDebug = isDebug;\n/**\n * Writes debug message to user log\n * @param message debug message\n */\nfunction debug(message) {\n command_1.issueCommand('debug', {}, message);\n}\nexports.debug = debug;\n/**\n * Adds an error issue\n * @param message error issue message. Errors will be converted to string via toString()\n */\nfunction error(message) {\n command_1.issue('error', message instanceof Error ? message.toString() : message);\n}\nexports.error = error;\n/**\n * Adds an warning issue\n * @param message warning issue message. Errors will be converted to string via toString()\n */\nfunction warning(message) {\n command_1.issue('warning', message instanceof Error ? message.toString() : message);\n}\nexports.warning = warning;\n/**\n * Writes info to log with console.log.\n * @param message info message\n */\nfunction info(message) {\n process.stdout.write(message + os.EOL);\n}\nexports.info = info;\n/**\n * Begin an output group.\n *\n * Output until the next `groupEnd` will be foldable in this group\n *\n * @param name The name of the output group\n */\nfunction startGroup(name) {\n command_1.issue('group', name);\n}\nexports.startGroup = startGroup;\n/**\n * End an output group.\n */\nfunction endGroup() {\n command_1.issue('endgroup');\n}\nexports.endGroup = endGroup;\n/**\n * Wrap an asynchronous function call in a group.\n *\n * Returns the same type as the function itself.\n *\n * @param name The name of the group\n * @param fn The function to wrap in the group\n */\nfunction group(name, fn) {\n return __awaiter(this, void 0, void 0, function* () {\n startGroup(name);\n let result;\n try {\n result = yield fn();\n }\n finally {\n endGroup();\n }\n return result;\n });\n}\nexports.group = group;\n//-----------------------------------------------------------------------\n// Wrapper action state\n//-----------------------------------------------------------------------\n/**\n * Saves state for current action, the state can only be retrieved by this action's post job execution.\n *\n * @param name name of the state to store\n * @param value value to store. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction saveState(name, value) {\n command_1.issueCommand('save-state', { name }, value);\n}\nexports.saveState = saveState;\n/**\n * Gets the value of an state set by this action's main execution.\n *\n * @param name name of the state to get\n * @returns string\n */\nfunction getState(name) {\n return process.env[`STATE_${name}`] || '';\n}\nexports.getState = getState;\n//# sourceMappingURL=core.js.map","\"use strict\";\n// For internal use, subject to change.\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n// We use any as a valid input type\n/* eslint-disable @typescript-eslint/no-explicit-any */\nconst fs = __importStar(require(\"fs\"));\nconst os = __importStar(require(\"os\"));\nconst utils_1 = require(\"./utils\");\nfunction issueCommand(command, message) {\n const filePath = process.env[`GITHUB_${command}`];\n if (!filePath) {\n throw new Error(`Unable to find environment variable for file command ${command}`);\n }\n if (!fs.existsSync(filePath)) {\n throw new Error(`Missing file at path: ${filePath}`);\n }\n fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {\n encoding: 'utf8'\n });\n}\nexports.issueCommand = issueCommand;\n//# sourceMappingURL=file-command.js.map","\"use strict\";\n// We use any as a valid input type\n/* eslint-disable @typescript-eslint/no-explicit-any */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * Sanitizes an input into a string so it can be passed into issueCommand safely\n * @param input input to sanitize into a string\n */\nfunction toCommandValue(input) {\n if (input === null || input === undefined) {\n return '';\n }\n else if (typeof input === 'string' || input instanceof String) {\n return input;\n }\n return JSON.stringify(input);\n}\nexports.toCommandValue = toCommandValue;\n//# sourceMappingURL=utils.js.map","'use strict';\nmodule.exports = balanced;\nfunction balanced(a, b, str) {\n if (a instanceof RegExp) a = maybeMatch(a, str);\n if (b instanceof RegExp) b = maybeMatch(b, str);\n\n var r = range(a, b, str);\n\n return r && {\n start: r[0],\n end: r[1],\n pre: str.slice(0, r[0]),\n body: str.slice(r[0] + a.length, r[1]),\n post: str.slice(r[1] + b.length)\n };\n}\n\nfunction maybeMatch(reg, str) {\n var m = str.match(reg);\n return m ? m[0] : null;\n}\n\nbalanced.range = range;\nfunction range(a, b, str) {\n var begs, beg, left, right, result;\n var ai = str.indexOf(a);\n var bi = str.indexOf(b, ai + 1);\n var i = ai;\n\n if (ai >= 0 && bi > 0) {\n begs = [];\n left = str.length;\n\n while (i >= 0 && !result) {\n if (i == ai) {\n begs.push(i);\n ai = str.indexOf(a, i + 1);\n } else if (begs.length == 1) {\n result = [ begs.pop(), bi ];\n } else {\n beg = begs.pop();\n if (beg < left) {\n left = beg;\n right = bi;\n }\n\n bi = str.indexOf(b, i + 1);\n }\n\n i = ai < bi && ai >= 0 ? ai : bi;\n }\n\n if (begs.length) {\n result = [ left, right ];\n }\n }\n\n return result;\n}\n","var concatMap = require('concat-map');\nvar balanced = require('balanced-match');\n\nmodule.exports = expandTop;\n\nvar escSlash = '\\0SLASH'+Math.random()+'\\0';\nvar escOpen = '\\0OPEN'+Math.random()+'\\0';\nvar escClose = '\\0CLOSE'+Math.random()+'\\0';\nvar escComma = '\\0COMMA'+Math.random()+'\\0';\nvar escPeriod = '\\0PERIOD'+Math.random()+'\\0';\n\nfunction numeric(str) {\n return parseInt(str, 10) == str\n ? parseInt(str, 10)\n : str.charCodeAt(0);\n}\n\nfunction escapeBraces(str) {\n return str.split('\\\\\\\\').join(escSlash)\n .split('\\\\{').join(escOpen)\n .split('\\\\}').join(escClose)\n .split('\\\\,').join(escComma)\n .split('\\\\.').join(escPeriod);\n}\n\nfunction unescapeBraces(str) {\n return str.split(escSlash).join('\\\\')\n .split(escOpen).join('{')\n .split(escClose).join('}')\n .split(escComma).join(',')\n .split(escPeriod).join('.');\n}\n\n\n// Basically just str.split(\",\"), but handling cases\n// where we have nested braced sections, which should be\n// treated as individual members, like {a,{b,c},d}\nfunction parseCommaParts(str) {\n if (!str)\n return [''];\n\n var parts = [];\n var m = balanced('{', '}', str);\n\n if (!m)\n return str.split(',');\n\n var pre = m.pre;\n var body = m.body;\n var post = m.post;\n var p = pre.split(',');\n\n p[p.length-1] += '{' + body + '}';\n var postParts = parseCommaParts(post);\n if (post.length) {\n p[p.length-1] += postParts.shift();\n p.push.apply(p, postParts);\n }\n\n parts.push.apply(parts, p);\n\n return parts;\n}\n\nfunction expandTop(str) {\n if (!str)\n return [];\n\n // I don't know why Bash 4.3 does this, but it does.\n // Anything starting with {} will have the first two bytes preserved\n // but *only* at the top level, so {},a}b will not expand to anything,\n // but a{},b}c will be expanded to [a}c,abc].\n // One could argue that this is a bug in Bash, but since the goal of\n // this module is to match Bash's rules, we escape a leading {}\n if (str.substr(0, 2) === '{}') {\n str = '\\\\{\\\\}' + str.substr(2);\n }\n\n return expand(escapeBraces(str), true).map(unescapeBraces);\n}\n\nfunction identity(e) {\n return e;\n}\n\nfunction embrace(str) {\n return '{' + str + '}';\n}\nfunction isPadded(el) {\n return /^-?0\\d/.test(el);\n}\n\nfunction lte(i, y) {\n return i <= y;\n}\nfunction gte(i, y) {\n return i >= y;\n}\n\nfunction expand(str, isTop) {\n var expansions = [];\n\n var m = balanced('{', '}', str);\n if (!m || /\\$$/.test(m.pre)) return [str];\n\n var isNumericSequence = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(m.body);\n var isAlphaSequence = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(m.body);\n var isSequence = isNumericSequence || isAlphaSequence;\n var isOptions = m.body.indexOf(',') >= 0;\n if (!isSequence && !isOptions) {\n // {a},b}\n if (m.post.match(/,.*\\}/)) {\n str = m.pre + '{' + m.body + escClose + m.post;\n return expand(str);\n }\n return [str];\n }\n\n var n;\n if (isSequence) {\n n = m.body.split(/\\.\\./);\n } else {\n n = parseCommaParts(m.body);\n if (n.length === 1) {\n // x{{a,b}}y ==> x{a}y x{b}y\n n = expand(n[0], false).map(embrace);\n if (n.length === 1) {\n var post = m.post.length\n ? expand(m.post, false)\n : [''];\n return post.map(function(p) {\n return m.pre + n[0] + p;\n });\n }\n }\n }\n\n // at this point, n is the parts, and we know it's not a comma set\n // with a single entry.\n\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n var pre = m.pre;\n var post = m.post.length\n ? expand(m.post, false)\n : [''];\n\n var N;\n\n if (isSequence) {\n var x = numeric(n[0]);\n var y = numeric(n[1]);\n var width = Math.max(n[0].length, n[1].length)\n var incr = n.length == 3\n ? Math.abs(numeric(n[2]))\n : 1;\n var test = lte;\n var reverse = y < x;\n if (reverse) {\n incr *= -1;\n test = gte;\n }\n var pad = n.some(isPadded);\n\n N = [];\n\n for (var i = x; test(i, y); i += incr) {\n var c;\n if (isAlphaSequence) {\n c = String.fromCharCode(i);\n if (c === '\\\\')\n c = '';\n } else {\n c = String(i);\n if (pad) {\n var need = width - c.length;\n if (need > 0) {\n var z = new Array(need + 1).join('0');\n if (i < 0)\n c = '-' + z + c.slice(1);\n else\n c = z + c;\n }\n }\n }\n N.push(c);\n }\n } else {\n N = concatMap(n, function(el) { return expand(el, false) });\n }\n\n for (var j = 0; j < N.length; j++) {\n for (var k = 0; k < post.length; k++) {\n var expansion = pre + N[j] + post[k];\n if (!isTop || isSequence || expansion)\n expansions.push(expansion);\n }\n }\n\n return expansions;\n}\n\n","\"use strict\";\n\nvar Shim = require(\"./shim\");\nvar GenericCollection = require(\"./generic-collection\");\nvar GenericMap = require(\"./generic-map\");\n\n// Burgled from https://github.com/domenic/dict\n\nmodule.exports = Dict;\nfunction Dict(values, getDefault) {\n if (!(this instanceof Dict)) {\n return new Dict(values, getDefault);\n }\n getDefault = getDefault || Function.noop;\n this.getDefault = getDefault;\n this.store = Object.create(null);\n this.length = 0;\n this.addEach(values);\n}\n\nDict.Dict = Dict; // hack so require(\"dict\").Dict will work in MontageJS.\n\nObject.addEach(Dict.prototype, GenericCollection.prototype);\nObject.addEach(Dict.prototype, GenericMap.prototype);\n\nDict.from = GenericCollection.from;\n\nDict.prototype.constructClone = function (values) {\n return new this.constructor(values, this.getDefault);\n};\n\nDict.prototype.assertString = function (key) {\n if (typeof key !== \"string\") {\n throw new TypeError(\"key must be a string but Got \" + key);\n }\n}\n\nObject.defineProperty(Dict.prototype,\"$__proto__\",{writable:true});\nObject.defineProperty(Dict.prototype,\"_hasProto\",{\n get:function() {\n return this.hasOwnProperty(\"$__proto__\") && typeof this._protoValue !== \"undefined\";\n }\n});\nObject.defineProperty(Dict.prototype,\"_protoValue\",{\n get:function() {\n return this[\"$__proto__\"];\n },\n set: function(value) {\n this[\"$__proto__\"] = value;\n }\n});\n\nObject.defineProperty(Dict.prototype,\"size\",GenericCollection._sizePropertyDescriptor);\n\n\nDict.prototype.get = function (key, defaultValue) {\n this.assertString(key);\n if (key === \"__proto__\") {\n if (this._hasProto) {\n return this._protoValue;\n } else if (arguments.length > 1) {\n return defaultValue;\n } else {\n return this.getDefault(key);\n }\n }\n else {\n if (key in this.store) {\n return this.store[key];\n } else if (arguments.length > 1) {\n return defaultValue;\n } else {\n return this.getDefault(key);\n }\n }\n};\n\nDict.prototype.set = function (key, value) {\n this.assertString(key);\n var isProtoKey = (key === \"__proto__\");\n\n if (isProtoKey ? this._hasProto : key in this.store) { // update\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, isProtoKey ? this._protoValue : this.store[key]);\n }\n\n isProtoKey\n ? this._protoValue = value\n : this.store[key] = value;\n\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, value);\n }\n return false;\n } else { // create\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, undefined);\n }\n this.length++;\n\n isProtoKey\n ? this._protoValue = value\n : this.store[key] = value;\n\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, value);\n }\n return true;\n }\n};\n\nDict.prototype.has = function (key) {\n this.assertString(key);\n return key === \"__proto__\" ? this._hasProto : key in this.store;\n};\n\nDict.prototype[\"delete\"] = function (key) {\n this.assertString(key);\n if (key === \"__proto__\") {\n if (this._hasProto) {\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, this._protoValue);\n }\n this._protoValue = undefined;\n this.length--;\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, undefined);\n }\n return true;\n }\n return false;\n }\n else {\n if (key in this.store) {\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, this.store[key]);\n }\n delete this.store[key];\n this.length--;\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, undefined);\n }\n return true;\n }\n return false;\n }\n};\n\nDict.prototype.clear = function () {\n var key;\n if (this._hasProto) {\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(\"__proto__\", this._protoValue);\n }\n this._protoValue = undefined;\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(\"__proto__\", undefined);\n }\n }\n for (key in this.store) {\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, this.store[key]);\n }\n delete this.store[key];\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, undefined);\n }\n }\n this.length = 0;\n};\n\nDict.prototype.reduce = function (callback, basis, thisp) {\n if(this._hasProto) {\n basis = callback.call(thisp, basis, \"$__proto__\", \"__proto__\", this);\n }\n var store = this.store;\n for (var key in this.store) {\n basis = callback.call(thisp, basis, store[key], key, this);\n }\n return basis;\n};\n\nDict.prototype.reduceRight = function (callback, basis, thisp) {\n var self = this;\n var store = this.store;\n basis = Object.keys(this.store).reduceRight(function (basis, key) {\n return callback.call(thisp, basis, store[key], key, self);\n }, basis);\n\n if(this._hasProto) {\n return callback.call(thisp, basis, this._protoValue, \"__proto__\", self);\n }\n return basis;\n};\n\nDict.prototype.one = function () {\n var key;\n for (key in this.store) {\n return this.store[key];\n }\n return this._protoValue;\n};\n\nDict.prototype.toJSON = function () {\n return this.toObject();\n};\n","\"use strict\";\n\nvar Shim = require(\"./shim\");\nvar Dict = require(\"./_dict\");\nvar List = require(\"./_list\");\nvar GenericCollection = require(\"./generic-collection\");\nvar GenericSet = require(\"./generic-set\");\nvar TreeLog = require(\"./tree-log\");\n\nvar object_has = Object.prototype.hasOwnProperty;\n\nmodule.exports = FastSet;\n\nfunction FastSet(values, equals, hash, getDefault) {\n if (!(this instanceof FastSet)) {\n return new FastSet(values, equals, hash, getDefault);\n }\n equals = equals || Object.equals;\n hash = hash || Object.hash;\n getDefault = getDefault || Function.noop;\n this.contentEquals = equals;\n this.contentHash = hash;\n this.getDefault = getDefault;\n var self = this;\n this.buckets = new this.Buckets(null, function getDefaultBucket() {\n return new self.Bucket();\n });\n this.length = 0;\n this.addEach(values);\n}\n\nFastSet.FastSet = FastSet; // hack so require(\"fast-set\").FastSet will work in MontageJS\n\nObject.addEach(FastSet.prototype, GenericCollection.prototype);\nObject.addEach(FastSet.prototype, GenericSet.prototype);\nFastSet.from = GenericCollection.from;\n\nFastSet.prototype.Buckets = Dict;\nFastSet.prototype.Bucket = List;\n\nFastSet.prototype.constructClone = function (values) {\n return new this.constructor(\n values,\n this.contentEquals,\n this.contentHash,\n this.getDefault\n );\n};\n\nFastSet.prototype.has = function (value) {\n var hash = this.contentHash(value);\n return this.buckets.get(hash).has(value);\n};\n\nFastSet.prototype.get = function (value, equals) {\n if (equals) {\n throw new Error(\"FastSet#get does not support second argument: equals\");\n }\n var hash = this.contentHash(value);\n var buckets = this.buckets;\n if (buckets.has(hash)) {\n return buckets.get(hash).get(value);\n } else {\n return this.getDefault(value);\n }\n};\n\nFastSet.prototype[\"delete\"] = function (value, equals) {\n if (equals) {\n throw new Error(\"FastSet#delete does not support second argument: equals\");\n }\n var hash = this.contentHash(value);\n var buckets = this.buckets;\n if (buckets.has(hash)) {\n var bucket = buckets.get(hash);\n if (bucket[\"delete\"](value)) {\n this.length--;\n if (bucket.length === 0) {\n buckets[\"delete\"](hash);\n }\n return true;\n }\n }\n return false;\n};\n\nFastSet.prototype.clear = function () {\n this.buckets.clear();\n this.length = 0;\n};\n\nFastSet.prototype.add = function (value) {\n var hash = this.contentHash(value);\n var buckets = this.buckets;\n if (!buckets.has(hash)) {\n buckets.set(hash, new this.Bucket(null, this.contentEquals));\n }\n if (!buckets.get(hash).has(value)) {\n buckets.get(hash).add(value);\n this.length++;\n return true;\n }\n return false;\n};\n\nFastSet.prototype.reduce = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var buckets = this.buckets;\n var index = 0;\n return buckets.reduce(function (basis, bucket) {\n return bucket.reduce(function (basis, value) {\n return callback.call(thisp, basis, value, index++, this);\n }, basis, this);\n }, basis, this);\n};\n\nFastSet.prototype.one = function () {\n if (this.length > 0) {\n return this.buckets.one().one();\n }\n};\n\nFastSet.prototype.iterate = function () {\n return this.buckets.valuesArray().flatten().iterate();\n};\n\nFastSet.prototype.log = function (charmap, logNode, callback, thisp) {\n charmap = charmap || TreeLog.unicodeSharp;\n logNode = logNode || this.logNode;\n if (!callback) {\n callback = console.log;\n thisp = console;\n }\n callback = callback.bind(thisp);\n\n var buckets = this.buckets, bucketsSize = buckets.size,\n mapIter = buckets.keys(), hash, index = 0,\n branch, leader, bucket;\n\n while (hash = mapIter.next().value) {\n if (index === bucketsSize - 1) {\n branch = charmap.fromAbove;\n leader = ' ';\n } else if (index === 0) {\n branch = charmap.branchDown;\n leader = charmap.strafe;\n } else {\n branch = charmap.fromBoth;\n leader = charmap.strafe;\n }\n bucket = buckets.get(hash);\n callback.call(thisp, branch + charmap.through + charmap.branchDown + ' ' + hash);\n bucket.forEach(function (value, node) {\n var branch, below, written;\n if (node === bucket.head.prev) {\n branch = charmap.fromAbove;\n below = ' ';\n } else {\n branch = charmap.fromBoth;\n below = charmap.strafe;\n }\n logNode(\n node,\n function (line) {\n if (!written) {\n callback.call(thisp, leader + ' ' + branch + charmap.through + charmap.through + line);\n written = true;\n } else {\n callback.call(thisp, leader + ' ' + below + ' ' + line);\n }\n },\n function (line) {\n callback.call(thisp, leader + ' ' + charmap.strafe + ' ' + line);\n }\n );\n });\n index++;\n }\n\n //var hashes = buckets.keysArray();\n // hashes.forEach(function (hash, index) {\n // var branch;\n // var leader;\n // if (index === hashes.length - 1) {\n // branch = charmap.fromAbove;\n // leader = ' ';\n // } else if (index === 0) {\n // branch = charmap.branchDown;\n // leader = charmap.strafe;\n // } else {\n // branch = charmap.fromBoth;\n // leader = charmap.strafe;\n // }\n // var bucket = buckets.get(hash);\n // callback.call(thisp, branch + charmap.through + charmap.branchDown + ' ' + hash);\n // bucket.forEach(function (value, node) {\n // var branch, below;\n // if (node === bucket.head.prev) {\n // branch = charmap.fromAbove;\n // below = ' ';\n // } else {\n // branch = charmap.fromBoth;\n // below = charmap.strafe;\n // }\n // var written;\n // logNode(\n // node,\n // function (line) {\n // if (!written) {\n // callback.call(thisp, leader + ' ' + branch + charmap.through + charmap.through + line);\n // written = true;\n // } else {\n // callback.call(thisp, leader + ' ' + below + ' ' + line);\n // }\n // },\n // function (line) {\n // callback.call(thisp, leader + ' ' + charmap.strafe + ' ' + line);\n // }\n // );\n // });\n // });\n};\n\nFastSet.prototype.logNode = function (node, write) {\n var value = node.value;\n if (Object(value) === value) {\n JSON.stringify(value, null, 4).split(\"\\n\").forEach(function (line) {\n write(\" \" + line);\n });\n } else {\n write(\" \" + value);\n }\n};\n","\"use strict\";\n\nmodule.exports = List;\n\nvar Shim = require(\"./shim\");\nvar GenericCollection = require(\"./generic-collection\");\nvar GenericOrder = require(\"./generic-order\");\n\nfunction List(values, equals, getDefault) {\n return List._init(List, this, values, equals, getDefault);\n}\n\nList._init = function (constructor, object, values, equals, getDefault) {\n if (!(object instanceof constructor)) {\n return new constructor(values, equals, getDefault);\n }\n var head = object.head = new object.Node();\n head.next = head;\n head.prev = head;\n object.contentEquals = equals || Object.equals;\n object.getDefault = getDefault || Function.noop;\n object.length = 0;\n object.addEach(values);\n}\n\nList.List = List; // hack so require(\"list\").List will work in MontageJS\n\nObject.addEach(List.prototype, GenericCollection.prototype);\nObject.addEach(List.prototype, GenericOrder.prototype);\n\nList.from = GenericCollection.from;\n\nList.prototype.constructClone = function (values) {\n return new this.constructor(values, this.contentEquals, this.getDefault);\n};\n\nList.prototype.find = function (value, equals, index) {\n equals = equals || this.contentEquals;\n var head = this.head;\n var at = this.scan(index, head.next);\n while (at !== head) {\n if (equals(at.value, value)) {\n return at;\n }\n at = at.next;\n }\n};\n\nList.prototype.findLast = function (value, equals, index) {\n equals = equals || this.contentEquals;\n var head = this.head;\n var at = this.scan(index, head.prev);\n while (at !== head) {\n if (equals(at.value, value)) {\n return at;\n }\n at = at.prev;\n }\n};\n\nList.prototype.has = function (value, equals) {\n return !!this.find(value, equals);\n};\n\nList.prototype.get = function (value, equals) {\n var found = this.find(value, equals);\n if (found) {\n return found.value;\n }\n return this.getDefault(value);\n};\n\n// LIFO (delete removes the most recently added equivalent value)\nList.prototype[\"delete\"] = function (value, equals) {\n var found = this.findLast(value, equals);\n if (found) {\n found[\"delete\"]();\n this.length--;\n return true;\n }\n return false;\n};\n\nList.prototype.deleteAll = function (value, equals) {\n equals = equals || this.contentEquals;\n var head = this.head;\n var at = head.next;\n var count = 0;\n while (at !== head) {\n if (equals(value, at.value)) {\n at[\"delete\"]();\n count++;\n }\n at = at.next;\n }\n this.length -= count;\n return count;\n};\n\nList.prototype.clear = function () {\n this.head.next = this.head.prev = this.head;\n this.length = 0;\n};\n\nList.prototype.add = function (value) {\n var node = new this.Node(value)\n return this._addNode(node);\n};\n\nList.prototype._addNode = function (node) {\n this.head.addBefore(node);\n this.length++;\n return true;\n};\n\nList.prototype.push = function () {\n var head = this.head;\n for (var i = 0; i < arguments.length; i++) {\n var value = arguments[i];\n var node = new this.Node(value);\n head.addBefore(node);\n }\n this.length += arguments.length;\n};\n\nList.prototype.unshift = function () {\n var at = this.head;\n for (var i = 0; i < arguments.length; i++) {\n var value = arguments[i];\n var node = new this.Node(value);\n at.addAfter(node);\n at = node;\n }\n this.length += arguments.length;\n};\n\nList.prototype._shouldPop = function () {\n var value;\n var head = this.head;\n if (head.prev !== head) {\n value = head.prev.value;\n }\n return value;\n}\n\nList.prototype.pop = function (_before, _after) {\n var value;\n var head = this.head;\n if (head.prev !== head) {\n value = head.prev.value;\n var index = this.length - 1;\n var popDispatchValueArray = _before ? _before.call(this,value,index) : void 0;\n head.prev['delete']();\n this.length--;\n _after ? _after.call(this,value,index, popDispatchValueArray) : void 0;\n }\n return value;\n};\n\nList.prototype.shift = function (_before, _after) {\n var value;\n var head = this.head;\n if (head.prev !== head) {\n value = head.next.value;\n var dispatchValueArray = _before ? _before.call(this,value,0) : void 0;\n head.next['delete']();\n this.length--;\n _after ? _after.call(this,value,0,dispatchValueArray) : void 0;\n }\n return value;\n};\n\nList.prototype.peek = function () {\n if (this.head !== this.head.next) {\n return this.head.next.value;\n }\n};\n\nList.prototype.poke = function (value) {\n if (this.head !== this.head.next) {\n this.head.next.value = value;\n } else {\n this.push(value);\n }\n};\n\nList.prototype.one = function () {\n return this.peek();\n};\n\n// TODO\n// List.prototype.indexOf = function (value) {\n// };\n\n// TODO\n// List.prototype.lastIndexOf = function (value) {\n// };\n\n// an internal utility for coercing index offsets to nodes\nList.prototype.scan = function (at, fallback) {\n var head = this.head;\n if (typeof at === \"number\") {\n var count = at;\n if (count >= 0) {\n at = head.next;\n while (count) {\n count--;\n at = at.next;\n if (at == head) {\n break;\n }\n }\n } else {\n at = head;\n while (count < 0) {\n count++;\n at = at.prev;\n if (at == head) {\n break;\n }\n }\n }\n return at;\n } else {\n return at || fallback;\n }\n};\n\n// at and end may both be positive or negative numbers (in which cases they\n// correspond to numeric indicies, or nodes)\nList.prototype.slice = function (at, end) {\n var sliced = [];\n var head = this.head;\n at = this.scan(at, head.next);\n end = this.scan(end, head);\n\n while (at !== end && at !== head) {\n sliced.push(at.value);\n at = at.next;\n }\n\n return sliced;\n};\n\nList.prototype.splice = function (at, length /*...plus*/) {\n return this.swap(at, length, Array.prototype.slice.call(arguments, 2));\n};\n\nList.prototype.swap = function (start, length, plus, _before, _after) {\n var initial = start;\n // start will be head if start is null or -1 (meaning from the end), but\n // will be head.next if start is 0 (meaning from the beginning)\n start = this.scan(start, this.head);\n if (length == null) {\n length = Infinity;\n }\n plus = Array.from(plus);\n\n // collect the minus array\n var minus = [];\n var at = start;\n while (length-- && length >= 0 && at !== this.head) {\n minus.push(at.value);\n at = at.next;\n }\n\n // before range change\n var index, startNode;\n index = _before ? _before.call(this, start, plus, minus) : void 0;\n\n // delete minus\n var at = start;\n for (var i = 0, at = start; i < minus.length; i++, at = at.next) {\n at[\"delete\"]();\n }\n // add plus\n if (initial == null && at === this.head) {\n at = this.head.next;\n }\n for (var i = 0; i < plus.length; i++) {\n var node = new this.Node(plus[i]);\n at.addBefore(node);\n }\n // adjust length\n this.length += plus.length - minus.length;\n\n _after ? _after.call(this, start, plus, minus) : void 0;\n\n return minus;\n};\n\nList.prototype.reverse = function () {\n var at = this.head;\n do {\n var temp = at.next;\n at.next = at.prev;\n at.prev = temp;\n at = at.next;\n } while (at !== this.head);\n return this;\n};\n\nList.prototype.sort = function () {\n this.swap(0, this.length, this.sorted.apply(this, arguments));\n};\n\n// TODO account for missing basis argument\nList.prototype.reduce = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var head = this.head;\n var at = head.next;\n while (at !== head) {\n basis = callback.call(thisp, basis, at.value, at, this);\n at = at.next;\n }\n return basis;\n};\n\nList.prototype.reduceRight = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var head = this.head;\n var at = head.prev;\n while (at !== head) {\n basis = callback.call(thisp, basis, at.value, at, this);\n at = at.prev;\n }\n return basis;\n};\n\nList.prototype.updateIndexes = function (node, index) {\n while (node !== this.head) {\n node.index = index++;\n node = node.next;\n }\n};\n\n\nList.prototype.iterate = function () {\n return new ListIterator(this.head);\n};\n\nfunction ListIterator(head) {\n this.head = head;\n this.at = head.next;\n};\n\nListIterator.prototype.__iterationObject = null;\nObject.defineProperty(ListIterator.prototype,\"_iterationObject\", {\n get: function() {\n return this.__iterationObject || (this.__iterationObject = { done: false, value:null});\n }\n});\n\n\nListIterator.prototype.next = function () {\n if (this.at === this.head) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n } else {\n var value = this.at.value;\n this.at = this.at.next;\n this._iterationObject.value = value;\n }\n return this._iterationObject;\n};\n\nList.prototype.Node = Node;\n\nfunction Node(value) {\n this.value = value;\n this.prev = null;\n this.next = null;\n};\n\nNode.prototype[\"delete\"] = function () {\n this.prev.next = this.next;\n this.next.prev = this.prev;\n};\n\nNode.prototype.addBefore = function (node) {\n var prev = this.prev;\n this.prev = node;\n node.prev = prev;\n prev.next = node;\n node.next = this;\n};\n\nNode.prototype.addAfter = function (node) {\n var next = this.next;\n this.next = node;\n node.next = next;\n next.prev = node;\n node.prev = this;\n};\n","\"use strict\";\n\nvar Shim = require(\"./shim\");\nvar GenericCollection = require(\"./generic-collection\");\nvar Map, GlobalMap, CollectionsMap;\n\nif((global.Map !== void 0) && (typeof global.Set.prototype.values === \"function\")) {\n\n Map = module.exports = global.Map,\n GlobalMap = Map;\n Map.Map = Map; // hack so require(\"map\").Map will work in MontageJS\n\n // use different strategies for making sets observable between Internet\n // Explorer and other browsers.\n var protoIsSupported = {}.__proto__ === Object.prototype,\n map_makeObservable;\n\n if (protoIsSupported) {\n map_makeObservable = function () {\n this.__proto__ = ChangeDispatchMap;\n };\n } else {\n map_makeObservable = function () {\n Object.defineProperties(this, observableSetProperties);\n };\n }\n\n Object.defineProperty(Map.prototype, \"makeObservable\", {\n value: map_makeObservable,\n writable: true,\n configurable: true,\n enumerable: false\n });\n\n //This is a no-op test in property-changes.js - PropertyChanges.prototype.makePropertyObservable, so might as well not pay the price every time....\n Object.defineProperty(Map.prototype, \"makePropertyObservable\", {\n value: function(){},\n writable: true,\n configurable: true,\n enumerable: false\n });\n\n\n Map.prototype.constructClone = function (values) {\n return new this.constructor(values);\n };\n\n Map.prototype.isMap = true;\n Map.prototype.addEach = function (values) {\n if (values && Object(values) === values) {\n if (typeof values.forEach === \"function\") {\n // copy map-alikes\n if (values.isMap === true) {\n values.forEach(function (value, key) {\n this.set(key, value);\n }, this);\n // iterate key value pairs of other iterables\n } else {\n values.forEach(function (pair) {\n this.set(pair[0], pair[1]);\n }, this);\n }\n } else if (typeof values.length === \"number\") {\n // Array-like objects that do not implement forEach, ergo,\n // Arguments\n for (var i = 0; i < values.length; i++) {\n this.add(values[i], i);\n }\n } else {\n // copy other objects as map-alikes\n Object.keys(values).forEach(function (key) {\n this.set(key, values[key]);\n }, this);\n }\n } else if (values && typeof values.length === \"number\") {\n // String\n for (var i = 0; i < values.length; i++) {\n this.add(values[i], i);\n }\n }\n return this;\n };\n\n Map.prototype.add = function (value, key) {\n return this.set(key, value);\n };\n\n Map.prototype.reduce = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n this.forEach(function(value, key, map) {\n basis = callback.call(thisp, basis, value, key, this);\n });\n return basis;\n };\n\n Map.prototype.reduceRight = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var keysIterator = this.keys();\n var size = this.size;\n var reverseOrder = new Array(this.size);\n var aKey, i = 0;\n while ((aKey = keysIterator.next().value)) {\n reverseOrder[--size] = aKey;\n }\n while (i++ < size) {\n basis = callback.call(thisp, basis, this.get(reverseOrder[i]), reverseOrder[i], this);\n }\n return basis;\n };\n\n Map.prototype.equals = function (that, equals) {\n equals = equals || Object.equals;\n if (this === that) {\n return true;\n } else if (that && typeof that.every === \"function\") {\n return that.size === this.size && that.every(function (value, key) {\n return equals(this.get(key), value);\n }, this);\n } else {\n var keys = Object.keys(that);\n return keys.length === this.size && Object.keys(that).every(function (key) {\n return equals(this.get(key), that[key]);\n }, this);\n }\n };\n\n var _keysArrayFunction = function(value,key) {return key;};\n Map.prototype.keysArray = function() {\n return this.map(_keysArrayFunction);\n }\n var _valuesArrayFunction = function(value,key) {return value;};\n Map.prototype.valuesArray = function() {\n return this.map(_valuesArrayFunction);\n }\n var _entriesArrayFunction = function(value,key) {return [key,value];};\n Map.prototype.entriesArray = function() {\n return this.map(_entriesArrayFunction);\n }\n Map.prototype.toJSON = function () {\n return this.entriesArray();\n };\n\n // XXX deprecated\n Map.prototype.items = function () {\n return this.entriesArray();\n };\n\n // Map.prototype.contentEquals = Object.equals;\n // Map.prototype.contentHash = Object.hash;\n\n\n Map.from = function (value) {\n var result = new this;\n result.addEach(value);\n return result;\n };\n\n\n //Backward compatibility:\n Object.defineProperty(Map.prototype,\"length\",{\n get: function() {\n return this.size;\n },\n enumerable: true,\n configurable:true\n });\n\n\n var map_clear = Map.prototype.clear,\n map_set = Map.prototype.set,\n map_delete = Map.prototype.delete;\n\n var observableMapProperties = {\n clear : {\n value: function () {\n var keys;\n if (this.dispatchesMapChanges) {\n this.forEach(function (value, key) {\n this.dispatchBeforeMapChange(key, value);\n }, this);\n keys = this.keysArray();\n }\n map_clear.call(this);\n if (this.dispatchesMapChanges) {\n keys.forEach(function (key) {\n this.dispatchMapChange(key);\n }, this);\n }\n },\n writable: true,\n configurable: true\n\n },\n set : {\n value: function (key, value) {\n var found = this.get(key);\n if (found) { // update\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, found);\n }\n\n map_set.call(this,key, value);\n\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, value);\n }\n } else { // create\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, undefined);\n }\n\n map_set.call(this,key, value);\n\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, value);\n }\n }\n return this;\n },\n writable: true,\n configurable: true\n },\n\n \"delete\": {\n value: function (key) {\n if (this.has(key)) {\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, this.get(key));\n }\n map_delete.call(this,key);\n\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, undefined);\n }\n return true;\n }\n return false;\n }\n }\n };\n\n\n\n Object.addEach(Map.prototype, GenericCollection.prototype, false);\n\n var ChangeDispatchMap = Object.create(Map.prototype, observableMapProperties);\n}\n\n var Set = require(\"./_set\").CollectionsSet;\n var GenericMap = require(\"./generic-map\");\n\n CollectionsMap = Map = function Map(values, equals, hash, getDefault) {\n if (!(this instanceof Map)) {\n return new Map(values, equals, hash, getDefault);\n }\n equals = equals || Object.equals;\n hash = hash || Object.hash;\n getDefault = getDefault || Function.noop;\n this.contentEquals = equals;\n this.contentHash = hash;\n this.getDefault = getDefault;\n this.store = new Set(\n undefined,\n function keysEqual(a, b) {\n return equals(a.key, b.key);\n },\n function keyHash(item) {\n return hash(item.key);\n }\n );\n this.length = 0;\n this.addEach(values);\n }\n\n Map.Map = Map; // hack so require(\"map\").Map will work in MontageJS\n\n Object.addEach(Map.prototype, GenericCollection.prototype);\n Object.addEach(Map.prototype, GenericMap.prototype); // overrides GenericCollection\n Object.defineProperty(Map.prototype,\"size\",GenericCollection._sizePropertyDescriptor);\n\n Map.from = GenericCollection.from;\n\n Map.prototype.constructClone = function (values) {\n return new this.constructor(\n values,\n this.contentEquals,\n this.contentHash,\n this.getDefault\n );\n };\n\n Map.prototype.log = function (charmap, logNode, callback, thisp) {\n logNode = logNode || this.logNode;\n this.store.log(charmap, function (node, log, logBefore) {\n logNode(node.value.value, log, logBefore);\n }, callback, thisp);\n };\n\n Map.prototype.logNode = function (node, log) {\n log(' key: ' + node.key);\n log(' value: ' + node.value);\n };\n\n if(!GlobalMap) {\n module.exports = CollectionsMap;\n }\n else {\n module.exports = GlobalMap;\n GlobalMap.CollectionsMap = CollectionsMap;\n }\n","\"use strict\";\n\nvar Shim = require(\"./shim\");\nvar GenericCollection = require(\"./generic-collection\");\nvar GenericSet = require(\"./generic-set\");\nvar Set, GlobalSet, CollectionsSet;\n\n\nif((global.Set !== void 0) && (typeof global.Set.prototype.values === \"function\")) {\n\n GlobalSet = module.exports = global.Set;\n GlobalSet.Set = GlobalSet; // hack so require(\"set\").Set will work in MontageJS\n\n GlobalSet.prototype.reduce = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n this.forEach(function(value) {\n basis = callback.call(thisp, basis, value, this);\n });\n return basis;\n };\n\n GlobalSet.prototype.reduceRight = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var setIterator = this.values();\n var size = this.size;\n var reverseOrder = new Array(this.size);\n var value, i = size;\n // Fill 'reverseOrder' with values of Set in inverted order.\n while ((value = setIterator.next().value)) {\n reverseOrder[--i] = value;\n }\n // Iterate over reversed values and callback.\n while (i < size) {\n basis = callback.call(thisp, basis, reverseOrder[i++], this);\n }\n return basis;\n };\n\n GlobalSet.prototype.equals = function (that, equals) {\n var self = this;\n return (\n that && typeof that.reduce === \"function\" &&\n this.size === (that.size || that.length) &&\n that.reduce(function (equal, value) {\n return equal && self.has(value, equals);\n }, true)\n );\n };\n\n GlobalSet.prototype.constructClone = function (values) {\n return new this.constructor(values, this.contentEquals, this.contentHash, this.getDefault);\n };\n\n GlobalSet.prototype.toJSON = function () {\n return this.entriesArray();\n };\n\n GlobalSet.prototype.one = function () {\n if (this.size > 0) {\n return this.values().next().value;\n }\n return undefined;\n };\n\n GlobalSet.prototype.pop = function () {\n if (this.size) {\n var setIterator = this.values(), aValue, value;\n while(aValue = setIterator.next().value) {\n value = aValue;\n }\n this[\"delete\"](value,this.size-1);\n return value;\n }\n };\n\n GlobalSet.prototype.shift = function () {\n if (this.size) {\n var firstValue = this.values().next().value;\n this[\"delete\"](firstValue,0);\n return firstValue;\n }\n };\n\n //Backward compatibility:\n Object.defineProperty(GlobalSet.prototype,\"length\",{\n get: function() {\n return this.size;\n },\n enumerable: true,\n configurable:true\n });\n\n GlobalSet.from = function (value) {\n var result = (new this);\n result.addEach(value);\n return result;\n };\n\n Object.addEach(GlobalSet.prototype, GenericCollection.prototype, false);\n Object.addEach(GlobalSet.prototype, GenericSet.prototype, false);\n\n}\n\n\n\n var List = require(\"./_list\");\n var FastSet = require(\"./_fast-set\");\n var Iterator = require(\"./iterator\");\n\n CollectionsSet = function CollectionsSet(values, equals, hash, getDefault) {\n return CollectionsSet._init(CollectionsSet, this, values, equals, hash, getDefault);\n }\n\n CollectionsSet._init = function (constructor, object, values, equals, hash, getDefault) {\n if (!(object instanceof constructor)) {\n return new constructor(values, equals, hash, getDefault);\n }\n equals = equals || Object.equals;\n hash = hash || Object.hash;\n getDefault = getDefault || Function.noop;\n object.contentEquals = equals;\n object.contentHash = hash;\n object.getDefault = getDefault;\n // a list of values in insertion order, used for all operations that depend\n // on iterating in insertion order\n object.order = new object.Order(undefined, equals);\n // a set of nodes from the order list, indexed by the corresponding value,\n // used for all operations that need to quickly seek value in the list\n object.store = new object.Store(\n undefined,\n function (a, b) {\n return equals(a.value, b.value);\n },\n function (node) {\n return hash(node.value);\n }\n );\n object.length = 0;\n object.addEach(values);\n\n }\n\n CollectionsSet.Set = CollectionsSet; // hack so require(\"set\").Set will work in MontageJS\n CollectionsSet.CollectionsSet = CollectionsSet;\n\n Object.addEach(CollectionsSet.prototype, GenericCollection.prototype);\n Object.addEach(CollectionsSet.prototype, GenericSet.prototype);\n\n CollectionsSet.from = GenericCollection.from;\n\n Object.defineProperty(CollectionsSet.prototype,\"size\",GenericCollection._sizePropertyDescriptor);\n\n //Overrides for consistency:\n // Set.prototype.forEach = GenericCollection.prototype.forEach;\n\n\n CollectionsSet.prototype.Order = List;\n CollectionsSet.prototype.Store = FastSet;\n\n CollectionsSet.prototype.constructClone = function (values) {\n return new this.constructor(values, this.contentEquals, this.contentHash, this.getDefault);\n };\n\n CollectionsSet.prototype.has = function (value) {\n var node = new this.order.Node(value);\n return this.store.has(node);\n };\n\n CollectionsSet.prototype.get = function (value, equals) {\n if (equals) {\n throw new Error(\"Set#get does not support second argument: equals\");\n }\n var node = new this.order.Node(value);\n node = this.store.get(node);\n if (node) {\n return node.value;\n } else {\n return this.getDefault(value);\n }\n };\n\n CollectionsSet.prototype.add = function (value) {\n var node = new this.order.Node(value);\n if (!this.store.has(node)) {\n var index = this.length;\n this.order.add(value);\n node = this.order.head.prev;\n this.store.add(node);\n this.length++;\n return true;\n }\n return false;\n };\n\n CollectionsSet.prototype[\"delete\"] = function (value, equals) {\n if (equals) {\n throw new Error(\"Set#delete does not support second argument: equals\");\n }\n var node = new this.order.Node(value);\n if (this.store.has(node)) {\n node = this.store.get(node);\n this.store[\"delete\"](node); // removes from the set\n this.order.splice(node, 1); // removes the node from the list\n this.length--;\n return true;\n }\n return false;\n };\n\n CollectionsSet.prototype.pop = function () {\n if (this.length) {\n var result = this.order.head.prev.value;\n this[\"delete\"](result);\n return result;\n }\n };\n\n CollectionsSet.prototype.shift = function () {\n if (this.length) {\n var result = this.order.head.next.value;\n this[\"delete\"](result);\n return result;\n }\n };\n\n CollectionsSet.prototype.one = function () {\n if (this.length > 0) {\n return this.store.one().value;\n }\n };\n\n CollectionsSet.prototype.clear = function () {\n this.store.clear();\n this.order.clear();\n this.length = 0;\n };\n Object.defineProperty(CollectionsSet.prototype,\"_clear\", {\n value: CollectionsSet.prototype.clear\n });\n\n CollectionsSet.prototype.reduce = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var list = this.order;\n var index = 0;\n return list.reduce(function (basis, value) {\n return callback.call(thisp, basis, value, index++, this);\n }, basis, this);\n };\n\n CollectionsSet.prototype.reduceRight = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var list = this.order;\n var index = this.length - 1;\n return list.reduceRight(function (basis, value) {\n return callback.call(thisp, basis, value, index--, this);\n }, basis, this);\n };\n\n CollectionsSet.prototype.iterate = function () {\n return this.order.iterate();\n };\n\n CollectionsSet.prototype.values = function () {\n return new Iterator(this.valuesArray(), true);\n };\n\n CollectionsSet.prototype.log = function () {\n var set = this.store;\n return set.log.apply(set, arguments);\n };\n\n\n\nif(!GlobalSet) {\n module.exports = CollectionsSet;\n}\nelse {\n GlobalSet.prototype.valuesArray = GenericSet.prototype.valuesArray;\n GlobalSet.prototype.entriesArray = GenericSet.prototype.entriesArray;\n module.exports = GlobalSet;\n GlobalSet.CollectionsSet = CollectionsSet;\n}\n","\"use strict\";\n\nrequire(\"./shim-object\");\nvar GenericCollection = require(\"./generic-collection\");\nvar GenericOrder = require(\"./generic-order\");\nvar RangeChanges = require(\"./listen/range-changes\");\n\n// by Petka Antonov\n// https://github.com/petkaantonov/deque/blob/master/js/deque.js\n// Deque specifically uses\n// http://en.wikipedia.org/wiki/Circular_buffer#Use_a_Fill_Count\n// 1. Incrementally maintained length\n// 2. Modulus avoided by using only powers of two for the capacity\n\nmodule.exports = Deque;\nfunction Deque(values, capacity) {\n if (!(this instanceof Deque)) {\n return new Deque(values, capacity);\n }\n this.capacity = this.snap(capacity);\n this.init();\n this.length = 0;\n this.front = 0;\n this.addEach(values);\n}\n\nObject.addEach(Deque.prototype, GenericCollection.prototype);\nObject.addEach(Deque.prototype, GenericOrder.prototype);\nObject.addEach(Deque.prototype, RangeChanges.prototype);\n\nDeque.from = GenericCollection.from;\n\nDeque.prototype.maxCapacity = (1 << 30) | 0;\nDeque.prototype.minCapacity = 16;\n\nDeque.prototype.constructClone = function (values) {\n return new this.constructor(values, this.capacity)\n};\n\nDeque.prototype.add = function (value) {\n this.push(value);\n};\n\nDeque.prototype.push = function (value /* or ...values */) {\n var argsLength = arguments.length;\n var length = this.length;\n\n if (this.dispatchesRangeChanges) {\n var plus = new Array(argsLength);\n for (var argIndex = 0; argIndex < argsLength; ++argIndex) {\n plus[argIndex] = arguments[argIndex];\n }\n var minus = [];\n this.dispatchBeforeRangeChange(plus, minus, length);\n }\n\n if (argsLength > 1) {\n var capacity = this.capacity;\n if (length + argsLength > capacity) {\n for (var argIndex = 0; argIndex < argsLength; ++argIndex) {\n this.ensureCapacity(length + 1);\n var j = (this.front + length) & (this.capacity - 1);\n this[j] = arguments[argIndex];\n length++;\n this.length = length;\n }\n }\n else {\n var j = this.front;\n for (var argIndex = 0; argIndex < argsLength; ++argIndex) {\n this[(j + length) & (capacity - 1)] = arguments[argIndex];\n j++;\n }\n this.length = length + argsLength;\n }\n\n } else if (argsLength === 1) {\n this.ensureCapacity(length + 1);\n var index = (this.front + length) & (this.capacity - 1);\n this[index] = value;\n this.length = length + 1;\n }\n\n if (this.dispatchesRangeChanges) {\n this.dispatchRangeChange(plus, minus, length);\n }\n\n return this.length;\n};\n\nDeque.prototype.pop = function () {\n var length = this.length;\n if (length === 0) {\n return;\n }\n var index = (this.front + length - 1) & (this.capacity - 1);\n var result = this[index];\n\n if (this.dispatchesRangeChanges) {\n this.dispatchBeforeRangeChange([], [result], length - 1);\n }\n\n this[index] = void 0;\n this.length = length - 1;\n\n if (this.dispatchesRangeChanges) {\n this.dispatchRangeChange([], [result], length - 1);\n }\n\n return result;\n};\n\nDeque.prototype.shift = function () {\n if (this.length !== 0) {\n var front = this.front;\n var result = this[front];\n\n if (this.dispatchesRangeChanges) {\n this.dispatchBeforeRangeChange([], [result], 0);\n }\n\n this[front] = void 0;\n this.front = (front + 1) & (this.capacity - 1);\n this.length--;\n\n if (this.dispatchesRangeChanges) {\n this.dispatchRangeChange([], [result], 0);\n }\n\n return result;\n }\n};\n\nDeque.prototype.unshift = function (value /* or ...values */) {\n var length = this.length;\n var argsLength = arguments.length;\n\n if (this.dispatchesRangeChanges) {\n var plus = new Array(argsLength);\n for (var argIndex = 0; argIndex < argsLength; ++argIndex) {\n plus[argIndex] = arguments[argIndex];\n }\n var minus = [];\n this.dispatchBeforeRangeChange(plus, minus, 0);\n }\n\n if (argsLength > 1) {\n var capacity = this.capacity;\n if (length + argsLength > capacity) {\n for (var argIndex = argsLength - 1; argIndex >= 0; argIndex--) {\n this.ensureCapacity(length + 1);\n var capacity = this.capacity;\n var index = (\n (\n (\n ( this.front - 1 ) &\n ( capacity - 1)\n ) ^ capacity\n ) - capacity\n );\n this[index] = arguments[argIndex];\n length++;\n this.front = index;\n this.length = length;\n }\n } else {\n var front = this.front;\n for (var argIndex = argsLength - 1; argIndex >= 0; argIndex--) {\n var index = (\n (\n (\n (front - 1) &\n (capacity - 1)\n ) ^ capacity\n ) - capacity\n );\n this[index] = arguments[argIndex];\n front = index;\n }\n this.front = front;\n this.length = length + argsLength;\n }\n } else if (argsLength === 1) {\n this.ensureCapacity(length + 1);\n var capacity = this.capacity;\n var index = (\n (\n (\n (this.front - 1) &\n (capacity - 1)\n ) ^ capacity\n ) - capacity\n );\n this[index] = value;\n this.length = length + 1;\n this.front = index;\n }\n\n if (this.dispatchesRangeChanges) {\n this.dispatchRangeChange(plus, minus, 0);\n }\n\n return this.length;\n};\n\nDeque.prototype.clear = function () {\n this.length = 0;\n this.front = 0;\n this.init();\n};\n\nDeque.prototype.ensureCapacity = function (capacity) {\n if (this.capacity < capacity) {\n this.grow(this.snap(this.capacity * 1.5 + 16));\n }\n};\n\nDeque.prototype.grow = function (capacity) {\n var oldFront = this.front;\n var oldCapacity = this.capacity;\n var oldContent = new Array(oldCapacity);\n var length = this.length;\n\n copy(this, 0, oldContent, 0, oldCapacity);\n this.capacity = capacity;\n this.init();\n this.front = 0;\n if (oldFront + length <= oldCapacity) {\n // Can perform direct linear copy.\n copy(oldContent, oldFront, this, 0, length);\n } else {\n // Cannot perform copy directly, perform as much as possible at the\n // end, and then copy the rest to the beginning of the buffer.\n var lengthBeforeWrapping = length - ((oldFront + length) & (oldCapacity - 1));\n copy(oldContent, oldFront, this, 0, lengthBeforeWrapping);\n copy(oldContent, 0, this, lengthBeforeWrapping, length - lengthBeforeWrapping);\n }\n};\n\nDeque.prototype.init = function () {\n for (var index = 0; index < this.capacity; ++index) {\n this[index] = \"nil\"; // TODO void 0\n }\n};\n\nDeque.prototype.snap = function (capacity) {\n if (typeof capacity !== \"number\") {\n return this.minCapacity;\n }\n return pow2AtLeast(\n Math.min(this.maxCapacity, Math.max(this.minCapacity, capacity))\n );\n};\n\nDeque.prototype.one = function () {\n if (this.length > 0) {\n return this[this.front];\n }\n};\n\nDeque.prototype.peek = function () {\n if (this.length === 0) {\n return;\n }\n return this[this.front];\n};\n\nDeque.prototype.poke = function (value) {\n if (this.length === 0) {\n return;\n }\n this[this.front] = value;\n};\n\nDeque.prototype.peekBack = function () {\n var length = this.length;\n if (length === 0) {\n return;\n }\n var index = (this.front + length - 1) & (this.capacity - 1);\n return this[index];\n};\n\nDeque.prototype.pokeBack = function (value) {\n var length = this.length;\n if (length === 0) {\n return;\n }\n var index = (this.front + length - 1) & (this.capacity - 1);\n this[index] = value;\n};\n\nDeque.prototype.get = function (index) {\n // Domain only includes integers\n if (index !== (index | 0)) {\n return;\n }\n // Support negative indicies\n if (index < 0) {\n index = index + this.length;\n }\n // Out of bounds\n if (index < 0 || index >= this.length) {\n return;\n }\n return this[(this.front + index) & (this.capacity - 1)];\n};\n\nDeque.prototype.indexOf = function (value, index) {\n // Default start index at beginning\n if (index == null) {\n index = 0;\n }\n // Support negative indicies\n if (index < 0) {\n index = index + this.length;\n }\n // Left to right walk\n var mask = this.capacity - 1;\n for (; index < this.length; index++) {\n var offset = (this.front + index) & mask;\n if (this[offset] === value) {\n return index;\n }\n }\n return -1;\n};\n\nDeque.prototype.lastIndexOf = function (value, index) {\n // Default start position at the end\n if (index == null) {\n index = this.length - 1;\n }\n // Support negative indicies\n if (index < 0) {\n index = index + this.length;\n }\n // Right to left walk\n var mask = this.capacity - 1;\n for (; index >= 0; index--) {\n var offset = (this.front + index) & mask;\n if (this[offset] === value) {\n return index;\n }\n }\n return -1;\n}\n\nvar deprecatedWarnNonce = {};\nfunction deprecatedWarn(msg, notOnce) {\n if (\n typeof console !== 'undefined' &&\n typeof console.warn === 'function' &&\n (notOnce !== true && deprecatedWarnNonce.hasOwnProperty(msg) === false)\n ) {\n console.warn(msg);\n deprecatedWarnNonce[msg]++;\n }\n}\n\n// TODO remove in v6 (not present in v2)\nDeque.prototype.find = function () {\n deprecatedWarn('Deque#find function is deprecated please use Deque#findValue instead.');\n return this.findValue.apply(this, arguments);\n};\n\nDeque.prototype.findValue = function (value, equals, index) {\n equals = equals || Object.equals;\n // Default start index at beginning\n if (index == null) {\n index = 0;\n }\n // Support negative indicies\n if (index < 0) {\n index = index + this.length;\n }\n // Left to right walk\n var mask = this.capacity - 1;\n for (; index < this.length; index++) {\n var offset = (this.front + index) & mask;\n if (equals(value, this[offset])) {\n return index;\n }\n }\n return -1;\n};\n\n// TODO remove in v6 (not present in v2)\nDeque.prototype.findLast = function () {\n deprecatedWarn('Deque#findLast function is deprecated please use Deque#findLastValue instead.');\n return this.findLastValue.apply(this, arguments);\n};\n\nDeque.prototype.findLastValue = function (value, equals, index) {\n equals = equals || Object.equals;\n // Default start position at the end\n if (index == null) {\n index = this.length - 1;\n }\n // Support negative indicies\n if (index < 0) {\n index = index + this.length;\n }\n // Right to left walk\n var mask = this.capacity - 1;\n for (; index >= 0; index--) {\n var offset = (this.front + index) & mask;\n if (equals(value, this[offset])) {\n return index;\n }\n }\n return -1;\n};\n\nDeque.prototype.has = function (value, equals) {\n equals = equals || Object.equals;\n // Left to right walk\n var mask = this.capacity - 1;\n for (var index = 0; index < this.length; index++) {\n var offset = (this.front + index) & mask;\n if (this[offset] === value) {\n return true;\n }\n }\n return false;\n};\n\nDeque.prototype.reduce = function (callback, basis /*, thisp*/) {\n // TODO account for missing basis argument\n var thisp = arguments[2];\n var mask = this.capacity - 1;\n for (var index = 0; index < this.length; index++) {\n var offset = (this.front + index) & mask;\n basis = callback.call(thisp, basis, this[offset], index, this);\n }\n return basis;\n};\n\nDeque.prototype.reduceRight = function (callback, basis /*, thisp*/) {\n // TODO account for missing basis argument\n var thisp = arguments[2];\n var mask = this.capacity - 1;\n for (var index = this.length - 1; index >= 0; index--) {\n var offset = (this.front + index) & mask;\n basis = callback.call(thisp, basis, this[offset], index, this);\n }\n return basis;\n};\n\nfunction copy(source, sourceIndex, target, targetIndex, length) {\n for (var index = 0; index < length; ++index) {\n target[index + targetIndex] = source[index + sourceIndex];\n }\n}\n\nfunction pow2AtLeast(n) {\n n = n >>> 0;\n n = n - 1;\n n = n | (n >> 1);\n n = n | (n >> 2);\n n = n | (n >> 4);\n n = n | (n >> 8);\n n = n | (n >> 16);\n return n + 1;\n}\n","\"use strict\";\n\nmodule.exports = GenericCollection;\nfunction GenericCollection() {\n throw new Error(\"Can't construct. GenericCollection is a mixin.\");\n}\n\nvar DOMTokenList = global.DOMTokenList || function(){};\n\nGenericCollection.EmptyArray = Object.freeze([]);\n\nGenericCollection.prototype.addEach = function (values, mapFn, thisp) {\n //We want to eliminate everything but array like: Strings, Arrays, DOMTokenList\n if(values && (values instanceof Array || (values instanceof DOMTokenList) || values instanceof String)) {\n if(mapFn) {\n for (var i = 0; i < values.length; i++) {\n this.add(mapFn.call(thisp,values[i]), i);\n }\n } else {\n for (var i = 0; i < values.length; i++) {\n this.add(values[i], i);\n }\n }\n }\n else if (values && Object(values) === values) {\n if (typeof values.forEach === \"function\") {\n if(mapFn) {\n values.map(mapFn, thisp).forEach(this.add, this);\n } else {\n values.forEach(this.add, this);\n }\n } else if(typeof values.next === \"function\") {\n var value, i=0;\n if(mapFn) {\n while ((value = values.next().value)) {\n this.add(mapFn.call(thisp,value), i++);\n }\n }\n else {\n while ((value = values.next().value)) {\n this.add(value, i++);\n }\n }\n } else if (typeof values.length === \"number\") {\n // Array-like objects that do not implement forEach, ergo,\n // Arguments\n if(mapFn) {\n for (var i = 0; i < values.length; i++) {\n this.add(mapFn.call(thisp,values[i]), i);\n }\n }\n else {\n for (var i = 0; i < values.length; i++) {\n this.add(values[i], i);\n }\n }\n } else {\n if(mapFn) {\n Object.keys(values).forEach(function (key) {\n this.add(mapFn.call(thisp,values[key]), key);\n }, this);\n } else {\n Object.keys(values).forEach(function (key) {\n this.add(values[key], key);\n }, this);\n }\n }\n }\n return this;\n};\n\n// This is sufficiently generic for Map (since the value may be a key)\n// and ordered collections (since it forwards the equals argument)\nGenericCollection.prototype.deleteEach = function (values, equals) {\n values.forEach(function (value) {\n this[\"delete\"](value, equals);\n }, this);\n return this;\n};\n\n// all of the following functions are implemented in terms of \"reduce\".\n// some need \"constructClone\".\n\nGenericCollection.prototype.forEach = function (callback /*, thisp*/) {\n var thisp = arguments[1];\n return this.reduce(function (undefined, value, key, object, depth) {\n callback.call(thisp, value, key, object, depth);\n }, undefined);\n};\n\nGenericCollection.prototype.map = function (callback /*, thisp*/) {\n var thisp = arguments[1];\n var result = [];\n this.reduce(function (undefined, value, key, object, depth) {\n result.push(callback.call(thisp, value, key, object, depth));\n }, undefined);\n return result;\n};\n\nGenericCollection.prototype.enumerate = function (start) {\n if (start == null) {\n start = 0;\n }\n var result = [];\n this.reduce(function (undefined, value) {\n result.push([start++, value]);\n }, undefined);\n return result;\n};\n\nGenericCollection.prototype.group = function (callback, thisp, equals) {\n equals = equals || Object.equals;\n var groups = [];\n var keys = [];\n this.forEach(function (value, key, object) {\n var key = callback.call(thisp, value, key, object);\n var index = keys.indexOf(key, equals);\n var group;\n if (index === -1) {\n group = [];\n groups.push([key, group]);\n keys.push(key);\n } else {\n group = groups[index][1];\n }\n group.push(value);\n });\n return groups;\n};\n\nGenericCollection.prototype.toArray = function () {\n return this.map(Function.identity);\n};\n\n// this depends on stringable keys, which apply to Array and Iterator\n// because they have numeric keys and all Maps since they may use\n// strings as keys. List, Set, and SortedSet have nodes for keys, so\n// toObject would not be meaningful.\nGenericCollection.prototype.toObject = function () {\n var object = {};\n this.reduce(function (undefined, value, key) {\n object[key] = value;\n }, undefined);\n return object;\n};\n\nGenericCollection.from = function () {\n return this.apply(this,arguments);\n};\n\nGenericCollection.prototype.filter = function (callback /*, thisp*/) {\n var thisp = arguments[1];\n var result = this.constructClone();\n this.reduce(function (undefined, value, key, object, depth) {\n if (callback.call(thisp, value, key, object, depth)) {\n result.add(value, key);\n }\n }, undefined);\n return result;\n};\n\nGenericCollection.prototype.every = function (callback /*, thisp*/) {\n var thisp = arguments[1];\n return this.reduce(function (result, value, key, object, depth) {\n return result && callback.call(thisp, value, key, object, depth);\n }, true);\n};\n\nGenericCollection.prototype.some = function (callback /*, thisp*/) {\n var thisp = arguments[1];\n return this.reduce(function (result, value, key, object, depth) {\n return result || callback.call(thisp, value, key, object, depth);\n }, false);\n};\n\nGenericCollection.prototype.all = function () {\n return this.every(Boolean);\n};\n\nGenericCollection.prototype.any = function () {\n return this.some(Boolean);\n};\n\nGenericCollection.prototype.min = function (compare) {\n compare = compare || this.contentCompare || Object.compare;\n var first = true;\n return this.reduce(function (result, value) {\n if (first) {\n first = false;\n return value;\n } else {\n return compare(value, result) < 0 ? value : result;\n }\n }, undefined);\n};\n\nGenericCollection.prototype.max = function (compare) {\n compare = compare || this.contentCompare || Object.compare;\n var first = true;\n return this.reduce(function (result, value) {\n if (first) {\n first = false;\n return value;\n } else {\n return compare(value, result) > 0 ? value : result;\n }\n }, undefined);\n};\n\nGenericCollection.prototype.sum = function (zero) {\n zero = zero === undefined ? 0 : zero;\n return this.reduce(function (a, b) {\n return a + b;\n }, zero);\n};\n\nGenericCollection.prototype.average = function (zero) {\n var sum = zero === undefined ? 0 : zero;\n var count = zero === undefined ? 0 : zero;\n this.reduce(function (undefined, value) {\n sum += value;\n count += 1;\n }, undefined);\n return sum / count;\n};\n\nGenericCollection.prototype.concat = function () {\n var result = this.constructClone(this);\n for (var i = 0; i < arguments.length; i++) {\n result.addEach(arguments[i]);\n }\n return result;\n};\n\nGenericCollection.prototype.flatten = function () {\n var self = this;\n return this.reduce(function (result, array) {\n array.forEach(function (value) {\n this.push(value);\n }, result, self);\n return result;\n }, []);\n};\n\nGenericCollection.prototype.zip = function () {\n var table = Array.prototype.slice.call(arguments);\n table.unshift(this);\n return Array.unzip(table);\n}\n\nGenericCollection.prototype.join = function (delimiter) {\n return this.reduce(function (result, string) {\n // work-around for reduce that does not support no-basis form\n if (result === void 0) {\n return string;\n } else {\n return result + delimiter + string;\n }\n }, void 0);\n};\n\nGenericCollection.prototype.sorted = function (compare, by, order) {\n compare = compare || this.contentCompare || Object.compare;\n // account for comparators generated by Function.by\n if (compare.by) {\n by = compare.by;\n compare = compare.compare || this.contentCompare || Object.compare;\n } else {\n by = by || Function.identity;\n }\n if (order === undefined)\n order = 1;\n return this.map(function (item) {\n return {\n by: by(item),\n value: item\n };\n })\n .sort(function (a, b) {\n return compare(a.by, b.by) * order;\n })\n .map(function (pair) {\n return pair.value;\n });\n};\n\nGenericCollection.prototype.reversed = function () {\n return this.constructClone(this).reverse();\n};\n\nGenericCollection.prototype.clone = function (depth, memo) {\n if (depth === undefined) {\n depth = Infinity;\n } else if (depth === 0) {\n return this;\n }\n var clone = this.constructClone();\n this.forEach(function (value, key) {\n clone.add(Object.clone(value, depth - 1, memo), key);\n }, this);\n return clone;\n};\n\nGenericCollection.prototype.only = function () {\n if (this.length === 1) {\n return this.one();\n }\n};\n\nGenericCollection.prototype.iterator = function () {\n return this.iterate.apply(this, arguments);\n};\n\nGenericCollection._sizePropertyDescriptor = {\n get: function() {\n return this.length;\n },\n enumerable: false,\n configurable: true\n};\n\nObject.defineProperty(GenericCollection.prototype,\"size\",GenericCollection._sizePropertyDescriptor);\n\nrequire(\"./shim-array\");\n","\"use strict\";\n\nvar Object = require(\"./shim-object\");\nvar Iterator = require(\"./iterator\");\n\nmodule.exports = GenericMap;\nfunction GenericMap() {\n throw new Error(\"Can't construct. GenericMap is a mixin.\");\n}\n\n// all of these methods depend on the constructor providing a `store` set\n\nGenericMap.prototype.isMap = true;\n\nGenericMap.prototype.addEach = function (values) {\n var i;\n if (values && Object(values) === values) {\n if (typeof values.forEach === \"function\") {\n // copy map-alikes\n if (values.isMap === true) {\n values.forEach(function (value, key) {\n this.set(key, value);\n }, this);\n // iterate key value pairs of other iterables\n } else {\n values.forEach(function (pair) {\n this.set(pair[0], pair[1]);\n }, this);\n }\n } else if (typeof values.length === \"number\") {\n // Array-like objects that do not implement forEach, ergo,\n // Arguments\n for (i = 0; i < values.length; i++) {\n this.add(values[i], i);\n }\n } else {\n // copy other objects as map-alikes\n Object.keys(values).forEach(function (key) {\n this.set(key, values[key]);\n }, this);\n }\n } else if (values && typeof values.length === \"number\") {\n // String\n for (i = 0; i < values.length; i++) {\n this.add(values[i], i);\n }\n }\n return this;\n};\n\nGenericMap.prototype.get = function (key, defaultValue) {\n var item = this.store.get(new this.Item(key));\n if (item) {\n return item.value;\n } else if (arguments.length > 1) {\n console.log(\"Use of a second argument as default value is deprecated to match standards\");\n return defaultValue;\n } else {\n return this.getDefault(key);\n }\n};\n\nGenericMap.prototype.set = function (key, value) {\n var item = new this.Item(key, value);\n var found = this.store.get(item);\n var grew = false;\n if (found) { // update\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, found.value);\n }\n found.value = value;\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, value);\n }\n } else { // create\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, undefined);\n }\n if (this.store.add(item)) {\n this.length++;\n grew = true;\n }\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, value);\n }\n }\n return this;\n};\n\nGenericMap.prototype.add = function (value, key) {\n return this.set(key, value);\n};\n\nGenericMap.prototype.has = function (key) {\n return this.store.has(new this.Item(key));\n};\n\nGenericMap.prototype['delete'] = function (key) {\n var item = new this.Item(key);\n if (this.store.has(item)) {\n var from = this.store.get(item).value;\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, from);\n }\n this.store[\"delete\"](item);\n this.length--;\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, undefined);\n }\n return true;\n }\n return false;\n};\n\nGenericMap.prototype.clear = function () {\n var keys, key;\n if (this.dispatchesMapChanges) {\n this.forEach(function (value, key) {\n this.dispatchBeforeMapChange(key, value);\n }, this);\n keys = this.keysArray();\n }\n this.store.clear();\n this.length = 0;\n if (this.dispatchesMapChanges) {\n for(var i=0;(key = keys[i]);i++) {\n this.dispatchMapChange(key);\n }\n // keys.forEach(function (key) {\n // this.dispatchMapChange(key);\n // }, this);\n }\n};\n\nGenericMap.prototype.reduce = function (callback, basis, thisp) {\n return this.store.reduce(function (basis, item) {\n return callback.call(thisp, basis, item.value, item.key, this);\n }, basis, this);\n};\n\nGenericMap.prototype.reduceRight = function (callback, basis, thisp) {\n return this.store.reduceRight(function (basis, item) {\n return callback.call(thisp, basis, item.value, item.key, this);\n }, basis, this);\n};\n\nGenericMap.prototype.keysArray = function () {\n return this.map(function (value, key) {\n return key;\n });\n};\nGenericMap.prototype.keys = function () {\n return new Iterator(this.keysArray(), true);\n};\n\nGenericMap.prototype.valuesArray = function () {\n return this.map(Function.identity);\n};\nGenericMap.prototype.values = function () {\n return new Iterator(this.valuesArray(), true);\n};\n\nGenericMap.prototype.entriesArray = function () {\n return this.map(function (value, key) {\n return [key, value];\n });\n};\nGenericMap.prototype.entries = function () {\n return new Iterator(this.entriesArray(), true);\n};\n\n// XXX deprecated\nGenericMap.prototype.items = function () {\n return this.entriesArray();\n};\n\nGenericMap.prototype.equals = function (that, equals) {\n equals = equals || Object.equals;\n if (this === that) {\n return true;\n } else if (that && typeof that.every === \"function\") {\n return that.length === this.length && that.every(function (value, key) {\n return equals(this.get(key), value);\n }, this);\n } else {\n var keys = Object.keys(that);\n return keys.length === this.length && Object.keys(that).every(function (key) {\n return equals(this.get(key), that[key]);\n }, this);\n }\n};\n\nGenericMap.prototype.toJSON = function () {\n return this.entriesArray();\n};\n\n\nGenericMap.prototype.Item = Item;\n\nfunction Item(key, value) {\n this.key = key;\n this.value = value;\n}\n\nItem.prototype.equals = function (that) {\n return Object.equals(this.key, that.key) && Object.equals(this.value, that.value);\n};\n\nItem.prototype.compare = function (that) {\n return Object.compare(this.key, that.key);\n};\n","\nvar Object = require(\"./shim-object\");\n\nmodule.exports = GenericOrder;\nfunction GenericOrder() {\n throw new Error(\"Can't construct. GenericOrder is a mixin.\");\n}\n\nGenericOrder.prototype.equals = function (that, equals) {\n equals = equals || this.contentEquals || Object.equals;\n\n if (this === that) {\n return true;\n }\n if (!that) {\n return false;\n }\n\n var self = this;\n return (\n this.length === that.length &&\n this.zip(that).every(function (pair) {\n return equals(pair[0], pair[1]);\n })\n );\n};\n\nGenericOrder.prototype.compare = function (that, compare) {\n compare = compare || this.contentCompare || Object.compare;\n\n if (this === that) {\n return 0;\n }\n if (!that) {\n return 1;\n }\n\n var length = Math.min(this.length, that.length);\n var comparison = this.zip(that).reduce(function (comparison, pair, index) {\n if (comparison === 0) {\n if (index >= length) {\n return comparison;\n } else {\n return compare(pair[0], pair[1]);\n }\n } else {\n return comparison;\n }\n }, 0);\n if (comparison === 0) {\n return this.length - that.length;\n }\n return comparison;\n};\n\nGenericOrder.prototype.toJSON = function () {\n return this.toArray();\n};\n","\nmodule.exports = GenericSet;\nfunction GenericSet() {\n throw new Error(\"Can't construct. GenericSet is a mixin.\");\n}\n\nGenericSet.prototype.isSet = true;\n\nGenericSet.prototype.union = function (that) {\n var union = this.constructClone(this);\n union.addEach(that);\n return union;\n};\n\nGenericSet.prototype.intersection = function (that) {\n return this.constructClone(this.filter(function (value) {\n return that.has(value);\n }));\n};\n\nGenericSet.prototype.difference = function (that) {\n var union = this.constructClone(this);\n union.deleteEach(that);\n return union;\n};\n\nGenericSet.prototype.symmetricDifference = function (that) {\n var union = this.union(that);\n var intersection = this.intersection(that);\n return union.difference(intersection);\n};\n\nGenericSet.prototype.deleteAll = function (value) {\n // deleteAll is equivalent to delete for sets since they guarantee that\n // only one value exists for an equivalence class, but deleteAll returns\n // the count of deleted values instead of whether a value was deleted.\n return +this[\"delete\"](value);\n};\n\nGenericSet.prototype.equals = function (that, equals) {\n var self = this;\n return (\n that && typeof that.reduce === \"function\" &&\n this.length === that.length &&\n that.reduce(function (equal, value) {\n return equal && self.has(value, equals);\n }, true)\n );\n};\n\nGenericSet.prototype.forEach = function (callback /*, thisp*/) {\n var thisp = arguments[1];\n return this.reduce(function (undefined, value, key, object, depth) {\n //ECMASCRIPT Sets send value twice in callback to forEach\n callback.call(thisp, value, value, object, depth);\n }, undefined);\n};\n\n\nGenericSet.prototype.toJSON = function () {\n return this.toArray();\n};\n\n// W3C DOMTokenList API overlap (does not handle variadic arguments)\n\nGenericSet.prototype.contains = function (value) {\n return this.has(value);\n};\n\nGenericSet.prototype.remove = function (value) {\n return this[\"delete\"](value);\n};\n\nGenericSet.prototype.toggle = function (value) {\n if (this.has(value)) {\n this[\"delete\"](value);\n } else {\n this.add(value);\n }\n};\n\nvar _valuesArrayFunction = function(value,key) {return value;};\nGenericSet.prototype.valuesArray = function() {\n return this.map(_valuesArrayFunction);\n}\nvar _entriesArrayFunction = function(value,key) {return [key,value];};\nGenericSet.prototype.entriesArray = function() {\n return this.map(_entriesArrayFunction);\n}\n","\"use strict\";\n\nmodule.exports = Iterator;\n\nvar Object = require(\"./shim-object\");\nvar GenericCollection = require(\"./generic-collection\");\n\n// upgrades an iterable to a Iterator\nfunction Iterator(iterable, standardMode) {\n\n /*\n standardMode should be passed as true by a collection that uses Iterator\n to provide a polyfill of standard iterations methods like entries() and values(),\n as Collection's iterator behaves differently than standards ones when it comes to sparse arrays.\n without passing standardMode, new Iterator instances will behave as intended independently of standards.\n */\n var values = standardMode && iterable && iterable.values && iterable.values();\n if(values && typeof values.next === \"function\" ) {\n return values;\n }\n\n if (!(this instanceof Iterator)) {\n return new Iterator(iterable);\n }\n\n if (Array.isArray(iterable) || typeof iterable === \"string\")\n return Iterator.iterate(iterable);\n\n iterable = Object(iterable);\n\n if (iterable instanceof Iterator) {\n return iterable;\n } else if (iterable.next) {\n this.next = function () {\n return iterable.next();\n };\n } else if (iterable.iterate) {\n var iterator = iterable.iterate();\n this.next = function () {\n return iterator.next();\n };\n } else if (Object.prototype.toString.call(iterable) === \"[object Function]\") {\n this.next = iterable;\n } else {\n throw new TypeError(\"Can't iterate \" + iterable);\n }\n\n}\n\nIterator.prototype.forEach = GenericCollection.prototype.forEach;\nIterator.prototype.map = GenericCollection.prototype.map;\nIterator.prototype.filter = GenericCollection.prototype.filter;\nIterator.prototype.every = GenericCollection.prototype.every;\nIterator.prototype.some = GenericCollection.prototype.some;\nIterator.prototype.any = GenericCollection.prototype.any;\nIterator.prototype.all = GenericCollection.prototype.all;\nIterator.prototype.min = GenericCollection.prototype.min;\nIterator.prototype.max = GenericCollection.prototype.max;\nIterator.prototype.sum = GenericCollection.prototype.sum;\nIterator.prototype.average = GenericCollection.prototype.average;\nIterator.prototype.flatten = GenericCollection.prototype.flatten;\nIterator.prototype.zip = GenericCollection.prototype.zip;\nIterator.prototype.enumerate = GenericCollection.prototype.enumerate;\nIterator.prototype.sorted = GenericCollection.prototype.sorted;\nIterator.prototype.group = GenericCollection.prototype.group;\nIterator.prototype.reversed = GenericCollection.prototype.reversed;\nIterator.prototype.toArray = GenericCollection.prototype.toArray;\nIterator.prototype.toObject = GenericCollection.prototype.toObject;\nIterator.prototype.iterator = GenericCollection.prototype.iterator;\n\nIterator.prototype.__iterationObject = null;\nObject.defineProperty(Iterator.prototype,\"_iterationObject\", {\n get: function() {\n return this.__iterationObject || (this.__iterationObject = { done: false, value:void 0});\n }\n});\n\n\n// this is a bit of a cheat so flatten and such work with the generic\n// reducible\nIterator.prototype.constructClone = function (values) {\n var clone = [];\n clone.addEach(values);\n return clone;\n};\n\nIterator.prototype.mapIterator = function (callback /*, thisp*/) {\n var self = Iterator(this),\n thisp = arguments[1],\n i = 0;\n\n if (Object.prototype.toString.call(callback) != \"[object Function]\")\n throw new TypeError();\n\n return new self.constructor(function () {\n if(self._iterationObject.done !== true) {\n var callbackValue = callback.call(thisp, self.next().value, i++, self);\n self._iterationObject.value = callbackValue;\n }\n return self._iterationObject;\n });\n};\n\nIterator.prototype.filterIterator = function (callback /*, thisp*/) {\n var self = Iterator(this),\n thisp = arguments[1],\n i = 0;\n\n if (Object.prototype.toString.call(callback) != \"[object Function]\")\n throw new TypeError();\n\n return new self.constructor(function () {\n var nextEntry;\n while (true) {\n nextEntry = self.next();\n if(nextEntry.done !== true) {\n if (callback.call(thisp, nextEntry.value, i++, self))\n return nextEntry;\n }\n else {\n //done true and value undefined at this point\n return nextEntry;\n }\n }\n });\n};\n\nIterator.prototype.reduce = function (callback /*, initial, thisp*/) {\n var self = Iterator(this),\n result = arguments[1],\n thisp = arguments[2],\n i = 0,\n nextEntry;\n\n if (Object.prototype.toString.call(callback) != \"[object Function]\")\n throw new TypeError();\n\n // first iteration unrolled\n nextEntry = self.next();\n if(nextEntry.done === true) {\n if (arguments.length > 1) {\n return arguments[1]; // initial\n } else {\n throw TypeError(\"cannot reduce a value from an empty iterator with no initial value\");\n }\n }\n if (arguments.length > 1) {\n result = callback.call(thisp, result, nextEntry.value, i, self);\n } else {\n result = nextEntry.value;\n }\n i++;\n // remaining entries\n while (true) {\n nextEntry = self.next();\n if(nextEntry.done === true) {\n return result;\n }\n result = callback.call(thisp, result, nextEntry.value, i, self);\n i++;\n }\n\n};\n\nIterator.prototype.concat = function () {\n return Iterator.concat(\n Array.prototype.concat.apply(this, arguments)\n );\n};\n\nIterator.prototype.dropWhile = function (callback /*, thisp */) {\n var self = Iterator(this),\n thisp = arguments[1],\n stopped = false,\n stopValue,\n nextEntry,\n i = 0;\n\n if (Object.prototype.toString.call(callback) != \"[object Function]\")\n throw new TypeError();\n\n while (true) {\n nextEntry = self.next();\n if(nextEntry.done === true) {\n break;\n }\n if (!callback.call(thisp, nextEntry.value, i, self)) {\n stopped = true;\n stopValue = nextEntry.value;\n break;\n }\n i++;\n }\n\n if (stopped) {\n return self.constructor([stopValue]).concat(self);\n } else {\n return self.constructor([]);\n }\n};\n\nIterator.prototype.takeWhile = function (callback /*, thisp*/) {\n var self = Iterator(this),\n thisp = arguments[1],\n nextEntry,\n i = 0;\n\n if (Object.prototype.toString.call(callback) != \"[object Function]\")\n throw new TypeError();\n\n return new self.constructor(function () {\n if(self._iterationObject.done !== true) {\n var value = self.next().value;\n if(callback.call(thisp, value, i++, self)) {\n self._iterationObject.value = value;\n }\n else {\n self._iterationObject.done = true;\n self._iterationObject.value = void 0;\n }\n }\n return self._iterationObject;\n });\n\n};\n\nIterator.prototype.zipIterator = function () {\n return Iterator.unzip(\n Array.prototype.concat.apply(this, arguments)\n );\n};\n\nIterator.prototype.enumerateIterator = function (start) {\n return Iterator.count(start).zipIterator(this);\n};\n\n// creates an iterator for Array and String\nIterator.iterate = function (iterable) {\n var start;\n start = 0;\n return new Iterator(function () {\n // advance to next owned entry\n if (typeof iterable === \"object\") {\n while (!(start in iterable)) {\n // deliberately late bound\n if (start >= iterable.length) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n break;\n }\n else start += 1;\n }\n } else if (start >= iterable.length) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n }\n\n if(!this._iterationObject.done) {\n this._iterationObject.value = iterable[start];\n start += 1;\n }\n return this._iterationObject;\n });\n};\n\nIterator.cycle = function (cycle, times) {\n var next;\n if (arguments.length < 2)\n times = Infinity;\n //cycle = Iterator(cycle).toArray();\n return new Iterator(function () {\n var iteration, nextEntry;\n\n if(next) {\n nextEntry = next();\n }\n\n if(!next || nextEntry.done === true) {\n if (times > 0) {\n times--;\n iteration = Iterator.iterate(cycle);\n nextEntry = (next = iteration.next.bind(iteration))();\n }\n else {\n this._iterationObject.done = true;\n nextEntry = this._iterationObject; }\n }\n return nextEntry;\n });\n};\n\nIterator.concat = function (iterators) {\n iterators = Iterator(iterators);\n var next;\n return new Iterator(function (){\n var iteration, nextEntry;\n if(next) nextEntry = next();\n if(!nextEntry || nextEntry.done === true) {\n nextEntry = iterators.next();\n if(nextEntry.done === false) {\n iteration = Iterator(nextEntry.value);\n next = iteration.next.bind(iteration);\n return next();\n }\n else {\n return nextEntry;\n }\n }\n else return nextEntry;\n });\n};\n\nIterator.unzip = function (iterators) {\n iterators = Iterator(iterators).map(Iterator);\n if (iterators.length === 0)\n return new Iterator([]);\n return new Iterator(function () {\n var stopped, nextEntry;\n var result = iterators.map(function (iterator) {\n nextEntry = iterator.next();\n if (nextEntry.done === true ) {\n stopped = true;\n }\n return nextEntry.value;\n });\n if (stopped) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n }\n else {\n this._iterationObject.value = result;\n }\n return this._iterationObject;\n });\n};\n\nIterator.zip = function () {\n return Iterator.unzip(\n Array.prototype.slice.call(arguments)\n );\n};\n\nIterator.chain = function () {\n return Iterator.concat(\n Array.prototype.slice.call(arguments)\n );\n};\n\nIterator.range = function (start, stop, step) {\n if (arguments.length < 3) {\n step = 1;\n }\n if (arguments.length < 2) {\n stop = start;\n start = 0;\n }\n start = start || 0;\n step = step || 1;\n return new Iterator(function () {\n if (start >= stop) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n }\n var result = start;\n start += step;\n this._iterationObject.value = result;\n\n return this._iterationObject;\n });\n};\n\nIterator.count = function (start, step) {\n return Iterator.range(start, Infinity, step);\n};\n\nIterator.repeat = function (value, times) {\n return new Iterator.range(times).mapIterator(function () {\n return value;\n });\n};\n","/*\n Copyright (c) 2016, Montage Studio Inc. All Rights Reserved.\n 3-Clause BSD License\n https://github.com/montagejs/montage/blob/master/LICENSE.md\n*/\n\nvar Map = require(\"../_map\");\n\nvar ObjectChangeDescriptor = module.exports.ObjectChangeDescriptor = function ObjectChangeDescriptor(name) {\n this.name = name;\n this.isActive = false;\n this._willChangeListeners = null;\n this._changeListeners = null;\n\treturn this;\n}\n\nObject.defineProperties(ObjectChangeDescriptor.prototype,{\n name: {\n\t\tvalue:null,\n\t\twritable: true\n\t},\n isActive: {\n\t\tvalue:false,\n\t\twritable: true\n\t},\n\t_willChangeListeners: {\n\t\tvalue:null,\n\t\twritable: true\n\t},\n\twillChangeListeners: {\n\t\tget: function() {\n\t\t\treturn this._willChangeListeners || (this._willChangeListeners = new this.willChangeListenersRecordConstructor(this.name));\n\t\t}\n\t},\n\t_changeListeners: {\n\t\tvalue:null,\n\t\twritable: true\n\t},\n changeListeners: {\n\t\tget: function() {\n\t\t\treturn this._changeListeners || (this._changeListeners = new this.changeListenersRecordConstructor(this.name));\n\t\t}\n\t},\n changeListenersRecordConstructor: {\n value: ChangeListenersRecord,\n writable: true\n },\n willChangeListenersRecordConstructor: {\n value: WillChangeListenersRecord,\n writable: true\n }\n\n});\n\nvar ListenerGhost = module.exports.ListenerGhost = Object.create(null);\nvar ChangeListenerSpecificHandlerMethodName = new Map();\n\n module.exports.ChangeListenersRecord = ChangeListenersRecord;\nfunction ChangeListenersRecord(name) {\n var specificHandlerMethodName = ChangeListenerSpecificHandlerMethodName.get(name);\n if(!specificHandlerMethodName) {\n specificHandlerMethodName = \"handle\";\n specificHandlerMethodName += name;\n specificHandlerMethodName += \"Change\";\n ChangeListenerSpecificHandlerMethodName.set(name,specificHandlerMethodName);\n }\n this._current = null;\n this._current = null;\n this.specificHandlerMethodName = specificHandlerMethodName;\n return this;\n}\n\nObject.defineProperties(ChangeListenersRecord.prototype,{\n _current: {\n\t\tvalue: null,\n\t\twritable: true\n\t},\n\tcurrent: {\n\t\tget: function() {\n // if(this._current) {\n // console.log(this.constructor.name,\" with \",this._current.length,\" listeners: \", this._current);\n // }\n return this._current;\n //return this._current || (this._current = []);\n\t\t},\n set: function(value) {\n this._current = value;\n }\n\t},\n ListenerGhost: {\n value:ListenerGhost,\n writable: true\n },\n ghostCount: {\n value:0,\n writable: true\n },\n maxListenerGhostRatio: {\n value:0.3,\n writable: true\n },\n listenerGhostFilter: {\n value: function listenerGhostFilter(value) {\n return value !== this.ListenerGhost;\n }\n },\n removeCurrentGostListenersIfNeeded: {\n value: function() {\n if(this._current && this.ghostCount/this._current.length>this.maxListenerGhostRatio) {\n this.ghostCount = 0;\n this._current = this._current.filter(this.listenerGhostFilter,this);\n }\n return this._current;\n }\n },\n dispatchBeforeChange: {\n value: false,\n writable: true\n },\n genericHandlerMethodName: {\n\t\tvalue: \"handlePropertyChange\",\n writable: true\n\t}\n});\n\nmodule.exports.WillChangeListenersRecord = WillChangeListenersRecord;\nvar WillChangeListenerSpecificHandlerMethodName = new Map();\nfunction WillChangeListenersRecord(name) {\n var specificHandlerMethodName = WillChangeListenerSpecificHandlerMethodName.get(name);\n if(!specificHandlerMethodName) {\n specificHandlerMethodName = \"handle\";\n specificHandlerMethodName += name;\n specificHandlerMethodName += \"WillChange\";\n WillChangeListenerSpecificHandlerMethodName.set(name,specificHandlerMethodName);\n }\n this.specificHandlerMethodName = specificHandlerMethodName;\n\treturn this;\n}\nWillChangeListenersRecord.prototype = new ChangeListenersRecord();\nWillChangeListenersRecord.prototype.constructor = WillChangeListenersRecord;\nWillChangeListenersRecord.prototype.genericHandlerMethodName = \"handlePropertyWillChange\";\n","\"use strict\";\n\nvar WeakMap = require(\"../weak-map\"),\n Map = require(\"../_map\"),\n ChangeDescriptor = require(\"./change-descriptor\"),\n ObjectChangeDescriptor = ChangeDescriptor.ObjectChangeDescriptor,\n ChangeListenersRecord = ChangeDescriptor.ChangeListenersRecord,\n ListenerGhost = ChangeDescriptor.ListenerGhost;\n\nmodule.exports = MapChanges;\nfunction MapChanges() {\n throw new Error(\"Can't construct. MapChanges is a mixin.\");\n}\n\nvar object_owns = Object.prototype.hasOwnProperty;\n\n/*\n Object map change descriptors carry information necessary for adding,\n removing, dispatching, and shorting events to listeners for map changes\n for a particular key on a particular object. These descriptors are used\n here for shallow map changes.\n\n {\n willChangeListeners:Array(Fgunction)\n changeListeners:Array(Function)\n }\n*/\n\nvar mapChangeDescriptors = new WeakMap();\n\nfunction MapChangeDescriptor(name) {\n this.name = name;\n this.isActive = false;\n this._willChangeListeners = null;\n this._changeListeners = null;\n};\n\nMapChangeDescriptor.prototype = new ObjectChangeDescriptor();\nMapChangeDescriptor.prototype.constructor = MapChangeDescriptor;\n\nMapChangeDescriptor.prototype.changeListenersRecordConstructor = MapChangeListenersRecord;\nMapChangeDescriptor.prototype.willChangeListenersRecordConstructor = MapWillChangeListenersRecord;\n\nvar MapChangeListenersSpecificHandlerMethodName = new Map();\n\nfunction MapChangeListenersRecord(name) {\n var specificHandlerMethodName = MapChangeListenersSpecificHandlerMethodName.get(name);\n if(!specificHandlerMethodName) {\n specificHandlerMethodName = \"handle\";\n specificHandlerMethodName += name.slice(0, 1).toUpperCase();\n specificHandlerMethodName += name.slice(1);\n specificHandlerMethodName += \"MapChange\";\n MapChangeListenersSpecificHandlerMethodName.set(name,specificHandlerMethodName);\n }\n this.specificHandlerMethodName = specificHandlerMethodName;\n\treturn this;\n}\nMapChangeListenersRecord.prototype = new ChangeListenersRecord();\nMapChangeListenersRecord.prototype.constructor = MapChangeListenersRecord;\nMapChangeListenersRecord.prototype.genericHandlerMethodName = \"handleMapChange\";\n\nvar MapWillChangeListenersSpecificHandlerMethodName = new Map();\n\nfunction MapWillChangeListenersRecord(name) {\n var specificHandlerMethodName = MapWillChangeListenersSpecificHandlerMethodName.get(name);\n if(!specificHandlerMethodName) {\n specificHandlerMethodName = \"handle\";\n specificHandlerMethodName += name.slice(0, 1).toUpperCase();\n specificHandlerMethodName += name.slice(1);\n specificHandlerMethodName += \"MapWillChange\";\n MapWillChangeListenersSpecificHandlerMethodName.set(name,specificHandlerMethodName);\n }\n this.specificHandlerMethodName = specificHandlerMethodName;\n return this;\n}\nMapWillChangeListenersRecord.prototype = new ChangeListenersRecord();\nMapWillChangeListenersRecord.prototype.constructor = MapWillChangeListenersRecord;\nMapWillChangeListenersRecord.prototype.genericHandlerMethodName = \"handleMapWillChange\";\n\n\nMapChanges.prototype.getAllMapChangeDescriptors = function () {\n if (!mapChangeDescriptors.has(this)) {\n mapChangeDescriptors.set(this, new Map());\n }\n return mapChangeDescriptors.get(this);\n};\n\nMapChanges.prototype.getMapChangeDescriptor = function (token) {\n var tokenChangeDescriptors = this.getAllMapChangeDescriptors();\n token = token || \"\";\n if (!tokenChangeDescriptors.has(token)) {\n tokenChangeDescriptors.set(token, new MapChangeDescriptor(token));\n }\n return tokenChangeDescriptors.get(token);\n};\n\nvar ObjectsDispatchesMapChanges = new WeakMap(),\n dispatchesMapChangesGetter = function() {\n return ObjectsDispatchesMapChanges.get(this);\n },\n dispatchesMapChangesSetter = function(value) {\n return ObjectsDispatchesMapChanges.set(this,value);\n },\n dispatchesChangesMethodName = \"dispatchesMapChanges\",\n dispatchesChangesPropertyDescriptor = {\n get: dispatchesMapChangesGetter,\n set: dispatchesMapChangesSetter,\n configurable: true,\n enumerable: false\n };\n\nMapChanges.prototype.addMapChangeListener = function addMapChangeListener(listener, token, beforeChange) {\n //console.log(\"this:\",this,\" addMapChangeListener(\",listener,\",\",token,\",\",beforeChange);\n\n if (!this.isObservable && this.makeObservable) {\n // for Array\n this.makeObservable();\n }\n var descriptor = this.getMapChangeDescriptor(token);\n var listeners;\n if (beforeChange) {\n listeners = descriptor.willChangeListeners;\n } else {\n listeners = descriptor.changeListeners;\n }\n\n // console.log(\"addMapChangeListener()\",listener, token);\n //console.log(\"this:\",this,\" addMapChangeListener() listeners._current is \",listeners._current);\n\n if(!listeners._current) {\n listeners._current = listener;\n }\n else if(!Array.isArray(listeners._current)) {\n listeners._current = [listeners._current,listener]\n }\n else {\n listeners._current.push(listener);\n }\n\n if(Object.getOwnPropertyDescriptor((this.__proto__||Object.getPrototypeOf(this)),dispatchesChangesMethodName) === void 0) {\n Object.defineProperty((this.__proto__||Object.getPrototypeOf(this)), dispatchesChangesMethodName, dispatchesChangesPropertyDescriptor);\n }\n this.dispatchesMapChanges = true;\n\n var self = this;\n return function cancelMapChangeListener() {\n if (!self) {\n // TODO throw new Error(\"Can't remove map change listener again\");\n return;\n }\n self.removeMapChangeListener(listener, token, beforeChange);\n self = null;\n };\n};\n\nMapChanges.prototype.removeMapChangeListener = function (listener, token, beforeChange) {\n var descriptor = this.getMapChangeDescriptor(token);\n\n var listeners;\n if (beforeChange) {\n listeners = descriptor.willChangeListeners;\n } else {\n listeners = descriptor.changeListeners;\n }\n\n if(listeners._current) {\n if(listeners._current === listener) {\n listeners._current = null;\n }\n else {\n var index = listeners._current.lastIndexOf(listener);\n if (index === -1) {\n throw new Error(\"Can't remove map change listener: does not exist: token \" + JSON.stringify(token));\n }\n else {\n if(descriptor.isActive) {\n listeners.ghostCount = listeners.ghostCount+1\n listeners._current[index]=ListenerGhost\n }\n else {\n listeners._current.spliceOne(index);\n }\n }\n }\n }\n\n\n};\n\nMapChanges.prototype.dispatchMapChange = function (key, value, beforeChange) {\n var descriptors = this.getAllMapChangeDescriptors(),\n Ghost = ListenerGhost;\n\n descriptors.forEach(function (descriptor, token) {\n\n if (descriptor.isActive) {\n return;\n }\n\n var listeners = beforeChange ? descriptor.willChangeListeners : descriptor.changeListeners;\n if(listeners && listeners._current) {\n\n var tokenName = listeners.specificHandlerMethodName;\n if(Array.isArray(listeners._current)) {\n if(listeners._current.length) {\n //removeGostListenersIfNeeded returns listeners.current or a new filtered one when conditions are met\n var currentListeners = listeners.removeCurrentGostListenersIfNeeded(),\n i, countI, listener;\n descriptor.isActive = true;\n\n try {\n for(i=0, countI = currentListeners.length;i, ...method names}\n// changeListeners:{current, active:Array, ...method names}\n// }\n\n// Maybe remove entries from this table if the corresponding object no longer\n// has any property change listeners for any key. However, the cost of\n// book-keeping is probably not warranted since it would be rare for an\n// observed object to no longer be observed unless it was about to be disposed\n// of or reused as an observable. The only benefit would be in avoiding bulk\n// calls to dispatchOwnPropertyChange events on objects that have no listeners.\n\n// To observe shallow property changes for a particular key of a particular\n// object, we install a property descriptor on the object that overrides the previous\n// descriptor. The overridden descriptors are stored in this weak map. The\n// weak map associates an object with another object that maps property names\n// to property descriptors.\n//\n// object.__overriddenPropertyDescriptors__[key]\n//\n// We retain the old descriptor for various purposes. For one, if the property\n// is no longer being observed by anyone, we revert the property descriptor to\n// the original. For \"value\" descriptors, we store the actual value of the\n// descriptor on the overridden descriptor, so when the property is reverted, it\n// retains the most recently set value. For \"get\" and \"set\" descriptors,\n// we observe then forward \"get\" and \"set\" operations to the original descriptor.\n\nmodule.exports = PropertyChanges;\n\nfunction PropertyChanges() {\n throw new Error(\"This is an abstract interface. Mix it. Don't construct it\");\n}\n\nrequire(\"../shim\");\nvar Map = require(\"../_map\");\nvar WeakMap = require(\"../weak-map\");\nvar ChangeDescriptor = require(\"./change-descriptor\"),\n ObjectChangeDescriptor = ChangeDescriptor.ObjectChangeDescriptor,\n ListenerGhost = ChangeDescriptor.ListenerGhost;\n\nPropertyChanges.debug = true;\n\nvar ObjectsPropertyChangeListeners = new WeakMap();\n\nvar ObjectChangeDescriptorName = new Map();\n\nPropertyChanges.ObjectChangeDescriptor = function() {\n\n}\n\nPropertyChanges.prototype.getOwnPropertyChangeDescriptor = function (key) {\n var objectPropertyChangeDescriptors = ObjectsPropertyChangeListeners.get(this), keyChangeDescriptor;\n if (!objectPropertyChangeDescriptors) {\n objectPropertyChangeDescriptors = Object.create(null);\n ObjectsPropertyChangeListeners.set(this,objectPropertyChangeDescriptors);\n }\n if ( (keyChangeDescriptor = objectPropertyChangeDescriptors[key]) === void 0) {\n var propertyName = ObjectChangeDescriptorName.get(key);\n if(!propertyName) {\n propertyName = String(key);\n propertyName = propertyName && propertyName[0].toUpperCase() + propertyName.slice(1);\n ObjectChangeDescriptorName.set(key,propertyName);\n }\n return objectPropertyChangeDescriptors[key] = new ObjectChangeDescriptor(propertyName);\n }\n else return keyChangeDescriptor;\n};\n\nPropertyChanges.prototype.hasOwnPropertyChangeDescriptor = function (key) {\n var objectPropertyChangeDescriptors = ObjectsPropertyChangeListeners.get(this);\n if (!objectPropertyChangeDescriptors) {\n return false;\n }\n if (!key) {\n return true;\n }\n if (objectPropertyChangeDescriptors[key] === void 0) {\n return false;\n }\n return true;\n};\n\nPropertyChanges.prototype.addOwnPropertyChangeListener = function (key, listener, beforeChange) {\n if (this.makeObservable && !this.isObservable) {\n this.makeObservable(); // particularly for observable arrays, for\n // their length property\n }\n var descriptor = PropertyChanges.getOwnPropertyChangeDescriptor(this, key),\n listeners = beforeChange ? descriptor.willChangeListeners : descriptor.changeListeners;\n\n PropertyChanges.makePropertyObservable(this, key);\n\n if(!listeners._current) {\n listeners._current = listener;\n }\n else if(!Array.isArray(listeners._current)) {\n listeners._current = [listeners._current,listener]\n }\n else {\n listeners._current.push(listener);\n }\n\n var self = this;\n return function cancelOwnPropertyChangeListener() {\n PropertyChanges.removeOwnPropertyChangeListener(self, key, listener, beforeChange);\n self = null;\n };\n};\n\nPropertyChanges.prototype.addBeforeOwnPropertyChangeListener = function (key, listener) {\n return PropertyChanges.addOwnPropertyChangeListener(this, key, listener, true);\n};\n\nPropertyChanges.prototype.removeOwnPropertyChangeListener = function removeOwnPropertyChangeListener(key, listener, beforeChange) {\n var descriptor = PropertyChanges.getOwnPropertyChangeDescriptor(this, key);\n\n var listeners;\n if (beforeChange) {\n listeners = descriptor._willChangeListeners;\n } else {\n listeners = descriptor._changeListeners;\n }\n\n if(listeners) {\n if(listeners._current) {\n if(listeners._current === listener) {\n listeners._current = null;\n }\n else {\n\n var index = listeners._current.lastIndexOf(listener);\n if (index === -1) {\n throw new Error(\"Can't remove property change listener: does not exist: property name\" + JSON.stringify(key));\n }\n if(descriptor.isActive) {\n listeners.ghostCount = listeners.ghostCount+1;\n listeners._current[index]=removeOwnPropertyChangeListener.ListenerGhost;\n }\n else {\n listeners._current.spliceOne(index);\n }\n }\n }\n }\n};\nPropertyChanges.prototype.removeOwnPropertyChangeListener.ListenerGhost = ListenerGhost;\n\nPropertyChanges.prototype.removeBeforeOwnPropertyChangeListener = function (key, listener) {\n return PropertyChanges.removeOwnPropertyChangeListener(this, key, listener, true);\n};\n\nPropertyChanges.prototype.dispatchOwnPropertyChange = function dispatchOwnPropertyChange(key, value, beforeChange) {\n var descriptor = PropertyChanges.getOwnPropertyChangeDescriptor(this, key),\n listeners;\n\n if (!descriptor.isActive) {\n descriptor.isActive = true;\n listeners = beforeChange ? descriptor._willChangeListeners: descriptor._changeListeners;\n try {\n dispatchOwnPropertyChange.dispatchEach(listeners, key, value, this);\n } finally {\n descriptor.isActive = false;\n }\n }\n};\nPropertyChanges.prototype.dispatchOwnPropertyChange.dispatchEach = dispatchEach;\n\nfunction dispatchEach(listeners, key, value, object) {\n if(listeners && listeners._current) {\n // copy snapshot of current listeners to active listeners\n var current,\n listener,\n i,\n countI,\n thisp,\n specificHandlerMethodName = listeners.specificHandlerMethodName,\n genericHandlerMethodName = listeners.genericHandlerMethodName,\n Ghost = ListenerGhost;\n\n if(Array.isArray(listeners._current)) {\n //removeGostListenersIfNeeded returns listeners.current or a new filtered one when conditions are met\n current = listeners.removeCurrentGostListenersIfNeeded();\n //We use a for to guarantee we won't dispatch to listeners that would be added after we started\n for(i=0, countI = current.length;i>> 0;\n\n // 3. If IsCallable(predicate) is false, throw a TypeError exception.\n if (typeof predicate !== 'function') {\n throw new TypeError('predicate must be a function');\n }\n\n // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.\n var thisArg = arguments[1];\n\n // 5. Let k be 0.\n var k = 0;\n\n // 6. Repeat, while k < len\n while (k < len) {\n // a. Let Pk be ! ToString(k).\n // b. Let kValue be ? Get(O, Pk).\n // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).\n // d. If testResult is true, return kValue.\n var kValue = o[k];\n if (predicate.call(thisArg, kValue, k, o)) {\n return kValue;\n }\n // e. Increase k by 1.\n k++;\n }\n });\n}\n\n// TODO remove in v6 (not present in v2)\nvar deprecatedWarnNonce = {};\nfunction deprecatedWarn(msg, notOnce) {\n if (\n typeof console !== 'undefined' &&\n typeof console.warn === 'function' &&\n (notOnce !== true && deprecatedWarnNonce.hasOwnProperty(msg) === false)\n ) {\n console.warn(msg);\n deprecatedWarnNonce[msg]++;\n }\n}\n\n// Save Array.prototype.find in order to support legacy and display warning.\n// TODO remove in v6 (not present in v2)\nvar ArrayFindPrototype = Object.getOwnPropertyDescriptor(Array.prototype, 'find').value;\ndefine(\"find\", function (value, equals, index) {\n if (\n typeof arguments[0] === 'function' &&\n this instanceof Array\n ) {\n return ArrayFindPrototype.apply(this, arguments);\n } else {\n deprecatedWarn('Array#find usage is deprecated please use Array#findValue');\n return this.findValue.apply(this, arguments);\n }\n});\n\ndefine(\"findValue\", function (value, equals, index) {\n if (index) {\n throw new Error(\"Array#findValue does not support third argument: index\");\n }\n equals = equals || this.contentEquals || Object.equals;\n for (var index = 0; index < this.length; index++) {\n if (index in this && equals(value, this[index])) {\n return index;\n }\n }\n return -1;\n});\n\n// TODO remove in v6 (not present in v2)\ndefine(\"findLast\", function (value, equals) {\n deprecatedWarn('Array#findLast function is deprecated please use Array#findLastValue instead.');\n return this.findLastValue.apply(this, arguments);\n});\n\ndefine(\"findLastValue\", function (value, equals) {\n equals = equals || this.contentEquals || Object.equals;\n var index = this.length;\n do {\n index--;\n if (index in this && equals(this[index], value)) {\n return index;\n }\n } while (index > 0);\n return -1;\n});\n\ndefine(\"swap\", function (start, length, plus) {\n var args, plusLength, i, j, returnValue;\n if (start > this.length) {\n this.length = start;\n }\n if (typeof plus !== \"undefined\") {\n args = [start, length];\n if (!Array.isArray(plus)) {\n plus = array_slice.call(plus);\n }\n i = 0;\n plusLength = plus.length;\n // 1000 is a magic number, presumed to be smaller than the remaining\n // stack length. For swaps this small, we take the fast path and just\n // use the underlying Array splice. We could measure the exact size of\n // the remaining stack using a try/catch around an unbounded recursive\n // function, but this would defeat the purpose of short-circuiting in\n // the common case.\n if (plusLength < 1000) {\n for (i; i < plusLength; i++) {\n args[i+2] = plus[i];\n }\n return array_splice.apply(this, args);\n } else {\n // Avoid maximum call stack error.\n // First delete the desired entries.\n returnValue = array_splice.apply(this, args);\n // Second batch in 1000s.\n for (i; i < plusLength;) {\n args = [start+i, 0];\n for (j = 2; j < 1002 && i < plusLength; j++, i++) {\n args[j] = plus[i];\n }\n array_splice.apply(this, args);\n }\n return returnValue;\n }\n // using call rather than apply to cut down on transient objects\n } else if (typeof length !== \"undefined\") {\n return array_splice.call(this, start, length);\n } else if (typeof start !== \"undefined\") {\n return array_splice.call(this, start);\n } else {\n return [];\n }\n});\n\ndefine(\"peek\", function () {\n return this[0];\n});\n\ndefine(\"poke\", function (value) {\n if (this.length > 0) {\n this[0] = value;\n }\n});\n\ndefine(\"peekBack\", function () {\n if (this.length > 0) {\n return this[this.length - 1];\n }\n});\n\ndefine(\"pokeBack\", function (value) {\n if (this.length > 0) {\n this[this.length - 1] = value;\n }\n});\n\ndefine(\"one\", function () {\n for (var i in this) {\n if (Object.owns(this, i)) {\n return this[i];\n }\n }\n});\n\nif (!Array.prototype.clear) {\n define(\"clear\", function () {\n this.length = 0;\n return this;\n });\n}\n\ndefine(\"compare\", function (that, compare) {\n compare = compare || Object.compare;\n var i;\n var length;\n var lhs;\n var rhs;\n var relative;\n\n if (this === that) {\n return 0;\n }\n\n if (!that || !Array.isArray(that)) {\n return GenericOrder.prototype.compare.call(this, that, compare);\n }\n\n length = (this.length < that.length) ? this.length : that.length;\n\n for (i = 0; i < length; i++) {\n if (i in this) {\n if (!(i in that)) {\n return -1;\n } else {\n lhs = this[i];\n rhs = that[i];\n relative = compare(lhs, rhs);\n if (relative) {\n return relative;\n }\n }\n } else if (i in that) {\n return 1;\n }\n }\n\n return this.length - that.length;\n});\n\ndefine(\"equals\", function (that, equals) {\n equals = equals || Object.equals;\n var i = 0;\n var length = this.length;\n var left;\n var right;\n\n if (this === that) {\n return true;\n }\n if (!that || !Array.isArray(that)) {\n return GenericOrder.prototype.equals.call(this, that);\n }\n\n if (length !== that.length) {\n return false;\n } else {\n for (; i < length; ++i) {\n if (i in this) {\n if (!(i in that)) {\n return false;\n }\n left = this[i];\n right = that[i];\n if (!equals(left, right)) {\n return false;\n }\n } else {\n if (i in that) {\n return false;\n }\n }\n }\n }\n return true;\n});\n\ndefine(\"clone\", function (depth, memo) {\n if (depth == null) {\n depth = Infinity;\n } else if (depth === 0) {\n return this;\n }\n memo = memo || new WeakMap();\n if (memo.has(this)) {\n return memo.get(this);\n }\n var clone = new Array(this.length);\n memo.set(this, clone);\n for (var i in this) {\n clone[i] = Object.clone(this[i], depth - 1, memo);\n };\n return clone;\n});\n\ndefine(\"iterate\", function (start, end) {\n return new ArrayIterator(this, start, end);\n});\n\nif(Array.prototype.spliceOne === void 0) {\n define(\"spliceOne\", function (index,itemToAdd) {\n var len=this.length;\n if (!len) { return }\n if(arguments.length === 1) {\n while (indexfunction () {}\n in its many colorful variations. It does nothing and returns\n undefined thus makes a suitable default in some circumstances.\n\n @function external:Function.noop\n*/\nFunction.noop = function () {\n};\n\n/**\n A utility to reduce unnecessary allocations of function (x) {return\n x} in its many colorful but ultimately wasteful parameter name\n variations.\n\n @function external:Function.identity\n @param {Any} any value\n @returns {Any} that value\n*/\nFunction.identity = function (value) {\n return value;\n};\n\n/**\n A utility for creating a comparator function for a particular aspect of a\n figurative class of objects.\n\n @function external:Function.by\n @param {Function} relation A function that accepts a value and returns a\n corresponding value to use as a representative when sorting that object.\n @param {Function} compare an alternate comparator for comparing the\n represented values. The default is Object.compare, which\n does a deep, type-sensitive, polymorphic comparison.\n @returns {Function} a comparator that has been annotated with\n by and compare properties so\n sorted can perform a transform that reduces the need to call\n by on each sorted object to just once.\n */\nFunction.by = function (by , compare) {\n compare = compare || Object.compare;\n by = by || Function.identity;\n var compareBy = function (a, b) {\n return compare(by(a), by(b));\n };\n compareBy.compare = compare;\n compareBy.by = by;\n return compareBy;\n};\n\n// TODO document\nFunction.get = function (key) {\n return function (object) {\n return Object.get(object, key);\n };\n};\n\n","\"use strict\";\n\nvar WeakMap = require(\"./weak-map\");\n\nrequire(\"./shim-function\");\n\nmodule.exports = Object;\n\n/*\n Based in part on extras from Motorola Mobility’s Montage\n Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved.\n 3-Clause BSD License\n https://github.com/motorola-mobility/montage/blob/master/LICENSE.md\n*/\n\n/**\n Defines extensions to intrinsic Object.\n @see [Object class]{@link external:Object}\n*/\n\n/**\n A utility object to avoid unnecessary allocations of an empty object\n {}. This object is frozen so it is safe to share.\n\n @object external:Object.empty\n*/\nObject.empty = Object.freeze(Object.create(null));\n\n/**\n Returns whether the given value is an object, as opposed to a value.\n Unboxed numbers, strings, true, false, undefined, and null are not\n objects. Arrays are objects.\n\n @function external:Object.isObject\n @param {Any} value\n @returns {Boolean} whether the given value is an object\n*/\nObject.isObject = function (object) {\n return Object(object) === object;\n};\n\n/**\n Returns the value of an any value, particularly objects that\n implement valueOf.\n\n

Note that, unlike the precedent of methods like\n Object.equals and Object.compare would suggest,\n this method is named Object.getValueOf instead of\n valueOf. This is a delicate issue, but the basis of this\n decision is that the JavaScript runtime would be far more likely to\n accidentally call this method with no arguments, assuming that it would\n return the value of Object itself in various situations,\n whereas Object.equals(Object, null) protects against this case\n by noting that Object owns the equals property\n and therefore does not delegate to it.\n\n @function external:Object.getValueOf\n @param {Any} value a value or object wrapping a value\n @returns {Any} the primitive value of that object, if one exists, or passes\n the value through\n*/\nObject.getValueOf = function (value) {\n if (value && typeof value.valueOf === \"function\") {\n value = value.valueOf();\n }\n return value;\n};\n\nvar hashMap = new WeakMap();\nObject.hash = function (object) {\n if (object && typeof object.hash === \"function\") {\n return \"\" + object.hash();\n } else if (Object(object) === object) {\n if (!hashMap.has(object)) {\n hashMap.set(object, Math.random().toString(36).slice(2));\n }\n return hashMap.get(object);\n } else {\n return \"\" + object;\n }\n};\n\n/**\n A shorthand for Object.prototype.hasOwnProperty.call(object,\n key). Returns whether the object owns a property for the given key.\n It does not consult the prototype chain and works for any string (including\n \"hasOwnProperty\") except \"__proto__\".\n\n @function external:Object.owns\n @param {Object} object\n @param {String} key\n @returns {Boolean} whether the object owns a property wfor the given key.\n*/\nvar owns = Object.prototype.hasOwnProperty;\nObject.owns = function (object, key) {\n return owns.call(object, key);\n};\n\n/**\n A utility that is like Object.owns but is also useful for finding\n properties on the prototype chain, provided that they do not refer to\n methods on the Object prototype. Works for all strings except \"__proto__\".\n\n

Alternately, you could use the \"in\" operator as long as the object\n descends from \"null\" instead of the Object.prototype, as with\n Object.create(null). However,\n Object.create(null) only works in fully compliant EcmaScript 5\n JavaScript engines and cannot be faithfully shimmed.\n\n

If the given object is an instance of a type that implements a method\n named \"has\", this function defers to the collection, so this method can be\n used to generically handle objects, arrays, or other collections. In that\n case, the domain of the key depends on the instance.\n\n @param {Object} object\n @param {String} key\n @returns {Boolean} whether the object, or any of its prototypes except\n Object.prototype\n @function external:Object.has\n*/\nObject.has = function (object, key) {\n if (typeof object !== \"object\") {\n throw new Error(\"Object.has can't accept non-object: \" + typeof object);\n }\n // forward to mapped collections that implement \"has\"\n if (object && typeof object.has === \"function\") {\n return object.has(key);\n // otherwise report whether the key is on the prototype chain,\n // as long as it is not one of the methods on object.prototype\n } else if (typeof key === \"string\") {\n return key in object && object[key] !== Object.prototype[key];\n } else {\n throw new Error(\"Key must be a string for Object.has on plain objects\");\n }\n};\n\n/**\n Gets the value for a corresponding key from an object.\n\n

Uses Object.has to determine whether there is a corresponding value for\n the given key. As such, Object.get is capable of retriving\n values from the prototype chain as long as they are not from the\n Object.prototype.\n\n

If there is no corresponding value, returns the given default, which may\n be undefined.\n\n

If the given object is an instance of a type that implements a method\n named \"get\", this function defers to the collection, so this method can be\n used to generically handle objects, arrays, or other collections. In that\n case, the domain of the key depends on the implementation. For a `Map`,\n for example, the key might be any object.\n\n @param {Object} object\n @param {String} key\n @param {Any} value a default to return, undefined if omitted\n @returns {Any} value for key, or default value\n @function external:Object.get\n*/\nObject.get = function (object, key, value) {\n if (typeof object !== \"object\") {\n throw new Error(\"Object.get can't accept non-object: \" + typeof object);\n }\n // forward to mapped collections that implement \"get\"\n if (object && typeof object.get === \"function\") {\n return object.get(key, value);\n } else if (Object.has(object, key)) {\n return object[key];\n } else {\n return value;\n }\n};\n\n/**\n Sets the value for a given key on an object.\n\n

If the given object is an instance of a type that implements a method\n named \"set\", this function defers to the collection, so this method can be\n used to generically handle objects, arrays, or other collections. As such,\n the key domain varies by the object type.\n\n @param {Object} object\n @param {String} key\n @param {Any} value\n @returns undefined\n @function external:Object.set\n*/\nObject.set = function (object, key, value) {\n if (object && typeof object.set === \"function\") {\n object.set(key, value);\n } else {\n object[key] = value;\n }\n};\n\nObject.addEach = function (target, source, overrides) {\n var overridesExistingProperty = arguments.length === 3 ? overrides : true;\n if (!source) {\n } else if (typeof source.forEach === \"function\" && !source.hasOwnProperty(\"forEach\")) {\n // copy map-alikes\n if (source.isMap === true) {\n source.forEach(function (value, key) {\n target[key] = value;\n });\n // iterate key value pairs of other iterables\n } else {\n source.forEach(function (pair) {\n target[pair[0]] = pair[1];\n });\n }\n } else if (typeof source.length === \"number\") {\n // arguments, strings\n for (var index = 0; index < source.length; index++) {\n target[index] = source[index];\n }\n } else {\n // copy other objects as map-alikes\n for(var keys = Object.keys(source), i = 0, key;(key = keys[i]); i++) {\n if(overridesExistingProperty || !Object.owns(target,key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n};\n\n\n/*\nvar defineEach = function defineEach(target, prototype) {\n // console.log(\"Map defineEach: \",Object.keys(prototype));\n var proto = Map.prototype;\n for (var name in prototype) {\n if(!proto.hasOwnProperty(name)) {\n Object.defineProperty(proto, name, {\n value: prototype[name],\n writable: writable,\n configurable: configurable,\n enumerable: enumerable\n });\n }\n }\n}\n*/\nObject.defineEach = function (target, source, overrides, configurable, enumerable, writable) {\n var overridesExistingProperty = arguments.length === 3 ? overrides : true;\n if (!source) {\n } else if (typeof source.forEach === \"function\" && !source.hasOwnProperty(\"forEach\")) {\n // copy map-alikes\n if (source.isMap === true) {\n source.forEach(function (value, key) {\n Object.defineProperty(target, key, {\n value: value,\n writable: writable,\n configurable: configurable,\n enumerable: enumerable\n });\n });\n // iterate key value pairs of other iterables\n } else {\n source.forEach(function (pair) {\n Object.defineProperty(target, pair[0], {\n value: pair[1],\n writable: writable,\n configurable: configurable,\n enumerable: enumerable\n });\n\n });\n }\n } else if (typeof source.length === \"number\") {\n // arguments, strings\n for (var index = 0; index < source.length; index++) {\n Object.defineProperty(target, index, {\n value: source[index],\n writable: writable,\n configurable: configurable,\n enumerable: enumerable\n });\n\n }\n } else {\n // copy other objects as map-alikes\n for(var keys = Object.keys(source), i = 0, key;(key = keys[i]); i++) {\n if(overridesExistingProperty || !Object.owns(target,key)) {\n Object.defineProperty(target, key, {\n value: source[key],\n writable: writable,\n configurable: configurable,\n enumerable: enumerable\n });\n\n }\n }\n }\n return target;\n};\n\n/**\n Iterates over the owned properties of an object.\n\n @function external:Object.forEach\n @param {Object} object an object to iterate.\n @param {Function} callback a function to call for every key and value\n pair in the object. Receives value, key,\n and object as arguments.\n @param {Object} thisp the this to pass through to the\n callback\n*/\nObject.forEach = function (object, callback, thisp) {\n\n var keys = Object.keys(object), i = 0, iKey;\n for(;(iKey = keys[i]);i++) {\n callback.call(thisp, object[iKey], iKey, object);\n }\n\n};\n\n/**\n Iterates over the owned properties of a map, constructing a new array of\n mapped values.\n\n @function external:Object.map\n @param {Object} object an object to iterate.\n @param {Function} callback a function to call for every key and value\n pair in the object. Receives value, key,\n and object as arguments.\n @param {Object} thisp the this to pass through to the\n callback\n @returns {Array} the respective values returned by the callback for each\n item in the object.\n*/\nObject.map = function (object, callback, thisp) {\n var keys = Object.keys(object), i = 0, result = [], iKey;\n for(;(iKey = keys[i]);i++) {\n result.push(callback.call(thisp, object[iKey], iKey, object));\n }\n return result;\n};\n\n/**\n Returns the values for owned properties of an object.\n\n @function external:Object.map\n @param {Object} object\n @returns {Array} the respective value for each owned property of the\n object.\n*/\nObject.values = function (object) {\n return Object.map(object, Function.identity);\n};\n\n// TODO inline document concat\nObject.concat = function () {\n var object = {};\n for (var i = 0; i < arguments.length; i++) {\n Object.addEach(object, arguments[i]);\n }\n return object;\n};\n\nObject.from = Object.concat;\n\n/**\n Returns whether two values are identical. Any value is identical to itself\n and only itself. This is much more restictive than equivalence and subtly\n different than strict equality, === because of edge cases\n including negative zero and NaN. Identity is useful for\n resolving collisions among keys in a mapping where the domain is any value.\n This method does not delgate to any method on an object and cannot be\n overridden.\n @see http://wiki.ecmascript.org/doku.php?id=harmony:egal\n @param {Any} this\n @param {Any} that\n @returns {Boolean} whether this and that are identical\n @function external:Object.is\n*/\nObject.is = function (x, y) {\n if (x === y) {\n // 0 === -0, but they are not identical\n return x !== 0 || 1 / x === 1 / y;\n }\n // NaN !== NaN, but they are identical.\n // NaNs are the only non-reflexive value, i.e., if x !== x,\n // then x is a NaN.\n // isNaN is broken: it converts its argument to number, so\n // isNaN(\"foo\") => true\n return x !== x && y !== y;\n};\n\n/**\n Performs a polymorphic, type-sensitive deep equivalence comparison of any\n two values.\n\n

As a basic principle, any value is equivalent to itself (as in\n identity), any boxed version of itself (as a new Number(10) is\n to 10), and any deep clone of itself.\n\n

Equivalence has the following properties:\n\n

    \n
  • polymorphic:\n If the given object is an instance of a type that implements a\n methods named \"equals\", this function defers to the method. So,\n this function can safely compare any values regardless of type,\n including undefined, null, numbers, strings, any pair of objects\n where either implements \"equals\", or object literals that may even\n contain an \"equals\" key.\n
  • type-sensitive:\n Incomparable types are not equal. No object is equivalent to any\n array. No string is equal to any other number.\n
  • deep:\n Collections with equivalent content are equivalent, recursively.\n
  • equivalence:\n Identical values and objects are equivalent, but so are collections\n that contain equivalent content. Whether order is important varies\n by type. For Arrays and lists, order is important. For Objects,\n maps, and sets, order is not important. Boxed objects are mutally\n equivalent with their unboxed values, by virtue of the standard\n valueOf method.\n
\n @param this\n @param that\n @returns {Boolean} whether the values are deeply equivalent\n @function external:Object.equals\n*/\nObject.equals = function (a, b, equals, memo) {\n equals = equals || Object.equals;\n //console.log(\"Object.equals: a:\",a, \"b:\",b, \"equals:\",equals);\n // unbox objects, but do not confuse object literals\n a = Object.getValueOf(a);\n b = Object.getValueOf(b);\n if (a === b)\n return true;\n if (Object.isObject(a)) {\n memo = memo || new WeakMap();\n if (memo.has(a)) {\n return true;\n }\n memo.set(a, true);\n }\n if (Object.isObject(a) && typeof a.equals === \"function\") {\n return a.equals(b, equals, memo);\n }\n // commutative\n if (Object.isObject(b) && typeof b.equals === \"function\") {\n return b.equals(a, equals, memo);\n }\n if (Object.isObject(a) && Object.isObject(b)) {\n if (Object.getPrototypeOf(a) === Object.prototype && Object.getPrototypeOf(b) === Object.prototype) {\n for (var name in a) {\n if (!equals(a[name], b[name], equals, memo)) {\n return false;\n }\n }\n for (var name in b) {\n if (!(name in a) || !equals(b[name], a[name], equals, memo)) {\n return false;\n }\n }\n return true;\n }\n }\n // NaN !== NaN, but they are equal.\n // NaNs are the only non-reflexive value, i.e., if x !== x,\n // then x is a NaN.\n // isNaN is broken: it converts its argument to number, so\n // isNaN(\"foo\") => true\n // We have established that a !== b, but if a !== a && b !== b, they are\n // both NaN.\n if (a !== a && b !== b)\n return true;\n if (!a || !b)\n return a === b;\n return false;\n};\n\n// Because a return value of 0 from a `compare` function may mean either\n// \"equals\" or \"is incomparable\", `equals` cannot be defined in terms of\n// `compare`. However, `compare` *can* be defined in terms of `equals` and\n// `lessThan`. Again however, more often it would be desirable to implement\n// all of the comparison functions in terms of compare rather than the other\n// way around.\n\n/**\n Determines the order in which any two objects should be sorted by returning\n a number that has an analogous relationship to zero as the left value to\n the right. That is, if the left is \"less than\" the right, the returned\n value will be \"less than\" zero, where \"less than\" may be any other\n transitive relationship.\n\n

Arrays are compared by the first diverging values, or by length.\n\n

Any two values that are incomparable return zero. As such,\n equals should not be implemented with compare\n since incomparability is indistinguishable from equality.\n\n

Sorts strings lexicographically. This is not suitable for any\n particular international setting. Different locales sort their phone books\n in very different ways, particularly regarding diacritics and ligatures.\n\n

If the given object is an instance of a type that implements a method\n named \"compare\", this function defers to the instance. The method does not\n need to be an owned property to distinguish it from an object literal since\n object literals are incomparable. Unlike Object however,\n Array implements compare.\n\n @param {Any} left\n @param {Any} right\n @returns {Number} a value having the same transitive relationship to zero\n as the left and right values.\n @function external:Object.compare\n*/\nObject.compare = function (a, b) {\n // unbox objects, but do not confuse object literals\n // mercifully handles the Date case\n a = Object.getValueOf(a);\n b = Object.getValueOf(b);\n if (a === b)\n return 0;\n var aType = typeof a;\n var bType = typeof b;\n if (aType === \"number\" && bType === \"number\")\n return a - b;\n if (aType === \"string\" && bType === \"string\")\n return a < b ? -Infinity : Infinity;\n // the possibility of equality elimiated above\n if (a && typeof a.compare === \"function\")\n return a.compare(b);\n // not commutative, the relationship is reversed\n if (b && typeof b.compare === \"function\")\n return -b.compare(a);\n return 0;\n};\n\n/**\n Creates a deep copy of any value. Values, being immutable, are\n returned without alternation. Forwards to clone on\n objects and arrays.\n\n @function external:Object.clone\n @param {Any} value a value to clone\n @param {Number} depth an optional traversal depth, defaults to infinity.\n A value of 0 means to make no clone and return the value\n directly.\n @param {Map} memo an optional memo of already visited objects to preserve\n reference cycles. The cloned object will have the exact same shape as the\n original, but no identical objects. Te map may be later used to associate\n all objects in the original object graph with their corresponding member of\n the cloned graph.\n @returns a copy of the value\n*/\nObject.clone = function (value, depth, memo) {\n value = Object.getValueOf(value);\n memo = memo || new WeakMap();\n if (depth === undefined) {\n depth = Infinity;\n } else if (depth === 0) {\n return value;\n }\n if (Object.isObject(value)) {\n if (!memo.has(value)) {\n if (value && typeof value.clone === \"function\") {\n memo.set(value, value.clone(depth, memo));\n } else {\n var prototype = Object.getPrototypeOf(value);\n if (prototype === null || prototype === Object.prototype) {\n var clone = Object.create(prototype);\n memo.set(value, clone);\n for (var key in value) {\n clone[key] = Object.clone(value[key], depth - 1, memo);\n }\n } else {\n throw new Error(\"Can't clone \" + value);\n }\n }\n }\n return memo.get(value);\n }\n return value;\n};\n\n/**\n Removes all properties owned by this object making the object suitable for\n reuse.\n\n @function external:Object.clear\n @returns this\n*/\nObject.clear = function (object) {\n if (object && typeof object.clear === \"function\") {\n object.clear();\n } else {\n var keys = Object.keys(object),\n i = keys.length;\n while (i) {\n i--;\n delete object[keys[i]];\n }\n }\n return object;\n};\n","\n/**\n accepts a string; returns the string with regex metacharacters escaped.\n the returned string can safely be used within a regex to match a literal\n string. escaped characters are [, ], {, }, (, ), -, *, +, ?, ., \\, ^, $,\n |, #, [comma], and whitespace.\n*/\nif (!RegExp.escape) {\n var special = /[-[\\]{}()*+?.\\\\^$|,#\\s]/g;\n RegExp.escape = function (string) {\n return string.replace(special, \"\\\\$&\");\n };\n}\n\n","\nvar Array = require(\"./shim-array\");\nvar Object = require(\"./shim-object\");\nvar Function = require(\"./shim-function\");\nvar RegExp = require(\"./shim-regexp\");\n\n","\"use strict\";\n\nmodule.exports = TreeLog;\n\nfunction TreeLog() {\n}\n\nTreeLog.ascii = {\n intersection: \"+\",\n through: \"-\",\n branchUp: \"+\",\n branchDown: \"+\",\n fromBelow: \".\",\n fromAbove: \"'\",\n fromBoth: \"+\",\n strafe: \"|\"\n};\n\nTreeLog.unicodeRound = {\n intersection: \"\\u254b\",\n through: \"\\u2501\",\n branchUp: \"\\u253b\",\n branchDown: \"\\u2533\",\n fromBelow: \"\\u256d\", // round corner\n fromAbove: \"\\u2570\", // round corner\n fromBoth: \"\\u2523\",\n strafe: \"\\u2503\"\n};\n\nTreeLog.unicodeSharp = {\n intersection: \"\\u254b\",\n through: \"\\u2501\",\n branchUp: \"\\u253b\",\n branchDown: \"\\u2533\",\n fromBelow: \"\\u250f\", // sharp corner\n fromAbove: \"\\u2517\", // sharp corner\n fromBoth: \"\\u2523\",\n strafe: \"\\u2503\"\n};\n\n","\nmodule.exports = (typeof WeakMap !== 'undefined') ? WeakMap : require(\"weak-map\");\n","module.exports = function (xs, fn) {\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n var x = fn(xs[i], i);\n if (isArray(x)) res.push.apply(res, x);\n else res.push(x);\n }\n return res;\n};\n\nvar isArray = Array.isArray || function (xs) {\n return Object.prototype.toString.call(xs) === '[object Array]';\n};\n","module.exports = realpath\nrealpath.realpath = realpath\nrealpath.sync = realpathSync\nrealpath.realpathSync = realpathSync\nrealpath.monkeypatch = monkeypatch\nrealpath.unmonkeypatch = unmonkeypatch\n\nvar fs = require('fs')\nvar origRealpath = fs.realpath\nvar origRealpathSync = fs.realpathSync\n\nvar version = process.version\nvar ok = /^v[0-5]\\./.test(version)\nvar old = require('./old.js')\n\nfunction newError (er) {\n return er && er.syscall === 'realpath' && (\n er.code === 'ELOOP' ||\n er.code === 'ENOMEM' ||\n er.code === 'ENAMETOOLONG'\n )\n}\n\nfunction realpath (p, cache, cb) {\n if (ok) {\n return origRealpath(p, cache, cb)\n }\n\n if (typeof cache === 'function') {\n cb = cache\n cache = null\n }\n origRealpath(p, cache, function (er, result) {\n if (newError(er)) {\n old.realpath(p, cache, cb)\n } else {\n cb(er, result)\n }\n })\n}\n\nfunction realpathSync (p, cache) {\n if (ok) {\n return origRealpathSync(p, cache)\n }\n\n try {\n return origRealpathSync(p, cache)\n } catch (er) {\n if (newError(er)) {\n return old.realpathSync(p, cache)\n } else {\n throw er\n }\n }\n}\n\nfunction monkeypatch () {\n fs.realpath = realpath\n fs.realpathSync = realpathSync\n}\n\nfunction unmonkeypatch () {\n fs.realpath = origRealpath\n fs.realpathSync = origRealpathSync\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar pathModule = require('path');\nvar isWindows = process.platform === 'win32';\nvar fs = require('fs');\n\n// JavaScript implementation of realpath, ported from node pre-v6\n\nvar DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);\n\nfunction rethrow() {\n // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and\n // is fairly slow to generate.\n var callback;\n if (DEBUG) {\n var backtrace = new Error;\n callback = debugCallback;\n } else\n callback = missingCallback;\n\n return callback;\n\n function debugCallback(err) {\n if (err) {\n backtrace.message = err.message;\n err = backtrace;\n missingCallback(err);\n }\n }\n\n function missingCallback(err) {\n if (err) {\n if (process.throwDeprecation)\n throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs\n else if (!process.noDeprecation) {\n var msg = 'fs: missing callback ' + (err.stack || err.message);\n if (process.traceDeprecation)\n console.trace(msg);\n else\n console.error(msg);\n }\n }\n }\n}\n\nfunction maybeCallback(cb) {\n return typeof cb === 'function' ? cb : rethrow();\n}\n\nvar normalize = pathModule.normalize;\n\n// Regexp that finds the next partion of a (partial) path\n// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']\nif (isWindows) {\n var nextPartRe = /(.*?)(?:[\\/\\\\]+|$)/g;\n} else {\n var nextPartRe = /(.*?)(?:[\\/]+|$)/g;\n}\n\n// Regex to find the device root, including trailing slash. E.g. 'c:\\\\'.\nif (isWindows) {\n var splitRootRe = /^(?:[a-zA-Z]:|[\\\\\\/]{2}[^\\\\\\/]+[\\\\\\/][^\\\\\\/]+)?[\\\\\\/]*/;\n} else {\n var splitRootRe = /^[\\/]*/;\n}\n\nexports.realpathSync = function realpathSync(p, cache) {\n // make p is absolute\n p = pathModule.resolve(p);\n\n if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {\n return cache[p];\n }\n\n var original = p,\n seenLinks = {},\n knownHard = {};\n\n // current character position in p\n var pos;\n // the partial path so far, including a trailing slash if any\n var current;\n // the partial path without a trailing slash (except when pointing at a root)\n var base;\n // the partial path scanned in the previous round, with slash\n var previous;\n\n start();\n\n function start() {\n // Skip over roots\n var m = splitRootRe.exec(p);\n pos = m[0].length;\n current = m[0];\n base = m[0];\n previous = '';\n\n // On windows, check that the root exists. On unix there is no need.\n if (isWindows && !knownHard[base]) {\n fs.lstatSync(base);\n knownHard[base] = true;\n }\n }\n\n // walk down the path, swapping out linked pathparts for their real\n // values\n // NB: p.length changes.\n while (pos < p.length) {\n // find the next part\n nextPartRe.lastIndex = pos;\n var result = nextPartRe.exec(p);\n previous = current;\n current += result[0];\n base = previous + result[1];\n pos = nextPartRe.lastIndex;\n\n // continue if not a symlink\n if (knownHard[base] || (cache && cache[base] === base)) {\n continue;\n }\n\n var resolvedLink;\n if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {\n // some known symbolic link. no need to stat again.\n resolvedLink = cache[base];\n } else {\n var stat = fs.lstatSync(base);\n if (!stat.isSymbolicLink()) {\n knownHard[base] = true;\n if (cache) cache[base] = base;\n continue;\n }\n\n // read the link if it wasn't read before\n // dev/ino always return 0 on windows, so skip the check.\n var linkTarget = null;\n if (!isWindows) {\n var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);\n if (seenLinks.hasOwnProperty(id)) {\n linkTarget = seenLinks[id];\n }\n }\n if (linkTarget === null) {\n fs.statSync(base);\n linkTarget = fs.readlinkSync(base);\n }\n resolvedLink = pathModule.resolve(previous, linkTarget);\n // track this, if given a cache.\n if (cache) cache[base] = resolvedLink;\n if (!isWindows) seenLinks[id] = linkTarget;\n }\n\n // resolve the link, then start over\n p = pathModule.resolve(resolvedLink, p.slice(pos));\n start();\n }\n\n if (cache) cache[original] = p;\n\n return p;\n};\n\n\nexports.realpath = function realpath(p, cache, cb) {\n if (typeof cb !== 'function') {\n cb = maybeCallback(cache);\n cache = null;\n }\n\n // make p is absolute\n p = pathModule.resolve(p);\n\n if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {\n return process.nextTick(cb.bind(null, null, cache[p]));\n }\n\n var original = p,\n seenLinks = {},\n knownHard = {};\n\n // current character position in p\n var pos;\n // the partial path so far, including a trailing slash if any\n var current;\n // the partial path without a trailing slash (except when pointing at a root)\n var base;\n // the partial path scanned in the previous round, with slash\n var previous;\n\n start();\n\n function start() {\n // Skip over roots\n var m = splitRootRe.exec(p);\n pos = m[0].length;\n current = m[0];\n base = m[0];\n previous = '';\n\n // On windows, check that the root exists. On unix there is no need.\n if (isWindows && !knownHard[base]) {\n fs.lstat(base, function(err) {\n if (err) return cb(err);\n knownHard[base] = true;\n LOOP();\n });\n } else {\n process.nextTick(LOOP);\n }\n }\n\n // walk down the path, swapping out linked pathparts for their real\n // values\n function LOOP() {\n // stop if scanned past end of path\n if (pos >= p.length) {\n if (cache) cache[original] = p;\n return cb(null, p);\n }\n\n // find the next part\n nextPartRe.lastIndex = pos;\n var result = nextPartRe.exec(p);\n previous = current;\n current += result[0];\n base = previous + result[1];\n pos = nextPartRe.lastIndex;\n\n // continue if not a symlink\n if (knownHard[base] || (cache && cache[base] === base)) {\n return process.nextTick(LOOP);\n }\n\n if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {\n // known symbolic link. no need to stat again.\n return gotResolvedLink(cache[base]);\n }\n\n return fs.lstat(base, gotStat);\n }\n\n function gotStat(err, stat) {\n if (err) return cb(err);\n\n // if not a symlink, skip to the next path part\n if (!stat.isSymbolicLink()) {\n knownHard[base] = true;\n if (cache) cache[base] = base;\n return process.nextTick(LOOP);\n }\n\n // stat & read the link if not read before\n // call gotTarget as soon as the link target is known\n // dev/ino always return 0 on windows, so skip the check.\n if (!isWindows) {\n var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);\n if (seenLinks.hasOwnProperty(id)) {\n return gotTarget(null, seenLinks[id], base);\n }\n }\n fs.stat(base, function(err) {\n if (err) return cb(err);\n\n fs.readlink(base, function(err, target) {\n if (!isWindows) seenLinks[id] = target;\n gotTarget(err, target);\n });\n });\n }\n\n function gotTarget(err, target, base) {\n if (err) return cb(err);\n\n var resolvedLink = pathModule.resolve(previous, target);\n if (cache) cache[base] = resolvedLink;\n gotResolvedLink(resolvedLink);\n }\n\n function gotResolvedLink(resolvedLink) {\n // resolve the link, then start over\n p = pathModule.resolve(resolvedLink, p.slice(pos));\n start();\n }\n};\n","exports.alphasort = alphasort\nexports.alphasorti = alphasorti\nexports.setopts = setopts\nexports.ownProp = ownProp\nexports.makeAbs = makeAbs\nexports.finish = finish\nexports.mark = mark\nexports.isIgnored = isIgnored\nexports.childrenIgnored = childrenIgnored\n\nfunction ownProp (obj, field) {\n return Object.prototype.hasOwnProperty.call(obj, field)\n}\n\nvar path = require(\"path\")\nvar minimatch = require(\"minimatch\")\nvar isAbsolute = require(\"path-is-absolute\")\nvar Minimatch = minimatch.Minimatch\n\nfunction alphasorti (a, b) {\n return a.toLowerCase().localeCompare(b.toLowerCase())\n}\n\nfunction alphasort (a, b) {\n return a.localeCompare(b)\n}\n\nfunction setupIgnores (self, options) {\n self.ignore = options.ignore || []\n\n if (!Array.isArray(self.ignore))\n self.ignore = [self.ignore]\n\n if (self.ignore.length) {\n self.ignore = self.ignore.map(ignoreMap)\n }\n}\n\n// ignore patterns are always in dot:true mode.\nfunction ignoreMap (pattern) {\n var gmatcher = null\n if (pattern.slice(-3) === '/**') {\n var gpattern = pattern.replace(/(\\/\\*\\*)+$/, '')\n gmatcher = new Minimatch(gpattern, { dot: true })\n }\n\n return {\n matcher: new Minimatch(pattern, { dot: true }),\n gmatcher: gmatcher\n }\n}\n\nfunction setopts (self, pattern, options) {\n if (!options)\n options = {}\n\n // base-matching: just use globstar for that.\n if (options.matchBase && -1 === pattern.indexOf(\"/\")) {\n if (options.noglobstar) {\n throw new Error(\"base matching requires globstar\")\n }\n pattern = \"**/\" + pattern\n }\n\n self.silent = !!options.silent\n self.pattern = pattern\n self.strict = options.strict !== false\n self.realpath = !!options.realpath\n self.realpathCache = options.realpathCache || Object.create(null)\n self.follow = !!options.follow\n self.dot = !!options.dot\n self.mark = !!options.mark\n self.nodir = !!options.nodir\n if (self.nodir)\n self.mark = true\n self.sync = !!options.sync\n self.nounique = !!options.nounique\n self.nonull = !!options.nonull\n self.nosort = !!options.nosort\n self.nocase = !!options.nocase\n self.stat = !!options.stat\n self.noprocess = !!options.noprocess\n self.absolute = !!options.absolute\n\n self.maxLength = options.maxLength || Infinity\n self.cache = options.cache || Object.create(null)\n self.statCache = options.statCache || Object.create(null)\n self.symlinks = options.symlinks || Object.create(null)\n\n setupIgnores(self, options)\n\n self.changedCwd = false\n var cwd = process.cwd()\n if (!ownProp(options, \"cwd\"))\n self.cwd = cwd\n else {\n self.cwd = path.resolve(options.cwd)\n self.changedCwd = self.cwd !== cwd\n }\n\n self.root = options.root || path.resolve(self.cwd, \"/\")\n self.root = path.resolve(self.root)\n if (process.platform === \"win32\")\n self.root = self.root.replace(/\\\\/g, \"/\")\n\n // TODO: is an absolute `cwd` supposed to be resolved against `root`?\n // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')\n self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd)\n if (process.platform === \"win32\")\n self.cwdAbs = self.cwdAbs.replace(/\\\\/g, \"/\")\n self.nomount = !!options.nomount\n\n // disable comments and negation in Minimatch.\n // Note that they are not supported in Glob itself anyway.\n options.nonegate = true\n options.nocomment = true\n\n self.minimatch = new Minimatch(pattern, options)\n self.options = self.minimatch.options\n}\n\nfunction finish (self) {\n var nou = self.nounique\n var all = nou ? [] : Object.create(null)\n\n for (var i = 0, l = self.matches.length; i < l; i ++) {\n var matches = self.matches[i]\n if (!matches || Object.keys(matches).length === 0) {\n if (self.nonull) {\n // do like the shell, and spit out the literal glob\n var literal = self.minimatch.globSet[i]\n if (nou)\n all.push(literal)\n else\n all[literal] = true\n }\n } else {\n // had matches\n var m = Object.keys(matches)\n if (nou)\n all.push.apply(all, m)\n else\n m.forEach(function (m) {\n all[m] = true\n })\n }\n }\n\n if (!nou)\n all = Object.keys(all)\n\n if (!self.nosort)\n all = all.sort(self.nocase ? alphasorti : alphasort)\n\n // at *some* point we statted all of these\n if (self.mark) {\n for (var i = 0; i < all.length; i++) {\n all[i] = self._mark(all[i])\n }\n if (self.nodir) {\n all = all.filter(function (e) {\n var notDir = !(/\\/$/.test(e))\n var c = self.cache[e] || self.cache[makeAbs(self, e)]\n if (notDir && c)\n notDir = c !== 'DIR' && !Array.isArray(c)\n return notDir\n })\n }\n }\n\n if (self.ignore.length)\n all = all.filter(function(m) {\n return !isIgnored(self, m)\n })\n\n self.found = all\n}\n\nfunction mark (self, p) {\n var abs = makeAbs(self, p)\n var c = self.cache[abs]\n var m = p\n if (c) {\n var isDir = c === 'DIR' || Array.isArray(c)\n var slash = p.slice(-1) === '/'\n\n if (isDir && !slash)\n m += '/'\n else if (!isDir && slash)\n m = m.slice(0, -1)\n\n if (m !== p) {\n var mabs = makeAbs(self, m)\n self.statCache[mabs] = self.statCache[abs]\n self.cache[mabs] = self.cache[abs]\n }\n }\n\n return m\n}\n\n// lotta situps...\nfunction makeAbs (self, f) {\n var abs = f\n if (f.charAt(0) === '/') {\n abs = path.join(self.root, f)\n } else if (isAbsolute(f) || f === '') {\n abs = f\n } else if (self.changedCwd) {\n abs = path.resolve(self.cwd, f)\n } else {\n abs = path.resolve(f)\n }\n\n if (process.platform === 'win32')\n abs = abs.replace(/\\\\/g, '/')\n\n return abs\n}\n\n\n// Return true, if pattern ends with globstar '**', for the accompanying parent directory.\n// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents\nfunction isIgnored (self, path) {\n if (!self.ignore.length)\n return false\n\n return self.ignore.some(function(item) {\n return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path))\n })\n}\n\nfunction childrenIgnored (self, path) {\n if (!self.ignore.length)\n return false\n\n return self.ignore.some(function(item) {\n return !!(item.gmatcher && item.gmatcher.match(path))\n })\n}\n","// Approach:\n//\n// 1. Get the minimatch set\n// 2. For each pattern in the set, PROCESS(pattern, false)\n// 3. Store matches per-set, then uniq them\n//\n// PROCESS(pattern, inGlobStar)\n// Get the first [n] items from pattern that are all strings\n// Join these together. This is PREFIX.\n// If there is no more remaining, then stat(PREFIX) and\n// add to matches if it succeeds. END.\n//\n// If inGlobStar and PREFIX is symlink and points to dir\n// set ENTRIES = []\n// else readdir(PREFIX) as ENTRIES\n// If fail, END\n//\n// with ENTRIES\n// If pattern[n] is GLOBSTAR\n// // handle the case where the globstar match is empty\n// // by pruning it out, and testing the resulting pattern\n// PROCESS(pattern[0..n] + pattern[n+1 .. $], false)\n// // handle other cases.\n// for ENTRY in ENTRIES (not dotfiles)\n// // attach globstar + tail onto the entry\n// // Mark that this entry is a globstar match\n// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)\n//\n// else // not globstar\n// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)\n// Test ENTRY against pattern[n]\n// If fails, continue\n// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])\n//\n// Caveat:\n// Cache all stats and readdirs results to minimize syscall. Since all\n// we ever care about is existence and directory-ness, we can just keep\n// `true` for files, and [children,...] for directories, or `false` for\n// things that don't exist.\n\nmodule.exports = glob\n\nvar fs = require('fs')\nvar rp = require('fs.realpath')\nvar minimatch = require('minimatch')\nvar Minimatch = minimatch.Minimatch\nvar inherits = require('inherits')\nvar EE = require('events').EventEmitter\nvar path = require('path')\nvar assert = require('assert')\nvar isAbsolute = require('path-is-absolute')\nvar globSync = require('./sync.js')\nvar common = require('./common.js')\nvar alphasort = common.alphasort\nvar alphasorti = common.alphasorti\nvar setopts = common.setopts\nvar ownProp = common.ownProp\nvar inflight = require('inflight')\nvar util = require('util')\nvar childrenIgnored = common.childrenIgnored\nvar isIgnored = common.isIgnored\n\nvar once = require('once')\n\nfunction glob (pattern, options, cb) {\n if (typeof options === 'function') cb = options, options = {}\n if (!options) options = {}\n\n if (options.sync) {\n if (cb)\n throw new TypeError('callback provided to sync glob')\n return globSync(pattern, options)\n }\n\n return new Glob(pattern, options, cb)\n}\n\nglob.sync = globSync\nvar GlobSync = glob.GlobSync = globSync.GlobSync\n\n// old api surface\nglob.glob = glob\n\nfunction extend (origin, add) {\n if (add === null || typeof add !== 'object') {\n return origin\n }\n\n var keys = Object.keys(add)\n var i = keys.length\n while (i--) {\n origin[keys[i]] = add[keys[i]]\n }\n return origin\n}\n\nglob.hasMagic = function (pattern, options_) {\n var options = extend({}, options_)\n options.noprocess = true\n\n var g = new Glob(pattern, options)\n var set = g.minimatch.set\n\n if (!pattern)\n return false\n\n if (set.length > 1)\n return true\n\n for (var j = 0; j < set[0].length; j++) {\n if (typeof set[0][j] !== 'string')\n return true\n }\n\n return false\n}\n\nglob.Glob = Glob\ninherits(Glob, EE)\nfunction Glob (pattern, options, cb) {\n if (typeof options === 'function') {\n cb = options\n options = null\n }\n\n if (options && options.sync) {\n if (cb)\n throw new TypeError('callback provided to sync glob')\n return new GlobSync(pattern, options)\n }\n\n if (!(this instanceof Glob))\n return new Glob(pattern, options, cb)\n\n setopts(this, pattern, options)\n this._didRealPath = false\n\n // process each pattern in the minimatch set\n var n = this.minimatch.set.length\n\n // The matches are stored as {: true,...} so that\n // duplicates are automagically pruned.\n // Later, we do an Object.keys() on these.\n // Keep them as a list so we can fill in when nonull is set.\n this.matches = new Array(n)\n\n if (typeof cb === 'function') {\n cb = once(cb)\n this.on('error', cb)\n this.on('end', function (matches) {\n cb(null, matches)\n })\n }\n\n var self = this\n this._processing = 0\n\n this._emitQueue = []\n this._processQueue = []\n this.paused = false\n\n if (this.noprocess)\n return this\n\n if (n === 0)\n return done()\n\n var sync = true\n for (var i = 0; i < n; i ++) {\n this._process(this.minimatch.set[i], i, false, done)\n }\n sync = false\n\n function done () {\n --self._processing\n if (self._processing <= 0) {\n if (sync) {\n process.nextTick(function () {\n self._finish()\n })\n } else {\n self._finish()\n }\n }\n }\n}\n\nGlob.prototype._finish = function () {\n assert(this instanceof Glob)\n if (this.aborted)\n return\n\n if (this.realpath && !this._didRealpath)\n return this._realpath()\n\n common.finish(this)\n this.emit('end', this.found)\n}\n\nGlob.prototype._realpath = function () {\n if (this._didRealpath)\n return\n\n this._didRealpath = true\n\n var n = this.matches.length\n if (n === 0)\n return this._finish()\n\n var self = this\n for (var i = 0; i < this.matches.length; i++)\n this._realpathSet(i, next)\n\n function next () {\n if (--n === 0)\n self._finish()\n }\n}\n\nGlob.prototype._realpathSet = function (index, cb) {\n var matchset = this.matches[index]\n if (!matchset)\n return cb()\n\n var found = Object.keys(matchset)\n var self = this\n var n = found.length\n\n if (n === 0)\n return cb()\n\n var set = this.matches[index] = Object.create(null)\n found.forEach(function (p, i) {\n // If there's a problem with the stat, then it means that\n // one or more of the links in the realpath couldn't be\n // resolved. just return the abs value in that case.\n p = self._makeAbs(p)\n rp.realpath(p, self.realpathCache, function (er, real) {\n if (!er)\n set[real] = true\n else if (er.syscall === 'stat')\n set[p] = true\n else\n self.emit('error', er) // srsly wtf right here\n\n if (--n === 0) {\n self.matches[index] = set\n cb()\n }\n })\n })\n}\n\nGlob.prototype._mark = function (p) {\n return common.mark(this, p)\n}\n\nGlob.prototype._makeAbs = function (f) {\n return common.makeAbs(this, f)\n}\n\nGlob.prototype.abort = function () {\n this.aborted = true\n this.emit('abort')\n}\n\nGlob.prototype.pause = function () {\n if (!this.paused) {\n this.paused = true\n this.emit('pause')\n }\n}\n\nGlob.prototype.resume = function () {\n if (this.paused) {\n this.emit('resume')\n this.paused = false\n if (this._emitQueue.length) {\n var eq = this._emitQueue.slice(0)\n this._emitQueue.length = 0\n for (var i = 0; i < eq.length; i ++) {\n var e = eq[i]\n this._emitMatch(e[0], e[1])\n }\n }\n if (this._processQueue.length) {\n var pq = this._processQueue.slice(0)\n this._processQueue.length = 0\n for (var i = 0; i < pq.length; i ++) {\n var p = pq[i]\n this._processing--\n this._process(p[0], p[1], p[2], p[3])\n }\n }\n }\n}\n\nGlob.prototype._process = function (pattern, index, inGlobStar, cb) {\n assert(this instanceof Glob)\n assert(typeof cb === 'function')\n\n if (this.aborted)\n return\n\n this._processing++\n if (this.paused) {\n this._processQueue.push([pattern, index, inGlobStar, cb])\n return\n }\n\n //console.error('PROCESS %d', this._processing, pattern)\n\n // Get the first [n] parts of pattern that are all strings.\n var n = 0\n while (typeof pattern[n] === 'string') {\n n ++\n }\n // now n is the index of the first one that is *not* a string.\n\n // see if there's anything else\n var prefix\n switch (n) {\n // if not, then this is rather simple\n case pattern.length:\n this._processSimple(pattern.join('/'), index, cb)\n return\n\n case 0:\n // pattern *starts* with some non-trivial item.\n // going to readdir(cwd), but not include the prefix in matches.\n prefix = null\n break\n\n default:\n // pattern has some string bits in the front.\n // whatever it starts with, whether that's 'absolute' like /foo/bar,\n // or 'relative' like '../baz'\n prefix = pattern.slice(0, n).join('/')\n break\n }\n\n var remain = pattern.slice(n)\n\n // get the list of entries.\n var read\n if (prefix === null)\n read = '.'\n else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {\n if (!prefix || !isAbsolute(prefix))\n prefix = '/' + prefix\n read = prefix\n } else\n read = prefix\n\n var abs = this._makeAbs(read)\n\n //if ignored, skip _processing\n if (childrenIgnored(this, read))\n return cb()\n\n var isGlobStar = remain[0] === minimatch.GLOBSTAR\n if (isGlobStar)\n this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb)\n else\n this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb)\n}\n\nGlob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {\n var self = this\n this._readdir(abs, inGlobStar, function (er, entries) {\n return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb)\n })\n}\n\nGlob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {\n\n // if the abs isn't a dir, then nothing can match!\n if (!entries)\n return cb()\n\n // It will only match dot entries if it starts with a dot, or if\n // dot is set. Stuff like @(.foo|.bar) isn't allowed.\n var pn = remain[0]\n var negate = !!this.minimatch.negate\n var rawGlob = pn._glob\n var dotOk = this.dot || rawGlob.charAt(0) === '.'\n\n var matchedEntries = []\n for (var i = 0; i < entries.length; i++) {\n var e = entries[i]\n if (e.charAt(0) !== '.' || dotOk) {\n var m\n if (negate && !prefix) {\n m = !e.match(pn)\n } else {\n m = e.match(pn)\n }\n if (m)\n matchedEntries.push(e)\n }\n }\n\n //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)\n\n var len = matchedEntries.length\n // If there are no matched entries, then nothing matches.\n if (len === 0)\n return cb()\n\n // if this is the last remaining pattern bit, then no need for\n // an additional stat *unless* the user has specified mark or\n // stat explicitly. We know they exist, since readdir returned\n // them.\n\n if (remain.length === 1 && !this.mark && !this.stat) {\n if (!this.matches[index])\n this.matches[index] = Object.create(null)\n\n for (var i = 0; i < len; i ++) {\n var e = matchedEntries[i]\n if (prefix) {\n if (prefix !== '/')\n e = prefix + '/' + e\n else\n e = prefix + e\n }\n\n if (e.charAt(0) === '/' && !this.nomount) {\n e = path.join(this.root, e)\n }\n this._emitMatch(index, e)\n }\n // This was the last one, and no stats were needed\n return cb()\n }\n\n // now test all matched entries as stand-ins for that part\n // of the pattern.\n remain.shift()\n for (var i = 0; i < len; i ++) {\n var e = matchedEntries[i]\n var newPattern\n if (prefix) {\n if (prefix !== '/')\n e = prefix + '/' + e\n else\n e = prefix + e\n }\n this._process([e].concat(remain), index, inGlobStar, cb)\n }\n cb()\n}\n\nGlob.prototype._emitMatch = function (index, e) {\n if (this.aborted)\n return\n\n if (isIgnored(this, e))\n return\n\n if (this.paused) {\n this._emitQueue.push([index, e])\n return\n }\n\n var abs = isAbsolute(e) ? e : this._makeAbs(e)\n\n if (this.mark)\n e = this._mark(e)\n\n if (this.absolute)\n e = abs\n\n if (this.matches[index][e])\n return\n\n if (this.nodir) {\n var c = this.cache[abs]\n if (c === 'DIR' || Array.isArray(c))\n return\n }\n\n this.matches[index][e] = true\n\n var st = this.statCache[abs]\n if (st)\n this.emit('stat', e, st)\n\n this.emit('match', e)\n}\n\nGlob.prototype._readdirInGlobStar = function (abs, cb) {\n if (this.aborted)\n return\n\n // follow all symlinked directories forever\n // just proceed as if this is a non-globstar situation\n if (this.follow)\n return this._readdir(abs, false, cb)\n\n var lstatkey = 'lstat\\0' + abs\n var self = this\n var lstatcb = inflight(lstatkey, lstatcb_)\n\n if (lstatcb)\n fs.lstat(abs, lstatcb)\n\n function lstatcb_ (er, lstat) {\n if (er && er.code === 'ENOENT')\n return cb()\n\n var isSym = lstat && lstat.isSymbolicLink()\n self.symlinks[abs] = isSym\n\n // If it's not a symlink or a dir, then it's definitely a regular file.\n // don't bother doing a readdir in that case.\n if (!isSym && lstat && !lstat.isDirectory()) {\n self.cache[abs] = 'FILE'\n cb()\n } else\n self._readdir(abs, false, cb)\n }\n}\n\nGlob.prototype._readdir = function (abs, inGlobStar, cb) {\n if (this.aborted)\n return\n\n cb = inflight('readdir\\0'+abs+'\\0'+inGlobStar, cb)\n if (!cb)\n return\n\n //console.error('RD %j %j', +inGlobStar, abs)\n if (inGlobStar && !ownProp(this.symlinks, abs))\n return this._readdirInGlobStar(abs, cb)\n\n if (ownProp(this.cache, abs)) {\n var c = this.cache[abs]\n if (!c || c === 'FILE')\n return cb()\n\n if (Array.isArray(c))\n return cb(null, c)\n }\n\n var self = this\n fs.readdir(abs, readdirCb(this, abs, cb))\n}\n\nfunction readdirCb (self, abs, cb) {\n return function (er, entries) {\n if (er)\n self._readdirError(abs, er, cb)\n else\n self._readdirEntries(abs, entries, cb)\n }\n}\n\nGlob.prototype._readdirEntries = function (abs, entries, cb) {\n if (this.aborted)\n return\n\n // if we haven't asked to stat everything, then just\n // assume that everything in there exists, so we can avoid\n // having to stat it a second time.\n if (!this.mark && !this.stat) {\n for (var i = 0; i < entries.length; i ++) {\n var e = entries[i]\n if (abs === '/')\n e = abs + e\n else\n e = abs + '/' + e\n this.cache[e] = true\n }\n }\n\n this.cache[abs] = entries\n return cb(null, entries)\n}\n\nGlob.prototype._readdirError = function (f, er, cb) {\n if (this.aborted)\n return\n\n // handle errors, and cache the information\n switch (er.code) {\n case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205\n case 'ENOTDIR': // totally normal. means it *does* exist.\n var abs = this._makeAbs(f)\n this.cache[abs] = 'FILE'\n if (abs === this.cwdAbs) {\n var error = new Error(er.code + ' invalid cwd ' + this.cwd)\n error.path = this.cwd\n error.code = er.code\n this.emit('error', error)\n this.abort()\n }\n break\n\n case 'ENOENT': // not terribly unusual\n case 'ELOOP':\n case 'ENAMETOOLONG':\n case 'UNKNOWN':\n this.cache[this._makeAbs(f)] = false\n break\n\n default: // some unusual error. Treat as failure.\n this.cache[this._makeAbs(f)] = false\n if (this.strict) {\n this.emit('error', er)\n // If the error is handled, then we abort\n // if not, we threw out of here\n this.abort()\n }\n if (!this.silent)\n console.error('glob error', er)\n break\n }\n\n return cb()\n}\n\nGlob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {\n var self = this\n this._readdir(abs, inGlobStar, function (er, entries) {\n self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb)\n })\n}\n\n\nGlob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {\n //console.error('pgs2', prefix, remain[0], entries)\n\n // no entries means not a dir, so it can never have matches\n // foo.txt/** doesn't match foo.txt\n if (!entries)\n return cb()\n\n // test without the globstar, and with every child both below\n // and replacing the globstar.\n var remainWithoutGlobStar = remain.slice(1)\n var gspref = prefix ? [ prefix ] : []\n var noGlobStar = gspref.concat(remainWithoutGlobStar)\n\n // the noGlobStar pattern exits the inGlobStar state\n this._process(noGlobStar, index, false, cb)\n\n var isSym = this.symlinks[abs]\n var len = entries.length\n\n // If it's a symlink, and we're in a globstar, then stop\n if (isSym && inGlobStar)\n return cb()\n\n for (var i = 0; i < len; i++) {\n var e = entries[i]\n if (e.charAt(0) === '.' && !this.dot)\n continue\n\n // these two cases enter the inGlobStar state\n var instead = gspref.concat(entries[i], remainWithoutGlobStar)\n this._process(instead, index, true, cb)\n\n var below = gspref.concat(entries[i], remain)\n this._process(below, index, true, cb)\n }\n\n cb()\n}\n\nGlob.prototype._processSimple = function (prefix, index, cb) {\n // XXX review this. Shouldn't it be doing the mounting etc\n // before doing stat? kinda weird?\n var self = this\n this._stat(prefix, function (er, exists) {\n self._processSimple2(prefix, index, er, exists, cb)\n })\n}\nGlob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {\n\n //console.error('ps2', prefix, exists)\n\n if (!this.matches[index])\n this.matches[index] = Object.create(null)\n\n // If it doesn't exist, then just mark the lack of results\n if (!exists)\n return cb()\n\n if (prefix && isAbsolute(prefix) && !this.nomount) {\n var trail = /[\\/\\\\]$/.test(prefix)\n if (prefix.charAt(0) === '/') {\n prefix = path.join(this.root, prefix)\n } else {\n prefix = path.resolve(this.root, prefix)\n if (trail)\n prefix += '/'\n }\n }\n\n if (process.platform === 'win32')\n prefix = prefix.replace(/\\\\/g, '/')\n\n // Mark this as a match\n this._emitMatch(index, prefix)\n cb()\n}\n\n// Returns either 'DIR', 'FILE', or false\nGlob.prototype._stat = function (f, cb) {\n var abs = this._makeAbs(f)\n var needDir = f.slice(-1) === '/'\n\n if (f.length > this.maxLength)\n return cb()\n\n if (!this.stat && ownProp(this.cache, abs)) {\n var c = this.cache[abs]\n\n if (Array.isArray(c))\n c = 'DIR'\n\n // It exists, but maybe not how we need it\n if (!needDir || c === 'DIR')\n return cb(null, c)\n\n if (needDir && c === 'FILE')\n return cb()\n\n // otherwise we have to stat, because maybe c=true\n // if we know it exists, but not what it is.\n }\n\n var exists\n var stat = this.statCache[abs]\n if (stat !== undefined) {\n if (stat === false)\n return cb(null, stat)\n else {\n var type = stat.isDirectory() ? 'DIR' : 'FILE'\n if (needDir && type === 'FILE')\n return cb()\n else\n return cb(null, type, stat)\n }\n }\n\n var self = this\n var statcb = inflight('stat\\0' + abs, lstatcb_)\n if (statcb)\n fs.lstat(abs, statcb)\n\n function lstatcb_ (er, lstat) {\n if (lstat && lstat.isSymbolicLink()) {\n // If it's a symlink, then treat it as the target, unless\n // the target does not exist, then treat it as a file.\n return fs.stat(abs, function (er, stat) {\n if (er)\n self._stat2(f, abs, null, lstat, cb)\n else\n self._stat2(f, abs, er, stat, cb)\n })\n } else {\n self._stat2(f, abs, er, lstat, cb)\n }\n }\n}\n\nGlob.prototype._stat2 = function (f, abs, er, stat, cb) {\n if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {\n this.statCache[abs] = false\n return cb()\n }\n\n var needDir = f.slice(-1) === '/'\n this.statCache[abs] = stat\n\n if (abs.slice(-1) === '/' && stat && !stat.isDirectory())\n return cb(null, false, stat)\n\n var c = true\n if (stat)\n c = stat.isDirectory() ? 'DIR' : 'FILE'\n this.cache[abs] = this.cache[abs] || c\n\n if (needDir && c === 'FILE')\n return cb()\n\n return cb(null, c, stat)\n}\n","module.exports = globSync\nglobSync.GlobSync = GlobSync\n\nvar fs = require('fs')\nvar rp = require('fs.realpath')\nvar minimatch = require('minimatch')\nvar Minimatch = minimatch.Minimatch\nvar Glob = require('./glob.js').Glob\nvar util = require('util')\nvar path = require('path')\nvar assert = require('assert')\nvar isAbsolute = require('path-is-absolute')\nvar common = require('./common.js')\nvar alphasort = common.alphasort\nvar alphasorti = common.alphasorti\nvar setopts = common.setopts\nvar ownProp = common.ownProp\nvar childrenIgnored = common.childrenIgnored\nvar isIgnored = common.isIgnored\n\nfunction globSync (pattern, options) {\n if (typeof options === 'function' || arguments.length === 3)\n throw new TypeError('callback provided to sync glob\\n'+\n 'See: https://github.com/isaacs/node-glob/issues/167')\n\n return new GlobSync(pattern, options).found\n}\n\nfunction GlobSync (pattern, options) {\n if (!pattern)\n throw new Error('must provide pattern')\n\n if (typeof options === 'function' || arguments.length === 3)\n throw new TypeError('callback provided to sync glob\\n'+\n 'See: https://github.com/isaacs/node-glob/issues/167')\n\n if (!(this instanceof GlobSync))\n return new GlobSync(pattern, options)\n\n setopts(this, pattern, options)\n\n if (this.noprocess)\n return this\n\n var n = this.minimatch.set.length\n this.matches = new Array(n)\n for (var i = 0; i < n; i ++) {\n this._process(this.minimatch.set[i], i, false)\n }\n this._finish()\n}\n\nGlobSync.prototype._finish = function () {\n assert(this instanceof GlobSync)\n if (this.realpath) {\n var self = this\n this.matches.forEach(function (matchset, index) {\n var set = self.matches[index] = Object.create(null)\n for (var p in matchset) {\n try {\n p = self._makeAbs(p)\n var real = rp.realpathSync(p, self.realpathCache)\n set[real] = true\n } catch (er) {\n if (er.syscall === 'stat')\n set[self._makeAbs(p)] = true\n else\n throw er\n }\n }\n })\n }\n common.finish(this)\n}\n\n\nGlobSync.prototype._process = function (pattern, index, inGlobStar) {\n assert(this instanceof GlobSync)\n\n // Get the first [n] parts of pattern that are all strings.\n var n = 0\n while (typeof pattern[n] === 'string') {\n n ++\n }\n // now n is the index of the first one that is *not* a string.\n\n // See if there's anything else\n var prefix\n switch (n) {\n // if not, then this is rather simple\n case pattern.length:\n this._processSimple(pattern.join('/'), index)\n return\n\n case 0:\n // pattern *starts* with some non-trivial item.\n // going to readdir(cwd), but not include the prefix in matches.\n prefix = null\n break\n\n default:\n // pattern has some string bits in the front.\n // whatever it starts with, whether that's 'absolute' like /foo/bar,\n // or 'relative' like '../baz'\n prefix = pattern.slice(0, n).join('/')\n break\n }\n\n var remain = pattern.slice(n)\n\n // get the list of entries.\n var read\n if (prefix === null)\n read = '.'\n else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {\n if (!prefix || !isAbsolute(prefix))\n prefix = '/' + prefix\n read = prefix\n } else\n read = prefix\n\n var abs = this._makeAbs(read)\n\n //if ignored, skip processing\n if (childrenIgnored(this, read))\n return\n\n var isGlobStar = remain[0] === minimatch.GLOBSTAR\n if (isGlobStar)\n this._processGlobStar(prefix, read, abs, remain, index, inGlobStar)\n else\n this._processReaddir(prefix, read, abs, remain, index, inGlobStar)\n}\n\n\nGlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {\n var entries = this._readdir(abs, inGlobStar)\n\n // if the abs isn't a dir, then nothing can match!\n if (!entries)\n return\n\n // It will only match dot entries if it starts with a dot, or if\n // dot is set. Stuff like @(.foo|.bar) isn't allowed.\n var pn = remain[0]\n var negate = !!this.minimatch.negate\n var rawGlob = pn._glob\n var dotOk = this.dot || rawGlob.charAt(0) === '.'\n\n var matchedEntries = []\n for (var i = 0; i < entries.length; i++) {\n var e = entries[i]\n if (e.charAt(0) !== '.' || dotOk) {\n var m\n if (negate && !prefix) {\n m = !e.match(pn)\n } else {\n m = e.match(pn)\n }\n if (m)\n matchedEntries.push(e)\n }\n }\n\n var len = matchedEntries.length\n // If there are no matched entries, then nothing matches.\n if (len === 0)\n return\n\n // if this is the last remaining pattern bit, then no need for\n // an additional stat *unless* the user has specified mark or\n // stat explicitly. We know they exist, since readdir returned\n // them.\n\n if (remain.length === 1 && !this.mark && !this.stat) {\n if (!this.matches[index])\n this.matches[index] = Object.create(null)\n\n for (var i = 0; i < len; i ++) {\n var e = matchedEntries[i]\n if (prefix) {\n if (prefix.slice(-1) !== '/')\n e = prefix + '/' + e\n else\n e = prefix + e\n }\n\n if (e.charAt(0) === '/' && !this.nomount) {\n e = path.join(this.root, e)\n }\n this._emitMatch(index, e)\n }\n // This was the last one, and no stats were needed\n return\n }\n\n // now test all matched entries as stand-ins for that part\n // of the pattern.\n remain.shift()\n for (var i = 0; i < len; i ++) {\n var e = matchedEntries[i]\n var newPattern\n if (prefix)\n newPattern = [prefix, e]\n else\n newPattern = [e]\n this._process(newPattern.concat(remain), index, inGlobStar)\n }\n}\n\n\nGlobSync.prototype._emitMatch = function (index, e) {\n if (isIgnored(this, e))\n return\n\n var abs = this._makeAbs(e)\n\n if (this.mark)\n e = this._mark(e)\n\n if (this.absolute) {\n e = abs\n }\n\n if (this.matches[index][e])\n return\n\n if (this.nodir) {\n var c = this.cache[abs]\n if (c === 'DIR' || Array.isArray(c))\n return\n }\n\n this.matches[index][e] = true\n\n if (this.stat)\n this._stat(e)\n}\n\n\nGlobSync.prototype._readdirInGlobStar = function (abs) {\n // follow all symlinked directories forever\n // just proceed as if this is a non-globstar situation\n if (this.follow)\n return this._readdir(abs, false)\n\n var entries\n var lstat\n var stat\n try {\n lstat = fs.lstatSync(abs)\n } catch (er) {\n if (er.code === 'ENOENT') {\n // lstat failed, doesn't exist\n return null\n }\n }\n\n var isSym = lstat && lstat.isSymbolicLink()\n this.symlinks[abs] = isSym\n\n // If it's not a symlink or a dir, then it's definitely a regular file.\n // don't bother doing a readdir in that case.\n if (!isSym && lstat && !lstat.isDirectory())\n this.cache[abs] = 'FILE'\n else\n entries = this._readdir(abs, false)\n\n return entries\n}\n\nGlobSync.prototype._readdir = function (abs, inGlobStar) {\n var entries\n\n if (inGlobStar && !ownProp(this.symlinks, abs))\n return this._readdirInGlobStar(abs)\n\n if (ownProp(this.cache, abs)) {\n var c = this.cache[abs]\n if (!c || c === 'FILE')\n return null\n\n if (Array.isArray(c))\n return c\n }\n\n try {\n return this._readdirEntries(abs, fs.readdirSync(abs))\n } catch (er) {\n this._readdirError(abs, er)\n return null\n }\n}\n\nGlobSync.prototype._readdirEntries = function (abs, entries) {\n // if we haven't asked to stat everything, then just\n // assume that everything in there exists, so we can avoid\n // having to stat it a second time.\n if (!this.mark && !this.stat) {\n for (var i = 0; i < entries.length; i ++) {\n var e = entries[i]\n if (abs === '/')\n e = abs + e\n else\n e = abs + '/' + e\n this.cache[e] = true\n }\n }\n\n this.cache[abs] = entries\n\n // mark and cache dir-ness\n return entries\n}\n\nGlobSync.prototype._readdirError = function (f, er) {\n // handle errors, and cache the information\n switch (er.code) {\n case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205\n case 'ENOTDIR': // totally normal. means it *does* exist.\n var abs = this._makeAbs(f)\n this.cache[abs] = 'FILE'\n if (abs === this.cwdAbs) {\n var error = new Error(er.code + ' invalid cwd ' + this.cwd)\n error.path = this.cwd\n error.code = er.code\n throw error\n }\n break\n\n case 'ENOENT': // not terribly unusual\n case 'ELOOP':\n case 'ENAMETOOLONG':\n case 'UNKNOWN':\n this.cache[this._makeAbs(f)] = false\n break\n\n default: // some unusual error. Treat as failure.\n this.cache[this._makeAbs(f)] = false\n if (this.strict)\n throw er\n if (!this.silent)\n console.error('glob error', er)\n break\n }\n}\n\nGlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {\n\n var entries = this._readdir(abs, inGlobStar)\n\n // no entries means not a dir, so it can never have matches\n // foo.txt/** doesn't match foo.txt\n if (!entries)\n return\n\n // test without the globstar, and with every child both below\n // and replacing the globstar.\n var remainWithoutGlobStar = remain.slice(1)\n var gspref = prefix ? [ prefix ] : []\n var noGlobStar = gspref.concat(remainWithoutGlobStar)\n\n // the noGlobStar pattern exits the inGlobStar state\n this._process(noGlobStar, index, false)\n\n var len = entries.length\n var isSym = this.symlinks[abs]\n\n // If it's a symlink, and we're in a globstar, then stop\n if (isSym && inGlobStar)\n return\n\n for (var i = 0; i < len; i++) {\n var e = entries[i]\n if (e.charAt(0) === '.' && !this.dot)\n continue\n\n // these two cases enter the inGlobStar state\n var instead = gspref.concat(entries[i], remainWithoutGlobStar)\n this._process(instead, index, true)\n\n var below = gspref.concat(entries[i], remain)\n this._process(below, index, true)\n }\n}\n\nGlobSync.prototype._processSimple = function (prefix, index) {\n // XXX review this. Shouldn't it be doing the mounting etc\n // before doing stat? kinda weird?\n var exists = this._stat(prefix)\n\n if (!this.matches[index])\n this.matches[index] = Object.create(null)\n\n // If it doesn't exist, then just mark the lack of results\n if (!exists)\n return\n\n if (prefix && isAbsolute(prefix) && !this.nomount) {\n var trail = /[\\/\\\\]$/.test(prefix)\n if (prefix.charAt(0) === '/') {\n prefix = path.join(this.root, prefix)\n } else {\n prefix = path.resolve(this.root, prefix)\n if (trail)\n prefix += '/'\n }\n }\n\n if (process.platform === 'win32')\n prefix = prefix.replace(/\\\\/g, '/')\n\n // Mark this as a match\n this._emitMatch(index, prefix)\n}\n\n// Returns either 'DIR', 'FILE', or false\nGlobSync.prototype._stat = function (f) {\n var abs = this._makeAbs(f)\n var needDir = f.slice(-1) === '/'\n\n if (f.length > this.maxLength)\n return false\n\n if (!this.stat && ownProp(this.cache, abs)) {\n var c = this.cache[abs]\n\n if (Array.isArray(c))\n c = 'DIR'\n\n // It exists, but maybe not how we need it\n if (!needDir || c === 'DIR')\n return c\n\n if (needDir && c === 'FILE')\n return false\n\n // otherwise we have to stat, because maybe c=true\n // if we know it exists, but not what it is.\n }\n\n var exists\n var stat = this.statCache[abs]\n if (!stat) {\n var lstat\n try {\n lstat = fs.lstatSync(abs)\n } catch (er) {\n if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {\n this.statCache[abs] = false\n return false\n }\n }\n\n if (lstat && lstat.isSymbolicLink()) {\n try {\n stat = fs.statSync(abs)\n } catch (er) {\n stat = lstat\n }\n } else {\n stat = lstat\n }\n }\n\n this.statCache[abs] = stat\n\n var c = true\n if (stat)\n c = stat.isDirectory() ? 'DIR' : 'FILE'\n\n this.cache[abs] = this.cache[abs] || c\n\n if (needDir && c === 'FILE')\n return false\n\n return c\n}\n\nGlobSync.prototype._mark = function (p) {\n return common.mark(this, p)\n}\n\nGlobSync.prototype._makeAbs = function (f) {\n return common.makeAbs(this, f)\n}\n","var wrappy = require('wrappy')\nvar reqs = Object.create(null)\nvar once = require('once')\n\nmodule.exports = wrappy(inflight)\n\nfunction inflight (key, cb) {\n if (reqs[key]) {\n reqs[key].push(cb)\n return null\n } else {\n reqs[key] = [cb]\n return makeres(key)\n }\n}\n\nfunction makeres (key) {\n return once(function RES () {\n var cbs = reqs[key]\n var len = cbs.length\n var args = slice(arguments)\n\n // XXX It's somewhat ambiguous whether a new callback added in this\n // pass should be queued for later execution if something in the\n // list of callbacks throws, or if it should just be discarded.\n // However, it's such an edge case that it hardly matters, and either\n // choice is likely as surprising as the other.\n // As it happens, we do go ahead and schedule it for later execution.\n try {\n for (var i = 0; i < len; i++) {\n cbs[i].apply(null, args)\n }\n } finally {\n if (cbs.length > len) {\n // added more in the interim.\n // de-zalgo, just in case, but don't call again.\n cbs.splice(0, len)\n process.nextTick(function () {\n RES.apply(null, args)\n })\n } else {\n delete reqs[key]\n }\n }\n })\n}\n\nfunction slice (args) {\n var length = args.length\n var array = []\n\n for (var i = 0; i < length; i++) array[i] = args[i]\n return array\n}\n","try {\n var util = require('util');\n /* istanbul ignore next */\n if (typeof util.inherits !== 'function') throw '';\n module.exports = util.inherits;\n} catch (e) {\n /* istanbul ignore next */\n module.exports = require('./inherits_browser.js');\n}\n","if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n })\n }\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n }\n}\n","module.exports = minimatch\nminimatch.Minimatch = Minimatch\n\nvar path = { sep: '/' }\ntry {\n path = require('path')\n} catch (er) {}\n\nvar GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}\nvar expand = require('brace-expansion')\n\nvar plTypes = {\n '!': { open: '(?:(?!(?:', close: '))[^/]*?)'},\n '?': { open: '(?:', close: ')?' },\n '+': { open: '(?:', close: ')+' },\n '*': { open: '(?:', close: ')*' },\n '@': { open: '(?:', close: ')' }\n}\n\n// any single thing other than /\n// don't need to escape / when using new RegExp()\nvar qmark = '[^/]'\n\n// * => any number of characters\nvar star = qmark + '*?'\n\n// ** when dots are allowed. Anything goes, except .. and .\n// not (^ or / followed by one or two dots followed by $ or /),\n// followed by anything, any number of times.\nvar twoStarDot = '(?:(?!(?:\\\\\\/|^)(?:\\\\.{1,2})($|\\\\\\/)).)*?'\n\n// not a ^ or / followed by a dot,\n// followed by anything, any number of times.\nvar twoStarNoDot = '(?:(?!(?:\\\\\\/|^)\\\\.).)*?'\n\n// characters that need to be escaped in RegExp.\nvar reSpecials = charSet('().*{}+?[]^$\\\\!')\n\n// \"abc\" -> { a:true, b:true, c:true }\nfunction charSet (s) {\n return s.split('').reduce(function (set, c) {\n set[c] = true\n return set\n }, {})\n}\n\n// normalizes slashes.\nvar slashSplit = /\\/+/\n\nminimatch.filter = filter\nfunction filter (pattern, options) {\n options = options || {}\n return function (p, i, list) {\n return minimatch(p, pattern, options)\n }\n}\n\nfunction ext (a, b) {\n a = a || {}\n b = b || {}\n var t = {}\n Object.keys(b).forEach(function (k) {\n t[k] = b[k]\n })\n Object.keys(a).forEach(function (k) {\n t[k] = a[k]\n })\n return t\n}\n\nminimatch.defaults = function (def) {\n if (!def || !Object.keys(def).length) return minimatch\n\n var orig = minimatch\n\n var m = function minimatch (p, pattern, options) {\n return orig.minimatch(p, pattern, ext(def, options))\n }\n\n m.Minimatch = function Minimatch (pattern, options) {\n return new orig.Minimatch(pattern, ext(def, options))\n }\n\n return m\n}\n\nMinimatch.defaults = function (def) {\n if (!def || !Object.keys(def).length) return Minimatch\n return minimatch.defaults(def).Minimatch\n}\n\nfunction minimatch (p, pattern, options) {\n if (typeof pattern !== 'string') {\n throw new TypeError('glob pattern string required')\n }\n\n if (!options) options = {}\n\n // shortcut: comments match nothing.\n if (!options.nocomment && pattern.charAt(0) === '#') {\n return false\n }\n\n // \"\" only matches \"\"\n if (pattern.trim() === '') return p === ''\n\n return new Minimatch(pattern, options).match(p)\n}\n\nfunction Minimatch (pattern, options) {\n if (!(this instanceof Minimatch)) {\n return new Minimatch(pattern, options)\n }\n\n if (typeof pattern !== 'string') {\n throw new TypeError('glob pattern string required')\n }\n\n if (!options) options = {}\n pattern = pattern.trim()\n\n // windows support: need to use /, not \\\n if (path.sep !== '/') {\n pattern = pattern.split(path.sep).join('/')\n }\n\n this.options = options\n this.set = []\n this.pattern = pattern\n this.regexp = null\n this.negate = false\n this.comment = false\n this.empty = false\n\n // make the set of regexps etc.\n this.make()\n}\n\nMinimatch.prototype.debug = function () {}\n\nMinimatch.prototype.make = make\nfunction make () {\n // don't do it more than once.\n if (this._made) return\n\n var pattern = this.pattern\n var options = this.options\n\n // empty patterns and comments match nothing.\n if (!options.nocomment && pattern.charAt(0) === '#') {\n this.comment = true\n return\n }\n if (!pattern) {\n this.empty = true\n return\n }\n\n // step 1: figure out negation, etc.\n this.parseNegate()\n\n // step 2: expand braces\n var set = this.globSet = this.braceExpand()\n\n if (options.debug) this.debug = console.error\n\n this.debug(this.pattern, set)\n\n // step 3: now we have a set, so turn each one into a series of path-portion\n // matching patterns.\n // These will be regexps, except in the case of \"**\", which is\n // set to the GLOBSTAR object for globstar behavior,\n // and will not contain any / characters\n set = this.globParts = set.map(function (s) {\n return s.split(slashSplit)\n })\n\n this.debug(this.pattern, set)\n\n // glob --> regexps\n set = set.map(function (s, si, set) {\n return s.map(this.parse, this)\n }, this)\n\n this.debug(this.pattern, set)\n\n // filter out everything that didn't compile properly.\n set = set.filter(function (s) {\n return s.indexOf(false) === -1\n })\n\n this.debug(this.pattern, set)\n\n this.set = set\n}\n\nMinimatch.prototype.parseNegate = parseNegate\nfunction parseNegate () {\n var pattern = this.pattern\n var negate = false\n var options = this.options\n var negateOffset = 0\n\n if (options.nonegate) return\n\n for (var i = 0, l = pattern.length\n ; i < l && pattern.charAt(i) === '!'\n ; i++) {\n negate = !negate\n negateOffset++\n }\n\n if (negateOffset) this.pattern = pattern.substr(negateOffset)\n this.negate = negate\n}\n\n// Brace expansion:\n// a{b,c}d -> abd acd\n// a{b,}c -> abc ac\n// a{0..3}d -> a0d a1d a2d a3d\n// a{b,c{d,e}f}g -> abg acdfg acefg\n// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg\n//\n// Invalid sets are not expanded.\n// a{2..}b -> a{2..}b\n// a{b}c -> a{b}c\nminimatch.braceExpand = function (pattern, options) {\n return braceExpand(pattern, options)\n}\n\nMinimatch.prototype.braceExpand = braceExpand\n\nfunction braceExpand (pattern, options) {\n if (!options) {\n if (this instanceof Minimatch) {\n options = this.options\n } else {\n options = {}\n }\n }\n\n pattern = typeof pattern === 'undefined'\n ? this.pattern : pattern\n\n if (typeof pattern === 'undefined') {\n throw new TypeError('undefined pattern')\n }\n\n if (options.nobrace ||\n !pattern.match(/\\{.*\\}/)) {\n // shortcut. no need to expand.\n return [pattern]\n }\n\n return expand(pattern)\n}\n\n// parse a component of the expanded set.\n// At this point, no pattern may contain \"/\" in it\n// so we're going to return a 2d array, where each entry is the full\n// pattern, split on '/', and then turned into a regular expression.\n// A regexp is made at the end which joins each array with an\n// escaped /, and another full one which joins each regexp with |.\n//\n// Following the lead of Bash 4.1, note that \"**\" only has special meaning\n// when it is the *only* thing in a path portion. Otherwise, any series\n// of * is equivalent to a single *. Globstar behavior is enabled by\n// default, and can be disabled by setting options.noglobstar.\nMinimatch.prototype.parse = parse\nvar SUBPARSE = {}\nfunction parse (pattern, isSub) {\n if (pattern.length > 1024 * 64) {\n throw new TypeError('pattern is too long')\n }\n\n var options = this.options\n\n // shortcuts\n if (!options.noglobstar && pattern === '**') return GLOBSTAR\n if (pattern === '') return ''\n\n var re = ''\n var hasMagic = !!options.nocase\n var escaping = false\n // ? => one single character\n var patternListStack = []\n var negativeLists = []\n var stateChar\n var inClass = false\n var reClassStart = -1\n var classStart = -1\n // . and .. never match anything that doesn't start with .,\n // even when options.dot is set.\n var patternStart = pattern.charAt(0) === '.' ? '' // anything\n // not (start or / followed by . or .. followed by / or end)\n : options.dot ? '(?!(?:^|\\\\\\/)\\\\.{1,2}(?:$|\\\\\\/))'\n : '(?!\\\\.)'\n var self = this\n\n function clearStateChar () {\n if (stateChar) {\n // we had some state-tracking character\n // that wasn't consumed by this pass.\n switch (stateChar) {\n case '*':\n re += star\n hasMagic = true\n break\n case '?':\n re += qmark\n hasMagic = true\n break\n default:\n re += '\\\\' + stateChar\n break\n }\n self.debug('clearStateChar %j %j', stateChar, re)\n stateChar = false\n }\n }\n\n for (var i = 0, len = pattern.length, c\n ; (i < len) && (c = pattern.charAt(i))\n ; i++) {\n this.debug('%s\\t%s %s %j', pattern, i, re, c)\n\n // skip over any that are escaped.\n if (escaping && reSpecials[c]) {\n re += '\\\\' + c\n escaping = false\n continue\n }\n\n switch (c) {\n case '/':\n // completely not allowed, even escaped.\n // Should already be path-split by now.\n return false\n\n case '\\\\':\n clearStateChar()\n escaping = true\n continue\n\n // the various stateChar values\n // for the \"extglob\" stuff.\n case '?':\n case '*':\n case '+':\n case '@':\n case '!':\n this.debug('%s\\t%s %s %j <-- stateChar', pattern, i, re, c)\n\n // all of those are literals inside a class, except that\n // the glob [!a] means [^a] in regexp\n if (inClass) {\n this.debug(' in class')\n if (c === '!' && i === classStart + 1) c = '^'\n re += c\n continue\n }\n\n // if we already have a stateChar, then it means\n // that there was something like ** or +? in there.\n // Handle the stateChar, then proceed with this one.\n self.debug('call clearStateChar %j', stateChar)\n clearStateChar()\n stateChar = c\n // if extglob is disabled, then +(asdf|foo) isn't a thing.\n // just clear the statechar *now*, rather than even diving into\n // the patternList stuff.\n if (options.noext) clearStateChar()\n continue\n\n case '(':\n if (inClass) {\n re += '('\n continue\n }\n\n if (!stateChar) {\n re += '\\\\('\n continue\n }\n\n patternListStack.push({\n type: stateChar,\n start: i - 1,\n reStart: re.length,\n open: plTypes[stateChar].open,\n close: plTypes[stateChar].close\n })\n // negation is (?:(?!js)[^/]*)\n re += stateChar === '!' ? '(?:(?!(?:' : '(?:'\n this.debug('plType %j %j', stateChar, re)\n stateChar = false\n continue\n\n case ')':\n if (inClass || !patternListStack.length) {\n re += '\\\\)'\n continue\n }\n\n clearStateChar()\n hasMagic = true\n var pl = patternListStack.pop()\n // negation is (?:(?!js)[^/]*)\n // The others are (?:)\n re += pl.close\n if (pl.type === '!') {\n negativeLists.push(pl)\n }\n pl.reEnd = re.length\n continue\n\n case '|':\n if (inClass || !patternListStack.length || escaping) {\n re += '\\\\|'\n escaping = false\n continue\n }\n\n clearStateChar()\n re += '|'\n continue\n\n // these are mostly the same in regexp and glob\n case '[':\n // swallow any state-tracking char before the [\n clearStateChar()\n\n if (inClass) {\n re += '\\\\' + c\n continue\n }\n\n inClass = true\n classStart = i\n reClassStart = re.length\n re += c\n continue\n\n case ']':\n // a right bracket shall lose its special\n // meaning and represent itself in\n // a bracket expression if it occurs\n // first in the list. -- POSIX.2 2.8.3.2\n if (i === classStart + 1 || !inClass) {\n re += '\\\\' + c\n escaping = false\n continue\n }\n\n // handle the case where we left a class open.\n // \"[z-a]\" is valid, equivalent to \"\\[z-a\\]\"\n if (inClass) {\n // split where the last [ was, make sure we don't have\n // an invalid re. if so, re-walk the contents of the\n // would-be class to re-translate any characters that\n // were passed through as-is\n // TODO: It would probably be faster to determine this\n // without a try/catch and a new RegExp, but it's tricky\n // to do safely. For now, this is safe and works.\n var cs = pattern.substring(classStart + 1, i)\n try {\n RegExp('[' + cs + ']')\n } catch (er) {\n // not a valid class!\n var sp = this.parse(cs, SUBPARSE)\n re = re.substr(0, reClassStart) + '\\\\[' + sp[0] + '\\\\]'\n hasMagic = hasMagic || sp[1]\n inClass = false\n continue\n }\n }\n\n // finish up the class.\n hasMagic = true\n inClass = false\n re += c\n continue\n\n default:\n // swallow any state char that wasn't consumed\n clearStateChar()\n\n if (escaping) {\n // no need\n escaping = false\n } else if (reSpecials[c]\n && !(c === '^' && inClass)) {\n re += '\\\\'\n }\n\n re += c\n\n } // switch\n } // for\n\n // handle the case where we left a class open.\n // \"[abc\" is valid, equivalent to \"\\[abc\"\n if (inClass) {\n // split where the last [ was, and escape it\n // this is a huge pita. We now have to re-walk\n // the contents of the would-be class to re-translate\n // any characters that were passed through as-is\n cs = pattern.substr(classStart + 1)\n sp = this.parse(cs, SUBPARSE)\n re = re.substr(0, reClassStart) + '\\\\[' + sp[0]\n hasMagic = hasMagic || sp[1]\n }\n\n // handle the case where we had a +( thing at the *end*\n // of the pattern.\n // each pattern list stack adds 3 chars, and we need to go through\n // and escape any | chars that were passed through as-is for the regexp.\n // Go through and escape them, taking care not to double-escape any\n // | chars that were already escaped.\n for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {\n var tail = re.slice(pl.reStart + pl.open.length)\n this.debug('setting tail', re, pl)\n // maybe some even number of \\, then maybe 1 \\, followed by a |\n tail = tail.replace(/((?:\\\\{2}){0,64})(\\\\?)\\|/g, function (_, $1, $2) {\n if (!$2) {\n // the | isn't already escaped, so escape it.\n $2 = '\\\\'\n }\n\n // need to escape all those slashes *again*, without escaping the\n // one that we need for escaping the | character. As it works out,\n // escaping an even number of slashes can be done by simply repeating\n // it exactly after itself. That's why this trick works.\n //\n // I am sorry that you have to see this.\n return $1 + $1 + $2 + '|'\n })\n\n this.debug('tail=%j\\n %s', tail, tail, pl, re)\n var t = pl.type === '*' ? star\n : pl.type === '?' ? qmark\n : '\\\\' + pl.type\n\n hasMagic = true\n re = re.slice(0, pl.reStart) + t + '\\\\(' + tail\n }\n\n // handle trailing things that only matter at the very end.\n clearStateChar()\n if (escaping) {\n // trailing \\\\\n re += '\\\\\\\\'\n }\n\n // only need to apply the nodot start if the re starts with\n // something that could conceivably capture a dot\n var addPatternStart = false\n switch (re.charAt(0)) {\n case '.':\n case '[':\n case '(': addPatternStart = true\n }\n\n // Hack to work around lack of negative lookbehind in JS\n // A pattern like: *.!(x).!(y|z) needs to ensure that a name\n // like 'a.xyz.yz' doesn't match. So, the first negative\n // lookahead, has to look ALL the way ahead, to the end of\n // the pattern.\n for (var n = negativeLists.length - 1; n > -1; n--) {\n var nl = negativeLists[n]\n\n var nlBefore = re.slice(0, nl.reStart)\n var nlFirst = re.slice(nl.reStart, nl.reEnd - 8)\n var nlLast = re.slice(nl.reEnd - 8, nl.reEnd)\n var nlAfter = re.slice(nl.reEnd)\n\n nlLast += nlAfter\n\n // Handle nested stuff like *(*.js|!(*.json)), where open parens\n // mean that we should *not* include the ) in the bit that is considered\n // \"after\" the negated section.\n var openParensBefore = nlBefore.split('(').length - 1\n var cleanAfter = nlAfter\n for (i = 0; i < openParensBefore; i++) {\n cleanAfter = cleanAfter.replace(/\\)[+*?]?/, '')\n }\n nlAfter = cleanAfter\n\n var dollar = ''\n if (nlAfter === '' && isSub !== SUBPARSE) {\n dollar = '$'\n }\n var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast\n re = newRe\n }\n\n // if the re is not \"\" at this point, then we need to make sure\n // it doesn't match against an empty path part.\n // Otherwise a/* will match a/, which it should not.\n if (re !== '' && hasMagic) {\n re = '(?=.)' + re\n }\n\n if (addPatternStart) {\n re = patternStart + re\n }\n\n // parsing just a piece of a larger pattern.\n if (isSub === SUBPARSE) {\n return [re, hasMagic]\n }\n\n // skip the regexp for non-magical patterns\n // unescape anything in it, though, so that it'll be\n // an exact match against a file etc.\n if (!hasMagic) {\n return globUnescape(pattern)\n }\n\n var flags = options.nocase ? 'i' : ''\n try {\n var regExp = new RegExp('^' + re + '$', flags)\n } catch (er) {\n // If it was an invalid regular expression, then it can't match\n // anything. This trick looks for a character after the end of\n // the string, which is of course impossible, except in multi-line\n // mode, but it's not a /m regex.\n return new RegExp('$.')\n }\n\n regExp._glob = pattern\n regExp._src = re\n\n return regExp\n}\n\nminimatch.makeRe = function (pattern, options) {\n return new Minimatch(pattern, options || {}).makeRe()\n}\n\nMinimatch.prototype.makeRe = makeRe\nfunction makeRe () {\n if (this.regexp || this.regexp === false) return this.regexp\n\n // at this point, this.set is a 2d array of partial\n // pattern strings, or \"**\".\n //\n // It's better to use .match(). This function shouldn't\n // be used, really, but it's pretty convenient sometimes,\n // when you just want to work with a regex.\n var set = this.set\n\n if (!set.length) {\n this.regexp = false\n return this.regexp\n }\n var options = this.options\n\n var twoStar = options.noglobstar ? star\n : options.dot ? twoStarDot\n : twoStarNoDot\n var flags = options.nocase ? 'i' : ''\n\n var re = set.map(function (pattern) {\n return pattern.map(function (p) {\n return (p === GLOBSTAR) ? twoStar\n : (typeof p === 'string') ? regExpEscape(p)\n : p._src\n }).join('\\\\\\/')\n }).join('|')\n\n // must match entire pattern\n // ending in a * or ** will make it less strict.\n re = '^(?:' + re + ')$'\n\n // can match anything, as long as it's not this.\n if (this.negate) re = '^(?!' + re + ').*$'\n\n try {\n this.regexp = new RegExp(re, flags)\n } catch (ex) {\n this.regexp = false\n }\n return this.regexp\n}\n\nminimatch.match = function (list, pattern, options) {\n options = options || {}\n var mm = new Minimatch(pattern, options)\n list = list.filter(function (f) {\n return mm.match(f)\n })\n if (mm.options.nonull && !list.length) {\n list.push(pattern)\n }\n return list\n}\n\nMinimatch.prototype.match = match\nfunction match (f, partial) {\n this.debug('match', f, this.pattern)\n // short-circuit in the case of busted things.\n // comments, etc.\n if (this.comment) return false\n if (this.empty) return f === ''\n\n if (f === '/' && partial) return true\n\n var options = this.options\n\n // windows: need to use /, not \\\n if (path.sep !== '/') {\n f = f.split(path.sep).join('/')\n }\n\n // treat the test path as a set of pathparts.\n f = f.split(slashSplit)\n this.debug(this.pattern, 'split', f)\n\n // just ONE of the pattern sets in this.set needs to match\n // in order for it to be valid. If negating, then just one\n // match means that we have failed.\n // Either way, return on the first hit.\n\n var set = this.set\n this.debug(this.pattern, 'set', set)\n\n // Find the basename of the path by looking for the last non-empty segment\n var filename\n var i\n for (i = f.length - 1; i >= 0; i--) {\n filename = f[i]\n if (filename) break\n }\n\n for (i = 0; i < set.length; i++) {\n var pattern = set[i]\n var file = f\n if (options.matchBase && pattern.length === 1) {\n file = [filename]\n }\n var hit = this.matchOne(file, pattern, partial)\n if (hit) {\n if (options.flipNegate) return true\n return !this.negate\n }\n }\n\n // didn't get any hits. this is success if it's a negative\n // pattern, failure otherwise.\n if (options.flipNegate) return false\n return this.negate\n}\n\n// set partial to true to test if, for example,\n// \"/a/b\" matches the start of \"/*/b/*/d\"\n// Partial means, if you run out of file before you run\n// out of pattern, then that's fine, as long as all\n// the parts match.\nMinimatch.prototype.matchOne = function (file, pattern, partial) {\n var options = this.options\n\n this.debug('matchOne',\n { 'this': this, file: file, pattern: pattern })\n\n this.debug('matchOne', file.length, pattern.length)\n\n for (var fi = 0,\n pi = 0,\n fl = file.length,\n pl = pattern.length\n ; (fi < fl) && (pi < pl)\n ; fi++, pi++) {\n this.debug('matchOne loop')\n var p = pattern[pi]\n var f = file[fi]\n\n this.debug(pattern, p, f)\n\n // should be impossible.\n // some invalid regexp stuff in the set.\n if (p === false) return false\n\n if (p === GLOBSTAR) {\n this.debug('GLOBSTAR', [pattern, p, f])\n\n // \"**\"\n // a/**/b/**/c would match the following:\n // a/b/x/y/z/c\n // a/x/y/z/b/c\n // a/b/x/b/x/c\n // a/b/c\n // To do this, take the rest of the pattern after\n // the **, and see if it would match the file remainder.\n // If so, return success.\n // If not, the ** \"swallows\" a segment, and try again.\n // This is recursively awful.\n //\n // a/**/b/**/c matching a/b/x/y/z/c\n // - a matches a\n // - doublestar\n // - matchOne(b/x/y/z/c, b/**/c)\n // - b matches b\n // - doublestar\n // - matchOne(x/y/z/c, c) -> no\n // - matchOne(y/z/c, c) -> no\n // - matchOne(z/c, c) -> no\n // - matchOne(c, c) yes, hit\n var fr = fi\n var pr = pi + 1\n if (pr === pl) {\n this.debug('** at the end')\n // a ** at the end will just swallow the rest.\n // We have found a match.\n // however, it will not swallow /.x, unless\n // options.dot is set.\n // . and .. are *never* matched by **, for explosively\n // exponential reasons.\n for (; fi < fl; fi++) {\n if (file[fi] === '.' || file[fi] === '..' ||\n (!options.dot && file[fi].charAt(0) === '.')) return false\n }\n return true\n }\n\n // ok, let's see if we can swallow whatever we can.\n while (fr < fl) {\n var swallowee = file[fr]\n\n this.debug('\\nglobstar while', file, fr, pattern, pr, swallowee)\n\n // XXX remove this slice. Just pass the start index.\n if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {\n this.debug('globstar found match!', fr, fl, swallowee)\n // found a match.\n return true\n } else {\n // can't swallow \".\" or \"..\" ever.\n // can only swallow \".foo\" when explicitly asked.\n if (swallowee === '.' || swallowee === '..' ||\n (!options.dot && swallowee.charAt(0) === '.')) {\n this.debug('dot detected!', file, fr, pattern, pr)\n break\n }\n\n // ** swallows a segment, and continue.\n this.debug('globstar swallow a segment, and continue')\n fr++\n }\n }\n\n // no match was found.\n // However, in partial mode, we can't say this is necessarily over.\n // If there's more *pattern* left, then\n if (partial) {\n // ran out of file\n this.debug('\\n>>> no match, partial?', file, fr, pattern, pr)\n if (fr === fl) return true\n }\n return false\n }\n\n // something other than **\n // non-magic patterns just have to match exactly\n // patterns with magic have been turned into regexps.\n var hit\n if (typeof p === 'string') {\n if (options.nocase) {\n hit = f.toLowerCase() === p.toLowerCase()\n } else {\n hit = f === p\n }\n this.debug('string match', p, f, hit)\n } else {\n hit = f.match(p)\n this.debug('pattern match', p, f, hit)\n }\n\n if (!hit) return false\n }\n\n // Note: ending in / means that we'll get a final \"\"\n // at the end of the pattern. This can only match a\n // corresponding \"\" at the end of the file.\n // If the file ends in /, then it can only match a\n // a pattern that ends in /, unless the pattern just\n // doesn't have any more for it. But, a/b/ should *not*\n // match \"a/b/*\", even though \"\" matches against the\n // [^/]*? pattern, except in partial mode, where it might\n // simply not be reached yet.\n // However, a/b/ should still satisfy a/*\n\n // now either we fell off the end of the pattern, or we're done.\n if (fi === fl && pi === pl) {\n // ran out of pattern and filename at the same time.\n // an exact hit!\n return true\n } else if (fi === fl) {\n // ran out of file, but still had pattern left.\n // this is ok if we're doing the match as part of\n // a glob fs traversal.\n return partial\n } else if (pi === pl) {\n // ran out of pattern, still have file left.\n // this is only acceptable if we're on the very last\n // empty segment of a file with a trailing slash.\n // a/* should match a/b/\n var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')\n return emptyFileEnd\n }\n\n // should be unreachable.\n throw new Error('wtf?')\n}\n\n// replace stuff like \\* with *\nfunction globUnescape (s) {\n return s.replace(/\\\\(.)/g, '$1')\n}\n\nfunction regExpEscape (s) {\n return s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&')\n}\n","var wrappy = require('wrappy')\nmodule.exports = wrappy(once)\nmodule.exports.strict = wrappy(onceStrict)\n\nonce.proto = once(function () {\n Object.defineProperty(Function.prototype, 'once', {\n value: function () {\n return once(this)\n },\n configurable: true\n })\n\n Object.defineProperty(Function.prototype, 'onceStrict', {\n value: function () {\n return onceStrict(this)\n },\n configurable: true\n })\n})\n\nfunction once (fn) {\n var f = function () {\n if (f.called) return f.value\n f.called = true\n return f.value = fn.apply(this, arguments)\n }\n f.called = false\n return f\n}\n\nfunction onceStrict (fn) {\n var f = function () {\n if (f.called)\n throw new Error(f.onceError)\n f.called = true\n return f.value = fn.apply(this, arguments)\n }\n var name = fn.name || 'Function wrapped with `once`'\n f.onceError = name + \" shouldn't be called more than once\"\n f.called = false\n return f\n}\n","'use strict';\n\nfunction posix(path) {\n\treturn path.charAt(0) === '/';\n}\n\nfunction win32(path) {\n\t// https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56\n\tvar splitDeviceRe = /^([a-zA-Z]:|[\\\\\\/]{2}[^\\\\\\/]+[\\\\\\/]+[^\\\\\\/]+)?([\\\\\\/])?([\\s\\S]*?)$/;\n\tvar result = splitDeviceRe.exec(path);\n\tvar device = result[1] || '';\n\tvar isUnc = Boolean(device && device.charAt(1) !== ':');\n\n\t// UNC paths are always absolute\n\treturn Boolean(result[2] || isUnc);\n}\n\nmodule.exports = process.platform === 'win32' ? win32 : posix;\nmodule.exports.posix = posix;\nmodule.exports.win32 = win32;\n",";(function (sax) { // wrapper for non-node envs\n sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }\n sax.SAXParser = SAXParser\n sax.SAXStream = SAXStream\n sax.createStream = createStream\n\n // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.\n // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),\n // since that's the earliest that a buffer overrun could occur. This way, checks are\n // as rare as required, but as often as necessary to ensure never crossing this bound.\n // Furthermore, buffers are only tested at most once per write(), so passing a very\n // large string into write() might have undesirable effects, but this is manageable by\n // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme\n // edge case, result in creating at most one complete copy of the string passed in.\n // Set to Infinity to have unlimited buffers.\n sax.MAX_BUFFER_LENGTH = 64 * 1024\n\n var buffers = [\n 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype',\n 'procInstName', 'procInstBody', 'entity', 'attribName',\n 'attribValue', 'cdata', 'script'\n ]\n\n sax.EVENTS = [\n 'text',\n 'processinginstruction',\n 'sgmldeclaration',\n 'doctype',\n 'comment',\n 'opentagstart',\n 'attribute',\n 'opentag',\n 'closetag',\n 'opencdata',\n 'cdata',\n 'closecdata',\n 'error',\n 'end',\n 'ready',\n 'script',\n 'opennamespace',\n 'closenamespace'\n ]\n\n function SAXParser (strict, opt) {\n if (!(this instanceof SAXParser)) {\n return new SAXParser(strict, opt)\n }\n\n var parser = this\n clearBuffers(parser)\n parser.q = parser.c = ''\n parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH\n parser.opt = opt || {}\n parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags\n parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'\n parser.tags = []\n parser.closed = parser.closedRoot = parser.sawRoot = false\n parser.tag = parser.error = null\n parser.strict = !!strict\n parser.noscript = !!(strict || parser.opt.noscript)\n parser.state = S.BEGIN\n parser.strictEntities = parser.opt.strictEntities\n parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES)\n parser.attribList = []\n\n // namespaces form a prototype chain.\n // it always points at the current tag,\n // which protos to its parent tag.\n if (parser.opt.xmlns) {\n parser.ns = Object.create(rootNS)\n }\n\n // mostly just for error reporting\n parser.trackPosition = parser.opt.position !== false\n if (parser.trackPosition) {\n parser.position = parser.line = parser.column = 0\n }\n emit(parser, 'onready')\n }\n\n if (!Object.create) {\n Object.create = function (o) {\n function F () {}\n F.prototype = o\n var newf = new F()\n return newf\n }\n }\n\n if (!Object.keys) {\n Object.keys = function (o) {\n var a = []\n for (var i in o) if (o.hasOwnProperty(i)) a.push(i)\n return a\n }\n }\n\n function checkBufferLength (parser) {\n var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)\n var maxActual = 0\n for (var i = 0, l = buffers.length; i < l; i++) {\n var len = parser[buffers[i]].length\n if (len > maxAllowed) {\n // Text/cdata nodes can get big, and since they're buffered,\n // we can get here under normal conditions.\n // Avoid issues by emitting the text node now,\n // so at least it won't get any bigger.\n switch (buffers[i]) {\n case 'textNode':\n closeText(parser)\n break\n\n case 'cdata':\n emitNode(parser, 'oncdata', parser.cdata)\n parser.cdata = ''\n break\n\n case 'script':\n emitNode(parser, 'onscript', parser.script)\n parser.script = ''\n break\n\n default:\n error(parser, 'Max buffer length exceeded: ' + buffers[i])\n }\n }\n maxActual = Math.max(maxActual, len)\n }\n // schedule the next check for the earliest possible buffer overrun.\n var m = sax.MAX_BUFFER_LENGTH - maxActual\n parser.bufferCheckPosition = m + parser.position\n }\n\n function clearBuffers (parser) {\n for (var i = 0, l = buffers.length; i < l; i++) {\n parser[buffers[i]] = ''\n }\n }\n\n function flushBuffers (parser) {\n closeText(parser)\n if (parser.cdata !== '') {\n emitNode(parser, 'oncdata', parser.cdata)\n parser.cdata = ''\n }\n if (parser.script !== '') {\n emitNode(parser, 'onscript', parser.script)\n parser.script = ''\n }\n }\n\n SAXParser.prototype = {\n end: function () { end(this) },\n write: write,\n resume: function () { this.error = null; return this },\n close: function () { return this.write(null) },\n flush: function () { flushBuffers(this) }\n }\n\n var Stream\n try {\n Stream = require('stream').Stream\n } catch (ex) {\n Stream = function () {}\n }\n\n var streamWraps = sax.EVENTS.filter(function (ev) {\n return ev !== 'error' && ev !== 'end'\n })\n\n function createStream (strict, opt) {\n return new SAXStream(strict, opt)\n }\n\n function SAXStream (strict, opt) {\n if (!(this instanceof SAXStream)) {\n return new SAXStream(strict, opt)\n }\n\n Stream.apply(this)\n\n this._parser = new SAXParser(strict, opt)\n this.writable = true\n this.readable = true\n\n var me = this\n\n this._parser.onend = function () {\n me.emit('end')\n }\n\n this._parser.onerror = function (er) {\n me.emit('error', er)\n\n // if didn't throw, then means error was handled.\n // go ahead and clear error, so we can write again.\n me._parser.error = null\n }\n\n this._decoder = null\n\n streamWraps.forEach(function (ev) {\n Object.defineProperty(me, 'on' + ev, {\n get: function () {\n return me._parser['on' + ev]\n },\n set: function (h) {\n if (!h) {\n me.removeAllListeners(ev)\n me._parser['on' + ev] = h\n return h\n }\n me.on(ev, h)\n },\n enumerable: true,\n configurable: false\n })\n })\n }\n\n SAXStream.prototype = Object.create(Stream.prototype, {\n constructor: {\n value: SAXStream\n }\n })\n\n SAXStream.prototype.write = function (data) {\n if (typeof Buffer === 'function' &&\n typeof Buffer.isBuffer === 'function' &&\n Buffer.isBuffer(data)) {\n if (!this._decoder) {\n var SD = require('string_decoder').StringDecoder\n this._decoder = new SD('utf8')\n }\n data = this._decoder.write(data)\n }\n\n this._parser.write(data.toString())\n this.emit('data', data)\n return true\n }\n\n SAXStream.prototype.end = function (chunk) {\n if (chunk && chunk.length) {\n this.write(chunk)\n }\n this._parser.end()\n return true\n }\n\n SAXStream.prototype.on = function (ev, handler) {\n var me = this\n if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {\n me._parser['on' + ev] = function () {\n var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)\n args.splice(0, 0, ev)\n me.emit.apply(me, args)\n }\n }\n\n return Stream.prototype.on.call(me, ev, handler)\n }\n\n // this really needs to be replaced with character classes.\n // XML allows all manner of ridiculous numbers and digits.\n var CDATA = '[CDATA['\n var DOCTYPE = 'DOCTYPE'\n var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'\n var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'\n var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }\n\n // http://www.w3.org/TR/REC-xml/#NT-NameStartChar\n // This implementation works on strings, a single character at a time\n // as such, it cannot ever support astral-plane characters (10000-EFFFF)\n // without a significant breaking change to either this parser, or the\n // JavaScript language. Implementation of an emoji-capable xml parser\n // is left as an exercise for the reader.\n var nameStart = /[:_A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]/\n\n var nameBody = /[:_A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\u00B7\\u0300-\\u036F\\u203F-\\u2040.\\d-]/\n\n var entityStart = /[#:_A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]/\n var entityBody = /[#:_A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\u00B7\\u0300-\\u036F\\u203F-\\u2040.\\d-]/\n\n function isWhitespace (c) {\n return c === ' ' || c === '\\n' || c === '\\r' || c === '\\t'\n }\n\n function isQuote (c) {\n return c === '\"' || c === '\\''\n }\n\n function isAttribEnd (c) {\n return c === '>' || isWhitespace(c)\n }\n\n function isMatch (regex, c) {\n return regex.test(c)\n }\n\n function notMatch (regex, c) {\n return !isMatch(regex, c)\n }\n\n var S = 0\n sax.STATE = {\n BEGIN: S++, // leading byte order mark or whitespace\n BEGIN_WHITESPACE: S++, // leading whitespace\n TEXT: S++, // general stuff\n TEXT_ENTITY: S++, // & and such.\n OPEN_WAKA: S++, // <\n SGML_DECL: S++, // \n SCRIPT: S++, //