From 0d8311219d181797de4f43bc69cddc73a803cee9 Mon Sep 17 00:00:00 2001 From: Alex Pilafian Date: Tue, 23 Jan 2018 12:36:28 +0000 Subject: [PATCH] Removing oboe-js dependency, as oboe is no longer maintained and cannot be relied upon for streaming very large JSON. Instead moving to ndjson format (newline-delimited JSON) and using the can-ndjson-stream library in conjunction with the Fetch API to handle all the heavy lifting of streaming it. This handles all memory-related problems with importing very large JSON database data. Also updates tests to work with new parsing strategy and ndjson format... --- dist/postgres-indexed-db.js | 12665 +++++++++++++--------------------- lib/exporter.js | 12 +- lib/importer.js | 51 +- package.json | 6 +- test/test.html | 109 +- test/test.js | 109 +- 6 files changed, 5050 insertions(+), 7902 deletions(-) diff --git a/dist/postgres-indexed-db.js b/dist/postgres-indexed-db.js index 95fc258..9c2494c 100644 --- a/dist/postgres-indexed-db.js +++ b/dist/postgres-indexed-db.js @@ -1,7 +1,7 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= options.items_per_page || @@ -180,15 +200,14 @@ module.exports.import = function( data_path, idb_name, options ){ current_page += 1; } - return oboe.drop; //allows to read files bigger than available RAM - } - }) - .fail(function(){ - failout('oboe_read_failed'); - }); + reader.read().then(doRead); + }; + reader.read().then(doRead); - }); + }); + + }); store.transaction.addEventListener('error', function(){ failout('idb_schema_failed'); @@ -214,12 +233,6 @@ module.exports.import = function( data_path, idb_name, options ){ delReq.onsuccess = fillIDB; delReq.onerror = fillIDB; - }) - .fail(function(){ - events.next({ - message: "error", - value: "manifest not found" - }); }); return events; @@ -229,7 +242,7 @@ module.exports.idbImported = function(idb_name){ var list = JSON.parse(window.localStorage.getItem('__idb_import_complete')) || {}; return list[idb_name] || false; }; -},{"lodash":"lodash","oboe":"oboe","q":"q","rxjs":55}],2:[function(require,module,exports){ +},{"can-ndjson-stream":"can-ndjson-stream","lodash":"lodash","q":"q","rxjs":50}],2:[function(require,module,exports){ 'use strict'; var master_obj = {} @@ -282,22 +295,22 @@ function placeHoldersCount (b64) { function byteLength (b64) { // base64 is 4/3 + up to two characters of the original data - return b64.length * 3 / 4 - placeHoldersCount(b64) + return (b64.length * 3 / 4) - placeHoldersCount(b64) } function toByteArray (b64) { - var i, j, l, tmp, placeHolders, arr + var i, l, tmp, placeHolders, arr var len = b64.length placeHolders = placeHoldersCount(b64) - arr = new Arr(len * 3 / 4 - placeHolders) + arr = new Arr((len * 3 / 4) - placeHolders) // if there are placeholders, only get up to the last complete 4 chars l = placeHolders > 0 ? len - 4 : len var L = 0 - for (i = 0, j = 0; i < l; i += 4, j += 3) { + for (i = 0; i < l; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] arr[L++] = (tmp >> 16) & 0xFF arr[L++] = (tmp >> 8) & 0xFF @@ -368,119 +381,6 @@ function fromByteArray (uint8) { arguments[4][4][0].apply(exports,arguments) },{"dup":4}],6:[function(require,module,exports){ (function (global){ -'use strict'; - -var buffer = require('buffer'); -var Buffer = buffer.Buffer; -var SlowBuffer = buffer.SlowBuffer; -var MAX_LEN = buffer.kMaxLength || 2147483647; -exports.alloc = function alloc(size, fill, encoding) { - if (typeof Buffer.alloc === 'function') { - return Buffer.alloc(size, fill, encoding); - } - if (typeof encoding === 'number') { - throw new TypeError('encoding must not be number'); - } - if (typeof size !== 'number') { - throw new TypeError('size must be a number'); - } - if (size > MAX_LEN) { - throw new RangeError('size is too large'); - } - var enc = encoding; - var _fill = fill; - if (_fill === undefined) { - enc = undefined; - _fill = 0; - } - var buf = new Buffer(size); - if (typeof _fill === 'string') { - var fillBuf = new Buffer(_fill, enc); - var flen = fillBuf.length; - var i = -1; - while (++i < size) { - buf[i] = fillBuf[i % flen]; - } - } else { - buf.fill(_fill); - } - return buf; -} -exports.allocUnsafe = function allocUnsafe(size) { - if (typeof Buffer.allocUnsafe === 'function') { - return Buffer.allocUnsafe(size); - } - if (typeof size !== 'number') { - throw new TypeError('size must be a number'); - } - if (size > MAX_LEN) { - throw new RangeError('size is too large'); - } - return new Buffer(size); -} -exports.from = function from(value, encodingOrOffset, length) { - if (typeof Buffer.from === 'function' && (!global.Uint8Array || Uint8Array.from !== Buffer.from)) { - return Buffer.from(value, encodingOrOffset, length); - } - if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number'); - } - if (typeof value === 'string') { - return new Buffer(value, encodingOrOffset); - } - if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { - var offset = encodingOrOffset; - if (arguments.length === 1) { - return new Buffer(value); - } - if (typeof offset === 'undefined') { - offset = 0; - } - var len = length; - if (typeof len === 'undefined') { - len = value.byteLength - offset; - } - if (offset >= value.byteLength) { - throw new RangeError('\'offset\' is out of bounds'); - } - if (len > value.byteLength - offset) { - throw new RangeError('\'length\' is out of bounds'); - } - return new Buffer(value.slice(offset, offset + len)); - } - if (Buffer.isBuffer(value)) { - var out = new Buffer(value.length); - value.copy(out, 0, 0, value.length); - return out; - } - if (value) { - if (Array.isArray(value) || (typeof ArrayBuffer !== 'undefined' && value.buffer instanceof ArrayBuffer) || 'length' in value) { - return new Buffer(value); - } - if (value.type === 'Buffer' && Array.isArray(value.data)) { - return new Buffer(value.data); - } - } - - throw new TypeError('First argument must be a string, Buffer, ' + 'ArrayBuffer, Array, or array-like object.'); -} -exports.allocUnsafeSlow = function allocUnsafeSlow(size) { - if (typeof Buffer.allocUnsafeSlow === 'function') { - return Buffer.allocUnsafeSlow(size); - } - if (typeof size !== 'number') { - throw new TypeError('size must be a number'); - } - if (size >= MAX_LEN) { - throw new RangeError('size is too large'); - } - return new SlowBuffer(size); -} - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - -},{"buffer":7}],7:[function(require,module,exports){ -(function (global){ /*! * The buffer module from node.js, for the browser. * @@ -2273,80 +2173,17 @@ function isnan (val) { }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"base64-js":3,"ieee754":31,"isarray":8}],8:[function(require,module,exports){ +},{"base64-js":3,"ieee754":28,"isarray":7}],7:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; +},{}],8:[function(require,module,exports){ +module.exports = {}; + },{}],9:[function(require,module,exports){ -module.exports = { - "100": "Continue", - "101": "Switching Protocols", - "102": "Processing", - "200": "OK", - "201": "Created", - "202": "Accepted", - "203": "Non-Authoritative Information", - "204": "No Content", - "205": "Reset Content", - "206": "Partial Content", - "207": "Multi-Status", - "208": "Already Reported", - "226": "IM Used", - "300": "Multiple Choices", - "301": "Moved Permanently", - "302": "Found", - "303": "See Other", - "304": "Not Modified", - "305": "Use Proxy", - "307": "Temporary Redirect", - "308": "Permanent Redirect", - "400": "Bad Request", - "401": "Unauthorized", - "402": "Payment Required", - "403": "Forbidden", - "404": "Not Found", - "405": "Method Not Allowed", - "406": "Not Acceptable", - "407": "Proxy Authentication Required", - "408": "Request Timeout", - "409": "Conflict", - "410": "Gone", - "411": "Length Required", - "412": "Precondition Failed", - "413": "Payload Too Large", - "414": "URI Too Long", - "415": "Unsupported Media Type", - "416": "Range Not Satisfiable", - "417": "Expectation Failed", - "418": "I'm a teapot", - "421": "Misdirected Request", - "422": "Unprocessable Entity", - "423": "Locked", - "424": "Failed Dependency", - "425": "Unordered Collection", - "426": "Upgrade Required", - "428": "Precondition Required", - "429": "Too Many Requests", - "431": "Request Header Fields Too Large", - "451": "Unavailable For Legal Reasons", - "500": "Internal Server Error", - "501": "Not Implemented", - "502": "Bad Gateway", - "503": "Service Unavailable", - "504": "Gateway Timeout", - "505": "HTTP Version Not Supported", - "506": "Variant Also Negotiates", - "507": "Insufficient Storage", - "508": "Loop Detected", - "509": "Bandwidth Limit Exceeded", - "510": "Not Extended", - "511": "Network Authentication Required" -} - -},{}],10:[function(require,module,exports){ (function (Buffer){ // Copyright Joyent, Inc. and other Node contributors. // @@ -2458,7 +2295,7 @@ function objectToString(o) { }).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":33}],11:[function(require,module,exports){ +},{"../../is-buffer/index.js":30}],10:[function(require,module,exports){ var pSlice = Array.prototype.slice; var objectKeys = require('./lib/keys.js'); var isArguments = require('./lib/is_arguments.js'); @@ -2554,7 +2391,7 @@ function objEquiv(a, b, opts) { return typeof a === typeof b; } -},{"./lib/is_arguments.js":12,"./lib/keys.js":13}],12:[function(require,module,exports){ +},{"./lib/is_arguments.js":11,"./lib/keys.js":12}],11:[function(require,module,exports){ var supportsArgumentsClass = (function(){ return Object.prototype.toString.call(arguments) })() == '[object Arguments]'; @@ -2576,7 +2413,7 @@ function unsupported(object){ false; }; -},{}],13:[function(require,module,exports){ +},{}],12:[function(require,module,exports){ exports = module.exports = typeof Object.keys === 'function' ? Object.keys : shim; @@ -2587,7 +2424,7 @@ function shim (obj) { return keys; } -},{}],14:[function(require,module,exports){ +},{}],13:[function(require,module,exports){ 'use strict'; var keys = require('object-keys'); @@ -2645,14 +2482,14 @@ defineProperties.supportsDescriptors = !!supportsDescriptors; module.exports = defineProperties; -},{"foreach":25,"object-keys":37}],15:[function(require,module,exports){ +},{"foreach":24,"object-keys":35}],14:[function(require,module,exports){ module.exports = function () { for (var i = 0; i < arguments.length; i++) { if (arguments[i] !== undefined) return arguments[i]; } }; -},{}],16:[function(require,module,exports){ +},{}],15:[function(require,module,exports){ 'use strict'; var $isNaN = require('./helpers/isNaN'); @@ -2664,12 +2501,14 @@ var mod = require('./helpers/mod'); var IsCallable = require('is-callable'); var toPrimitive = require('es-to-primitive/es5'); +var has = require('has'); + // https://es5.github.io/#x9 var ES5 = { ToPrimitive: toPrimitive, ToBoolean: function ToBoolean(value) { - return Boolean(value); + return !!value; }, ToNumber: function ToNumber(value) { return Number(value); @@ -2735,33 +2574,181 @@ var ES5 = { if (typeof x === 'string') { return 'String'; } + }, + + // http://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type + IsPropertyDescriptor: function IsPropertyDescriptor(Desc) { + if (this.Type(Desc) !== 'Object') { + return false; + } + var allowed = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Get]]': true, + '[[Set]]': true, + '[[Value]]': true, + '[[Writable]]': true + }; + // jscs:disable + for (var key in Desc) { // eslint-disable-line + if (has(Desc, key) && !allowed[key]) { + return false; + } + } + // jscs:enable + var isData = has(Desc, '[[Value]]'); + var IsAccessor = has(Desc, '[[Get]]') || has(Desc, '[[Set]]'); + if (isData && IsAccessor) { + throw new TypeError('Property Descriptors may not be both accessor and data descriptors'); + } + return true; + }, + + // http://ecma-international.org/ecma-262/5.1/#sec-8.10.1 + IsAccessorDescriptor: function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!this.IsPropertyDescriptor(Desc)) { + throw new TypeError('Desc must be a Property Descriptor'); + } + + if (!has(Desc, '[[Get]]') && !has(Desc, '[[Set]]')) { + return false; + } + + return true; + }, + + // http://ecma-international.org/ecma-262/5.1/#sec-8.10.2 + IsDataDescriptor: function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!this.IsPropertyDescriptor(Desc)) { + throw new TypeError('Desc must be a Property Descriptor'); + } + + if (!has(Desc, '[[Value]]') && !has(Desc, '[[Writable]]')) { + return false; + } + + return true; + }, + + // http://ecma-international.org/ecma-262/5.1/#sec-8.10.3 + IsGenericDescriptor: function IsGenericDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!this.IsPropertyDescriptor(Desc)) { + throw new TypeError('Desc must be a Property Descriptor'); + } + + if (!this.IsAccessorDescriptor(Desc) && !this.IsDataDescriptor(Desc)) { + return true; + } + + return false; + }, + + // http://ecma-international.org/ecma-262/5.1/#sec-8.10.4 + FromPropertyDescriptor: function FromPropertyDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return Desc; + } + + if (!this.IsPropertyDescriptor(Desc)) { + throw new TypeError('Desc must be a Property Descriptor'); + } + + if (this.IsDataDescriptor(Desc)) { + return { + value: Desc['[[Value]]'], + writable: !!Desc['[[Writable]]'], + enumerable: !!Desc['[[Enumerable]]'], + configurable: !!Desc['[[Configurable]]'] + }; + } else if (this.IsAccessorDescriptor(Desc)) { + return { + get: Desc['[[Get]]'], + set: Desc['[[Set]]'], + enumerable: !!Desc['[[Enumerable]]'], + configurable: !!Desc['[[Configurable]]'] + }; + } else { + throw new TypeError('FromPropertyDescriptor must be called with a fully populated Property Descriptor'); + } + }, + + // http://ecma-international.org/ecma-262/5.1/#sec-8.10.5 + ToPropertyDescriptor: function ToPropertyDescriptor(Obj) { + if (this.Type(Obj) !== 'Object') { + throw new TypeError('ToPropertyDescriptor requires an object'); + } + + var desc = {}; + if (has(Obj, 'enumerable')) { + desc['[[Enumerable]]'] = this.ToBoolean(Obj.enumerable); + } + if (has(Obj, 'configurable')) { + desc['[[Configurable]]'] = this.ToBoolean(Obj.configurable); + } + if (has(Obj, 'value')) { + desc['[[Value]]'] = Obj.value; + } + if (has(Obj, 'writable')) { + desc['[[Writable]]'] = this.ToBoolean(Obj.writable); + } + if (has(Obj, 'get')) { + var getter = Obj.get; + if (typeof getter !== 'undefined' && !this.IsCallable(getter)) { + throw new TypeError('getter must be a function'); + } + desc['[[Get]]'] = getter; + } + if (has(Obj, 'set')) { + var setter = Obj.set; + if (typeof setter !== 'undefined' && !this.IsCallable(setter)) { + throw new TypeError('setter must be a function'); + } + desc['[[Set]]'] = setter; + } + + if ((has(desc, '[[Get]]') || has(desc, '[[Set]]')) && (has(desc, '[[Value]]') || has(desc, '[[Writable]]'))) { + throw new TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); + } + return desc; } }; module.exports = ES5; -},{"./helpers/isFinite":17,"./helpers/isNaN":18,"./helpers/mod":19,"./helpers/sign":20,"es-to-primitive/es5":21,"is-callable":34}],17:[function(require,module,exports){ +},{"./helpers/isFinite":16,"./helpers/isNaN":17,"./helpers/mod":18,"./helpers/sign":19,"es-to-primitive/es5":20,"has":27,"is-callable":31}],16:[function(require,module,exports){ var $isNaN = Number.isNaN || function (a) { return a !== a; }; module.exports = Number.isFinite || function (x) { return typeof x === 'number' && !$isNaN(x) && x !== Infinity && x !== -Infinity; }; -},{}],18:[function(require,module,exports){ +},{}],17:[function(require,module,exports){ module.exports = Number.isNaN || function isNaN(a) { return a !== a; }; -},{}],19:[function(require,module,exports){ +},{}],18:[function(require,module,exports){ module.exports = function mod(number, modulo) { var remain = number % modulo; return Math.floor(remain >= 0 ? remain : remain + modulo); }; -},{}],20:[function(require,module,exports){ +},{}],19:[function(require,module,exports){ module.exports = function sign(number) { return number >= 0 ? 1 : -1; }; -},{}],21:[function(require,module,exports){ +},{}],20:[function(require,module,exports){ 'use strict'; var toStr = Object.prototype.toString; @@ -2800,12 +2787,12 @@ module.exports = function ToPrimitive(input, PreferredType) { return ES5internalSlots['[[DefaultValue]]'](input, PreferredType); }; -},{"./helpers/isPrimitive":22,"is-callable":34}],22:[function(require,module,exports){ +},{"./helpers/isPrimitive":21,"is-callable":31}],21:[function(require,module,exports){ module.exports = function isPrimitive(value) { return value === null || (typeof value !== 'function' && typeof value !== 'object'); }; -},{}],23:[function(require,module,exports){ +},{}],22:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -3109,7 +3096,7 @@ function isUndefined(arg) { return arg === void 0; } -},{}],24:[function(require,module,exports){ +},{}],23:[function(require,module,exports){ var isFunction = require('is-function') module.exports = forEach @@ -3157,7 +3144,7 @@ function forEachObject(object, iterator, context) { } } -},{"is-function":35}],25:[function(require,module,exports){ +},{"is-function":32}],24:[function(require,module,exports){ var hasOwn = Object.prototype.hasOwnProperty; var toString = Object.prototype.toString; @@ -3181,7 +3168,11 @@ module.exports = function forEach (obj, fn, ctx) { }; -},{}],26:[function(require,module,exports){ +},{}],25:[function(require,module,exports){ +'use strict'; + +/* eslint no-invalid-this: 1 */ + var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible '; var slice = Array.prototype.slice; var toStr = Object.prototype.toString; @@ -3231,54 +3222,19 @@ module.exports = function bind(that) { return bound; }; -},{}],27:[function(require,module,exports){ +},{}],26:[function(require,module,exports){ +'use strict'; + var implementation = require('./implementation'); module.exports = Function.prototype.bind || implementation; -},{"./implementation":26}],28:[function(require,module,exports){ +},{"./implementation":25}],27:[function(require,module,exports){ var bind = require('function-bind'); module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty); -},{"function-bind":27}],29:[function(require,module,exports){ -var http = exports.http = require('http') -var https = exports.https = require('https') -var url = require('url') - -exports.get = function(opt, cb) { - return getMod(opt).get(opt, cb) -} - -exports.request = function(opt, cb) { - return getMod(opt).request(opt, cb) -} - -exports.getModule = getMod -function getMod(opt) { - if (typeof opt === 'string') - opt = url.parse(opt) - - return opt.protocol === 'https:' ? https : http -} - -},{"http":403,"https":30,"url":425}],30:[function(require,module,exports){ -var http = require('http'); - -var https = module.exports; - -for (var key in http) { - if (http.hasOwnProperty(key)) https[key] = http[key]; -}; - -https.request = function (params, cb) { - if (!params) params = {}; - params.scheme = 'https'; - params.protocol = 'https:'; - return http.request.call(this, params, cb); -} - -},{"http":403}],31:[function(require,module,exports){ +},{"function-bind":26}],28:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = nBytes * 8 - mLen - 1 @@ -3364,7 +3320,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],32:[function(require,module,exports){ +},{}],29:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -3389,11 +3345,11 @@ if (typeof Object.create === 'function') { } } -},{}],33:[function(require,module,exports){ +},{}],30:[function(require,module,exports){ /*! * Determine if an object is a Buffer * - * @author Feross Aboukhadijeh + * @author Feross Aboukhadijeh * @license MIT */ @@ -3412,7 +3368,7 @@ function isSlowBuffer (obj) { return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) } -},{}],34:[function(require,module,exports){ +},{}],31:[function(require,module,exports){ 'use strict'; var fnToStr = Function.prototype.toString; @@ -3453,7 +3409,7 @@ module.exports = function isCallable(value) { return strClass === fnClass || strClass === genClass; }; -},{}],35:[function(require,module,exports){ +},{}],32:[function(require,module,exports){ module.exports = isFunction var toString = Object.prototype.toString @@ -3470,7 +3426,36 @@ function isFunction (fn) { fn === window.prompt)) }; -},{}],36:[function(require,module,exports){ +},{}],33:[function(require,module,exports){ +exports = module.exports = stringify +exports.getSerialize = serializer + +function stringify(obj, replacer, spaces, cycleReplacer) { + return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces) +} + +function serializer(replacer, cycleReplacer) { + var stack = [], keys = [] + + if (cycleReplacer == null) cycleReplacer = function(key, value) { + if (stack[0] === value) return "[Circular ~]" + return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]" + } + + return function(key, value) { + if (stack.length > 0) { + var thisPos = stack.indexOf(this) + ~thisPos ? stack.splice(thisPos + 1) : stack.push(this) + ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key) + if (~stack.indexOf(value)) value = cycleReplacer.call(this, key, value) + } + else stack.push(value) + + return replacer == null ? value : replacer.call(this, key, value) + } +} + +},{}],34:[function(require,module,exports){ var hasMap = typeof Map === 'function' && Map.prototype; var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null; var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null; @@ -3480,21 +3465,41 @@ var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOw var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null; var setForEach = hasSet && Set.prototype.forEach; var booleanValueOf = Boolean.prototype.valueOf; +var objectToString = Object.prototype.toString; module.exports = function inspect_ (obj, opts, depth, seen) { + if (typeof obj === 'undefined') { + return 'undefined'; + } + if (obj === null) { + return 'null'; + } + if (typeof obj === 'boolean') { + return obj ? 'true' : 'false'; + } + if (typeof obj === 'string') { + return inspectString(obj); + } + if (typeof obj === 'number') { + if (obj === 0) { + return Infinity / obj > 0 ? '0' : '-0'; + } + return String(obj); + } + if (!opts) opts = {}; - - var maxDepth = opts.depth === undefined ? 5 : opts.depth; - if (depth === undefined) depth = 0; - if (depth >= maxDepth && maxDepth > 0 && obj && typeof obj === 'object') { + + var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth; + if (typeof depth === 'undefined') depth = 0; + if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') { return '[Object]'; } - - if (seen === undefined) seen = []; + + if (typeof seen === 'undefined') seen = []; else if (indexOf(seen, obj) >= 0) { return '[Circular]'; } - + function inspect (value, from) { if (from) { seen = seen.slice(); @@ -3502,22 +3507,16 @@ module.exports = function inspect_ (obj, opts, depth, seen) { } return inspect_(value, opts, depth + 1, seen); } - - if (typeof obj === 'string') { - return inspectString(obj); - } - else if (typeof obj === 'function') { + + if (typeof obj === 'function') { var name = nameOf(obj); return '[Function' + (name ? ': ' + name : '') + ']'; } - else if (obj === null) { - return 'null'; - } - else if (isSymbol(obj)) { + if (isSymbol(obj)) { var symString = Symbol.prototype.toString.call(obj); - return typeof obj === 'object' ? 'Object(' + symString + ')' : symString; + return typeof obj === 'object' ? markBoxed(symString) : symString; } - else if (isElement(obj)) { + if (isElement(obj)) { var s = '<' + String(obj.nodeName).toLowerCase(); var attrs = obj.attributes || []; for (var i = 0; i < attrs.length; i++) { @@ -3528,75 +3527,47 @@ module.exports = function inspect_ (obj, opts, depth, seen) { s += ''; return s; } - else if (isArray(obj)) { + if (isArray(obj)) { if (obj.length === 0) return '[]'; - var xs = Array(obj.length); - for (var i = 0; i < obj.length; i++) { - xs[i] = has(obj, i) ? inspect(obj[i], obj) : ''; - } - return '[ ' + xs.join(', ') + ' ]'; + return '[ ' + arrObjKeys(obj, inspect).join(', ') + ' ]'; } - else if (isError(obj)) { - var parts = []; - for (var key in obj) { - if (!has(obj, key)) continue; - - if (/[^\w$]/.test(key)) { - parts.push(inspect(key) + ': ' + inspect(obj[key])); - } - else { - parts.push(key + ': ' + inspect(obj[key])); - } - } - if (parts.length === 0) return '[' + obj + ']'; - return '{ [' + obj + '] ' + parts.join(', ') + ' }'; + if (isError(obj)) { + var parts = arrObjKeys(obj, inspect); + if (parts.length === 0) return '[' + String(obj) + ']'; + return '{ [' + String(obj) + '] ' + parts.join(', ') + ' }'; } - else if (typeof obj === 'object' && typeof obj.inspect === 'function') { + if (typeof obj === 'object' && typeof obj.inspect === 'function') { return obj.inspect(); } - else if (isMap(obj)) { + if (isMap(obj)) { var parts = []; mapForEach.call(obj, function (value, key) { parts.push(inspect(key, obj) + ' => ' + inspect(value, obj)); }); - return 'Map (' + mapSize.call(obj) + ') {' + parts.join(', ') + '}'; + return collectionOf('Map', mapSize.call(obj), parts); } - else if (isSet(obj)) { + if (isSet(obj)) { var parts = []; setForEach.call(obj, function (value ) { parts.push(inspect(value, obj)); }); - return 'Set (' + setSize.call(obj) + ') {' + parts.join(', ') + '}'; + return collectionOf('Set', setSize.call(obj), parts); } - else if (typeof obj !== 'object') { - return String(obj); + if (isNumber(obj)) { + return markBoxed(Number(obj)); } - else if (isNumber(obj)) { - return 'Object(' + Number(obj) + ')'; + if (isBoolean(obj)) { + return markBoxed(booleanValueOf.call(obj)); } - else if (isBoolean(obj)) { - return 'Object(' + booleanValueOf.call(obj) + ')'; + if (isString(obj)) { + return markBoxed(inspect(String(obj))); } - else if (isString(obj)) { - return 'Object(' + inspect(String(obj)) + ')'; - } - else if (!isDate(obj) && !isRegExp(obj)) { - var xs = [], keys = []; - for (var key in obj) { - if (has(obj, key)) keys.push(key); - } - keys.sort(); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (/[^\w$]/.test(key)) { - xs.push(inspect(key) + ': ' + inspect(obj[key], obj)); - } - else xs.push(key + ': ' + inspect(obj[key], obj)); - } + if (!isDate(obj) && !isRegExp(obj)) { + var xs = arrObjKeys(obj, inspect); if (xs.length === 0) return '{}'; return '{ ' + xs.join(', ') + ' }'; } - else return String(obj); + return String(obj); }; function quote (s) { @@ -3618,12 +3589,12 @@ function has (obj, key) { } function toStr (obj) { - return Object.prototype.toString.call(obj); + return objectToString.call(obj); } function nameOf (f) { if (f.name) return f.name; - var m = f.toString().match(/^function\s*([\w$]+)/); + var m = String(f).match(/^function\s*([\w$]+)/); if (m) return m[1]; } @@ -3641,7 +3612,12 @@ function isMap (x) { } try { mapSize.call(x); - return true; + try { + setSize.call(x); + } catch (s) { + return true; + } + return x instanceof Map; // core-js workaround, pre-v2.5.0 } catch (e) {} return false; } @@ -3652,7 +3628,12 @@ function isSet (x) { } try { setSize.call(x); - return true; + try { + mapSize.call(x); + } catch (m) { + return true; + } + return x instanceof Set; // core-js workaround, pre-v2.5.0 } catch (e) {} return false; } @@ -3670,16 +3651,45 @@ function isElement (x) { function inspectString (str) { var s = str.replace(/(['\\])/g, '\\$1').replace(/[\x00-\x1f]/g, lowbyte); return "'" + s + "'"; - - function lowbyte (c) { - var n = c.charCodeAt(0); - var x = { 8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r' }[n]; - if (x) return '\\' + x; - return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16); +} + +function lowbyte (c) { + var n = c.charCodeAt(0); + var x = { 8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r' }[n]; + if (x) return '\\' + x; + return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16); +} + +function markBoxed (str) { + return 'Object(' + str + ')'; +} + +function collectionOf (type, size, entries) { + return type + ' (' + size + ') {' + entries.join(', ') + '}'; +} + +function arrObjKeys (obj, inspect) { + var isArr = isArray(obj); + var xs = []; + if (isArr) { + xs.length = obj.length; + for (var i = 0; i < obj.length; i++) { + xs[i] = has(obj, i) ? inspect(obj[i], obj) : ''; + } + } + for (var key in obj) { + if (!has(obj, key)) continue; + if (isArr && String(Number(key)) === key && key < obj.length) continue; + if (/[^\w$]/.test(key)) { + xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj)); + } else { + xs.push(key + ': ' + inspect(obj[key], obj)); + } } + return xs; } -},{}],37:[function(require,module,exports){ +},{}],35:[function(require,module,exports){ 'use strict'; // modified from https://github.com/es-shims/es5-shim @@ -3821,7 +3831,7 @@ keysShim.shim = function shimObjectKeys() { module.exports = keysShim; -},{"./isArguments":38}],38:[function(require,module,exports){ +},{"./isArguments":36}],36:[function(require,module,exports){ 'use strict'; var toStr = Object.prototype.toString; @@ -3840,7 +3850,54 @@ module.exports = function isArguments(value) { return isArgs; }; -},{}],39:[function(require,module,exports){ +},{}],37:[function(require,module,exports){ +exports.endianness = function () { return 'LE' }; + +exports.hostname = function () { + if (typeof location !== 'undefined') { + return location.hostname + } + else return ''; +}; + +exports.loadavg = function () { return [] }; + +exports.uptime = function () { return 0 }; + +exports.freemem = function () { + return Number.MAX_VALUE; +}; + +exports.totalmem = function () { + return Number.MAX_VALUE; +}; + +exports.cpus = function () { return [] }; + +exports.type = function () { return 'Browser' }; + +exports.release = function () { + if (typeof navigator !== 'undefined') { + return navigator.appVersion; + } + return ''; +}; + +exports.networkInterfaces += exports.getNetworkInterfaces += function () { return {} }; + +exports.arch = function () { return 'javascript' }; + +exports.platform = function () { return 'browser' }; + +exports.tmpdir = exports.tmpDir = function () { + return '/tmp'; +}; + +exports.EOL = '\n'; + +},{}],38:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -4069,7 +4126,7 @@ var substr = 'ab'.substr(-1) === 'b' }).call(this,require('_process')) -},{"_process":41}],40:[function(require,module,exports){ +},{"_process":40}],39:[function(require,module,exports){ (function (process){ 'use strict'; @@ -4117,7 +4174,7 @@ function nextTick(fn, arg1, arg2, arg3) { }).call(this,require('_process')) -},{"_process":41}],41:[function(require,module,exports){ +},{"_process":40}],40:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -4288,6 +4345,10 @@ process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } process.binding = function (name) { throw new Error('process.binding is not supported'); @@ -4299,724 +4360,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],42:[function(require,module,exports){ -(function (global){ -/*! https://mths.be/punycode v1.4.1 by @mathias */ -;(function(root) { - - /** Detect free variables */ - var freeExports = typeof exports == 'object' && exports && - !exports.nodeType && exports; - var freeModule = typeof module == 'object' && module && - !module.nodeType && module; - var freeGlobal = typeof global == 'object' && global; - if ( - freeGlobal.global === freeGlobal || - freeGlobal.window === freeGlobal || - freeGlobal.self === freeGlobal - ) { - root = freeGlobal; - } - - /** - * The `punycode` object. - * @name punycode - * @type Object - */ - var punycode, - - /** Highest positive signed 32-bit float value */ - maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 - - /** Bootstring parameters */ - base = 36, - tMin = 1, - tMax = 26, - skew = 38, - damp = 700, - initialBias = 72, - initialN = 128, // 0x80 - delimiter = '-', // '\x2D' - - /** Regular expressions */ - regexPunycode = /^xn--/, - regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars - regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators - - /** Error messages */ - errors = { - 'overflow': 'Overflow: input needs wider integers to process', - 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', - 'invalid-input': 'Invalid input' - }, - - /** Convenience shortcuts */ - baseMinusTMin = base - tMin, - floor = Math.floor, - stringFromCharCode = String.fromCharCode, - - /** Temporary variable */ - key; - - /*--------------------------------------------------------------------------*/ - - /** - * A generic error utility function. - * @private - * @param {String} type The error type. - * @returns {Error} Throws a `RangeError` with the applicable error message. - */ - function error(type) { - throw new RangeError(errors[type]); - } - - /** - * A generic `Array#map` utility function. - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function that gets called for every array - * item. - * @returns {Array} A new array of values returned by the callback function. - */ - function map(array, fn) { - var length = array.length; - var result = []; - while (length--) { - result[length] = fn(array[length]); - } - return result; - } - - /** - * A simple `Array#map`-like wrapper to work with domain name strings or email - * addresses. - * @private - * @param {String} domain The domain name or email address. - * @param {Function} callback The function that gets called for every - * character. - * @returns {Array} A new string of characters returned by the callback - * function. - */ - function mapDomain(string, fn) { - var parts = string.split('@'); - var result = ''; - if (parts.length > 1) { - // In email addresses, only the domain name should be punycoded. Leave - // the local part (i.e. everything up to `@`) intact. - result = parts[0] + '@'; - string = parts[1]; - } - // Avoid `split(regex)` for IE8 compatibility. See #17. - string = string.replace(regexSeparators, '\x2E'); - var labels = string.split('.'); - var encoded = map(labels, fn).join('.'); - return result + encoded; - } - - /** - * Creates an array containing the numeric code points of each Unicode - * character in the string. While JavaScript uses UCS-2 internally, - * this function will convert a pair of surrogate halves (each of which - * UCS-2 exposes as separate characters) into a single code point, - * matching UTF-16. - * @see `punycode.ucs2.encode` - * @see - * @memberOf punycode.ucs2 - * @name decode - * @param {String} string The Unicode input string (UCS-2). - * @returns {Array} The new array of code points. - */ - function ucs2decode(string) { - var output = [], - counter = 0, - length = string.length, - value, - extra; - while (counter < length) { - value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // high surrogate, and there is a next character - extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // unmatched surrogate; only append this code unit, in case the next - // code unit is the high surrogate of a surrogate pair - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; - } - - /** - * Creates a string based on an array of numeric code points. - * @see `punycode.ucs2.decode` - * @memberOf punycode.ucs2 - * @name encode - * @param {Array} codePoints The array of numeric code points. - * @returns {String} The new Unicode string (UCS-2). - */ - function ucs2encode(array) { - return map(array, function(value) { - var output = ''; - if (value > 0xFFFF) { - value -= 0x10000; - output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); - value = 0xDC00 | value & 0x3FF; - } - output += stringFromCharCode(value); - return output; - }).join(''); - } - - /** - * Converts a basic code point into a digit/integer. - * @see `digitToBasic()` - * @private - * @param {Number} codePoint The basic numeric code point value. - * @returns {Number} The numeric value of a basic code point (for use in - * representing integers) in the range `0` to `base - 1`, or `base` if - * the code point does not represent a value. - */ - function basicToDigit(codePoint) { - if (codePoint - 48 < 10) { - return codePoint - 22; - } - if (codePoint - 65 < 26) { - return codePoint - 65; - } - if (codePoint - 97 < 26) { - return codePoint - 97; - } - return base; - } - - /** - * Converts a digit/integer into a basic code point. - * @see `basicToDigit()` - * @private - * @param {Number} digit The numeric value of a basic code point. - * @returns {Number} The basic code point whose value (when used for - * representing integers) is `digit`, which needs to be in the range - * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is - * used; else, the lowercase form is used. The behavior is undefined - * if `flag` is non-zero and `digit` has no uppercase form. - */ - function digitToBasic(digit, flag) { - // 0..25 map to ASCII a..z or A..Z - // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); - } - - /** - * Bias adaptation function as per section 3.4 of RFC 3492. - * https://tools.ietf.org/html/rfc3492#section-3.4 - * @private - */ - function adapt(delta, numPoints, firstTime) { - var k = 0; - delta = firstTime ? floor(delta / damp) : delta >> 1; - delta += floor(delta / numPoints); - for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { - delta = floor(delta / baseMinusTMin); - } - return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); - } - - /** - * Converts a Punycode string of ASCII-only symbols to a string of Unicode - * symbols. - * @memberOf punycode - * @param {String} input The Punycode string of ASCII-only symbols. - * @returns {String} The resulting string of Unicode symbols. - */ - function decode(input) { - // Don't use UCS-2 - var output = [], - inputLength = input.length, - out, - i = 0, - n = initialN, - bias = initialBias, - basic, - j, - index, - oldi, - w, - k, - digit, - t, - /** Cached calculation results */ - baseMinusT; - - // Handle the basic code points: let `basic` be the number of input code - // points before the last delimiter, or `0` if there is none, then copy - // the first basic code points to the output. - - basic = input.lastIndexOf(delimiter); - if (basic < 0) { - basic = 0; - } - - for (j = 0; j < basic; ++j) { - // if it's not a basic code point - if (input.charCodeAt(j) >= 0x80) { - error('not-basic'); - } - output.push(input.charCodeAt(j)); - } - - // Main decoding loop: start just after the last delimiter if any basic code - // points were copied; start at the beginning otherwise. - - for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { - - // `index` is the index of the next character to be consumed. - // Decode a generalized variable-length integer into `delta`, - // which gets added to `i`. The overflow checking is easier - // if we increase `i` as we go, then subtract off its starting - // value at the end to obtain `delta`. - for (oldi = i, w = 1, k = base; /* no condition */; k += base) { - - if (index >= inputLength) { - error('invalid-input'); - } - - digit = basicToDigit(input.charCodeAt(index++)); - - if (digit >= base || digit > floor((maxInt - i) / w)) { - error('overflow'); - } - - i += digit * w; - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - - if (digit < t) { - break; - } - - baseMinusT = base - t; - if (w > floor(maxInt / baseMinusT)) { - error('overflow'); - } - - w *= baseMinusT; - - } - - out = output.length + 1; - bias = adapt(i - oldi, out, oldi == 0); - - // `i` was supposed to wrap around from `out` to `0`, - // incrementing `n` each time, so we'll fix that now: - if (floor(i / out) > maxInt - n) { - error('overflow'); - } - - n += floor(i / out); - i %= out; - - // Insert `n` at position `i` of the output - output.splice(i++, 0, n); - - } - - return ucs2encode(output); - } - - /** - * Converts a string of Unicode symbols (e.g. a domain name label) to a - * Punycode string of ASCII-only symbols. - * @memberOf punycode - * @param {String} input The string of Unicode symbols. - * @returns {String} The resulting Punycode string of ASCII-only symbols. - */ - function encode(input) { - var n, - delta, - handledCPCount, - basicLength, - bias, - j, - m, - q, - k, - t, - currentValue, - output = [], - /** `inputLength` will hold the number of code points in `input`. */ - inputLength, - /** Cached calculation results */ - handledCPCountPlusOne, - baseMinusT, - qMinusT; - - // Convert the input in UCS-2 to Unicode - input = ucs2decode(input); - - // Cache the length - inputLength = input.length; - - // Initialize the state - n = initialN; - delta = 0; - bias = initialBias; - - // Handle the basic code points - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue < 0x80) { - output.push(stringFromCharCode(currentValue)); - } - } - - handledCPCount = basicLength = output.length; - - // `handledCPCount` is the number of code points that have been handled; - // `basicLength` is the number of basic code points. - - // Finish the basic string - if it is not empty - with a delimiter - if (basicLength) { - output.push(delimiter); - } - - // Main encoding loop: - while (handledCPCount < inputLength) { - - // All non-basic code points < n have been handled already. Find the next - // larger one: - for (m = maxInt, j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue >= n && currentValue < m) { - m = currentValue; - } - } - - // Increase `delta` enough to advance the decoder's state to , - // but guard against overflow - handledCPCountPlusOne = handledCPCount + 1; - if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { - error('overflow'); - } - - delta += (m - n) * handledCPCountPlusOne; - n = m; - - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - - if (currentValue < n && ++delta > maxInt) { - error('overflow'); - } - - if (currentValue == n) { - // Represent delta as a generalized variable-length integer - for (q = delta, k = base; /* no condition */; k += base) { - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - if (q < t) { - break; - } - qMinusT = q - t; - baseMinusT = base - t; - output.push( - stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) - ); - q = floor(qMinusT / baseMinusT); - } - - output.push(stringFromCharCode(digitToBasic(q, 0))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); - delta = 0; - ++handledCPCount; - } - } - - ++delta; - ++n; - - } - return output.join(''); - } - - /** - * Converts a Punycode string representing a domain name or an email address - * to Unicode. Only the Punycoded parts of the input will be converted, i.e. - * it doesn't matter if you call it on a string that has already been - * converted to Unicode. - * @memberOf punycode - * @param {String} input The Punycoded domain name or email address to - * convert to Unicode. - * @returns {String} The Unicode representation of the given Punycode - * string. - */ - function toUnicode(input) { - return mapDomain(input, function(string) { - return regexPunycode.test(string) - ? decode(string.slice(4).toLowerCase()) - : string; - }); - } - - /** - * Converts a Unicode string representing a domain name or an email address to - * Punycode. Only the non-ASCII parts of the domain name will be converted, - * i.e. it doesn't matter if you call it with a domain that's already in - * ASCII. - * @memberOf punycode - * @param {String} input The domain name or email address to convert, as a - * Unicode string. - * @returns {String} The Punycode representation of the given domain name or - * email address. - */ - function toASCII(input) { - return mapDomain(input, function(string) { - return regexNonASCII.test(string) - ? 'xn--' + encode(string) - : string; - }); - } - - /*--------------------------------------------------------------------------*/ - - /** Define the public API */ - punycode = { - /** - * A string representing the current Punycode.js version number. - * @memberOf punycode - * @type String - */ - 'version': '1.4.1', - /** - * An object of methods to convert from JavaScript's internal character - * representation (UCS-2) to Unicode code points, and back. - * @see - * @memberOf punycode - * @type Object - */ - 'ucs2': { - 'decode': ucs2decode, - 'encode': ucs2encode - }, - 'decode': decode, - 'encode': encode, - 'toASCII': toASCII, - 'toUnicode': toUnicode - }; - - /** Expose `punycode` */ - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - typeof define == 'function' && - typeof define.amd == 'object' && - define.amd - ) { - define('punycode', function() { - return punycode; - }); - } else if (freeExports && freeModule) { - if (module.exports == freeExports) { - // in Node.js, io.js, or RingoJS v0.8.0+ - freeModule.exports = punycode; - } else { - // in Narwhal or RingoJS v0.7.0- - for (key in punycode) { - punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); - } - } - } else { - // in Rhino or a web browser - root.punycode = punycode; - } - -}(this)); - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - -},{}],43:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -// If obj.hasOwnProperty has been overridden, then calling -// obj.hasOwnProperty(prop) will break. -// See: https://github.com/joyent/node/issues/1707 -function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -} - -module.exports = function(qs, sep, eq, options) { - sep = sep || '&'; - eq = eq || '='; - var obj = {}; - - if (typeof qs !== 'string' || qs.length === 0) { - return obj; - } - - var regexp = /\+/g; - qs = qs.split(sep); - - var maxKeys = 1000; - if (options && typeof options.maxKeys === 'number') { - maxKeys = options.maxKeys; - } - - var len = qs.length; - // maxKeys <= 0 means that we should not limit keys count - if (maxKeys > 0 && len > maxKeys) { - len = maxKeys; - } - - for (var i = 0; i < len; ++i) { - var x = qs[i].replace(regexp, '%20'), - idx = x.indexOf(eq), - kstr, vstr, k, v; - - if (idx >= 0) { - kstr = x.substr(0, idx); - vstr = x.substr(idx + 1); - } else { - kstr = x; - vstr = ''; - } - - k = decodeURIComponent(kstr); - v = decodeURIComponent(vstr); - - if (!hasOwnProperty(obj, k)) { - obj[k] = v; - } else if (isArray(obj[k])) { - obj[k].push(v); - } else { - obj[k] = [obj[k], v]; - } - } - - return obj; -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -},{}],44:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -var stringifyPrimitive = function(v) { - switch (typeof v) { - case 'string': - return v; - - case 'boolean': - return v ? 'true' : 'false'; - - case 'number': - return isFinite(v) ? v : ''; - - default: - return ''; - } -}; - -module.exports = function(obj, sep, eq, name) { - sep = sep || '&'; - eq = eq || '='; - if (obj === null) { - obj = undefined; - } - - if (typeof obj === 'object') { - return map(objectKeys(obj), function(k) { - var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; - if (isArray(obj[k])) { - return map(obj[k], function(v) { - return ks + encodeURIComponent(stringifyPrimitive(v)); - }).join(sep); - } else { - return ks + encodeURIComponent(stringifyPrimitive(obj[k])); - } - }).join(sep); - - } - - if (!name) return ''; - return encodeURIComponent(stringifyPrimitive(name)) + eq + - encodeURIComponent(stringifyPrimitive(obj)); -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -function map (xs, f) { - if (xs.map) return xs.map(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - res.push(f(xs[i], i)); - } - return res; -} - -var objectKeys = Object.keys || function (obj) { - var res = []; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); - } - return res; -}; - -},{}],45:[function(require,module,exports){ -'use strict'; - -exports.decode = exports.parse = require('./decode'); -exports.encode = exports.stringify = require('./encode'); - -},{"./decode":43,"./encode":44}],46:[function(require,module,exports){ +},{}],41:[function(require,module,exports){ (function (process){ var through = require('through'); var nextTick = typeof setImmediate !== 'undefined' @@ -5050,7 +4394,7 @@ module.exports = function (write, end) { }).call(this,require('_process')) -},{"_process":41,"through":423}],47:[function(require,module,exports){ +},{"_process":40,"through":411}],42:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -5099,7 +4443,7 @@ var AsyncSubject = (function (_super) { }(Subject_1.Subject)); exports.AsyncSubject = AsyncSubject; -},{"./Subject":57,"./Subscription":60}],48:[function(require,module,exports){ +},{"./Subject":52,"./Subscription":55}],43:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -5149,7 +4493,7 @@ var BehaviorSubject = (function (_super) { }(Subject_1.Subject)); exports.BehaviorSubject = BehaviorSubject; -},{"./Subject":57,"./util/ObjectUnsubscribedError":372}],49:[function(require,module,exports){ +},{"./Subject":52,"./util/ObjectUnsubscribedError":367}],44:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -5186,7 +4530,7 @@ var InnerSubscriber = (function (_super) { }(Subscriber_1.Subscriber)); exports.InnerSubscriber = InnerSubscriber; -},{"./Subscriber":59}],50:[function(require,module,exports){ +},{"./Subscriber":54}],45:[function(require,module,exports){ "use strict"; var Observable_1 = require('./Observable'); /** @@ -5314,7 +4658,7 @@ var Notification = (function () { }()); exports.Notification = Notification; -},{"./Observable":51}],51:[function(require,module,exports){ +},{"./Observable":46}],46:[function(require,module,exports){ "use strict"; var root_1 = require('./util/root'); var toSubscriber_1 = require('./util/toSubscriber'); @@ -5455,7 +4799,7 @@ var Observable = (function () { }()); exports.Observable = Observable; -},{"./symbol/observable":358,"./util/root":386,"./util/toSubscriber":388}],52:[function(require,module,exports){ +},{"./symbol/observable":353,"./util/root":381,"./util/toSubscriber":383}],47:[function(require,module,exports){ "use strict"; exports.empty = { closed: true, @@ -5464,7 +4808,7 @@ exports.empty = { complete: function () { } }; -},{}],53:[function(require,module,exports){ +},{}],48:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -5495,7 +4839,7 @@ var OuterSubscriber = (function (_super) { }(Subscriber_1.Subscriber)); exports.OuterSubscriber = OuterSubscriber; -},{"./Subscriber":59}],54:[function(require,module,exports){ +},{"./Subscriber":54}],49:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -5575,7 +4919,7 @@ var ReplayEvent = (function () { return ReplayEvent; }()); -},{"./Subject":57,"./operator/observeOn":294,"./scheduler/queue":356}],55:[function(require,module,exports){ +},{"./Subject":52,"./operator/observeOn":289,"./scheduler/queue":351}],50:[function(require,module,exports){ "use strict"; /* tslint:disable:no-unused-variable */ // Subject imported before Observable to bypass circular dependency issue since @@ -5804,7 +5148,7 @@ var Symbol = { }; exports.Symbol = Symbol; -},{"./AsyncSubject":47,"./BehaviorSubject":48,"./Notification":50,"./Observable":51,"./ReplaySubject":54,"./Subject":57,"./Subscriber":59,"./Subscription":60,"./add/observable/bindCallback":61,"./add/observable/bindNodeCallback":62,"./add/observable/combineLatest":63,"./add/observable/concat":64,"./add/observable/defer":65,"./add/observable/dom/ajax":66,"./add/observable/dom/webSocket":67,"./add/observable/empty":68,"./add/observable/forkJoin":69,"./add/observable/from":70,"./add/observable/fromEvent":71,"./add/observable/fromEventPattern":72,"./add/observable/fromPromise":73,"./add/observable/generate":74,"./add/observable/if":75,"./add/observable/interval":76,"./add/observable/merge":77,"./add/observable/never":78,"./add/observable/of":79,"./add/observable/onErrorResumeNext":80,"./add/observable/pairs":81,"./add/observable/race":82,"./add/observable/range":83,"./add/observable/throw":84,"./add/observable/timer":85,"./add/observable/using":86,"./add/observable/zip":87,"./add/operator/audit":88,"./add/operator/auditTime":89,"./add/operator/buffer":90,"./add/operator/bufferCount":91,"./add/operator/bufferTime":92,"./add/operator/bufferToggle":93,"./add/operator/bufferWhen":94,"./add/operator/cache":95,"./add/operator/catch":96,"./add/operator/combineAll":97,"./add/operator/combineLatest":98,"./add/operator/concat":99,"./add/operator/concatAll":100,"./add/operator/concatMap":101,"./add/operator/concatMapTo":102,"./add/operator/count":103,"./add/operator/debounce":104,"./add/operator/debounceTime":105,"./add/operator/defaultIfEmpty":106,"./add/operator/delay":107,"./add/operator/delayWhen":108,"./add/operator/dematerialize":109,"./add/operator/distinct":110,"./add/operator/distinctKey":111,"./add/operator/distinctUntilChanged":112,"./add/operator/distinctUntilKeyChanged":113,"./add/operator/do":114,"./add/operator/elementAt":115,"./add/operator/every":116,"./add/operator/exhaust":117,"./add/operator/exhaustMap":118,"./add/operator/expand":119,"./add/operator/filter":120,"./add/operator/finally":121,"./add/operator/find":122,"./add/operator/findIndex":123,"./add/operator/first":124,"./add/operator/groupBy":125,"./add/operator/ignoreElements":126,"./add/operator/isEmpty":127,"./add/operator/last":128,"./add/operator/let":129,"./add/operator/map":130,"./add/operator/mapTo":131,"./add/operator/materialize":132,"./add/operator/max":133,"./add/operator/merge":134,"./add/operator/mergeAll":135,"./add/operator/mergeMap":136,"./add/operator/mergeMapTo":137,"./add/operator/mergeScan":138,"./add/operator/min":139,"./add/operator/multicast":140,"./add/operator/observeOn":141,"./add/operator/onErrorResumeNext":142,"./add/operator/pairwise":143,"./add/operator/partition":144,"./add/operator/pluck":145,"./add/operator/publish":146,"./add/operator/publishBehavior":147,"./add/operator/publishLast":148,"./add/operator/publishReplay":149,"./add/operator/race":150,"./add/operator/reduce":151,"./add/operator/repeat":152,"./add/operator/repeatWhen":153,"./add/operator/retry":154,"./add/operator/retryWhen":155,"./add/operator/sample":156,"./add/operator/sampleTime":157,"./add/operator/scan":158,"./add/operator/sequenceEqual":159,"./add/operator/share":160,"./add/operator/single":161,"./add/operator/skip":162,"./add/operator/skipUntil":163,"./add/operator/skipWhile":164,"./add/operator/startWith":165,"./add/operator/subscribeOn":166,"./add/operator/switch":167,"./add/operator/switchMap":168,"./add/operator/switchMapTo":169,"./add/operator/take":170,"./add/operator/takeLast":171,"./add/operator/takeUntil":172,"./add/operator/takeWhile":173,"./add/operator/throttle":174,"./add/operator/throttleTime":175,"./add/operator/timeInterval":176,"./add/operator/timeout":177,"./add/operator/timeoutWith":178,"./add/operator/timestamp":179,"./add/operator/toArray":180,"./add/operator/toPromise":181,"./add/operator/window":182,"./add/operator/windowCount":183,"./add/operator/windowTime":184,"./add/operator/windowToggle":185,"./add/operator/windowWhen":186,"./add/operator/withLatestFrom":187,"./add/operator/zip":188,"./add/operator/zipAll":189,"./observable/ConnectableObservable":194,"./observable/MulticastObservable":206,"./observable/dom/AjaxObservable":220,"./operator/timeInterval":329,"./operator/timestamp":332,"./scheduler/VirtualTimeScheduler":352,"./scheduler/animationFrame":353,"./scheduler/asap":354,"./scheduler/async":355,"./scheduler/queue":356,"./symbol/iterator":357,"./symbol/observable":358,"./symbol/rxSubscriber":359,"./testing/TestScheduler":364,"./util/ArgumentOutOfRangeError":366,"./util/EmptyError":367,"./util/ObjectUnsubscribedError":372,"./util/UnsubscriptionError":373}],56:[function(require,module,exports){ +},{"./AsyncSubject":42,"./BehaviorSubject":43,"./Notification":45,"./Observable":46,"./ReplaySubject":49,"./Subject":52,"./Subscriber":54,"./Subscription":55,"./add/observable/bindCallback":56,"./add/observable/bindNodeCallback":57,"./add/observable/combineLatest":58,"./add/observable/concat":59,"./add/observable/defer":60,"./add/observable/dom/ajax":61,"./add/observable/dom/webSocket":62,"./add/observable/empty":63,"./add/observable/forkJoin":64,"./add/observable/from":65,"./add/observable/fromEvent":66,"./add/observable/fromEventPattern":67,"./add/observable/fromPromise":68,"./add/observable/generate":69,"./add/observable/if":70,"./add/observable/interval":71,"./add/observable/merge":72,"./add/observable/never":73,"./add/observable/of":74,"./add/observable/onErrorResumeNext":75,"./add/observable/pairs":76,"./add/observable/race":77,"./add/observable/range":78,"./add/observable/throw":79,"./add/observable/timer":80,"./add/observable/using":81,"./add/observable/zip":82,"./add/operator/audit":83,"./add/operator/auditTime":84,"./add/operator/buffer":85,"./add/operator/bufferCount":86,"./add/operator/bufferTime":87,"./add/operator/bufferToggle":88,"./add/operator/bufferWhen":89,"./add/operator/cache":90,"./add/operator/catch":91,"./add/operator/combineAll":92,"./add/operator/combineLatest":93,"./add/operator/concat":94,"./add/operator/concatAll":95,"./add/operator/concatMap":96,"./add/operator/concatMapTo":97,"./add/operator/count":98,"./add/operator/debounce":99,"./add/operator/debounceTime":100,"./add/operator/defaultIfEmpty":101,"./add/operator/delay":102,"./add/operator/delayWhen":103,"./add/operator/dematerialize":104,"./add/operator/distinct":105,"./add/operator/distinctKey":106,"./add/operator/distinctUntilChanged":107,"./add/operator/distinctUntilKeyChanged":108,"./add/operator/do":109,"./add/operator/elementAt":110,"./add/operator/every":111,"./add/operator/exhaust":112,"./add/operator/exhaustMap":113,"./add/operator/expand":114,"./add/operator/filter":115,"./add/operator/finally":116,"./add/operator/find":117,"./add/operator/findIndex":118,"./add/operator/first":119,"./add/operator/groupBy":120,"./add/operator/ignoreElements":121,"./add/operator/isEmpty":122,"./add/operator/last":123,"./add/operator/let":124,"./add/operator/map":125,"./add/operator/mapTo":126,"./add/operator/materialize":127,"./add/operator/max":128,"./add/operator/merge":129,"./add/operator/mergeAll":130,"./add/operator/mergeMap":131,"./add/operator/mergeMapTo":132,"./add/operator/mergeScan":133,"./add/operator/min":134,"./add/operator/multicast":135,"./add/operator/observeOn":136,"./add/operator/onErrorResumeNext":137,"./add/operator/pairwise":138,"./add/operator/partition":139,"./add/operator/pluck":140,"./add/operator/publish":141,"./add/operator/publishBehavior":142,"./add/operator/publishLast":143,"./add/operator/publishReplay":144,"./add/operator/race":145,"./add/operator/reduce":146,"./add/operator/repeat":147,"./add/operator/repeatWhen":148,"./add/operator/retry":149,"./add/operator/retryWhen":150,"./add/operator/sample":151,"./add/operator/sampleTime":152,"./add/operator/scan":153,"./add/operator/sequenceEqual":154,"./add/operator/share":155,"./add/operator/single":156,"./add/operator/skip":157,"./add/operator/skipUntil":158,"./add/operator/skipWhile":159,"./add/operator/startWith":160,"./add/operator/subscribeOn":161,"./add/operator/switch":162,"./add/operator/switchMap":163,"./add/operator/switchMapTo":164,"./add/operator/take":165,"./add/operator/takeLast":166,"./add/operator/takeUntil":167,"./add/operator/takeWhile":168,"./add/operator/throttle":169,"./add/operator/throttleTime":170,"./add/operator/timeInterval":171,"./add/operator/timeout":172,"./add/operator/timeoutWith":173,"./add/operator/timestamp":174,"./add/operator/toArray":175,"./add/operator/toPromise":176,"./add/operator/window":177,"./add/operator/windowCount":178,"./add/operator/windowTime":179,"./add/operator/windowToggle":180,"./add/operator/windowWhen":181,"./add/operator/withLatestFrom":182,"./add/operator/zip":183,"./add/operator/zipAll":184,"./observable/ConnectableObservable":189,"./observable/MulticastObservable":201,"./observable/dom/AjaxObservable":215,"./operator/timeInterval":324,"./operator/timestamp":327,"./scheduler/VirtualTimeScheduler":347,"./scheduler/animationFrame":348,"./scheduler/asap":349,"./scheduler/async":350,"./scheduler/queue":351,"./symbol/iterator":352,"./symbol/observable":353,"./symbol/rxSubscriber":354,"./testing/TestScheduler":359,"./util/ArgumentOutOfRangeError":361,"./util/EmptyError":362,"./util/ObjectUnsubscribedError":367,"./util/UnsubscriptionError":368}],51:[function(require,module,exports){ "use strict"; /** * An execution context and a data structure to order tasks and schedule their @@ -5854,7 +5198,7 @@ var Scheduler = (function () { }()); exports.Scheduler = Scheduler; -},{}],57:[function(require,module,exports){ +},{}],52:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -6015,7 +5359,7 @@ var AnonymousSubject = (function (_super) { }(Subject)); exports.AnonymousSubject = AnonymousSubject; -},{"./Observable":51,"./SubjectSubscription":58,"./Subscriber":59,"./Subscription":60,"./symbol/rxSubscriber":359,"./util/ObjectUnsubscribedError":372}],58:[function(require,module,exports){ +},{"./Observable":46,"./SubjectSubscription":53,"./Subscriber":54,"./Subscription":55,"./symbol/rxSubscriber":354,"./util/ObjectUnsubscribedError":367}],53:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -6056,7 +5400,7 @@ var SubjectSubscription = (function (_super) { }(Subscription_1.Subscription)); exports.SubjectSubscription = SubjectSubscription; -},{"./Subscription":60}],59:[function(require,module,exports){ +},{"./Subscription":55}],54:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -6306,7 +5650,7 @@ var SafeSubscriber = (function (_super) { return SafeSubscriber; }(Subscriber)); -},{"./Observer":52,"./Subscription":60,"./symbol/rxSubscriber":359,"./util/isFunction":379}],60:[function(require,module,exports){ +},{"./Observer":47,"./Subscription":55,"./symbol/rxSubscriber":354,"./util/isFunction":374}],55:[function(require,module,exports){ "use strict"; var isArray_1 = require('./util/isArray'); var isObject_1 = require('./util/isObject'); @@ -6460,788 +5804,788 @@ var Subscription = (function () { }()); exports.Subscription = Subscription; -},{"./util/UnsubscriptionError":373,"./util/errorObject":376,"./util/isArray":377,"./util/isFunction":379,"./util/isObject":381,"./util/tryCatch":389}],61:[function(require,module,exports){ +},{"./util/UnsubscriptionError":368,"./util/errorObject":371,"./util/isArray":372,"./util/isFunction":374,"./util/isObject":376,"./util/tryCatch":384}],56:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var bindCallback_1 = require('../../observable/bindCallback'); Observable_1.Observable.bindCallback = bindCallback_1.bindCallback; -},{"../../Observable":51,"../../observable/bindCallback":215}],62:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/bindCallback":210}],57:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var bindNodeCallback_1 = require('../../observable/bindNodeCallback'); Observable_1.Observable.bindNodeCallback = bindNodeCallback_1.bindNodeCallback; -},{"../../Observable":51,"../../observable/bindNodeCallback":216}],63:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/bindNodeCallback":211}],58:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var combineLatest_1 = require('../../observable/combineLatest'); Observable_1.Observable.combineLatest = combineLatest_1.combineLatest; -},{"../../Observable":51,"../../observable/combineLatest":217}],64:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/combineLatest":212}],59:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var concat_1 = require('../../observable/concat'); Observable_1.Observable.concat = concat_1.concat; -},{"../../Observable":51,"../../observable/concat":218}],65:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/concat":213}],60:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var defer_1 = require('../../observable/defer'); Observable_1.Observable.defer = defer_1.defer; -},{"../../Observable":51,"../../observable/defer":219}],66:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/defer":214}],61:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../../Observable'); var ajax_1 = require('../../../observable/dom/ajax'); Observable_1.Observable.ajax = ajax_1.ajax; -},{"../../../Observable":51,"../../../observable/dom/ajax":222}],67:[function(require,module,exports){ +},{"../../../Observable":46,"../../../observable/dom/ajax":217}],62:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../../Observable'); var webSocket_1 = require('../../../observable/dom/webSocket'); Observable_1.Observable.webSocket = webSocket_1.webSocket; -},{"../../../Observable":51,"../../../observable/dom/webSocket":223}],68:[function(require,module,exports){ +},{"../../../Observable":46,"../../../observable/dom/webSocket":218}],63:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var empty_1 = require('../../observable/empty'); Observable_1.Observable.empty = empty_1.empty; -},{"../../Observable":51,"../../observable/empty":224}],69:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/empty":219}],64:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var forkJoin_1 = require('../../observable/forkJoin'); Observable_1.Observable.forkJoin = forkJoin_1.forkJoin; -},{"../../Observable":51,"../../observable/forkJoin":225}],70:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/forkJoin":220}],65:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var from_1 = require('../../observable/from'); Observable_1.Observable.from = from_1.from; -},{"../../Observable":51,"../../observable/from":226}],71:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/from":221}],66:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var fromEvent_1 = require('../../observable/fromEvent'); Observable_1.Observable.fromEvent = fromEvent_1.fromEvent; -},{"../../Observable":51,"../../observable/fromEvent":227}],72:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/fromEvent":222}],67:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var fromEventPattern_1 = require('../../observable/fromEventPattern'); Observable_1.Observable.fromEventPattern = fromEventPattern_1.fromEventPattern; -},{"../../Observable":51,"../../observable/fromEventPattern":228}],73:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/fromEventPattern":223}],68:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var fromPromise_1 = require('../../observable/fromPromise'); Observable_1.Observable.fromPromise = fromPromise_1.fromPromise; -},{"../../Observable":51,"../../observable/fromPromise":229}],74:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/fromPromise":224}],69:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var GenerateObservable_1 = require('../../observable/GenerateObservable'); Observable_1.Observable.generate = GenerateObservable_1.GenerateObservable.create; -},{"../../Observable":51,"../../observable/GenerateObservable":202}],75:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/GenerateObservable":197}],70:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var if_1 = require('../../observable/if'); Observable_1.Observable.if = if_1._if; -},{"../../Observable":51,"../../observable/if":230}],76:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/if":225}],71:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var interval_1 = require('../../observable/interval'); Observable_1.Observable.interval = interval_1.interval; -},{"../../Observable":51,"../../observable/interval":231}],77:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/interval":226}],72:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var merge_1 = require('../../observable/merge'); Observable_1.Observable.merge = merge_1.merge; -},{"../../Observable":51,"../../observable/merge":232}],78:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/merge":227}],73:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var never_1 = require('../../observable/never'); Observable_1.Observable.never = never_1.never; -},{"../../Observable":51,"../../observable/never":233}],79:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/never":228}],74:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var of_1 = require('../../observable/of'); Observable_1.Observable.of = of_1.of; -},{"../../Observable":51,"../../observable/of":234}],80:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/of":229}],75:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var onErrorResumeNext_1 = require('../../operator/onErrorResumeNext'); Observable_1.Observable.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNextStatic; -},{"../../Observable":51,"../../operator/onErrorResumeNext":295}],81:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/onErrorResumeNext":290}],76:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var pairs_1 = require('../../observable/pairs'); Observable_1.Observable.pairs = pairs_1.pairs; -},{"../../Observable":51,"../../observable/pairs":235}],82:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/pairs":230}],77:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var race_1 = require('../../operator/race'); Observable_1.Observable.race = race_1.raceStatic; -},{"../../Observable":51,"../../operator/race":303}],83:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/race":298}],78:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var range_1 = require('../../observable/range'); Observable_1.Observable.range = range_1.range; -},{"../../Observable":51,"../../observable/range":236}],84:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/range":231}],79:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var throw_1 = require('../../observable/throw'); Observable_1.Observable.throw = throw_1._throw; -},{"../../Observable":51,"../../observable/throw":237}],85:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/throw":232}],80:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var timer_1 = require('../../observable/timer'); Observable_1.Observable.timer = timer_1.timer; -},{"../../Observable":51,"../../observable/timer":238}],86:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/timer":233}],81:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var using_1 = require('../../observable/using'); Observable_1.Observable.using = using_1.using; -},{"../../Observable":51,"../../observable/using":239}],87:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/using":234}],82:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var zip_1 = require('../../observable/zip'); Observable_1.Observable.zip = zip_1.zip; -},{"../../Observable":51,"../../observable/zip":240}],88:[function(require,module,exports){ +},{"../../Observable":46,"../../observable/zip":235}],83:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var audit_1 = require('../../operator/audit'); Observable_1.Observable.prototype.audit = audit_1.audit; -},{"../../Observable":51,"../../operator/audit":241}],89:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/audit":236}],84:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var auditTime_1 = require('../../operator/auditTime'); Observable_1.Observable.prototype.auditTime = auditTime_1.auditTime; -},{"../../Observable":51,"../../operator/auditTime":242}],90:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/auditTime":237}],85:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var buffer_1 = require('../../operator/buffer'); Observable_1.Observable.prototype.buffer = buffer_1.buffer; -},{"../../Observable":51,"../../operator/buffer":243}],91:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/buffer":238}],86:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var bufferCount_1 = require('../../operator/bufferCount'); Observable_1.Observable.prototype.bufferCount = bufferCount_1.bufferCount; -},{"../../Observable":51,"../../operator/bufferCount":244}],92:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/bufferCount":239}],87:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var bufferTime_1 = require('../../operator/bufferTime'); Observable_1.Observable.prototype.bufferTime = bufferTime_1.bufferTime; -},{"../../Observable":51,"../../operator/bufferTime":245}],93:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/bufferTime":240}],88:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var bufferToggle_1 = require('../../operator/bufferToggle'); Observable_1.Observable.prototype.bufferToggle = bufferToggle_1.bufferToggle; -},{"../../Observable":51,"../../operator/bufferToggle":246}],94:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/bufferToggle":241}],89:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var bufferWhen_1 = require('../../operator/bufferWhen'); Observable_1.Observable.prototype.bufferWhen = bufferWhen_1.bufferWhen; -},{"../../Observable":51,"../../operator/bufferWhen":247}],95:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/bufferWhen":242}],90:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var cache_1 = require('../../operator/cache'); Observable_1.Observable.prototype.cache = cache_1.cache; -},{"../../Observable":51,"../../operator/cache":248}],96:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/cache":243}],91:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var catch_1 = require('../../operator/catch'); Observable_1.Observable.prototype.catch = catch_1._catch; Observable_1.Observable.prototype._catch = catch_1._catch; -},{"../../Observable":51,"../../operator/catch":249}],97:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/catch":244}],92:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var combineAll_1 = require('../../operator/combineAll'); Observable_1.Observable.prototype.combineAll = combineAll_1.combineAll; -},{"../../Observable":51,"../../operator/combineAll":250}],98:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/combineAll":245}],93:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var combineLatest_1 = require('../../operator/combineLatest'); Observable_1.Observable.prototype.combineLatest = combineLatest_1.combineLatest; -},{"../../Observable":51,"../../operator/combineLatest":251}],99:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/combineLatest":246}],94:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var concat_1 = require('../../operator/concat'); Observable_1.Observable.prototype.concat = concat_1.concat; -},{"../../Observable":51,"../../operator/concat":252}],100:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/concat":247}],95:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var concatAll_1 = require('../../operator/concatAll'); Observable_1.Observable.prototype.concatAll = concatAll_1.concatAll; -},{"../../Observable":51,"../../operator/concatAll":253}],101:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/concatAll":248}],96:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var concatMap_1 = require('../../operator/concatMap'); Observable_1.Observable.prototype.concatMap = concatMap_1.concatMap; -},{"../../Observable":51,"../../operator/concatMap":254}],102:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/concatMap":249}],97:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var concatMapTo_1 = require('../../operator/concatMapTo'); Observable_1.Observable.prototype.concatMapTo = concatMapTo_1.concatMapTo; -},{"../../Observable":51,"../../operator/concatMapTo":255}],103:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/concatMapTo":250}],98:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var count_1 = require('../../operator/count'); Observable_1.Observable.prototype.count = count_1.count; -},{"../../Observable":51,"../../operator/count":256}],104:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/count":251}],99:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var debounce_1 = require('../../operator/debounce'); Observable_1.Observable.prototype.debounce = debounce_1.debounce; -},{"../../Observable":51,"../../operator/debounce":257}],105:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/debounce":252}],100:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var debounceTime_1 = require('../../operator/debounceTime'); Observable_1.Observable.prototype.debounceTime = debounceTime_1.debounceTime; -},{"../../Observable":51,"../../operator/debounceTime":258}],106:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/debounceTime":253}],101:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var defaultIfEmpty_1 = require('../../operator/defaultIfEmpty'); Observable_1.Observable.prototype.defaultIfEmpty = defaultIfEmpty_1.defaultIfEmpty; -},{"../../Observable":51,"../../operator/defaultIfEmpty":259}],107:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/defaultIfEmpty":254}],102:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var delay_1 = require('../../operator/delay'); Observable_1.Observable.prototype.delay = delay_1.delay; -},{"../../Observable":51,"../../operator/delay":260}],108:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/delay":255}],103:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var delayWhen_1 = require('../../operator/delayWhen'); Observable_1.Observable.prototype.delayWhen = delayWhen_1.delayWhen; -},{"../../Observable":51,"../../operator/delayWhen":261}],109:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/delayWhen":256}],104:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var dematerialize_1 = require('../../operator/dematerialize'); Observable_1.Observable.prototype.dematerialize = dematerialize_1.dematerialize; -},{"../../Observable":51,"../../operator/dematerialize":262}],110:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/dematerialize":257}],105:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var distinct_1 = require('../../operator/distinct'); Observable_1.Observable.prototype.distinct = distinct_1.distinct; -},{"../../Observable":51,"../../operator/distinct":263}],111:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/distinct":258}],106:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var distinctKey_1 = require('../../operator/distinctKey'); Observable_1.Observable.prototype.distinctKey = distinctKey_1.distinctKey; -},{"../../Observable":51,"../../operator/distinctKey":264}],112:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/distinctKey":259}],107:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var distinctUntilChanged_1 = require('../../operator/distinctUntilChanged'); Observable_1.Observable.prototype.distinctUntilChanged = distinctUntilChanged_1.distinctUntilChanged; -},{"../../Observable":51,"../../operator/distinctUntilChanged":265}],113:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/distinctUntilChanged":260}],108:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var distinctUntilKeyChanged_1 = require('../../operator/distinctUntilKeyChanged'); Observable_1.Observable.prototype.distinctUntilKeyChanged = distinctUntilKeyChanged_1.distinctUntilKeyChanged; -},{"../../Observable":51,"../../operator/distinctUntilKeyChanged":266}],114:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/distinctUntilKeyChanged":261}],109:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var do_1 = require('../../operator/do'); Observable_1.Observable.prototype.do = do_1._do; Observable_1.Observable.prototype._do = do_1._do; -},{"../../Observable":51,"../../operator/do":267}],115:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/do":262}],110:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var elementAt_1 = require('../../operator/elementAt'); Observable_1.Observable.prototype.elementAt = elementAt_1.elementAt; -},{"../../Observable":51,"../../operator/elementAt":268}],116:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/elementAt":263}],111:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var every_1 = require('../../operator/every'); Observable_1.Observable.prototype.every = every_1.every; -},{"../../Observable":51,"../../operator/every":269}],117:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/every":264}],112:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var exhaust_1 = require('../../operator/exhaust'); Observable_1.Observable.prototype.exhaust = exhaust_1.exhaust; -},{"../../Observable":51,"../../operator/exhaust":270}],118:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/exhaust":265}],113:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var exhaustMap_1 = require('../../operator/exhaustMap'); Observable_1.Observable.prototype.exhaustMap = exhaustMap_1.exhaustMap; -},{"../../Observable":51,"../../operator/exhaustMap":271}],119:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/exhaustMap":266}],114:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var expand_1 = require('../../operator/expand'); Observable_1.Observable.prototype.expand = expand_1.expand; -},{"../../Observable":51,"../../operator/expand":272}],120:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/expand":267}],115:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var filter_1 = require('../../operator/filter'); Observable_1.Observable.prototype.filter = filter_1.filter; -},{"../../Observable":51,"../../operator/filter":273}],121:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/filter":268}],116:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var finally_1 = require('../../operator/finally'); Observable_1.Observable.prototype.finally = finally_1._finally; Observable_1.Observable.prototype._finally = finally_1._finally; -},{"../../Observable":51,"../../operator/finally":274}],122:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/finally":269}],117:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var find_1 = require('../../operator/find'); Observable_1.Observable.prototype.find = find_1.find; -},{"../../Observable":51,"../../operator/find":275}],123:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/find":270}],118:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var findIndex_1 = require('../../operator/findIndex'); Observable_1.Observable.prototype.findIndex = findIndex_1.findIndex; -},{"../../Observable":51,"../../operator/findIndex":276}],124:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/findIndex":271}],119:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var first_1 = require('../../operator/first'); Observable_1.Observable.prototype.first = first_1.first; -},{"../../Observable":51,"../../operator/first":277}],125:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/first":272}],120:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var groupBy_1 = require('../../operator/groupBy'); Observable_1.Observable.prototype.groupBy = groupBy_1.groupBy; -},{"../../Observable":51,"../../operator/groupBy":278}],126:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/groupBy":273}],121:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var ignoreElements_1 = require('../../operator/ignoreElements'); Observable_1.Observable.prototype.ignoreElements = ignoreElements_1.ignoreElements; -},{"../../Observable":51,"../../operator/ignoreElements":279}],127:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/ignoreElements":274}],122:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var isEmpty_1 = require('../../operator/isEmpty'); Observable_1.Observable.prototype.isEmpty = isEmpty_1.isEmpty; -},{"../../Observable":51,"../../operator/isEmpty":280}],128:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/isEmpty":275}],123:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var last_1 = require('../../operator/last'); Observable_1.Observable.prototype.last = last_1.last; -},{"../../Observable":51,"../../operator/last":281}],129:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/last":276}],124:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var let_1 = require('../../operator/let'); Observable_1.Observable.prototype.let = let_1.letProto; Observable_1.Observable.prototype.letBind = let_1.letProto; -},{"../../Observable":51,"../../operator/let":282}],130:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/let":277}],125:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var map_1 = require('../../operator/map'); Observable_1.Observable.prototype.map = map_1.map; -},{"../../Observable":51,"../../operator/map":283}],131:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/map":278}],126:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var mapTo_1 = require('../../operator/mapTo'); Observable_1.Observable.prototype.mapTo = mapTo_1.mapTo; -},{"../../Observable":51,"../../operator/mapTo":284}],132:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/mapTo":279}],127:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var materialize_1 = require('../../operator/materialize'); Observable_1.Observable.prototype.materialize = materialize_1.materialize; -},{"../../Observable":51,"../../operator/materialize":285}],133:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/materialize":280}],128:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var max_1 = require('../../operator/max'); Observable_1.Observable.prototype.max = max_1.max; -},{"../../Observable":51,"../../operator/max":286}],134:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/max":281}],129:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var merge_1 = require('../../operator/merge'); Observable_1.Observable.prototype.merge = merge_1.merge; -},{"../../Observable":51,"../../operator/merge":287}],135:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/merge":282}],130:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var mergeAll_1 = require('../../operator/mergeAll'); Observable_1.Observable.prototype.mergeAll = mergeAll_1.mergeAll; -},{"../../Observable":51,"../../operator/mergeAll":288}],136:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/mergeAll":283}],131:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var mergeMap_1 = require('../../operator/mergeMap'); Observable_1.Observable.prototype.mergeMap = mergeMap_1.mergeMap; Observable_1.Observable.prototype.flatMap = mergeMap_1.mergeMap; -},{"../../Observable":51,"../../operator/mergeMap":289}],137:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/mergeMap":284}],132:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var mergeMapTo_1 = require('../../operator/mergeMapTo'); Observable_1.Observable.prototype.flatMapTo = mergeMapTo_1.mergeMapTo; Observable_1.Observable.prototype.mergeMapTo = mergeMapTo_1.mergeMapTo; -},{"../../Observable":51,"../../operator/mergeMapTo":290}],138:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/mergeMapTo":285}],133:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var mergeScan_1 = require('../../operator/mergeScan'); Observable_1.Observable.prototype.mergeScan = mergeScan_1.mergeScan; -},{"../../Observable":51,"../../operator/mergeScan":291}],139:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/mergeScan":286}],134:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var min_1 = require('../../operator/min'); Observable_1.Observable.prototype.min = min_1.min; -},{"../../Observable":51,"../../operator/min":292}],140:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/min":287}],135:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var multicast_1 = require('../../operator/multicast'); Observable_1.Observable.prototype.multicast = multicast_1.multicast; -},{"../../Observable":51,"../../operator/multicast":293}],141:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/multicast":288}],136:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var observeOn_1 = require('../../operator/observeOn'); Observable_1.Observable.prototype.observeOn = observeOn_1.observeOn; -},{"../../Observable":51,"../../operator/observeOn":294}],142:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/observeOn":289}],137:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var onErrorResumeNext_1 = require('../../operator/onErrorResumeNext'); Observable_1.Observable.prototype.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext; -},{"../../Observable":51,"../../operator/onErrorResumeNext":295}],143:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/onErrorResumeNext":290}],138:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var pairwise_1 = require('../../operator/pairwise'); Observable_1.Observable.prototype.pairwise = pairwise_1.pairwise; -},{"../../Observable":51,"../../operator/pairwise":296}],144:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/pairwise":291}],139:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var partition_1 = require('../../operator/partition'); Observable_1.Observable.prototype.partition = partition_1.partition; -},{"../../Observable":51,"../../operator/partition":297}],145:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/partition":292}],140:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var pluck_1 = require('../../operator/pluck'); Observable_1.Observable.prototype.pluck = pluck_1.pluck; -},{"../../Observable":51,"../../operator/pluck":298}],146:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/pluck":293}],141:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var publish_1 = require('../../operator/publish'); Observable_1.Observable.prototype.publish = publish_1.publish; -},{"../../Observable":51,"../../operator/publish":299}],147:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/publish":294}],142:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var publishBehavior_1 = require('../../operator/publishBehavior'); Observable_1.Observable.prototype.publishBehavior = publishBehavior_1.publishBehavior; -},{"../../Observable":51,"../../operator/publishBehavior":300}],148:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/publishBehavior":295}],143:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var publishLast_1 = require('../../operator/publishLast'); Observable_1.Observable.prototype.publishLast = publishLast_1.publishLast; -},{"../../Observable":51,"../../operator/publishLast":301}],149:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/publishLast":296}],144:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var publishReplay_1 = require('../../operator/publishReplay'); Observable_1.Observable.prototype.publishReplay = publishReplay_1.publishReplay; -},{"../../Observable":51,"../../operator/publishReplay":302}],150:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/publishReplay":297}],145:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var race_1 = require('../../operator/race'); Observable_1.Observable.prototype.race = race_1.race; -},{"../../Observable":51,"../../operator/race":303}],151:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/race":298}],146:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var reduce_1 = require('../../operator/reduce'); Observable_1.Observable.prototype.reduce = reduce_1.reduce; -},{"../../Observable":51,"../../operator/reduce":304}],152:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/reduce":299}],147:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var repeat_1 = require('../../operator/repeat'); Observable_1.Observable.prototype.repeat = repeat_1.repeat; -},{"../../Observable":51,"../../operator/repeat":305}],153:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/repeat":300}],148:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var repeatWhen_1 = require('../../operator/repeatWhen'); Observable_1.Observable.prototype.repeatWhen = repeatWhen_1.repeatWhen; -},{"../../Observable":51,"../../operator/repeatWhen":306}],154:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/repeatWhen":301}],149:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var retry_1 = require('../../operator/retry'); Observable_1.Observable.prototype.retry = retry_1.retry; -},{"../../Observable":51,"../../operator/retry":307}],155:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/retry":302}],150:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var retryWhen_1 = require('../../operator/retryWhen'); Observable_1.Observable.prototype.retryWhen = retryWhen_1.retryWhen; -},{"../../Observable":51,"../../operator/retryWhen":308}],156:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/retryWhen":303}],151:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var sample_1 = require('../../operator/sample'); Observable_1.Observable.prototype.sample = sample_1.sample; -},{"../../Observable":51,"../../operator/sample":309}],157:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/sample":304}],152:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var sampleTime_1 = require('../../operator/sampleTime'); Observable_1.Observable.prototype.sampleTime = sampleTime_1.sampleTime; -},{"../../Observable":51,"../../operator/sampleTime":310}],158:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/sampleTime":305}],153:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var scan_1 = require('../../operator/scan'); Observable_1.Observable.prototype.scan = scan_1.scan; -},{"../../Observable":51,"../../operator/scan":311}],159:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/scan":306}],154:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var sequenceEqual_1 = require('../../operator/sequenceEqual'); Observable_1.Observable.prototype.sequenceEqual = sequenceEqual_1.sequenceEqual; -},{"../../Observable":51,"../../operator/sequenceEqual":312}],160:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/sequenceEqual":307}],155:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var share_1 = require('../../operator/share'); Observable_1.Observable.prototype.share = share_1.share; -},{"../../Observable":51,"../../operator/share":313}],161:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/share":308}],156:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var single_1 = require('../../operator/single'); Observable_1.Observable.prototype.single = single_1.single; -},{"../../Observable":51,"../../operator/single":314}],162:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/single":309}],157:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var skip_1 = require('../../operator/skip'); Observable_1.Observable.prototype.skip = skip_1.skip; -},{"../../Observable":51,"../../operator/skip":315}],163:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/skip":310}],158:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var skipUntil_1 = require('../../operator/skipUntil'); Observable_1.Observable.prototype.skipUntil = skipUntil_1.skipUntil; -},{"../../Observable":51,"../../operator/skipUntil":316}],164:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/skipUntil":311}],159:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var skipWhile_1 = require('../../operator/skipWhile'); Observable_1.Observable.prototype.skipWhile = skipWhile_1.skipWhile; -},{"../../Observable":51,"../../operator/skipWhile":317}],165:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/skipWhile":312}],160:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var startWith_1 = require('../../operator/startWith'); Observable_1.Observable.prototype.startWith = startWith_1.startWith; -},{"../../Observable":51,"../../operator/startWith":318}],166:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/startWith":313}],161:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var subscribeOn_1 = require('../../operator/subscribeOn'); Observable_1.Observable.prototype.subscribeOn = subscribeOn_1.subscribeOn; -},{"../../Observable":51,"../../operator/subscribeOn":319}],167:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/subscribeOn":314}],162:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var switch_1 = require('../../operator/switch'); Observable_1.Observable.prototype.switch = switch_1._switch; Observable_1.Observable.prototype._switch = switch_1._switch; -},{"../../Observable":51,"../../operator/switch":320}],168:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/switch":315}],163:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var switchMap_1 = require('../../operator/switchMap'); Observable_1.Observable.prototype.switchMap = switchMap_1.switchMap; -},{"../../Observable":51,"../../operator/switchMap":321}],169:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/switchMap":316}],164:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var switchMapTo_1 = require('../../operator/switchMapTo'); Observable_1.Observable.prototype.switchMapTo = switchMapTo_1.switchMapTo; -},{"../../Observable":51,"../../operator/switchMapTo":322}],170:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/switchMapTo":317}],165:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var take_1 = require('../../operator/take'); Observable_1.Observable.prototype.take = take_1.take; -},{"../../Observable":51,"../../operator/take":323}],171:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/take":318}],166:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var takeLast_1 = require('../../operator/takeLast'); Observable_1.Observable.prototype.takeLast = takeLast_1.takeLast; -},{"../../Observable":51,"../../operator/takeLast":324}],172:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/takeLast":319}],167:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var takeUntil_1 = require('../../operator/takeUntil'); Observable_1.Observable.prototype.takeUntil = takeUntil_1.takeUntil; -},{"../../Observable":51,"../../operator/takeUntil":325}],173:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/takeUntil":320}],168:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var takeWhile_1 = require('../../operator/takeWhile'); Observable_1.Observable.prototype.takeWhile = takeWhile_1.takeWhile; -},{"../../Observable":51,"../../operator/takeWhile":326}],174:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/takeWhile":321}],169:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var throttle_1 = require('../../operator/throttle'); Observable_1.Observable.prototype.throttle = throttle_1.throttle; -},{"../../Observable":51,"../../operator/throttle":327}],175:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/throttle":322}],170:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var throttleTime_1 = require('../../operator/throttleTime'); Observable_1.Observable.prototype.throttleTime = throttleTime_1.throttleTime; -},{"../../Observable":51,"../../operator/throttleTime":328}],176:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/throttleTime":323}],171:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var timeInterval_1 = require('../../operator/timeInterval'); Observable_1.Observable.prototype.timeInterval = timeInterval_1.timeInterval; -},{"../../Observable":51,"../../operator/timeInterval":329}],177:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/timeInterval":324}],172:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var timeout_1 = require('../../operator/timeout'); Observable_1.Observable.prototype.timeout = timeout_1.timeout; -},{"../../Observable":51,"../../operator/timeout":330}],178:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/timeout":325}],173:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var timeoutWith_1 = require('../../operator/timeoutWith'); Observable_1.Observable.prototype.timeoutWith = timeoutWith_1.timeoutWith; -},{"../../Observable":51,"../../operator/timeoutWith":331}],179:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/timeoutWith":326}],174:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var timestamp_1 = require('../../operator/timestamp'); Observable_1.Observable.prototype.timestamp = timestamp_1.timestamp; -},{"../../Observable":51,"../../operator/timestamp":332}],180:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/timestamp":327}],175:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var toArray_1 = require('../../operator/toArray'); Observable_1.Observable.prototype.toArray = toArray_1.toArray; -},{"../../Observable":51,"../../operator/toArray":333}],181:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/toArray":328}],176:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var toPromise_1 = require('../../operator/toPromise'); Observable_1.Observable.prototype.toPromise = toPromise_1.toPromise; -},{"../../Observable":51,"../../operator/toPromise":334}],182:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/toPromise":329}],177:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var window_1 = require('../../operator/window'); Observable_1.Observable.prototype.window = window_1.window; -},{"../../Observable":51,"../../operator/window":335}],183:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/window":330}],178:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var windowCount_1 = require('../../operator/windowCount'); Observable_1.Observable.prototype.windowCount = windowCount_1.windowCount; -},{"../../Observable":51,"../../operator/windowCount":336}],184:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/windowCount":331}],179:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var windowTime_1 = require('../../operator/windowTime'); Observable_1.Observable.prototype.windowTime = windowTime_1.windowTime; -},{"../../Observable":51,"../../operator/windowTime":337}],185:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/windowTime":332}],180:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var windowToggle_1 = require('../../operator/windowToggle'); Observable_1.Observable.prototype.windowToggle = windowToggle_1.windowToggle; -},{"../../Observable":51,"../../operator/windowToggle":338}],186:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/windowToggle":333}],181:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var windowWhen_1 = require('../../operator/windowWhen'); Observable_1.Observable.prototype.windowWhen = windowWhen_1.windowWhen; -},{"../../Observable":51,"../../operator/windowWhen":339}],187:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/windowWhen":334}],182:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var withLatestFrom_1 = require('../../operator/withLatestFrom'); Observable_1.Observable.prototype.withLatestFrom = withLatestFrom_1.withLatestFrom; -},{"../../Observable":51,"../../operator/withLatestFrom":340}],188:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/withLatestFrom":335}],183:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var zip_1 = require('../../operator/zip'); Observable_1.Observable.prototype.zip = zip_1.zipProto; -},{"../../Observable":51,"../../operator/zip":341}],189:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/zip":336}],184:[function(require,module,exports){ "use strict"; var Observable_1 = require('../../Observable'); var zipAll_1 = require('../../operator/zipAll'); Observable_1.Observable.prototype.zipAll = zipAll_1.zipAll; -},{"../../Observable":51,"../../operator/zipAll":342}],190:[function(require,module,exports){ +},{"../../Observable":46,"../../operator/zipAll":337}],185:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -7312,7 +6656,7 @@ var ArrayLikeObservable = (function (_super) { }(Observable_1.Observable)); exports.ArrayLikeObservable = ArrayLikeObservable; -},{"../Observable":51,"./EmptyObservable":196,"./ScalarObservable":211}],191:[function(require,module,exports){ +},{"../Observable":46,"./EmptyObservable":191,"./ScalarObservable":206}],186:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -7435,7 +6779,7 @@ var ArrayObservable = (function (_super) { }(Observable_1.Observable)); exports.ArrayObservable = ArrayObservable; -},{"../Observable":51,"../util/isScheduler":383,"./EmptyObservable":196,"./ScalarObservable":211}],192:[function(require,module,exports){ +},{"../Observable":46,"../util/isScheduler":378,"./EmptyObservable":191,"./ScalarObservable":206}],187:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -7600,7 +6944,7 @@ function dispatchError(arg) { subject.error(err); } -},{"../AsyncSubject":47,"../Observable":51,"../util/errorObject":376,"../util/tryCatch":389}],193:[function(require,module,exports){ +},{"../AsyncSubject":42,"../Observable":46,"../util/errorObject":371,"../util/tryCatch":384}],188:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -7777,7 +7121,7 @@ function dispatchError(arg) { subject.error(err); } -},{"../AsyncSubject":47,"../Observable":51,"../util/errorObject":376,"../util/tryCatch":389}],194:[function(require,module,exports){ +},{"../AsyncSubject":42,"../Observable":46,"../util/errorObject":371,"../util/tryCatch":384}],189:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -7932,7 +7276,7 @@ var RefCountSubscriber = (function (_super) { return RefCountSubscriber; }(Subscriber_1.Subscriber)); -},{"../Observable":51,"../Subject":57,"../Subscriber":59,"../Subscription":60}],195:[function(require,module,exports){ +},{"../Observable":46,"../Subject":52,"../Subscriber":54,"../Subscription":55}],190:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -8026,7 +7370,7 @@ var DeferSubscriber = (function (_super) { return DeferSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../Observable":51,"../OuterSubscriber":53,"../util/subscribeToResult":387}],196:[function(require,module,exports){ +},{"../Observable":46,"../OuterSubscriber":48,"../util/subscribeToResult":382}],191:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -8102,7 +7446,7 @@ var EmptyObservable = (function (_super) { }(Observable_1.Observable)); exports.EmptyObservable = EmptyObservable; -},{"../Observable":51}],197:[function(require,module,exports){ +},{"../Observable":46}],192:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -8185,7 +7529,7 @@ var ErrorObservable = (function (_super) { }(Observable_1.Observable)); exports.ErrorObservable = ErrorObservable; -},{"../Observable":51}],198:[function(require,module,exports){ +},{"../Observable":46}],193:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -8298,7 +7642,7 @@ var ForkJoinSubscriber = (function (_super) { return ForkJoinSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../Observable":51,"../OuterSubscriber":53,"../util/isArray":377,"../util/subscribeToResult":387,"./EmptyObservable":196}],199:[function(require,module,exports){ +},{"../Observable":46,"../OuterSubscriber":48,"../util/isArray":372,"../util/subscribeToResult":382,"./EmptyObservable":191}],194:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -8431,7 +7775,7 @@ var FromEventObservable = (function (_super) { }(Observable_1.Observable)); exports.FromEventObservable = FromEventObservable; -},{"../Observable":51,"../Subscription":60,"../util/errorObject":376,"../util/isFunction":379,"../util/tryCatch":389}],200:[function(require,module,exports){ +},{"../Observable":46,"../Subscription":55,"../util/errorObject":371,"../util/isFunction":374,"../util/tryCatch":384}],195:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -8540,7 +7884,7 @@ var FromEventPatternObservable = (function (_super) { }(Observable_1.Observable)); exports.FromEventPatternObservable = FromEventPatternObservable; -},{"../Observable":51,"../Subscription":60}],201:[function(require,module,exports){ +},{"../Observable":46,"../Subscription":55}],196:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -8657,7 +8001,7 @@ var FromObservable = (function (_super) { }(Observable_1.Observable)); exports.FromObservable = FromObservable; -},{"../Observable":51,"../operator/observeOn":294,"../symbol/iterator":357,"../symbol/observable":358,"../util/isArray":377,"../util/isPromise":382,"./ArrayLikeObservable":190,"./ArrayObservable":191,"./IteratorObservable":205,"./PromiseObservable":209}],202:[function(require,module,exports){ +},{"../Observable":46,"../operator/observeOn":289,"../symbol/iterator":352,"../symbol/observable":353,"../util/isArray":372,"../util/isPromise":377,"./ArrayLikeObservable":185,"./ArrayObservable":186,"./IteratorObservable":200,"./PromiseObservable":204}],197:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -8793,7 +8137,7 @@ var GenerateObservable = (function (_super) { }(Observable_1.Observable)); exports.GenerateObservable = GenerateObservable; -},{"../Observable":51,"../util/isScheduler":383}],203:[function(require,module,exports){ +},{"../Observable":46,"../util/isScheduler":378}],198:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -8855,7 +8199,7 @@ var IfSubscriber = (function (_super) { return IfSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../Observable":51,"../OuterSubscriber":53,"../util/subscribeToResult":387}],204:[function(require,module,exports){ +},{"../Observable":46,"../OuterSubscriber":48,"../util/subscribeToResult":382}],199:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -8944,7 +8288,7 @@ var IntervalObservable = (function (_super) { }(Observable_1.Observable)); exports.IntervalObservable = IntervalObservable; -},{"../Observable":51,"../scheduler/async":355,"../util/isNumeric":380}],205:[function(require,module,exports){ +},{"../Observable":46,"../scheduler/async":350,"../util/isNumeric":375}],200:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -9102,7 +8446,7 @@ function sign(value) { return valueAsNumber < 0 ? -1 : 1; } -},{"../Observable":51,"../symbol/iterator":357,"../util/root":386}],206:[function(require,module,exports){ +},{"../Observable":46,"../symbol/iterator":352,"../util/root":381}],201:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -9130,7 +8474,7 @@ var MulticastObservable = (function (_super) { }(Observable_1.Observable)); exports.MulticastObservable = MulticastObservable; -},{"../Observable":51,"../observable/ConnectableObservable":194}],207:[function(require,module,exports){ +},{"../Observable":46,"../observable/ConnectableObservable":189}],202:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -9190,7 +8534,7 @@ var NeverObservable = (function (_super) { }(Observable_1.Observable)); exports.NeverObservable = NeverObservable; -},{"../Observable":51,"../util/noop":384}],208:[function(require,module,exports){ +},{"../Observable":46,"../util/noop":379}],203:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -9276,7 +8620,7 @@ var PairsObservable = (function (_super) { }(Observable_1.Observable)); exports.PairsObservable = PairsObservable; -},{"../Observable":51}],209:[function(require,module,exports){ +},{"../Observable":46}],204:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -9398,7 +8742,7 @@ function dispatchError(arg) { } } -},{"../Observable":51,"../util/root":386}],210:[function(require,module,exports){ +},{"../Observable":46,"../util/root":381}],205:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -9495,7 +8839,7 @@ var RangeObservable = (function (_super) { }(Observable_1.Observable)); exports.RangeObservable = RangeObservable; -},{"../Observable":51}],211:[function(require,module,exports){ +},{"../Observable":46}],206:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -9554,7 +8898,7 @@ var ScalarObservable = (function (_super) { }(Observable_1.Observable)); exports.ScalarObservable = ScalarObservable; -},{"../Observable":51}],212:[function(require,module,exports){ +},{"../Observable":46}],207:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -9606,7 +8950,7 @@ var SubscribeOnObservable = (function (_super) { }(Observable_1.Observable)); exports.SubscribeOnObservable = SubscribeOnObservable; -},{"../Observable":51,"../scheduler/asap":354,"../util/isNumeric":380}],213:[function(require,module,exports){ +},{"../Observable":46,"../scheduler/asap":349,"../util/isNumeric":375}],208:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -9714,7 +9058,7 @@ var TimerObservable = (function (_super) { }(Observable_1.Observable)); exports.TimerObservable = TimerObservable; -},{"../Observable":51,"../scheduler/async":355,"../util/isDate":378,"../util/isNumeric":380,"../util/isScheduler":383}],214:[function(require,module,exports){ +},{"../Observable":46,"../scheduler/async":350,"../util/isDate":373,"../util/isNumeric":375,"../util/isScheduler":378}],209:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -9776,17 +9120,17 @@ var UsingSubscriber = (function (_super) { return UsingSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../Observable":51,"../OuterSubscriber":53,"../util/subscribeToResult":387}],215:[function(require,module,exports){ +},{"../Observable":46,"../OuterSubscriber":48,"../util/subscribeToResult":382}],210:[function(require,module,exports){ "use strict"; var BoundCallbackObservable_1 = require('./BoundCallbackObservable'); exports.bindCallback = BoundCallbackObservable_1.BoundCallbackObservable.create; -},{"./BoundCallbackObservable":192}],216:[function(require,module,exports){ +},{"./BoundCallbackObservable":187}],211:[function(require,module,exports){ "use strict"; var BoundNodeCallbackObservable_1 = require('./BoundNodeCallbackObservable'); exports.bindNodeCallback = BoundNodeCallbackObservable_1.BoundNodeCallbackObservable.create; -},{"./BoundNodeCallbackObservable":193}],217:[function(require,module,exports){ +},{"./BoundNodeCallbackObservable":188}],212:[function(require,module,exports){ "use strict"; var isScheduler_1 = require('../util/isScheduler'); var isArray_1 = require('../util/isArray'); @@ -9858,17 +9202,17 @@ function combineLatest() { } exports.combineLatest = combineLatest; -},{"../operator/combineLatest":251,"../util/isArray":377,"../util/isScheduler":383,"./ArrayObservable":191}],218:[function(require,module,exports){ +},{"../operator/combineLatest":246,"../util/isArray":372,"../util/isScheduler":378,"./ArrayObservable":186}],213:[function(require,module,exports){ "use strict"; var concat_1 = require('../operator/concat'); exports.concat = concat_1.concatStatic; -},{"../operator/concat":252}],219:[function(require,module,exports){ +},{"../operator/concat":247}],214:[function(require,module,exports){ "use strict"; var DeferObservable_1 = require('./DeferObservable'); exports.defer = DeferObservable_1.DeferObservable.create; -},{"./DeferObservable":195}],220:[function(require,module,exports){ +},{"./DeferObservable":190}],215:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -10262,7 +9606,7 @@ var AjaxTimeoutError = (function (_super) { }(AjaxError)); exports.AjaxTimeoutError = AjaxTimeoutError; -},{"../../Observable":51,"../../Subscriber":59,"../../operator/map":283,"../../util/errorObject":376,"../../util/root":386,"../../util/tryCatch":389}],221:[function(require,module,exports){ +},{"../../Observable":46,"../../Subscriber":54,"../../operator/map":278,"../../util/errorObject":371,"../../util/root":381,"../../util/tryCatch":384}],216:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -10468,102 +9812,102 @@ var WebSocketSubject = (function (_super) { }(Subject_1.AnonymousSubject)); exports.WebSocketSubject = WebSocketSubject; -},{"../../Observable":51,"../../ReplaySubject":54,"../../Subject":57,"../../Subscriber":59,"../../Subscription":60,"../../util/assign":375,"../../util/errorObject":376,"../../util/root":386,"../../util/tryCatch":389}],222:[function(require,module,exports){ +},{"../../Observable":46,"../../ReplaySubject":49,"../../Subject":52,"../../Subscriber":54,"../../Subscription":55,"../../util/assign":370,"../../util/errorObject":371,"../../util/root":381,"../../util/tryCatch":384}],217:[function(require,module,exports){ "use strict"; var AjaxObservable_1 = require('./AjaxObservable'); exports.ajax = AjaxObservable_1.AjaxObservable.create; -},{"./AjaxObservable":220}],223:[function(require,module,exports){ +},{"./AjaxObservable":215}],218:[function(require,module,exports){ "use strict"; var WebSocketSubject_1 = require('./WebSocketSubject'); exports.webSocket = WebSocketSubject_1.WebSocketSubject.create; -},{"./WebSocketSubject":221}],224:[function(require,module,exports){ +},{"./WebSocketSubject":216}],219:[function(require,module,exports){ "use strict"; var EmptyObservable_1 = require('./EmptyObservable'); exports.empty = EmptyObservable_1.EmptyObservable.create; -},{"./EmptyObservable":196}],225:[function(require,module,exports){ +},{"./EmptyObservable":191}],220:[function(require,module,exports){ "use strict"; var ForkJoinObservable_1 = require('./ForkJoinObservable'); exports.forkJoin = ForkJoinObservable_1.ForkJoinObservable.create; -},{"./ForkJoinObservable":198}],226:[function(require,module,exports){ +},{"./ForkJoinObservable":193}],221:[function(require,module,exports){ "use strict"; var FromObservable_1 = require('./FromObservable'); exports.from = FromObservable_1.FromObservable.create; -},{"./FromObservable":201}],227:[function(require,module,exports){ +},{"./FromObservable":196}],222:[function(require,module,exports){ "use strict"; var FromEventObservable_1 = require('./FromEventObservable'); exports.fromEvent = FromEventObservable_1.FromEventObservable.create; -},{"./FromEventObservable":199}],228:[function(require,module,exports){ +},{"./FromEventObservable":194}],223:[function(require,module,exports){ "use strict"; var FromEventPatternObservable_1 = require('./FromEventPatternObservable'); exports.fromEventPattern = FromEventPatternObservable_1.FromEventPatternObservable.create; -},{"./FromEventPatternObservable":200}],229:[function(require,module,exports){ +},{"./FromEventPatternObservable":195}],224:[function(require,module,exports){ "use strict"; var PromiseObservable_1 = require('./PromiseObservable'); exports.fromPromise = PromiseObservable_1.PromiseObservable.create; -},{"./PromiseObservable":209}],230:[function(require,module,exports){ +},{"./PromiseObservable":204}],225:[function(require,module,exports){ "use strict"; var IfObservable_1 = require('./IfObservable'); exports._if = IfObservable_1.IfObservable.create; -},{"./IfObservable":203}],231:[function(require,module,exports){ +},{"./IfObservable":198}],226:[function(require,module,exports){ "use strict"; var IntervalObservable_1 = require('./IntervalObservable'); exports.interval = IntervalObservable_1.IntervalObservable.create; -},{"./IntervalObservable":204}],232:[function(require,module,exports){ +},{"./IntervalObservable":199}],227:[function(require,module,exports){ "use strict"; var merge_1 = require('../operator/merge'); exports.merge = merge_1.mergeStatic; -},{"../operator/merge":287}],233:[function(require,module,exports){ +},{"../operator/merge":282}],228:[function(require,module,exports){ "use strict"; var NeverObservable_1 = require('./NeverObservable'); exports.never = NeverObservable_1.NeverObservable.create; -},{"./NeverObservable":207}],234:[function(require,module,exports){ +},{"./NeverObservable":202}],229:[function(require,module,exports){ "use strict"; var ArrayObservable_1 = require('./ArrayObservable'); exports.of = ArrayObservable_1.ArrayObservable.of; -},{"./ArrayObservable":191}],235:[function(require,module,exports){ +},{"./ArrayObservable":186}],230:[function(require,module,exports){ "use strict"; var PairsObservable_1 = require('./PairsObservable'); exports.pairs = PairsObservable_1.PairsObservable.create; -},{"./PairsObservable":208}],236:[function(require,module,exports){ +},{"./PairsObservable":203}],231:[function(require,module,exports){ "use strict"; var RangeObservable_1 = require('./RangeObservable'); exports.range = RangeObservable_1.RangeObservable.create; -},{"./RangeObservable":210}],237:[function(require,module,exports){ +},{"./RangeObservable":205}],232:[function(require,module,exports){ "use strict"; var ErrorObservable_1 = require('./ErrorObservable'); exports._throw = ErrorObservable_1.ErrorObservable.create; -},{"./ErrorObservable":197}],238:[function(require,module,exports){ +},{"./ErrorObservable":192}],233:[function(require,module,exports){ "use strict"; var TimerObservable_1 = require('./TimerObservable'); exports.timer = TimerObservable_1.TimerObservable.create; -},{"./TimerObservable":213}],239:[function(require,module,exports){ +},{"./TimerObservable":208}],234:[function(require,module,exports){ "use strict"; var UsingObservable_1 = require('./UsingObservable'); exports.using = UsingObservable_1.UsingObservable.create; -},{"./UsingObservable":214}],240:[function(require,module,exports){ +},{"./UsingObservable":209}],235:[function(require,module,exports){ "use strict"; var zip_1 = require('../operator/zip'); exports.zip = zip_1.zipStatic; -},{"../operator/zip":341}],241:[function(require,module,exports){ +},{"../operator/zip":336}],236:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -10674,7 +10018,7 @@ var AuditSubscriber = (function (_super) { return AuditSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/errorObject":376,"../util/subscribeToResult":387,"../util/tryCatch":389}],242:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/errorObject":371,"../util/subscribeToResult":382,"../util/tryCatch":384}],237:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -10779,7 +10123,7 @@ function dispatchNext(subscriber) { subscriber.clearThrottle(); } -},{"../Subscriber":59,"../scheduler/async":355}],243:[function(require,module,exports){ +},{"../Subscriber":54,"../scheduler/async":350}],238:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -10856,7 +10200,7 @@ var BufferSubscriber = (function (_super) { return BufferSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],244:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],239:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -10971,7 +10315,7 @@ var BufferCountSubscriber = (function (_super) { return BufferCountSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],245:[function(require,module,exports){ +},{"../Subscriber":54}],240:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -11170,7 +10514,7 @@ function dispatchBufferClose(arg) { subscriber.closeContext(context); } -},{"../Subscriber":59,"../scheduler/async":355,"../util/isScheduler":383}],246:[function(require,module,exports){ +},{"../Subscriber":54,"../scheduler/async":350,"../util/isScheduler":378}],241:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -11323,7 +10667,7 @@ var BufferToggleSubscriber = (function (_super) { return BufferToggleSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../Subscription":60,"../util/subscribeToResult":387}],247:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../Subscription":55,"../util/subscribeToResult":382}],242:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -11446,7 +10790,7 @@ var BufferWhenSubscriber = (function (_super) { return BufferWhenSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../Subscription":60,"../util/errorObject":376,"../util/subscribeToResult":387,"../util/tryCatch":389}],248:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../Subscription":55,"../util/errorObject":371,"../util/subscribeToResult":382,"../util/tryCatch":384}],243:[function(require,module,exports){ "use strict"; var Observable_1 = require('../Observable'); var ReplaySubject_1 = require('../ReplaySubject'); @@ -11496,7 +10840,7 @@ function cache(bufferSize, windowTime, scheduler) { } exports.cache = cache; -},{"../Observable":51,"../ReplaySubject":54}],249:[function(require,module,exports){ +},{"../Observable":46,"../ReplaySubject":49}],244:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -11562,7 +10906,7 @@ var CatchSubscriber = (function (_super) { return CatchSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],250:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],245:[function(require,module,exports){ "use strict"; var combineLatest_1 = require('./combineLatest'); /** @@ -11610,7 +10954,7 @@ function combineAll(project) { } exports.combineAll = combineAll; -},{"./combineLatest":251}],251:[function(require,module,exports){ +},{"./combineLatest":246}],246:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -11758,7 +11102,7 @@ var CombineLatestSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.CombineLatestSubscriber = CombineLatestSubscriber; -},{"../OuterSubscriber":53,"../observable/ArrayObservable":191,"../util/isArray":377,"../util/subscribeToResult":387}],252:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../observable/ArrayObservable":186,"../util/isArray":372,"../util/subscribeToResult":382}],247:[function(require,module,exports){ "use strict"; var isScheduler_1 = require('../util/isScheduler'); var ArrayObservable_1 = require('../observable/ArrayObservable'); @@ -11867,7 +11211,7 @@ function concatStatic() { } exports.concatStatic = concatStatic; -},{"../observable/ArrayObservable":191,"../util/isScheduler":383,"./mergeAll":288}],253:[function(require,module,exports){ +},{"../observable/ArrayObservable":186,"../util/isScheduler":378,"./mergeAll":283}],248:[function(require,module,exports){ "use strict"; var mergeAll_1 = require('./mergeAll'); /** @@ -11917,7 +11261,7 @@ function concatAll() { } exports.concatAll = concatAll; -},{"./mergeAll":288}],254:[function(require,module,exports){ +},{"./mergeAll":283}],249:[function(require,module,exports){ "use strict"; var mergeMap_1 = require('./mergeMap'); /** @@ -11981,7 +11325,7 @@ function concatMap(project, resultSelector) { } exports.concatMap = concatMap; -},{"./mergeMap":289}],255:[function(require,module,exports){ +},{"./mergeMap":284}],250:[function(require,module,exports){ "use strict"; var mergeMapTo_1 = require('./mergeMapTo'); /** @@ -12039,7 +11383,7 @@ function concatMapTo(innerObservable, resultSelector) { } exports.concatMapTo = concatMapTo; -},{"./mergeMapTo":290}],256:[function(require,module,exports){ +},{"./mergeMapTo":285}],251:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -12148,7 +11492,7 @@ var CountSubscriber = (function (_super) { return CountSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],257:[function(require,module,exports){ +},{"../Subscriber":54}],252:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -12276,7 +11620,7 @@ var DebounceSubscriber = (function (_super) { return DebounceSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],258:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],253:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -12393,7 +11737,7 @@ function dispatchNext(subscriber) { subscriber.debouncedNext(); } -},{"../Subscriber":59,"../scheduler/async":355}],259:[function(require,module,exports){ +},{"../Subscriber":54,"../scheduler/async":350}],254:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -12470,7 +11814,7 @@ var DefaultIfEmptySubscriber = (function (_super) { return DefaultIfEmptySubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],260:[function(require,module,exports){ +},{"../Subscriber":54}],255:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -12606,7 +11950,7 @@ var DelayMessage = (function () { return DelayMessage; }()); -},{"../Notification":50,"../Subscriber":59,"../scheduler/async":355,"../util/isDate":378}],261:[function(require,module,exports){ +},{"../Notification":45,"../Subscriber":54,"../scheduler/async":350,"../util/isDate":373}],256:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -12797,7 +12141,7 @@ var SubscriptionDelaySubscriber = (function (_super) { return SubscriptionDelaySubscriber; }(Subscriber_1.Subscriber)); -},{"../Observable":51,"../OuterSubscriber":53,"../Subscriber":59,"../util/subscribeToResult":387}],262:[function(require,module,exports){ +},{"../Observable":46,"../OuterSubscriber":48,"../Subscriber":54,"../util/subscribeToResult":382}],257:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -12868,7 +12212,7 @@ var DeMaterializeSubscriber = (function (_super) { return DeMaterializeSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],263:[function(require,module,exports){ +},{"../Subscriber":54}],258:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -12952,7 +12296,7 @@ var DistinctSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.DistinctSubscriber = DistinctSubscriber; -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],264:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],259:[function(require,module,exports){ "use strict"; var distinct_1 = require('./distinct'); /** @@ -12979,7 +12323,7 @@ function distinctKey(key, compare, flushes) { } exports.distinctKey = distinctKey; -},{"./distinct":263}],265:[function(require,module,exports){ +},{"./distinct":258}],260:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -13057,7 +12401,7 @@ var DistinctUntilChangedSubscriber = (function (_super) { return DistinctUntilChangedSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../util/errorObject":376,"../util/tryCatch":389}],266:[function(require,module,exports){ +},{"../Subscriber":54,"../util/errorObject":371,"../util/tryCatch":384}],261:[function(require,module,exports){ "use strict"; var distinctUntilChanged_1 = require('./distinctUntilChanged'); /** @@ -13081,7 +12425,7 @@ function distinctUntilKeyChanged(key, compare) { } exports.distinctUntilKeyChanged = distinctUntilKeyChanged; -},{"./distinctUntilChanged":265}],267:[function(require,module,exports){ +},{"./distinctUntilChanged":260}],262:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -13194,7 +12538,7 @@ var DoSubscriber = (function (_super) { return DoSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],268:[function(require,module,exports){ +},{"../Subscriber":54}],263:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -13290,7 +12634,7 @@ var ElementAtSubscriber = (function (_super) { return ElementAtSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../util/ArgumentOutOfRangeError":366}],269:[function(require,module,exports){ +},{"../Subscriber":54,"../util/ArgumentOutOfRangeError":361}],264:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -13359,7 +12703,7 @@ var EverySubscriber = (function (_super) { return EverySubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],270:[function(require,module,exports){ +},{"../Subscriber":54}],265:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -13450,7 +12794,7 @@ var SwitchFirstSubscriber = (function (_super) { return SwitchFirstSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],271:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],266:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -13588,7 +12932,7 @@ var SwitchFirstMapSubscriber = (function (_super) { return SwitchFirstMapSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],272:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],267:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -13739,7 +13083,7 @@ var ExpandSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.ExpandSubscriber = ExpandSubscriber; -},{"../OuterSubscriber":53,"../util/errorObject":376,"../util/subscribeToResult":387,"../util/tryCatch":389}],273:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/errorObject":371,"../util/subscribeToResult":382,"../util/tryCatch":384}],268:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -13833,7 +13177,7 @@ var FilterSubscriber = (function (_super) { return FilterSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],274:[function(require,module,exports){ +},{"../Subscriber":54}],269:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -13877,7 +13221,7 @@ var FinallySubscriber = (function (_super) { return FinallySubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../Subscription":60}],275:[function(require,module,exports){ +},{"../Subscriber":54,"../Subscription":55}],270:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -13978,7 +13322,7 @@ var FindValueSubscriber = (function (_super) { }(Subscriber_1.Subscriber)); exports.FindValueSubscriber = FindValueSubscriber; -},{"../Subscriber":59}],276:[function(require,module,exports){ +},{"../Subscriber":54}],271:[function(require,module,exports){ "use strict"; var find_1 = require('./find'); /** @@ -14020,7 +13364,7 @@ function findIndex(predicate, thisArg) { } exports.findIndex = findIndex; -},{"./find":275}],277:[function(require,module,exports){ +},{"./find":270}],272:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -14169,7 +13513,7 @@ var FirstSubscriber = (function (_super) { return FirstSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../util/EmptyError":367}],278:[function(require,module,exports){ +},{"../Subscriber":54,"../util/EmptyError":362}],273:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -14402,7 +13746,7 @@ var InnerRefCountSubscription = (function (_super) { return InnerRefCountSubscription; }(Subscription_1.Subscription)); -},{"../Observable":51,"../Subject":57,"../Subscriber":59,"../Subscription":60,"../util/FastMap":368,"../util/Map":370}],279:[function(require,module,exports){ +},{"../Observable":46,"../Subject":52,"../Subscriber":54,"../Subscription":55,"../util/FastMap":363,"../util/Map":365}],274:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -14450,7 +13794,7 @@ var IgnoreElementsSubscriber = (function (_super) { return IgnoreElementsSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../util/noop":384}],280:[function(require,module,exports){ +},{"../Subscriber":54,"../util/noop":379}],275:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -14503,7 +13847,7 @@ var IsEmptySubscriber = (function (_super) { return IsEmptySubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],281:[function(require,module,exports){ +},{"../Subscriber":54}],276:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -14622,7 +13966,7 @@ var LastSubscriber = (function (_super) { return LastSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../util/EmptyError":367}],282:[function(require,module,exports){ +},{"../Subscriber":54,"../util/EmptyError":362}],277:[function(require,module,exports){ "use strict"; /** * @param func @@ -14635,7 +13979,7 @@ function letProto(func) { } exports.letProto = letProto; -},{}],283:[function(require,module,exports){ +},{}],278:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -14723,7 +14067,7 @@ var MapSubscriber = (function (_super) { return MapSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],284:[function(require,module,exports){ +},{"../Subscriber":54}],279:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -14787,7 +14131,7 @@ var MapToSubscriber = (function (_super) { return MapToSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],285:[function(require,module,exports){ +},{"../Subscriber":54}],280:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -14871,7 +14215,7 @@ var MaterializeSubscriber = (function (_super) { return MaterializeSubscriber; }(Subscriber_1.Subscriber)); -},{"../Notification":50,"../Subscriber":59}],286:[function(require,module,exports){ +},{"../Notification":45,"../Subscriber":54}],281:[function(require,module,exports){ "use strict"; var reduce_1 = require('./reduce'); /** @@ -14894,7 +14238,7 @@ function max(comparer) { } exports.max = max; -},{"./reduce":304}],287:[function(require,module,exports){ +},{"./reduce":299}],282:[function(require,module,exports){ "use strict"; var ArrayObservable_1 = require('../observable/ArrayObservable'); var mergeAll_1 = require('./mergeAll'); @@ -15025,7 +14369,7 @@ function mergeStatic() { } exports.mergeStatic = mergeStatic; -},{"../observable/ArrayObservable":191,"../util/isScheduler":383,"./mergeAll":288}],288:[function(require,module,exports){ +},{"../observable/ArrayObservable":186,"../util/isScheduler":378,"./mergeAll":283}],283:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -15137,7 +14481,7 @@ var MergeAllSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.MergeAllSubscriber = MergeAllSubscriber; -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],289:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],284:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -15299,7 +14643,7 @@ var MergeMapSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.MergeMapSubscriber = MergeMapSubscriber; -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],290:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],285:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -15454,7 +14798,7 @@ var MergeMapToSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.MergeMapToSubscriber = MergeMapToSubscriber; -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],291:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],286:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -15561,7 +14905,7 @@ var MergeScanSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.MergeScanSubscriber = MergeScanSubscriber; -},{"../OuterSubscriber":53,"../util/errorObject":376,"../util/subscribeToResult":387,"../util/tryCatch":389}],292:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/errorObject":371,"../util/subscribeToResult":382,"../util/tryCatch":384}],287:[function(require,module,exports){ "use strict"; var reduce_1 = require('./reduce'); /** @@ -15583,7 +14927,7 @@ function min(comparer) { } exports.min = min; -},{"./reduce":304}],293:[function(require,module,exports){ +},{"./reduce":299}],288:[function(require,module,exports){ "use strict"; var MulticastObservable_1 = require('../observable/MulticastObservable'); var ConnectableObservable_1 = require('../observable/ConnectableObservable'); @@ -15622,7 +14966,7 @@ function multicast(subjectOrSubjectFactory, selector) { } exports.multicast = multicast; -},{"../observable/ConnectableObservable":194,"../observable/MulticastObservable":206}],294:[function(require,module,exports){ +},{"../observable/ConnectableObservable":189,"../observable/MulticastObservable":201}],289:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -15698,7 +15042,7 @@ var ObserveOnMessage = (function () { }()); exports.ObserveOnMessage = ObserveOnMessage; -},{"../Notification":50,"../Subscriber":59}],295:[function(require,module,exports){ +},{"../Notification":45,"../Subscriber":54}],290:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -15774,7 +15118,7 @@ var OnErrorResumeNextSubscriber = (function (_super) { return OnErrorResumeNextSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../observable/FromObservable":201,"../util/isArray":377,"../util/subscribeToResult":387}],296:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../observable/FromObservable":196,"../util/isArray":372,"../util/subscribeToResult":382}],291:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -15852,7 +15196,7 @@ var PairwiseSubscriber = (function (_super) { return PairwiseSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],297:[function(require,module,exports){ +},{"../Subscriber":54}],292:[function(require,module,exports){ "use strict"; var not_1 = require('../util/not'); var filter_1 = require('./filter'); @@ -15905,7 +15249,7 @@ function partition(predicate, thisArg) { } exports.partition = partition; -},{"../util/not":385,"./filter":273}],298:[function(require,module,exports){ +},{"../util/not":380,"./filter":268}],293:[function(require,module,exports){ "use strict"; var map_1 = require('./map'); /** @@ -15964,7 +15308,7 @@ function plucker(props, length) { return mapper; } -},{"./map":283}],299:[function(require,module,exports){ +},{"./map":278}],294:[function(require,module,exports){ "use strict"; var Subject_1 = require('../Subject'); var multicast_1 = require('./multicast'); @@ -15987,7 +15331,7 @@ function publish(selector) { } exports.publish = publish; -},{"../Subject":57,"./multicast":293}],300:[function(require,module,exports){ +},{"../Subject":52,"./multicast":288}],295:[function(require,module,exports){ "use strict"; var BehaviorSubject_1 = require('../BehaviorSubject'); var multicast_1 = require('./multicast'); @@ -16002,7 +15346,7 @@ function publishBehavior(value) { } exports.publishBehavior = publishBehavior; -},{"../BehaviorSubject":48,"./multicast":293}],301:[function(require,module,exports){ +},{"../BehaviorSubject":43,"./multicast":288}],296:[function(require,module,exports){ "use strict"; var AsyncSubject_1 = require('../AsyncSubject'); var multicast_1 = require('./multicast'); @@ -16016,7 +15360,7 @@ function publishLast() { } exports.publishLast = publishLast; -},{"../AsyncSubject":47,"./multicast":293}],302:[function(require,module,exports){ +},{"../AsyncSubject":42,"./multicast":288}],297:[function(require,module,exports){ "use strict"; var ReplaySubject_1 = require('../ReplaySubject'); var multicast_1 = require('./multicast'); @@ -16035,7 +15379,7 @@ function publishReplay(bufferSize, windowTime, scheduler) { } exports.publishReplay = publishReplay; -},{"../ReplaySubject":54,"./multicast":293}],303:[function(require,module,exports){ +},{"../ReplaySubject":49,"./multicast":288}],298:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -16147,7 +15491,7 @@ var RaceSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.RaceSubscriber = RaceSubscriber; -},{"../OuterSubscriber":53,"../observable/ArrayObservable":191,"../util/isArray":377,"../util/subscribeToResult":387}],304:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../observable/ArrayObservable":186,"../util/isArray":372,"../util/subscribeToResult":382}],299:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -16260,7 +15604,7 @@ var ReduceSubscriber = (function (_super) { }(Subscriber_1.Subscriber)); exports.ReduceSubscriber = ReduceSubscriber; -},{"../Subscriber":59}],305:[function(require,module,exports){ +},{"../Subscriber":54}],300:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -16336,7 +15680,7 @@ var RepeatSubscriber = (function (_super) { return RepeatSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../observable/EmptyObservable":196}],306:[function(require,module,exports){ +},{"../Subscriber":54,"../observable/EmptyObservable":191}],301:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -16443,7 +15787,7 @@ var RepeatWhenSubscriber = (function (_super) { return RepeatWhenSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../Subject":57,"../util/errorObject":376,"../util/subscribeToResult":387,"../util/tryCatch":389}],307:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../Subject":52,"../util/errorObject":371,"../util/subscribeToResult":382,"../util/tryCatch":384}],302:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -16513,7 +15857,7 @@ var RetrySubscriber = (function (_super) { return RetrySubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],308:[function(require,module,exports){ +},{"../Subscriber":54}],303:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -16620,7 +15964,7 @@ var RetryWhenSubscriber = (function (_super) { return RetryWhenSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../Subject":57,"../util/errorObject":376,"../util/subscribeToResult":387,"../util/tryCatch":389}],309:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../Subject":52,"../util/errorObject":371,"../util/subscribeToResult":382,"../util/tryCatch":384}],304:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -16707,7 +16051,7 @@ var SampleSubscriber = (function (_super) { return SampleSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],310:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],305:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -16799,7 +16143,7 @@ function dispatchNotification(state) { this.schedule(state, period); } -},{"../Subscriber":59,"../scheduler/async":355}],311:[function(require,module,exports){ +},{"../Subscriber":54,"../scheduler/async":350}],306:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -16908,7 +16252,7 @@ var ScanSubscriber = (function (_super) { return ScanSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],312:[function(require,module,exports){ +},{"../Subscriber":54}],307:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -17073,7 +16417,7 @@ var SequenceEqualCompareToSubscriber = (function (_super) { return SequenceEqualCompareToSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../util/errorObject":376,"../util/tryCatch":389}],313:[function(require,module,exports){ +},{"../Subscriber":54,"../util/errorObject":371,"../util/tryCatch":384}],308:[function(require,module,exports){ "use strict"; var multicast_1 = require('./multicast'); var Subject_1 = require('../Subject'); @@ -17098,7 +16442,7 @@ function share() { exports.share = share; ; -},{"../Subject":57,"./multicast":293}],314:[function(require,module,exports){ +},{"../Subject":52,"./multicast":288}],309:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -17194,7 +16538,7 @@ var SingleSubscriber = (function (_super) { return SingleSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../util/EmptyError":367}],315:[function(require,module,exports){ +},{"../Subscriber":54,"../util/EmptyError":362}],310:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -17246,7 +16590,7 @@ var SkipSubscriber = (function (_super) { return SkipSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],316:[function(require,module,exports){ +},{"../Subscriber":54}],311:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -17318,7 +16662,7 @@ var SkipUntilSubscriber = (function (_super) { return SkipUntilSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],317:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],312:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -17385,7 +16729,7 @@ var SkipWhileSubscriber = (function (_super) { return SkipWhileSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],318:[function(require,module,exports){ +},{"../Subscriber":54}],313:[function(require,module,exports){ "use strict"; var ArrayObservable_1 = require('../observable/ArrayObservable'); var ScalarObservable_1 = require('../observable/ScalarObservable'); @@ -17429,7 +16773,7 @@ function startWith() { } exports.startWith = startWith; -},{"../observable/ArrayObservable":191,"../observable/EmptyObservable":196,"../observable/ScalarObservable":211,"../util/isScheduler":383,"./concat":252}],319:[function(require,module,exports){ +},{"../observable/ArrayObservable":186,"../observable/EmptyObservable":191,"../observable/ScalarObservable":206,"../util/isScheduler":378,"./concat":247}],314:[function(require,module,exports){ "use strict"; var SubscribeOnObservable_1 = require('../observable/SubscribeOnObservable'); /** @@ -17449,7 +16793,7 @@ function subscribeOn(scheduler, delay) { } exports.subscribeOn = subscribeOn; -},{"../observable/SubscribeOnObservable":212}],320:[function(require,module,exports){ +},{"../observable/SubscribeOnObservable":207}],315:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -17558,7 +16902,7 @@ var SwitchSubscriber = (function (_super) { return SwitchSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],321:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],316:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -17698,7 +17042,7 @@ var SwitchMapSubscriber = (function (_super) { return SwitchMapSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],322:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],317:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -17825,7 +17169,7 @@ var SwitchMapToSubscriber = (function (_super) { return SwitchMapToSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],323:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],318:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -17914,7 +17258,7 @@ var TakeSubscriber = (function (_super) { return TakeSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../observable/EmptyObservable":196,"../util/ArgumentOutOfRangeError":366}],324:[function(require,module,exports){ +},{"../Subscriber":54,"../observable/EmptyObservable":191,"../util/ArgumentOutOfRangeError":361}],319:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -18022,7 +17366,7 @@ var TakeLastSubscriber = (function (_super) { return TakeLastSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../observable/EmptyObservable":196,"../util/ArgumentOutOfRangeError":366}],325:[function(require,module,exports){ +},{"../Subscriber":54,"../observable/EmptyObservable":191,"../util/ArgumentOutOfRangeError":361}],320:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -18098,7 +17442,7 @@ var TakeUntilSubscriber = (function (_super) { return TakeUntilSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],326:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],321:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -18191,7 +17535,7 @@ var TakeWhileSubscriber = (function (_super) { return TakeWhileSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],327:[function(require,module,exports){ +},{"../Subscriber":54}],322:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -18300,7 +17644,7 @@ var ThrottleSubscriber = (function (_super) { return ThrottleSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],328:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],323:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -18396,7 +17740,7 @@ function dispatchNext(arg) { subscriber.clearThrottle(); } -},{"../Subscriber":59,"../scheduler/async":355}],329:[function(require,module,exports){ +},{"../Subscriber":54,"../scheduler/async":350}],324:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -18456,7 +17800,7 @@ var TimeIntervalSubscriber = (function (_super) { return TimeIntervalSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../scheduler/async":355}],330:[function(require,module,exports){ +},{"../Subscriber":54,"../scheduler/async":350}],325:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -18559,7 +17903,7 @@ var TimeoutSubscriber = (function (_super) { return TimeoutSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../scheduler/async":355,"../util/isDate":378}],331:[function(require,module,exports){ +},{"../Subscriber":54,"../scheduler/async":350,"../util/isDate":373}],326:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -18670,7 +18014,7 @@ var TimeoutWithSubscriber = (function (_super) { return TimeoutWithSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../scheduler/async":355,"../util/isDate":378,"../util/subscribeToResult":387}],332:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../scheduler/async":350,"../util/isDate":373,"../util/subscribeToResult":382}],327:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -18721,7 +18065,7 @@ var TimestampSubscriber = (function (_super) { return TimestampSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59,"../scheduler/async":355}],333:[function(require,module,exports){ +},{"../Subscriber":54,"../scheduler/async":350}],328:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -18767,7 +18111,7 @@ var ToArraySubscriber = (function (_super) { return ToArraySubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":59}],334:[function(require,module,exports){ +},{"../Subscriber":54}],329:[function(require,module,exports){ "use strict"; var root_1 = require('../util/root'); /** @@ -18796,7 +18140,7 @@ function toPromise(PromiseCtor) { } exports.toPromise = toPromise; -},{"../util/root":386}],335:[function(require,module,exports){ +},{"../util/root":381}],330:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -18907,7 +18251,7 @@ var WindowSubscriber = (function (_super) { return WindowSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../Subject":57,"../util/subscribeToResult":387}],336:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../Subject":52,"../util/subscribeToResult":382}],331:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -19039,7 +18383,7 @@ var WindowCountSubscriber = (function (_super) { return WindowCountSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subject":57,"../Subscriber":59}],337:[function(require,module,exports){ +},{"../Subject":52,"../Subscriber":54}],332:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -19209,7 +18553,7 @@ function dispatchWindowClose(arg) { subscriber.closeWindow(window); } -},{"../Subject":57,"../Subscriber":59,"../scheduler/async":355}],338:[function(require,module,exports){ +},{"../Subject":52,"../Subscriber":54,"../scheduler/async":350}],333:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -19390,7 +18734,7 @@ var WindowToggleSubscriber = (function (_super) { return WindowToggleSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../Subject":57,"../Subscription":60,"../util/errorObject":376,"../util/subscribeToResult":387,"../util/tryCatch":389}],339:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../Subject":52,"../Subscription":55,"../util/errorObject":371,"../util/subscribeToResult":382,"../util/tryCatch":384}],334:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -19518,7 +18862,7 @@ var WindowSubscriber = (function (_super) { return WindowSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../Subject":57,"../util/errorObject":376,"../util/subscribeToResult":387,"../util/tryCatch":389}],340:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../Subject":52,"../util/errorObject":371,"../util/subscribeToResult":382,"../util/tryCatch":384}],335:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -19649,7 +18993,7 @@ var WithLatestFromSubscriber = (function (_super) { return WithLatestFromSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../util/subscribeToResult":387}],341:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../util/subscribeToResult":382}],336:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -19904,7 +19248,7 @@ var ZipBufferIterator = (function (_super) { return ZipBufferIterator; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":53,"../Subscriber":59,"../observable/ArrayObservable":191,"../symbol/iterator":357,"../util/isArray":377,"../util/subscribeToResult":387}],342:[function(require,module,exports){ +},{"../OuterSubscriber":48,"../Subscriber":54,"../observable/ArrayObservable":186,"../symbol/iterator":352,"../util/isArray":372,"../util/subscribeToResult":382}],337:[function(require,module,exports){ "use strict"; var zip_1 = require('./zip'); /** @@ -19918,7 +19262,7 @@ function zipAll(project) { } exports.zipAll = zipAll; -},{"./zip":341}],343:[function(require,module,exports){ +},{"./zip":336}],338:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -19963,7 +19307,7 @@ var Action = (function (_super) { }(Subscription_1.Subscription)); exports.Action = Action; -},{"../Subscription":60}],344:[function(require,module,exports){ +},{"../Subscription":55}],339:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -20017,7 +19361,7 @@ var AnimationFrameAction = (function (_super) { }(AsyncAction_1.AsyncAction)); exports.AnimationFrameAction = AnimationFrameAction; -},{"../util/AnimationFrame":365,"./AsyncAction":348}],345:[function(require,module,exports){ +},{"../util/AnimationFrame":360,"./AsyncAction":343}],340:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -20055,7 +19399,7 @@ var AnimationFrameScheduler = (function (_super) { }(AsyncScheduler_1.AsyncScheduler)); exports.AnimationFrameScheduler = AnimationFrameScheduler; -},{"./AsyncScheduler":349}],346:[function(require,module,exports){ +},{"./AsyncScheduler":344}],341:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -20109,7 +19453,7 @@ var AsapAction = (function (_super) { }(AsyncAction_1.AsyncAction)); exports.AsapAction = AsapAction; -},{"../util/Immediate":369,"./AsyncAction":348}],347:[function(require,module,exports){ +},{"../util/Immediate":364,"./AsyncAction":343}],342:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -20147,7 +19491,7 @@ var AsapScheduler = (function (_super) { }(AsyncScheduler_1.AsyncScheduler)); exports.AsapScheduler = AsapScheduler; -},{"./AsyncScheduler":349}],348:[function(require,module,exports){ +},{"./AsyncScheduler":344}],343:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -20290,7 +19634,7 @@ var AsyncAction = (function (_super) { }(Action_1.Action)); exports.AsyncAction = AsyncAction; -},{"../util/root":386,"./Action":343}],349:[function(require,module,exports){ +},{"../util/root":381,"./Action":338}],344:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -20342,7 +19686,7 @@ var AsyncScheduler = (function (_super) { }(Scheduler_1.Scheduler)); exports.AsyncScheduler = AsyncScheduler; -},{"../Scheduler":56}],350:[function(require,module,exports){ +},{"../Scheduler":51}],345:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -20390,7 +19734,7 @@ var QueueAction = (function (_super) { }(AsyncAction_1.AsyncAction)); exports.QueueAction = QueueAction; -},{"./AsyncAction":348}],351:[function(require,module,exports){ +},{"./AsyncAction":343}],346:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -20407,7 +19751,7 @@ var QueueScheduler = (function (_super) { }(AsyncScheduler_1.AsyncScheduler)); exports.QueueScheduler = QueueScheduler; -},{"./AsyncScheduler":349}],352:[function(require,module,exports){ +},{"./AsyncScheduler":344}],347:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -20506,31 +19850,31 @@ var VirtualAction = (function (_super) { }(AsyncAction_1.AsyncAction)); exports.VirtualAction = VirtualAction; -},{"./AsyncAction":348,"./AsyncScheduler":349}],353:[function(require,module,exports){ +},{"./AsyncAction":343,"./AsyncScheduler":344}],348:[function(require,module,exports){ "use strict"; var AnimationFrameAction_1 = require('./AnimationFrameAction'); var AnimationFrameScheduler_1 = require('./AnimationFrameScheduler'); exports.animationFrame = new AnimationFrameScheduler_1.AnimationFrameScheduler(AnimationFrameAction_1.AnimationFrameAction); -},{"./AnimationFrameAction":344,"./AnimationFrameScheduler":345}],354:[function(require,module,exports){ +},{"./AnimationFrameAction":339,"./AnimationFrameScheduler":340}],349:[function(require,module,exports){ "use strict"; var AsapAction_1 = require('./AsapAction'); var AsapScheduler_1 = require('./AsapScheduler'); exports.asap = new AsapScheduler_1.AsapScheduler(AsapAction_1.AsapAction); -},{"./AsapAction":346,"./AsapScheduler":347}],355:[function(require,module,exports){ +},{"./AsapAction":341,"./AsapScheduler":342}],350:[function(require,module,exports){ "use strict"; var AsyncAction_1 = require('./AsyncAction'); var AsyncScheduler_1 = require('./AsyncScheduler'); exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction); -},{"./AsyncAction":348,"./AsyncScheduler":349}],356:[function(require,module,exports){ +},{"./AsyncAction":343,"./AsyncScheduler":344}],351:[function(require,module,exports){ "use strict"; var QueueAction_1 = require('./QueueAction'); var QueueScheduler_1 = require('./QueueScheduler'); exports.queue = new QueueScheduler_1.QueueScheduler(QueueAction_1.QueueAction); -},{"./QueueAction":350,"./QueueScheduler":351}],357:[function(require,module,exports){ +},{"./QueueAction":345,"./QueueScheduler":346}],352:[function(require,module,exports){ "use strict"; var root_1 = require('../util/root'); var Symbol = root_1.root.Symbol; @@ -20563,7 +19907,7 @@ else { } } -},{"../util/root":386}],358:[function(require,module,exports){ +},{"../util/root":381}],353:[function(require,module,exports){ "use strict"; var root_1 = require('../util/root'); function getSymbolObservable(context) { @@ -20586,14 +19930,14 @@ function getSymbolObservable(context) { exports.getSymbolObservable = getSymbolObservable; exports.$$observable = getSymbolObservable(root_1.root); -},{"../util/root":386}],359:[function(require,module,exports){ +},{"../util/root":381}],354:[function(require,module,exports){ "use strict"; var root_1 = require('../util/root'); var Symbol = root_1.root.Symbol; exports.$$rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ? Symbol.for('rxSubscriber') : '@@rxSubscriber'; -},{"../util/root":386}],360:[function(require,module,exports){ +},{"../util/root":381}],355:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -20640,7 +19984,7 @@ var ColdObservable = (function (_super) { exports.ColdObservable = ColdObservable; applyMixins_1.applyMixins(ColdObservable, [SubscriptionLoggable_1.SubscriptionLoggable]); -},{"../Observable":51,"../Subscription":60,"../util/applyMixins":374,"./SubscriptionLoggable":363}],361:[function(require,module,exports){ +},{"../Observable":46,"../Subscription":55,"../util/applyMixins":369,"./SubscriptionLoggable":358}],356:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -20689,7 +20033,7 @@ var HotObservable = (function (_super) { exports.HotObservable = HotObservable; applyMixins_1.applyMixins(HotObservable, [SubscriptionLoggable_1.SubscriptionLoggable]); -},{"../Subject":57,"../Subscription":60,"../util/applyMixins":374,"./SubscriptionLoggable":363}],362:[function(require,module,exports){ +},{"../Subject":52,"../Subscription":55,"../util/applyMixins":369,"./SubscriptionLoggable":358}],357:[function(require,module,exports){ "use strict"; var SubscriptionLog = (function () { function SubscriptionLog(subscribedFrame, unsubscribedFrame) { @@ -20701,7 +20045,7 @@ var SubscriptionLog = (function () { }()); exports.SubscriptionLog = SubscriptionLog; -},{}],363:[function(require,module,exports){ +},{}],358:[function(require,module,exports){ "use strict"; var SubscriptionLog_1 = require('./SubscriptionLog'); var SubscriptionLoggable = (function () { @@ -20721,7 +20065,7 @@ var SubscriptionLoggable = (function () { }()); exports.SubscriptionLoggable = SubscriptionLoggable; -},{"./SubscriptionLog":362}],364:[function(require,module,exports){ +},{"./SubscriptionLog":357}],359:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -20945,7 +20289,7 @@ var TestScheduler = (function (_super) { }(VirtualTimeScheduler_1.VirtualTimeScheduler)); exports.TestScheduler = TestScheduler; -},{"../Notification":50,"../Observable":51,"../scheduler/VirtualTimeScheduler":352,"./ColdObservable":360,"./HotObservable":361,"./SubscriptionLog":362}],365:[function(require,module,exports){ +},{"../Notification":45,"../Observable":46,"../scheduler/VirtualTimeScheduler":347,"./ColdObservable":355,"./HotObservable":356,"./SubscriptionLog":357}],360:[function(require,module,exports){ "use strict"; var root_1 = require('./root'); var RequestAnimationFrameDefinition = (function () { @@ -20980,7 +20324,7 @@ var RequestAnimationFrameDefinition = (function () { exports.RequestAnimationFrameDefinition = RequestAnimationFrameDefinition; exports.AnimationFrame = new RequestAnimationFrameDefinition(root_1.root); -},{"./root":386}],366:[function(require,module,exports){ +},{"./root":381}],361:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -21009,7 +20353,7 @@ var ArgumentOutOfRangeError = (function (_super) { }(Error)); exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError; -},{}],367:[function(require,module,exports){ +},{}],362:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -21038,7 +20382,7 @@ var EmptyError = (function (_super) { }(Error)); exports.EmptyError = EmptyError; -},{}],368:[function(require,module,exports){ +},{}],363:[function(require,module,exports){ "use strict"; var FastMap = (function () { function FastMap() { @@ -21070,7 +20414,7 @@ var FastMap = (function () { }()); exports.FastMap = FastMap; -},{}],369:[function(require,module,exports){ +},{}],364:[function(require,module,exports){ /** Some credit for this helper goes to http://github.com/YuzuJS/setImmediate */ @@ -21280,13 +20624,13 @@ var ImmediateDefinition = (function () { exports.ImmediateDefinition = ImmediateDefinition; exports.Immediate = new ImmediateDefinition(root_1.root); -},{"./root":386}],370:[function(require,module,exports){ +},{"./root":381}],365:[function(require,module,exports){ "use strict"; var root_1 = require('./root'); var MapPolyfill_1 = require('./MapPolyfill'); exports.Map = root_1.root.Map || (function () { return MapPolyfill_1.MapPolyfill; })(); -},{"./MapPolyfill":371,"./root":386}],371:[function(require,module,exports){ +},{"./MapPolyfill":366,"./root":381}],366:[function(require,module,exports){ "use strict"; var MapPolyfill = (function () { function MapPolyfill() { @@ -21334,7 +20678,7 @@ var MapPolyfill = (function () { }()); exports.MapPolyfill = MapPolyfill; -},{}],372:[function(require,module,exports){ +},{}],367:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -21362,7 +20706,7 @@ var ObjectUnsubscribedError = (function (_super) { }(Error)); exports.ObjectUnsubscribedError = ObjectUnsubscribedError; -},{}],373:[function(require,module,exports){ +},{}],368:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -21388,7 +20732,7 @@ var UnsubscriptionError = (function (_super) { }(Error)); exports.UnsubscriptionError = UnsubscriptionError; -},{}],374:[function(require,module,exports){ +},{}],369:[function(require,module,exports){ "use strict"; function applyMixins(derivedCtor, baseCtors) { for (var i = 0, len = baseCtors.length; i < len; i++) { @@ -21402,7 +20746,7 @@ function applyMixins(derivedCtor, baseCtors) { } exports.applyMixins = applyMixins; -},{}],375:[function(require,module,exports){ +},{}],370:[function(require,module,exports){ "use strict"; var root_1 = require('./root'); var Object = root_1.root.Object; @@ -21434,30 +20778,30 @@ if (typeof Object.assign != 'function') { } exports.assign = Object.assign; -},{"./root":386}],376:[function(require,module,exports){ +},{"./root":381}],371:[function(require,module,exports){ "use strict"; // typeof any so that it we don't have to cast when comparing a result to the error object exports.errorObject = { e: {} }; -},{}],377:[function(require,module,exports){ +},{}],372:[function(require,module,exports){ "use strict"; exports.isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); -},{}],378:[function(require,module,exports){ +},{}],373:[function(require,module,exports){ "use strict"; function isDate(value) { return value instanceof Date && !isNaN(+value); } exports.isDate = isDate; -},{}],379:[function(require,module,exports){ +},{}],374:[function(require,module,exports){ "use strict"; function isFunction(x) { return typeof x === 'function'; } exports.isFunction = isFunction; -},{}],380:[function(require,module,exports){ +},{}],375:[function(require,module,exports){ "use strict"; var isArray_1 = require('../util/isArray'); function isNumeric(val) { @@ -21470,34 +20814,34 @@ function isNumeric(val) { exports.isNumeric = isNumeric; ; -},{"../util/isArray":377}],381:[function(require,module,exports){ +},{"../util/isArray":372}],376:[function(require,module,exports){ "use strict"; function isObject(x) { return x != null && typeof x === 'object'; } exports.isObject = isObject; -},{}],382:[function(require,module,exports){ +},{}],377:[function(require,module,exports){ "use strict"; function isPromise(value) { return value && typeof value.subscribe !== 'function' && typeof value.then === 'function'; } exports.isPromise = isPromise; -},{}],383:[function(require,module,exports){ +},{}],378:[function(require,module,exports){ "use strict"; function isScheduler(value) { return value && typeof value.schedule === 'function'; } exports.isScheduler = isScheduler; -},{}],384:[function(require,module,exports){ +},{}],379:[function(require,module,exports){ "use strict"; /* tslint:disable:no-empty */ function noop() { } exports.noop = noop; -},{}],385:[function(require,module,exports){ +},{}],380:[function(require,module,exports){ "use strict"; function not(pred, thisArg) { function notPred() { @@ -21509,7 +20853,7 @@ function not(pred, thisArg) { } exports.not = not; -},{}],386:[function(require,module,exports){ +},{}],381:[function(require,module,exports){ (function (global){ "use strict"; var objectTypes = { @@ -21528,7 +20872,7 @@ if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === fre }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],387:[function(require,module,exports){ +},{}],382:[function(require,module,exports){ "use strict"; var root_1 = require('./root'); var isArray_1 = require('./isArray'); @@ -21603,7 +20947,7 @@ function subscribeToResult(outerSubscriber, result, outerValue, outerIndex) { } exports.subscribeToResult = subscribeToResult; -},{"../InnerSubscriber":49,"../Observable":51,"../symbol/iterator":357,"../symbol/observable":358,"./isArray":377,"./isPromise":382,"./root":386}],388:[function(require,module,exports){ +},{"../InnerSubscriber":44,"../Observable":46,"../symbol/iterator":352,"../symbol/observable":353,"./isArray":372,"./isPromise":377,"./root":381}],383:[function(require,module,exports){ "use strict"; var Subscriber_1 = require('../Subscriber'); var rxSubscriber_1 = require('../symbol/rxSubscriber'); @@ -21623,7 +20967,7 @@ function toSubscriber(nextOrObserver, error, complete) { } exports.toSubscriber = toSubscriber; -},{"../Subscriber":59,"../symbol/rxSubscriber":359}],389:[function(require,module,exports){ +},{"../Subscriber":54,"../symbol/rxSubscriber":354}],384:[function(require,module,exports){ "use strict"; var errorObject_1 = require('./errorObject'); var tryCatchTarget; @@ -21643,7 +20987,185 @@ function tryCatch(fn) { exports.tryCatch = tryCatch; ; -},{"./errorObject":376}],390:[function(require,module,exports){ +},{"./errorObject":371}],385:[function(require,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer + +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} + +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} + +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) + +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} + +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} + +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} + +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} + +},{"buffer":6}],386:[function(require,module,exports){ +/* +Copyright (c) 2014-2016, Matteo Collina + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +'use strict' + +var through = require('through2') +var StringDecoder = require('string_decoder').StringDecoder + +function transform (chunk, enc, cb) { + this._last += this._decoder.write(chunk) + if (this._last.length > this.maxLength) { + return cb(new Error('maximum buffer reached')) + } + + var list = this._last.split(this.matcher) + + this._last = list.pop() + + for (var i = 0; i < list.length; i++) { + push(this, this.mapper(list[i])) + } + + cb() +} + +function flush (cb) { + // forward any gibberish left in there + this._last += this._decoder.end() + + if (this._last) { + push(this, this.mapper(this._last)) + } + + cb() +} + +function push (self, val) { + if (val !== undefined) { + self.push(val) + } +} + +function noop (incoming) { + return incoming +} + +function split (matcher, mapper, options) { + // Set defaults for any arguments not supplied. + matcher = matcher || /\r?\n/ + mapper = mapper || noop + options = options || {} + + // Test arguments explicitly. + switch (arguments.length) { + case 1: + // If mapper is only argument. + if (typeof matcher === 'function') { + mapper = matcher + matcher = /\r?\n/ + // If options is only argument. + } else if (typeof matcher === 'object' && !(matcher instanceof RegExp)) { + options = matcher + matcher = /\r?\n/ + } + break + + case 2: + // If mapper and options are arguments. + if (typeof matcher === 'function') { + options = mapper + mapper = matcher + matcher = /\r?\n/ + // If matcher and options are arguments. + } else if (typeof mapper === 'object') { + options = mapper + mapper = noop + } + } + + var stream = through(options, transform, flush) + + // this stream is in objectMode only in the readable part + stream._readableState.objectMode = true + + // objectMode default hwm is 16 and not 16384 + if (stream._readableState.highWaterMark && !options.highWaterMark) { + stream._readableState.highWaterMark = 16 + } + + stream._last = '' + stream._decoder = new StringDecoder('utf8') + stream.matcher = matcher + stream.mapper = mapper + stream.maxLength = options.maxLength + + return stream +} + +module.exports = split + +},{"string_decoder":407,"through2":424}],387:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -21772,12 +21294,33 @@ Stream.prototype.pipe = function(dest, options) { return dest; }; -},{"events":23,"inherits":32,"readable-stream/duplex.js":392,"readable-stream/passthrough.js":399,"readable-stream/readable.js":400,"readable-stream/transform.js":401,"readable-stream/writable.js":402}],391:[function(require,module,exports){ -arguments[4][8][0].apply(exports,arguments) -},{"dup":8}],392:[function(require,module,exports){ -module.exports = require("./lib/_stream_duplex.js") +},{"events":22,"inherits":29,"readable-stream/duplex.js":389,"readable-stream/passthrough.js":398,"readable-stream/readable.js":399,"readable-stream/transform.js":400,"readable-stream/writable.js":401}],388:[function(require,module,exports){ +arguments[4][7][0].apply(exports,arguments) +},{"dup":7}],389:[function(require,module,exports){ +module.exports = require('./lib/_stream_duplex.js'); + +},{"./lib/_stream_duplex.js":390}],390:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -},{"./lib/_stream_duplex.js":393}],393:[function(require,module,exports){ // a duplex stream is just a stream that is both readable and writable. // Since JS doesn't have multiple prototypal inheritance, this class // prototypally inherits from Readable, and then parasitically from @@ -21787,6 +21330,10 @@ module.exports = require("./lib/_stream_duplex.js") /**/ +var processNextTick = require('process-nextick-args'); +/**/ + +/**/ var objectKeys = Object.keys || function (obj) { var keys = []; for (var key in obj) { @@ -21797,10 +21344,6 @@ var objectKeys = Object.keys || function (obj) { module.exports = Duplex; -/**/ -var processNextTick = require('process-nextick-args'); -/**/ - /**/ var util = require('core-util-is'); util.inherits = require('inherits'); @@ -21848,12 +21391,61 @@ function onEndNT(self) { self.end(); } +Object.defineProperty(Duplex.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); + +Duplex.prototype._destroy = function (err, cb) { + this.push(null); + this.end(); + + processNextTick(cb, err); +}; + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xs[i], i); } } -},{"./_stream_readable":395,"./_stream_writable":397,"core-util-is":10,"inherits":32,"process-nextick-args":40}],394:[function(require,module,exports){ +},{"./_stream_readable":392,"./_stream_writable":394,"core-util-is":9,"inherits":29,"process-nextick-args":39}],391:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // a passthrough stream. // basically just the most minimal sort of Transform stream. // Every written chunk gets output as-is. @@ -21880,16 +21472,38 @@ function PassThrough(options) { PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":396,"core-util-is":10,"inherits":32}],395:[function(require,module,exports){ -(function (process){ -'use strict'; +},{"./_stream_transform":393,"core-util-is":9,"inherits":29}],392:[function(require,module,exports){ +(function (process,global){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -module.exports = Readable; +'use strict'; /**/ + var processNextTick = require('process-nextick-args'); /**/ +module.exports = Readable; + /**/ var isArray = require('isarray'); /**/ @@ -21909,19 +21523,20 @@ var EElistenerCount = function (emitter, type) { /**/ /**/ -var Stream; -(function () { - try { - Stream = require('st' + 'ream'); - } catch (_) {} finally { - if (!Stream) Stream = require('events').EventEmitter; - } -})(); +var Stream = require('./internal/streams/stream'); /**/ -var Buffer = require('buffer').Buffer; +// TODO(bmeurer): Change this back to const once hole checks are +// properly optimized away early in Ignition+TurboFan. /**/ -var bufferShim = require('buffer-shims'); +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} /**/ /**/ @@ -21940,10 +21555,13 @@ if (debugUtil && debugUtil.debuglog) { /**/ var BufferList = require('./internal/streams/BufferList'); +var destroyImpl = require('./internal/streams/destroy'); var StringDecoder; util.inherits(Readable, Stream); +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + function prependListener(emitter, event, fn) { // Sadly this is not cacheable as some libraries bundle their own // event emitter implementation with them. @@ -21976,7 +21594,7 @@ function ReadableState(options, stream) { this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; // cast to ints. - this.highWaterMark = ~ ~this.highWaterMark; + this.highWaterMark = Math.floor(this.highWaterMark); // A linked list is used to store data chunks instead of an array because the // linked list can remove elements from the beginning faster than @@ -21990,10 +21608,10 @@ function ReadableState(options, stream) { this.endEmitted = false; this.reading = false; - // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, because any - // actions that shouldn't happen until "later" should generally also - // not happen before the first write call. + // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. this.sync = true; // whenever we return null, then we set a flag to say @@ -22003,15 +21621,14 @@ function ReadableState(options, stream) { this.readableListening = false; this.resumeScheduled = false; + // has it been destroyed + this.destroyed = false; + // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. // Everything else in the universe uses 'utf8', though. this.defaultEncoding = options.defaultEncoding || 'utf8'; - // when piping, we only care about 'readable' events that happen - // after read()ing all the bytes and not getting any pushback. - this.ranOut = false; - // the number of writers that are awaiting a drain event in .pipe()s this.awaitDrain = 0; @@ -22037,87 +21654,129 @@ function Readable(options) { // legacy this.readable = true; - if (options && typeof options.read === 'function') this._read = options.read; + if (options) { + if (typeof options.read === 'function') this._read = options.read; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } Stream.call(this); } +Object.defineProperty(Readable.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + } +}); + +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; +Readable.prototype._destroy = function (err, cb) { + this.push(null); + cb(err); +}; + // Manually shove something into the read() buffer. // This returns true if the highWaterMark has not been hit yet, // similar to how Writable.write() returns true if you should // write() some more. Readable.prototype.push = function (chunk, encoding) { var state = this._readableState; + var skipChunkCheck; - if (!state.objectMode && typeof chunk === 'string') { - encoding = encoding || state.defaultEncoding; - if (encoding !== state.encoding) { - chunk = bufferShim.from(chunk, encoding); - encoding = ''; + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; } + } else { + skipChunkCheck = true; } - return readableAddChunk(this, state, chunk, encoding, false); + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); }; // Unshift should *always* be something directly out of read() Readable.prototype.unshift = function (chunk) { - var state = this._readableState; - return readableAddChunk(this, state, chunk, '', true); -}; - -Readable.prototype.isPaused = function () { - return this._readableState.flowing === false; + return readableAddChunk(this, chunk, null, true, false); }; -function readableAddChunk(stream, state, chunk, encoding, addToFront) { - var er = chunkInvalid(state, chunk); - if (er) { - stream.emit('error', er); - } else if (chunk === null) { +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + var state = stream._readableState; + if (chunk === null) { state.reading = false; onEofChunk(stream, state); - } else if (state.objectMode || chunk && chunk.length > 0) { - if (state.ended && !addToFront) { - var e = new Error('stream.push() after EOF'); - stream.emit('error', e); - } else if (state.endEmitted && addToFront) { - var _e = new Error('stream.unshift() after end event'); - stream.emit('error', _e); - } else { - var skipAdd; - if (state.decoder && !addToFront && !encoding) { - chunk = state.decoder.write(chunk); - skipAdd = !state.objectMode && chunk.length === 0; - } - - if (!addToFront) state.reading = false; - - // Don't add to the buffer if we've decoded to an empty string chunk and - // we're not in object mode - if (!skipAdd) { - // if we want the data now, just emit it. - if (state.flowing && state.length === 0 && !state.sync) { - stream.emit('data', chunk); - stream.read(0); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (addToFront) { + if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + } else if (state.ended) { + stream.emit('error', new Error('stream.push() after EOF')); + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); } else { - // update the buffer info. - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); - - if (state.needReadable) emitReadable(stream); + addChunk(stream, state, chunk, false); } } - - maybeReadMore(stream, state); + } else if (!addToFront) { + state.reading = false; } - } else if (!addToFront) { - state.reading = false; } return needMoreData(state); } +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + maybeReadMore(stream, state); +} + +function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + // if it's past the high water mark, we can push in some more. // Also, if we have no data yet, we can stand some // more bytes. This is to work around cases where hwm=0, @@ -22129,6 +21788,10 @@ function needMoreData(state) { return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); } +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + // backwards compatibility. Readable.prototype.setEncoding = function (enc) { if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; @@ -22277,14 +21940,6 @@ Readable.prototype.read = function (n) { return ret; }; -function chunkInvalid(state, chunk) { - var er = null; - if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - return er; -} - function onEofChunk(stream, state) { if (state.ended) return; if (state.decoder) { @@ -22372,14 +22027,17 @@ Readable.prototype.pipe = function (dest, pipeOpts) { var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; - var endFn = doEnd ? onend : cleanup; + var endFn = doEnd ? onend : unpipe; if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn); dest.on('unpipe', onunpipe); - function onunpipe(readable) { + function onunpipe(readable, unpipeInfo) { debug('onunpipe'); if (readable === src) { - cleanup(); + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } } } @@ -22405,7 +22063,7 @@ Readable.prototype.pipe = function (dest, pipeOpts) { dest.removeListener('error', onerror); dest.removeListener('unpipe', onunpipe); src.removeListener('end', onend); - src.removeListener('end', cleanup); + src.removeListener('end', unpipe); src.removeListener('data', ondata); cleanedUp = true; @@ -22498,6 +22156,7 @@ function pipeOnDrain(src) { Readable.prototype.unpipe = function (dest) { var state = this._readableState; + var unpipeInfo = { hasUnpiped: false }; // if we're not piping anywhere, then do nothing. if (state.pipesCount === 0) return this; @@ -22513,7 +22172,7 @@ Readable.prototype.unpipe = function (dest) { state.pipes = null; state.pipesCount = 0; state.flowing = false; - if (dest) dest.emit('unpipe', this); + if (dest) dest.emit('unpipe', this, unpipeInfo); return this; } @@ -22528,7 +22187,7 @@ Readable.prototype.unpipe = function (dest) { state.flowing = false; for (var i = 0; i < len; i++) { - dests[i].emit('unpipe', this); + dests[i].emit('unpipe', this, unpipeInfo); }return this; } @@ -22540,7 +22199,7 @@ Readable.prototype.unpipe = function (dest) { state.pipesCount -= 1; if (state.pipesCount === 1) state.pipes = state.pipes[0]; - dest.emit('unpipe', this); + dest.emit('unpipe', this, unpipeInfo); return this; }; @@ -22561,7 +22220,7 @@ Readable.prototype.on = function (ev, fn) { if (!state.reading) { processNextTick(nReadingNextTick, this); } else if (state.length) { - emitReadable(this, state); + emitReadable(this); } } } @@ -22668,10 +22327,9 @@ Readable.prototype.wrap = function (stream) { } // proxy certain important events. - var events = ['error', 'close', 'destroy', 'pause', 'resume']; - forEach(events, function (ev) { - stream.on(ev, self.emit.bind(self, ev)); - }); + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n])); + } // when we try to consume some more bytes, simply unpause the // underlying stream. @@ -22763,7 +22421,7 @@ function copyFromBufferString(n, list) { // This function is designed to be inlinable, so please take care when making // changes to the function body. function copyFromBuffer(n, list) { - var ret = bufferShim.allocUnsafe(n); + var ret = Buffer.allocUnsafe(n); var p = list.head; var c = 1; p.data.copy(ret); @@ -22823,9 +22481,30 @@ function indexOf(xs, x) { } return -1; } -}).call(this,require('_process')) +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"./_stream_duplex":390,"./internal/streams/BufferList":395,"./internal/streams/destroy":396,"./internal/streams/stream":397,"_process":40,"core-util-is":9,"events":22,"inherits":29,"isarray":388,"process-nextick-args":39,"safe-buffer":385,"string_decoder/":402,"util":4}],393:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -},{"./_stream_duplex":393,"./internal/streams/BufferList":398,"_process":41,"buffer":7,"buffer-shims":6,"core-util-is":10,"events":23,"inherits":32,"isarray":391,"process-nextick-args":40,"string_decoder/":419,"util":4}],396:[function(require,module,exports){ // a transform stream is a readable/writable stream where you do // something with the data. Sometimes it's called a "filter", // but that's not a great name for it, since that implies a thing where @@ -22899,7 +22578,9 @@ function afterTransform(stream, er, data) { var cb = ts.writecb; - if (!cb) return stream.emit('error', new Error('no writecb in Transform class')); + if (!cb) { + return stream.emit('error', new Error('write callback called multiple times')); + } ts.writechunk = null; ts.writecb = null; @@ -22992,6 +22673,15 @@ Transform.prototype._read = function (n) { } }; +Transform.prototype._destroy = function (err, cb) { + var _this = this; + + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + _this.emit('close'); + }); +}; + function done(stream, er, data) { if (er) return stream.emit('error', er); @@ -23008,20 +22698,63 @@ function done(stream, er, data) { return stream.push(null); } -},{"./_stream_duplex":393,"core-util-is":10,"inherits":32}],397:[function(require,module,exports){ -(function (process){ +},{"./_stream_duplex":390,"core-util-is":9,"inherits":29}],394:[function(require,module,exports){ +(function (process,global){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // A bit simpler than readable streams. // Implement an async ._write(chunk, encoding, cb), and it'll handle all // the drain event emission and buffering. 'use strict'; -module.exports = Writable; - /**/ + var processNextTick = require('process-nextick-args'); /**/ +module.exports = Writable; + +/* */ +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} + +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ + /**/ var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick; /**/ @@ -23044,32 +22777,26 @@ var internalUtil = { /**/ /**/ -var Stream; -(function () { - try { - Stream = require('st' + 'ream'); - } catch (_) {} finally { - if (!Stream) Stream = require('events').EventEmitter; - } -})(); +var Stream = require('./internal/streams/stream'); /**/ -var Buffer = require('buffer').Buffer; /**/ -var bufferShim = require('buffer-shims'); +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} /**/ +var destroyImpl = require('./internal/streams/destroy'); + util.inherits(Writable, Stream); function nop() {} -function WriteReq(chunk, encoding, cb) { - this.chunk = chunk; - this.encoding = encoding; - this.callback = cb; - this.next = null; -} - function WritableState(options, stream) { Duplex = Duplex || require('./_stream_duplex'); @@ -23089,7 +22816,10 @@ function WritableState(options, stream) { this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; // cast to ints. - this.highWaterMark = ~ ~this.highWaterMark; + this.highWaterMark = Math.floor(this.highWaterMark); + + // if _final has been called + this.finalCalled = false; // drain event flag. this.needDrain = false; @@ -23100,6 +22830,9 @@ function WritableState(options, stream) { // when 'finish' is emitted this.finished = false; + // has it been destroyed + this.destroyed = false; + // should we decode strings into buffers before passing to _write? // this is here so that some node-core streams can optimize string // handling at a lower level. @@ -23181,7 +22914,7 @@ WritableState.prototype.getBuffer = function getBuffer() { Object.defineProperty(WritableState.prototype, 'buffer', { get: internalUtil.deprecate(function () { return this.getBuffer(); - }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.') + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') }); } catch (_) {} })(); @@ -23227,6 +22960,10 @@ function Writable(options) { if (typeof options.write === 'function') this._write = options.write; if (typeof options.writev === 'function') this._writev = options.writev; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + + if (typeof options.final === 'function') this._final = options.final; } Stream.call(this); @@ -23244,20 +22981,16 @@ function writeAfterEnd(stream, cb) { processNextTick(cb, er); } -// If we get something that is not a buffer, string, null, or undefined, -// and we're not in objectMode, then that's an error. -// Otherwise stream chunks are all considered to be of length=1, and the -// watermarks determine how many objects to keep in the buffer, rather than -// how many bytes or characters. +// Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. function validChunk(stream, state, chunk, cb) { var valid = true; var er = false; - // Always throw error if a null is written - // if we are not in object mode then throw - // if it is not a buffer, string, or undefined. + if (chunk === null) { er = new TypeError('May not write null values to stream'); - } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { er = new TypeError('Invalid non-string/buffer chunk'); } if (er) { @@ -23271,19 +23004,24 @@ function validChunk(stream, state, chunk, cb) { Writable.prototype.write = function (chunk, encoding, cb) { var state = this._writableState; var ret = false; + var isBuf = _isUint8Array(chunk) && !state.objectMode; + + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } if (typeof encoding === 'function') { cb = encoding; encoding = null; } - if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; if (typeof cb !== 'function') cb = nop; - if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) { + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { state.pendingcb++; - ret = writeOrBuffer(this, state, chunk, encoding, cb); + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } return ret; @@ -23315,7 +23053,7 @@ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { - chunk = bufferShim.from(chunk, encoding); + chunk = Buffer.from(chunk, encoding); } return chunk; } @@ -23323,10 +23061,15 @@ function decodeChunk(state, chunk, encoding) { // if we're already writing something, then just put this // in the queue, and wait our turn. Otherwise, call _write // If we return false, then we need a drain event, so set that flag. -function writeOrBuffer(stream, state, chunk, encoding, cb) { - chunk = decodeChunk(state, chunk, encoding); - - if (Buffer.isBuffer(chunk)) encoding = 'buffer'; +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } + } var len = state.objectMode ? 1 : chunk.length; state.length += len; @@ -23337,7 +23080,13 @@ function writeOrBuffer(stream, state, chunk, encoding, cb) { if (state.writing || state.corked) { var last = state.lastBufferedRequest; - state.lastBufferedRequest = new WriteReq(chunk, encoding, cb); + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; if (last) { last.next = state.lastBufferedRequest; } else { @@ -23362,10 +23111,26 @@ function doWrite(stream, state, writev, len, chunk, encoding, cb) { function onwriteError(stream, state, sync, er, cb) { --state.pendingcb; - if (sync) processNextTick(cb, er);else cb(er); - stream._writableState.errorEmitted = true; - stream.emit('error', er); + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + processNextTick(cb, er); + // this can emit finish, and it will always happen + // after error + processNextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + // this can emit finish, but finish must + // always follow error + finishMaybe(stream, state); + } } function onwriteStateUpdate(state) { @@ -23395,8 +23160,8 @@ function onwrite(stream, er) { asyncWrite(afterWrite, stream, state, finished, cb); /**/ } else { - afterWrite(stream, state, finished, cb); - } + afterWrite(stream, state, finished, cb); + } } } @@ -23430,11 +23195,14 @@ function clearBuffer(stream, state) { holder.entry = entry; var count = 0; + var allBuffers = true; while (entry) { buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; entry = entry.next; count += 1; } + buffer.allBuffers = allBuffers; doWrite(stream, state, true, state.length, buffer, '', holder.finish); @@ -23508,23 +23276,37 @@ Writable.prototype.end = function (chunk, encoding, cb) { function needFinish(state) { return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; } - -function prefinish(stream, state) { - if (!state.prefinished) { +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + stream.emit('error', err); + } state.prefinished = true; stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function') { + state.pendingcb++; + state.finalCalled = true; + processNextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } } } function finishMaybe(stream, state) { var need = needFinish(state); if (need) { + prefinish(stream, state); if (state.pendingcb === 0) { - prefinish(stream, state); state.finished = true; stream.emit('finish'); - } else { - prefinish(stream, state); } } return need; @@ -23540,2366 +23322,2649 @@ function endWritable(stream, state, cb) { stream.writable = false; } -// It seems a linked list but it is not -// there will be only 2 of these for each stream -function CorkedRequest(state) { - var _this = this; - - this.next = null; - this.entry = null; +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = corkReq; + } else { + state.corkedRequestsFree = corkReq; + } +} - this.finish = function (err) { - var entry = _this.entry; - _this.entry = null; - while (entry) { - var cb = entry.callback; - state.pendingcb--; - cb(err); - entry = entry.next; +Object.defineProperty(Writable.prototype, 'destroyed', { + get: function () { + if (this._writableState === undefined) { + return false; } - if (state.corkedRequestsFree) { - state.corkedRequestsFree.next = _this; - } else { - state.corkedRequestsFree = _this; + return this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; } - }; + + // backward compatibility, the user is explicitly + // managing destroyed + this._writableState.destroyed = value; + } +}); + +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; +Writable.prototype._destroy = function (err, cb) { + this.end(); + cb(err); +}; +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"./_stream_duplex":390,"./internal/streams/destroy":396,"./internal/streams/stream":397,"_process":40,"core-util-is":9,"inherits":29,"process-nextick-args":39,"safe-buffer":385,"util-deprecate":425}],395:[function(require,module,exports){ +'use strict'; + +/**/ + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Buffer = require('safe-buffer').Buffer; +/**/ + +function copyBuffer(src, target, offset) { + src.copy(target, offset); } -}).call(this,require('_process')) -},{"./_stream_duplex":393,"_process":41,"buffer":7,"buffer-shims":6,"core-util-is":10,"events":23,"inherits":32,"process-nextick-args":40,"util-deprecate":427}],398:[function(require,module,exports){ +module.exports = function () { + function BufferList() { + _classCallCheck(this, BufferList); + + this.head = null; + this.tail = null; + this.length = 0; + } + + BufferList.prototype.push = function push(v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + }; + + BufferList.prototype.unshift = function unshift(v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + }; + + BufferList.prototype.shift = function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + }; + + BufferList.prototype.clear = function clear() { + this.head = this.tail = null; + this.length = 0; + }; + + BufferList.prototype.join = function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; + }; + + BufferList.prototype.concat = function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + if (this.length === 1) return this.head.data; + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + return ret; + }; + + return BufferList; +}(); +},{"safe-buffer":385}],396:[function(require,module,exports){ 'use strict'; -var Buffer = require('buffer').Buffer; /**/ -var bufferShim = require('buffer-shims'); + +var processNextTick = require('process-nextick-args'); /**/ -module.exports = BufferList; +// undocumented cb() API, needed for core, not for public API +function destroy(err, cb) { + var _this = this; -function BufferList() { - this.head = null; - this.tail = null; - this.length = 0; -} + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; -BufferList.prototype.push = function (v) { - var entry = { data: v, next: null }; - if (this.length > 0) this.tail.next = entry;else this.head = entry; - this.tail = entry; - ++this.length; -}; + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { + processNextTick(emitErrorNT, this, err); + } + return; + } -BufferList.prototype.unshift = function (v) { - var entry = { data: v, next: this.head }; - if (this.length === 0) this.tail = entry; - this.head = entry; - ++this.length; -}; + // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks -BufferList.prototype.shift = function () { - if (this.length === 0) return; - var ret = this.head.data; - if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; - --this.length; - return ret; -}; + if (this._readableState) { + this._readableState.destroyed = true; + } -BufferList.prototype.clear = function () { - this.head = this.tail = null; - this.length = 0; -}; + // if this is a duplex stream mark the writable part as destroyed as well + if (this._writableState) { + this._writableState.destroyed = true; + } -BufferList.prototype.join = function (s) { - if (this.length === 0) return ''; - var p = this.head; - var ret = '' + p.data; - while (p = p.next) { - ret += s + p.data; - }return ret; -}; + this._destroy(err || null, function (err) { + if (!cb && err) { + processNextTick(emitErrorNT, _this, err); + if (_this._writableState) { + _this._writableState.errorEmitted = true; + } + } else if (cb) { + cb(err); + } + }); +} -BufferList.prototype.concat = function (n) { - if (this.length === 0) return bufferShim.alloc(0); - if (this.length === 1) return this.head.data; - var ret = bufferShim.allocUnsafe(n >>> 0); - var p = this.head; - var i = 0; - while (p) { - p.data.copy(ret, i); - i += p.data.length; - p = p.next; +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; } - return ret; + + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } +} + +function emitErrorNT(self, err) { + self.emit('error', err); +} + +module.exports = { + destroy: destroy, + undestroy: undestroy }; -},{"buffer":7,"buffer-shims":6}],399:[function(require,module,exports){ -module.exports = require("./lib/_stream_passthrough.js") +},{"process-nextick-args":39}],397:[function(require,module,exports){ +module.exports = require('events').EventEmitter; -},{"./lib/_stream_passthrough.js":394}],400:[function(require,module,exports){ -(function (process){ -var Stream = (function (){ - try { - return require('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify - } catch(_){} -}()); +},{"events":22}],398:[function(require,module,exports){ +module.exports = require('./readable').PassThrough + +},{"./readable":399}],399:[function(require,module,exports){ exports = module.exports = require('./lib/_stream_readable.js'); -exports.Stream = Stream || exports; +exports.Stream = exports; exports.Readable = exports; exports.Writable = require('./lib/_stream_writable.js'); exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); -if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) { - module.exports = Stream; -} +},{"./lib/_stream_duplex.js":390,"./lib/_stream_passthrough.js":391,"./lib/_stream_readable.js":392,"./lib/_stream_transform.js":393,"./lib/_stream_writable.js":394}],400:[function(require,module,exports){ +module.exports = require('./readable').Transform -}).call(this,require('_process')) +},{"./readable":399}],401:[function(require,module,exports){ +module.exports = require('./lib/_stream_writable.js'); -},{"./lib/_stream_duplex.js":393,"./lib/_stream_passthrough.js":394,"./lib/_stream_readable.js":395,"./lib/_stream_transform.js":396,"./lib/_stream_writable.js":397,"_process":41}],401:[function(require,module,exports){ -module.exports = require("./lib/_stream_transform.js") +},{"./lib/_stream_writable.js":394}],402:[function(require,module,exports){ +'use strict'; -},{"./lib/_stream_transform.js":396}],402:[function(require,module,exports){ -module.exports = require("./lib/_stream_writable.js") +var Buffer = require('safe-buffer').Buffer; -},{"./lib/_stream_writable.js":397}],403:[function(require,module,exports){ -(function (global){ -var ClientRequest = require('./lib/request') -var extend = require('xtend') -var statusCodes = require('builtin-status-codes') -var url = require('url') - -var http = exports - -http.request = function (opts, cb) { - if (typeof opts === 'string') - opts = url.parse(opts) - else - opts = extend(opts) - - // Normally, the page is loaded from http or https, so not specifying a protocol - // will result in a (valid) protocol-relative url. However, this won't work if - // the protocol is something else, like 'file:' - var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : '' - - var protocol = opts.protocol || defaultProtocol - var host = opts.hostname || opts.host - var port = opts.port - var path = opts.path || '/' - - // Necessary for IPv6 addresses - if (host && host.indexOf(':') !== -1) - host = '[' + host + ']' - - // This may be a relative url. The browser should always be able to interpret it correctly. - opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path - opts.method = (opts.method || 'GET').toUpperCase() - opts.headers = opts.headers || {} - - // Also valid opts.auth, opts.mode - - var req = new ClientRequest(opts) - if (cb) - req.on('response', cb) - return req -} - -http.get = function get (opts, cb) { - var req = http.request(opts, cb) - req.end() - return req -} - -http.Agent = function () {} -http.Agent.defaultMaxSockets = 4 - -http.STATUS_CODES = statusCodes - -http.METHODS = [ - 'CHECKOUT', - 'CONNECT', - 'COPY', - 'DELETE', - 'GET', - 'HEAD', - 'LOCK', - 'M-SEARCH', - 'MERGE', - 'MKACTIVITY', - 'MKCOL', - 'MOVE', - 'NOTIFY', - 'OPTIONS', - 'PATCH', - 'POST', - 'PROPFIND', - 'PROPPATCH', - 'PURGE', - 'PUT', - 'REPORT', - 'SEARCH', - 'SUBSCRIBE', - 'TRACE', - 'UNLOCK', - 'UNSUBSCRIBE' -] -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; + } +}; -},{"./lib/request":405,"builtin-status-codes":9,"url":425,"xtend":428}],404:[function(require,module,exports){ -(function (global){ -exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream) +function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; + default: + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; + } + } +}; -exports.blobConstructor = false -try { - new Blob([new ArrayBuffer(1)]) - exports.blobConstructor = true -} catch (e) {} - -// The xhr request to example.com may violate some restrictive CSP configurations, -// so if we're running in a browser that supports `fetch`, avoid calling getXHR() -// and assume support for certain features below. -var xhr -function getXHR () { - // Cache the xhr value - if (xhr !== undefined) return xhr - - if (global.XMLHttpRequest) { - xhr = new global.XMLHttpRequest() - // If XDomainRequest is available (ie only, where xhr might not work - // cross domain), use the page location. Otherwise use example.com - // Note: this doesn't actually make an http request. - try { - xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com') - } catch(e) { - xhr = null - } - } else { - // Service workers don't have XHR - xhr = null - } - return xhr +// Do not cache `Buffer.isEncoding` when checking encoding names as some +// modules monkey-patch it to support additional encodings +function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; } -function checkTypeSupport (type) { - var xhr = getXHR() - if (!xhr) return false - try { - xhr.responseType = type - return xhr.responseType === type - } catch (e) {} - return false +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. +exports.StringDecoder = StringDecoder; +function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; + } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); } -// For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'. -// Safari 7.1 appears to have fixed this bug. -var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined' -var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice) - -// If fetch is supported, then arraybuffer will be supported too. Skip calling -// checkTypeSupport(), since that calls getXHR(). -exports.arraybuffer = exports.fetch || (haveArrayBuffer && checkTypeSupport('arraybuffer')) +StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; +}; -// These next two tests unavoidably show warnings in Chrome. Since fetch will always -// be used if it's available, just return false for these to avoid the warnings. -exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream') -exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer && - checkTypeSupport('moz-chunked-arraybuffer') +StringDecoder.prototype.end = utf8End; -// If fetch is supported, then overrideMimeType will be supported too. Skip calling -// getXHR(). -exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false) +// Returns only complete characters in a Buffer +StringDecoder.prototype.text = utf8Text; -exports.vbArray = isFunction(global.VBArray) +// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer +StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; +}; -function isFunction (value) { - return typeof value === 'function' +// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a +// continuation byte. +function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return -1; } -xhr = null // Help gc - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - -},{}],405:[function(require,module,exports){ -(function (process,global,Buffer){ -var capability = require('./capability') -var inherits = require('inherits') -var response = require('./response') -var stream = require('readable-stream') -var toArrayBuffer = require('to-arraybuffer') - -var IncomingMessage = response.IncomingMessage -var rStates = response.readyStates - -function decideMode (preferBinary, useFetch) { - if (capability.fetch && useFetch) { - return 'fetch' - } else if (capability.mozchunkedarraybuffer) { - return 'moz-chunked-arraybuffer' - } else if (capability.msstream) { - return 'ms-stream' - } else if (capability.arraybuffer && preferBinary) { - return 'arraybuffer' - } else if (capability.vbArray && preferBinary) { - return 'text:vbarray' - } else { - return 'text' - } +// Checks at most 3 bytes at the end of a Buffer in order to detect an +// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) +// needed to complete the UTF-8 character (if applicable) are returned. +function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; + } + return nb; + } + return 0; } -var ClientRequest = module.exports = function (opts) { - var self = this - stream.Writable.call(self) - - self._opts = opts - self._body = [] - self._headers = {} - if (opts.auth) - self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64')) - Object.keys(opts.headers).forEach(function (name) { - self.setHeader(name, opts.headers[name]) - }) - - var preferBinary - var useFetch = true - if (opts.mode === 'disable-fetch' || 'timeout' in opts) { - // If the use of XHR should be preferred and includes preserving the 'content-type' header. - // Force XHR to be used since the Fetch API does not yet support timeouts. - useFetch = false - preferBinary = true - } else if (opts.mode === 'prefer-streaming') { - // If streaming is a high priority but binary compatibility and - // the accuracy of the 'content-type' header aren't - preferBinary = false - } else if (opts.mode === 'allow-wrong-content-type') { - // If streaming is more important than preserving the 'content-type' header - preferBinary = !capability.overrideMimeType - } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') { - // Use binary if text streaming may corrupt data or the content-type header, or for speed - preferBinary = true - } else { - throw new Error('Invalid value for opts.mode') - } - self._mode = decideMode(preferBinary, useFetch) - - self.on('finish', function () { - self._onFinish() - }) +// Validates as many continuation bytes for a multi-byte UTF-8 character as +// needed or are available. If we see a non-continuation byte where we expect +// one, we "replace" the validated continuation bytes we've seen so far with +// UTF-8 replacement characters ('\ufffd'), to match v8's UTF-8 decoding +// behavior. The continuation byte check is included three times in the case +// where all of the continuation bytes for a character exist in the same buffer. +// It is also done this way as a slight performance increase instead of using a +// loop. +function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'.repeat(p); + } + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'.repeat(p + 1); + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'.repeat(p + 2); + } + } + } +} + +// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. +function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf, p); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; +} + +// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a +// partial character, the character's bytes are buffered until the required +// number of bytes are available. +function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); +} + +// For UTF-8, a replacement character for each buffered byte of a (partial) +// character needs to be added to the output. +function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed); + return r; +} + +// UTF-16LE typically needs two bytes per character, but even if we have an even +// number of bytes available, we need to check if we end on a leading/high +// surrogate. In that case, we need to wait for the next two bytes in order to +// decode the last character properly. +function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; + } + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); +} + +// For UTF-16LE we do not explicitly append special replacement characters if we +// end on a partial character, we simply let v8 handle that. +function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; +} + +function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; + } else { + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + } + return buf.toString('base64', i, buf.length - n); } -inherits(ClientRequest, stream.Writable) - -ClientRequest.prototype.setHeader = function (name, value) { - var self = this - var lowerName = name.toLowerCase() - // This check is not necessary, but it prevents warnings from browsers about setting unsafe - // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but - // http-browserify did it, so I will too. - if (unsafeHeaders.indexOf(lowerName) !== -1) - return - - self._headers[lowerName] = { - name: name, - value: value - } +function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; } -ClientRequest.prototype.getHeader = function (name) { - var self = this - return self._headers[name.toLowerCase()].value +// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) +function simpleWrite(buf) { + return buf.toString(this.encoding); } -ClientRequest.prototype.removeHeader = function (name) { - var self = this - delete self._headers[name.toLowerCase()] +function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; } +},{"safe-buffer":385}],403:[function(require,module,exports){ +'use strict'; -ClientRequest.prototype._onFinish = function () { - var self = this +var bind = require('function-bind'); +var ES = require('es-abstract/es5'); +var replace = bind.call(Function.call, String.prototype.replace); - if (self._destroyed) - return - var opts = self._opts +var leftWhitespace = /^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/; +var rightWhitespace = /[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/; - var headersObj = self._headers - var body = null - if (opts.method === 'POST' || opts.method === 'PUT' || opts.method === 'PATCH' || opts.method === 'MERGE') { - if (capability.blobConstructor) { - body = new global.Blob(self._body.map(function (buffer) { - return toArrayBuffer(buffer) - }), { - type: (headersObj['content-type'] || {}).value || '' - }) - } else { - // get utf8 string - body = Buffer.concat(self._body).toString() - } - } +module.exports = function trim() { + var S = ES.ToString(ES.CheckObjectCoercible(this)); + return replace(replace(S, leftWhitespace, ''), rightWhitespace, ''); +}; - if (self._mode === 'fetch') { - var headers = Object.keys(headersObj).map(function (name) { - return [headersObj[name].name, headersObj[name].value] - }) - - global.fetch(self._opts.url, { - method: self._opts.method, - headers: headers, - body: body || undefined, - mode: 'cors', - credentials: opts.withCredentials ? 'include' : 'same-origin' - }).then(function (response) { - self._fetchResponse = response - self._connect() - }, function (reason) { - self.emit('error', reason) - }) - } else { - var xhr = self._xhr = new global.XMLHttpRequest() - try { - xhr.open(self._opts.method, self._opts.url, true) - } catch (err) { - process.nextTick(function () { - self.emit('error', err) - }) - return - } +},{"es-abstract/es5":15,"function-bind":26}],404:[function(require,module,exports){ +'use strict'; - // Can't set responseType on really old browsers - if ('responseType' in xhr) - xhr.responseType = self._mode.split(':')[0] +var bind = require('function-bind'); +var define = require('define-properties'); - if ('withCredentials' in xhr) - xhr.withCredentials = !!opts.withCredentials +var implementation = require('./implementation'); +var getPolyfill = require('./polyfill'); +var shim = require('./shim'); - if (self._mode === 'text' && 'overrideMimeType' in xhr) - xhr.overrideMimeType('text/plain; charset=x-user-defined') +var boundTrim = bind.call(Function.call, getPolyfill()); - if ('timeout' in opts) { - xhr.timeout = opts.timeout - xhr.ontimeout = function () { - self.emit('timeout') - } - } +define(boundTrim, { + getPolyfill: getPolyfill, + implementation: implementation, + shim: shim +}); - Object.keys(headersObj).forEach(function (name) { - xhr.setRequestHeader(headersObj[name].name, headersObj[name].value) - }) - - self._response = null - xhr.onreadystatechange = function () { - switch (xhr.readyState) { - case rStates.LOADING: - case rStates.DONE: - self._onXHRProgress() - break - } - } - // Necessary for streaming in Firefox, since xhr.response is ONLY defined - // in onprogress, not in onreadystatechange with xhr.readyState = 3 - if (self._mode === 'moz-chunked-arraybuffer') { - xhr.onprogress = function () { - self._onXHRProgress() - } - } +module.exports = boundTrim; - xhr.onerror = function () { - if (self._destroyed) - return - self.emit('error', new Error('XHR error')) - } +},{"./implementation":403,"./polyfill":405,"./shim":406,"define-properties":13,"function-bind":26}],405:[function(require,module,exports){ +'use strict'; - try { - xhr.send(body) - } catch (err) { - process.nextTick(function () { - self.emit('error', err) - }) - return - } - } -} +var implementation = require('./implementation'); -/** - * Checks if xhr.status is readable and non-zero, indicating no error. - * Even though the spec says it should be available in readyState 3, - * accessing it throws an exception in IE8 - */ -function statusValid (xhr) { - try { - var status = xhr.status - return (status !== null && status !== 0) - } catch (e) { - return false +var zeroWidthSpace = '\u200b'; + +module.exports = function getPolyfill() { + if (String.prototype.trim && zeroWidthSpace.trim() === zeroWidthSpace) { + return String.prototype.trim; } -} + return implementation; +}; -ClientRequest.prototype._onXHRProgress = function () { - var self = this +},{"./implementation":403}],406:[function(require,module,exports){ +'use strict'; - if (!statusValid(self._xhr) || self._destroyed) - return +var define = require('define-properties'); +var getPolyfill = require('./polyfill'); - if (!self._response) - self._connect() +module.exports = function shimStringTrim() { + var polyfill = getPolyfill(); + define(String.prototype, { trim: polyfill }, { trim: function () { return String.prototype.trim !== polyfill; } }); + return polyfill; +}; - self._response._onXHRProgress() -} +},{"./polyfill":405,"define-properties":13}],407:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -ClientRequest.prototype._connect = function () { - var self = this +var Buffer = require('buffer').Buffer; - if (self._destroyed) - return +var isBufferEncoding = Buffer.isEncoding + || function(encoding) { + switch (encoding && encoding.toLowerCase()) { + case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; + default: return false; + } + } - self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode) - self._response.on('error', function(err) { - self.emit('error', err) - }) - self.emit('response', self._response) +function assertEncoding(encoding) { + if (encoding && !isBufferEncoding(encoding)) { + throw new Error('Unknown encoding: ' + encoding); + } } -ClientRequest.prototype._write = function (chunk, encoding, cb) { - var self = this +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. CESU-8 is handled as part of the UTF-8 encoding. +// +// @TODO Handling all encodings inside a single object makes it very difficult +// to reason about this code, so it should be split up in the future. +// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code +// points as used by CESU-8. +var StringDecoder = exports.StringDecoder = function(encoding) { + this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); + assertEncoding(encoding); + switch (this.encoding) { + case 'utf8': + // CESU-8 represents each of Surrogate Pair by 3-bytes + this.surrogateSize = 3; + break; + case 'ucs2': + case 'utf16le': + // UTF-16 represents each of Surrogate Pair by 2-bytes + this.surrogateSize = 2; + this.detectIncompleteChar = utf16DetectIncompleteChar; + break; + case 'base64': + // Base-64 stores 3 bytes in 4 chars, and pads the remainder. + this.surrogateSize = 3; + this.detectIncompleteChar = base64DetectIncompleteChar; + break; + default: + this.write = passThroughWrite; + return; + } - self._body.push(chunk) - cb() -} + // Enough space to store all bytes of a single character. UTF-8 needs 4 + // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). + this.charBuffer = new Buffer(6); + // Number of bytes received for the current incomplete multi-byte character. + this.charReceived = 0; + // Number of bytes expected for the current incomplete multi-byte character. + this.charLength = 0; +}; -ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () { - var self = this - self._destroyed = true - if (self._response) - self._response._destroyed = true - if (self._xhr) - self._xhr.abort() - // Currently, there isn't a way to truly abort a fetch. - // If you like bikeshedding, see https://github.com/whatwg/fetch/issues/27 -} -ClientRequest.prototype.end = function (data, encoding, cb) { - var self = this - if (typeof data === 'function') { - cb = data - data = undefined - } +// write decodes the given buffer and returns it as JS string that is +// guaranteed to not contain any partial multi-byte characters. Any partial +// character found at the end of the buffer is buffered up, and will be +// returned when calling write again with the remaining bytes. +// +// Note: Converting a Buffer containing an orphan surrogate to a String +// currently works, but converting a String to a Buffer (via `new Buffer`, or +// Buffer#write) will replace incomplete surrogates with the unicode +// replacement character. See https://codereview.chromium.org/121173009/ . +StringDecoder.prototype.write = function(buffer) { + var charStr = ''; + // if our last write ended with an incomplete multibyte character + while (this.charLength) { + // determine how many remaining bytes this buffer has to offer for this char + var available = (buffer.length >= this.charLength - this.charReceived) ? + this.charLength - this.charReceived : + buffer.length; - stream.Writable.prototype.end.call(self, data, encoding, cb) -} - -ClientRequest.prototype.flushHeaders = function () {} -ClientRequest.prototype.setTimeout = function () {} -ClientRequest.prototype.setNoDelay = function () {} -ClientRequest.prototype.setSocketKeepAlive = function () {} - -// Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method -var unsafeHeaders = [ - 'accept-charset', - 'accept-encoding', - 'access-control-request-headers', - 'access-control-request-method', - 'connection', - 'content-length', - 'cookie', - 'cookie2', - 'date', - 'dnt', - 'expect', - 'host', - 'keep-alive', - 'origin', - 'referer', - 'te', - 'trailer', - 'transfer-encoding', - 'upgrade', - 'user-agent', - 'via' -] - -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) - -},{"./capability":404,"./response":406,"_process":41,"buffer":7,"inherits":32,"readable-stream":414,"to-arraybuffer":424}],406:[function(require,module,exports){ -(function (process,global,Buffer){ -var capability = require('./capability') -var inherits = require('inherits') -var stream = require('readable-stream') - -var rStates = exports.readyStates = { - UNSENT: 0, - OPENED: 1, - HEADERS_RECEIVED: 2, - LOADING: 3, - DONE: 4 -} - -var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode) { - var self = this - stream.Readable.call(self) - - self._mode = mode - self.headers = {} - self.rawHeaders = [] - self.trailers = {} - self.rawTrailers = [] - - // Fake the 'close' event, but only once 'end' fires - self.on('end', function () { - // The nextTick is necessary to prevent the 'request' module from causing an infinite loop - process.nextTick(function () { - self.emit('close') - }) - }) - - if (mode === 'fetch') { - self._fetchResponse = response - - self.url = response.url - self.statusCode = response.status - self.statusMessage = response.statusText - - response.headers.forEach(function(header, key){ - self.headers[key.toLowerCase()] = header - self.rawHeaders.push(key, header) - }) - - - // TODO: this doesn't respect backpressure. Once WritableStream is available, this can be fixed - var reader = response.body.getReader() - function read () { - reader.read().then(function (result) { - if (self._destroyed) - return - if (result.done) { - self.push(null) - return - } - self.push(new Buffer(result.value)) - read() - }).catch(function(err) { - self.emit('error', err) - }) - } - read() + // add the new bytes to the char buffer + buffer.copy(this.charBuffer, this.charReceived, 0, available); + this.charReceived += available; - } else { - self._xhr = xhr - self._pos = 0 - - self.url = xhr.responseURL - self.statusCode = xhr.status - self.statusMessage = xhr.statusText - var headers = xhr.getAllResponseHeaders().split(/\r?\n/) - headers.forEach(function (header) { - var matches = header.match(/^([^:]+):\s*(.*)/) - if (matches) { - var key = matches[1].toLowerCase() - if (key === 'set-cookie') { - if (self.headers[key] === undefined) { - self.headers[key] = [] - } - self.headers[key].push(matches[2]) - } else if (self.headers[key] !== undefined) { - self.headers[key] += ', ' + matches[2] - } else { - self.headers[key] = matches[2] - } - self.rawHeaders.push(matches[1], matches[2]) - } - }) - - self._charset = 'x-user-defined' - if (!capability.overrideMimeType) { - var mimeType = self.rawHeaders['mime-type'] - if (mimeType) { - var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/) - if (charsetMatch) { - self._charset = charsetMatch[1].toLowerCase() - } - } - if (!self._charset) - self._charset = 'utf-8' // best guess - } - } -} + if (this.charReceived < this.charLength) { + // still not enough chars in this buffer? wait for more ... + return ''; + } -inherits(IncomingMessage, stream.Readable) + // remove bytes belonging to the current character from the buffer + buffer = buffer.slice(available, buffer.length); -IncomingMessage.prototype._read = function () {} + // get the character that was split + charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); -IncomingMessage.prototype._onXHRProgress = function () { - var self = this + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + var charCode = charStr.charCodeAt(charStr.length - 1); + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + this.charLength += this.surrogateSize; + charStr = ''; + continue; + } + this.charReceived = this.charLength = 0; - var xhr = self._xhr + // if there are no more bytes in this buffer, just emit our char + if (buffer.length === 0) { + return charStr; + } + break; + } - var response = null - switch (self._mode) { - case 'text:vbarray': // For IE9 - if (xhr.readyState !== rStates.DONE) - break - try { - // This fails in IE8 - response = new global.VBArray(xhr.responseBody).toArray() - } catch (e) {} - if (response !== null) { - self.push(new Buffer(response)) - break - } - // Falls through in IE8 - case 'text': - try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4 - response = xhr.responseText - } catch (e) { - self._mode = 'text:vbarray' - break - } - if (response.length > self._pos) { - var newData = response.substr(self._pos) - if (self._charset === 'x-user-defined') { - var buffer = new Buffer(newData.length) - for (var i = 0; i < newData.length; i++) - buffer[i] = newData.charCodeAt(i) & 0xff - - self.push(buffer) - } else { - self.push(newData, self._charset) - } - self._pos = response.length - } - break - case 'arraybuffer': - if (xhr.readyState !== rStates.DONE || !xhr.response) - break - response = xhr.response - self.push(new Buffer(new Uint8Array(response))) - break - case 'moz-chunked-arraybuffer': // take whole - response = xhr.response - if (xhr.readyState !== rStates.LOADING || !response) - break - self.push(new Buffer(new Uint8Array(response))) - break - case 'ms-stream': - response = xhr.response - if (xhr.readyState !== rStates.LOADING) - break - var reader = new global.MSStreamReader() - reader.onprogress = function () { - if (reader.result.byteLength > self._pos) { - self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos)))) - self._pos = reader.result.byteLength - } - } - reader.onload = function () { - self.push(null) - } - // reader.onerror = ??? // TODO: this - reader.readAsArrayBuffer(response) - break - } + // determine and set charLength / charReceived + this.detectIncompleteChar(buffer); - // The ms-stream case handles end separately in reader.onload() - if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') { - self.push(null) - } -} + var end = buffer.length; + if (this.charLength) { + // buffer the incomplete character bytes we got + buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); + end -= this.charReceived; + } -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) + charStr += buffer.toString(this.encoding, 0, end); -},{"./capability":404,"_process":41,"buffer":7,"inherits":32,"readable-stream":414}],407:[function(require,module,exports){ -arguments[4][8][0].apply(exports,arguments) -},{"dup":8}],408:[function(require,module,exports){ -arguments[4][393][0].apply(exports,arguments) -},{"./_stream_readable":410,"./_stream_writable":412,"core-util-is":10,"dup":393,"inherits":32,"process-nextick-args":40}],409:[function(require,module,exports){ -arguments[4][394][0].apply(exports,arguments) -},{"./_stream_transform":411,"core-util-is":10,"dup":394,"inherits":32}],410:[function(require,module,exports){ -(function (process){ -'use strict'; + var end = charStr.length - 1; + var charCode = charStr.charCodeAt(end); + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + var size = this.surrogateSize; + this.charLength += size; + this.charReceived += size; + this.charBuffer.copy(this.charBuffer, size, 0, size); + buffer.copy(this.charBuffer, 0, 0, size); + return charStr.substring(0, end); + } -module.exports = Readable; + // or just emit the charStr + return charStr; +}; -/**/ -var processNextTick = require('process-nextick-args'); -/**/ +// detectIncompleteChar determines if there is an incomplete UTF-8 character at +// the end of the given buffer. If so, it sets this.charLength to the byte +// length that character, and sets this.charReceived to the number of bytes +// that are available for this character. +StringDecoder.prototype.detectIncompleteChar = function(buffer) { + // determine how many bytes we have to check at the end of this buffer + var i = (buffer.length >= 3) ? 3 : buffer.length; -/**/ -var isArray = require('isarray'); -/**/ + // Figure out if one of the last i bytes of our buffer announces an + // incomplete char. + for (; i > 0; i--) { + var c = buffer[buffer.length - i]; -/**/ -var Duplex; -/**/ + // See http://en.wikipedia.org/wiki/UTF-8#Description -Readable.ReadableState = ReadableState; + // 110XXXXX + if (i == 1 && c >> 5 == 0x06) { + this.charLength = 2; + break; + } -/**/ -var EE = require('events').EventEmitter; + // 1110XXXX + if (i <= 2 && c >> 4 == 0x0E) { + this.charLength = 3; + break; + } -var EElistenerCount = function (emitter, type) { - return emitter.listeners(type).length; + // 11110XXX + if (i <= 3 && c >> 3 == 0x1E) { + this.charLength = 4; + break; + } + } + this.charReceived = i; }; -/**/ -/**/ -var Stream; -(function () { - try { - Stream = require('st' + 'ream'); - } catch (_) {} finally { - if (!Stream) Stream = require('events').EventEmitter; - } -})(); -/**/ +StringDecoder.prototype.end = function(buffer) { + var res = ''; + if (buffer && buffer.length) + res = this.write(buffer); -var Buffer = require('buffer').Buffer; -/**/ -var bufferShim = require('buffer-shims'); -/**/ + if (this.charReceived) { + var cr = this.charReceived; + var buf = this.charBuffer; + var enc = this.encoding; + res += buf.slice(0, cr).toString(enc); + } -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ + return res; +}; -/**/ -var debugUtil = require('util'); -var debug = void 0; -if (debugUtil && debugUtil.debuglog) { - debug = debugUtil.debuglog('stream'); -} else { - debug = function () {}; +function passThroughWrite(buffer) { + return buffer.toString(this.encoding); } -/**/ -var BufferList = require('./internal/streams/BufferList'); -var StringDecoder; - -util.inherits(Readable, Stream); +function utf16DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 2; + this.charLength = this.charReceived ? 2 : 0; +} -function prependListener(emitter, event, fn) { - // Sadly this is not cacheable as some libraries bundle their own - // event emitter implementation with them. - if (typeof emitter.prependListener === 'function') { - return emitter.prependListener(event, fn); - } else { - // This is a hack to make sure that our error handler is attached before any - // userland ones. NEVER DO THIS. This is here only because this code needs - // to continue to work with older versions of Node.js that do not include - // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; - } +function base64DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 3; + this.charLength = this.charReceived ? 3 : 0; } -function ReadableState(options, stream) { - Duplex = Duplex || require('./_stream_duplex'); +},{"buffer":6}],408:[function(require,module,exports){ +(function (process){ +var through = require('through'); +var fs = require('fs'); - options = options || {}; +module.exports = function () { + var line = ''; + var stream = through(write, flush); + return stream; + + function write (buf) { + for (var i = 0; i < buf.length; i++) { + var c = typeof buf === 'string' + ? buf.charAt(i) + : String.fromCharCode(buf[i]) + ; + if (c === '\n') flush(); + else line += c; + } + } + + function flush () { + if (fs.writeSync && /^win/.test(process.platform)) { + try { fs.writeSync(1, line + '\n'); } + catch (e) { stream.emit('error', e) } + } else { + try { console.log(line) } + catch (e) { stream.emit('error', e) } + } + line = ''; + } +}; - // object stream flag. Used to make read(n) ignore n and to - // make all the buffer merging and length checks go away - this.objectMode = !!options.objectMode; +}).call(this,require('_process')) - if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; +},{"_process":40,"fs":5,"through":411}],409:[function(require,module,exports){ +(function (process){ +var defined = require('defined'); +var EventEmitter = require('events').EventEmitter; +var inherits = require('inherits'); +var through = require('through'); +var resumer = require('resumer'); +var inspect = require('object-inspect'); +var bind = require('function-bind'); +var has = require('has'); +var regexpTest = bind.call(Function.call, RegExp.prototype.test); +var yamlIndicators = /\:|\-|\?/; +var nextTick = typeof setImmediate !== 'undefined' + ? setImmediate + : process.nextTick +; - // the point at which it stops calling _read() to fill the buffer - // Note: 0 is a valid value, means "don't call _read preemptively ever" - var hwm = options.highWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; +module.exports = Results; +inherits(Results, EventEmitter); - // cast to ints. - this.highWaterMark = ~ ~this.highWaterMark; +function Results () { + if (!(this instanceof Results)) return new Results; + this.count = 0; + this.fail = 0; + this.pass = 0; + this._stream = through(); + this.tests = []; + this._only = null; +} - // A linked list is used to store data chunks instead of an array because the - // linked list can remove elements from the beginning faster than - // array.shift() - this.buffer = new BufferList(); - this.length = 0; - this.pipes = null; - this.pipesCount = 0; - this.flowing = null; - this.ended = false; - this.endEmitted = false; - this.reading = false; +Results.prototype.createStream = function (opts) { + if (!opts) opts = {}; + var self = this; + var output, testId = 0; + if (opts.objectMode) { + output = through(); + self.on('_push', function ontest (t, extra) { + if (!extra) extra = {}; + var id = testId++; + t.once('prerun', function () { + var row = { + type: 'test', + name: t.name, + id: id + }; + if (has(extra, 'parent')) { + row.parent = extra.parent; + } + output.queue(row); + }); + t.on('test', function (st) { + ontest(st, { parent: id }); + }); + t.on('result', function (res) { + res.test = id; + res.type = 'assert'; + output.queue(res); + }); + t.on('end', function () { + output.queue({ type: 'end', test: id }); + }); + }); + self.on('done', function () { output.queue(null) }); + } else { + output = resumer(); + output.queue('TAP version 13\n'); + self._stream.pipe(output); + } + + nextTick(function next() { + var t; + while (t = getNextTest(self)) { + t.run(); + if (!t.ended) return t.once('end', function(){ nextTick(next); }); + } + self.emit('done'); + }); + + return output; +}; - // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, because any - // actions that shouldn't happen until "later" should generally also - // not happen before the first write call. - this.sync = true; +Results.prototype.push = function (t) { + var self = this; + self.tests.push(t); + self._watch(t); + self.emit('_push', t); +}; - // whenever we return null, then we set a flag to say - // that we're awaiting a 'readable' event emission. - this.needReadable = false; - this.emittedReadable = false; - this.readableListening = false; - this.resumeScheduled = false; +Results.prototype.only = function (t) { + this._only = t; +}; - // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; +Results.prototype._watch = function (t) { + var self = this; + var write = function (s) { self._stream.queue(s) }; + t.once('prerun', function () { + write('# ' + t.name + '\n'); + }); + + t.on('result', function (res) { + if (typeof res === 'string') { + write('# ' + res + '\n'); + return; + } + write(encodeResult(res, self.count + 1)); + self.count ++; - // when piping, we only care about 'readable' events that happen - // after read()ing all the bytes and not getting any pushback. - this.ranOut = false; + if (res.ok) self.pass ++ + else self.fail ++ + }); + + t.on('test', function (st) { self._watch(st) }); +}; - // the number of writers that are awaiting a drain event in .pipe()s - this.awaitDrain = 0; +Results.prototype.close = function () { + var self = this; + if (self.closed) self._stream.emit('error', new Error('ALREADY CLOSED')); + self.closed = true; + var write = function (s) { self._stream.queue(s) }; + + write('\n1..' + self.count + '\n'); + write('# tests ' + self.count + '\n'); + write('# pass ' + self.pass + '\n'); + if (self.fail) write('# fail ' + self.fail + '\n') + else write('\n# ok\n') - // if true, a maybeReadMore has been scheduled - this.readingMore = false; + self._stream.queue(null); +}; - this.decoder = null; - this.encoding = null; - if (options.encoding) { - if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - this.decoder = new StringDecoder(options.encoding); - this.encoding = options.encoding; - } +function encodeResult (res, count) { + var output = ''; + output += (res.ok ? 'ok ' : 'not ok ') + count; + output += res.name ? ' ' + res.name.toString().replace(/\s+/g, ' ') : ''; + + if (res.skip) output += ' # SKIP'; + else if (res.todo) output += ' # TODO'; + + output += '\n'; + if (res.ok) return output; + + var outer = ' '; + var inner = outer + ' '; + output += outer + '---\n'; + output += inner + 'operator: ' + res.operator + '\n'; + + if (has(res, 'expected') || has(res, 'actual')) { + var ex = inspect(res.expected, {depth: res.objectPrintDepth}); + var ac = inspect(res.actual, {depth: res.objectPrintDepth}); + + if (Math.max(ex.length, ac.length) > 65 || invalidYaml(ex) || invalidYaml(ac)) { + output += inner + 'expected: |-\n' + inner + ' ' + ex + '\n'; + output += inner + 'actual: |-\n' + inner + ' ' + ac + '\n'; + } else { + output += inner + 'expected: ' + ex + '\n'; + output += inner + 'actual: ' + ac + '\n'; + } + } + if (res.at) { + output += inner + 'at: ' + res.at + '\n'; + } + + var actualStack = res.actual && res.actual.stack; + var errorStack = res.error && res.error.stack; + var stack = defined(actualStack, errorStack); + if (stack) { + var lines = String(stack).split('\n'); + output += inner + 'stack: |-\n'; + for (var i = 0; i < lines.length; i++) { + output += inner + ' ' + lines[i] + '\n'; + } + } + + output += outer + '...\n'; + return output; } -function Readable(options) { - Duplex = Duplex || require('./_stream_duplex'); +function getNextTest (results) { + if (!results._only) { + return results.tests.shift(); + } + + do { + var t = results.tests.shift(); + if (!t) continue; + if (results._only === t) { + return t; + } + } while (results.tests.length !== 0) +} - if (!(this instanceof Readable)) return new Readable(options); +function invalidYaml (str) { + return regexpTest(yamlIndicators, str); +} - this._readableState = new ReadableState(options, this); +}).call(this,require('_process')) - // legacy - this.readable = true; +},{"_process":40,"defined":14,"events":22,"function-bind":26,"has":27,"inherits":29,"object-inspect":34,"resumer":41,"through":411}],410:[function(require,module,exports){ +(function (process,__dirname){ +var deepEqual = require('deep-equal'); +var defined = require('defined'); +var path = require('path'); +var inherits = require('inherits'); +var EventEmitter = require('events').EventEmitter; +var has = require('has'); +var trim = require('string.prototype.trim'); +var bind = require('function-bind'); +var forEach = require('for-each'); +var isEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable); - if (options && typeof options.read === 'function') this._read = options.read; +module.exports = Test; - Stream.call(this); -} +var nextTick = typeof setImmediate !== 'undefined' + ? setImmediate + : process.nextTick +; +var safeSetTimeout = setTimeout; -// Manually shove something into the read() buffer. -// This returns true if the highWaterMark has not been hit yet, -// similar to how Writable.write() returns true if you should -// write() some more. -Readable.prototype.push = function (chunk, encoding) { - var state = this._readableState; +inherits(Test, EventEmitter); - if (!state.objectMode && typeof chunk === 'string') { - encoding = encoding || state.defaultEncoding; - if (encoding !== state.encoding) { - chunk = bufferShim.from(chunk, encoding); - encoding = ''; - } - } +var getTestArgs = function (name_, opts_, cb_) { + var name = '(anonymous)'; + var opts = {}; + var cb; - return readableAddChunk(this, state, chunk, encoding, false); + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + var t = typeof arg; + if (t === 'string') { + name = arg; + } else if (t === 'object') { + opts = arg || opts; + } else if (t === 'function') { + cb = arg; + } + } + return { name: name, opts: opts, cb: cb }; }; -// Unshift should *always* be something directly out of read() -Readable.prototype.unshift = function (chunk) { - var state = this._readableState; - return readableAddChunk(this, state, chunk, '', true); -}; +function Test (name_, opts_, cb_) { + if (! (this instanceof Test)) { + return new Test(name_, opts_, cb_); + } -Readable.prototype.isPaused = function () { - return this._readableState.flowing === false; -}; + var args = getTestArgs(name_, opts_, cb_); -function readableAddChunk(stream, state, chunk, encoding, addToFront) { - var er = chunkInvalid(state, chunk); - if (er) { - stream.emit('error', er); - } else if (chunk === null) { - state.reading = false; - onEofChunk(stream, state); - } else if (state.objectMode || chunk && chunk.length > 0) { - if (state.ended && !addToFront) { - var e = new Error('stream.push() after EOF'); - stream.emit('error', e); - } else if (state.endEmitted && addToFront) { - var _e = new Error('stream.unshift() after end event'); - stream.emit('error', _e); - } else { - var skipAdd; - if (state.decoder && !addToFront && !encoding) { - chunk = state.decoder.write(chunk); - skipAdd = !state.objectMode && chunk.length === 0; - } + this.readable = true; + this.name = args.name || '(anonymous)'; + this.assertCount = 0; + this.pendingCount = 0; + this._skip = args.opts.skip || false; + this._timeout = args.opts.timeout; + this._objectPrintDepth = args.opts.objectPrintDepth || 5; + this._plan = undefined; + this._cb = args.cb; + this._progeny = []; + this._ok = true; - if (!addToFront) state.reading = false; + for (var prop in this) { + this[prop] = (function bind(self, val) { + if (typeof val === 'function') { + return function bound() { + return val.apply(self, arguments); + }; + } + return val; + })(this, this[prop]); + } +} - // Don't add to the buffer if we've decoded to an empty string chunk and - // we're not in object mode - if (!skipAdd) { - // if we want the data now, just emit it. - if (state.flowing && state.length === 0 && !state.sync) { - stream.emit('data', chunk); - stream.read(0); - } else { - // update the buffer info. - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); +Test.prototype.run = function () { + if (this._skip) { + this.comment('SKIP ' + this.name); + } + if (!this._cb || this._skip) { + return this._end(); + } + if (this._timeout != null) { + this.timeoutAfter(this._timeout); + } + this.emit('prerun'); + this._cb(this); + this.emit('run'); +}; - if (state.needReadable) emitReadable(stream); +Test.prototype.test = function (name, opts, cb) { + var self = this; + var t = new Test(name, opts, cb); + this._progeny.push(t); + this.pendingCount++; + this.emit('test', t); + t.on('prerun', function () { + self.assertCount++; + }) + + if (!self._pendingAsserts()) { + nextTick(function () { + self._end(); + }); + } + + nextTick(function() { + if (!self._plan && self.pendingCount == self._progeny.length) { + self._end(); } - } + }); +}; - maybeReadMore(stream, state); - } - } else if (!addToFront) { - state.reading = false; - } +Test.prototype.comment = function (msg) { + var that = this; + forEach(trim(msg).split('\n'), function (aMsg) { + that.emit('result', trim(aMsg).replace(/^#\s*/, '')); + }); +}; - return needMoreData(state); -} +Test.prototype.plan = function (n) { + this._plan = n; + this.emit('plan', n); +}; -// if it's past the high water mark, we can push in some more. -// Also, if we have no data yet, we can stand some -// more bytes. This is to work around cases where hwm=0, -// such as the repl. Also, if the push() triggered a -// readable event, and the user called read(largeNumber) such that -// needReadable was set, then we ought to push more, so that another -// 'readable' event will be triggered. -function needMoreData(state) { - return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +Test.prototype.timeoutAfter = function(ms) { + if (!ms) throw new Error('timeoutAfter requires a timespan'); + var self = this; + var timeout = safeSetTimeout(function() { + self.fail('test timed out after ' + ms + 'ms'); + self.end(); + }, ms); + this.once('end', function() { + clearTimeout(timeout); + }); } -// backwards compatibility. -Readable.prototype.setEncoding = function (enc) { - if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; - return this; +Test.prototype.end = function (err) { + var self = this; + if (arguments.length >= 1 && !!err) { + this.ifError(err); + } + + if (this.calledEnd) { + this.fail('.end() called twice'); + } + this.calledEnd = true; + this._end(); }; -// Don't raise the hwm > 8MB -var MAX_HWM = 0x800000; -function computeNewHighWaterMark(n) { - if (n >= MAX_HWM) { - n = MAX_HWM; - } else { - // Get the next highest power of 2 to prevent increasing hwm excessively in - // tiny amounts - n--; - n |= n >>> 1; - n |= n >>> 2; - n |= n >>> 4; - n |= n >>> 8; - n |= n >>> 16; - n++; - } - return n; -} - -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function howMuchToRead(n, state) { - if (n <= 0 || state.length === 0 && state.ended) return 0; - if (state.objectMode) return 1; - if (n !== n) { - // Only flow one buffer at a time - if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; - } - // If we're asking for more than the current hwm, then raise the hwm. - if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); - if (n <= state.length) return n; - // Don't have enough - if (!state.ended) { - state.needReadable = true; - return 0; - } - return state.length; -} +Test.prototype._end = function (err) { + var self = this; + if (this._progeny.length) { + var t = this._progeny.shift(); + t.on('end', function () { self._end() }); + t.run(); + return; + } + + if (!this.ended) this.emit('end'); + var pendingAsserts = this._pendingAsserts(); + if (!this._planError && this._plan !== undefined && pendingAsserts) { + this._planError = true; + this.fail('plan != count', { + expected : this._plan, + actual : this.assertCount + }); + } + this.ended = true; +}; -// you can override either this method, or the async _read(n) below. -Readable.prototype.read = function (n) { - debug('read', n); - n = parseInt(n, 10); - var state = this._readableState; - var nOrig = n; +Test.prototype._exit = function () { + if (this._plan !== undefined && + !this._planError && this.assertCount !== this._plan) { + this._planError = true; + this.fail('plan != count', { + expected : this._plan, + actual : this.assertCount, + exiting : true + }); + } else if (!this.ended) { + this.fail('test exited without ending', { + exiting: true + }); + } +}; - if (n !== 0) state.emittedReadable = false; +Test.prototype._pendingAsserts = function () { + if (this._plan === undefined) { + return 1; + } + return this._plan - (this._progeny.length + this.assertCount); +}; - // if we're doing read(0) to trigger a readable event, but we - // already have a bunch of data in the buffer, then just trigger - // the 'readable' event and move on. - if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { - debug('read: emitReadable', state.length, state.ended); - if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); - return null; - } - - n = howMuchToRead(n, state); - - // if we've ended, and we're now clear, then finish it up. - if (n === 0 && state.ended) { - if (state.length === 0) endReadable(this); - return null; - } - - // All the actual chunk generation logic needs to be - // *below* the call to _read. The reason is that in certain - // synthetic stream cases, such as passthrough streams, _read - // may be a completely synchronous operation which may change - // the state of the read buffer, providing enough data when - // before there was *not* enough. - // - // So, the steps are: - // 1. Figure out what the state of things will be after we do - // a read from the buffer. - // - // 2. If that resulting state will trigger a _read, then call _read. - // Note that this may be asynchronous, or synchronous. Yes, it is - // deeply ugly to write APIs this way, but that still doesn't mean - // that the Readable class should behave improperly, as streams are - // designed to be sync/async agnostic. - // Take note if the _read call is sync or async (ie, if the read call - // has returned yet), so that we know whether or not it's safe to emit - // 'readable' etc. - // - // 3. Actually pull the requested chunks out of the buffer and return. - - // if we need a readable event, then we need to do some reading. - var doRead = state.needReadable; - debug('need readable', doRead); - - // if we currently have less than the highWaterMark, then also read some - if (state.length === 0 || state.length - n < state.highWaterMark) { - doRead = true; - debug('length less than watermark', doRead); - } - - // however, if we've ended, then there's no point, and if we're already - // reading, then it's unnecessary. - if (state.ended || state.reading) { - doRead = false; - debug('reading or ended', doRead); - } else if (doRead) { - debug('do read'); - state.reading = true; - state.sync = true; - // if the length is currently zero, then we *need* a readable event. - if (state.length === 0) state.needReadable = true; - // call internal read method - this._read(state.highWaterMark); - state.sync = false; - // If _read pushed data synchronously, then `reading` will be false, - // and we need to re-evaluate how much data we can return to the user. - if (!state.reading) n = howMuchToRead(nOrig, state); - } - - var ret; - if (n > 0) ret = fromList(n, state);else ret = null; - - if (ret === null) { - state.needReadable = true; - n = 0; - } else { - state.length -= n; - } - - if (state.length === 0) { - // If we have nothing in the buffer, then we want to know - // as soon as we *do* get something into the buffer. - if (!state.ended) state.needReadable = true; - - // If we tried to read() past the EOF, then emit end on the next tick. - if (nOrig !== n && state.ended) endReadable(this); - } +Test.prototype._assert = function assert (ok, opts) { + var self = this; + var extra = opts.extra || {}; + + var res = { + id : self.assertCount ++, + ok : Boolean(ok), + skip : defined(extra.skip, opts.skip), + name : defined(extra.message, opts.message, '(unnamed assert)'), + operator : defined(extra.operator, opts.operator), + objectPrintDepth : self._objectPrintDepth + }; + if (has(opts, 'actual') || has(extra, 'actual')) { + res.actual = defined(extra.actual, opts.actual); + } + if (has(opts, 'expected') || has(extra, 'expected')) { + res.expected = defined(extra.expected, opts.expected); + } + this._ok = Boolean(this._ok && ok); + + if (!ok) { + res.error = defined(extra.error, opts.error, new Error(res.name)); + } + + if (!ok) { + var e = new Error('exception'); + var err = (e.stack || '').split('\n'); + var dir = path.dirname(__dirname) + path.sep; + + for (var i = 0; i < err.length; i++) { + var m = /^[^\s]*\s*\bat\s+(.+)/.exec(err[i]); + if (!m) { + continue; + } + + var s = m[1].split(/\s+/); + var filem = /((?:\/|[A-Z]:\\)[^:\s]+:(\d+)(?::(\d+))?)/.exec(s[1]); + if (!filem) { + filem = /((?:\/|[A-Z]:\\)[^:\s]+:(\d+)(?::(\d+))?)/.exec(s[2]); + + if (!filem) { + filem = /((?:\/|[A-Z]:\\)[^:\s]+:(\d+)(?::(\d+))?)/.exec(s[3]); - if (ret !== null) this.emit('data', ret); + if (!filem) { + continue; + } + } + } + + if (filem[1].slice(0, dir.length) === dir) { + continue; + } + + res.functionName = s[0]; + res.file = filem[1]; + res.line = Number(filem[2]); + if (filem[3]) res.column = filem[3]; + + res.at = m[1]; + break; + } + } - return ret; + self.emit('result', res); + + var pendingAsserts = self._pendingAsserts(); + if (!pendingAsserts) { + if (extra.exiting) { + self._end(); + } else { + nextTick(function () { + self._end(); + }); + } + } + + if (!self._planError && pendingAsserts < 0) { + self._planError = true; + self.fail('plan != count', { + expected : self._plan, + actual : self._plan - pendingAsserts + }); + } }; -function chunkInvalid(state, chunk) { - var er = null; - if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - return er; -} +Test.prototype.fail = function (msg, extra) { + this._assert(false, { + message : msg, + operator : 'fail', + extra : extra + }); +}; -function onEofChunk(stream, state) { - if (state.ended) return; - if (state.decoder) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) { - state.buffer.push(chunk); - state.length += state.objectMode ? 1 : chunk.length; - } - } - state.ended = true; +Test.prototype.pass = function (msg, extra) { + this._assert(true, { + message : msg, + operator : 'pass', + extra : extra + }); +}; - // emit 'readable' now to make sure it gets picked up. - emitReadable(stream); -} +Test.prototype.skip = function (msg, extra) { + this._assert(true, { + message : msg, + operator : 'skip', + skip : true, + extra : extra + }); +}; -// Don't emit readable right away in sync mode, because this can trigger -// another read() call => stack overflow. This way, it might trigger -// a nextTick recursion warning, but that's not so bad. -function emitReadable(stream) { - var state = stream._readableState; - state.needReadable = false; - if (!state.emittedReadable) { - debug('emitReadable', state.flowing); - state.emittedReadable = true; - if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream); - } -} +Test.prototype.ok += Test.prototype['true'] += Test.prototype.assert += function (value, msg, extra) { + this._assert(value, { + message : defined(msg, 'should be truthy'), + operator : 'ok', + expected : true, + actual : value, + extra : extra + }); +}; -function emitReadable_(stream) { - debug('emit readable'); - stream.emit('readable'); - flow(stream); -} +Test.prototype.notOk += Test.prototype['false'] += Test.prototype.notok += function (value, msg, extra) { + this._assert(!value, { + message : defined(msg, 'should be falsy'), + operator : 'notOk', + expected : false, + actual : value, + extra : extra + }); +}; -// at this point, the user has presumably seen the 'readable' event, -// and called read() to consume some data. that may have triggered -// in turn another _read(n) call, in which case reading = true if -// it's in progress. -// However, if we're not ended, or reading, and the length < hwm, -// then go ahead and try to read some more preemptively. -function maybeReadMore(stream, state) { - if (!state.readingMore) { - state.readingMore = true; - processNextTick(maybeReadMore_, stream, state); - } -} +Test.prototype.error += Test.prototype.ifError += Test.prototype.ifErr += Test.prototype.iferror += function (err, msg, extra) { + this._assert(!err, { + message : defined(msg, String(err)), + operator : 'error', + actual : err, + extra : extra + }); +}; -function maybeReadMore_(stream, state) { - var len = state.length; - while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { - debug('maybeReadMore read 0'); - stream.read(0); - if (len === state.length) - // didn't get any data, stop spinning. - break;else len = state.length; - } - state.readingMore = false; -} +Test.prototype.equal += Test.prototype.equals += Test.prototype.isEqual += Test.prototype.is += Test.prototype.strictEqual += Test.prototype.strictEquals += function (a, b, msg, extra) { + this._assert(a === b, { + message : defined(msg, 'should be equal'), + operator : 'equal', + actual : a, + expected : b, + extra : extra + }); +}; -// abstract method. to be overridden in specific implementation classes. -// call cb(er, data) where data is <= n in length. -// for virtual (non-string, non-buffer) streams, "length" is somewhat -// arbitrary, and perhaps not very meaningful. -Readable.prototype._read = function (n) { - this.emit('error', new Error('_read() is not implemented')); +Test.prototype.notEqual += Test.prototype.notEquals += Test.prototype.notStrictEqual += Test.prototype.notStrictEquals += Test.prototype.isNotEqual += Test.prototype.isNot += Test.prototype.not += Test.prototype.doesNotEqual += Test.prototype.isInequal += function (a, b, msg, extra) { + this._assert(a !== b, { + message : defined(msg, 'should not be equal'), + operator : 'notEqual', + actual : a, + notExpected : b, + extra : extra + }); }; -Readable.prototype.pipe = function (dest, pipeOpts) { - var src = this; - var state = this._readableState; +Test.prototype.deepEqual += Test.prototype.deepEquals += Test.prototype.isEquivalent += Test.prototype.same += function (a, b, msg, extra) { + this._assert(deepEqual(a, b, { strict: true }), { + message : defined(msg, 'should be equivalent'), + operator : 'deepEqual', + actual : a, + expected : b, + extra : extra + }); +}; - switch (state.pipesCount) { - case 0: - state.pipes = dest; - break; - case 1: - state.pipes = [state.pipes, dest]; - break; - default: - state.pipes.push(dest); - break; - } - state.pipesCount += 1; - debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); +Test.prototype.deepLooseEqual += Test.prototype.looseEqual += Test.prototype.looseEquals += function (a, b, msg, extra) { + this._assert(deepEqual(a, b), { + message : defined(msg, 'should be equivalent'), + operator : 'deepLooseEqual', + actual : a, + expected : b, + extra : extra + }); +}; - var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; +Test.prototype.notDeepEqual += Test.prototype.notEquivalent += Test.prototype.notDeeply += Test.prototype.notSame += Test.prototype.isNotDeepEqual += Test.prototype.isNotDeeply += Test.prototype.isNotEquivalent += Test.prototype.isInequivalent += function (a, b, msg, extra) { + this._assert(!deepEqual(a, b, { strict: true }), { + message : defined(msg, 'should not be equivalent'), + operator : 'notDeepEqual', + actual : a, + notExpected : b, + extra : extra + }); +}; - var endFn = doEnd ? onend : cleanup; - if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn); +Test.prototype.notDeepLooseEqual += Test.prototype.notLooseEqual += Test.prototype.notLooseEquals += function (a, b, msg, extra) { + this._assert(!deepEqual(a, b), { + message : defined(msg, 'should be equivalent'), + operator : 'notDeepLooseEqual', + actual : a, + expected : b, + extra : extra + }); +}; - dest.on('unpipe', onunpipe); - function onunpipe(readable) { - debug('onunpipe'); - if (readable === src) { - cleanup(); +Test.prototype['throws'] = function (fn, expected, msg, extra) { + if (typeof expected === 'string') { + msg = expected; + expected = undefined; } - } - - function onend() { - debug('onend'); - dest.end(); - } - // when the dest drains, it reduces the awaitDrain counter - // on the source. This would be more elegant with a .once() - // handler in flow(), but adding and removing repeatedly is - // too slow. - var ondrain = pipeOnDrain(src); - dest.on('drain', ondrain); - - var cleanedUp = false; - function cleanup() { - debug('cleanup'); - // cleanup event handlers once the pipe is broken - dest.removeListener('close', onclose); - dest.removeListener('finish', onfinish); - dest.removeListener('drain', ondrain); - dest.removeListener('error', onerror); - dest.removeListener('unpipe', onunpipe); - src.removeListener('end', onend); - src.removeListener('end', cleanup); - src.removeListener('data', ondata); - - cleanedUp = true; - - // if the reader is waiting for a drain event from this - // specific writer, then it would cause it to never start - // flowing again. - // So, if this is awaiting a drain, then we just call it now. - // If we don't know, then assume that we are waiting for one. - if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); - } + var caught = undefined; - // If the user pushes more data while we're writing to dest then we'll end up - // in ondata again. However, we only want to increase awaitDrain once because - // dest will only emit one 'drain' event for the multiple writes. - // => Introduce a guard on increasing awaitDrain. - var increasedAwaitDrain = false; - src.on('data', ondata); - function ondata(chunk) { - debug('ondata'); - increasedAwaitDrain = false; - var ret = dest.write(chunk); - if (false === ret && !increasedAwaitDrain) { - // If the user unpiped during `dest.write()`, it is possible - // to get stuck in a permanently paused state if that write - // also returned false. - // => Check whether `dest` is still a piping destination. - if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { - debug('false write response, pause', src._readableState.awaitDrain); - src._readableState.awaitDrain++; - increasedAwaitDrain = true; - } - src.pause(); + try { + fn(); + } catch (err) { + caught = { error : err }; + if ((err != null) && (!isEnumerable(err, 'message') || !has(err, 'message'))) { + var message = err.message; + delete err.message; + err.message = message; + } } - } - - // if the dest has an error, then stop piping into it. - // however, don't suppress the throwing behavior for this. - function onerror(er) { - debug('onerror', er); - unpipe(); - dest.removeListener('error', onerror); - if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); - } - - // Make sure our error handler is attached before userland ones. - prependListener(dest, 'error', onerror); - // Both close and finish should trigger unpipe, but only once. - function onclose() { - dest.removeListener('finish', onfinish); - unpipe(); - } - dest.once('close', onclose); - function onfinish() { - debug('onfinish'); - dest.removeListener('close', onclose); - unpipe(); - } - dest.once('finish', onfinish); - - function unpipe() { - debug('unpipe'); - src.unpipe(dest); - } - - // tell the dest that it's being piped to - dest.emit('pipe', src); - - // start the flow if it hasn't been started already. - if (!state.flowing) { - debug('pipe resume'); - src.resume(); - } - - return dest; -}; + var passed = caught; -function pipeOnDrain(src) { - return function () { - var state = src._readableState; - debug('pipeOnDrain', state.awaitDrain); - if (state.awaitDrain) state.awaitDrain--; - if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { - state.flowing = true; - flow(src); + if (expected instanceof RegExp) { + passed = expected.test(caught && caught.error); + expected = String(expected); } - }; -} - -Readable.prototype.unpipe = function (dest) { - var state = this._readableState; - // if we're not piping anywhere, then do nothing. - if (state.pipesCount === 0) return this; - - // just one destination. most common case. - if (state.pipesCount === 1) { - // passed in one, but it's not the right one. - if (dest && dest !== state.pipes) return this; - - if (!dest) dest = state.pipes; - - // got a match. - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - if (dest) dest.emit('unpipe', this); - return this; - } - - // slow case. multiple pipe destinations. - - if (!dest) { - // remove all. - var dests = state.pipes; - var len = state.pipesCount; - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - - for (var i = 0; i < len; i++) { - dests[i].emit('unpipe', this); - }return this; - } - - // try to find the right one. - var index = indexOf(state.pipes, dest); - if (index === -1) return this; - - state.pipes.splice(index, 1); - state.pipesCount -= 1; - if (state.pipesCount === 1) state.pipes = state.pipes[0]; - - dest.emit('unpipe', this); - - return this; -}; - -// set up data events if they are asked for -// Ensure readable listeners eventually get something -Readable.prototype.on = function (ev, fn) { - var res = Stream.prototype.on.call(this, ev, fn); - - if (ev === 'data') { - // Start flowing on next tick if stream isn't explicitly paused - if (this._readableState.flowing !== false) this.resume(); - } else if (ev === 'readable') { - var state = this._readableState; - if (!state.endEmitted && !state.readableListening) { - state.readableListening = state.needReadable = true; - state.emittedReadable = false; - if (!state.reading) { - processNextTick(nReadingNextTick, this); - } else if (state.length) { - emitReadable(this, state); - } + if (typeof expected === 'function' && caught) { + passed = caught.error instanceof expected; + caught.error = caught.error.constructor; } - } - return res; + this._assert(typeof fn === 'function' && passed, { + message : defined(msg, 'should throw'), + operator : 'throws', + actual : caught && caught.error, + expected : expected, + error: !passed && caught && caught.error, + extra : extra + }); }; -Readable.prototype.addListener = Readable.prototype.on; - -function nReadingNextTick(self) { - debug('readable nexttick read 0'); - self.read(0); -} -// pause() and resume() are remnants of the legacy readable stream API -// If the user uses them, then switch into old mode. -Readable.prototype.resume = function () { - var state = this._readableState; - if (!state.flowing) { - debug('resume'); - state.flowing = true; - resume(this, state); - } - return this; +Test.prototype.doesNotThrow = function (fn, expected, msg, extra) { + if (typeof expected === 'string') { + msg = expected; + expected = undefined; + } + var caught = undefined; + try { + fn(); + } + catch (err) { + caught = { error : err }; + } + this._assert(!caught, { + message : defined(msg, 'should not throw'), + operator : 'throws', + actual : caught && caught.error, + expected : expected, + error : caught && caught.error, + extra : extra + }); }; -function resume(stream, state) { - if (!state.resumeScheduled) { - state.resumeScheduled = true; - processNextTick(resume_, stream, state); - } -} - -function resume_(stream, state) { - if (!state.reading) { - debug('resume read 0'); - stream.read(0); - } - - state.resumeScheduled = false; - state.awaitDrain = 0; - stream.emit('resume'); - flow(stream); - if (state.flowing && !state.reading) stream.read(0); -} - -Readable.prototype.pause = function () { - debug('call pause flowing=%j', this._readableState.flowing); - if (false !== this._readableState.flowing) { - debug('pause'); - this._readableState.flowing = false; - this.emit('pause'); - } - return this; +Test.skip = function (name_, _opts, _cb) { + var args = getTestArgs.apply(null, arguments); + args.opts.skip = true; + return Test(args.name, args.opts, args.cb); }; -function flow(stream) { - var state = stream._readableState; - debug('flow', state.flowing); - while (state.flowing && stream.read() !== null) {} -} - -// wrap an old-style stream as the async data source. -// This is *not* part of the readable stream interface. -// It is an ugly unfortunate mess of history. -Readable.prototype.wrap = function (stream) { - var state = this._readableState; - var paused = false; - - var self = this; - stream.on('end', function () { - debug('wrapped end'); - if (state.decoder && !state.ended) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) self.push(chunk); - } - - self.push(null); - }); - - stream.on('data', function (chunk) { - debug('wrapped data'); - if (state.decoder) chunk = state.decoder.write(chunk); - - // don't skip over falsy values in objectMode - if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; - - var ret = self.push(chunk); - if (!ret) { - paused = true; - stream.pause(); - } - }); +// vim: set softtabstop=4 shiftwidth=4: - // proxy all the other methods. - // important when wrapping filters and duplexes. - for (var i in stream) { - if (this[i] === undefined && typeof stream[i] === 'function') { - this[i] = function (method) { - return function () { - return stream[method].apply(stream, arguments); - }; - }(i); - } - } - // proxy certain important events. - var events = ['error', 'close', 'destroy', 'pause', 'resume']; - forEach(events, function (ev) { - stream.on(ev, self.emit.bind(self, ev)); - }); +}).call(this,require('_process'),"/node_modules/tape/lib") - // when we try to consume some more bytes, simply unpause the - // underlying stream. - self._read = function (n) { - debug('wrapped _read', n); - if (paused) { - paused = false; - stream.resume(); - } - }; +},{"_process":40,"deep-equal":10,"defined":14,"events":22,"for-each":23,"function-bind":26,"has":27,"inherits":29,"path":38,"string.prototype.trim":404}],411:[function(require,module,exports){ +(function (process){ +var Stream = require('stream') - return self; -}; +// through +// +// a stream that does nothing but re-emit the input. +// useful for aggregating a series of changing but not ending streams into one stream) -// exposed for testing purposes only. -Readable._fromList = fromList; +exports = module.exports = through +through.through = through -// Pluck off n bytes from an array of buffers. -// Length is the combined lengths of all the buffers in the list. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromList(n, state) { - // nothing buffered - if (state.length === 0) return null; +//create a readable writable stream. - var ret; - if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { - // read it all, truncate the list - if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); - state.buffer.clear(); - } else { - // read part of list - ret = fromListPartial(n, state.buffer, state.decoder); - } +function through (write, end, opts) { + write = write || function (data) { this.queue(data) } + end = end || function () { this.queue(null) } - return ret; -} + var ended = false, destroyed = false, buffer = [], _ended = false + var stream = new Stream() + stream.readable = stream.writable = true + stream.paused = false -// Extracts only enough buffered data to satisfy the amount requested. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromListPartial(n, list, hasStrings) { - var ret; - if (n < list.head.data.length) { - // slice is the same for buffers and strings - ret = list.head.data.slice(0, n); - list.head.data = list.head.data.slice(n); - } else if (n === list.head.data.length) { - // first chunk is a perfect match - ret = list.shift(); - } else { - // result spans more than one buffer - ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); +// stream.autoPause = !(opts && opts.autoPause === false) + stream.autoDestroy = !(opts && opts.autoDestroy === false) + + stream.write = function (data) { + write.call(this, data) + return !stream.paused } - return ret; -} -// Copies a specified amount of characters from the list of buffered data -// chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBufferString(n, list) { - var p = list.head; - var c = 1; - var ret = p.data; - n -= ret.length; - while (p = p.next) { - var str = p.data; - var nb = n > str.length ? str.length : n; - if (nb === str.length) ret += str;else ret += str.slice(0, n); - n -= nb; - if (n === 0) { - if (nb === str.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = str.slice(nb); - } - break; + function drain() { + while(buffer.length && !stream.paused) { + var data = buffer.shift() + if(null === data) + return stream.emit('end') + else + stream.emit('data', data) } - ++c; } - list.length -= c; - return ret; -} -// Copies a specified amount of bytes from the list of buffered data chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBuffer(n, list) { - var ret = bufferShim.allocUnsafe(n); - var p = list.head; - var c = 1; - p.data.copy(ret); - n -= p.data.length; - while (p = p.next) { - var buf = p.data; - var nb = n > buf.length ? buf.length : n; - buf.copy(ret, ret.length - n, 0, nb); - n -= nb; - if (n === 0) { - if (nb === buf.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = buf.slice(nb); - } - break; - } - ++c; + stream.queue = stream.push = function (data) { +// console.error(ended) + if(_ended) return stream + if(data === null) _ended = true + buffer.push(data) + drain() + return stream } - list.length -= c; - return ret; -} -function endReadable(stream) { - var state = stream._readableState; + //this will be registered as the first 'end' listener + //must call destroy next tick, to make sure we're after any + //stream piped from here. + //this is only a problem if end is not emitted synchronously. + //a nicer way to do this is to make sure this is the last listener for 'end' - // If we get here before consuming all the bytes, then that is a - // bug in node. Should never happen. - if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + stream.on('end', function () { + stream.readable = false + if(!stream.writable && stream.autoDestroy) + process.nextTick(function () { + stream.destroy() + }) + }) - if (!state.endEmitted) { - state.ended = true; - processNextTick(endReadableNT, state, stream); + function _end () { + stream.writable = false + end.call(stream) + if(!stream.readable && stream.autoDestroy) + stream.destroy() } -} -function endReadableNT(state, stream) { - // Check that we didn't get one last unshift. - if (!state.endEmitted && state.length === 0) { - state.endEmitted = true; - stream.readable = false; - stream.emit('end'); + stream.end = function (data) { + if(ended) return + ended = true + if(arguments.length) stream.write(data) + _end() // will emit or queue + return stream } -} -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xs[i], i); + stream.destroy = function () { + if(destroyed) return + destroyed = true + ended = true + buffer.length = 0 + stream.writable = stream.readable = false + stream.emit('close') + return stream } -} -function indexOf(xs, x) { - for (var i = 0, l = xs.length; i < l; i++) { - if (xs[i] === x) return i; + stream.pause = function () { + if(stream.paused) return + stream.paused = true + return stream } - return -1; + + stream.resume = function () { + if(stream.paused) { + stream.paused = false + stream.emit('resume') + } + drain() + //may have become paused again, + //as drain emits 'data'. + if(!stream.paused) + stream.emit('drain') + return stream + } + return stream } + + }).call(this,require('_process')) -},{"./_stream_duplex":408,"./internal/streams/BufferList":413,"_process":41,"buffer":7,"buffer-shims":6,"core-util-is":10,"events":23,"inherits":32,"isarray":407,"process-nextick-args":40,"string_decoder/":419,"util":4}],411:[function(require,module,exports){ -arguments[4][396][0].apply(exports,arguments) -},{"./_stream_duplex":408,"core-util-is":10,"dup":396,"inherits":32}],412:[function(require,module,exports){ -(function (process){ -// A bit simpler than readable streams. -// Implement an async ._write(chunk, encoding, cb), and it'll handle all -// the drain event emission and buffering. +},{"_process":40,"stream":387}],412:[function(require,module,exports){ +arguments[4][7][0].apply(exports,arguments) +},{"dup":7}],413:[function(require,module,exports){ +arguments[4][390][0].apply(exports,arguments) +},{"./_stream_readable":415,"./_stream_writable":417,"core-util-is":9,"dup":390,"inherits":29,"process-nextick-args":39}],414:[function(require,module,exports){ +arguments[4][391][0].apply(exports,arguments) +},{"./_stream_transform":416,"core-util-is":9,"dup":391,"inherits":29}],415:[function(require,module,exports){ +(function (process,global){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -module.exports = Writable; - /**/ + var processNextTick = require('process-nextick-args'); /**/ +module.exports = Readable; + /**/ -var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick; +var isArray = require('isarray'); /**/ /**/ var Duplex; /**/ -Writable.WritableState = WritableState; +Readable.ReadableState = ReadableState; /**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); +var EE = require('events').EventEmitter; + +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; /**/ /**/ -var internalUtil = { - deprecate: require('util-deprecate') -}; +var Stream = require('./internal/streams/stream'); /**/ +// TODO(bmeurer): Change this back to const once hole checks are +// properly optimized away early in Ignition+TurboFan. /**/ -var Stream; -(function () { - try { - Stream = require('st' + 'ream'); - } catch (_) {} finally { - if (!Stream) Stream = require('events').EventEmitter; - } -})(); +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} /**/ -var Buffer = require('buffer').Buffer; /**/ -var bufferShim = require('buffer-shims'); +var util = require('core-util-is'); +util.inherits = require('inherits'); /**/ -util.inherits(Writable, Stream); +/**/ +var debugUtil = require('util'); +var debug = void 0; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ -function nop() {} +var BufferList = require('./internal/streams/BufferList'); +var destroyImpl = require('./internal/streams/destroy'); +var StringDecoder; -function WriteReq(chunk, encoding, cb) { - this.chunk = chunk; - this.encoding = encoding; - this.callback = cb; - this.next = null; +util.inherits(Readable, Stream); + +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') { + return emitter.prependListener(event, fn); + } else { + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; + } } -function WritableState(options, stream) { +function ReadableState(options, stream) { Duplex = Duplex || require('./_stream_duplex'); options = options || {}; - // object stream flag to indicate whether or not this stream - // contains buffers or objects. + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away this.objectMode = !!options.objectMode; - if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; - // the point at which write() starts returning false - // Note: 0 is a valid value, means that we always return false if - // the entire buffer is not flushed immediately on write() + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" var hwm = options.highWaterMark; var defaultHwm = this.objectMode ? 16 : 16 * 1024; this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; // cast to ints. - this.highWaterMark = ~ ~this.highWaterMark; + this.highWaterMark = Math.floor(this.highWaterMark); - // drain event flag. - this.needDrain = false; - // at the start of calling end() - this.ending = false; - // when end() has been called, and returned + // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; this.ended = false; - // when 'finish' is emitted - this.finished = false; + this.endEmitted = false; + this.reading = false; - // should we decode strings into buffers before passing to _write? - // this is here so that some node-core streams can optimize string - // handling at a lower level. - var noDecode = options.decodeStrings === false; - this.decodeStrings = !noDecode; + // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // has it been destroyed + this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. // Everything else in the universe uses 'utf8', though. this.defaultEncoding = options.defaultEncoding || 'utf8'; - // not an actual buffer we keep track of, but a measurement - // of how much we're waiting to get pushed to some underlying - // socket or file. - this.length = 0; + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; - // a flag to see when we're in the middle of a write. - this.writing = false; + // if true, a maybeReadMore has been scheduled + this.readingMore = false; - // when true all writes will be buffered until .uncork() call - this.corked = 0; + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} - // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, because any - // actions that shouldn't happen until "later" should generally also - // not happen before the first write call. - this.sync = true; +function Readable(options) { + Duplex = Duplex || require('./_stream_duplex'); - // a flag to know if we're processing previously buffered items, which - // may call the _write() callback in the same tick, so that we don't - // end up in an overlapped onwrite situation. - this.bufferProcessing = false; + if (!(this instanceof Readable)) return new Readable(options); - // the callback that's passed to _write(chunk,cb) - this.onwrite = function (er) { - onwrite(stream, er); - }; + this._readableState = new ReadableState(options, this); - // the callback that the user supplies to write(chunk,encoding,cb) - this.writecb = null; + // legacy + this.readable = true; - // the amount that is being written when _write is called. - this.writelen = 0; + if (options) { + if (typeof options.read === 'function') this._read = options.read; - this.bufferedRequest = null; - this.lastBufferedRequest = null; + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } - // number of pending user-supplied write callbacks - // this must be 0 before 'finish' can be emitted - this.pendingcb = 0; + Stream.call(this); +} - // emit prefinish if the only thing we're waiting for is _write cbs - // This is relevant for synchronous Transform streams - this.prefinished = false; +Object.defineProperty(Readable.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } - // True if the error was already emitted and should not be thrown again - this.errorEmitted = false; + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + } +}); - // count buffered requests - this.bufferedRequestCount = 0; +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; +Readable.prototype._destroy = function (err, cb) { + this.push(null); + cb(err); +}; - // allocate the first CorkedRequest, there is always - // one allocated and free to use, and we maintain at most two - this.corkedRequestsFree = new CorkedRequest(this); +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); +}; + +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + var state = stream._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (addToFront) { + if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + } else if (state.ended) { + stream.emit('error', new Error('stream.push() after EOF')); + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + } + } + + return needMoreData(state); } -WritableState.prototype.getBuffer = function getBuffer() { - var current = this.bufferedRequest; - var out = []; - while (current) { - out.push(current); - current = current.next; +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); } - return out; + maybeReadMore(stream, state); +} + +function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; }; -(function () { - try { - Object.defineProperty(WritableState.prototype, 'buffer', { - get: internalUtil.deprecate(function () { - return this.getBuffer(); - }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.') - }); - } catch (_) {} -})(); +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; -// Test _writableState for inheritance to account for Duplex streams, -// whose prototype chain only points to Readable. -var realHasInstance; -if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { - realHasInstance = Function.prototype[Symbol.hasInstance]; - Object.defineProperty(Writable, Symbol.hasInstance, { - value: function (object) { - if (realHasInstance.call(this, object)) return true; +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} + +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } + // If we're asking for more than the current hwm, then raise the hwm. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + + if (n !== 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } - return object && object._writableState instanceof WritableState; - } - }); -} else { - realHasInstance = function (object) { - return object instanceof this; - }; -} + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. -function Writable(options) { - Duplex = Duplex || require('./_stream_duplex'); + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); - // Writable ctor is applied to Duplexes, too. - // `realHasInstance` is necessary because using plain `instanceof` - // would return false, as no `_writableState` property is attached. + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } - // Trying to use the custom `instanceof` for Writable here will also break the - // Node.js LazyTransform implementation, which has a non-trivial getter for - // `_writableState` that would lead to infinite recursion. - if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { - return new Writable(options); + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); } - this._writableState = new WritableState(options, this); + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; - // legacy. - this.writable = true; + if (ret === null) { + state.needReadable = true; + n = 0; + } else { + state.length -= n; + } - if (options) { - if (typeof options.write === 'function') this._write = options.write; + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; - if (typeof options.writev === 'function') this._writev = options.writev; + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended) endReadable(this); } - Stream.call(this); -} + if (ret !== null) this.emit('data', ret); -// Otherwise people can pipe Writable streams, which is just wrong. -Writable.prototype.pipe = function () { - this.emit('error', new Error('Cannot pipe, not readable')); + return ret; }; -function writeAfterEnd(stream, cb) { - var er = new Error('write after end'); - // TODO: defer error events consistently everywhere, not just the cb - stream.emit('error', er); - processNextTick(cb, er); +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); } -// If we get something that is not a buffer, string, null, or undefined, -// and we're not in objectMode, then that's an error. -// Otherwise stream chunks are all considered to be of length=1, and the -// watermarks determine how many objects to keep in the buffer, rather than -// how many bytes or characters. -function validChunk(stream, state, chunk, cb) { - var valid = true; - var er = false; - // Always throw error if a null is written - // if we are not in object mode then throw - // if it is not a buffer, string, or undefined. - if (chunk === null) { - er = new TypeError('May not write null values to stream'); - } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - if (er) { - stream.emit('error', er); - processNextTick(cb, er); - valid = false; +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream); } - return valid; } -Writable.prototype.write = function (chunk, encoding, cb) { - var state = this._writableState; - var ret = false; +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} - if (typeof encoding === 'function') { - cb = encoding; - encoding = null; +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + processNextTick(maybeReadMore_, stream, state); } +} - if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; - - if (typeof cb !== 'function') cb = nop; - - if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) { - state.pendingcb++; - ret = writeOrBuffer(this, state, chunk, encoding, cb); +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; } + state.readingMore = false; +} - return ret; +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function (n) { + this.emit('error', new Error('_read() is not implemented')); }; -Writable.prototype.cork = function () { - var state = this._writableState; +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; - state.corked++; -}; + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); -Writable.prototype.uncork = function () { - var state = this._writableState; + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; - if (state.corked) { - state.corked--; + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn); - if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } } -}; - -Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { - // node::ParseEncoding() requires lower case. - if (typeof encoding === 'string') encoding = encoding.toLowerCase(); - if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); - this._writableState.defaultEncoding = encoding; - return this; -}; -function decodeChunk(state, chunk, encoding) { - if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { - chunk = bufferShim.from(chunk, encoding); + function onend() { + debug('onend'); + dest.end(); } - return chunk; -} -// if we're already writing something, then just put this -// in the queue, and wait our turn. Otherwise, call _write -// If we return false, then we need a drain event, so set that flag. -function writeOrBuffer(stream, state, chunk, encoding, cb) { - chunk = decodeChunk(state, chunk, encoding); + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); - if (Buffer.isBuffer(chunk)) encoding = 'buffer'; - var len = state.objectMode ? 1 : chunk.length; + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); - state.length += len; + cleanedUp = true; - var ret = state.length < state.highWaterMark; - // we must ensure that previous needDrain will not be reset to false. - if (!ret) state.needDrain = true; + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } - if (state.writing || state.corked) { - var last = state.lastBufferedRequest; - state.lastBufferedRequest = new WriteReq(chunk, encoding, cb); - if (last) { - last.next = state.lastBufferedRequest; - } else { - state.bufferedRequest = state.lastBufferedRequest; + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + increasedAwaitDrain = false; + var ret = dest.write(chunk); + if (false === ret && !increasedAwaitDrain) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + increasedAwaitDrain = true; + } + src.pause(); } - state.bufferedRequestCount += 1; - } else { - doWrite(stream, state, false, len, chunk, encoding, cb); } - return ret; -} + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + } -function doWrite(stream, state, writev, len, chunk, encoding, cb) { - state.writelen = len; - state.writecb = cb; - state.writing = true; - state.sync = true; - if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); - state.sync = false; -} + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); -function onwriteError(stream, state, sync, er, cb) { - --state.pendingcb; - if (sync) processNextTick(cb, er);else cb(er); + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); - stream._writableState.errorEmitted = true; - stream.emit('error', er); -} + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } -function onwriteStateUpdate(state) { - state.writing = false; - state.writecb = null; - state.length -= state.writelen; - state.writelen = 0; + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; } -function onwrite(stream, er) { - var state = stream._writableState; - var sync = state.sync; - var cb = state.writecb; +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { hasUnpiped: false }; - onwriteStateUpdate(state); + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; - if (er) onwriteError(stream, state, sync, er, cb);else { - // Check if we're actually ready to finish, but don't emit yet - var finished = needFinish(state); + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; - if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { - clearBuffer(stream, state); - } + if (!dest) dest = state.pipes; - if (sync) { - /**/ - asyncWrite(afterWrite, stream, state, finished, cb); - /**/ - } else { - afterWrite(stream, state, finished, cb); - } + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; } -} -function afterWrite(stream, state, finished, cb) { - if (!finished) onwriteDrain(stream, state); - state.pendingcb--; - cb(); - finishMaybe(stream, state); -} + // slow case. multiple pipe destinations. -// Must force callback to be called on nextTick, so that we don't -// emit 'drain' before the write() consumer gets the 'false' return -// value, and has a chance to attach a 'drain' listener. -function onwriteDrain(stream, state) { - if (state.length === 0 && state.needDrain) { - state.needDrain = false; - stream.emit('drain'); + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, unpipeInfo); + }return this; } -} -// if there's something in the buffer waiting, then process it -function clearBuffer(stream, state) { - state.bufferProcessing = true; - var entry = state.bufferedRequest; + // try to find the right one. + var index = indexOf(state.pipes, dest); + if (index === -1) return this; - if (stream._writev && entry && entry.next) { - // Fast case, write everything using _writev() - var l = state.bufferedRequestCount; - var buffer = new Array(l); - var holder = state.corkedRequestsFree; - holder.entry = entry; + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; - var count = 0; - while (entry) { - buffer[count] = entry; - entry = entry.next; - count += 1; - } + dest.emit('unpipe', this, unpipeInfo); - doWrite(stream, state, true, state.length, buffer, '', holder.finish); + return this; +}; - // doWrite is almost always async, defer these to save a bit of time - // as the hot path ends with doWrite - state.pendingcb++; - state.lastBufferedRequest = null; - if (holder.next) { - state.corkedRequestsFree = holder.next; - holder.next = null; - } else { - state.corkedRequestsFree = new CorkedRequest(state); - } - } else { - // Slow case, write chunks one-by-one - while (entry) { - var chunk = entry.chunk; - var encoding = entry.encoding; - var cb = entry.callback; - var len = state.objectMode ? 1 : chunk.length; +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); - doWrite(stream, state, false, len, chunk, encoding, cb); - entry = entry.next; - // if we didn't call the onwrite immediately, then - // it means that we need to wait until it does. - // also, that means that the chunk and cb are currently - // being processed, so move the buffer counter past them. - if (state.writing) { - break; + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); + } else if (ev === 'readable') { + var state = this._readableState; + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.emittedReadable = false; + if (!state.reading) { + processNextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this); } } - - if (entry === null) state.lastBufferedRequest = null; } - state.bufferedRequestCount = 0; - state.bufferedRequest = entry; - state.bufferProcessing = false; -} - -Writable.prototype._write = function (chunk, encoding, cb) { - cb(new Error('_write() is not implemented')); + return res; }; +Readable.prototype.addListener = Readable.prototype.on; -Writable.prototype._writev = null; - -Writable.prototype.end = function (chunk, encoding, cb) { - var state = this._writableState; - - if (typeof chunk === 'function') { - cb = chunk; - chunk = null; - encoding = null; - } else if (typeof encoding === 'function') { - cb = encoding; - encoding = null; - } - - if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} - // .end() fully uncorks - if (state.corked) { - state.corked = 1; - this.uncork(); +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); } - - // ignore unnecessary end() calls. - if (!state.ending && !state.finished) endWritable(this, state, cb); + return this; }; -function needFinish(state) { - return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; -} - -function prefinish(stream, state) { - if (!state.prefinished) { - state.prefinished = true; - stream.emit('prefinish'); +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + processNextTick(resume_, stream, state); } } -function finishMaybe(stream, state) { - var need = needFinish(state); - if (need) { - if (state.pendingcb === 0) { - prefinish(stream, state); - state.finished = true; - stream.emit('finish'); - } else { - prefinish(stream, state); - } +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); } - return need; + + state.resumeScheduled = false; + state.awaitDrain = 0; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); } -function endWritable(stream, state, cb) { - state.ending = true; - finishMaybe(stream, state); - if (cb) { - if (state.finished) processNextTick(cb);else stream.once('finish', cb); +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); } - state.ended = true; - stream.writable = false; -} + return this; +}; -// It seems a linked list but it is not -// there will be only 2 of these for each stream -function CorkedRequest(state) { - var _this = this; +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null) {} +} - this.next = null; - this.entry = null; +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function (stream) { + var state = this._readableState; + var paused = false; - this.finish = function (err) { - var entry = _this.entry; - _this.entry = null; - while (entry) { - var cb = entry.callback; - state.pendingcb--; - cb(err); - entry = entry.next; - } - if (state.corkedRequestsFree) { - state.corkedRequestsFree.next = _this; - } else { - state.corkedRequestsFree = _this; + var self = this; + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) self.push(chunk); } - }; -} -}).call(this,require('_process')) -},{"./_stream_duplex":408,"_process":41,"buffer":7,"buffer-shims":6,"core-util-is":10,"events":23,"inherits":32,"process-nextick-args":40,"util-deprecate":427}],413:[function(require,module,exports){ -arguments[4][398][0].apply(exports,arguments) -},{"buffer":7,"buffer-shims":6,"dup":398}],414:[function(require,module,exports){ -(function (process){ -var Stream = (function (){ - try { - return require('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify - } catch(_){} -}()); -exports = module.exports = require('./lib/_stream_readable.js'); -exports.Stream = Stream || exports; -exports.Readable = exports; -exports.Writable = require('./lib/_stream_writable.js'); -exports.Duplex = require('./lib/_stream_duplex.js'); -exports.Transform = require('./lib/_stream_transform.js'); -exports.PassThrough = require('./lib/_stream_passthrough.js'); + self.push(null); + }); -if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) { - module.exports = Stream; -} + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); -}).call(this,require('_process')) + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; -},{"./lib/_stream_duplex.js":408,"./lib/_stream_passthrough.js":409,"./lib/_stream_readable.js":410,"./lib/_stream_transform.js":411,"./lib/_stream_writable.js":412,"_process":41}],415:[function(require,module,exports){ -'use strict'; + var ret = self.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); -var bind = require('function-bind'); -var ES = require('es-abstract/es5'); -var replace = bind.call(Function.call, String.prototype.replace); + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } -var leftWhitespace = /^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/; -var rightWhitespace = /[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/; + // proxy certain important events. + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n])); + } -module.exports = function trim() { - var S = ES.ToString(ES.CheckObjectCoercible(this)); - return replace(replace(S, leftWhitespace, ''), rightWhitespace, ''); + // when we try to consume some more bytes, simply unpause the + // underlying stream. + self._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return self; }; -},{"es-abstract/es5":16,"function-bind":27}],416:[function(require,module,exports){ -'use strict'; +// exposed for testing purposes only. +Readable._fromList = fromList; -var bind = require('function-bind'); -var define = require('define-properties'); +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; -var implementation = require('./implementation'); -var getPolyfill = require('./polyfill'); -var shim = require('./shim'); + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = fromListPartial(n, state.buffer, state.decoder); + } -var boundTrim = bind.call(Function.call, getPolyfill()); + return ret; +} -define(boundTrim, { - getPolyfill: getPolyfill, - implementation: implementation, - shim: shim -}); +// Extracts only enough buffered data to satisfy the amount requested. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); + } + return ret; +} -module.exports = boundTrim; +// Copies a specified amount of characters from the list of buffered data +// chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} -},{"./implementation":415,"./polyfill":417,"./shim":418,"define-properties":14,"function-bind":27}],417:[function(require,module,exports){ -'use strict'; +// Copies a specified amount of bytes from the list of buffered data chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBuffer(n, list) { + var ret = Buffer.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} -var implementation = require('./implementation'); +function endReadable(stream) { + var state = stream._readableState; -var zeroWidthSpace = '\u200b'; + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); -module.exports = function getPolyfill() { - if (String.prototype.trim && zeroWidthSpace.trim() === zeroWidthSpace) { - return String.prototype.trim; - } - return implementation; -}; + if (!state.endEmitted) { + state.ended = true; + processNextTick(endReadableNT, state, stream); + } +} -},{"./implementation":415}],418:[function(require,module,exports){ -'use strict'; +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} -var define = require('define-properties'); -var getPolyfill = require('./polyfill'); +function forEach(xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} -module.exports = function shimStringTrim() { - var polyfill = getPolyfill(); - define(String.prototype, { trim: polyfill }, { trim: function () { return String.prototype.trim !== polyfill; } }); - return polyfill; -}; +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./polyfill":417,"define-properties":14}],419:[function(require,module,exports){ +},{"./_stream_duplex":413,"./internal/streams/BufferList":418,"./internal/streams/destroy":419,"./internal/streams/stream":420,"_process":40,"core-util-is":9,"events":22,"inherits":29,"isarray":412,"process-nextick-args":39,"safe-buffer":385,"string_decoder/":423,"util":4}],416:[function(require,module,exports){ +arguments[4][393][0].apply(exports,arguments) +},{"./_stream_duplex":413,"core-util-is":9,"dup":393,"inherits":29}],417:[function(require,module,exports){ +(function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -25921,1092 +25986,847 @@ module.exports = function shimStringTrim() { // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -var Buffer = require('buffer').Buffer; +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. -var isBufferEncoding = Buffer.isEncoding - || function(encoding) { - switch (encoding && encoding.toLowerCase()) { - case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; - default: return false; - } - } +'use strict'; +/**/ -function assertEncoding(encoding) { - if (encoding && !isBufferEncoding(encoding)) { - throw new Error('Unknown encoding: ' + encoding); - } +var processNextTick = require('process-nextick-args'); +/**/ + +module.exports = Writable; + +/* */ +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; } -// StringDecoder provides an interface for efficiently splitting a series of -// buffers into a series of JS strings without breaking apart multi-byte -// characters. CESU-8 is handled as part of the UTF-8 encoding. -// -// @TODO Handling all encodings inside a single object makes it very difficult -// to reason about this code, so it should be split up in the future. -// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code -// points as used by CESU-8. -var StringDecoder = exports.StringDecoder = function(encoding) { - this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); - assertEncoding(encoding); - switch (this.encoding) { - case 'utf8': - // CESU-8 represents each of Surrogate Pair by 3-bytes - this.surrogateSize = 3; - break; - case 'ucs2': - case 'utf16le': - // UTF-16 represents each of Surrogate Pair by 2-bytes - this.surrogateSize = 2; - this.detectIncompleteChar = utf16DetectIncompleteChar; - break; - case 'base64': - // Base-64 stores 3 bytes in 4 chars, and pads the remainder. - this.surrogateSize = 3; - this.detectIncompleteChar = base64DetectIncompleteChar; - break; - default: - this.write = passThroughWrite; - return; - } +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; - // Enough space to store all bytes of a single character. UTF-8 needs 4 - // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). - this.charBuffer = new Buffer(6); - // Number of bytes received for the current incomplete multi-byte character. - this.charReceived = 0; - // Number of bytes expected for the current incomplete multi-byte character. - this.charLength = 0; + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ + +/**/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick; +/**/ + +/**/ +var Duplex; +/**/ + +Writable.WritableState = WritableState; + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +/**/ +var internalUtil = { + deprecate: require('util-deprecate') }; +/**/ +/**/ +var Stream = require('./internal/streams/stream'); +/**/ -// write decodes the given buffer and returns it as JS string that is -// guaranteed to not contain any partial multi-byte characters. Any partial -// character found at the end of the buffer is buffered up, and will be -// returned when calling write again with the remaining bytes. -// -// Note: Converting a Buffer containing an orphan surrogate to a String -// currently works, but converting a String to a Buffer (via `new Buffer`, or -// Buffer#write) will replace incomplete surrogates with the unicode -// replacement character. See https://codereview.chromium.org/121173009/ . -StringDecoder.prototype.write = function(buffer) { - var charStr = ''; - // if our last write ended with an incomplete multibyte character - while (this.charLength) { - // determine how many remaining bytes this buffer has to offer for this char - var available = (buffer.length >= this.charLength - this.charReceived) ? - this.charLength - this.charReceived : - buffer.length; +/**/ +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} +/**/ - // add the new bytes to the char buffer - buffer.copy(this.charBuffer, this.charReceived, 0, available); - this.charReceived += available; +var destroyImpl = require('./internal/streams/destroy'); - if (this.charReceived < this.charLength) { - // still not enough chars in this buffer? wait for more ... - return ''; - } +util.inherits(Writable, Stream); - // remove bytes belonging to the current character from the buffer - buffer = buffer.slice(available, buffer.length); +function nop() {} - // get the character that was split - charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); +function WritableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); - // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character - var charCode = charStr.charCodeAt(charStr.length - 1); - if (charCode >= 0xD800 && charCode <= 0xDBFF) { - this.charLength += this.surrogateSize; - charStr = ''; - continue; - } - this.charReceived = this.charLength = 0; + options = options || {}; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // if _final has been called + this.finalCalled = false; + + // drain event flag. + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // has it been destroyed + this.destroyed = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; - // if there are no more bytes in this buffer, just emit our char - if (buffer.length === 0) { - return charStr; - } - break; - } + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; - // determine and set charLength / charReceived - this.detectIncompleteChar(buffer); + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; - var end = buffer.length; - if (this.charLength) { - // buffer the incomplete character bytes we got - buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); - end -= this.charReceived; - } + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; - charStr += buffer.toString(this.encoding, 0, end); + // count buffered requests + this.bufferedRequestCount = 0; - var end = charStr.length - 1; - var charCode = charStr.charCodeAt(end); - // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character - if (charCode >= 0xD800 && charCode <= 0xDBFF) { - var size = this.surrogateSize; - this.charLength += size; - this.charReceived += size; - this.charBuffer.copy(this.charBuffer, size, 0, size); - buffer.copy(this.charBuffer, 0, 0, size); - return charStr.substring(0, end); - } + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); +} - // or just emit the charStr - return charStr; +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; }; -// detectIncompleteChar determines if there is an incomplete UTF-8 character at -// the end of the given buffer. If so, it sets this.charLength to the byte -// length that character, and sets this.charReceived to the number of bytes -// that are available for this character. -StringDecoder.prototype.detectIncompleteChar = function(buffer) { - // determine how many bytes we have to check at the end of this buffer - var i = (buffer.length >= 3) ? 3 : buffer.length; - - // Figure out if one of the last i bytes of our buffer announces an - // incomplete char. - for (; i > 0; i--) { - var c = buffer[buffer.length - i]; +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} +})(); - // See http://en.wikipedia.org/wiki/UTF-8#Description +// Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. +var realHasInstance; +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function (object) { + if (realHasInstance.call(this, object)) return true; - // 110XXXXX - if (i == 1 && c >> 5 == 0x06) { - this.charLength = 2; - break; + return object && object._writableState instanceof WritableState; } + }); +} else { + realHasInstance = function (object) { + return object instanceof this; + }; +} - // 1110XXXX - if (i <= 2 && c >> 4 == 0x0E) { - this.charLength = 3; - break; - } +function Writable(options) { + Duplex = Duplex || require('./_stream_duplex'); - // 11110XXX - if (i <= 3 && c >> 3 == 0x1E) { - this.charLength = 4; - break; - } + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { + return new Writable(options); } - this.charReceived = i; -}; -StringDecoder.prototype.end = function(buffer) { - var res = ''; - if (buffer && buffer.length) - res = this.write(buffer); + this._writableState = new WritableState(options, this); - if (this.charReceived) { - var cr = this.charReceived; - var buf = this.charBuffer; - var enc = this.encoding; - res += buf.slice(0, cr).toString(enc); + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + + if (typeof options.writev === 'function') this._writev = options.writev; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + + if (typeof options.final === 'function') this._final = options.final; } - return res; + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe, not readable')); }; -function passThroughWrite(buffer) { - return buffer.toString(this.encoding); +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + processNextTick(cb, er); } -function utf16DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 2; - this.charLength = this.charReceived ? 2 : 0; -} +// Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. +function validChunk(stream, state, chunk, cb) { + var valid = true; + var er = false; -function base64DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 3; - this.charLength = this.charReceived ? 3 : 0; + if (chunk === null) { + er = new TypeError('May not write null values to stream'); + } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + if (er) { + stream.emit('error', er); + processNextTick(cb, er); + valid = false; + } + return valid; } -},{"buffer":7}],420:[function(require,module,exports){ -(function (process){ -var through = require('through'); -var fs = require('fs'); +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = _isUint8Array(chunk) && !state.objectMode; -module.exports = function () { - var line = ''; - var stream = through(write, flush); - return stream; - - function write (buf) { - for (var i = 0; i < buf.length; i++) { - var c = typeof buf === 'string' - ? buf.charAt(i) - : String.fromCharCode(buf[i]) - ; - if (c === '\n') flush(); - else line += c; - } - } - - function flush () { - if (fs.writeSync && /^win/.test(process.platform)) { - try { fs.writeSync(1, line + '\n'); } - catch (e) { stream.emit('error', e) } - } - else { - try { console.log(line) } - catch (e) { stream.emit('error', e) } - } - line = ''; - } -}; + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } -}).call(this,require('_process')) + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } -},{"_process":41,"fs":5,"through":423}],421:[function(require,module,exports){ -(function (process){ -var EventEmitter = require('events').EventEmitter; -var inherits = require('inherits'); -var through = require('through'); -var resumer = require('resumer'); -var inspect = require('object-inspect'); -var bind = require('function-bind'); -var has = require('has'); -var regexpTest = bind.call(Function.call, RegExp.prototype.test); -var yamlIndicators = /\:|\-|\?/; -var nextTick = typeof setImmediate !== 'undefined' - ? setImmediate - : process.nextTick -; + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; -module.exports = Results; -inherits(Results, EventEmitter); + if (typeof cb !== 'function') cb = nop; -function Results () { - if (!(this instanceof Results)) return new Results; - this.count = 0; - this.fail = 0; - this.pass = 0; - this._stream = through(); - this.tests = []; - this._only = null; -} + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } -Results.prototype.createStream = function (opts) { - if (!opts) opts = {}; - var self = this; - var output, testId = 0; - if (opts.objectMode) { - output = through(); - self.on('_push', function ontest (t, extra) { - if (!extra) extra = {}; - var id = testId++; - t.once('prerun', function () { - var row = { - type: 'test', - name: t.name, - id: id - }; - if (has(extra, 'parent')) { - row.parent = extra.parent; - } - output.queue(row); - }); - t.on('test', function (st) { - ontest(st, { parent: id }); - }); - t.on('result', function (res) { - res.test = id; - res.type = 'assert'; - output.queue(res); - }); - t.on('end', function () { - output.queue({ type: 'end', test: id }); - }); - }); - self.on('done', function () { output.queue(null) }); - } - else { - output = resumer(); - output.queue('TAP version 13\n'); - self._stream.pipe(output); - } - - nextTick(function next() { - var t; - while (t = getNextTest(self)) { - t.run(); - if (!t.ended) return t.once('end', function(){ nextTick(next); }); - } - self.emit('done'); - }); - - return output; + return ret; }; -Results.prototype.push = function (t) { - var self = this; - self.tests.push(t); - self._watch(t); - self.emit('_push', t); -}; +Writable.prototype.cork = function () { + var state = this._writableState; -Results.prototype.only = function (t) { - this._only = t; + state.corked++; }; -Results.prototype._watch = function (t) { - var self = this; - var write = function (s) { self._stream.queue(s) }; - t.once('prerun', function () { - write('# ' + t.name + '\n'); - }); - - t.on('result', function (res) { - if (typeof res === 'string') { - write('# ' + res + '\n'); - return; - } - write(encodeResult(res, self.count + 1)); - self.count ++; +Writable.prototype.uncork = function () { + var state = this._writableState; - if (res.ok) self.pass ++ - else self.fail ++ - }); - - t.on('test', function (st) { self._watch(st) }); -}; + if (state.corked) { + state.corked--; -Results.prototype.close = function () { - var self = this; - if (self.closed) self._stream.emit('error', new Error('ALREADY CLOSED')); - self.closed = true; - var write = function (s) { self._stream.queue(s) }; - - write('\n1..' + self.count + '\n'); - write('# tests ' + self.count + '\n'); - write('# pass ' + self.pass + '\n'); - if (self.fail) write('# fail ' + self.fail + '\n') - else write('\n# ok\n') + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; - self._stream.queue(null); +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; + return this; }; -function encodeResult (res, count) { - var output = ''; - output += (res.ok ? 'ok ' : 'not ok ') + count; - output += res.name ? ' ' + res.name.toString().replace(/\s+/g, ' ') : ''; - - if (res.skip) output += ' # SKIP'; - else if (res.todo) output += ' # TODO'; - - output += '\n'; - if (res.ok) return output; - - var outer = ' '; - var inner = outer + ' '; - output += outer + '---\n'; - output += inner + 'operator: ' + res.operator + '\n'; - - if (has(res, 'expected') || has(res, 'actual')) { - var ex = inspect(res.expected, {depth: res.objectPrintDepth}); - var ac = inspect(res.actual, {depth: res.objectPrintDepth}); - - if (Math.max(ex.length, ac.length) > 65 || invalidYaml(ex) || invalidYaml(ac)) { - output += inner + 'expected: |-\n' + inner + ' ' + ex + '\n'; - output += inner + 'actual: |-\n' + inner + ' ' + ac + '\n'; - } - else { - output += inner + 'expected: ' + ex + '\n'; - output += inner + 'actual: ' + ac + '\n'; - } - } - if (res.at) { - output += inner + 'at: ' + res.at + '\n'; - } - if (res.operator === 'error' && res.actual && res.actual.stack) { - var lines = String(res.actual.stack).split('\n'); - output += inner + 'stack: |-\n'; - for (var i = 0; i < lines.length; i++) { - output += inner + ' ' + lines[i] + '\n'; - } - } - - output += outer + '...\n'; - return output; +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + return chunk; } -function getNextTest (results) { - if (!results._only) { - return results.tests.shift(); +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; } - - do { - var t = results.tests.shift(); - if (!t) continue; - if (results._only === t) { - return t; - } - } while (results.tests.length !== 0) -} - -function invalidYaml (str) { - return regexpTest(yamlIndicators, str); -} - -}).call(this,require('_process')) - -},{"_process":41,"events":23,"function-bind":27,"has":28,"inherits":32,"object-inspect":36,"resumer":46,"through":423}],422:[function(require,module,exports){ -(function (process,__dirname){ -var deepEqual = require('deep-equal'); -var defined = require('defined'); -var path = require('path'); -var inherits = require('inherits'); -var EventEmitter = require('events').EventEmitter; -var has = require('has'); -var trim = require('string.prototype.trim'); -var bind = require('function-bind'); -var forEach = require('for-each'); -var isEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable); - -module.exports = Test; - -var nextTick = typeof setImmediate !== 'undefined' - ? setImmediate - : process.nextTick -; -var safeSetTimeout = setTimeout; + } + var len = state.objectMode ? 1 : chunk.length; -inherits(Test, EventEmitter); + state.length += len; -var getTestArgs = function (name_, opts_, cb_) { - var name = '(anonymous)'; - var opts = {}; - var cb; + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - var t = typeof arg; - if (t === 'string') { - name = arg; - } - else if (t === 'object') { - opts = arg || opts; - } - else if (t === 'function') { - cb = arg; - } + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; } - return { name: name, opts: opts, cb: cb }; -}; + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } -function Test (name_, opts_, cb_) { - if (! (this instanceof Test)) { - return new Test(name_, opts_, cb_); - } + return ret; +} - var args = getTestArgs(name_, opts_, cb_); +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} - this.readable = true; - this.name = args.name || '(anonymous)'; - this.assertCount = 0; - this.pendingCount = 0; - this._skip = args.opts.skip || false; - this._timeout = args.opts.timeout; - this._objectPrintDepth = args.opts.objectPrintDepth || 5; - this._plan = undefined; - this._cb = args.cb; - this._progeny = []; - this._ok = true; +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; - for (var prop in this) { - this[prop] = (function bind(self, val) { - if (typeof val === 'function') { - return function bound() { - return val.apply(self, arguments); - }; - } - else return val; - })(this, this[prop]); - } + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + processNextTick(cb, er); + // this can emit finish, and it will always happen + // after error + processNextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + // this can emit finish, but finish must + // always follow error + finishMaybe(stream, state); + } } -Test.prototype.run = function () { - if (this._skip) { - this.comment('SKIP ' + this.name); - } - if (!this._cb || this._skip) { - return this._end(); - } - if (this._timeout != null) { - this.timeoutAfter(this._timeout); - } - this.emit('prerun'); - this._cb(this); - this.emit('run'); -}; +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); -Test.prototype.test = function (name, opts, cb) { - var self = this; - var t = new Test(name, opts, cb); - this._progeny.push(t); - this.pendingCount++; - this.emit('test', t); - t.on('prerun', function () { - self.assertCount++; - }) - - if (!self._pendingAsserts()) { - nextTick(function () { - self._end(); - }); + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); + + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); } - - nextTick(function() { - if (!self._plan && self.pendingCount == self._progeny.length) { - self._end(); - } - }); -}; -Test.prototype.comment = function (msg) { - var that = this; - forEach(trim(msg).split('\n'), function (aMsg) { - that.emit('result', trim(aMsg).replace(/^#\s*/, '')); - }); -}; + if (sync) { + /**/ + asyncWrite(afterWrite, stream, state, finished, cb); + /**/ + } else { + afterWrite(stream, state, finished, cb); + } + } +} -Test.prototype.plan = function (n) { - this._plan = n; - this.emit('plan', n); -}; +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} -Test.prototype.timeoutAfter = function(ms) { - if (!ms) throw new Error('timeoutAfter requires a timespan'); - var self = this; - var timeout = safeSetTimeout(function() { - self.fail('test timed out after ' + ms + 'ms'); - self.end(); - }, ms); - this.once('end', function() { - clearTimeout(timeout); - }); +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } } -Test.prototype.end = function (err) { - var self = this; - if (arguments.length >= 1 && !!err) { - this.ifError(err); - } - - if (this.calledEnd) { - this.fail('.end() called twice'); - } - this.calledEnd = true; - this._end(); -}; +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; -Test.prototype._end = function (err) { - var self = this; - if (this._progeny.length) { - var t = this._progeny.shift(); - t.on('end', function () { self._end() }); - t.run(); - return; - } - - if (!this.ended) this.emit('end'); - var pendingAsserts = this._pendingAsserts(); - if (!this._planError && this._plan !== undefined && pendingAsserts) { - this._planError = true; - this.fail('plan != count', { - expected : this._plan, - actual : this.assertCount - }); - } - this.ended = true; -}; + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; -Test.prototype._exit = function () { - if (this._plan !== undefined && - !this._planError && this.assertCount !== this._plan) { - this._planError = true; - this.fail('plan != count', { - expected : this._plan, - actual : this.assertCount, - exiting : true - }); - } - else if (!this.ended) { - this.fail('test exited without ending', { - exiting: true - }); + var count = 0; + var allBuffers = true; + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; } -}; + buffer.allBuffers = allBuffers; -Test.prototype._pendingAsserts = function () { - if (this._plan === undefined) { - return 1; - } - else { - return this._plan - (this._progeny.length + this.assertCount); - } -}; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); -Test.prototype._assert = function assert (ok, opts) { - var self = this; - var extra = opts.extra || {}; - - var res = { - id : self.assertCount ++, - ok : Boolean(ok), - skip : defined(extra.skip, opts.skip), - name : defined(extra.message, opts.message, '(unnamed assert)'), - operator : defined(extra.operator, opts.operator), - objectPrintDepth : self._objectPrintDepth - }; - if (has(opts, 'actual') || has(extra, 'actual')) { - res.actual = defined(extra.actual, opts.actual); - } - if (has(opts, 'expected') || has(extra, 'expected')) { - res.expected = defined(extra.expected, opts.expected); - } - this._ok = Boolean(this._ok && ok); - - if (!ok) { - res.error = defined(extra.error, opts.error, new Error(res.name)); + // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); } - - if (!ok) { - var e = new Error('exception'); - var err = (e.stack || '').split('\n'); - var dir = path.dirname(__dirname) + path.sep; - - for (var i = 0; i < err.length; i++) { - var m = /^[^\s]*\s*\bat\s+(.+)/.exec(err[i]); - if (!m) { - continue; - } - - var s = m[1].split(/\s+/); - var filem = /((?:\/|[A-Z]:\\)[^:\s]+:(\d+)(?::(\d+))?)/.exec(s[1]); - if (!filem) { - filem = /((?:\/|[A-Z]:\\)[^:\s]+:(\d+)(?::(\d+))?)/.exec(s[2]); - - if (!filem) { - filem = /((?:\/|[A-Z]:\\)[^:\s]+:(\d+)(?::(\d+))?)/.exec(s[3]); + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; - if (!filem) { - continue; - } - } - } - - if (filem[1].slice(0, dir.length) === dir) { - continue; - } - - res.functionName = s[0]; - res.file = filem[1]; - res.line = Number(filem[2]); - if (filem[3]) res.column = filem[3]; - - res.at = m[1]; - break; - } + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } } - self.emit('result', res); - - var pendingAsserts = self._pendingAsserts(); - if (!pendingAsserts) { - if (extra.exiting) { - self._end(); - } else { - nextTick(function () { - self._end(); - }); - } - } - - if (!self._planError && pendingAsserts < 0) { - self._planError = true; - self.fail('plan != count', { - expected : self._plan, - actual : self._plan - pendingAsserts - }); - } -}; + if (entry === null) state.lastBufferedRequest = null; + } -Test.prototype.fail = function (msg, extra) { - this._assert(false, { - message : msg, - operator : 'fail', - extra : extra - }); -}; + state.bufferedRequestCount = 0; + state.bufferedRequest = entry; + state.bufferProcessing = false; +} -Test.prototype.pass = function (msg, extra) { - this._assert(true, { - message : msg, - operator : 'pass', - extra : extra - }); +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('_write() is not implemented')); }; -Test.prototype.skip = function (msg, extra) { - this._assert(true, { - message : msg, - operator : 'skip', - skip : true, - extra : extra - }); -}; +Writable.prototype._writev = null; -Test.prototype.ok -= Test.prototype['true'] -= Test.prototype.assert -= function (value, msg, extra) { - this._assert(value, { - message : defined(msg, 'should be truthy'), - operator : 'ok', - expected : true, - actual : value, - extra : extra - }); -}; +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; -Test.prototype.notOk -= Test.prototype['false'] -= Test.prototype.notok -= function (value, msg, extra) { - this._assert(!value, { - message : defined(msg, 'should be falsy'), - operator : 'notOk', - expected : false, - actual : value, - extra : extra - }); -}; + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } -Test.prototype.error -= Test.prototype.ifError -= Test.prototype.ifErr -= Test.prototype.iferror -= function (err, msg, extra) { - this._assert(!err, { - message : defined(msg, String(err)), - operator : 'error', - actual : err, - extra : extra - }); -}; + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); -Test.prototype.equal -= Test.prototype.equals -= Test.prototype.isEqual -= Test.prototype.is -= Test.prototype.strictEqual -= Test.prototype.strictEquals -= function (a, b, msg, extra) { - this._assert(a === b, { - message : defined(msg, 'should be equal'), - operator : 'equal', - actual : a, - expected : b, - extra : extra - }); -}; + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } -Test.prototype.notEqual -= Test.prototype.notEquals -= Test.prototype.notStrictEqual -= Test.prototype.notStrictEquals -= Test.prototype.isNotEqual -= Test.prototype.isNot -= Test.prototype.not -= Test.prototype.doesNotEqual -= Test.prototype.isInequal -= function (a, b, msg, extra) { - this._assert(a !== b, { - message : defined(msg, 'should not be equal'), - operator : 'notEqual', - actual : a, - notExpected : b, - extra : extra - }); + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) endWritable(this, state, cb); }; -Test.prototype.deepEqual -= Test.prototype.deepEquals -= Test.prototype.isEquivalent -= Test.prototype.same -= function (a, b, msg, extra) { - this._assert(deepEqual(a, b, { strict: true }), { - message : defined(msg, 'should be equivalent'), - operator : 'deepEqual', - actual : a, - expected : b, - extra : extra - }); -}; +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + stream.emit('error', err); + } + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function') { + state.pendingcb++; + state.finalCalled = true; + processNextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } + } +} -Test.prototype.deepLooseEqual -= Test.prototype.looseEqual -= Test.prototype.looseEquals -= function (a, b, msg, extra) { - this._assert(deepEqual(a, b), { - message : defined(msg, 'should be equivalent'), - operator : 'deepLooseEqual', - actual : a, - expected : b, - extra : extra - }); -}; +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + prefinish(stream, state); + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + } + } + return need; +} -Test.prototype.notDeepEqual -= Test.prototype.notEquivalent -= Test.prototype.notDeeply -= Test.prototype.notSame -= Test.prototype.isNotDeepEqual -= Test.prototype.isNotDeeply -= Test.prototype.isNotEquivalent -= Test.prototype.isInequivalent -= function (a, b, msg, extra) { - this._assert(!deepEqual(a, b, { strict: true }), { - message : defined(msg, 'should not be equivalent'), - operator : 'notDeepEqual', - actual : a, - notExpected : b, - extra : extra - }); -}; +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) processNextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} -Test.prototype.notDeepLooseEqual -= Test.prototype.notLooseEqual -= Test.prototype.notLooseEquals -= function (a, b, msg, extra) { - this._assert(!deepEqual(a, b), { - message : defined(msg, 'should be equivalent'), - operator : 'notDeepLooseEqual', - actual : a, - expected : b, - extra : extra - }); -}; +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = corkReq; + } else { + state.corkedRequestsFree = corkReq; + } +} -Test.prototype['throws'] = function (fn, expected, msg, extra) { - if (typeof expected === 'string') { - msg = expected; - expected = undefined; +Object.defineProperty(Writable.prototype, 'destroyed', { + get: function () { + if (this._writableState === undefined) { + return false; + } + return this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; } - var caught = undefined; + // backward compatibility, the user is explicitly + // managing destroyed + this._writableState.destroyed = value; + } +}); - try { - fn(); - } catch (err) { - caught = { error : err }; - if ((err != null) && (!isEnumerable(err, 'message') || !has(err, 'message'))) { - var message = err.message; - delete err.message; - err.message = message; - } - } +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; +Writable.prototype._destroy = function (err, cb) { + this.end(); + cb(err); +}; +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - var passed = caught; +},{"./_stream_duplex":413,"./internal/streams/destroy":419,"./internal/streams/stream":420,"_process":40,"core-util-is":9,"inherits":29,"process-nextick-args":39,"safe-buffer":385,"util-deprecate":425}],418:[function(require,module,exports){ +arguments[4][395][0].apply(exports,arguments) +},{"dup":395,"safe-buffer":385}],419:[function(require,module,exports){ +arguments[4][396][0].apply(exports,arguments) +},{"dup":396,"process-nextick-args":39}],420:[function(require,module,exports){ +arguments[4][397][0].apply(exports,arguments) +},{"dup":397,"events":22}],421:[function(require,module,exports){ +arguments[4][399][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":413,"./lib/_stream_passthrough.js":414,"./lib/_stream_readable.js":415,"./lib/_stream_transform.js":416,"./lib/_stream_writable.js":417,"dup":399}],422:[function(require,module,exports){ +arguments[4][400][0].apply(exports,arguments) +},{"./readable":421,"dup":400}],423:[function(require,module,exports){ +arguments[4][402][0].apply(exports,arguments) +},{"dup":402,"safe-buffer":385}],424:[function(require,module,exports){ +(function (process){ +var Transform = require('readable-stream/transform') + , inherits = require('util').inherits + , xtend = require('xtend') - if (expected instanceof RegExp) { - passed = expected.test(caught && caught.error); - expected = String(expected); - } +function DestroyableTransform(opts) { + Transform.call(this, opts) + this._destroyed = false +} - if (typeof expected === 'function' && caught) { - passed = caught.error instanceof expected; - caught.error = caught.error.constructor; - } +inherits(DestroyableTransform, Transform) - this._assert(typeof fn === 'function' && passed, { - message : defined(msg, 'should throw'), - operator : 'throws', - actual : caught && caught.error, - expected : expected, - error: !passed && caught && caught.error, - extra : extra - }); -}; +DestroyableTransform.prototype.destroy = function(err) { + if (this._destroyed) return + this._destroyed = true + + var self = this + process.nextTick(function() { + if (err) + self.emit('error', err) + self.emit('close') + }) +} -Test.prototype.doesNotThrow = function (fn, expected, msg, extra) { - if (typeof expected === 'string') { - msg = expected; - expected = undefined; - } - var caught = undefined; - try { - fn(); - } - catch (err) { - caught = { error : err }; +// a noop _transform function +function noop (chunk, enc, callback) { + callback(null, chunk) +} + + +// create a new export function, used by both the main export and +// the .ctor export, contains common logic for dealing with arguments +function through2 (construct) { + return function (options, transform, flush) { + if (typeof options == 'function') { + flush = transform + transform = options + options = {} } - this._assert(!caught, { - message : defined(msg, 'should not throw'), - operator : 'throws', - actual : caught && caught.error, - expected : expected, - error : caught && caught.error, - extra : extra - }); -}; -Test.skip = function (name_, _opts, _cb) { - var args = getTestArgs.apply(null, arguments); - args.opts.skip = true; - return Test(args.name, args.opts, args.cb); -}; + if (typeof transform != 'function') + transform = noop -// vim: set softtabstop=4 shiftwidth=4: + if (typeof flush != 'function') + flush = null + return construct(options, transform, flush) + } +} -}).call(this,require('_process'),"/node_modules/tape/lib") -},{"_process":41,"deep-equal":11,"defined":15,"events":23,"for-each":24,"function-bind":27,"has":28,"inherits":32,"path":39,"string.prototype.trim":416}],423:[function(require,module,exports){ -(function (process){ -var Stream = require('stream') +// main export, just make me a transform stream! +module.exports = through2(function (options, transform, flush) { + var t2 = new DestroyableTransform(options) -// through -// -// a stream that does nothing but re-emit the input. -// useful for aggregating a series of changing but not ending streams into one stream) + t2._transform = transform -exports = module.exports = through -through.through = through + if (flush) + t2._flush = flush -//create a readable writable stream. + return t2 +}) -function through (write, end, opts) { - write = write || function (data) { this.queue(data) } - end = end || function () { this.queue(null) } - var ended = false, destroyed = false, buffer = [], _ended = false - var stream = new Stream() - stream.readable = stream.writable = true - stream.paused = false +// make me a reusable prototype that I can `new`, or implicitly `new` +// with a constructor call +module.exports.ctor = through2(function (options, transform, flush) { + function Through2 (override) { + if (!(this instanceof Through2)) + return new Through2(override) -// stream.autoPause = !(opts && opts.autoPause === false) - stream.autoDestroy = !(opts && opts.autoDestroy === false) + this.options = xtend(options, override) - stream.write = function (data) { - write.call(this, data) - return !stream.paused + DestroyableTransform.call(this, this.options) } - function drain() { - while(buffer.length && !stream.paused) { - var data = buffer.shift() - if(null === data) - return stream.emit('end') - else - stream.emit('data', data) - } - } + inherits(Through2, DestroyableTransform) - stream.queue = stream.push = function (data) { -// console.error(ended) - if(_ended) return stream - if(data === null) _ended = true - buffer.push(data) - drain() - return stream - } + Through2.prototype._transform = transform - //this will be registered as the first 'end' listener - //must call destroy next tick, to make sure we're after any - //stream piped from here. - //this is only a problem if end is not emitted synchronously. - //a nicer way to do this is to make sure this is the last listener for 'end' + if (flush) + Through2.prototype._flush = flush - stream.on('end', function () { - stream.readable = false - if(!stream.writable && stream.autoDestroy) - process.nextTick(function () { - stream.destroy() - }) - }) + return Through2 +}) - function _end () { - stream.writable = false - end.call(stream) - if(!stream.readable && stream.autoDestroy) - stream.destroy() - } - stream.end = function (data) { - if(ended) return - ended = true - if(arguments.length) stream.write(data) - _end() // will emit or queue - return stream - } +module.exports.obj = through2(function (options, transform, flush) { + var t2 = new DestroyableTransform(xtend({ objectMode: true, highWaterMark: 16 }, options)) - stream.destroy = function () { - if(destroyed) return - destroyed = true - ended = true - buffer.length = 0 - stream.writable = stream.readable = false - stream.emit('close') - return stream - } + t2._transform = transform - stream.pause = function () { - if(stream.paused) return - stream.paused = true - return stream + if (flush) + t2._flush = flush + + return t2 +}) + +}).call(this,require('_process')) + +},{"_process":40,"readable-stream/transform":422,"util":428,"xtend":429}],425:[function(require,module,exports){ +(function (global){ + +/** + * Module exports. + */ + +module.exports = deprecate; + +/** + * Mark that a method should not be used. + * Returns a modified function which warns once by default. + * + * If `localStorage.noDeprecation = true` is set, then it is a no-op. + * + * If `localStorage.throwDeprecation = true` is set, then deprecated functions + * will throw an Error when invoked. + * + * If `localStorage.traceDeprecation = true` is set, then deprecated functions + * will invoke `console.trace()` instead of `console.error()`. + * + * @param {Function} fn - the function to deprecate + * @param {String} msg - the string to print to the console when `fn` is invoked + * @returns {Function} a new "deprecated" version of `fn` + * @api public + */ + +function deprecate (fn, msg) { + if (config('noDeprecation')) { + return fn; } - stream.resume = function () { - if(stream.paused) { - stream.paused = false - stream.emit('resume') + var warned = false; + function deprecated() { + if (!warned) { + if (config('throwDeprecation')) { + throw new Error(msg); + } else if (config('traceDeprecation')) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; } - drain() - //may have become paused again, - //as drain emits 'data'. - if(!stream.paused) - stream.emit('drain') - return stream + return fn.apply(this, arguments); } - return stream + + return deprecated; } +/** + * Checks `localStorage` for boolean values for the given `name`. + * + * @param {String} name + * @returns {Boolean} + * @api private + */ -}).call(this,require('_process')) +function config (name) { + // accessing global.localStorage can trigger a DOMException in sandboxed iframes + try { + if (!global.localStorage) return false; + } catch (_) { + return false; + } + var val = global.localStorage[name]; + if (null == val) return false; + return String(val).toLowerCase() === 'true'; +} -},{"_process":41,"stream":390}],424:[function(require,module,exports){ -var Buffer = require('buffer').Buffer - -module.exports = function (buf) { - // If the buffer is backed by a Uint8Array, a faster version will work - if (buf instanceof Uint8Array) { - // If the buffer isn't a subarray, return the underlying ArrayBuffer - if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) { - return buf.buffer - } else if (typeof buf.buffer.slice === 'function') { - // Otherwise we need to get a proper copy - return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength) - } - } +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - if (Buffer.isBuffer(buf)) { - // This is the slow version that will work with any Buffer - // implementation (even in old browsers) - var arrayCopy = new Uint8Array(buf.length) - var len = buf.length - for (var i = 0; i < len; i++) { - arrayCopy[i] = buf[i] - } - return arrayCopy.buffer - } else { - throw new Error('Argument must be a Buffer') - } +},{}],426:[function(require,module,exports){ +arguments[4][29][0].apply(exports,arguments) +},{"dup":29}],427:[function(require,module,exports){ +module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; } - -},{"buffer":7}],425:[function(require,module,exports){ +},{}],428:[function(require,module,exports){ +(function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -27028,809 +26848,575 @@ module.exports = function (buf) { // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -'use strict'; +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } -var punycode = require('punycode'); -var util = require('./util'); - -exports.parse = urlParse; -exports.resolve = urlResolve; -exports.resolveObject = urlResolveObject; -exports.format = urlFormat; - -exports.Url = Url; - -function Url() { - this.protocol = null; - this.slashes = null; - this.auth = null; - this.host = null; - this.port = null; - this.hostname = null; - this.hash = null; - this.search = null; - this.query = null; - this.pathname = null; - this.path = null; - this.href = null; -} - -// Reference: RFC 3986, RFC 1808, RFC 2396 - -// define these here so at least they only have to be -// compiled once on the first module load. -var protocolPattern = /^([a-z0-9.+-]+:)/i, - portPattern = /:[0-9]*$/, - - // Special case for a simple path URL - simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, - - // RFC 2396: characters reserved for delimiting URLs. - // We actually just auto-escape these. - delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], - - // RFC 2396: characters not allowed for various reasons. - unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), - - // Allowed by RFCs, but cause of XSS attacks. Always escape these. - autoEscape = ['\''].concat(unwise), - // Characters that are never ever allowed in a hostname. - // Note that any invalid chars are also handled, but these - // are the ones that are *expected* to be seen, so we fast-path - // them. - nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape), - hostEndingChars = ['/', '?', '#'], - hostnameMaxLen = 255, - hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, - hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, - // protocols that can allow "unsafe" and "unwise" chars. - unsafeProtocol = { - 'javascript': true, - 'javascript:': true - }, - // protocols that never have a hostname. - hostlessProtocol = { - 'javascript': true, - 'javascript:': true - }, - // protocols that always contain a // bit. - slashedProtocol = { - 'http': true, - 'https': true, - 'ftp': true, - 'gopher': true, - 'file': true, - 'http:': true, - 'https:': true, - 'ftp:': true, - 'gopher:': true, - 'file:': true - }, - querystring = require('querystring'); - -function urlParse(url, parseQueryString, slashesDenoteHost) { - if (url && util.isObject(url) && url instanceof Url) return url; - - var u = new Url; - u.parse(url, parseQueryString, slashesDenoteHost); - return u; -} - -Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { - if (!util.isString(url)) { - throw new TypeError("Parameter 'url' must be a string, not " + typeof url); - } - - // Copy chrome, IE, opera backslash-handling behavior. - // Back slashes before the query string get converted to forward slashes - // See: https://code.google.com/p/chromium/issues/detail?id=25916 - var queryIndex = url.indexOf('?'), - splitter = - (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#', - uSplit = url.split(splitter), - slashRegex = /\\/g; - uSplit[0] = uSplit[0].replace(slashRegex, '/'); - url = uSplit.join(splitter); - - var rest = url; - - // trim before proceeding. - // This is to support parse stuff like " http://foo.com \n" - rest = rest.trim(); - - if (!slashesDenoteHost && url.split('#').length === 1) { - // Try fast path regexp - var simplePath = simplePathPattern.exec(rest); - if (simplePath) { - this.path = rest; - this.href = rest; - this.pathname = simplePath[1]; - if (simplePath[2]) { - this.search = simplePath[2]; - if (parseQueryString) { - this.query = querystring.parse(this.search.substr(1)); - } else { - this.query = this.search.substr(1); + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; } - } else if (parseQueryString) { - this.search = ''; - this.query = {}; - } - return this; + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); } } + return str; +}; - var proto = protocolPattern.exec(rest); - if (proto) { - proto = proto[0]; - var lowerProto = proto.toLowerCase(); - this.protocol = lowerProto; - rest = rest.substr(proto.length); - } - // figure out if it's got a host - // user@server is *always* interpreted as a hostname, and url - // resolution will treat //foo/bar as host=foo,path=bar because that's - // how the browser resolves relative URLs. - if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { - var slashes = rest.substr(0, 2) === '//'; - if (slashes && !(proto && hostlessProtocol[proto])) { - rest = rest.substr(2); - this.slashes = true; - } +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global.process)) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; } - if (!hostlessProtocol[proto] && - (slashes || (proto && !slashedProtocol[proto]))) { + if (process.noDeprecation === true) { + return fn; + } - // there's a hostname. - // the first instance of /, ?, ;, or # ends the host. - // - // If there is an @ in the hostname, then non-host chars *are* allowed - // to the left of the last @ sign, unless some host-ending character - // comes *before* the @-sign. - // URLs are obnoxious. - // - // ex: - // http://a@b@c/ => user:a@b host:c - // http://a@b?@c => user:a host:c path:/?@c + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } - // v0.12 TODO(isaacs): This is not quite how Chrome does things. - // Review our test case against browsers more comprehensively. + return deprecated; +}; - // find the first instance of any hostEndingChars - var hostEnd = -1; - for (var i = 0; i < hostEndingChars.length; i++) { - var hec = rest.indexOf(hostEndingChars[i]); - if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) - hostEnd = hec; - } - // at this point, either we have an explicit point where the - // auth portion cannot go past, or the last @ char is the decider. - var auth, atSign; - if (hostEnd === -1) { - // atSign can be anywhere. - atSign = rest.lastIndexOf('@'); +var debugs = {}; +var debugEnviron; +exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; } else { - // atSign must be in auth portion. - // http://a@b/c@d => host:b auth:a path:/c@d - atSign = rest.lastIndexOf('@', hostEnd); - } - - // Now we have a portion which is definitely the auth. - // Pull that off. - if (atSign !== -1) { - auth = rest.slice(0, atSign); - rest = rest.slice(atSign + 1); - this.auth = decodeURIComponent(auth); - } - - // the host is the remaining to the left of the first non-host char - hostEnd = -1; - for (var i = 0; i < nonHostChars.length; i++) { - var hec = rest.indexOf(nonHostChars[i]); - if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) - hostEnd = hec; - } - // if we still have not hit it, then the entire thing is a host. - if (hostEnd === -1) - hostEnd = rest.length; - - this.host = rest.slice(0, hostEnd); - rest = rest.slice(hostEnd); - - // pull out port. - this.parseHost(); - - // we've indicated that there is a hostname, - // so even if it's empty, it has to be present. - this.hostname = this.hostname || ''; - - // if hostname begins with [ and ends with ] - // assume that it's an IPv6 address. - var ipv6Hostname = this.hostname[0] === '[' && - this.hostname[this.hostname.length - 1] === ']'; - - // validate a little. - if (!ipv6Hostname) { - var hostparts = this.hostname.split(/\./); - for (var i = 0, l = hostparts.length; i < l; i++) { - var part = hostparts[i]; - if (!part) continue; - if (!part.match(hostnamePartPattern)) { - var newpart = ''; - for (var j = 0, k = part.length; j < k; j++) { - if (part.charCodeAt(j) > 127) { - // we replace non-ASCII char with a temporary placeholder - // we need this to make sure size of hostname is not - // broken by replacing non-ASCII by nothing - newpart += 'x'; - } else { - newpart += part[j]; - } - } - // we test again with ASCII char only - if (!newpart.match(hostnamePartPattern)) { - var validParts = hostparts.slice(0, i); - var notHost = hostparts.slice(i + 1); - var bit = part.match(hostnamePartStart); - if (bit) { - validParts.push(bit[1]); - notHost.unshift(bit[2]); - } - if (notHost.length) { - rest = '/' + notHost.join('.') + rest; - } - this.hostname = validParts.join('.'); - break; - } - } - } + debugs[set] = function() {}; } + } + return debugs[set]; +}; - if (this.hostname.length > hostnameMaxLen) { - this.hostname = ''; - } else { - // hostnames are always lower case. - this.hostname = this.hostname.toLowerCase(); - } - if (!ipv6Hostname) { - // IDNA Support: Returns a punycoded representation of "domain". - // It only converts parts of the domain name that - // have non-ASCII characters, i.e. it doesn't matter if - // you call it with a domain that already is ASCII-only. - this.hostname = punycode.toASCII(this.hostname); - } +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; + + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; + + +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } +} - var p = this.port ? ':' + this.port : ''; - var h = this.hostname || ''; - this.host = h + p; - this.href += this.host; - // strip [ and ] from the hostname - // the host field still retains them, though - if (ipv6Hostname) { - this.hostname = this.hostname.substr(1, this.hostname.length - 2); - if (rest[0] !== '/') { - rest = '/' + rest; - } - } - } +function stylizeNoColor(str, styleType) { + return str; +} - // now rest is set to the post-host stuff. - // chop off any delim chars. - if (!unsafeProtocol[lowerProto]) { - // First, make 100% sure that any "autoEscape" chars get - // escaped, even if encodeURIComponent doesn't think they - // need to be. - for (var i = 0, l = autoEscape.length; i < l; i++) { - var ae = autoEscape[i]; - if (rest.indexOf(ae) === -1) - continue; - var esc = encodeURIComponent(ae); - if (esc === ae) { - esc = escape(ae); - } - rest = rest.split(ae).join(esc); - } - } +function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; +} - // chop off from the tail first. - var hash = rest.indexOf('#'); - if (hash !== -1) { - // got a fragment string. - this.hash = rest.substr(hash); - rest = rest.slice(0, hash); - } - var qm = rest.indexOf('?'); - if (qm !== -1) { - this.search = rest.substr(qm); - this.query = rest.substr(qm + 1); - if (parseQueryString) { - this.query = querystring.parse(this.query); +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); } - rest = rest.slice(0, qm); - } else if (parseQueryString) { - // no query string, but parseQueryString still requested - this.search = ''; - this.query = {}; - } - if (rest) this.pathname = rest; - if (slashedProtocol[lowerProto] && - this.hostname && !this.pathname) { - this.pathname = '/'; + return ret; } - //to support http.request - if (this.pathname || this.search) { - var p = this.pathname || ''; - var s = this.search || ''; - this.path = p + s; + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; } - // finally, reconstruct the href based on what has been validated. - this.href = this.format(); - return this; -}; - -// format a parsed object into a url string -function urlFormat(obj) { - // ensure it's an object, and not a string url. - // If it's an obj, this is a no-op. - // this way, you can call url_format() on strings - // to clean up potentially wonky urls. - if (util.isString(obj)) obj = urlParse(obj); - if (!(obj instanceof Url)) return Url.prototype.format.call(obj); - return obj.format(); -} + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); -Url.prototype.format = function() { - var auth = this.auth || ''; - if (auth) { - auth = encodeURIComponent(auth); - auth = auth.replace(/%3A/i, ':'); - auth += '@'; + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); } - var protocol = this.protocol || '', - pathname = this.pathname || '', - hash = this.hash || '', - host = false, - query = ''; + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } - if (this.host) { - host = auth + this.host; - } else if (this.hostname) { - host = auth + (this.hostname.indexOf(':') === -1 ? - this.hostname : - '[' + this.hostname + ']'); - if (this.port) { - host += ':' + this.port; + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); } } - if (this.query && - util.isObject(this.query) && - Object.keys(this.query).length) { - query = querystring.stringify(this.query); + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; } - var search = this.search || (query && ('?' + query)) || ''; + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } - if (protocol && protocol.substr(-1) !== ':') protocol += ':'; + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } - // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. - // unless they had them to begin with. - if (this.slashes || - (!protocol || slashedProtocol[protocol]) && host !== false) { - host = '//' + (host || ''); - if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname; - } else if (!host) { - host = ''; + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); } - if (hash && hash.charAt(0) !== '#') hash = '#' + hash; - if (search && search.charAt(0) !== '?') search = '?' + search; + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } - pathname = pathname.replace(/[?#]/g, function(match) { - return encodeURIComponent(match); - }); - search = search.replace('#', '%23'); + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } - return protocol + host + pathname + search + hash; -}; + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } -function urlResolve(source, relative) { - return urlParse(source, false, true).resolve(relative); -} + ctx.seen.push(value); -Url.prototype.resolve = function(relative) { - return this.resolveObject(urlParse(relative, false, true)).format(); -}; + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } -function urlResolveObject(source, relative) { - if (!source) return relative; - return urlParse(source, false, true).resolveObject(relative); + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); } -Url.prototype.resolveObject = function(relative) { - if (util.isString(relative)) { - var rel = new Url(); - rel.parse(relative, false, true); - relative = rel; - } - var result = new Url(); - var tkeys = Object.keys(this); - for (var tk = 0; tk < tkeys.length; tk++) { - var tkey = tkeys[tk]; - result[tkey] = this[tkey]; +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} - // hash is always overridden, no matter what. - // even href="" will remove it. - result.hash = relative.hash; - // if the relative url is empty, then there's nothing left to do here. - if (relative.href === '') { - result.href = result.format(); - return result; - } +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} - // hrefs like //foo/bar always cut to the protocol. - if (relative.slashes && !relative.protocol) { - // take everything except the protocol from relative - var rkeys = Object.keys(relative); - for (var rk = 0; rk < rkeys.length; rk++) { - var rkey = rkeys[rk]; - if (rkey !== 'protocol') - result[rkey] = relative[rkey]; - } - //urlParse appends trailing / to urls like http://www.example.com - if (slashedProtocol[result.protocol] && - result.hostname && !result.pathname) { - result.path = result.pathname = '/'; +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); } - - result.href = result.format(); - return result; } - - if (relative.protocol && relative.protocol !== result.protocol) { - // if it's a known url protocol, then changing - // the protocol does weird things - // first, if it's not file:, then we MUST have a host, - // and if there was a path - // to begin with, then we MUST have a path. - // if it is file:, then the host is dropped, - // because that's known to be hostless. - // anything else is assumed to be absolute. - if (!slashedProtocol[relative.protocol]) { - var keys = Object.keys(relative); - for (var v = 0; v < keys.length; v++) { - var k = keys[v]; - result[k] = relative[k]; - } - result.href = result.format(); - return result; + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); } + }); + return output; +} - result.protocol = relative.protocol; - if (!relative.host && !hostlessProtocol[relative.protocol]) { - var relPath = (relative.pathname || '').split('/'); - while (relPath.length && !(relative.host = relPath.shift())); - if (!relative.host) relative.host = ''; - if (!relative.hostname) relative.hostname = ''; - if (relPath[0] !== '') relPath.unshift(''); - if (relPath.length < 2) relPath.unshift(''); - result.pathname = relPath.join('/'); + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); } else { - result.pathname = relative.pathname; - } - result.search = relative.search; - result.query = relative.query; - result.host = relative.host || ''; - result.auth = relative.auth; - result.hostname = relative.hostname || relative.host; - result.port = relative.port; - // to support http.request - if (result.pathname || result.search) { - var p = result.pathname || ''; - var s = result.search || ''; - result.path = p + s; - } - result.slashes = result.slashes || relative.slashes; - result.href = result.format(); - return result; + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } } - - var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), - isRelAbs = ( - relative.host || - relative.pathname && relative.pathname.charAt(0) === '/' - ), - mustEndAbs = (isRelAbs || isSourceAbs || - (result.host && relative.pathname)), - removeAllDots = mustEndAbs, - srcPath = result.pathname && result.pathname.split('/') || [], - relPath = relative.pathname && relative.pathname.split('/') || [], - psychotic = result.protocol && !slashedProtocol[result.protocol]; - - // if the url is a non-slashed url, then relative - // links like ../.. should be able - // to crawl up to the hostname, as well. This is strange. - // result.protocol has already been set by now. - // Later on, put the first path part into the host field. - if (psychotic) { - result.hostname = ''; - result.port = null; - if (result.host) { - if (srcPath[0] === '') srcPath[0] = result.host; - else srcPath.unshift(result.host); - } - result.host = ''; - if (relative.protocol) { - relative.hostname = null; - relative.port = null; - if (relative.host) { - if (relPath[0] === '') relPath[0] = relative.host; - else relPath.unshift(relative.host); - } - relative.host = null; - } - mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); - } - - if (isRelAbs) { - // it's absolute. - result.host = (relative.host || relative.host === '') ? - relative.host : result.host; - result.hostname = (relative.hostname || relative.hostname === '') ? - relative.hostname : result.hostname; - result.search = relative.search; - result.query = relative.query; - srcPath = relPath; - // fall through to the dot-handling below. - } else if (relPath.length) { - // it's relative - // throw away the existing file, and take the new path instead. - if (!srcPath) srcPath = []; - srcPath.pop(); - srcPath = srcPath.concat(relPath); - result.search = relative.search; - result.query = relative.query; - } else if (!util.isNullOrUndefined(relative.search)) { - // just pull out the search. - // like href='?foo'. - // Put this after the other two cases because it simplifies the booleans - if (psychotic) { - result.hostname = result.host = srcPath.shift(); - //occationaly the auth can get stuck only in host - //this especially happens in cases like - //url.resolveObject('mailto:local1@domain1', 'local2@domain2') - var authInHost = result.host && result.host.indexOf('@') > 0 ? - result.host.split('@') : false; - if (authInHost) { - result.auth = authInHost.shift(); - result.host = result.hostname = authInHost.shift(); - } - } - result.search = relative.search; - result.query = relative.query; - //to support http.request - if (!util.isNull(result.pathname) || !util.isNull(result.search)) { - result.path = (result.pathname ? result.pathname : '') + - (result.search ? result.search : ''); - } - result.href = result.format(); - return result; + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; } - - if (!srcPath.length) { - // no path at all. easy. - // we've already handled the other stuff above. - result.pathname = null; - //to support http.request - if (result.search) { - result.path = '/' + result.search; + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } } else { - result.path = null; + str = ctx.stylize('[Circular]', 'special'); } - result.href = result.format(); - return result; } - - // if a url ENDs in . or .., then it must get a trailing slash. - // however, if it ends in anything else non-slashy, - // then it must NOT get a trailing slash. - var last = srcPath.slice(-1)[0]; - var hasTrailingSlash = ( - (result.host || relative.host || srcPath.length > 1) && - (last === '.' || last === '..') || last === ''); - - // strip single dots, resolve double dots to parent dir - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = srcPath.length; i >= 0; i--) { - last = srcPath[i]; - if (last === '.') { - srcPath.splice(i, 1); - } else if (last === '..') { - srcPath.splice(i, 1); - up++; - } else if (up) { - srcPath.splice(i, 1); - up--; + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; } - } - - // if the path is allowed to go above the root, restore leading ..s - if (!mustEndAbs && !removeAllDots) { - for (; up--; up) { - srcPath.unshift('..'); + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); } } - if (mustEndAbs && srcPath[0] !== '' && - (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { - srcPath.unshift(''); - } + return name + ': ' + str; +} - if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { - srcPath.push(''); - } - var isAbsolute = srcPath[0] === '' || - (srcPath[0] && srcPath[0].charAt(0) === '/'); +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); - // put the host back - if (psychotic) { - result.hostname = result.host = isAbsolute ? '' : - srcPath.length ? srcPath.shift() : ''; - //occationaly the auth can get stuck only in host - //this especially happens in cases like - //url.resolveObject('mailto:local1@domain1', 'local2@domain2') - var authInHost = result.host && result.host.indexOf('@') > 0 ? - result.host.split('@') : false; - if (authInHost) { - result.auth = authInHost.shift(); - result.host = result.hostname = authInHost.shift(); - } + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; } - mustEndAbs = mustEndAbs || (result.host && srcPath.length); + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} - if (mustEndAbs && !isAbsolute) { - srcPath.unshift(''); - } - if (!srcPath.length) { - result.pathname = null; - result.path = null; - } else { - result.pathname = srcPath.join('/'); - } +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; - //to support request.http - if (!util.isNull(result.pathname) || !util.isNull(result.search)) { - result.path = (result.pathname ? result.pathname : '') + - (result.search ? result.search : ''); - } - result.auth = relative.auth || result.auth; - result.slashes = result.slashes || relative.slashes; - result.href = result.format(); - return result; -}; +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; -Url.prototype.parseHost = function() { - var host = this.host; - var port = portPattern.exec(host); - if (port) { - port = port[0]; - if (port !== ':') { - this.port = port.substr(1); - } - host = host.substr(0, host.length - port.length); - } - if (host) this.hostname = host; -}; +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; -},{"./util":426,"punycode":42,"querystring":45}],426:[function(require,module,exports){ -'use strict'; +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; -module.exports = { - isString: function(arg) { - return typeof(arg) === 'string'; - }, - isObject: function(arg) { - return typeof(arg) === 'object' && arg !== null; - }, - isNull: function(arg) { - return arg === null; - }, - isNullOrUndefined: function(arg) { - return arg == null; - } -}; +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; -},{}],427:[function(require,module,exports){ -(function (global){ +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; -/** - * Module exports. - */ +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; -module.exports = deprecate; +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; -/** - * Mark that a method should not be used. - * Returns a modified function which warns once by default. - * - * If `localStorage.noDeprecation = true` is set, then it is a no-op. - * - * If `localStorage.throwDeprecation = true` is set, then deprecated functions - * will throw an Error when invoked. - * - * If `localStorage.traceDeprecation = true` is set, then deprecated functions - * will invoke `console.trace()` instead of `console.error()`. - * - * @param {Function} fn - the function to deprecate - * @param {String} msg - the string to print to the console when `fn` is invoked - * @returns {Function} a new "deprecated" version of `fn` - * @api public - */ +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; -function deprecate (fn, msg) { - if (config('noDeprecation')) { - return fn; - } +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; - var warned = false; - function deprecated() { - if (!warned) { - if (config('throwDeprecation')) { - throw new Error(msg); - } else if (config('traceDeprecation')) { - console.trace(msg); - } else { - console.warn(msg); - } - warned = true; - } - return fn.apply(this, arguments); - } +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; - return deprecated; +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = require('./support/isBuffer'); + +function objectToString(o) { + return Object.prototype.toString.call(o); } + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + /** - * Checks `localStorage` for boolean values for the given `name`. + * Inherit the prototype methods from one constructor into another. * - * @param {String} name - * @returns {Boolean} - * @api private + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. */ +exports.inherits = require('inherits'); -function config (name) { - // accessing global.localStorage can trigger a DOMException in sandboxed iframes - try { - if (!global.localStorage) return false; - } catch (_) { - return false; +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; } - var val = global.localStorage[name]; - if (null == val) return false; - return String(val).toLowerCase() === 'true'; + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); } -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],428:[function(require,module,exports){ +},{"./support/isBuffer":427,"_process":40,"inherits":426}],429:[function(require,module,exports){ module.exports = extend var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -27851,7 +27437,75 @@ function extend() { return target } -},{}],"lodash":[function(require,module,exports){ +},{}],"can-ndjson-stream":[function(require,module,exports){ +/*exported ndjsonStream*/ + +var namespace = require('can-namespace'); + +var ndjsonStream = function(response) { + // For cancellation + var is_reader, cancellationRequest = false; + return new ReadableStream({ + start: function(controller) { + var reader = response.getReader(); + is_reader = reader; + var decoder = new TextDecoder(); + var data_buf = ""; + + reader.read().then(function processResult(result) { + if (result.done) { + if (cancellationRequest) { + // Immediately exit + return; + } + + data_buf = data_buf.trim(); + if (data_buf.length !== 0) { + try { + var data_l = JSON.parse(data_buf); + controller.enqueue(data_l); + } catch(e) { + controller.error(e); + return; + } + } + controller.close(); + return; + } + + var data = decoder.decode(result.value, {stream: true}); + data_buf += data; + var lines = data_buf.split("\n"); + for(var i = 0; i < lines.length - 1; ++i) { + var l = lines[i].trim(); + if (l.length > 0) { + try { + var data_line = JSON.parse(l); + controller.enqueue(data_line); + } catch(e) { + controller.error(e); + cancellationRequest = true; + reader.cancel(); + return; + } + } + } + data_buf = lines[lines.length-1]; + + return reader.read().then(processResult); + }); + + }, + cancel: function(reason) { + console.log("Cancel registered due to ", reason); + cancellationRequest = true; + is_reader.cancel(); + } + }); +}; + +module.exports = namespace.ndjsonStream = ndjsonStream; +},{"can-namespace":8}],"lodash":[function(require,module,exports){ (function (global){ /** * @license @@ -44940,2591 +44594,40 @@ function extend() { }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],"oboe":[function(require,module,exports){ -// this file is the concatenation of several js files. See http://github.com/jimhigson/oboe.js -// for the unconcatenated source +},{}],"ndjson":[function(require,module,exports){ +var through = require('through2') +var split = require('split2') +var EOL = require('os').EOL +var stringify = require('json-stringify-safe') -module.exports = (function () { - - // v2.1.3 +module.exports = parse +module.exports.serialize = module.exports.stringify = serialize +module.exports.parse = parse -/* - -Copyright (c) 2013, Jim Higson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +function parse (opts) { + opts = opts || {} + opts.strict = opts.strict !== false -*/ - -/** - * Partially complete a function. - * - * var add3 = partialComplete( function add(a,b){return a+b}, 3 ); - * - * add3(4) // gives 7 - * - * function wrap(left, right, cen){return left + " " + cen + " " + right;} - * - * var pirateGreeting = partialComplete( wrap , "I'm", ", a mighty pirate!" ); - * - * pirateGreeting("Guybrush Threepwood"); - * // gives "I'm Guybrush Threepwood, a mighty pirate!" - */ -var partialComplete = varArgs(function( fn, args ) { - - // this isn't the shortest way to write this but it does - // avoid creating a new array each time to pass to fn.apply, - // otherwise could just call boundArgs.concat(callArgs) - - var numBoundArgs = args.length; - - return varArgs(function( callArgs ) { - - for (var i = 0; i < callArgs.length; i++) { - args[numBoundArgs + i] = callArgs[i]; - } - - args.length = numBoundArgs + callArgs.length; - - return fn.apply(this, args); - }); - }), - -/** - * Compose zero or more functions: - * - * compose(f1, f2, f3)(x) = f1(f2(f3(x)))) - * - * The last (inner-most) function may take more than one parameter: - * - * compose(f1, f2, f3)(x,y) = f1(f2(f3(x,y)))) - */ - compose = varArgs(function(fns) { - - var fnsList = arrayAsList(fns); - - function next(params, curFn) { - return [apply(params, curFn)]; - } - - return varArgs(function(startParams){ - - return foldR(next, startParams, fnsList)[0]; - }); - }); - -/** - * A more optimised version of compose that takes exactly two functions - * @param f1 - * @param f2 - */ -function compose2(f1, f2){ - return function(){ - return f1.call(this,f2.apply(this,arguments)); - } -} - -/** - * Generic form for a function to get a property from an object - * - * var o = { - * foo:'bar' - * } - * - * var getFoo = attr('foo') - * - * fetFoo(o) // returns 'bar' - * - * @param {String} key the property name - */ -function attr(key) { - return function(o) { return o[key]; }; -} - -/** - * Call a list of functions with the same args until one returns a - * truthy result. Similar to the || operator. - * - * So: - * lazyUnion([f1,f2,f3 ... fn])( p1, p2 ... pn ) - * - * Is equivalent to: - * apply([p1, p2 ... pn], f1) || - * apply([p1, p2 ... pn], f2) || - * apply([p1, p2 ... pn], f3) ... apply(fn, [p1, p2 ... pn]) - * - * @returns the first return value that is given that is truthy. - */ - var lazyUnion = varArgs(function(fns) { - - return varArgs(function(params){ - - var maybeValue; - - for (var i = 0; i < len(fns); i++) { - - maybeValue = apply(params, fns[i]); - - if( maybeValue ) { - return maybeValue; - } - } - }); - }); - -/** - * This file declares various pieces of functional programming. - * - * This isn't a general purpose functional library, to keep things small it - * has just the parts useful for Oboe.js. - */ - - -/** - * Call a single function with the given arguments array. - * Basically, a functional-style version of the OO-style Function#apply for - * when we don't care about the context ('this') of the call. - * - * The order of arguments allows partial completion of the arguments array - */ -function apply(args, fn) { - return fn.apply(undefined, args); -} - -/** - * Define variable argument functions but cut out all that tedious messing about - * with the arguments object. Delivers the variable-length part of the arguments - * list as an array. - * - * Eg: - * - * var myFunction = varArgs( - * function( fixedArgument, otherFixedArgument, variableNumberOfArguments ){ - * console.log( variableNumberOfArguments ); - * } - * ) - * - * myFunction('a', 'b', 1, 2, 3); // logs [1,2,3] - * - * var myOtherFunction = varArgs(function( variableNumberOfArguments ){ - * console.log( variableNumberOfArguments ); - * }) - * - * myFunction(1, 2, 3); // logs [1,2,3] - * - */ -function varArgs(fn){ - - var numberOfFixedArguments = fn.length -1, - slice = Array.prototype.slice; - - - if( numberOfFixedArguments == 0 ) { - // an optimised case for when there are no fixed args: - - return function(){ - return fn.call(this, slice.call(arguments)); - } - - } else if( numberOfFixedArguments == 1 ) { - // an optimised case for when there are is one fixed args: - - return function(){ - return fn.call(this, arguments[0], slice.call(arguments, 1)); - } - } - - // general case - - // we know how many arguments fn will always take. Create a - // fixed-size array to hold that many, to be re-used on - // every call to the returned function - var argsHolder = Array(fn.length); - - return function(){ - - for (var i = 0; i < numberOfFixedArguments; i++) { - argsHolder[i] = arguments[i]; - } - - argsHolder[numberOfFixedArguments] = - slice.call(arguments, numberOfFixedArguments); - - return fn.apply( this, argsHolder); - } -} - - -/** - * Swap the order of parameters to a binary function - * - * A bit like this flip: http://zvon.org/other/haskell/Outputprelude/flip_f.html - */ -function flip(fn){ - return function(a, b){ - return fn(b,a); - } -} - - -/** - * Create a function which is the intersection of two other functions. - * - * Like the && operator, if the first is truthy, the second is never called, - * otherwise the return value from the second is returned. - */ -function lazyIntersection(fn1, fn2) { - - return function (param) { - - return fn1(param) && fn2(param); - }; -} - -/** - * A function which does nothing - */ -function noop(){} - -/** - * A function which is always happy - */ -function always(){return true} - -/** - * Create a function which always returns the same - * value - * - * var return3 = functor(3); - * - * return3() // gives 3 - * return3() // still gives 3 - * return3() // will always give 3 - */ -function functor(val){ - return function(){ - return val; - } -} - -/** - * This file defines some loosely associated syntactic sugar for - * Javascript programming - */ - - -/** - * Returns true if the given candidate is of type T - */ -function isOfType(T, maybeSomething){ - return maybeSomething && maybeSomething.constructor === T; -} - -var len = attr('length'), - isString = partialComplete(isOfType, String); - -/** - * I don't like saying this: - * - * foo !=== undefined - * - * because of the double-negative. I find this: - * - * defined(foo) - * - * easier to read. - */ -function defined( value ) { - return value !== undefined; -} - -/** - * Returns true if object o has a key named like every property in - * the properties array. Will give false if any are missing, or if o - * is not an object. - */ -function hasAllProperties(fieldList, o) { - - return (o instanceof Object) - && - all(function (field) { - return (field in o); - }, fieldList); -} -/** - * Like cons in Lisp - */ -function cons(x, xs) { - - /* Internally lists are linked 2-element Javascript arrays. - - Ideally the return here would be Object.freeze([x,xs]) - so that bugs related to mutation are found fast. - However, cons is right on the critical path for - performance and this slows oboe-mark down by - ~25%. Under theoretical future JS engines that freeze more - efficiently (possibly even use immutability to - run faster) this should be considered for - restoration. - */ - - return [x,xs]; -} - -/** - * The empty list - */ -var emptyList = null, - -/** - * Get the head of a list. - * - * Ie, head(cons(a,b)) = a - */ - head = attr(0), - -/** - * Get the tail of a list. - * - * Ie, tail(cons(a,b)) = b - */ - tail = attr(1); - - -/** - * Converts an array to a list - * - * asList([a,b,c]) - * - * is equivalent to: - * - * cons(a, cons(b, cons(c, emptyList))) - **/ -function arrayAsList(inputArray){ - - return reverseList( - inputArray.reduce( - flip(cons), - emptyList - ) - ); -} - -/** - * A varargs version of arrayAsList. Works a bit like list - * in LISP. - * - * list(a,b,c) - * - * is equivalent to: - * - * cons(a, cons(b, cons(c, emptyList))) - */ -var list = varArgs(arrayAsList); - -/** - * Convert a list back to a js native array - */ -function listAsArray(list){ - - return foldR( function(arraySoFar, listItem){ - - arraySoFar.unshift(listItem); - return arraySoFar; - - }, [], list ); - -} - -/** - * Map a function over a list - */ -function map(fn, list) { - - return list - ? cons(fn(head(list)), map(fn,tail(list))) - : emptyList - ; -} - -/** - * foldR implementation. Reduce a list down to a single value. - * - * @pram {Function} fn (rightEval, curVal) -> result - */ -function foldR(fn, startValue, list) { - - return list - ? fn(foldR(fn, startValue, tail(list)), head(list)) - : startValue - ; -} - -/** - * foldR implementation. Reduce a list down to a single value. - * - * @pram {Function} fn (rightEval, curVal) -> result - */ -function foldR1(fn, list) { - - return tail(list) - ? fn(foldR1(fn, tail(list)), head(list)) - : head(list) - ; -} - - -/** - * Return a list like the one given but with the first instance equal - * to item removed - */ -function without(list, test, removedFn) { - - return withoutInner(list, removedFn || noop); - - function withoutInner(subList, removedFn) { - return subList - ? ( test(head(subList)) - ? (removedFn(head(subList)), tail(subList)) - : cons(head(subList), withoutInner(tail(subList), removedFn)) - ) - : emptyList - ; - } -} - -/** - * Returns true if the given function holds for every item in - * the list, false otherwise - */ -function all(fn, list) { - - return !list || - ( fn(head(list)) && all(fn, tail(list)) ); -} - -/** - * Call every function in a list of functions with the same arguments - * - * This doesn't make any sense if we're doing pure functional because - * it doesn't return anything. Hence, this is only really useful if the - * functions being called have side-effects. - */ -function applyEach(fnList, args) { - - if( fnList ) { - head(fnList).apply(null, args); - - applyEach(tail(fnList), args); - } -} - -/** - * Reverse the order of a list - */ -function reverseList(list){ - - // js re-implementation of 3rd solution from: - // http://www.haskell.org/haskellwiki/99_questions/Solutions/5 - function reverseInner( list, reversedAlready ) { - if( !list ) { - return reversedAlready; + function parseRow (row) { + try { + if (row) return JSON.parse(row) + } catch (e) { + if (opts.strict) { + this.emit('error', new Error('Could not parse row ' + row.slice(0, 50) + '...')) } - - return reverseInner(tail(list), cons(head(list), reversedAlready)) - } - - return reverseInner(list, emptyList); -} - -function first(test, list) { - return list && - (test(head(list)) - ? head(list) - : first(test,tail(list))); -} - -/* - This is a slightly hacked-up browser only version of clarinet - - * some features removed to help keep browser Oboe under - the 5k micro-library limit - * plug directly into event bus - - For the original go here: - https://github.com/dscape/clarinet - - We receive the events: - STREAM_DATA - STREAM_END - - We emit the events: - SAX_KEY - SAX_VALUE_OPEN - SAX_VALUE_CLOSE - FAIL_EVENT - */ - -function clarinet(eventBus) { - "use strict"; - - var - // shortcut some events on the bus - emitSaxKey = eventBus(SAX_KEY).emit, - emitValueOpen = eventBus(SAX_VALUE_OPEN).emit, - emitValueClose = eventBus(SAX_VALUE_CLOSE).emit, - emitFail = eventBus(FAIL_EVENT).emit, - - MAX_BUFFER_LENGTH = 64 * 1024 - , stringTokenPattern = /[\\"\n]/g - , _n = 0 - - // states - , BEGIN = _n++ - , VALUE = _n++ // general stuff - , OPEN_OBJECT = _n++ // { - , CLOSE_OBJECT = _n++ // } - , OPEN_ARRAY = _n++ // [ - , CLOSE_ARRAY = _n++ // ] - , STRING = _n++ // "" - , OPEN_KEY = _n++ // , "a" - , CLOSE_KEY = _n++ // : - , TRUE = _n++ // r - , TRUE2 = _n++ // u - , TRUE3 = _n++ // e - , FALSE = _n++ // a - , FALSE2 = _n++ // l - , FALSE3 = _n++ // s - , FALSE4 = _n++ // e - , NULL = _n++ // u - , NULL2 = _n++ // l - , NULL3 = _n++ // l - , NUMBER_DECIMAL_POINT = _n++ // . - , NUMBER_DIGIT = _n // [0-9] - - // setup initial parser values - , bufferCheckPosition = MAX_BUFFER_LENGTH - , latestError - , c - , p - , textNode = undefined - , numberNode = "" - , slashed = false - , closed = false - , state = BEGIN - , stack = [] - , unicodeS = null - , unicodeI = 0 - , depth = 0 - , position = 0 - , column = 0 //mostly for error reporting - , line = 1 - ; - - function checkBufferLength () { - - var maxActual = 0; - - if (textNode !== undefined && textNode.length > MAX_BUFFER_LENGTH) { - emitError("Max buffer length exceeded: textNode"); - maxActual = Math.max(maxActual, textNode.length); - } - if (numberNode.length > MAX_BUFFER_LENGTH) { - emitError("Max buffer length exceeded: numberNode"); - maxActual = Math.max(maxActual, numberNode.length); - } - - bufferCheckPosition = (MAX_BUFFER_LENGTH - maxActual) - + position; - } - - eventBus(STREAM_DATA).on(handleData); - - /* At the end of the http content close the clarinet - This will provide an error if the total content provided was not - valid json, ie if not all arrays, objects and Strings closed properly */ - eventBus(STREAM_END).on(handleStreamEnd); - - function emitError (errorString) { - if (textNode !== undefined) { - emitValueOpen(textNode); - emitValueClose(); - textNode = undefined; - } - - latestError = Error(errorString + "\nLn: "+line+ - "\nCol: "+column+ - "\nChr: "+c); - - emitFail(errorReport(undefined, undefined, latestError)); - } - - function handleStreamEnd() { - if( state == BEGIN ) { - // Handle the case where the stream closes without ever receiving - // any input. This isn't an error - response bodies can be blank, - // particularly for 204 http responses - - // Because of how Oboe is currently implemented, we parse a - // completely empty stream as containing an empty object. - // This is because Oboe's done event is only fired when the - // root object of the JSON stream closes. - - // This should be decoupled and attached instead to the input stream - // from the http (or whatever) resource ending. - // If this decoupling could happen the SAX parser could simply emit - // zero events on a completely empty input. - emitValueOpen({}); - emitValueClose(); - - closed = true; - return; - } - - if (state !== VALUE || depth !== 0) - emitError("Unexpected end"); - - if (textNode !== undefined) { - emitValueOpen(textNode); - emitValueClose(); - textNode = undefined; - } - - closed = true; - } - - function whitespace(c){ - return c == '\r' || c == '\n' || c == ' ' || c == '\t'; - } - - function handleData (chunk) { - - // this used to throw the error but inside Oboe we will have already - // gotten the error when it was emitted. The important thing is to - // not continue with the parse. - if (latestError) - return; - - if (closed) { - return emitError("Cannot write after close"); } + } - var i = 0; - c = chunk[0]; - - while (c) { - p = c; - c = chunk[i++]; - if(!c) break; - - position ++; - if (c == "\n") { - line ++; - column = 0; - } else column ++; - switch (state) { - - case BEGIN: - if (c === "{") state = OPEN_OBJECT; - else if (c === "[") state = OPEN_ARRAY; - else if (!whitespace(c)) - return emitError("Non-whitespace before {[."); - continue; - - case OPEN_KEY: - case OPEN_OBJECT: - if (whitespace(c)) continue; - if(state === OPEN_KEY) stack.push(CLOSE_KEY); - else { - if(c === '}') { - emitValueOpen({}); - emitValueClose(); - state = stack.pop() || VALUE; - continue; - } else stack.push(CLOSE_OBJECT); - } - if(c === '"') - state = STRING; - else - return emitError("Malformed object key should start with \" "); - continue; - - case CLOSE_KEY: - case CLOSE_OBJECT: - if (whitespace(c)) continue; - - if(c===':') { - if(state === CLOSE_OBJECT) { - stack.push(CLOSE_OBJECT); - - if (textNode !== undefined) { - // was previously (in upstream Clarinet) one event - // - object open came with the text of the first - emitValueOpen({}); - emitSaxKey(textNode); - textNode = undefined; - } - depth++; - } else { - if (textNode !== undefined) { - emitSaxKey(textNode); - textNode = undefined; - } - } - state = VALUE; - } else if (c==='}') { - if (textNode !== undefined) { - emitValueOpen(textNode); - emitValueClose(); - textNode = undefined; - } - emitValueClose(); - depth--; - state = stack.pop() || VALUE; - } else if(c===',') { - if(state === CLOSE_OBJECT) - stack.push(CLOSE_OBJECT); - if (textNode !== undefined) { - emitValueOpen(textNode); - emitValueClose(); - textNode = undefined; - } - state = OPEN_KEY; - } else - return emitError('Bad object'); - continue; - - case OPEN_ARRAY: // after an array there always a value - case VALUE: - if (whitespace(c)) continue; - if(state===OPEN_ARRAY) { - emitValueOpen([]); - depth++; - state = VALUE; - if(c === ']') { - emitValueClose(); - depth--; - state = stack.pop() || VALUE; - continue; - } else { - stack.push(CLOSE_ARRAY); - } - } - if(c === '"') state = STRING; - else if(c === '{') state = OPEN_OBJECT; - else if(c === '[') state = OPEN_ARRAY; - else if(c === 't') state = TRUE; - else if(c === 'f') state = FALSE; - else if(c === 'n') state = NULL; - else if(c === '-') { // keep and continue - numberNode += c; - } else if(c==='0') { - numberNode += c; - state = NUMBER_DIGIT; - } else if('123456789'.indexOf(c) !== -1) { - numberNode += c; - state = NUMBER_DIGIT; - } else - return emitError("Bad value"); - continue; - - case CLOSE_ARRAY: - if(c===',') { - stack.push(CLOSE_ARRAY); - if (textNode !== undefined) { - emitValueOpen(textNode); - emitValueClose(); - textNode = undefined; - } - state = VALUE; - } else if (c===']') { - if (textNode !== undefined) { - emitValueOpen(textNode); - emitValueClose(); - textNode = undefined; - } - emitValueClose(); - depth--; - state = stack.pop() || VALUE; - } else if (whitespace(c)) - continue; - else - return emitError('Bad array'); - continue; - - case STRING: - if (textNode === undefined) { - textNode = ""; - } - - // thanks thejh, this is an about 50% performance improvement. - var starti = i-1; - - STRING_BIGLOOP: while (true) { - - // zero means "no unicode active". 1-4 mean "parse some more". end after 4. - while (unicodeI > 0) { - unicodeS += c; - c = chunk.charAt(i++); - if (unicodeI === 4) { - // TODO this might be slow? well, probably not used too often anyway - textNode += String.fromCharCode(parseInt(unicodeS, 16)); - unicodeI = 0; - starti = i-1; - } else { - unicodeI++; - } - // we can just break here: no stuff we skipped that still has to be sliced out or so - if (!c) break STRING_BIGLOOP; - } - if (c === '"' && !slashed) { - state = stack.pop() || VALUE; - textNode += chunk.substring(starti, i-1); - break; - } - if (c === '\\' && !slashed) { - slashed = true; - textNode += chunk.substring(starti, i-1); - c = chunk.charAt(i++); - if (!c) break; - } - if (slashed) { - slashed = false; - if (c === 'n') { textNode += '\n'; } - else if (c === 'r') { textNode += '\r'; } - else if (c === 't') { textNode += '\t'; } - else if (c === 'f') { textNode += '\f'; } - else if (c === 'b') { textNode += '\b'; } - else if (c === 'u') { - // \uxxxx. meh! - unicodeI = 1; - unicodeS = ''; - } else { - textNode += c; - } - c = chunk.charAt(i++); - starti = i-1; - if (!c) break; - else continue; - } - - stringTokenPattern.lastIndex = i; - var reResult = stringTokenPattern.exec(chunk); - if (!reResult) { - i = chunk.length+1; - textNode += chunk.substring(starti, i-1); - break; - } - i = reResult.index+1; - c = chunk.charAt(reResult.index); - if (!c) { - textNode += chunk.substring(starti, i-1); - break; - } - } - continue; - - case TRUE: - if (!c) continue; // strange buffers - if (c==='r') state = TRUE2; - else - return emitError( 'Invalid true started with t'+ c); - continue; - - case TRUE2: - if (!c) continue; - if (c==='u') state = TRUE3; - else - return emitError('Invalid true started with tr'+ c); - continue; - - case TRUE3: - if (!c) continue; - if(c==='e') { - emitValueOpen(true); - emitValueClose(); - state = stack.pop() || VALUE; - } else - return emitError('Invalid true started with tru'+ c); - continue; - - case FALSE: - if (!c) continue; - if (c==='a') state = FALSE2; - else - return emitError('Invalid false started with f'+ c); - continue; - - case FALSE2: - if (!c) continue; - if (c==='l') state = FALSE3; - else - return emitError('Invalid false started with fa'+ c); - continue; - - case FALSE3: - if (!c) continue; - if (c==='s') state = FALSE4; - else - return emitError('Invalid false started with fal'+ c); - continue; - - case FALSE4: - if (!c) continue; - if (c==='e') { - emitValueOpen(false); - emitValueClose(); - state = stack.pop() || VALUE; - } else - return emitError('Invalid false started with fals'+ c); - continue; - - case NULL: - if (!c) continue; - if (c==='u') state = NULL2; - else - return emitError('Invalid null started with n'+ c); - continue; - - case NULL2: - if (!c) continue; - if (c==='l') state = NULL3; - else - return emitError('Invalid null started with nu'+ c); - continue; - - case NULL3: - if (!c) continue; - if(c==='l') { - emitValueOpen(null); - emitValueClose(); - state = stack.pop() || VALUE; - } else - return emitError('Invalid null started with nul'+ c); - continue; - - case NUMBER_DECIMAL_POINT: - if(c==='.') { - numberNode += c; - state = NUMBER_DIGIT; - } else - return emitError('Leading zero not followed by .'); - continue; - - case NUMBER_DIGIT: - if('0123456789'.indexOf(c) !== -1) numberNode += c; - else if (c==='.') { - if(numberNode.indexOf('.')!==-1) - return emitError('Invalid number has two dots'); - numberNode += c; - } else if (c==='e' || c==='E') { - if(numberNode.indexOf('e')!==-1 || - numberNode.indexOf('E')!==-1 ) - return emitError('Invalid number has two exponential'); - numberNode += c; - } else if (c==="+" || c==="-") { - if(!(p==='e' || p==='E')) - return emitError('Invalid symbol in number'); - numberNode += c; - } else { - if (numberNode) { - emitValueOpen(parseFloat(numberNode)); - emitValueClose(); - numberNode = ""; - } - i--; // go back one - state = stack.pop() || VALUE; - } - continue; - - default: - return emitError("Unknown state: " + state); - } - } - if (position >= bufferCheckPosition) - checkBufferLength(); - } -} - - -/** - * A bridge used to assign stateless functions to listen to clarinet. - * - * As well as the parameter from clarinet, each callback will also be passed - * the result of the last callback. - * - * This may also be used to clear all listeners by assigning zero handlers: - * - * ascentManager( clarinet, {} ) - */ -function ascentManager(oboeBus, handlers){ - "use strict"; - - var listenerId = {}, - ascent; - - function stateAfter(handler) { - return function(param){ - ascent = handler( ascent, param); - } - } - - for( var eventName in handlers ) { - - oboeBus(eventName).on(stateAfter(handlers[eventName]), listenerId); - } - - oboeBus(NODE_SWAP).on(function(newNode) { - - var oldHead = head(ascent), - key = keyOf(oldHead), - ancestors = tail(ascent), - parentNode; - - if( ancestors ) { - parentNode = nodeOf(head(ancestors)); - parentNode[key] = newNode; - } - }); - - oboeBus(NODE_DROP).on(function() { - - var oldHead = head(ascent), - key = keyOf(oldHead), - ancestors = tail(ascent), - parentNode; - - if( ancestors ) { - parentNode = nodeOf(head(ancestors)); - - delete parentNode[key]; - } - }); - - oboeBus(ABORTING).on(function(){ - - for( var eventName in handlers ) { - oboeBus(eventName).un(listenerId); - } - }); -} - -var httpTransport = functor(require('http-https')); - -/** - * A wrapper around the browser XmlHttpRequest object that raises an - * event whenever a new part of the response is available. - * - * In older browsers progressive reading is impossible so all the - * content is given in a single call. For newer ones several events - * should be raised, allowing progressive interpretation of the response. - * - * @param {Function} oboeBus an event bus local to this Oboe instance - * @param {XMLHttpRequest} transport the http implementation to use as the transport. Under normal - * operation, will have been created using httpTransport() above - * and therefore be Node's http - * but for tests a stub may be provided instead. - * @param {String} method one of 'GET' 'POST' 'PUT' 'PATCH' 'DELETE' - * @param {String} contentSource the url to make a request to, or a stream to read from - * @param {String|Null} data some content to be sent with the request. - * Only valid if method is POST or PUT. - * @param {Object} [headers] the http request headers to send - */ -function streamingHttp(oboeBus, transport, method, contentSource, data, headers) { - "use strict"; - - /* receiving data after calling .abort on Node's http has been observed in the - wild. Keep aborted as state so that if the request has been aborted we - can ignore new data from that point on */ - var aborted = false; - - function readStreamToEventBus(readableStream) { - - // use stream in flowing mode - readableStream.on('data', function (chunk) { - - // avoid reading the stream after aborting the request - if( !aborted ) { - oboeBus(STREAM_DATA).emit(chunk.toString()); - } - }); - - readableStream.on('end', function() { - - // avoid reading the stream after aborting the request - if( !aborted ) { - oboeBus(STREAM_END).emit(); - } - }); - } - - function readStreamToEnd(readableStream, callback){ - var content = ''; - - readableStream.on('data', function (chunk) { - - content += chunk.toString(); - }); - - readableStream.on('end', function() { - - callback( content ); - }); - } - - function openUrlAsStream( url ) { - - var parsedUrl = require('url').parse(url); - - return transport.request({ - hostname: parsedUrl.hostname, - port: parsedUrl.port, - path: parsedUrl.path, - method: method, - headers: headers, - protocol: parsedUrl.protocol - }); - } - - function fetchUrl() { - if( !contentSource.match(/https?:\/\//) ) { - throw new Error( - 'Supported protocols when passing a URL into Oboe are http and https. ' + - 'If you wish to use another protocol, please pass a ReadableStream ' + - '(http://nodejs.org/api/stream.html#stream_class_stream_readable) like ' + - 'oboe(fs.createReadStream("my_file")). I was given the URL: ' + - contentSource - ); - } - - var req = openUrlAsStream(contentSource); - - req.on('response', function(res){ - var statusCode = res.statusCode, - successful = String(statusCode)[0] == 2; - - oboeBus(HTTP_START).emit( res.statusCode, res.headers); - - if( successful ) { - - readStreamToEventBus(res) - - } else { - readStreamToEnd(res, function(errorBody){ - oboeBus(FAIL_EVENT).emit( - errorReport( statusCode, errorBody ) - ); - }); - } - }); - - req.on('error', function(e) { - oboeBus(FAIL_EVENT).emit( - errorReport(undefined, undefined, e ) - ); - }); - - oboeBus(ABORTING).on( function(){ - aborted = true; - req.abort(); - }); - - if( data ) { - req.write(data); - } - - req.end(); - } - - if( isString(contentSource) ) { - fetchUrl(contentSource); - } else { - // contentsource is a stream - readStreamToEventBus(contentSource); - } - -} - -var jsonPathSyntax = (function() { - - var - - /** - * Export a regular expression as a simple function by exposing just - * the Regex#exec. This allows regex tests to be used under the same - * interface as differently implemented tests, or for a user of the - * tests to not concern themselves with their implementation as regular - * expressions. - * - * This could also be expressed point-free as: - * Function.prototype.bind.bind(RegExp.prototype.exec), - * - * But that's far too confusing! (and not even smaller once minified - * and gzipped) - */ - regexDescriptor = function regexDescriptor(regex) { - return regex.exec.bind(regex); - } - - /** - * Join several regular expressions and express as a function. - * This allows the token patterns to reuse component regular expressions - * instead of being expressed in full using huge and confusing regular - * expressions. - */ - , jsonPathClause = varArgs(function( componentRegexes ) { - - // The regular expressions all start with ^ because we - // only want to find matches at the start of the - // JSONPath fragment we are inspecting - componentRegexes.unshift(/^/); - - return regexDescriptor( - RegExp( - componentRegexes.map(attr('source')).join('') - ) - ); - }) - - , possiblyCapturing = /(\$?)/ - , namedNode = /([\w-_]+|\*)/ - , namePlaceholder = /()/ - , nodeInArrayNotation = /\["([^"]+)"\]/ - , numberedNodeInArrayNotation = /\[(\d+|\*)\]/ - , fieldList = /{([\w ]*?)}/ - , optionalFieldList = /(?:{([\w ]*?)})?/ - - - // foo or * - , jsonPathNamedNodeInObjectNotation = jsonPathClause( - possiblyCapturing, - namedNode, - optionalFieldList - ) - - // ["foo"] - , jsonPathNamedNodeInArrayNotation = jsonPathClause( - possiblyCapturing, - nodeInArrayNotation, - optionalFieldList - ) - - // [2] or [*] - , jsonPathNumberedNodeInArrayNotation = jsonPathClause( - possiblyCapturing, - numberedNodeInArrayNotation, - optionalFieldList - ) - - // {a b c} - , jsonPathPureDuckTyping = jsonPathClause( - possiblyCapturing, - namePlaceholder, - fieldList - ) - - // .. - , jsonPathDoubleDot = jsonPathClause(/\.\./) - - // . - , jsonPathDot = jsonPathClause(/\./) - - // ! - , jsonPathBang = jsonPathClause( - possiblyCapturing, - /!/ - ) - - // nada! - , emptyString = jsonPathClause(/$/) - - ; - - - /* We export only a single function. When called, this function injects - into another function the descriptors from above. - */ - return function (fn){ - return fn( - lazyUnion( - jsonPathNamedNodeInObjectNotation - , jsonPathNamedNodeInArrayNotation - , jsonPathNumberedNodeInArrayNotation - , jsonPathPureDuckTyping - ) - , jsonPathDoubleDot - , jsonPathDot - , jsonPathBang - , emptyString - ); - }; - -}()); -/** - * Get a new key->node mapping - * - * @param {String|Number} key - * @param {Object|Array|String|Number|null} node a value found in the json - */ -function namedNode(key, node) { - return {key:key, node:node}; -} - -/** get the key of a namedNode */ -var keyOf = attr('key'); - -/** get the node from a namedNode */ -var nodeOf = attr('node'); -/** - * This file provides various listeners which can be used to build up - * a changing ascent based on the callbacks provided by Clarinet. It listens - * to the low-level events from Clarinet and emits higher-level ones. - * - * The building up is stateless so to track a JSON file - * ascentManager.js is required to store the ascent state - * between calls. - */ - - - -/** - * A special value to use in the path list to represent the path 'to' a root - * object (which doesn't really have any path). This prevents the need for - * special-casing detection of the root object and allows it to be treated - * like any other object. We might think of this as being similar to the - * 'unnamed root' domain ".", eg if I go to - * http://en.wikipedia.org./wiki/En/Main_page the dot after 'org' deliminates - * the unnamed root of the DNS. - * - * This is kept as an object to take advantage that in Javascript's OO objects - * are guaranteed to be distinct, therefore no other object can possibly clash - * with this one. Strings, numbers etc provide no such guarantee. - **/ -var ROOT_PATH = {}; - - -/** - * Create a new set of handlers for clarinet's events, bound to the emit - * function given. - */ -function incrementalContentBuilder( oboeBus ) { - - var emitNodeOpened = oboeBus(NODE_OPENED).emit, - emitNodeClosed = oboeBus(NODE_CLOSED).emit, - emitRootOpened = oboeBus(ROOT_PATH_FOUND).emit, - emitRootClosed = oboeBus(ROOT_NODE_FOUND).emit; - - function arrayIndicesAreKeys( possiblyInconsistentAscent, newDeepestNode) { - - /* for values in arrays we aren't pre-warned of the coming paths - (Clarinet gives no call to onkey like it does for values in objects) - so if we are in an array we need to create this path ourselves. The - key will be len(parentNode) because array keys are always sequential - numbers. */ - - var parentNode = nodeOf( head( possiblyInconsistentAscent)); - - return isOfType( Array, parentNode) - ? - keyFound( possiblyInconsistentAscent, - len(parentNode), - newDeepestNode - ) - : - // nothing needed, return unchanged - possiblyInconsistentAscent - ; - } - - function nodeOpened( ascent, newDeepestNode ) { - - if( !ascent ) { - // we discovered the root node, - emitRootOpened( newDeepestNode); - - return keyFound( ascent, ROOT_PATH, newDeepestNode); - } - - // we discovered a non-root node - - var arrayConsistentAscent = arrayIndicesAreKeys( ascent, newDeepestNode), - ancestorBranches = tail( arrayConsistentAscent), - previouslyUnmappedName = keyOf( head( arrayConsistentAscent)); - - appendBuiltContent( - ancestorBranches, - previouslyUnmappedName, - newDeepestNode - ); - - return cons( - namedNode( previouslyUnmappedName, newDeepestNode ), - ancestorBranches - ); - } - - - /** - * Add a new value to the object we are building up to represent the - * parsed JSON - */ - function appendBuiltContent( ancestorBranches, key, node ){ - - nodeOf( head( ancestorBranches))[key] = node; - } - - - /** - * For when we find a new key in the json. - * - * @param {String|Number|Object} newDeepestName the key. If we are in an - * array will be a number, otherwise a string. May take the special - * value ROOT_PATH if the root node has just been found - * - * @param {String|Number|Object|Array|Null|undefined} [maybeNewDeepestNode] - * usually this won't be known so can be undefined. Can't use null - * to represent unknown because null is a valid value in JSON - **/ - function keyFound(ascent, newDeepestName, maybeNewDeepestNode) { - - if( ascent ) { // if not root - - // If we have the key but (unless adding to an array) no known value - // yet. Put that key in the output but against no defined value: - appendBuiltContent( ascent, newDeepestName, maybeNewDeepestNode ); - } - - var ascentWithNewPath = cons( - namedNode( newDeepestName, - maybeNewDeepestNode), - ascent - ); - - emitNodeOpened( ascentWithNewPath); - - return ascentWithNewPath; - } - - - /** - * For when the current node ends. - */ - function nodeClosed( ascent ) { - - emitNodeClosed( ascent); - - return tail( ascent) || - // If there are no nodes left in the ascent the root node - // just closed. Emit a special event for this: - emitRootClosed(nodeOf(head(ascent))); - } - - var contentBuilderHandlers = {}; - contentBuilderHandlers[SAX_VALUE_OPEN] = nodeOpened; - contentBuilderHandlers[SAX_VALUE_CLOSE] = nodeClosed; - contentBuilderHandlers[SAX_KEY] = keyFound; - return contentBuilderHandlers; -} - -/** - * The jsonPath evaluator compiler used for Oboe.js. - * - * One function is exposed. This function takes a String JSONPath spec and - * returns a function to test candidate ascents for matches. - * - * String jsonPath -> (List ascent) -> Boolean|Object - * - * This file is coded in a pure functional style. That is, no function has - * side effects, every function evaluates to the same value for the same - * arguments and no variables are reassigned. - */ -// the call to jsonPathSyntax injects the token syntaxes that are needed -// inside the compiler -var jsonPathCompiler = jsonPathSyntax(function (pathNodeSyntax, - doubleDotSyntax, - dotSyntax, - bangSyntax, - emptySyntax ) { - - var CAPTURING_INDEX = 1; - var NAME_INDEX = 2; - var FIELD_LIST_INDEX = 3; - - var headKey = compose2(keyOf, head), - headNode = compose2(nodeOf, head); - - /** - * Create an evaluator function for a named path node, expressed in the - * JSONPath like: - * foo - * ["bar"] - * [2] - */ - function nameClause(previousExpr, detection ) { - - var name = detection[NAME_INDEX], - - matchesName = ( !name || name == '*' ) - ? always - : function(ascent){return headKey(ascent) == name}; - - - return lazyIntersection(matchesName, previousExpr); - } - - /** - * Create an evaluator function for a a duck-typed node, expressed like: - * - * {spin, taste, colour} - * .particle{spin, taste, colour} - * *{spin, taste, colour} - */ - function duckTypeClause(previousExpr, detection) { - - var fieldListStr = detection[FIELD_LIST_INDEX]; - - if (!fieldListStr) - return previousExpr; // don't wrap at all, return given expr as-is - - var hasAllrequiredFields = partialComplete( - hasAllProperties, - arrayAsList(fieldListStr.split(/\W+/)) - ), - - isMatch = compose2( - hasAllrequiredFields, - headNode - ); - - return lazyIntersection(isMatch, previousExpr); - } - - /** - * Expression for $, returns the evaluator function - */ - function capture( previousExpr, detection ) { - - // extract meaning from the detection - var capturing = !!detection[CAPTURING_INDEX]; - - if (!capturing) - return previousExpr; // don't wrap at all, return given expr as-is - - return lazyIntersection(previousExpr, head); - - } - - /** - * Create an evaluator function that moves onto the next item on the - * lists. This function is the place where the logic to move up a - * level in the ascent exists. - * - * Eg, for JSONPath ".foo" we need skip1(nameClause(always, [,'foo'])) - */ - function skip1(previousExpr) { - - - if( previousExpr == always ) { - /* If there is no previous expression this consume command - is at the start of the jsonPath. - Since JSONPath specifies what we'd like to find but not - necessarily everything leading down to it, when running - out of JSONPath to check against we default to true */ - return always; - } - - /** return true if the ascent we have contains only the JSON root, - * false otherwise - */ - function notAtRoot(ascent){ - return headKey(ascent) != ROOT_PATH; - } - - return lazyIntersection( - /* If we're already at the root but there are more - expressions to satisfy, can't consume any more. No match. - - This check is why none of the other exprs have to be able - to handle empty lists; skip1 is the only evaluator that - moves onto the next token and it refuses to do so once it - reaches the last item in the list. */ - notAtRoot, - - /* We are not at the root of the ascent yet. - Move to the next level of the ascent by handing only - the tail to the previous expression */ - compose2(previousExpr, tail) - ); - - } - - /** - * Create an evaluator function for the .. (double dot) token. Consumes - * zero or more levels of the ascent, the fewest that are required to find - * a match when given to previousExpr. - */ - function skipMany(previousExpr) { - - if( previousExpr == always ) { - /* If there is no previous expression this consume command - is at the start of the jsonPath. - Since JSONPath specifies what we'd like to find but not - necessarily everything leading down to it, when running - out of JSONPath to check against we default to true */ - return always; - } - - var - // In JSONPath .. is equivalent to !.. so if .. reaches the root - // the match has succeeded. Ie, we might write ..foo or !..foo - // and both should match identically. - terminalCaseWhenArrivingAtRoot = rootExpr(), - terminalCaseWhenPreviousExpressionIsSatisfied = previousExpr, - recursiveCase = skip1(function(ascent) { - return cases(ascent); - }), - - cases = lazyUnion( - terminalCaseWhenArrivingAtRoot - , terminalCaseWhenPreviousExpressionIsSatisfied - , recursiveCase - ); - - return cases; - } - - /** - * Generate an evaluator for ! - matches only the root element of the json - * and ignores any previous expressions since nothing may precede !. - */ - function rootExpr() { - - return function(ascent){ - return headKey(ascent) == ROOT_PATH; - }; - } - - /** - * Generate a statement wrapper to sit around the outermost - * clause evaluator. - * - * Handles the case where the capturing is implicit because the JSONPath - * did not contain a '$' by returning the last node. - */ - function statementExpr(lastClause) { - - return function(ascent) { - - // kick off the evaluation by passing through to the last clause - var exprMatch = lastClause(ascent); - - return exprMatch === true ? head(ascent) : exprMatch; - }; - } - - /** - * For when a token has been found in the JSONPath input. - * Compiles the parser for that token and returns in combination with the - * parser already generated. - * - * @param {Function} exprs a list of the clause evaluator generators for - * the token that was found - * @param {Function} parserGeneratedSoFar the parser already found - * @param {Array} detection the match given by the regex engine when - * the feature was found - */ - function expressionsReader( exprs, parserGeneratedSoFar, detection ) { - - // if exprs is zero-length foldR will pass back the - // parserGeneratedSoFar as-is so we don't need to treat - // this as a special case - - return foldR( - function( parserGeneratedSoFar, expr ){ - - return expr(parserGeneratedSoFar, detection); - }, - parserGeneratedSoFar, - exprs - ); - - } - - /** - * If jsonPath matches the given detector function, creates a function which - * evaluates against every clause in the clauseEvaluatorGenerators. The - * created function is propagated to the onSuccess function, along with - * the remaining unparsed JSONPath substring. - * - * The intended use is to create a clauseMatcher by filling in - * the first two arguments, thus providing a function that knows - * some syntax to match and what kind of generator to create if it - * finds it. The parameter list once completed is: - * - * (jsonPath, parserGeneratedSoFar, onSuccess) - * - * onSuccess may be compileJsonPathToFunction, to recursively continue - * parsing after finding a match or returnFoundParser to stop here. - */ - function generateClauseReaderIfTokenFound ( - - tokenDetector, clauseEvaluatorGenerators, - - jsonPath, parserGeneratedSoFar, onSuccess) { - - var detected = tokenDetector(jsonPath); - - if(detected) { - var compiledParser = expressionsReader( - clauseEvaluatorGenerators, - parserGeneratedSoFar, - detected - ), - - remainingUnparsedJsonPath = jsonPath.substr(len(detected[0])); - - return onSuccess(remainingUnparsedJsonPath, compiledParser); - } - } - - /** - * Partially completes generateClauseReaderIfTokenFound above. - */ - function clauseMatcher(tokenDetector, exprs) { - - return partialComplete( - generateClauseReaderIfTokenFound, - tokenDetector, - exprs - ); - } - - /** - * clauseForJsonPath is a function which attempts to match against - * several clause matchers in order until one matches. If non match the - * jsonPath expression is invalid and an error is thrown. - * - * The parameter list is the same as a single clauseMatcher: - * - * (jsonPath, parserGeneratedSoFar, onSuccess) - */ - var clauseForJsonPath = lazyUnion( - - clauseMatcher(pathNodeSyntax , list( capture, - duckTypeClause, - nameClause, - skip1 )) - - , clauseMatcher(doubleDotSyntax , list( skipMany)) - - // dot is a separator only (like whitespace in other languages) but - // rather than make it a special case, use an empty list of - // expressions when this token is found - , clauseMatcher(dotSyntax , list() ) - - , clauseMatcher(bangSyntax , list( capture, - rootExpr)) - - , clauseMatcher(emptySyntax , list( statementExpr)) - - , function (jsonPath) { - throw Error('"' + jsonPath + '" could not be tokenised') - } - ); - - - /** - * One of two possible values for the onSuccess argument of - * generateClauseReaderIfTokenFound. - * - * When this function is used, generateClauseReaderIfTokenFound simply - * returns the compiledParser that it made, regardless of if there is - * any remaining jsonPath to be compiled. - */ - function returnFoundParser(_remainingJsonPath, compiledParser){ - return compiledParser - } - - /** - * Recursively compile a JSONPath expression. - * - * This function serves as one of two possible values for the onSuccess - * argument of generateClauseReaderIfTokenFound, meaning continue to - * recursively compile. Otherwise, returnFoundParser is given and - * compilation terminates. - */ - function compileJsonPathToFunction( uncompiledJsonPath, - parserGeneratedSoFar ) { - - /** - * On finding a match, if there is remaining text to be compiled - * we want to either continue parsing using a recursive call to - * compileJsonPathToFunction. Otherwise, we want to stop and return - * the parser that we have found so far. - */ - var onFind = uncompiledJsonPath - ? compileJsonPathToFunction - : returnFoundParser; - - return clauseForJsonPath( - uncompiledJsonPath, - parserGeneratedSoFar, - onFind - ); - } - - /** - * This is the function that we expose to the rest of the library. - */ - return function(jsonPath){ - - try { - // Kick off the recursive parsing of the jsonPath - return compileJsonPathToFunction(jsonPath, always); - - } catch( e ) { - throw Error( 'Could not compile "' + jsonPath + - '" because ' + e.message - ); - } - } - -}); - -/** - * A pub/sub which is responsible for a single event type. A - * multi-event type event bus is created by pubSub by collecting - * several of these. - * - * @param {String} eventType - * the name of the events managed by this singleEventPubSub - * @param {singleEventPubSub} [newListener] - * place to notify of new listeners - * @param {singleEventPubSub} [removeListener] - * place to notify of when listeners are removed - */ -function singleEventPubSub(eventType, newListener, removeListener){ - - /** we are optimised for emitting events over firing them. - * As well as the tuple list which stores event ids and - * listeners there is a list with just the listeners which - * can be iterated more quickly when we are emitting - */ - var listenerTupleList, - listenerList; - - function hasId(id){ - return function(tuple) { - return tuple.id == id; - }; - } - - return { - - /** - * @param {Function} listener - * @param {*} listenerId - * an id that this listener can later by removed by. - * Can be of any type, to be compared to other ids using == - */ - on:function( listener, listenerId ) { - - var tuple = { - listener: listener - , id: listenerId || listener // when no id is given use the - // listener function as the id - }; - - if( newListener ) { - newListener.emit(eventType, listener, tuple.id); - } - - listenerTupleList = cons( tuple, listenerTupleList ); - listenerList = cons( listener, listenerList ); - - return this; // chaining - }, - - emit:function () { - applyEach( listenerList, arguments ); - }, - - un: function( listenerId ) { - - var removed; - - listenerTupleList = without( - listenerTupleList, - hasId(listenerId), - function(tuple){ - removed = tuple; - } - ); - - if( removed ) { - listenerList = without( listenerList, function(listener){ - return listener == removed.listener; - }); - - if( removeListener ) { - removeListener.emit(eventType, removed.listener, removed.id); - } - } - }, - - listeners: function(){ - // differs from Node EventEmitter: returns list, not array - return listenerList; - }, - - hasListener: function(listenerId){ - var test = listenerId? hasId(listenerId) : always; - - return defined(first( test, listenerTupleList)); - } - }; -} -/** - * pubSub is a curried interface for listening to and emitting - * events. - * - * If we get a bus: - * - * var bus = pubSub(); - * - * We can listen to event 'foo' like: - * - * bus('foo').on(myCallback) - * - * And emit event foo like: - * - * bus('foo').emit() - * - * or, with a parameter: - * - * bus('foo').emit('bar') - * - * All functions can be cached and don't need to be - * bound. Ie: - * - * var fooEmitter = bus('foo').emit - * fooEmitter('bar'); // emit an event - * fooEmitter('baz'); // emit another - * - * There's also an uncurried[1] shortcut for .emit and .on: - * - * bus.on('foo', callback) - * bus.emit('foo', 'bar') - * - * [1]: http://zvon.org/other/haskell/Outputprelude/uncurry_f.html - */ -function pubSub(){ - - var singles = {}, - newListener = newSingle('newListener'), - removeListener = newSingle('removeListener'); - - function newSingle(eventName) { - return singles[eventName] = singleEventPubSub( - eventName, - newListener, - removeListener - ); - } - - /** pubSub instances are functions */ - function pubSubInstance( eventName ){ - - return singles[eventName] || newSingle( eventName ); - } - - // add convenience EventEmitter-style uncurried form of 'emit' and 'on' - ['emit', 'on', 'un'].forEach(function(methodName){ - - pubSubInstance[methodName] = varArgs(function(eventName, parameters){ - apply( parameters, pubSubInstance( eventName )[methodName]); - }); - }); - - return pubSubInstance; -} - -/** - * This file declares some constants to use as names for event types. - */ - -var // the events which are never exported are kept as - // the smallest possible representation, in numbers: - _S = 1, - - // fired whenever a new node starts in the JSON stream: - NODE_OPENED = _S++, - - // fired whenever a node closes in the JSON stream: - NODE_CLOSED = _S++, - - // called if a .node callback returns a value - - NODE_SWAP = _S++, - NODE_DROP = _S++, - - FAIL_EVENT = 'fail', - - ROOT_NODE_FOUND = _S++, - ROOT_PATH_FOUND = _S++, - - HTTP_START = 'start', - STREAM_DATA = 'data', - STREAM_END = 'end', - ABORTING = _S++, - - // SAX events butchered from Clarinet - SAX_KEY = _S++, - SAX_VALUE_OPEN = _S++, - SAX_VALUE_CLOSE = _S++; - -function errorReport(statusCode, body, error) { - try{ - var jsonBody = JSON.parse(body); - }catch(e){} - - return { - statusCode:statusCode, - body:body, - jsonBody:jsonBody, - thrown:error - }; -} - -/** - * The pattern adaptor listens for newListener and removeListener - * events. When patterns are added or removed it compiles the JSONPath - * and wires them up. - * - * When nodes and paths are found it emits the fully-qualified match - * events with parameters ready to ship to the outside world - */ - -function patternAdapter(oboeBus, jsonPathCompiler) { - - var predicateEventMap = { - node:oboeBus(NODE_CLOSED) - , path:oboeBus(NODE_OPENED) - }; - - function emitMatchingNode(emitMatch, node, ascent) { - - /* - We're now calling to the outside world where Lisp-style - lists will not be familiar. Convert to standard arrays. - - Also, reverse the order because it is more common to - list paths "root to leaf" than "leaf to root" */ - var descent = reverseList(ascent); - - emitMatch( - node, - - // To make a path, strip off the last item which is the special - // ROOT_PATH token for the 'path' to the root node - listAsArray(tail(map(keyOf,descent))), // path - listAsArray(map(nodeOf, descent)) // ancestors - ); - } - - /* - * Set up the catching of events such as NODE_CLOSED and NODE_OPENED and, if - * matching the specified pattern, propagate to pattern-match events such as - * oboeBus('node:!') - * - * - * - * @param {Function} predicateEvent - * either oboeBus(NODE_CLOSED) or oboeBus(NODE_OPENED). - * @param {Function} compiledJsonPath - */ - function addUnderlyingListener( fullEventName, predicateEvent, compiledJsonPath ){ - - var emitMatch = oboeBus(fullEventName).emit; - - predicateEvent.on( function (ascent) { - - var maybeMatchingMapping = compiledJsonPath(ascent); - - /* Possible values for maybeMatchingMapping are now: - - false: - we did not match - - an object/array/string/number/null: - we matched and have the node that matched. - Because nulls are valid json values this can be null. - - undefined: - we matched but don't have the matching node yet. - ie, we know there is an upcoming node that matches but we - can't say anything else about it. - */ - if (maybeMatchingMapping !== false) { - - emitMatchingNode( - emitMatch, - nodeOf(maybeMatchingMapping), - ascent - ); - } - }, fullEventName); - - oboeBus('removeListener').on( function(removedEventName){ - - // if the fully qualified match event listener is later removed, clean up - // by removing the underlying listener if it was the last using that pattern: - - if( removedEventName == fullEventName ) { - - if( !oboeBus(removedEventName).listeners( )) { - predicateEvent.un( fullEventName ); - } - } - }); - } - - oboeBus('newListener').on( function(fullEventName){ - - var match = /(node|path):(.*)/.exec(fullEventName); - - if( match ) { - var predicateEvent = predicateEventMap[match[1]]; - - if( !predicateEvent.hasListener( fullEventName) ) { - - addUnderlyingListener( - fullEventName, - predicateEvent, - jsonPathCompiler( match[2] ) - ); - } - } - }) - -} - -/** - * The instance API is the thing that is returned when oboe() is called. - * it allows: - * - * - listeners for various events to be added and removed - * - the http response header/headers to be read - */ -function instanceApi(oboeBus, contentSource){ - - var oboeApi, - fullyQualifiedNamePattern = /^(node|path):./, - rootNodeFinishedEvent = oboeBus(ROOT_NODE_FOUND), - emitNodeDrop = oboeBus(NODE_DROP).emit, - emitNodeSwap = oboeBus(NODE_SWAP).emit, - - /** - * Add any kind of listener that the instance api exposes - */ - addListener = varArgs(function( eventId, parameters ){ - - if( oboeApi[eventId] ) { - - // for events added as .on(event, callback), if there is a - // .event() equivalent with special behaviour , pass through - // to that: - apply(parameters, oboeApi[eventId]); - } else { - - // we have a standard Node.js EventEmitter 2-argument call. - // The first parameter is the listener. - var event = oboeBus(eventId), - listener = parameters[0]; - - if( fullyQualifiedNamePattern.test(eventId) ) { - - // allow fully-qualified node/path listeners - // to be added - addForgettableCallback(event, listener); - } else { - - // the event has no special handling, pass through - // directly onto the event bus: - event.on( listener); - } - } - - return oboeApi; // chaining - }), - - /** - * Remove any kind of listener that the instance api exposes - */ - removeListener = function( eventId, p2, p3 ){ - - if( eventId == 'done' ) { - - rootNodeFinishedEvent.un(p2); - - } else if( eventId == 'node' || eventId == 'path' ) { - - // allow removal of node and path - oboeBus.un(eventId + ':' + p2, p3); - } else { - - // we have a standard Node.js EventEmitter 2-argument call. - // The second parameter is the listener. This may be a call - // to remove a fully-qualified node/path listener but requires - // no special handling - var listener = p2; - - oboeBus(eventId).un(listener); - } - - return oboeApi; // chaining - }; - - /** - * Add a callback, wrapped in a try/catch so as to not break the - * execution of Oboe if an exception is thrown (fail events are - * fired instead) - * - * The callback is used as the listener id so that it can later be - * removed using .un(callback) - */ - function addProtectedCallback(eventName, callback) { - oboeBus(eventName).on(protectedCallback(callback), callback); - return oboeApi; // chaining - } - - /** - * Add a callback where, if .forget() is called during the callback's - * execution, the callback will be de-registered - */ - function addForgettableCallback(event, callback, listenerId) { - - // listenerId is optional and if not given, the original - // callback will be used - listenerId = listenerId || callback; - - var safeCallback = protectedCallback(callback); - - event.on( function() { - - var discard = false; - - oboeApi.forget = function(){ - discard = true; - }; - - apply( arguments, safeCallback ); - - delete oboeApi.forget; - - if( discard ) { - event.un(listenerId); - } - }, listenerId); - - return oboeApi; // chaining - } - - /** - * wrap a callback so that if it throws, Oboe.js doesn't crash but instead - * throw the error in another event loop - */ - function protectedCallback( callback ) { - return function() { - try{ - return callback.apply(oboeApi, arguments); - }catch(e) { - setTimeout(function() { - throw e; - }); - } - } - } - - /** - * Return the fully qualified event for when a pattern matches - * either a node or a path - * - * @param type {String} either 'node' or 'path' - */ - function fullyQualifiedPatternMatchEvent(type, pattern) { - return oboeBus(type + ':' + pattern); - } - - function wrapCallbackToSwapNodeIfSomethingReturned( callback ) { - return function() { - var returnValueFromCallback = callback.apply(this, arguments); - - if( defined(returnValueFromCallback) ) { - - if( returnValueFromCallback == oboe.drop ) { - emitNodeDrop(); - } else { - emitNodeSwap(returnValueFromCallback); - } - } - } - } - - function addSingleNodeOrPathListener(eventId, pattern, callback) { - - var effectiveCallback; - - if( eventId == 'node' ) { - effectiveCallback = wrapCallbackToSwapNodeIfSomethingReturned(callback); - } else { - effectiveCallback = callback; - } - - addForgettableCallback( - fullyQualifiedPatternMatchEvent(eventId, pattern), - effectiveCallback, - callback - ); - } - - /** - * Add several listeners at a time, from a map - */ - function addMultipleNodeOrPathListeners(eventId, listenerMap) { - - for( var pattern in listenerMap ) { - addSingleNodeOrPathListener(eventId, pattern, listenerMap[pattern]); - } - } - - /** - * implementation behind .onPath() and .onNode() - */ - function addNodeOrPathListenerApi( eventId, jsonPathOrListenerMap, callback ){ - - if( isString(jsonPathOrListenerMap) ) { - addSingleNodeOrPathListener(eventId, jsonPathOrListenerMap, callback); - - } else { - addMultipleNodeOrPathListeners(eventId, jsonPathOrListenerMap); - } - - return oboeApi; // chaining - } - - - // some interface methods are only filled in after we receive - // values and are noops before that: - oboeBus(ROOT_PATH_FOUND).on( function(rootNode) { - oboeApi.root = functor(rootNode); - }); - - /** - * When content starts make the headers readable through the - * instance API - */ - oboeBus(HTTP_START).on( function(_statusCode, headers) { - - oboeApi.header = function(name) { - return name ? headers[name] - : headers - ; - } - }); - - /** - * Construct and return the public API of the Oboe instance to be - * returned to the calling application - */ - return oboeApi = { - on : addListener, - addListener : addListener, - removeListener : removeListener, - emit : oboeBus.emit, - - node : partialComplete(addNodeOrPathListenerApi, 'node'), - path : partialComplete(addNodeOrPathListenerApi, 'path'), - - done : partialComplete(addForgettableCallback, rootNodeFinishedEvent), - start : partialComplete(addProtectedCallback, HTTP_START ), - - // fail doesn't use protectedCallback because - // could lead to non-terminating loops - fail : oboeBus(FAIL_EVENT).on, - - // public api calling abort fires the ABORTING event - abort : oboeBus(ABORTING).emit, - - // initially return nothing for header and root - header : noop, - root : noop, - - source : contentSource - }; -} - -/** - * This file sits just behind the API which is used to attain a new - * Oboe instance. It creates the new components that are required - * and introduces them to each other. - */ - -function wire (httpMethodName, contentSource, body, headers, withCredentials){ - - var oboeBus = pubSub(); - - // Wire the input stream in if we are given a content source. - // This will usually be the case. If not, the instance created - // will have to be passed content from an external source. - - if( contentSource ) { - - streamingHttp( oboeBus, - httpTransport(), - httpMethodName, - contentSource, - body, - headers, - withCredentials - ); - } - - clarinet(oboeBus); - - ascentManager(oboeBus, incrementalContentBuilder(oboeBus)); - - patternAdapter(oboeBus, jsonPathCompiler); - - return instanceApi(oboeBus, contentSource); -} - -function applyDefaults( passthrough, url, httpMethodName, body, headers, withCredentials, cached ){ - - headers = headers ? - // Shallow-clone the headers array. This allows it to be - // modified without side effects to the caller. We don't - // want to change objects that the user passes in. - JSON.parse(JSON.stringify(headers)) - : {}; - - if( body ) { - if( !isString(body) ) { - - // If the body is not a string, stringify it. This allows objects to - // be given which will be sent as JSON. - body = JSON.stringify(body); - - // Default Content-Type to JSON unless given otherwise. - headers['Content-Type'] = headers['Content-Type'] || 'application/json'; - } - } else { - body = null; - } - - // support cache busting like jQuery.ajax({cache:false}) - function modifiedUrl(baseUrl, cached) { - - if( cached === false ) { - - if( baseUrl.indexOf('?') == -1 ) { - baseUrl += '?'; - } else { - baseUrl += '&'; - } - - baseUrl += '_=' + new Date().getTime(); - } - return baseUrl; - } - - return passthrough( httpMethodName || 'GET', modifiedUrl(url, cached), body, headers, withCredentials || false ); + return split(parseRow, opts) } -// export public API -function oboe(arg1) { - - // We use duck-typing to detect if the parameter given is a stream, with the - // below list of parameters. - // Unpipe and unshift would normally be present on a stream but this breaks - // compatibility with Request streams. - // See https://github.com/jimhigson/oboe.js/issues/65 - - var nodeStreamMethodNames = list('resume', 'pause', 'pipe'), - isStream = partialComplete( - hasAllProperties - , nodeStreamMethodNames - ); - - if( arg1 ) { - if (isStream(arg1) || isString(arg1)) { - - // simple version for GETs. Signature is: - // oboe( url ) - // or, under node: - // oboe( readableStream ) - return applyDefaults( - wire, - arg1 // url - ); - - } else { - - // method signature is: - // oboe({method:m, url:u, body:b, headers:{...}}) - - return applyDefaults( - wire, - arg1.url, - arg1.method, - arg1.body, - arg1.headers, - arg1.withCredentials, - arg1.cached - ); - - } - } else { - // wire up a no-AJAX, no-stream Oboe. Will have to have content - // fed in externally and using .emit. - return wire(); - } +function serialize (opts) { + return through.obj(opts, function(obj, enc, cb) { + cb(null, stringify(obj) + EOL) + }) } -/* oboe.drop is a special value. If a node callback returns this value the - parsed node is deleted from the JSON - */ -oboe.drop = function() { - return oboe.drop; -}; - - - return oboe; -})(); - -},{"http-https":29,"url":425}],"q":[function(require,module,exports){ +},{"json-stringify-safe":33,"os":37,"split2":386,"through2":424}],"q":[function(require,module,exports){ (function (process){ // vim:ts=4:sts=4:sw=4: /*! @@ -49577,7 +46680,7 @@ return Q; }).call(this,require('_process')) -},{"_process":41}],"tape":[function(require,module,exports){ +},{"_process":40}],"tape":[function(require,module,exports){ (function (process){ var defined = require('defined'); var createDefaultStream = require('./lib/default_stream'); @@ -49733,5 +46836,5 @@ function createHarness (conf_) { }).call(this,require('_process')) -},{"./lib/default_stream":420,"./lib/results":421,"./lib/test":422,"_process":41,"defined":15,"through":423}]},{},[2]) -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJsaWIvaW1wb3J0ZXIuanMiLCJsaWIvaW5kZXguanMiLCJub2RlX21vZHVsZXMvYmFzZTY0LWpzL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2Jyb3dzZXItcmVzb2x2ZS9lbXB0eS5qcyIsIm5vZGVfbW9kdWxlcy9idWZmZXItc2hpbXMvaW5kZXguanMiLCJub2RlX21vZHVsZXMvYnVmZmVyL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2J1ZmZlci9ub2RlX21vZHVsZXMvaXNhcnJheS9pbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9idWlsdGluLXN0YXR1cy1jb2Rlcy9icm93c2VyLmpzIiwibm9kZV9tb2R1bGVzL2NvcmUtdXRpbC1pcy9saWIvdXRpbC5qcyIsIm5vZGVfbW9kdWxlcy9kZWVwLWVxdWFsL2luZGV4Lmpz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AgZXZlbnRzLm5leHQoe1xuICAgICAgICAgICAgICAgIG1lc3NhZ2U6IFwibWFuaWZlc3RcIixcbiAgICAgICAgICAgICAgICB2YWx1ZTogbWFuaWZlc3RcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICB2YXIgZGVsUmVxID0gaW5kZXhlZERCLmRlbGV0ZURhdGFiYXNlKGlkYl9uYW1lKTtcblxuICAgICAgICAgICAgZGVsUmVxLm9uYmxvY2tlZCA9IGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ2RhdGFiYXNlIGRlbGV0ZSBibG9ja2VkJyk7XG4gICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICB2YXIgZmlsbElEQiA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBkZWxldGUgaW1wb3J0ZWRfaWRic1tpZGJfbmFtZV07XG4gICAgICAgICAgICAgICAgY29tbWl0bG9jYWxTdG9yYWdlKCk7XG5cbiAgICAgICAgICAgICAgICBldmVudHMubmV4dCh7XG4gICAgICAgICAgICAgICAgICAgIG1lc3NhZ2U6IFwib2xkX2lkYl9kZWxldGVkXCJcbiAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgICAgIHZhciBwYWdlc193cml0dGVuID0gMDtcbiAgICAgICAgICAgICAgICB2YXIgdG90YWxfcGFnZXMgPSAwO1xuXG4gICAgICAgICAgICAgICAgdmFyIG9wZW4gPSBpbmRleGVkREIub3BlbihpZGJfbmFtZSwgMSk7XG5cbiAgICAgICAgICAgICAgICBvcGVuLm9uZXJyb3IgPSBmdW5jdGlvbihldmVudCkge1xuICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygnZXJyb3Igb3BlbmluZyBpbmRleGVkREInKTtcbiAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgdmFyIHJlcG9ydFByb2dyZXNzID0gZnVuY3Rpb24ocHJvZ3Jlc3Mpe1xuICAgICAgICAgICAgICAgICAgICBldmVudHMubmV4dCh7XG4gICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlOiBcInByb2dyZXNzXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogcHJvZ3Jlc3NcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfTtcblxuXG4gICAgICAgICAgICAgICAgdmFyIG1pZ3JhdGUgPSBmdW5jdGlvbihldmVudCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZGIgPSBldmVudC50YXJnZXQucmVzdWx0O1xuICAgICAgICAgICAgICAgICAgICB2YXIgc3RvcmVfcHJvbWlzZXMgPSBbXTtcblxuICAgICAgICAgICAgICAgICAgICB2YXIgZmFpbG91dCA9IGZ1bmN0aW9uKHJlYXNvbil7XG4gICAgICAgICAgICAgICAgICAgICAgICBldmVudHMubmV4dCh7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZTogXCJlcnJvclwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiByZWFzb25cbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBkYi5jbG9zZSgpO1xuICAgICAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgICAgIF8uZWFjaChtYW5pZmVzdCwgZnVuY3Rpb24gKF9tYW5pZmVzdCwga2V5KSB7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwa2V5X2luZGljZXMgPSB7fTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzdG9yZV9vcHRzID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleVBhdGg6IF9tYW5pZmVzdC5wcmltYXJ5X2tleXNbMF1cbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmKF9tYW5pZmVzdC5wcmltYXJ5X2tleXMubGVuZ3RoID4gMSl7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGtleV9pbmRpY2VzW1wiaWR4X211bHRpcGxlX3BrZXlzXCJdID0gX21hbmlmZXN0LnByaW1hcnlfa2V5cztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgc3RvcmVfb3B0cy5rZXlQYXRoO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RvcmUgPSBkYi5jcmVhdGVPYmplY3RTdG9yZShrZXksICBzdG9yZV9vcHRzKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgXy5lYWNoKF8uZXh0ZW5kKHBrZXlfaW5kaWNlcywgX21hbmlmZXN0LmluZGljZXMpLCBmdW5jdGlvbihjb2x1bW5zLCBpZHhfbmFtZSl7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmUuY3JlYXRlSW5kZXgoaWR4X25hbWUsIGNvbHVtbnMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzdG9yZV9kZWZlcnJlZCA9IHEuZGVmZXIoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JlX3Byb21pc2VzLnB1c2goc3RvcmVfZGVmZXJyZWQucHJvbWlzZSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwYWdlcyA9IHBhcnNlSW50KF9tYW5pZmVzdC5yb3dfY291bnQgLyBvcHRpb25zLml0ZW1zX3Blcl9wYWdlKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgaWYoX21hbmlmZXN0LnJvd19jb3VudCAlIG9wdGlvbnMuaXRlbXNfcGVyX3BhZ2UgIT0gMCl7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZXMgKz0gMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsX3BhZ2VzICs9IHBhZ2VzO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcGFnZV9wcm9taXNlcyA9IG5ldyBBcnJheShwYWdlcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcGFnZV9kZWZlcnJlZHMgPSBuZXcgQXJyYXkocGFnZXMpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBfLmVhY2gocGFnZV9wcm9taXNlcywgZnVuY3Rpb24odW51c2VkLCBpKXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZCA9IHEuZGVmZXIoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlX2RlZmVycmVkc1tpXSA9IGQ7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZV9wcm9taXNlc1tpXSA9IGQucHJvbWlzZTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHJvbWlzZS50aGVuKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZXNfd3JpdHRlbiArPSAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXBvcnRQcm9ncmVzcyhwYWdlc193cml0dGVuIC8gdG90YWxfcGFnZXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmFpbG91dCgncGFnZV9zdG9yYWdlX2ZhaWxlZCcpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHEuYWxsKHBhZ2VfcHJvbWlzZXMpLnRoZW4oc3RvcmVfZGVmZXJyZWQucmVzb2x2ZSwgc3RvcmVfZGVmZXJyZWQucmVqZWN0KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmUudHJhbnNhY3Rpb24uYWRkRXZlbnRMaXN0ZW5lcignY29tcGxldGUnLCBmdW5jdGlvbigpe1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGN1cnJlbnRfcGFnZSA9IDA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHBhZ2VfaXRlbXMgPSBbXTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzdG9yZV9wYWdlID0gZnVuY3Rpb24oX3BhZ2UsIF9pdGVtcyl7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0eCA9IGRiLnRyYW5zYWN0aW9uKFtrZXldLCBcInJlYWR3cml0ZVwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9zdG9yZSA9IHR4Lm9iamVjdFN0b3JlKGtleSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXy5lYWNoKF9pdGVtcywgZnVuY3Rpb24gKGl0ZW0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcmVzdWx0O1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihfbWFuaWZlc3QucHJpbWFyeV9rZXlzLmxlbmd0aCA+IDEpe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBtdWx0aUtleSA9IF8ubWFwKF9tYW5pZmVzdC5wcmltYXJ5X2tleXMsIGZ1bmN0aW9uIChwa2V5KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtW3BrZXldO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLmpvaW4oJ18nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfcmVzdWx0ID0gX3N0b3JlLnB1dChpdGVtLCBtdWx0aUtleSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ZWxzZXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfcmVzdWx0ID0gX3N0b3JlLnB1dChpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX3Jlc3VsdC5vbmVycm9yID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VfZGVmZXJyZWRzW19wYWdlXS5yZWplY3QoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR4LmFkZEV2ZW50TGlzdGVuZXIoJ2NvbXBsZXRlJywgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZV9kZWZlcnJlZHNbX3BhZ2VdLnJlc29sdmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcblxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JvZShkYXRhX3BhdGggKyAnLycgKyBrZXkgKyAnLmpzb24nKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAubm9kZSh7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAnIS4qJzogZnVuY3Rpb24ocm93KXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlX2l0ZW1zLnB1c2gocm93KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKHBhZ2VfaXRlbXMubGVuZ3RoID49IG9wdGlvbnMuaXRlbXNfcGVyX3BhZ2UgfHxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudF9wYWdlID09IChwYWdlcyAtIDEpICYmXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlX2l0ZW1zLmxlbmd0aCA+PSAoX21hbmlmZXN0LnJvd19jb3VudCAlIG9wdGlvbnMuaXRlbXNfcGVyX3BhZ2UpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIClcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yZV9wYWdlKGN1cnJlbnRfcGFnZSwgcGFnZV9pdGVtcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VfaXRlbXMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudF9wYWdlICs9IDE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9ib2UuZHJvcDsgLy9hbGxvd3MgdG8gcmVhZCBmaWxlcyBiaWdnZXIgdGhhbiBhdmFpbGFibGUgUkFNXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5mYWlsKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmYWlsb3V0KCdvYm9lX3JlYWRfZmFpbGVkJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG5cbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBzdG9yZS50cmFuc2FjdGlvbi5hZGRFdmVudExpc3RlbmVyKCdlcnJvcicsIGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZmFpbG91dCgnaWRiX3NjaGVtYV9mYWlsZWQnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgIHEuYWxsKHN0b3JlX3Byb21pc2VzKS50aGVuKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGltcG9ydGVkX2lkYnNbaWRiX25hbWVdID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdGxvY2FsU3RvcmFnZSgpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBldmVudHMubmV4dCh7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZTogXCJzdWNjZXNzXCJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgZGIuY2xvc2UoKTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgb3Blbi5vbnVwZ3JhZGVuZWVkZWQgPSBtaWdyYXRlO1xuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgZGVsUmVxLm9uc3VjY2VzcyA9IGZpbGxJREI7XG4gICAgICAgICAgICBkZWxSZXEub25lcnJvciA9IGZpbGxJREI7XG5cbiAgICAgICAgfSlcbiAgICAgICAgLmZhaWwoZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIGV2ZW50cy5uZXh0KHtcbiAgICAgICAgICAgICAgICBtZXNzYWdlOiBcImVycm9yXCIsXG4gICAgICAgICAgICAgICAgdmFsdWU6IFwibWFuaWZlc3Qgbm90IGZvdW5kXCJcbi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E9PSAnZnVuY3Rpb24nIHx8IHRvU3RyLmNhbGwodGFyZ2V0KSAhPT0gZnVuY1R5cGUpIHtcbiAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcihFUlJPUl9NRVNTQUdFICsgdGFyZ2V0KTtcbiAgICB9XG4gICAgdmFyIGFyZ3MgPSBzbGljZS5jYWxsKGFyZ3VtZW50cywgMSk7XG5cbiAgICB2YXIgYm91bmQ7XG4gICAgdmFyIGJpbmRlciA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgaWYgKHRoaXMgaW5zdGFuY2VvZiBib3VuZCkge1xuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHRhcmdldC5hcHBseShcbiAgICAgICAgICAgICAgICB0aGlzLFxuICAgICAgICAgICAgICAgIGFyZ3MuY29uY2F0KHNsaWNlLmNhbGwoYXJndW1lbnRzKSlcbiAgICAgICAgICAgICk7XG4gICAgICAgICAgICBpZiAoT2JqZWN0KHJlc3VsdCkgPT09IHJlc3VsdCkge1xuICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0YXJnZXQuYXBwbHkoXG4gICAgICAgICAgICAgICAgdGhhdCxcbiAgICAgICAgICAgICAgICBhcmdzLmNvbmNhdChzbGljZS5jYWxsKGFyZ3VtZW50cykpXG4gICAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIHZhciBib3VuZExlbmd0aCA9IE1hdGgubWF4KDAsIHRhcmdldC5sZW5ndGggLSBhcmdzLmxlbmd0aCk7XG4gICAgdmFyIGJvdW5kQXJncyA9IFtdO1xuICAgIGZvciAodmFyIGkgPSAwOyBpIDwgYm91bmRMZW5ndGg7IGkrKykge1xuICAgICAgICBib3VuZEFyZ3MucHVzaCgnJCcgKyBpKTtcbiAgICB9XG5cbiAgICBib3VuZCA9IEZ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3RoKSBzICs9ICcuLi4nO1xuICAgICAgICBzICs9ICc8LycgKyBTdHJpbmcob2JqLm5vZGVOYW1lKS50b0xvd2VyQ2FzZSgpICsgJz4nO1xuICAgICAgICByZXR1cm4gcztcbiAgICB9XG4gICAgZWxzZSBpZiAoaXNBcnJheShvYmopKSB7XG4gICAgICAgIGlmIChvYmoubGVuZ3RoID09PSAwKSByZXR1cm4gJ1tdJztcbiAgICAgICAgdmFyIHhzID0gQXJyYXkob2JqLmxlbmd0aCk7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgb2JqLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICB4c1tpXSA9IGhhcyhvYmosIGkpID8gaW5zcGVjdChvYmpbaV0sIG9iaikgOiAnJztcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gJ1sgJyArIHhzLmpvaW4oJywgJykgKyAnIF0nO1xuICAgIH1cbiAgICBlbHNlIGlmIChpc0Vycm9yKG9iaikpIHtcbiAgICAgICAgdmFyIHBhcnRzID0gW107XG4gICAgICAgIGZvciAodmFyIGtleSBpbiBvYmopIHtcbiAgICAgICAgICAgIGlmICghaGFzKG9iaiwga2V5KSkgY29udGludWU7XG4gICAgICAgICAgICBcbiAgICAgICAgICAgIGlmICgvW15cXHckXS8udGVzdChrZXkpKSB7XG4gICAgICAgICAgICAgICAgcGFydHMucHVzaChpbnNwZWN0KGtleSkgKyAnOiAnICsgaW5zcGVjdChvYmpba2V5XSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgcGFydHMucHVzaChrZXkgKyAnOiAnICsgaW5zcGVjdChvYmpba2V5XSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChwYXJ0cy5sZW5ndGggPT09IDApIHJldHVybiAnWycgKyBvYmogKyAnXSc7XG4gICAgICAgIHJldHVybiAneyBbJyArIG9iaiArICddICcgKyBwYXJ0cy5qb2luKCcsICcpICsgJyB9JztcbiAgICB9XG4gICAgZWxzZSBpZiAodHlwZW9mIG9iaiA9PT0gJ29iamVjdCcgJiYgdHlwZW9mIG9iai5pbnNwZWN0ID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgIHJldHVybiBvYmouaW5zcGVjdCgpO1xuICAgIH1cbiAgICBlbHNlIGlmIChpc01hcChvYmopKSB7XG4gICAgICAgIHZhciBwYXJ0cyA9IFtdO1xuICAgICAgICBtYXBGb3JFYWNoLmNhbGwob2JqLCBmdW5jdGlvbiAodmFsdWUsIGtleSkge1xuICAgICAgICAgICAgcGFydHMucHVzaChpbnNwZWN0KGtleSwgb2JqKSArICcgPT4gJyArIGluc3BlY3QodmFsdWUsIG9iaikpO1xuICAgICAgICB9KTtcbiAgICAgICAgcmV0dXJuICdNYXAgKCcgKyBtYXBTaXplLmNhbGwob2JqKSArICcpIHsnICsgcGFydHMuam9pbignLCAnKSArICd9JztcbiAgICB9XG4gICAgZWxzZSBpZiAoaXNTZXQob2JqKSkge1xuICAgICAgICB2YXIgcGFydHMgPSBbXTtcbiAgICAgICAgc2V0Rm9yRWFjaC5jYWxsKG9iaiwgZnVuY3Rpb24gKHZhbHVlICkge1xuICAgICAgICAgICAgcGFydHMucHVzaChpbnNwZWN0KHZhbHVlLCBvYmopKTtcbiAgICAgICAgfSk7XG4gICAgICAgIHJldHVybiAnU2V0ICgnICsgc2V0U2l6ZS5jYWxsKG9iaikgKyAnKSB7JyArIHBhcnRzLmpvaW4oJywgJykgKyAnfSc7XG4gICAgfVxuICAgIGVsc2UgaWYgKHR5cGVvZiBvYmogIT09ICdvYmplY3QnKSB7XG4gICAgICAgIHJldHVybiBTdHJpbmcob2JqKTtcbiAgICB9XG4gICAgZWxzZSBpZiAoaXNOdW1iZXIob2JqKSkge1xuICAgICAgICByZXR1cm4gJ09iamVjdCgnICsgTnVtYmVyKG9iaikgKyAnKSc7XG4gICAgfVxuICAgIGVsc2UgaWYgKGlzQm9vbGVhbihvYmopKSB7XG4gICAgICAgIHJldHVybiAnT2JqZWN0KCcgKyBib29sZWFuVmFsdWVPZi5jYWxsKG9iaikgKyAnKSc7XG4gICAgfVxuICAgIGVsc2UgaWYgKGlzU3RyaW5nKG9iaikpIHtcbiAgICAgICAgcmV0dXJuICdPYmplY3QoJyArIGluc3BlY3QoU3RyaW5nKG9iaikpICsgJyknO1xuICAgIH1cbiAgICBlbHNlIGlmICghaXNEYXRlKG9iaikgJiYgIWlzUmVnRXhwKG9iaikpIHtcbiAgICAgICAgdmFyIHhzID0gW10sIGtleXMgPSBbXTtcbiAgICAgICAgZm9yICh2YXIga2V5IGluIG9iaikge1xuICAgICAgICAgICAgaWYgKGhhcyhvYmosIGtleSkpIGtleXMucHVzaChrZXkpO1xuICAgICAgICB9XG4gICAgICAgIGtleXMuc29ydCgpO1xuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGtleXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIHZhciBrZXkgPSBrZXlzW2ldO1xuICAgICAgICAgICAgaWYgKC9bXlxcdyRdLy50ZXN0KGtleSkpIHtcbiAgICAgICAgICAgICAgICB4cy5wdXNoKGluc3BlY3Qoa2V5KSArICc6ICcgKyBpbnNwZWN0KG9ialtrZXldLCBvYmopKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgeHMucHVzaChrZXkgKyAnOiAnICsgaW5zcGVjdChvYmpba2V5XSwgb2JqKSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHhzLmxlbmd0aCA9PT0gMCkgcmV0dXJuICd7fSc7XG4gICAgICAgIHJldHVybiAneyAnICsgeHMuam9pbignLCAnKSArICcgfSc7XG4gICAgfVxuICAgIGVsc2UgcmV0dXJuIFN0cmluZyhvYmopO1xufTtcblxuZnVuY3Rpb24gcXVvdGUgKHMpIHtcbiAgICByZXR1cm4gU3RyaW5nKHMpLnJlcGxhY2UoL1wiL2csICcmcXVvdDsnKTtcbn1cblxuZnVuY3Rpb24gaXN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0aGF0IGVpdGhlciByZXNvbHZlcyBvbiBvYnNlcnZhYmxlIGNvbXBsZXRpb24gb3JcbiAgICAgKiAgcmVqZWN0cyB3aXRoIHRoZSBoYW5kbGVkIGVycm9yXG4gICAgICovXG4gICAgT2JzZXJ2YWJsZS5wcm90b3R5cGUuZm9yRWFjaCA9IGZ1bmN0aW9uIChuZXh0LCBQcm9taXNlQ3Rvcikge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICBpZiAoIVByb21pc2VDdG9yKSB7XG4gICAgICAgICAgICBpZiAocm9vdF8xLnJvb3QuUnggJiYgcm9vdF8xLnJvb3QuUnguY29uZmlnICYmIHJvb3RfMS5yb290LlJ4LmNvbmZpZy5Qcm9taXNlKSB7XG4gICAgICAgICAgICAgICAgUHJvbWlzZUN0b3IgPSByb290XzEucm9vdC5SeC5jb25maWcuUHJvbWlzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKHJvb3RfMS5yb290LlByb21pc2UpIHtcbiAgICAgICAgICAgICAgICBQcm9taXNlQ3RvciA9IHJvb3RfMS5yb290LlByb21pc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCFQcm9taXNlQ3Rvcikge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdubyBQcm9taXNlIGltcGwgZm91bmQnKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gbmV3IFByb21pc2VDdG9yKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHtcbiAgICAgICAgICAgIHZhciBzdWJzY3JpcHRpb24gPSBfdGhpcy5zdWJzY3JpYmUoZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgaWYgKHN1YnNjcmlwdGlvbikge1xuICAgICAgICAgICAgICAgICAgICAvLyBpZiB0aGVyZSBpcyBhIHN1YnNjcmlwdGlvbiwgdGhlbiB3ZSBjYW4gc3VybWlzZVxuICAgICAgICAgICAgICAgICAgICAvLyB0aGUgbmV4dCBoYW5kbGluZyBpcyBhc3luY2hyb25vdXMuIEFueSBlcnJvcnMgdGhyb3duXG4gICAgICAgICAgICAgICAgICAgIC8vIG5lZWQgdG8gYmUgcmVqZWN0ZWQgZXhwbGljaXRseSBhbmQgdW5zdWJzY3JpYmUgbXVzdCBiZVxuICAgICAgICAgICAgICAgICAgICAvLyBjYWxsZWQgbWFudWFsbHlcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIGlmIHRoZXJlIGlzIE5PIHN1YnNjcmlwdGlvbiwgdGhlbiB3ZSdyZSBnZXR0aW5nIGEgbmV4dGVkXG4gICAgICAgICAgICAgICAgICAgIC8vIHZhbHVlIHN5bmNocm9ub3VzbHkgZHVyaW5nIHN1YnNjcmlwdGlvbi4gV2UgY2FuIGp1c3QgY2FsbCBpdC5cbiAgICAgICAgICAgICAgICAgICAgLy8gSWYgaXQgZXJyb3JzLCBPYnNlcnZhYmxlJ3MgYHN1YnNjcmliZWAgd2lsbCBlbnN1cmUgdGhlXG4gICAgICAgICAgICAgICAgICAgIC8vIHVuc3Vic2NyaXB0aW9uIGxvZ2ljIGlzIGNhbGxlZCwgdGhlbiBzeW5jaHJvbm91c2x5IHJldGhyb3cgdGhlIGVycm9yLlxuICAgICAgICAgICAgICAgICAgICAvLyBBZnRlciB0aGF0LCBQcm9taXNlIHdp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Lk9iamVjdFVuc3Vic2NyaWJlZEVycm9yKCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCF0aGlzLmlzU3RvcHBlZCkge1xuICAgICAgICAgICAgdmFyIG9ic2VydmVycyA9IHRoaXMub2JzZXJ2ZXJzO1xuICAgICAgICAgICAgdmFyIGxlbiA9IG9ic2VydmVycy5sZW5ndGg7XG4gICAgICAgICAgICB2YXIgY29weSA9IG9ic2VydmVycy5zbGljZSgpO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgICAgICAgIGNvcHlbaV0ubmV4dCh2YWx1ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFN1YmplY3QucHJvdG90eXBlLmVycm9yID0gZnVuY3Rpb24gKGVycikge1xuICAgICAgICBpZiAodGhpcy5jbG9zZWQpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBPYmplY3RVbnN1YnNjcmliZWRFcnJvcl8xLk9iamVjdFVuc3Vic2NyaWJlZEVycm9yKCk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5oYXNFcnJvciA9IHRydWU7XG4gICAgICAgIHRoaXMudGhyb3duRXJyb3IgPSBlcnI7XG4gICAgICAgIHRoaXMuaXNTdG9wcGVkID0gdHJ1ZTtcbiAgICAgICAgdmFyIG9ic2VydmVycyA9IHRoaXMub2JzZXJ2ZXJzO1xuICAgICAgICB2YXIgbGVuID0gb2JzZXJ2ZXJzLmxlbmd0aDtcbiAgICAgICAgdmFyIGNvcHkgPSBvYnNlcnZlcnMuc2xpY2UoKTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgICAgY29weVtpXS5lcnJvcihlcnIpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMub2JzZXJ2ZXJzLmxlbmd0aCA9IDA7XG4gICAgfTtcbiAgICBTdWJqZWN0LnByb3RvdHlwZS5jb21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sIGNvbXBsZXRlKSB7XG4gICAgICAgIF9zdXBlci5jYWxsKHRoaXMpO1xuICAgICAgICB0aGlzLnN5bmNFcnJvclZhbHVlID0gbnVsbDtcbiAgICAgICAgdGhpcy5zeW5jRXJyb3JUaHJvd24gPSBmYWxzZTtcbiAgICAgICAgdGhpcy5zeW5jRXJyb3JUaHJvd2FibGUgPSBmYWxzZTtcbiAgICAgICAgdGhpcy5pc1N0b3BwZWQgPSBmYWxzZTtcbiAgICAgICAgc3dpdGNoIChhcmd1bWVudHMubGVuZ3RoKSB7XG4gICAgICAgICAgICBjYXNlIDA6XG4gICAgICAgICAgICAgICAgdGhpcy5kZXN0aW5hdGlvbiA9IE9ic2VydmVyXzEuZW1wdHk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIDE6XG4gICAgICAgICAgICAgICAgaWYgKCFkZXN0aW5hdGlvbk9yTmV4dCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3RpbmF0aW9uID0gT2JzZXJ2ZXJfMS5lbXB0eTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZGVzdGluYXRpb25Pck5leHQgPT09ICdvYmplY3QnKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChkZXN0aW5hdGlvbk9yTmV4dCBpbnN0YW5jZW9mIFN1YnNjcmliZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdGluYXRpb24gPSBkZXN0aW5hdGlvbk9yTmV4dDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdGluYXRpb24uYWRkKHRoaXMpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zeW5jRXJyb3JUaHJvd2FibGUgPSB0cnVlO1xuICAgICAgICA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Ll9lcnJvciwgZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKCFfcGFyZW50LnN5bmNFcnJvclRocm93YWJsZSkge1xuICAgICAgICAgICAgICAgIHRoaXMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBfcGFyZW50LnN5bmNFcnJvclZhbHVlID0gZXJyO1xuICAgICAgICAgICAgICAgIF9wYXJlbnQuc3luY0Vycm9yVGhyb3duID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFNhZmVTdWJzY3JpYmVyLnByb3RvdHlwZS5jb21wbGV0ZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgaWYgKCF0aGlzLmlzU3RvcHBlZCkge1xuICAgICAgICAgICAgdmFyIF9wYXJlbnQgPSB0aGlzLl9wYXJlbnQ7XG4gICAgICAgICAgICBpZiAodGhpcy5fY29tcGxldGUpIHtcbiAgICAgICAgICAgICAgICBpZiAoIV9wYXJlbnQuc3luY0Vycm9yVGhyb3dhYmxlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX190cnlPclVuc3ViKHRoaXMuX2NvbXBsZXRlKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fX3RyeU9yU2V0RXJyb3IoX3BhcmVudCwgdGhpcy5fY29tcGxldGUpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbiAgICBTYWZlU3Vic2NyaWJlci5wcm90b3R5cGUuX190cnlPclVuc3ViID0gZnVuY3Rpb24gKGZuLCB2YWx1ZSkge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgZm4uY2FsbCh0aGlzLl9jb250ZXh0LCB2YWx1ZSk7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgdGhyb3cgZXJyO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBTYWZlU3Vic2NyaWJlci5wcm90b3R5cGUuX190cnlPclNldEVycm9yID0gZnVuY3Rpb24gKHBhcmVudCwgZm4sIHZhbHVlKSB7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICBmbi5jYWxsKHRoaXMuX2NvbnRleHQsIHZhbHVlKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICBwYXJlbnQuc3luY0Vycm9yVmFsdWUgPSBlcnI7XG4gICAgICAgICAgICBwYXJlbnQuc3luY0Vycm9yVGhyb3duID0gdHJ1ZTtcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9O1xuICAgIFNhZmVTdWJzY3JpYmVyLnByb3RvdHlwZS5fdW5zdWJzY3JpYmUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBfcGFyZW50ID0gdGhpcy5fcGFyZW50O1xuICAgICAgICB0aGlzLl9jb250ZXh0ID0gbnVsbDtcbiAgICAgICAgdGhpcy5fcGFyZW50ID0gbnVsbDtcbiAgICAgICAgX3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SB7XG4gICAgICAgICAgICB2YXIgaW5kZXggPSAtMTtcbiAgICAgICAgICAgIHZhciBsZW4gPSBfc3Vic2NyaXB0aW9ucy5sZW5ndGg7XG4gICAgICAgICAgICB3aGlsZSAoKytpbmRleCA8IGxlbikge1xuICAgICAgICAgICAgICAgIHZhciBzdWIgPSBfc3Vic2NyaXB0aW9uc1tpbmRleF07XG4gICAgICAgICAgICAgICAgaWYgKGlzT2JqZWN0XzEuaXNPYmplY3Qoc3ViKSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdHJpYWwgPSB0cnlDYXRjaF8xLnRyeUNhdGNoKHN1Yi51bnN1YnNjcmliZSkuY2FsbChzdWIpO1xuICAgICAgICAgICAgICAgICAgICBpZiAodHJpYWwgPT09IGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGhhc0Vycm9ycyA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBlcnJvcnMgfHwgW107XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgZXJyID0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVyciBpbnN0YW5jZW9mIFVuc3Vic2NyaXB0aW9uRXJyb3JfMS5VbnN1YnNjcmlwdGlvbkVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JzID0gZXJyb3JzLmNvbmNhdChlcnIuZXJyb3JzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9ycy5wdXNoKGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGhh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vdmUoKWAgdG8gcmVtb3ZlIHRoZSBwYXNzZWQgdGVhcmRvd24gbG9naWMgZnJvbSB0aGUgaW5uZXIgc3Vic2NyaXB0aW9uc1xuICAgICAqIGxpc3QuXG4gICAgICovXG4gICAgU3Vic2NyaXB0aW9uLnByb3RvdHlwZS5hZGQgPSBmdW5jdGlvbiAodGVhcmRvd24pIHtcbiAgICAgICAgaWYgKCF0ZWFyZG93biB8fCAodGVhcmRvd24gPT09IFN1YnNjcmlwdGlvbi5FTVBUWSkpIHtcbiAgICAgICAgICAgIHJldHVybiBTdWJzY3JpcHRpb24uRU1QVFk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRlYXJkb3duID09PSB0aGlzKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfVxuICAgICAgICB2YXIgc3ViID0gdGVhcmRvd247XG4gICAgICAgIHN3aXRjaCAodHlwZW9mIHRlYXJkb3duKSB7XG4gICAgICAgICAgICBjYXNlICdmdW5jdGlvbic6XG4gICAgICAgICAgICAgICAgc3ViID0gbmV3IFN1YnNjcmlwdGlvbih0ZWFyZG93bik7XG4gICAgICAgICAgICBjYXNlICdvYmplY3QnOlxuICAgICAgICAgICAgICAgIGlmIChzdWIuY2xvc2VkIHx8IHR5cGVvZiBzdWIudW5zdWJzY3JpYmUgIT09ICdmdW5jdGlvbicpIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2UgaWYgKHRoaXMuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgIHN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgKHRoaXMuX3N1YnNjcmlwdGlvbnMgfHwgKHRoaXMuX3N1YnNjcmlwdGlvbnMgPSBbXSkpLnB1c2goc3ViKTtcbiAgICAgICAgICAgICAgICB9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4gICAgICAgICAgICAgICAgdmFyIGhhbmRsZXIgPSBmdW5jdGlvbiBoYW5kbGVyRm4oKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpbm5lckFyZ3MgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgX2kgPSAwOyBfaSA8IGFyZ3VtZW50cy5sZW5ndGg7IF9pKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyQXJnc1tfaSAtIDBdID0gYXJndW1lbnRzW19pXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB2YXIgc291cmNlID0gaGFuZGxlckZuLnNvdXJjZTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHNlbGVjdG9yID0gc291cmNlLnNlbGVjdG9yLCBzdWJqZWN0ID0gc291cmNlLnN1YmplY3Q7XG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxlY3Rvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdF8xID0gdHJ5Q2F0Y2hfMS50cnlDYXRjaChzZWxlY3RvcikuYXBwbHkodGhpcywgaW5uZXJBcmdzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHRfMSA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YmplY3QuZXJyb3IoZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YmplY3QubmV4dChyZXN1bHRfMSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5uZXh0KGlubmVyQXJncy5sZW5ndGggPT09IDEgPyBpbm5lckFyZ3NbMF0gOiBpbm5lckFyZ3MpO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAvLyB1c2UgbmFtZWQgZnVuY3Rpb24gaW5zdGFuY2UgdG8gYXZvaWQgY2xvc3VyZS5cbiAgICAgICAgICAgICAgICBoYW5kbGVyLnNvdXJjZSA9IHRoaXM7XG4gICAgICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2goY2FsbGJhY2tGdW5jKS5hcHBseSh0aGlzLCBhcmdzLmNvbmNhdChoYW5kbGVyKSk7XG4gICAgICAgICAgICAgICAgaWYgKHJlc3VsdCA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgICAgICBzdWJqZWN0LmVycm9yKGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QuZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHN1YmplY3Quc3Vic2NyaWJlKHN1YnNjcmliZXIpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHNjaGVkdWxlci5zY2hlZHVsZShCb3VuZENhbGxiYWNrT2JzZXJ2YWJsZS5kaXNwYXRjaCwgMCwgeyBzb3VyY2U6IHRoaXMsIHN1YnNjcmliZXI6IHN1YnNjcmliZXIgfSk7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIEJvdW5kQ2FsbGJhY2tPYnNlcnZhYmxlLmRpc3BhdGNoID0gZnVuY3Rpb24gKHN0YXRlKSB7XG4gICAgICAgIHZhciBzZWxmID0gdGhpcztcbiAgICAgICAgdmFyIHNvdXJjZSA9IHN0YXRlLnNvdXJjZSwgc3Vic2NyaWJlciA9IHN0YXRlLnN1YnNjcmliZXI7XG4gICAgICAgIHZhciBjYWxsYmFja0Z1bmMgPSBzb3VyY2UuY2FsbGJhY2tGdW5jLCBhcmdzID0gc291cmNlLmFyZ3MsIHNjaGVkdWxlciA9IHNvdXJjZS5zY2hlZHVsZXI7XG4gICAgICAgIHZhciBzdWJqZWN0ID0gc291cmNlLnN1YmplY3Q7XG4gICAgICAgIGlmICghc3ViamVjdCkge1xuICAgICAgICAgICAgc3ViamVjdCA9IHNvdXJjZS5zdWJqZWN0ID0gbmV3IEFzeW5jU3ViamVjdF8xLkFzeW5jU3ViamVjdCgpO1xuICAgICAgICAgICAgdmFyIGhhbmRsZXIgPSBmdW5jdGlvbiBoYW5kbGVyRm4oKSB7XG4gICAgICAgICAgICAgICAgdmFyIGlubmVyQXJncyA9IFtdO1xuICAgICAgICAgICAgICAgIGZvciAodmFyIF9pID0gMDsgX2kgPCBhcmd1bWVudHMubGVuZ3RoOyBfaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIGlubmVyQXJnc1tfaSAtIDBdID0gYXJndW1lbnRzW19pXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdmFyIHNvdXJjZSA9IGhhbmRsZXJGbi5zb3VyY2U7XG4gICAgICAgICAgICAgICAgdmFyIHNlbGVjdG9yID0gc291cmNlLnNlbGVjdG9yLCBzdWJqZWN0ID0gc291cmNlLnN1YmplY3Q7XG4gICAgICAgICAgICAgICAgaWYgKHNlbGVjdG9yKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciByZXN1bHRfMiA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2goc2VsZWN0b3IpLmFwcGx5KHRoaXMsIGlubmVyQXJncyk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHRfMiA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5hZGQoc2NoZWR1bGVyLnNjaGVkdWxlKGRpc3BhdGNoRXJyb3IsIDAsIHsgZXJyOiBlcnJvck9iamVjdF8xLmVycm9yT2JqZWN0LmUsIHN1YmplY3Q6IHN1YmplY3QgfSkpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5hZGQoc2NoZWR1bGVyLnNjaGVkdWxlKGRpc3BhdGNoTmV4dCwgMCwgeyB2YWx1ZTogcmVzdWx0XzIsIHN1YmplY3Q6IHN1YmplY3QgfSkpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBpbm5lckFyZ3MubGVuZ3RoID09PSAxID8gaW5uZXJBcmdzWzBdIDogaW5uZXJBcmdzO1xuICAgICAgICAgICAgICAgICAgICBzZWxmLmFkZChzY2hlZHVsZXIuc2NoZWR1bGUoZGlzcGF0Y2hOZXh0LCAwLCB7IHZhbHVlOiB2YWx1ZSwgc3ViamVjdDogc3ViamVjdCB9KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIC8vIHVzZSBuYW1lZCBmdW5jdGlvbiB0byBwYXNzIHZhbHVlcyBpbiB3aXRob3V0IGNsb3N1cmVcbiAgICAgICAgICAgIGhhbmRsZXIuc291cmNlID0gc291cmNlO1xuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2goY2FsbGJhY2tGdW5jKS5hcHBseSh0aGlzLCBhcmdzLmNvbmNhdChoYW5kbGVyKSk7XG4gICAgICAgICAgICBpZiAocmVzdWx0ID09PSBlcnJvck9iamVjdF8xLmVycm9yT2JqZWN0KSB7XG4gICAgICAgICAgIC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5cGUuX3N1YnNjcmliZSA9IGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgIHZhciBjYWxsYmFja0Z1bmMgPSB0aGlzLmNhbGxiYWNrRnVuYztcbiAgICAgICAgdmFyIGFyZ3MgPSB0aGlzLmFyZ3M7XG4gICAgICAgIHZhciBzY2hlZHVsZXIgPSB0aGlzLnNjaGVkdWxlcjtcbiAgICAgICAgdmFyIHN1YmplY3QgPSB0aGlzLnN1YmplY3Q7XG4gICAgICAgIGlmICghc2NoZWR1bGVyKSB7XG4gICAgICAgICAgICBpZiAoIXN1YmplY3QpIHtcbiAgICAgICAgICAgICAgICBzdWJqZWN0ID0gdGhpcy5zdWJqZWN0ID0gbmV3IEFzeW5jU3ViamVjdF8xLkFzeW5jU3ViamVjdCgpO1xuICAgICAgICAgICAgICAgIHZhciBoYW5kbGVyID0gZnVuY3Rpb24gaGFuZGxlckZuKCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgaW5uZXJBcmdzID0gW107XG4gICAgICAgICAgICAgICAgICAgIGZvciAodmFyIF9pID0gMDsgX2kgPCBhcmd1bWVudHMubGVuZ3RoOyBfaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpbm5lckFyZ3NbX2kgLSAwXSA9IGFyZ3VtZW50c1tfaV07XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgdmFyIHNvdXJjZSA9IGhhbmRsZXJGbi5zb3VyY2U7XG4gICAgICAgICAgICAgICAgICAgIHZhciBzZWxlY3RvciA9IHNvdXJjZS5zZWxlY3Rvciwgc3ViamVjdCA9IHNvdXJjZS5zdWJqZWN0O1xuICAgICAgICAgICAgICAgICAgICB2YXIgZXJyID0gaW5uZXJBcmdzLnNoaWZ0KCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YmplY3QuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIGlmIChzZWxlY3Rvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdF8xID0gdHJ5Q2F0Y2hfMS50cnlDYXRjaChzZWxlY3RvcikuYXBwbHkodGhpcywgaW5uZXJBcmdzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHRfMSA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YmplY3QuZXJyb3IoZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YmplY3QubmV4dChyZXN1bHRfMSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5uZXh0KGlubmVyQXJncy5sZW5ndGggPT09IDEgPyBpbm5lckFyZ3NbMF0gOiBpbm5lckFyZ3MpO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAvLyB1c2UgbmFtZWQgZnVuY3Rpb24gaW5zdGFuY2UgdG8gYXZvaWQgY2xvc3VyZS5cbiAgICAgICAgICAgICAgICBoYW5kbGVyLnNvdXJjZSA9IHRoaXM7XG4gICAgICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2goY2FsbGJhY2tGdW5jKS5hcHBseSh0aGlz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CBjb25uZWN0YWJsZSkge1xuICAgICAgICBfc3VwZXIuY2FsbCh0aGlzLCBkZXN0aW5hdGlvbik7XG4gICAgICAgIHRoaXMuY29ubmVjdGFibGUgPSBjb25uZWN0YWJsZTtcbiAgICB9XG4gICAgUmVmQ291bnRTdWJzY3JpYmVyLnByb3RvdHlwZS5fdW5zdWJzY3JpYmUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBjb25uZWN0YWJsZSA9IHRoaXMuY29ubmVjdGFibGU7XG4gICAgICAgIGlmICghY29ubmVjdGFibGUpIHtcbiAgICAgICAgICAgIHRoaXMuY29ubmVjdGlvbiA9IG51bGw7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5jb25uZWN0YWJsZSA9IG51bGw7XG4gICAgICAgIHZhciByZWZDb3VudCA9IGNvbm5lY3RhYmxlLl9yZWZDb3VudDtcbiAgICAgICAgaWYgKHJlZkNvdW50IDw9IDApIHtcbiAgICAgICAgICAgIHRoaXMuY29ubmVjdGlvbiA9IG51bGw7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgY29ubmVjdGFibGUuX3JlZkNvdW50ID0gcmVmQ291bnQgLSAxO1xuICAgICAgICBpZiAocmVmQ291bnQgPiAxKSB7XG4gICAgICAgICAgICB0aGlzLmNvbm5lY3Rpb24gPSBudWxsO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIC8vL1xuICAgICAgICAvLyBDb21wYXJlIHRoZSBsb2NhbCBSZWZDb3VudFN1YnNjcmliZXIncyBjb25uZWN0aW9uIFN1YnNjcmlwdGlvbiB0byB0aGVcbiAgICAgICAgLy8gY29ubmVjdGlvbiBTdWJzY3JpcHRpb24gb24gdGhlIHNoYXJlZCBDb25uZWN0YWJsZU9ic2VydmFibGUuIEluIGNhc2VzXG4gICAgICAgIC8vIHdoZXJlIHRoZSBDb25uZWN0YWJsZU9ic2VydmF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jcmliZXI6IHN1YnNjcmliZXIsXG4gICAgICAgICAgICAgICAgaXRlcmF0ZTogdGhpcy5pdGVyYXRlLFxuICAgICAgICAgICAgICAgIGNvbmRpdGlvbjogdGhpcy5jb25kaXRpb24sXG4gICAgICAgICAgICAgICAgcmVzdWx0U2VsZWN0b3I6IHRoaXMucmVzdWx0U2VsZWN0b3IsXG4gICAgICAgICAgICAgICAgc3RhdGU6IHN0YXRlIH0pO1xuICAgICAgICB9XG4gICAgICAgIHZhciBfYSA9IHRoaXMsIGNvbmRpdGlvbiA9IF9hLmNvbmRpdGlvbiwgcmVzdWx0U2VsZWN0b3IgPSBfYS5yZXN1bHRTZWxlY3RvciwgaXRlcmF0ZSA9IF9hLml0ZXJhdGU7XG4gICAgICAgIGRvIHtcbiAgICAgICAgICAgIGlmIChjb25kaXRpb24pIHtcbiAgICAgICAgICAgICAgICB2YXIgY29uZGl0aW9uUmVzdWx0ID0gdm9pZCAwO1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbmRpdGlvblJlc3VsdCA9IGNvbmRpdGlvbihzdGF0ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICghY29uZGl0aW9uUmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHZhbHVlID0gdm9pZCAwO1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICB2YWx1ZSA9IHJlc3VsdFNlbGVjdG9yKHN0YXRlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgIGlmIChzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBzdGF0ZSA9IGl0ZXJhdGUoc3RhdGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gd2hpbGUgKHRydWUpO1xuICAgIH07XG4gICAgR2VuZXJhdGVPYnNlcnZhYmxlLmRpc3BhdGNoID0gZnVuY3Rpb24gKHN0YXRlKSB7XG4gICAgICAgIHZhciBzdWJzY3JpYmVyID0gc3RhdGUuc3Vic2NyaWJlciwgY29uZGl0aW9uID0gc3RhdGUuY29uZGl0aW9uO1xuICAgICAgICBpZiAoc3Vic2NyaWJlci5jbG9zZWQpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAoc3RhdGUubmVlZEl0ZXJhdGUpIHtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgc3RhdGUuc3RhdGUgPSBzdGF0ZS5pdGVyYXRlKHN0YXRlLnN0YXRlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgc3RhdGUubmVlZEl0ZXJhdGUgPSB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIGlmIChjb25kaXRpb24pIHtcbiAgICAgICAgICAgIHZhciBjb25kaXRpb25SZXN1bHQgPSB2b2lkIDA7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIGNvbmRpdGlvblJlc3VsdCA9IGNvbmRpdGlvbihzdGF0ZS5zdGF0ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghY29uZGl0aW9uUmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB2YXIgdmFsdWU7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICB2YWx1ZSA9IHN0YXRlLnJlc3VsdFNlbGVjdG9yKHN0YXRlLnN0YXRlKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICBzdWJzY3JpYmVyLmVycm9yKGVycik7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN1YnNjcmliZXIuY2xvc2VkKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgc3Vic2NyaWJlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgaWYgKHN1YnNjcmli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liZXJcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSBpdGVyYXRvci5uZXh0KCk7XG4gICAgICAgICAgICAgICAgaWYgKHJlc3VsdC5kb25lKSB7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQocmVzdWx0LnZhbHVlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHN1YnNjcmliZXIuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gd2hpbGUgKHRydWUpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICByZXR1cm4gSXRlcmF0b3JPYnNlcnZhYmxlO1xufShPYnNlcnZhYmxlXzEuT2JzZXJ2YWJsZSkpO1xuZXhwb3J0cy5JdGVyYXRvck9ic2VydmFibGUgPSBJdGVyYXRvck9ic2VydmFibGU7XG52YXIgU3RyaW5nSXRlcmF0b3IgPSAoZnVuY3Rpb24gKCkge1xuICAgIGZ1bmN0aW9uIFN0cmluZ0l0ZXJhdG9yKHN0ciwgaWR4LCBsZW4pIHtcbiAgICAgICAgaWYgKGlkeCA9PT0gdm9pZCAwKSB7IGlkeCA9IDA7IH1cbiAgICAgICAgaWYgKGxlbiA9PT0gdm9pZCAwKSB7IGxlbiA9IHN0ci5sZW5ndGg7IH1cbiAgICAgICAgdGhpcy5zdHIgPSBzdHI7XG4gICAgICAgIHRoaXMuaWR4ID0gaWR4O1xuICAgICAgICB0aGlzLmxlbiA9IGxlbjtcbiAgICB9XG4gICAgU3RyaW5n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nNlcnZhYmxlLnByb3RvdHlwZS5fc3Vic2NyaWJlID0gZnVuY3Rpb24gKHN1YnNjcmliZXIpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgdmFyIHByb21pc2UgPSB0aGlzLnByb21pc2U7XG4gICAgICAgIHZhciBzY2hlZHVsZXIgPSB0aGlzLnNjaGVkdWxlcjtcbiAgICAgICAgaWYgKHNjaGVkdWxlciA9PSBudWxsKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5faXNTY2FsYXIpIHtcbiAgICAgICAgICAgICAgICBpZiAoIXN1YnNjcmliZXIuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dCh0aGlzLnZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHByb21pc2UudGhlbihmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMudmFsdWUgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMuX2lzU2NhbGFyID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAgICAgLnRoZW4obnVsbCwgZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgICAgICAvLyBlc2NhcGUgdGhlIHByb21pc2UgdHJhcCwgdGhyb3cgdW5oYW5kbGVkIGVycm9yc1xuICAgICAgICAgICAgICAgICAgICByb290XzEucm9vdC5zZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHsgdGhyb3cgZXJyOyB9KTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9pc1NjYWxhcikge1xuICAgICAgICAgICAgICAgIGlmICghc3Vic2NyaWJlci5jbG9zZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNjaGVkdWxlci5zY2hlZHVsZShkaXNwYXRjaE5leHQsIDAsIHsgdmFsdWU6IHRoaXMudmFsdWUsIHN1YnNjcmliZXI6IHN1YnNjcmliZXIgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgcHJvbWlzZS50aGVuKGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy52YWx1ZSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy5faXNTY2FsYXIgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICBpZiAoIXN1YnNjcmliZXIuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmFkZChzY2hlZHVsZXIuc2NoZWR1bGUoZGlzcGF0Y2hOZXh0LCAwLCB7IHZhbHVlOiB2YWx1ZSwgc3Vic2NyaWJlcjogc3Vic2NyaWJlciB9KSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB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ZW50aWFscyA9ICEhdGhpcy53aXRoQ3JlZGVudGlhbHM7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHhocjtcbiAgICB9XG4gICAgZWxzZSBpZiAoISFyb290XzEucm9vdC5YRG9tYWluUmVxdWVzdCkge1xuICAgICAgICByZXR1cm4gbmV3IHJvb3RfMS5yb290LlhEb21haW5SZXF1ZXN0KCk7XG4gICAgfVxuICAgIGVsc2Uge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0NPUlMgaXMgbm90IHN1cHBvcnRlZCBieSB5b3VyIGJyb3dzZXInKTtcbiAgICB9XG59XG5mdW5jdGlvbiBnZXRYTUxIdHRwUmVxdWVzdCgpIHtcbiAgICBpZiAocm9vdF8xLnJvb3QuWE1MSHR0cFJlcXVlc3QpIHtcbiAgICAgICAgcmV0dXJuIG5ldyByb290XzEucm9vdC5YTUxIdHRwUmVxdWVzdCgpO1xuICAgIH1cbiAgICBlbHNlIHtcbiAgICAgICAgdmFyIHByb2dJZCA9IHZvaWQgMDtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHZhciBwcm9nSWRzID0gWydNc3htbDIuWE1MSFRUUCcsICdNaWNyb3NvZnQuWE1MSFRUUCcsICdNc3htbDIuWE1MSFRUUC40LjAnXTtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgMzsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgcHJvZ0lkID0gcHJvZ0lkc1tpXTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG5ldyByb290XzEucm9vdC5BY3RpdmVYT2JqZWN0KHByb2dJZCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgIC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3aXRoQ3JlZGVudGlhbHM6IGZhbHNlLFxuICAgICAgICAgICAgaGVhZGVyczoge30sXG4gICAgICAgICAgICBtZXRob2Q6ICdHRVQnLFxuICAgICAgICAgICAgcmVzcG9uc2VUeXBlOiAnanNvbicsXG4gICAgICAgICAgICB0aW1lb3V0OiAwXG4gICAgICAgIH07XG4gICAgICAgIGlmICh0eXBlb2YgdXJsT3JSZXF1ZXN0ID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgcmVxdWVzdC51cmwgPSB1cmxPclJlcXVlc3Q7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBmb3IgKHZhciBwcm9wIGluIHVybE9yUmVxdWVzdCkge1xuICAgICAgICAgICAgICAgIGlmICh1cmxPclJlcXVlc3QuaGFzT3duUHJvcGVydHkocHJvcCkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVxdWVzdFtwcm9wXSA9IHVybE9yUmVxdWVzdFtwcm9wXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5yZXF1ZXN0ID0gcmVxdWVzdDtcbiAgICB9XG4gICAgQWpheE9ic2VydmFibGUucHJvdG90eXBlLl9zdWJzY3JpYmUgPSBmdW5jdGlvbiAoc3Vic2NyaWJlcikge1xuICAgICAgICByZXR1cm4gbmV3IEFqYXhTdWJzY3JpYmVyKHN1YnNjcmliZXIsIHRoaXMucmVxdWVzdCk7XG4gICAgfTtcbiAgICAvKipcbiAgICAgKiBDcmVhdGVzIGFuIG9ic2VydmFibGUgZm9yIGFuIEFqYXggcmVxdWVzdCB3aXRoIGVpdGhlciBhIHJlcXVlc3Qgb2JqZWN0IHdpdGhcbiAgICAgKiB1cmwsIGhlYWRlcnMsIGV0YyBvciBhIHN0cmluZyBmb3IgYSBVUkwuXG4gICAgICpcbiAgICAgKiBAZXhhbXBsZVxuICAgICAqIHNvdXJjZSA9IFJ4Lk9ic2VydmFibGUu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O1xuICAgICAgICAgICAgLy8gb3BlbiBYSFIgZmlyc3RcbiAgICAgICAgICAgIHZhciByZXN1bHQgPSB2b2lkIDA7XG4gICAgICAgICAgICBpZiAodXNlcikge1xuICAgICAgICAgICAgICAgIHJlc3VsdCA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2goeGhyLm9wZW4pLmNhbGwoeGhyLCBtZXRob2QsIHVybCwgYXN5bmMsIHVzZXIsIHBhc3N3b3JkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHJlc3VsdCA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2goeGhyLm9wZW4pLmNhbGwoeGhyLCBtZXRob2QsIHVybCwgYXN5bmMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHJlc3VsdCA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgIHRoaXMuZXJyb3IoZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIHRpbWVvdXQgYW5kIHJlc3BvbnNlVHlwZSBjYW4gYmUgc2V0IG9uY2UgdGhlIFhIUiBpcyBvcGVuXG4gICAgICAgICAgICB4aHIudGltZW91dCA9IHJlcXVlc3QudGltZW91dDtcbiAgICAgICAgICAgIHhoci5yZXNwb25zZVR5cGUgPSByZXF1ZXN0LnJlc3BvbnNlVHlwZTtcbiAgICAgICAgICAgIC8vIHNldCBoZWFkZXJzXG4gICAgICAgICAgICB0aGlzLnNldEhlYWRlcnMoeGhyLCBoZWFkZXJzKTtcbiAgICAgICAgICAgIC8vIG5vdyBzZXQgdXAgdGhlIGV2ZW50c1xuICAgICAgICAgICAgdGhpcy5zZXR1cEV2ZW50cyh4aHIsIHJlcXVlc3QpO1xuICAgICAgICAgICAgLy8gZmluYWxseSBzZW5kIHRoZSByZXF1ZXN0XG4gICAgICAgICAgICBpZiAoYm9keSkge1xuICAgICAgICAgICAgICAgIHhoci5zZW5kKGJvZHkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgeGhyLnNlbmQoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4geGhyO1xuICAgIH07XG4gICAgQWpheFN1YnNjcmliZXIucHJvdG90eXBlLnNlcmlhbGl6ZUJvZHkgPSBmdW5jdGlvbiAoYm9keSwgY29udGVudFR5cGUpIHtcbiAgICAgICAgaWYgKCFib2R5IHx8IHR5cGVvZiBib2R5ID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgcmV0dXJuIGJvZHk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAocm9vdF8xLnJvb3QuRm9ybURhdGEgJiYgYm9keSBpbnN0YW5jZW9mIHJvb3RfMS5yb290LkZvcm1EYXRhKSB7XG4gICAgICAgICAgICByZXR1cm4gYm9keTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoY29udGVudFR5cGUpIHtcbiAgICAgICAgICAgIHZhciBzcGxpdEluZGV4ID0gY29udGVudFR5cGUuaW5kZXhPZignOycpO1xuICAgICAgICAgICAgaWYgKHNwbGl0SW5kZXggIT09IC0xKSB7XG4gICAgICAgICAgICAgICAgY29udGVudFR5cGUgPSBjb250ZW50VHlwZS5zdWJzdHJpbmcoMCwgc3BsaXRJbmRleCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgc3dpdGNoIChjb250ZW50VHlwZSkge1xuICAgICAgICAgICAgY2FzZSAnYXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVkJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmtleXMoYm9keSkubWFwKGZ1bmN0aW9uIChrZXkpIHsgcmV0dXJuIChlbmNvZGVVUkkoa2V5KSArIFwiPVwiICs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A9PT0gJ3RleHQnID8gKHRoaXMucmVzcG9uc2UgfHwgdGhpcy5yZXNwb25zZVRleHQpIDogdGhpcy5yZXNwb25zZSk7XG4gICAgICAgICAgICAgICAgLy8gZml4IHN0YXR1cyBjb2RlIHdoZW4gaXQgaXMgMCAoMCBzdGF0dXMgaXMgdW5kb2N1bWVudGVkKS5cbiAgICAgICAgICAgICAgICAvLyBPY2N1cnMgd2hlbiBhY2Nlc3NpbmcgZmlsZSByZXNvdXJjZXMgb3Igb24gQW5kcm9pZCA0LjEgc3RvY2sgYnJvd3NlclxuICAgICAgICAgICAgICAgIC8vIHdoaWxlIHJldHJpZXZpbmcgZmlsZXMgZnJvbSBhcHBsaWNhdGlvbiBjYWNoZS5cbiAgICAgICAgICAgICAgICBpZiAoc3RhdHVzXzEgPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzXzEgPSByZXNwb25zZSA/IDIwMCA6IDA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICgyMDAgPD0gc3RhdHVzXzEgJiYgc3RhdHVzXzEgPCAzMDApIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHByb2dyZXNzU3Vic2NyaWJlcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NTdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KGUpO1xuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBpZiAocHJvZ3Jlc3NTdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc1N1YnNjcmliZXIuZXJyb3IoZSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAg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B7XG4gICAgICAgICAgICAgICAgLy8gV0FSTklORzogY29uZmlnIG9iamVjdCBjb3VsZCBvdmVycmlkZSBpbXBvcnRhbnQgbWVtYmVycyBoZXJlLlxuICAgICAgICAgICAgICAgIGFzc2lnbl8xLmFzc2lnbih0aGlzLCB1cmxDb25maWdPclNvdXJjZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIXRoaXMuV2ViU29ja2V0Q3Rvcikge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignbm8gV2ViU29ja2V0IGNvbnN0cnVjdG9yIGNhbiBiZSBmb3VuZCcpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5kZXN0aW5hdGlvbiA9IG5ldyBSZXBsYXlTdWJqZWN0XzEuUmVwbGF5U3ViamVjdCgpO1xuICAgICAgICB9XG4gICAgfVxuICAgIFdlYlNvY2tldFN1YmplY3QucHJvdG90eXBlLnJlc3VsdFNlbGVjdG9yID0gZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgcmV0dXJuIEpTT04ucGFyc2UoZS5kYXRhKTtcbiAgICB9O1xuICAgIC8qKlxuICAgICAqIEBwYXJhbSB1cmxDb25maWdPclNvdXJjZVxuICAgICAqIEByZXR1cm4ge1dlYlNvY2tldFN1YmplY3R9XG4gICAgICogQHN0YXRpYyB0cnVlXG4gICAgICogQG5hbWUgd2ViU29ja2V0XG4gICAgICogQG93bmVyIE9ic2VydmFibGVcbiAgICAgKi9cbiAgICBXZWJTb2NrZXRTdWJqZWN0LmNyZWF0ZSA9IGZ1bmN0aW9uICh1cmxDb25maWdPclNvdXJjZSkge1xuICAgICAgICByZXR1cm4gbmV3IFdlYlNvY2tldFN1YmplY3QodXJsQ29uZmlnT3JTb3VyY2UpO1xuICAgIH07XG4gICAgV2ViU29ja2V0U3ViamVjdC5wcm90b3R5cGUubGlmdCA9IGZ1bmN0aW9uIChvcGVyYXRvcikge1xuICAgICAgICB2YXIgc29jayA9IG5ldyB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yT2JqZWN0KSB7XG4gICAgICAgICAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QuZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2UgaWYgKHJlc3VsdCkge1xuICAgICAgICAgICAgICAgICAgICBvYnNlcnZlci5uZXh0KHgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChlcnIpIHsgcmV0dXJuIG9ic2VydmVyLmVycm9yKGVycik7IH0sIGZ1bmN0aW9uICgpIHsgcmV0dXJuIG9ic2VydmVyLmNvbXBsZXRlKCk7IH0pO1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gdHJ5Q2F0Y2hfMS50cnlDYXRjaCh1bnN1Yk1zZykoKTtcbiAgICAgICAgICAgICAgICBpZiAocmVzdWx0ID09PSBlcnJvck9iamVjdF8xLmVycm9yT2JqZWN0KSB7XG4gICAgICAgICAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QuZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLm5leHQocmVzdWx0KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9KTtcbiAgICB9O1xuICAgIFdlYlNvY2tldFN1YmplY3QucHJvdG90eXBlLl9jb25uZWN0U29ja2V0ID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICB2YXIgV2ViU29ja2V0Q3RvciA9IHRoaXMuV2ViU29ja2V0Q3RvcjtcbiAgICAgICAgdmFyIG9ic2VydmVyID0gdGhpcy5fb3V0cHV0O1xuICAgICAgICB2YXIgc29ja2V0ID0gbnVsbDtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHNvY2tldCA9IHRoaXMucHJvdG9jb2wgP1xuICAgICAgICAgICAgICAgIG5ldyBXZWJTb2NrZXRDdG9yKHRoaXMudXJsLCB0aGlzLnByb3RvY29sKSA6XG4gICAgICAgICAgICAgICAgbmV3IFdlYlNvY2tldEN0b3IodGhpcy51cmwpO1xuICAgICAgICAgICAgdGhpcy5zb2NrZXQgPSBzb2NrZXQ7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKGUpO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHZhciBzdWJzY3JpcHRpb24gPSBuZXcgU3Vic2NyaXB0aW9uXzEuU3Vic2NyaXB0aW9uKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIF90aGlzLnNvY2tldCA9IG51bGw7XG4gICAgICAgICAgICBpZiAoc29ja2V0ICYmIHNvY2tldC5yZWFkeVN0YXRlID09PSAxKSB7XG4gICAgICAgICAgICAgICAgc29ja2V0LmNsb3NlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICBzb2NrZXQub25vcGVuID0gZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgICAgIHZhciBvcGVuT2JzZXJ2ZXIgPSBfdGhpcy5vcGVuT2JzZXJ2ZXI7XG4gICAgICAgICAgICBpZiAob3Blbk9ic2VydmVyKSB7XG4gICAgICAgICAgICAgICAgb3Blbk9ic2VydmVyLm5leHQoZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgcXVldWUgPSBfdGhpcy5kZXN0aW5hdGlvbjtcbiAgICAgICAgICAgIF90aGlzLmRlc3RpbmF0aW9uID0gU3Vic2NyaWJlcl8xLlN1YnNjcmliZXIuY3JlYXRlKGZ1bmN0aW9uICh4KSB7IHJldHVybiBzb2NrZXQucmVhZHlTdGF0ZSA9PT0gMSAmJiBzb2NrZXQuc2VuZCh4KTsgfSwgZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgICAgICAgICB2YXIgY2xvc2luZ09ic2VydmVyID0gX3RoaXMuY2xvc2luZ09ic2VydmVyO1xuICAgICAgICAgICAgICAgIGlmIChjbG9zaW5nT2JzZXJ2ZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgY2xvc2luZ09ic2VydmVyLm5leHQodW5kZWZpbmVkKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGUgJiYgZS5jb2RlKSB7XG4gICAgICAgICAgICAgICAgICAgIHNvY2tldC5jbG9zZShlLmNvZGUsIGUucmVhc29uKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKG5ldyBUeXBlRXJyb3IoJ1dlYlNvY2tldFN1YmplY3QuZXJyb3IgbXVzdCBiZSBjYWxsZWQgd2l0aCBhbiBvYmplY3Qgd2l0aCBhbiBlcnJvciBjb2RlLCAnICtcbiAgICAgICAgICAgICAgICAgICAgICAgICdhbmQgYW4gb3B0aW9uYWwgcmVhc29uOiB7IGNvZGU6IG51bWJlciwgcmVhc29uOiBzdHJpbmcgfScpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgX3RoaXMuZGVzdGluYXRpb24gPSBuZXcgUmVwbGF5U3ViamVjdF8xLlJlcGxheVN1YmplY3QoKTtcbiAgICAgICAgICAgICAgICBfdGhpcy5zb2NrZXQgPSBudWxsO1xuICAgICAgICAgICAgfSwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIHZhciBjbG9zaW5nT2JzZXJ2ZXIgPSBfdGhpcy5jbG9zaW5nT2JzZXJ2ZXI7XG4gICAgICAgICAgICAgICAgaWYgKGNsb3NpbmdPYnNlcnZlcikge1xuICAgICAgICAgICAgICAgICAgICBjbG9zaW5nT2JzZXJ2ZXIubmV4dCh1bmRlZmluZWQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzb2NrZXQuY2xvc2UoKTtcbiAgICAgICAgICAgICAgICBfdGhpcy5kZXN0aW5hdGlvbiA9IG5ldyBSZXBsYXlTdWJqZWN0XzEuUmVwbGF5U3ViamVjdCgpO1xuICAgICAgICAgICAgICAgIF90aGlzLnNvY2tldCA9IG51bGw7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGlmIChxdWV1ZSAmJiBxdWV1ZSBpbnN0YW5jZW9mIFJlcGxheVN1YmplY3RfMS5SZXBsYXlTdWJqZWN0KSB7XG4gICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uLmFkZChxdWV1ZS5zdWJzY3JpYmUoX3RoaXMuZGVzdGluYXRpb24pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgc29ja2V0Lm9uZXJyb3IgPSBmdW5jdGlvbiAoZSkgeyByZXR1cm4gb2JzZXJ2ZXIuZXJyb3IoZSk7IH07XG4gICAgICAgIHNvY2tldC5vbmNsb3NlID0gZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgICAgIHZhciBjbG9zZU9ic2VydmVyID0gX3RoaXMuY2xvc2VPYnNlcnZlcjtcbiAgICAgICAgICAgIGlmIChjbG9zZU9ic2VydmVyKSB7XG4gICAgICAgICAgICAgICAgY2xvc2VPYnNlcnZlci5uZXh0KGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGUud2FzQ2xlYW4pIHtcbiAgICAgICAgICAgICAgICBvYnNlcnZlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgb2JzZXJ2ZXIuZXJyb3IoZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICAgIHNvY2tldC5vbm1lc3NhZ2UgPSBmdW5jdGlvbiAoZSkge1xuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2goX3RoaXMucmVzdWx0U2VsZWN0b3IpKGUpO1xuICAgICAgICAgICAgaWYgKHJlc3VsdCA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QuZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBvYnNlcnZlci5uZXh0KHJlc3VsdCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfTtcbiAgICBXZWJTb2NrZXRTdWJqZWN0LnByb3RvdHlwZS5fc3Vic2NyaWJlID0gZnVuY3Rpb24gKHN1YnNjcmliZXIpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgdmFyIHNvdXJjZSA9IHRoaXMuc291cmNlO1xuICAgICAgICBpZiAoc291cmNlKSB7XG4gICAgICAgICAgICByZXR1cm4gc291cmNlLnN1YnNjcmliZShzdWJzY3JpYmVyKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXRoaXMuc29ja2V0KSB7XG4gICAgICAgICAgICB0aGlzLl9jb25uZWN0U29ja2V0KCk7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHN1YnNjcmlwdGlvbiA9IG5ldyBTdWJzY3JpcHRpb25fMS5TdWJzY3JpcHRpb24oKTtcbiAgICAgICAgc3Vic2NyaXB0aW9uLmFkZCh0aGlzLl9vdXRwdXQuc3Vic2NyaWJlKHN1YnNjcmliZXIpKTtcbiAgICAgICAgc3Vic2NyaXB0aW9uLmFkZChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgc29ja2V0ID0gX3RoaXMuc29ja2V0O1xuICAgIC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bnRleHRzO1xuICAgICAgICB2YXIgbGVuID0gY29udGV4dHMubGVuZ3RoO1xuICAgICAgICB2YXIgZmlsbGVkQnVmZmVyQ29udGV4dDtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgICAgdmFyIGNvbnRleHQgPSBjb250ZXh0c1tpXTtcbiAgICAgICAgICAgIHZhciBidWZmZXIgPSBjb250ZXh0LmJ1ZmZlcjtcbiAgICAgICAgICAgIGJ1ZmZlci5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgIGlmIChidWZmZXIubGVuZ3RoID09IHRoaXMubWF4QnVmZmVyU2l6ZSkge1xuICAgICAgICAgICAgICAgIGZpbGxlZEJ1ZmZlckNvbnRleHQgPSBjb250ZXh0O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChmaWxsZWRCdWZmZXJDb250ZXh0KSB7XG4gICAgICAgICAgICB0aGlzLm9uQnVmZmVyRnVsbChmaWxsZWRCdWZmZXJDb250ZXh0KTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgQnVmZmVyVGltZVN1YnNjcmliZXIucHJvdG90eXBlLl9lcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgdGhpcy5jb250ZXh0cy5sZW5ndGggPSAwO1xuICAgICAgICBfc3VwZXIucHJvdG90eXBlLl9lcnJvci5jYWxsKHRoaXMsIGVycik7XG4gICAgfTtcbiAgICBCdWZmZXJUaW1lU3Vic2NyaWJlci5wcm90b3R5cGUuX2NvbXBsZXRlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgX2EgPSB0aGlzLCBjb250ZXh0cyA9IF9hLmNvbnRleHRzLCBkZXN0aW5hdGlvbiA9IF9hLmRlc3RpbmF0aW9uO1xuICAgICAgICB3aGlsZSAoY29udGV4dHMubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgdmFyIGNvbnRleHQgPSBjb250ZXh0cy5zaGlmdC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sIGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgICAgICAgICB2YXIgcyA9IHN1YmplY3Q7XG4gICAgICAgICAgICAgICAgc3ViamVjdCA9IG51bGw7XG4gICAgICAgICAgICAgICAgcy5lcnJvcihlcnIpO1xuICAgICAgICAgICAgfSwgZnVuY3Rpb24gKCkgeyByZXR1cm4gc3ViamVjdC5jb21wbGV0ZSgpOyB9KTtcbiAgICAgICAgfVxuICAgICAgICByZWZzKys7XG4gICAgICAgIGlmICghc3ViamVjdCkge1xuICAgICAgICAgICAgc3ViamVjdCA9IGdldFN1YmplY3QoKTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgaW5uZXJTdWIgPSBzdWJqZWN0LnN1YnNjcmliZShvYnNlcnZlcik7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICByZWZzLS07XG4gICAgICAgICAgICBpZiAoaW5uZXJTdWIpIHtcbiAgICAgICAgICAgICAgICBpbm5lclN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHJlZnMgPT09IDApIHtcbiAgICAgICAgICAgICAgICBvdXRlclN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH0pO1xufVxuZXhwb3J0cy5jYWNoZSA9IGNhY2hlO1xuLy8jIHNvdXJjZU1hcHBpbmdVUkw9Y2FjaGUuanMubWFwIiwiXCJ1c2Ugc3RyaWN0XCI7XG52YXIgX19leHRlbmRzID0gKHRoaXMgJiYgdGhpcy5fX2V4dGVuZHMpIHx8IGZ1bmN0aW9uIChkLCBiKSB7XG4gICAgZm9yICh2YXIgcCBpbiBiKSBpZiAoYi5oYXNPd25Qcm9wZXJ0eShwKSkgZFtwXSA9IGJbcF07XG4gICAgZnVuY3Rpb24gX18oKSB7IHRoaXMuY29uc3RydWN0b3IgPSBkOyB9XG4gICAgZC5wcm90b3R5cGUgPSBiID09PSBudWxsID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pbm5lclN1Yikge1xuICAgICAgICB2YXIgdmFsdWVzID0gdGhpcy52YWx1ZXM7XG4gICAgICAgIHZhciBvbGRWYWwgPSB2YWx1ZXNbb3V0ZXJJbmRleF07XG4gICAgICAgIHZhciB0b1Jlc3BvbmQgPSAhdGhpcy50b1Jlc3BvbmRcbiAgICAgICAgICAgID8gMFxuICAgICAgICAgICAgOiBvbGRWYWwgPT09IG5vbmUgPyAtLXRoaXMudG9SZXNwb25kIDogdGhpcy50b1Jlc3BvbmQ7XG4gICAgICAgIHZhbHVlc1tvdXRlckluZGV4XSA9IGlubmVyVmFsdWU7XG4gICAgICAgIGlmICh0b1Jlc3BvbmQgPT09IDApIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnByb2plY3QpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90cnlQcm9qZWN0KHZhbHVlcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLmRlc3RpbmF0aW9uLm5leHQodmFsdWVzLnNsaWNlKCkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbiAgICBDb21iaW5lTGF0ZXN0U3Vic2NyaWJlci5wcm90b3R5cGUuX3RyeVByb2plY3QgPSBmdW5jdGlvbiAodmFsdWVzKSB7XG4gICAgICAgIHZhciByZXN1bHQ7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICByZXN1bHQgPSB0aGlzLnByb2plY3QuYXBwbHkodGhpcywgdmFsdWVzKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICB0aGlzLmRlc3RpbmF0aW9uLmVycm9yKGVycik7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5uZXh0KHJlc3VsdCk7XG4gICAgfTtcbiAgICByZXR1cm4gQ29tYmluZUxhdGVzdFN1YnNjcmliZXI7XG59KE91dG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ubGVuZ3RoID0gMDtcbiAgICB9O1xuICAgIERpc3RpbmN0U3Vic2NyaWJlci5wcm90b3R5cGUubm90aWZ5RXJyb3IgPSBmdW5jdGlvbiAoZXJyb3IsIGlubmVyU3ViKSB7XG4gICAgICAgIHRoaXMuX2Vycm9yKGVycm9yKTtcbiAgICB9O1xuICAgIERpc3RpbmN0U3Vic2NyaWJlci5wcm90b3R5cGUuX25leHQgPSBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgdmFyIGZvdW5kID0gZmFsc2U7XG4gICAgICAgIHZhciB2YWx1ZXMgPSB0aGlzLnZhbHVlcztcbiAgICAgICAgdmFyIGxlbiA9IHZhbHVlcy5sZW5ndGg7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuY29tcGFyZSh2YWx1ZXNbaV0sIHZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5lcnJvcihlcnIpO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMudmFsdWVzLnB1c2godmFsdWUpO1xuICAgICAgICB0aGlzLmRlc3RpbmF0aW9uLm5leHQodmFsdWUpO1xuICAgIH07XG4gICAgRGlzdGluY3RTdWJzY3JpYmVyLnByb3RvdHlwZS5jb21wYXJlID0gZnVuY3Rpb24gKHgsIHkpIHtcbiAgICAgICAgcmV0dXJuIHggPT09IHk7XG4gICAgfTtcbiAgICByZXR1cm4gRGlzdGluY3RTdWJzY3JpYmVyO1xufShPdXRlclN1YnNjcmliZXJfMS5PdXRlclN1YnNjc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V0dXJuIHggPT09IHk7XG4gICAgfTtcbiAgICBEaXN0aW5jdFVudGlsQ2hhbmdlZFN1YnNjcmliZXIucHJvdG90eXBlLl9uZXh0ID0gZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgIHZhciBrZXlTZWxlY3RvciA9IHRoaXMua2V5U2VsZWN0b3I7XG4gICAgICAgIHZhciBrZXkgPSB2YWx1ZTtcbiAgICAgICAgaWYgKGtleVNlbGVjdG9yKSB7XG4gICAgICAgICAgICBrZXkgPSB0cnlDYXRjaF8xLnRyeUNhdGNoKHRoaXMua2V5U2VsZWN0b3IpKHZhbHVlKTtcbiAgICAgICAgICAgIGlmIChrZXkgPT09IGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kZXN0aW5hdGlvbi5lcnJvcihlcnJvck9iamVjdF8xLmVycm9yT2JqZWN0LmUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHZhciByZXN1bHQgPSBmYWxzZTtcbiAgICAgICAgaWYgKHRoaXMuaGFzS2V5KSB7XG4gICAgICAgICAgICByZXN1bHQgPSB0cnlDYXRjaF8xLnRyeUNhdGNoKHRoaXMuY29tcGFyZSkodGhpcy5rZXksIGtleSk7XG4gICAgICAgICAgICBpZiAocmVzdWx0ID09PSBlcnJvck9iamVjdF8xLmVycm9yT2JqZWN0KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGVzdGluYXRpb24uZXJyb3IoZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuaGFzS2V5ID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoQm9vbGVhbihyZXN1bHQpID09PSBmYWxzZSkge1xuICAgICAgICAgICAgdGhpcy5rZXkgPSBrZXk7XG4gICAgICAgICA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nByZWRpY2F0ZSh2YWx1ZSwgaW5kZXgsIHRoaXMuc291cmNlKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICB0aGlzLmRlc3RpbmF0aW9uLmVycm9yKGVycik7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHJlc3VsdCkge1xuICAgICAgICAgICAgdGhpcy5fZW1pdCh2YWx1ZSwgaW5kZXgpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBGaXJzdFN1YnNjcmliZXIucHJvdG90eXBlLl9lbWl0ID0gZnVuY3Rpb24gKHZhbHVlLCBpbmRleCkge1xuICAgICAgICBpZiAodGhpcy5yZXN1bHRTZWxlY3Rvcikge1xuICAgICAgICAgICAgdGhpcy5fdHJ5UmVzdWx0U2VsZWN0b3IodmFsdWUsIGluZGV4KTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9lbWl0RmluYWwodmFsdWUpO1xuICAgIH07XG4gICAgRmlyc3RTdWJzY3JpYmVyLnByb3RvdHlwZS5fdHJ5UmVzdWx0U2VsZWN0b3IgPSBmdW5jdGlvbiAodmFsdWUsIGluZGV4KSB7XG4gICAgICAgIHZhciByZXN1bHQ7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICByZXN1bHQgPSB0aGlzLnJlc3VsdFNlbGVjdG9yKHZhbHVlLCBpbmRleCk7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5lcnJvcihlcnIpO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX2VtaXRGaW5hbChyZXN1bHQpO1xuICAgIH07XG4gICAgRmlyc3RTdWJzY3JpYmVyLnByb3RvdHlwZS5fZW1pdEZpbmFsID0gZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAg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WVudFNlbGVjdG9yKSB7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIGVsZW1lbnQgPSB0aGlzLmVsZW1lbnRTZWxlY3Rvcih2YWx1ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5lcnJvcihlcnIpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgZWxlbWVudCA9IHZhbHVlO1xuICAgICAgICB9XG4gICAgICAgIGlmICghZ3JvdXApIHtcbiAgICAgICAgICAgIGdyb3Vwcy5zZXQoa2V5LCBncm91cCA9IG5ldyBTdWJqZWN0XzEuU3ViamVjdCgpKTtcbiAgICAgICAgICAgIHZhciBncm91cGVkT2JzZXJ2YWJsZSA9IG5ldyBHcm91cGVkT2JzZXJ2YWJsZShrZXksIGdyb3VwLCB0aGlzKTtcbiAgICAgICAgICAgIHRoaXMuZGVzdGluYXRpb24ubmV4dChncm91cGVkT2JzZXJ2YWJsZSk7XG4gICAgICAgICAgICBpZiAodGhpcy5kdXJhdGlvblNlbGVjdG9yKSB7XG4gICAgICAgICAgICAgICAgdmFyIGR1cmF0aW9uID0gdm9pZCAwO1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGR1cmF0aW9uID0gdGhpcy5kdXJhdGlvblNlbGVjdG9yKG5ldyBHcm91cGVkT2JzZXJ2YWJsZShrZXksIGdyb3VwKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuYWRkKGR1cmF0aW9uLnN1YnNjcmliZShuZXcgR3JvdXBEdXJhdGlvblN1YnNjcmliZXIoa2V5LCBncm91cCwgdGhpcykpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoIWdyb3VwLmNsb3NlZCkge1xuICAgICAgICAgICAgZ3JvdXAubmV4dChlbGVtZW50KTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgR3JvdXBCeVN1YnNjcmliZXIucHJvdG90eXBlLl9lcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgdmFyIGdyb3VwcyA9IHRoaXMuZ3JvdXBzO1xuICAgICAgICBpZiAoZ3JvdXBzKSB7XG4gICAgICAgICAgICBncm91cHMuZm9yRWFjaChmdW5jdGlvbiAoZ3JvdXAsIGtleSkge1xuICAgICAgICAgICAgICAgIGdyb3VwLmVycm9yKGVycik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGdyb3Vwcy5jbGVhcigpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuZGVzdGluYXRpb24uZXJyb3IoZXJyKTtcbiAgICB9O1xuICAgIEdyb3VwQnlTdWJzY3JpYmVyLnByb3RvdHlwZS5fY29tcGxldGUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBncm91cHMgPSB0aGlzLmdyb3VwcztcbiAgICAgICAgaWYgKGdyb3Vwcykge1xuICAgICAgICAgICAgZ3JvdXBzLmZvckVhY2goZnVuY3Rpb24gKGdyb3VwLCBrZXkpIHtcbiAgICAgICAgICAgICAgICBncm91cC5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBncm91cHMuY2xlYXIoKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLmRlc3RpbmF0aW9uLmNvbXBsZXRlKCk7XG4gICAgfTtcbiAgICBHcm91cEJ5U3Vic2NyaWJlci5wcm90b3R5cGUucmVtb3ZlR3JvdXAgPSBmdW5jdGlvbiAoa2V5KSB7XG4gICAgICAgIHRoaXMuZ3JvdXBzLmRlbGV0ZShrZXkpO1x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N0b3IpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90cnlSZXN1bHRTZWxlY3Rvcih2YWx1ZSwgaW5kZXgpO1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMubGFzdFZhbHVlID0gdmFsdWU7XG4gICAgICAgICAgICB0aGlzLmhhc1ZhbHVlID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgTGFzdFN1YnNjcmliZXIucHJvdG90eXBlLl90cnlQcmVkaWNhdGUgPSBmdW5jdGlvbiAodmFsdWUsIGluZGV4KSB7XG4gICAgICAgIHZhciByZXN1bHQ7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICByZXN1bHQgPSB0aGlzLnByZWRpY2F0ZSh2YWx1ZSwgaW5kZXgsIHRoaXMuc291cmNlKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICB0aGlzLmRlc3RpbmF0aW9uLmVycm9yKGVycik7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHJlc3VsdCkge1xuICAgICAgICAgICAgaWYgKHRoaXMucmVzdWx0U2VsZWN0b3IpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90cnlSZXN1bHRTZWxlY3Rvcih2YWx1ZSwgaW5kZXgpO1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMubGFzdFZhbHVlID0gdmFsdWU7XG4gICAgICAgICAgICB0aGlzLmhhc1ZhbHVlID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgTGFzdFN1YnNjcmliZXIucHJvdG90eXBlLl90cnlSZXN1bHRTZWxlY3RvciA9IGZ1bmN0aW9uICh2YWx1ZSwgaW5kZXgpIHtcbiAgICAgICAgdmFyIHJlc3VsdDtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICA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gPSBbXTtcbiAgICAgICAgdGhpcy5zdWJzY3JpcHRpb25zID0gW107XG4gICAgfVxuICAgIFJhY2VTdWJzY3JpYmVyLnByb3RvdHlwZS5fbmV4dCA9IGZ1bmN0aW9uIChvYnNlcnZhYmxlKSB7XG4gICAgICAgIHRoaXMub2JzZXJ2YWJsZXMucHVzaChvYnNlcnZhYmxlKTtcbiAgICB9O1xuICAgIFJhY2VTdWJzY3JpYmVyLnByb3RvdHlwZS5fY29tcGxldGUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBvYnNlcnZhYmxlcyA9IHRoaXMub2JzZXJ2YWJsZXM7XG4gICAgICAgIHZhciBsZW4gPSBvYnNlcnZhYmxlcy5sZW5ndGg7XG4gICAgICAgIGlmIChsZW4gPT09IDApIHtcbiAgICAgICAgICAgIHRoaXMuZGVzdGluYXRpb24uY29tcGxldGUoKTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbGVuOyBpKyspIHtcbiAgICAgICAgICAgICAgICB2YXIgb2JzZXJ2YWJsZSA9IG9ic2VydmFibGVzW2ldO1xuICAgICAgICAgICAgICAgIHZhciBzdWJzY3JpcHRpb24gPSBzdWJzY3JpYmVUb1Jlc3VsdF8xLnN1YnNjcmliZVRvUmVzdWx0KHRoaXMsIG9ic2VydmFibGUsIG9ic2VydmFibGUsIGkpO1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLnN1YnNjcmlwdGlvbnMpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zdWJzY3JpcHRpb25zLnB1c2goc3Vic2NyaXB0aW9uKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGQoc3Vic2NyaXB0aW9uKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLm9ic2VydmFibGVzID0gbnVsbDtcbiAgICAgICAgfVxuICAgIH07XG4gICAgUmFj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yA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2godGhpcy5ub3RpZmllcikobm90aWZpY2F0aW9ucyk7XG4gICAgICAgICAgICAgICAgaWYgKHJldHJpZXMgPT09IGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9zdXBlci5wcm90b3R5cGUuY29tcGxldGUuY2FsbCh0aGlzKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0cmllc1N1YnNjcmlwdGlvbiA9IHN1YnNjcmliZVRvUmVzdWx0XzEuc3Vic2NyaWJlVG9SZXN1bHQodGhpcywgcmV0cmllcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLm5vdGlmaWNhdGlvbnMgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMucmV0cmllc1N1YnNjcmlwdGlvbiA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB0aGlzLmNsb3NlZCA9IGZhbHNlO1xuICAgICAgICAgICAgdGhpcy5ub3RpZmljYXRpb25zID0gbm90aWZpY2F0aW9ucztcbiAgICAgICAgICAgIHRoaXMucmV0cmllcyA9IHJldHJpZXM7XG4gICAgICAgICAgICB0aGlzLnJldHJpZXNTdWJzY3JpcHRpb24gPSByZXRyaWVzU3Vic2NyaXB0aW9uO1xuICAgICAgICAgICAgbm90aWZpY2F0aW9ucy5uZXh0KCk7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFJlcGVhdFdoZW5TdWJzY3JpYmVyLnByb3RvdHlwZS5fdW5zdWJzY3JpYmUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBfYSA9IHRoaXMsIG5vdGlmaWNhdGlvbnMgPSBfYS5ub3RpZmljYXRpb25zLCByZXRyaWVzU3Vic2NyaXB0aW9uID0g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ICB9XG4gICAgUmV0cnlTdWJzY3JpYmVyLnByb3RvdHlwZS5lcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgaWYgKCF0aGlzLmlzU3RvcHBlZCkge1xuICAgICAgICAgICAgdmFyIF9hID0gdGhpcywgc291cmNlID0gX2Euc291cmNlLCBjb3VudCA9IF9hLmNvdW50O1xuICAgICAgICAgICAgaWYgKGNvdW50ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF9zdXBlci5wcm90b3R5cGUuZXJyb3IuY2FsbCh0aGlzLCBlcnIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSBpZiAoY291bnQgPiAtMSkge1xuICAgICAgICAgICAgICAgIHRoaXMuY291bnQgPSBjb3VudCAtIDE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB0aGlzLmlzU3RvcHBlZCA9IGZhbHNlO1xuICAgICAgICAgICAgdGhpcy5jbG9zZWQgPSBmYWxzZTtcbiAgICAgICAgICAgIHNvdXJjZS5zdWJzY3JpYmUodGhpcyk7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIHJldHVybiBSZXRyeVN1YnNjcmliZXI7XG59KFN1YnNjcmliZXJfMS5TdWJzY3JpYmVyKSk7XG4vLyMgc291cmNlTWFwcGluZ1VSTD1yZXRyeS5qcy5tYXAiLCJcInVzZSBzdHJpY3RcIjtcbnZhciBfX2V4dGVuZHMgPSAodGhpcyAmJiB0aGlzLl9fZXh0ZW5kcykgfHwgZnVuY3Rpb24gKGQsIGIpIHtcbiAgICBmb3IgKHZhciBwIGluIGIpIGlmIChiLmhhc093blByb3BlcnR5KHApKSBkW3BdID0gYltwXTtcbiAgICBmdW5jdGlvbiBfXygpIHsgdGhpcy5jb25zdHJ1Y3RvciA9IGQ7IH1cbiAgICBkLnByb3RvdHlwZSA9IGIgPT09IG51bGwgPyBPYmplY3QuY3JlYXR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5Q2F0Y2godGhpcy5ub3RpZmllcikoZXJyb3JzKTtcbiAgICAgICAgICAgICAgICBpZiAocmV0cmllcyA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3N1cGVyLnByb3RvdHlwZS5lcnJvci5jYWxsKHRoaXMsIGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QuZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHJpZXNTdWJzY3JpcHRpb24gPSBzdWJzY3JpYmVUb1Jlc3VsdF8xLnN1YnNjcmliZVRvUmVzdWx0KHRoaXMsIHJldHJpZXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5lcnJvcnMgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMucmV0cmllc1N1YnNjcmlwdGlvbiA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB0aGlzLmNsb3NlZCA9IGZhbHNlO1xuICAgICAgICAgICAgdGhpcy5lcnJvcnMgPSBlcnJvcnM7XG4gICAgICAgICAgICB0aGlzLnJldHJpZXMgPSByZXRyaWVzO1xuICAgICAgICAgICAgdGhpcy5yZXRyaWVzU3Vic2NyaXB0aW9uID0gcmV0cmllc1N1YnNjcmlwdGlvbjtcbiAgICAgICAgICAgIGVycm9ycy5uZXh0KGVycik7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFJldHJ5V2hlblN1YnNjcmliZXIucHJvdG90eXBlLl91bnN1YnNjcmliZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdmFyIF9hID0gdGhpcywgZXJyb3JzID0gX2EuZXJyb3JzLCByZXRyaWVzU3Vic2NyaXB0aW9uID0gX2EucmV0cmllc1N1YnNjcmlwdGlvbjtcbiAgICAgICAgaWYgKGVycm9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4gICAgU2VxdWVuY2VFcXVhbFN1YnNjcmliZXIucHJvdG90eXBlLmNoZWNrVmFsdWVzID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgX2MgPSB0aGlzLCBfYSA9IF9jLl9hLCBfYiA9IF9jLl9iLCBjb21wYXJvciA9IF9jLmNvbXBhcm9yO1xuICAgICAgICB3aGlsZSAoX2EubGVuZ3RoID4gMCAmJiBfYi5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICB2YXIgYSA9IF9hLnNoaWZ0KCk7XG4gICAgICAgICAgICB2YXIgYiA9IF9iLnNoaWZ0KCk7XG4gICAgICAgICAgICB2YXIgYXJlRXF1YWwgPSBmYWxzZTtcbiAgICAgICAgICAgIGlmIChjb21wYXJvcikge1xuICAgICAgICAgICAgICAgIGFyZUVxdWFsID0gdHJ5Q2F0Y2hfMS50cnlDYXRjaChjb21wYXJvcikoYSwgYik7XG4gICAgICAgICAgICAgICAgaWYgKGFyZUVxdWFsID09PSBlcnJvck9iamVjdF8xLmVycm9yT2JqZWN0KSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdGluYXRpb24uZXJyb3IoZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBhcmVFcXVhbCA9IGEgPT09IGI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIWFyZUVxdWFsKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5lbWl0KGZhbHNlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgU2VxdWVuY2VFcXVhbFN1YnNjcmliZXIucHJvdG90eXBlLmVtaXQgPSBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgdmFyIGRlc3RpbmF0aW9uID0gdGhpcy5kZXN0aW5hdGlvbjtcbiAgICAgICAgZGVzdGluYX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ZSkpO1xuICAgICAgICB9XG4gICAgfVxuICAgIFdpbmRvd1RpbWVTdWJzY3JpYmVyLnByb3RvdHlwZS5fbmV4dCA9IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICB2YXIgd2luZG93cyA9IHRoaXMud2luZG93cztcbiAgICAgICAgdmFyIGxlbiA9IHdpbmRvd3MubGVuZ3RoO1xuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbjsgaSsrKSB7XG4gICAgICAgICAgICB2YXIgd2luZG93XzMgPSB3aW5kb3dzW2ldO1xuICAgICAgICAgICAgaWYgKCF3aW5kb3dfMy5jbG9zZWQpIHtcbiAgICAgICAgICAgICAgICB3aW5kb3dfMy5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgV2luZG93VGltZVN1YnNjcmliZXIucHJvdG90eXBlLl9lcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgdmFyIHdpbmRvd3MgPSB0aGlzLndpbmRvd3M7XG4gICAgICAgIHdoaWxlICh3aW5kb3dzLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgIHdpbmRvd3Muc2hpZnQoKS5lcnJvcihlcnIpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuZGVzdGluYXRpb24uZXJyb3IoZXJyKTtcbiAgICB9O1xuICAgIFdpbmRvd1RpbWVTdWJzY3JpYmVyLnByb3RvdHlwZS5fY29tcGxldGUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciB3aW5kb3dzID0gdGhpcy53aW5kb3dzO1xuICAgICAgICB3aGlsZSAod2luZG93cy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICB2YXIgd2luZG93XzQgPSB3aW5kb3dzLnNoaWZ0KCk7XG4gICAgICAgICAgICBpZiAoIXdpbmRvd180LmNsb3NlZCkge1xuICAgICAgICAgICAgICAgIHdpbmRvd180LmNvbXBsZXRlKCk7XG4gICAgICA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3IgPSBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgIHZhciBjb250ZXh0cyA9IHRoaXMuY29udGV4dHM7XG4gICAgICAgIHRoaXMuY29udGV4dHMgPSBudWxsO1xuICAgICAgICBpZiAoY29udGV4dHMpIHtcbiAgICAgICAgICAgIHZhciBsZW4gPSBjb250ZXh0cy5sZW5ndGg7XG4gICAgICAgICAgICB2YXIgaW5kZXggPSAtMTtcbiAgICAgICAgICAgIHdoaWxlICgrK2luZGV4IDwgbGVuKSB7XG4gICAgICAgICAgICAgICAgdmFyIGNvbnRleHQgPSBjb250ZXh0c1tpbmRleF07XG4gICAgICAgICAgICAgICAgY29udGV4dC53aW5kb3cuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICBjb250ZXh0LnN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIF9zdXBlci5wcm90b3R5cGUuX2Vycm9yLmNhbGwodGhpcywgZXJyKTtcbiAgICB9O1xuICAgIFdpbmRvd1RvZ2dsZVN1YnNjcmliZXIucHJvdG90eXBlLl9jb21wbGV0ZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdmFyIGNvbnRleHRzID0gdGhpcy5jb250ZXh0cztcbiAgICAgICAgdGhpcy5jb250ZXh0cyA9IG51bGw7XG4gICAgICAgIGlmIChjb250ZXh0cykge1xuICAgICAgICAgICAgdmFyIGxlbiA9IGNvbnRleHRzLmxlbmd0aDtcbiAgICAgICAgICAgIHZhciBpbmRleCA9IC0xO1xuICAgICAgICAgICAgd2hpbGUgKCsraW5kZXggPCBsZW4pIHtcbiAgICAgICAgICAgICAgICB2YXIgY29udGV4dCA9IGNvbnRleHRzW2luZGV4XTtcbiAgICAgICAgICAgICAgICBjb250ZXh0LndpbmRvdy5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIGNvbnRleHQuc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4g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AgICAgICAgICBpZiAoY2xvc2luZ05vdGlmaWVyID09PSBlcnJvck9iamVjdF8xLmVycm9yT2JqZWN0KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZXJyb3IoZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHZhciB3aW5kb3dfMSA9IG5ldyBTdWJqZWN0XzEuU3ViamVjdCgpO1xuICAgICAgICAgICAgICAgIHZhciBzdWJzY3JpcHRpb24gPSBuZXcgU3Vic2NyaXB0aW9uXzEuU3Vic2NyaXB0aW9uKCk7XG4gICAgICAgICAgICAgICAgdmFyIGNvbnRleHQgPSB7IHdpbmRvdzogd2luZG93XzEsIHN1YnNjcmlwdGlvbjogc3Vic2NyaXB0aW9uIH07XG4gICAgICAgICAgICAgICAgdGhpcy5jb250ZXh0cy5wdXNoKGNvbnRleHQpO1xuICAgICAgICAgICAgICAgIHZhciBpbm5lclN1YnNjcmlwdGlvbiA9IHN1YnNjcmliZVRvUmVzdWx0XzEuc3Vic2NyaWJlVG9SZXN1bHQodGhpcywgY2xvc2luZ05vdGlmaWVyLCBjb250ZXh0KTtcbiAgICAgICAgICAgICAgICBpZiAoaW5uZXJTdWJzY3JpcHRpb24uY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VXaW5kb3codGhpcy5jb250ZXh0cy5sZW5ndGggLSAxKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGlubmVyU3Vic2NyaXB0aW9uLmNvbnRleHQgPSBjb250ZXh0O1xuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24uYWRkKGlubmVyU3Vic2NyaXB0aW9uKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5uZXh0KHdpbmRvd18xKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuY2xvc2VXaW5kb3codGhpcy5jb250ZXh0cy5pbmRleE9mKG91dGVyVmFsdWUpKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgV2luZG93VG9nZ2xlU3Vic2NyaWJlci5wcm90b3R5cGUubm90aWZ5RXJyb3IgPSBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgIHRoaXMuZXJyb3IoZXJyKTtcbiAgICB9O1xuICAgIFdpbmRvd1RvZ2dsZVN1YnNjcmliZXIucHJvdG90eXBlLm5vdGlmeUNvbXBsZXRlID0gZnVuY3Rpb24gKGlubmVyKSB7XG4gICAgICAgIGlmIChpbm5lciAhPT0gdGhpcy5vcGVuU3Vic2NyaXB0aW9uKSB7XG4gICAgICAgICAgICB0aGlzLmNsb3NlV2luZG93KHRoaXMuY29udGV4dHMuaW5kZXhPZihpbm5lci5jb250ZXh0KSk7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFdpbmRvd1RvZ2dsZVN1YnNjcmliZXIucHJvdG90eXBlLmNsb3NlV2luZG93ID0gZnVuY3Rpb24gKGluZGV4KSB7XG4gICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgY29udGV4dHMgPSB0aGlzLmNvbnRleHRzO1xuICAgICAgICB2YXIgY29udGV4dCA9IGNvbnRleHRzW2luZGV4XTtcbiAgICAgICAgdmFyIHdpbmRvdyA9IGNvbnRleHQud2luZG93LCBzdWJzY3JpcHRpb24gPSBjb250ZXh0LnN1YnNjcmlwdGlvbjtcbiAgICAgICAgY29udGV4dHMuc3BsaWNlKGluZGV4LCAxKTtcbiAgICAgICAgd2luZG93LmNvbXBsZXRlKCk7XG4gICAgICAgIHN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xuICAgIH07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xuICAgICAgICB2YXIgc2hvdWxkQ29tcGxldGUgPSBmYWxzZTtcbiAgICAgICAgdmFyIGFyZ3MgPSBbXTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgICAgdmFyIGl0ZXJhdG9yID0gaXRlcmF0b3JzW2ldO1xuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IGl0ZXJhdG9yLm5leHQoKTtcbiAgICAgICAgICAgIC8vIGNoZWNrIHRvIHNlZSBpZiBpdCdzIGNvbXBsZXRlZCBub3cgdGhhdCB5b3UndmUgZ290dGVuXG4gICAgICAgICAgICAvLyB0aGUgbmV4dCB2YWx1ZS5cbiAgICAgICAgICAgIGlmIChpdGVyYXRvci5oYXNDb21wbGV0ZWQoKSkge1xuICAgICAgICAgICAgICAgIHNob3VsZENvbXBsZXRlID0gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChyZXN1bHQuZG9uZSkge1xuICAgICAgICAgICAgICAgIGRlc3RpbmF0aW9uLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgYXJncy5wdXNoKHJlc3VsdC52YWx1ZSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMucHJvamVjdCkge1xuICAgICAgICAgICAgdGhpcy5fdHJ5UHJvamVjdChhcmdzKTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGRlc3RpbmF0aW9uLm5leHQoYXJncyk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHNob3VsZENvbXBsZXRlKSB7XG4gICAgICAgICAgICBkZXN0aW5hdGlvbi5jb21wbGV0ZSgpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBaaXBTdWJzY3JpYmVyLnByb3RvdHlwZS5fdHJ5UHJvamVjdCA9IGZ1bmN0aW9uIChhcmdzKSB7XG4gICAgICAgI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IGlmIChyb290XzEucm9vdC5TZXQgJiYgdHlwZW9mIG5ldyByb290XzEucm9vdC5TZXQoKVsnQEBpdGVyYXRvciddID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgIC8vIEJ1ZyBmb3IgbW96aWxsYSB2ZXJzaW9uXG4gICAgICAgIGV4cG9ydHMuJCRpdGVyYXRvciA9ICdAQGl0ZXJhdG9yJztcbiAgICB9XG4gICAgZWxzZSBpZiAocm9vdF8xLnJvb3QuTWFwKSB7XG4gICAgICAgIC8vIGVzNi1zaGltIHNwZWNpZmljIGxvZ2ljXG4gICAgICAgIHZhciBrZXlzID0gT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXMocm9vdF8xLnJvb3QuTWFwLnByb3RvdHlwZSk7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7ICsraSkge1xuICAgICAgICAgICAgdmFyIGtleSA9IGtleXNbaV07XG4gICAgICAgICAgICBpZiAoa2V5ICE9PSAnZW50cmllcycgJiYga2V5ICE9PSAnc2l6ZScgJiYgcm9vdF8xLnJvb3QuTWFwLnByb3RvdHlwZVtrZXldID09PSByb290XzEucm9vdC5NYXAucHJvdG90eXBlWydlbnRyaWVzJ10pIHtcbiAgICAgICAgICAgICAgICBleHBvcnRzLiQkaXRlcmF0b3IgPSBrZXk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgZWxzZSB7XG4gICAgICAgIGV4cG9ydHMuJCRpdGVyYXRvciA9ICdAQGl0ZXJhdG9yJztcbiAgICB9XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1pdGVyYXRvci5qcy5tYXAiLCJcInVzZSBzdHJpY3RcIjtcbnZhciByb290XzEgPSByZXF1aXJlKCcuLi91dGlsL3Jvb3QnKTtcbmZ1bmN0aW9uIGdldFN5bWJvbE9ic2VydmFibGUoY29udGV4dCkge1xuICAgIHZhciAkJG9ic2Vyd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0lORklOSVRZO1xuICAgICAgICB2YXIgdW5zdWJzY3JpcHRpb25GcmFtZSA9IE51bWJlci5QT1NJVElWRV9JTkZJTklUWTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgICAgdmFyIGZyYW1lID0gaSAqIHRoaXMuZnJhbWVUaW1lRmFjdG9yO1xuICAgICAgICAgICAgdmFyIGMgPSBtYXJibGVzW2ldO1xuICAgICAgICAgICAgc3dpdGNoIChjKSB7XG4gICAgICAgICAgICAgICAgY2FzZSAnLSc6XG4gICAgICAgICAgICAgICAgY2FzZSAnICc6XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgJygnOlxuICAgICAgICAgICAgICAgICAgICBncm91cFN0YXJ0ID0gZnJhbWU7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgJyknOlxuICAgICAgICAgICAgICAgICAgICBncm91cFN0YXJ0ID0gLTE7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgJ14nOlxuICAgICAgICAgICAgICAgICAgICBpZiAoc3Vic2NyaXB0aW9uRnJhbWUgIT09IE51bWJlci5QT1NJVElWRV9JTkZJTklUWSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdmb3VuZCBhIHNlY29uZCBzdWJzY3JpcHRpb24gcG9pbnQgXFwnXlxcJyBpbiBhICcgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdzdWJzY3JpcHRpb24gbWFyYmxlIGRpYWdyYW0uIFRoZXJlIGNhbiBvbmx5IGJlIG9uZS4nKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb25GcmFtZSA9IGdyb3VwU3RhcnQgPiAtMSA/IGdyb3VwU3RhcnQgOiBmcmFtZTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgY2FzZSAnISc6XG4gICAgICAgICAgICAgICAgICAgIGlmICh1bnN1YnNjcmlwdGlvbkZyYW1lICE9PSBOdW1iZXIuUE9TSVRJVkVfSU5GSU5JVFkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignZm91bmQgYSBzZWNvbmQgc3Vic2NyaXB0aW9uIHBvaW50IFxcJ15cXCcgaW4gYSAnICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnc3Vic2NyaXB0aW9uIG1hcmJsZSBkaWFncmFtLiBUaGVyZSBjYW4gb25seSBiZSBvbmUuJyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgdW5zdWJzY3JpcHRpb25GcmFtZSA9IGdyb3VwU3RhcnQgPiAtMSA/IGdyb3VwU3RhcnQgOiBmcmFtZTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCd0aGVyZSBjYW4gb25seSBiZSBcXCdeXFwnIGFuZCBcXCchXFwnIG1hcmtlcnMgaW4gYSAnICtcbiAgICAgICAgICAgICAgICAgICAgICAgICdzdWJzY3JpcHRpb24gbWFyYmxlIGRpYWdyYW0uIEZvdW5kIGluc3RlYWQgXFwnJyArIGMgKyAnXFwnLicpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh1bnN1YnNjcmlwdGlvbkZyYW1lIDwgMCkge1xuICAgICAgICAgICAgcmV0dXJuIG5ldyBTdWJzY3JpcHRpb25Mb2dfMS5TdWJzY3JpcHRpb25Mb2coc3Vic2NyaXB0aW9uRnJhbWUpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIG5ldyBTdWJzY3JpcHRpb25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sZXNcbiAgICAgICAgICAgICAgICBpZiAobWF0ZXJpYWxpemVJbm5lck9ic2VydmFibGVzICYmIHZhbHVlc1t4XSBpbnN0YW5jZW9mIENvbGRPYnNlcnZhYmxlXzEuQ29sZE9ic2VydmFibGUpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlc1t4XS5tZXNzYWdlcztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlc1t4XTtcbiAgICAgICAgICAgIH07XG4gICAgICAgIHZhciBncm91cFN0YXJ0ID0gLTE7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbGVuOyBpKyspIHtcbiAgICAgICAgICAgIHZhciBmcmFtZSA9IGkgKiB0aGlzLmZyYW1lVGltZUZhY3RvciArIGZyYW1lT2Zmc2V0O1xuICAgICAgICAgICAgdmFyIG5vdGlmaWNhdGlvbiA9IHZvaWQgMDtcbiAgICAgICAgICAgIHZhciBjID0gbWFyYmxlc1tpXTtcbiAgICAgICAgICAgIHN3aXRjaCAoYykge1xuICAgICAgICAgICAgICAgIGNhc2UgJy0nOlxuICAgICAgICAgICAgICAgIGNhc2UgJyAnOlxuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICcoJzpcbiAgICAgICAgICAgICAgICAgICAgZ3JvdXBTdGFydCA9IGZyYW1lO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICcpJzpcbiAgICAgICAgICAgICAgICAgICAgZ3JvdXBTdGFydCA9IC0xO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICd8JzpcbiAgICAgICAgICAgICAgICAgICAgbm90aWZpY2F0aW9uID0gTm90aWZpY2F0aW9uXzEuTm90aWZpY2F0aW9uLmNyZWF0ZUNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgIC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zb3VyY2VzID0gW107XG4gICAgICAgICAgICBmb3IgKHZhciBfaSA9IDE7IF9pIDwgYXJndW1lbnRzLmxlbmd0aDsgX2krKykge1xuICAgICAgICAgICAgICAgIHNvdXJjZXNbX2kgLSAxXSA9IGFyZ3VtZW50c1tfaV07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGFyZ2V0ID09PSB1bmRlZmluZWQgfHwgdGFyZ2V0ID09PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcignY2Fubm90IGNvbnZlcnQgdW5kZWZpbmVkIG9yIG51bGwgdG8gb2JqZWN0Jyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgb3V0cHV0ID0gT2JqZWN0KHRhcmdldCk7XG4gICAgICAgICAgICB2YXIgbGVuID0gc291cmNlcy5sZW5ndGg7XG4gICAgICAgICAgICBmb3IgKHZhciBpbmRleCA9IDA7IGluZGV4IDwgbGVuOyBpbmRleCsrKSB7XG4gICAgICAgICAgICAgICAgdmFyIHNvdXJjZSA9IHNvdXJjZXNbaW5kZXhdO1xuICAgICAgICAgICAgICAgIGlmIChzb3VyY2UgIT09IHVuZGVmaW5lZCAmJiBzb3VyY2UgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIga2V5IGluIHNvdXJjZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNvdXJjZS5oYXNPd25Qcm9wZXJ0eShrZXkpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W2tleV0gPSBzb3VyY2Vba2V5XTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBvdXRwdXQ7XG4gICAgICAgIH07XG4gICAgfSkoKTtcbn1cbmV4cG9ydHMuYXNzaWduID0gT2JqZ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uICAgIGlmIChkZXN0aW5hdGlvbi5jbG9zZWQpIHtcbiAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgfVxuICAgIGlmIChyZXN1bHQgaW5zdGFuY2VvZiBPYnNlcnZhYmxlXzEuT2JzZXJ2YWJsZSkge1xuICAgICAgICBpZiAocmVzdWx0Ll9pc1NjYWxhcikge1xuICAgICAgICAgICAgZGVzdGluYXRpb24ubmV4dChyZXN1bHQudmFsdWUpO1xuICAgICAgICAgICAgZGVzdGluYXRpb24uY29tcGxldGUoKTtcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHJlc3VsdC5zdWJzY3JpYmUoZGVzdGluYXRpb24pO1xuICAgICAgICB9XG4gICAgfVxuICAgIGlmIChpc0FycmF5XzEuaXNBcnJheShyZXN1bHQpKSB7XG4gICAgICAgIGZvciAodmFyIGkgPSAwLCBsZW4gPSByZXN1bHQubGVuZ3RoOyBpIDwgbGVuICYmICFkZXN0aW5hdGlvbi5jbG9zZWQ7IGkrKykge1xuICAgICAgICAgICAgZGVzdGluYXRpb24ubmV4dChyZXN1bHRbaV0pO1xuICAgICAgICB9XG4gICAgICAgIGlmICghZGVzdGluYXRpb24uY2xvc2VkKSB7XG4gICAgICAgICAgICBkZXN0aW5hdGlvbi5jb21wbGV0ZSgpO1xuICAgICAgICB9XG4gICAgfVxuICAgIGVsc2UgaWYgKGlzUHJvbWlzZV8xLmlzUHJvbWlzZShyZXN1bHQpKSB7XG4gICAgICAgIHJlc3VsdC50aGVuKGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgaWYgKCFkZXN0aW5hdGlvbi5jbG9zZWQpIHtcbiAgICAgICAgICAgICAgICBkZXN0aW5hdGlvbi5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICBkZXN0aW5hdGlvbi5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9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BpZiAob3B0cy5vYmplY3RNb2RlKSB7XG4gICAgICAgIG91dHB1dCA9IHRocm91Z2goKTtcbiAgICAgICAgc2VsZi5vbignX3B1c2gnLCBmdW5jdGlvbiBvbnRlc3QgKHQsIGV4dHJhKSB7XG4gICAgICAgICAgICBpZiAoIWV4dHJhKSBleHRyYSA9IHt9O1xuICAgICAgICAgICAgdmFyIGlkID0gdGVzdElkKys7XG4gICAgICAgICAgICB0Lm9uY2UoJ3ByZXJ1bicsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICB2YXIgcm93ID0ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiAndGVzdCcsXG4gICAgICAgICAgICAgICAgICAgIG5hbWU6IHQubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGlkXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBpZiAoaGFzKGV4dHJhLCAncGFyZW50JykpIHtcbiAgICAgICAgICAgICAgICAgICAgcm93LnBhcmVudCA9IGV4dHJhLnBhcmVudDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgb3V0cHV0LnF1ZXVlKHJvdyk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHQub24oJ3Rlc3QnLCBmdW5jdGlvbiAoc3QpIHtcbiAgICAgICAgICAgICAgICBvbnRlc3Qoc3QsIHsgcGFyZW50OiBpZCB9KTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdC5vbigncmVzdWx0JywgZnVuY3Rpb24gKHJlcykge1xuICAgICAgICAgICAgICAgIHJlcy50ZXN0ID0gaWQ7XG4gICAgICAgICAgICAgICAgcmVzLnR5cGUgPSAnYXNzZXJ0JztcbiAgICAgICAgICAgICAgICBvdXRwdXQucXVldWUocmVzKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdC5vbignZW5kJywgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIG91dHB1dC5xdWV1Z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aW50RGVwdGh9KTtcbiAgICAgICAgXG4gICAgICAgIGlmIChNYXRoLm1heChleC5sZW5ndGgsIGFjLmxlbmd0aCkgPiA2NSB8fCBpbnZhbGlkWWFtbChleCkgfHwgaW52YWxpZFlhbWwoYWMpKSB7XG4gICAgICAgICAgICBvdXRwdXQgKz0gaW5uZXIgKyAnZXhwZWN0ZWQ6IHwtXFxuJyArIGlubmVyICsgJyAgJyArIGV4ICsgJ1xcbic7XG4gICAgICAgICAgICBvdXRwdXQgKz0gaW5uZXIgKyAnYWN0dWFsOiB8LVxcbicgKyBpbm5lciArICcgICcgKyBhYyArICdcXG4nO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgb3V0cHV0ICs9IGlubmVyICsgJ2V4cGVjdGVkOiAnICsgZXggKyAnXFxuJztcbiAgICAgICAgICAgIG91dHB1dCArPSBpbm5lciArICdhY3R1YWw6ICAgJyArIGFjICsgJ1xcbic7XG4gICAgICAgIH1cbiAgICB9XG4gICAgaWYgKHJlcy5hdCkge1xuICAgICAgICBvdXRwdXQgKz0gaW5uZXIgKyAnYXQ6ICcgKyByZXMuYXQgKyAnXFxuJztcbiAgICB9XG4gICAgaWYgKHJlcy5vcGVyYXRvciA9PT0gJ2Vycm9yJyAmJiByZXMuYWN0dWFsICYmIHJlcy5hY3R1YWwuc3RhY2spIHtcbiAgICAgICAgdmFyIGxpbmVzID0gU3RyaW5nKHJlcy5hY3R1YWwuc3RhY2spLnNwbGl0KCdcXG4nKTtcbiAgICAgICAgb3V0cHV0ICs9IGlubmVyICsgJ3N0YWNrOiB8LVxcbic7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbGluZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIG91dHB1dCArPSBpbm5lciArICcgICcgKyBsaW5lc1tpXSArICdcXG4nO1xuICAgICAgICB9XG4gICAgfVxuICAgIFxuICAgIG91dHB1dCArPSBvdXRlciArICcuLi5cXG4nO1xuICA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ICAgICAgICAgICAgaWYgKCFtKSB7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBcbiAgICAgICAgICAgIHZhciBzID0gbVsxXS5zcGxpdCgvXFxzKy8pO1xuICAgICAgICAgICAgdmFyIGZpbGVtID0gLygoPzpcXC98W0EtWl06XFxcXClbXjpcXHNdKzooXFxkKykoPzo6KFxcZCspKT8pLy5leGVjKHNbMV0pO1xuICAgICAgICAgICAgaWYgKCFmaWxlbSkge1xuICAgICAgICAgICAgICAgIGZpbGVtID0gLygoPzpcXC98W0EtWl06XFxcXClbXjpcXHNdKzooXFxkKykoPzo6KFxcZCspKT8pLy5leGVjKHNbMl0pO1xuICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgIGlmICghZmlsZW0pIHtcbiAgICAgICAgICAgICAgICAgICAgZmlsZW0gPSAvKCg/OlxcL3xbQS1aXTpcXFxcKVteOlxcc10rOihcXGQrKSg/OjooXFxkKykpPykvLmV4ZWMoc1szXSk7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKCFmaWxlbSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBcbiAgICAgICAgICAgIGlmIChmaWxlbVsxXS5zbGljZSgwLCBkaXIubGVuZ3RoKSA9PT0gZGlyKSB7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBcbiAgICAgICAgICAgIHJlcy5mdW5jdGlvbk5hbWUgPSBzWzBdO1xuICAgICAgICAgICAgcmVzLmZpbGUgPSBmaWxlbVsxXTtcbiAgICAgICAgICAgIHJlcy5saW5lID0gTnVtYmVyKGZpbGVtWzJdKTtcbiAgICAgICAgICAgIGlmIChmaWxlbVszXSkgcmVzLmNvbHVtbiA9IGZpbGVtWzNdO1xuICAgICAgIC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cnQubWF0Y2goaG9zdG5hbWVQYXJ0UGF0dGVybikpIHtcbiAgICAgICAgICB2YXIgbmV3cGFydCA9ICcnO1xuICAgICAgICAgIGZvciAodmFyIGogPSAwLCBrID0gcGFydC5sZW5ndGg7IGogPCBrOyBqKyspIHtcbiAgICAgICAgICAgIGlmIChwYXJ0LmNoYXJDb2RlQXQoaikgPiAxMjcpIHtcbiAgICAgICAgICAgICAgLy8gd2UgcmVwbGFjZSBub24tQVNDSUkgY2hhciB3aXRoIGEgdGVtcG9yYXJ5IHBsYWNlaG9sZGVyXG4gICAgICAgICAgICAgIC8vIHdlIG5lZWQgdGhpcyB0byBtYWtlIHN1cmUgc2l6ZSBvZiBob3N0bmFtZSBpcyBub3RcbiAgICAgICAgICAgICAgLy8gYnJva2VuIGJ5IHJlcGxhY2luZyBub24tQVNDSUkgYnkgbm90aGluZ1xuICAgICAgICAgICAgICBuZXdwYXJ0ICs9ICd4JztcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIG5ld3BhcnQgKz0gcGFydFtqXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgLy8gd2UgdGVzdCBhZ2FpbiB3aXRoIEFTQ0lJIGNoYXIgb25seVxuICAgICAgICAgIGlmICghbmV3cGFydC5tYXRjaChob3N0bmFtZVBhcnRQYXR0ZXJuKSkge1xuICAgICAgICAgICAgdmFyIHZhbGlkUGFydHMgPSBob3N0cGFydHMuc2xpY2UoMCwgaSk7XG4gICAgICAgICAgICB2YXIgbm90SG9zdCA9IGhvc3RwYXJ0cy5zbGljZShpICsgMSk7XG4gICAgICAgICAgICB2YXIgYml0ID0gcGFydC5tYXRjaChob3N0bmFtZVBhcnRTdGFydCk7XG4gICAgICAgICAgICBpZiAoYml0KSB7XG4gICAgICAgICAgICAgIHZhbGlkUGFydHMucHVzaChiaXRbMV0pO1xuICAgICAgICAgICAgICBub3RIb3N0LnVuc2hpZnQoYml0WzJdKTtcbiAgICAgIC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AgICAgICogVXNlZCB0byBkZXRlY3QgY29kZSB0byBiZSBldmFsdWF0ZWQuXG4gICAgICAgKlxuICAgICAgICogQG1lbWJlck9mIF8udGVtcGxhdGVTZXR0aW5nc1xuICAgICAgICogQHR5cGUge1JlZ0V4cH1cbiAgICAgICAqL1xuICAgICAgJ2V2YWx1YXRlJzogcmVFdmFsdWF0ZSxcblxuICAgICAgLyoqXG4gICAgICAgKiBVc2VkIHRvIGRldGVjdCBgZGF0YWAgcHJvcGVydHkgdmFsdWVzIHRvIGluamVjdC5cbiAgICAgICAqXG4gICAgICAgKiBAbWVtYmVyT2YgXy50ZW1wbGF0ZVNldHRpbmdzXG4gICAgICAgKiBAdHlwZSB7UmVnRXhwfVxuICAgICAgICovXG4gICAgICAnaW50ZXJwb2xhdGUnOiByZUludGVycG9sYXRlLFxuXG4gICAgICAvKipcbiAgICAgICAqIFVzZWQgdG8gcmVmZXJlbmNlIHRoZSBkYXRhIG9iamVjdCBpbiB0aGUgdGVtcGxhdGUgdGV4dC5cbiAgICAgICAqXG4gICAgICAgKiBAbWVtYmVyT2YgXy50ZW1wbGF0ZVNldHRpbmdzXG4gICAgICAgKiBAdHlwZSB7c3RyaW5nfVxuICAgICAgICovXG4gICAgICAndmFyaWFibGUnOiAnJyxcblxuICAgICAgLyoqXG4gICAgICAgKiBVc2VkIHRvIGltcG9ydCB2YXJpYWJsZXMgaW50byB0aGUgY29tcGlsZWQgdGVtcGxhdGUuXG4gICAgICAgKlxuICAgICAgICogQG1lbWJlck9mIF8udGVtcGxhdGVTZXR0aW5nc1xuICAgICAgICogQHR5cGUge09iamVjdH1cbiAgICAgICAqL1xuICAgICAgJ2ltcG9ydHMnOiB7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEEgcmVmZXJlbmNlIHRvIHRoZSBgbG9kYXNoYCBmdW5jdGlvbi5cbiAgICAgICAgICpcbiAgICAgICAgICogQG1lbWJlck9mIF8udGVtcGxhdGVTZXR0aW5ncy5pbXBvcnRzX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lblxuICAgICAgICAgICAgICA/IGNhY2hlSGFzKHNlZW4sIGNvbXB1dGVkKVxuICAgICAgICAgICAgICA6IGluY2x1ZGVzKHJlc3VsdCwgY29tcHV0ZWQsIGNvbXBhcmF0b3IpXG4gICAgICAgICAgICApKSB7XG4gICAgICAgICAgb3RoSW5kZXggPSBvdGhMZW5ndGg7XG4gICAgICAgICAgd2hpbGUgKC0tb3RoSW5kZXgpIHtcbiAgICAgICAgICAgIHZhciBjYWNoZSA9IGNhY2hlc1tvdGhJbmRleF07XG4gICAgICAgICAgICBpZiAoIShjYWNoZVxuICAgICAgICAgICAgICAgICAgPyBjYWNoZUhhcyhjYWNoZSwgY29tcHV0ZWQpXG4gICAgICAgICAgICAgICAgICA6IGluY2x1ZGVzKGFycmF5c1tvdGhJbmRleF0sIGNvbXB1dGVkLCBjb21wYXJhdG9yKSlcbiAgICAgICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgY29udGludWUgb3V0ZXI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChzZWVuKSB7XG4gICAgICAgICAgICBzZWVuLnB1c2goY29tcHV0ZWQpO1xuICAgICAgICAgIH1cbiAgICAgICAgICByZXN1bHQucHVzaCh2YWx1ZSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogVGhlIGJhc2UgaW1wbGVtZW50YXRpb24gb2YgYF8uaW52ZXJ0YCBhbmQgYF8uaW52ZXJ0QnlgIHdoaWNoIGludmVydHNcbiAgICAgKiBgb2JqZWN0YCB3aXRoIHZhbHVlcyB0cmFuc2Zvcm1lZCBieSBgaXRlcmF0ZWVgIGFuZCBzZXQgYnkgYHNldHRlcmAuXG4gICAgICpcbiAgICAgKiBAcHJpdmF0ZVxuICAgICAqIEBwYXJhbSB7T2JqZWN0fSBvYmplY3QgVGhlIG9iamVjdCB0byBpdGVyYXRlIG92ZXIuXG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ZUlzTWF0Y2gob2JqZWN0LCBzb3VyY2UsIG1hdGNoRGF0YSwgY3VzdG9taXplcikge1xuICAgICAgdmFyIGluZGV4ID0gbWF0Y2hEYXRhLmxlbmd0aCxcbiAgICAgICAgICBsZW5ndGggPSBpbmRleCxcbiAgICAgICAgICBub0N1c3RvbWl6ZXIgPSAhY3VzdG9taXplcjtcblxuICAgICAgaWYgKG9iamVjdCA9PSBudWxsKSB7XG4gICAgICAgIHJldHVybiAhbGVuZ3RoO1xuICAgICAgfVxuICAgICAgb2JqZWN0ID0gT2JqZWN0KG9iamVjdCk7XG4gICAgICB3aGlsZSAoaW5kZXgtLSkge1xuICAgICAgICB2YXIgZGF0YSA9IG1hdGNoRGF0YVtpbmRleF07XG4gICAgICAgIGlmICgobm9DdXN0b21pemVyICYmIGRhdGFbMl0pXG4gICAgICAgICAgICAgID8gZGF0YVsxXSAhPT0gb2JqZWN0W2RhdGFbMF1dXG4gICAgICAgICAgICAgIDogIShkYXRhWzBdIGluIG9iamVjdClcbiAgICAgICAgICAgICkge1xuICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgd2hpbGUgKCsraW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgZGF0YSA9IG1hdGNoRGF0YVtpbmRleF07XG4gICAgICAgIHZhciBrZXkgPSBkYXRhWzBdLFxuICAgICAgICAgICAgb2JqVmFsdWUgPSBvYmplY3Rba2V5XSxcbiAgICAgICAgICAgIHNyY1ZhbHVlID0gZGF0YVsxXTtcblxuICAgICAgICBpZiAobm9DdXN0b21pemVyICYmIGRhdGFbMl0pIHtcbiAgICAgICAgICBpZiAob2JqVmFsdWUgPT09IHVuZGVmaW5lZCAmJiAhKGtleSBpbiBvYmplY3QpKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHZhciBzdGFjayA9IG5ldyBTdGFjaztcbiA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1bHQucHVzaChrZXkpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoZSBiYXNlIGltcGxlbWVudGF0aW9uIG9mIGBfLmtleXNJbmAgd2hpY2ggZG9lc24ndCB0cmVhdCBzcGFyc2UgYXJyYXlzIGFzIGRlbnNlLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gb2JqZWN0IFRoZSBvYmplY3QgdG8gcXVlcnkuXG4gICAgICogQHJldHVybnMge0FycmF5fSBSZXR1cm5zIHRoZSBhcnJheSBvZiBwcm9wZXJ0eSBuYW1lcy5cbiAgICAgKi9cbiAgICBmdW5jdGlvbiBiYXNlS2V5c0luKG9iamVjdCkge1xuICAgICAgaWYgKCFpc09iamVjdChvYmplY3QpKSB7XG4gICAgICAgIHJldHVybiBuYXRpdmVLZXlzSW4ob2JqZWN0KTtcbiAgICAgIH1cbiAgICAgIHZhciBpc1Byb3RvID0gaXNQcm90b3R5cGUob2JqZWN0KSxcbiAgICAgICAgICByZXN1bHQgPSBbXTtcblxuICAgICAgZm9yICh2YXIga2V5IGluIG9iamVjdCkge1xuICAgICAgICBpZiAoIShrZXkgPT0gJ2NvbnN0cnVjdG9yJyAmJiAoaXNQcm90byB8fCAhaGFzT3duUHJvcGVydHkuY2FsbChvYmplY3QsIGtleSkpKSkge1xuICAgICAgICAgIHJlc3VsdC5wdXNoKGtleSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogVGhlIGJhc2UgaW1wbGVtZW50YXRpb24gb2YgYF8ubHRgIHdoaWNoIGRvZXNuJ3QgY29lcmNlIGFyZ3VtZW50cy5cbiAgICAgKlxuICAgICAqIEBwcml2YXRlXG4gICAgICogQHBhcmFtIHsqfSB2YWx1ZSBUaGUgdmFsdWUgdG8gY29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hcmFtIHtudW1iZXJbXX0gaW5kZXhlcyBUaGUgaW5kZXhlcyBvZiBlbGVtZW50cyB0byByZW1vdmUuXG4gICAgICogQHJldHVybnMge0FycmF5fSBSZXR1cm5zIGBhcnJheWAuXG4gICAgICovXG4gICAgZnVuY3Rpb24gYmFzZVB1bGxBdChhcnJheSwgaW5kZXhlcykge1xuICAgICAgdmFyIGxlbmd0aCA9IGFycmF5ID8gaW5kZXhlcy5sZW5ndGggOiAwLFxuICAgICAgICAgIGxhc3RJbmRleCA9IGxlbmd0aCAtIDE7XG5cbiAgICAgIHdoaWxlIChsZW5ndGgtLSkge1xuICAgICAgICB2YXIgaW5kZXggPSBpbmRleGVzW2xlbmd0aF07XG4gICAgICAgIGlmIChsZW5ndGggPT0gbGFzdEluZGV4IHx8IGluZGV4ICE9PSBwcmV2aW91cykge1xuICAgICAgICAgIHZhciBwcmV2aW91cyA9IGluZGV4O1xuICAgICAgICAgIGlmIChpc0luZGV4KGluZGV4KSkge1xuICAgICAgICAgICAgc3BsaWNlLmNhbGwoYXJyYXksIGluZGV4LCAxKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgYmFzZVVuc2V0KGFycmF5LCBpbmRleCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gYXJyYXk7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogVGhlIGJhc2UgaW1wbGVtZW50YXRpb24gb2YgYF8ucmFuZG9tYCB3aXRob3V0IHN1cHBvcnQgZm9yIHJldHVybmluZ1xuICAgICAqIGZsb2F0aW5nLXBvaW50IG51bWJlcnMuXG4gICAgICpcbiAgICAgKiBAcHJpdmF0ZVxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSBsb3dlciBUaGUgbG93ZXIgYm91bmQuXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IHVwcGVyIFRoZSB1cHBlciBib3VuZC5cbiAgICAgKiBAcmV0dXJucyB7bnVtYmVyfSB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ltYm9sID0gaXNTeW1ib2wob3RoZXIpO1xuXG4gICAgICAgIGlmICgoIW90aElzTnVsbCAmJiAhb3RoSXNTeW1ib2wgJiYgIXZhbElzU3ltYm9sICYmIHZhbHVlID4gb3RoZXIpIHx8XG4gICAgICAgICAgICAodmFsSXNTeW1ib2wgJiYgb3RoSXNEZWZpbmVkICYmIG90aElzUmVmbGV4aXZlICYmICFvdGhJc051bGwgJiYgIW90aElzU3ltYm9sKSB8fFxuICAgICAgICAgICAgKHZhbElzTnVsbCAmJiBvdGhJc0RlZmluZWQgJiYgb3RoSXNSZWZsZXhpdmUpIHx8XG4gICAgICAgICAgICAoIXZhbElzRGVmaW5lZCAmJiBvdGhJc1JlZmxleGl2ZSkgfHxcbiAgICAgICAgICAgICF2YWxJc1JlZmxleGl2ZSkge1xuICAgICAgICAgIHJldHVybiAxO1xuICAgICAgICB9XG4gICAgICAgIGlmICgoIXZhbElzTnVsbCAmJiAhdmFsSXNTeW1ib2wgJiYgIW90aElzU3ltYm9sICYmIHZhbHVlIDwgb3RoZXIpIHx8XG4gICAgICAgICAgICAob3RoSXNTeW1ib2wgJiYgdmFsSXNEZWZpbmVkICYmIHZhbElzUmVmbGV4aXZlICYmICF2YWxJc051bGwgJiYgIXZhbElzU3ltYm9sKSB8fFxuICAgICAgICAgICAgKG90aElzTnVsbCAmJiB2YWxJc0RlZmluZWQgJiYgdmFsSXNSZWZsZXhpdmUpIHx8XG4gICAgICAgICAgICAoIW90aElzRGVmaW5lZCAmJiB2YWxJc1JlZmxleGl2ZSkgfHxcbiAgICAgICAgICAgICFvdGhJc1JlZmxleGl2ZSkge1xuICAgICAgICAgIHJldHVybiAtMTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIDA7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogVXNlZCBieSBgXy5vcmRlckJ5YCB0byBjb21wYXJlIG11bHRpcGxlIHByb3BlcnRpZXMgb2YgYSB2YWx1ZSB0byBhbm90aGVyX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RvIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gc291cmNlIFRoZSBvYmplY3QgdG8gY29weSBwcm9wZXJ0aWVzIGZyb20uXG4gICAgICogQHBhcmFtIHtBcnJheX0gcHJvcHMgVGhlIHByb3BlcnR5IGlkZW50aWZpZXJzIHRvIGNvcHkuXG4gICAgICogQHBhcmFtIHtPYmplY3R9IFtvYmplY3Q9e31dIFRoZSBvYmplY3QgdG8gY29weSBwcm9wZXJ0aWVzIHRvLlxuICAgICAqIEBwYXJhbSB7RnVuY3Rpb259IFtjdXN0b21pemVyXSBUaGUgZnVuY3Rpb24gdG8gY3VzdG9taXplIGNvcGllZCB2YWx1ZXMuXG4gICAgICogQHJldHVybnMge09iamVjdH0gUmV0dXJucyBgb2JqZWN0YC5cbiAgICAgKi9cbiAgICBmdW5jdGlvbiBjb3B5T2JqZWN0KHNvdXJjZSwgcHJvcHMsIG9iamVjdCwgY3VzdG9taXplcikge1xuICAgICAgdmFyIGlzTmV3ID0gIW9iamVjdDtcbiAgICAgIG9iamVjdCB8fCAob2JqZWN0ID0ge30pO1xuXG4gICAgICB2YXIgaW5kZXggPSAtMSxcbiAgICAgICAgICBsZW5ndGggPSBwcm9wcy5sZW5ndGg7XG5cbiAgICAgIHdoaWxlICgrK2luZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgIHZhciBrZXkgPSBwcm9wc1tpbmRleF07XG5cbiAgICAgICAgdmFyIG5ld1ZhbHVlID0gY3VzdG9taXplclxuICAgICAgICAgID8gY3VzdG9taXplcihvYmplY3Rba2V5XSwgc291cmNlW2tleV0sIGtleSwgb2JqZWN0LCBzb3VyY2UpXG4gICAgICAgICAgOiB1bmRlZmluZWQ7XG5cbiAgICAgICAgaWYgKG5ld1ZhbHVlID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICBuZXdWYWx1ZSA9IHNvdXJjZVtrZXldO1xuICAgICAgICB9XG4gICAgICAgIGlmIChpc05ldykge1xuICAgICAgICAgIGJhc2VBc3NpZ25WYWx1ZShvYmplY3QsIGtleSwgbmV3VmFsdWUpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGFzc2lnblZhbHVlKG9iamVjdCwga2V5LCBuZXdWYWx1ZSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiBvYmplY3Q7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQ29waWVzIG93biBzeW1ib2xzIG9mIGBzb3VyY2VgIHRvIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gc291cmNlIFRoZSBvYmplY3QgdG8gY29weSBzeW1ib2xzIGZyb20uXG4gICAgICogQHBhcmFtIHtPYmplY3R9IFtvYmplY3Q9e31dIFRoZSBvYmplY3QgdG8gY29weSBzeW1ib2xzIHRvLlxuICAgICAqIEByZXR1cm5zIHtPYmplY3R9IFJldHVybnMgYG9iamVjdGAuXG4gICAgICovXG4gICAgZnVuY3Rpb24gY29weVN5bWJvbHMoc291cmNlLCBvYmplY3QpIHtcbiAgICAgIHJldHVybiBjb3B5T2JqZWN0KHNvdXJjZSwgZ2V0U3ltYm9scyhzb3VyY2UpLCBvYmplY3QpO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIENvcGllcyBvd24gYW5kIGluaGVyaXRlZCBzeW1ib2xzIG9mIGBzb3VyY2VgIHRvIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gc291cmNlIFRoZSBvYmplY3QgdG8gY29weSBzeW1ib2xzIGZyb20uXG4gICAgICogQHBhcmFtIHtPYmplY3R9IFtvYmplY3Q9e31dIFRoZSBvYmplY3QgdG8gY29weSBzeW1ib2xzIHRvLlxuICAgICAqIEByZXR1cm5zIHtPYmplY3R9IFJldHVybnMgYG9iamVjdGAuXG4gICAgICovXG4gICAgZ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IGxlbmd0aCkge1xuICAgICAgICAgIGZ1bmMgPSBmdW5jc1tpbmRleF07XG5cbiAgICAgICAgICB2YXIgZnVuY05hbWUgPSBnZXRGdW5jTmFtZShmdW5jKSxcbiAgICAgICAgICAgICAgZGF0YSA9IGZ1bmNOYW1lID09ICd3cmFwcGVyJyA/IGdldERhdGEoZnVuYykgOiB1bmRlZmluZWQ7XG5cbiAgICAgICAgICBpZiAoZGF0YSAmJiBpc0xhemlhYmxlKGRhdGFbMF0pICYmXG4gICAgICAgICAgICAgICAgZGF0YVsxXSA9PSAoV1JBUF9BUllfRkxBRyB8IFdSQVBfQ1VSUllfRkxBRyB8IFdSQVBfUEFSVElBTF9GTEFHIHwgV1JBUF9SRUFSR19GTEFHKSAmJlxuICAgICAgICAgICAgICAgICFkYXRhWzRdLmxlbmd0aCAmJiBkYXRhWzldID09IDFcbiAgICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICB3cmFwcGVyID0gd3JhcHBlcltnZXRGdW5jTmFtZShkYXRhWzBdKV0uYXBwbHkod3JhcHBlciwgZGF0YVszXSk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHdyYXBwZXIgPSAoZnVuYy5sZW5ndGggPT0gMSAmJiBpc0xhemlhYmxlKGZ1bmMpKVxuICAgICAgICAgICAgICA/IHdyYXBwZXJbZnVuY05hbWVdKClcbiAgICAgICAgICAgICAgOiB3cmFwcGVyLnRocnUoZnVuYyk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmdW5jdGlvbigpIHtcbiAgICAgICAgICB2YXIgYXJncyA9IGFyZ3VtZW50cyxcbiAgICAgICAgICAgICAgdmFsdWUgPSBhcmdzWzBdO1xuXG4gICAgICAgICAgaWYgKHdyYXBwZXIgJiYgYXJncy5sZW5ndGggPT0gMSAmJiBpc0FycmF5KHZhbHVlKSkge1xuICAgICAgICAgICAgcmV0dXJuIHdyYXBwZXIucGxhbnQodmFsdWUpLnZhbHVlK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F0aW9uKG9wZXJhdG9yLCBkZWZhdWx0VmFsdWUpIHtcbiAgICAgIHJldHVybiBmdW5jdGlvbih2YWx1ZSwgb3RoZXIpIHtcbiAgICAgICAgdmFyIHJlc3VsdDtcbiAgICAgICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQgJiYgb3RoZXIgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgIHJldHVybiBkZWZhdWx0VmFsdWU7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHZhbHVlICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICByZXN1bHQgPSB2YWx1ZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAob3RoZXIgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgIGlmIChyZXN1bHQgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgcmV0dXJuIG90aGVyO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09ICdzdHJpbmcnIHx8IHR5cGVvZiBvdGhlciA9PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgdmFsdWUgPSBiYXNlVG9TdHJpbmcodmFsdWUpO1xuICAgICAgICAgICAgb3RoZXIgPSBiYXNlVG9TdHJpbmcob3RoZXIpO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB2YWx1ZSA9IGJhc2VUb051bWJlcih2YWx1ZSk7XG4gICAgICAgICAgICBvdGhlciA9IGJhc2VUb051bWJlcihvdGhlcik7XG4gICAgICAgICAgfVxuICAgICAgICAgIHJlc3VsdCA9IG9wZXJhdG9yKHZhbHVlLCBvdGhlcik7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgIH07XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQ3JlYXRlcyBhIGZ1bmN0aW9uIGxpa2UgYF8ub3ZlcmAuXG4gICAgICpcbiAgICAgKiBAcHJpdmF0ZVxuICAgICAqIEBwYXJhbSB7R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vbikge1xuICAgICAgICAgIC8vIFNoaWZ0IHdpdGggZXhwb25lbnRpYWwgbm90YXRpb24gdG8gYXZvaWQgZmxvYXRpbmctcG9pbnQgaXNzdWVzLlxuICAgICAgICAgIC8vIFNlZSBbTUROXShodHRwczovL21kbi5pby9yb3VuZCNFeGFtcGxlcykgZm9yIG1vcmUgZGV0YWlscy5cbiAgICAgICAgICB2YXIgcGFpciA9ICh0b1N0cmluZyhudW1iZXIpICsgJ2UnKS5zcGxpdCgnZScpLFxuICAgICAgICAgICAgICB2YWx1ZSA9IGZ1bmMocGFpclswXSArICdlJyArICgrcGFpclsxXSArIHByZWNpc2lvbikpO1xuXG4gICAgICAgICAgcGFpciA9ICh0b1N0cmluZyh2YWx1ZSkgKyAnZScpLnNwbGl0KCdlJyk7XG4gICAgICAgICAgcmV0dXJuICsocGFpclswXSArICdlJyArICgrcGFpclsxXSAtIHByZWNpc2lvbikpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmdW5jKG51bWJlcik7XG4gICAgICB9O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIENyZWF0ZXMgYSBzZXQgb2JqZWN0IG9mIGB2YWx1ZXNgLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge0FycmF5fSB2YWx1ZXMgVGhlIHZhbHVlcyB0byBhZGQgdG8gdGhlIHNldC5cbiAgICAgKiBAcmV0dXJucyB7T2JqZWN0fSBSZXR1cm5zIHRoZSBuZXcgc2V0LlxuICAgICAqL1xuICAgIHZhciBjcmVhdGVTZXQgPSAhKFNldCAmJiAoMSAvIHNldFRvQXJyYXkobmV3IFNldChbLC0wXSkpWzFdKSA9PSBJTkZJTklUWSkgPyBub29wIDogZnVuY3Rpb24odmFsdWVzKSB7XG4gICAgICByZXR1cm4gbmV3IFNldCh2YWx1ZXMpO1xuICAgIH07XG5cbiAgICAvKipcbiAgICAgKiBDcmVhdGVzIGEgYF8udG9QYWlyc2Agb3IgYF8udG9QYW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jaykpKSB7XG4gICAgICAgICAgICAgICAgICByZXR1cm4gc2Vlbi5wdXNoKG90aEluZGV4KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH0pKSB7XG4gICAgICAgICAgICByZXN1bHQgPSBmYWxzZTtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmICghKFxuICAgICAgICAgICAgICBhcnJWYWx1ZSA9PT0gb3RoVmFsdWUgfHxcbiAgICAgICAgICAgICAgICBlcXVhbEZ1bmMoYXJyVmFsdWUsIG90aFZhbHVlLCBiaXRtYXNrLCBjdXN0b21pemVyLCBzdGFjaylcbiAgICAgICAgICAgICkpIHtcbiAgICAgICAgICByZXN1bHQgPSBmYWxzZTtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgc3RhY2tbJ2RlbGV0ZSddKGFycmF5KTtcbiAgICAgIHN0YWNrWydkZWxldGUnXShvdGhlcik7XG4gICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIEEgc3BlY2lhbGl6ZWQgdmVyc2lvbiBvZiBgYmFzZUlzRXF1YWxEZWVwYCBmb3IgY29tcGFyaW5nIG9iamVjdHMgb2ZcbiAgICAgKiB0aGUgc2FtZSBgdG9TdHJpbmdUYWdgLlxuICAgICAqXG4gICAgICogKipOb3RlOioqIFRoaXMgZnVuY3Rpb24gb25seSBzdXBwb3J0cyBjb21wYXJpbmcgdmFsdWVzIHdpdGggdGFncyBvZlxuICAgICAqIGBCb29sZWFuYCwgYERhdGVgLCBgRXJyb3JgLCBgTnVtYmVyYCwgYFJlZ0V4cGAsIG9yIGBTdHJpbmdgLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gb2JqZWN0IFRoZSBvYmplY3QgdG8gY29tcGFyZS5cbiAgICAgKiBAcGFyYW0ge09iamVjdH0gb3RoZX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zcuMC8jc2VjLXJlZ2V4cC5wcm90b3R5cGUudG9zdHJpbmdcbiAgICAgICAgICAvLyBmb3IgbW9yZSBkZXRhaWxzLlxuICAgICAgICAgIHJldHVybiBvYmplY3QgPT0gKG90aGVyICsgJycpO1xuXG4gICAgICAgIGNhc2UgbWFwVGFnOlxuICAgICAgICAgIHZhciBjb252ZXJ0ID0gbWFwVG9BcnJheTtcblxuICAgICAgICBjYXNlIHNldFRhZzpcbiAgICAgICAgICB2YXIgaXNQYXJ0aWFsID0gYml0bWFzayAmIENPTVBBUkVfUEFSVElBTF9GTEFHO1xuICAgICAgICAgIGNvbnZlcnQgfHwgKGNvbnZlcnQgPSBzZXRUb0FycmF5KTtcblxuICAgICAgICAgIGlmIChvYmplY3Quc2l6ZSAhPSBvdGhlci5zaXplICYmICFpc1BhcnRpYWwpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICB9XG4gICAgICAgICAgLy8gQXNzdW1lIGN5Y2xpYyB2YWx1ZXMgYXJlIGVxdWFsLlxuICAgICAgICAgIHZhciBzdGFja2VkID0gc3RhY2suZ2V0KG9iamVjdCk7XG4gICAgICAgICAgaWYgKHN0YWNrZWQpIHtcbiAgICAgICAgICAgIHJldHVybiBzdGFja2VkID09IG90aGVyO1xuICAgICAgICAgIH1cbiAgICAgICAgICBiaXRtYXNrIHw9IENPTVBBUkVfVU5PUkRFUkVEX0ZMQUc7XG5cbiAgICAgICAgICAvLyBSZWN1cnNpdmVseSBjb21wYXJlIG9iamVjdHMgKHN1c2NlcHRpYmxlIHRvIGNhbGwgc3RhY2sgbGltaXRzKS5cbiAgICAgICAgICBzdGFjay5zZXQob2JqZWN0LCBvdGhlcik7XG4gICAgICAgICAgdmFyIHJlc3VsdCA9IGVxdWFsQXJyYXlzKGNvbnZlcnQob2JqZWN0KSwgY29udmVydChvdGhlciksIGJpdG1hc2ssIGN1c3RvbWl6ZXIsIGVxdWFsRnVuYywgc3RhY2spO1xuICAgICAgICA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ZCA9PSBvdGhlcjtcbiAgICAgIH1cbiAgICAgIHZhciByZXN1bHQgPSB0cnVlO1xuICAgICAgc3RhY2suc2V0KG9iamVjdCwgb3RoZXIpO1xuICAgICAgc3RhY2suc2V0KG90aGVyLCBvYmplY3QpO1xuXG4gICAgICB2YXIgc2tpcEN0b3IgPSBpc1BhcnRpYWw7XG4gICAgICB3aGlsZSAoKytpbmRleCA8IG9iakxlbmd0aCkge1xuICAgICAgICBrZXkgPSBvYmpQcm9wc1tpbmRleF07XG4gICAgICAgIHZhciBvYmpWYWx1ZSA9IG9iamVjdFtrZXldLFxuICAgICAgICAgICAgb3RoVmFsdWUgPSBvdGhlcltrZXldO1xuXG4gICAgICAgIGlmIChjdXN0b21pemVyKSB7XG4gICAgICAgICAgdmFyIGNvbXBhcmVkID0gaXNQYXJ0aWFsXG4gICAgICAgICAgICA/IGN1c3RvbWl6ZXIob3RoVmFsdWUsIG9ialZhbHVlLCBrZXksIG90aGVyLCBvYmplY3QsIHN0YWNrKVxuICAgICAgICAgICAgOiBjdXN0b21pemVyKG9ialZhbHVlLCBvdGhWYWx1ZSwga2V5LCBvYmplY3QsIG90aGVyLCBzdGFjayk7XG4gICAgICAgIH1cbiAgICAgICAgLy8gUmVjdXJzaXZlbHkgY29tcGFyZSBvYmplY3RzIChzdXNjZXB0aWJsZSB0byBjYWxsIHN0YWNrIGxpbWl0cykuXG4gICAgICAgIGlmICghKGNvbXBhcmVkID09PSB1bmRlZmluZWRcbiAgICAgICAgICAgICAgPyAob2JqVmFsdWUgPT09IG90aFZhbHVlIHx8IGVxdWFsRnVuYyhvYmpWYWx1ZSwgb3RoVmFsdWUsIGJpdG1hc2ssIGN1c3RvbWl6ZXIsIHN0YWNrKSlcbiAgICAgICAgICAgICAgOiBjb21wYXJlZFxuICAgICAgICAgICAgKSkge1xuICAgICAgICAgIHJlc3VsdCA9IGZhbHNlO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIHNraXBDdG9yI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2UgdWludDE2VGFnOiBjYXNlIHVpbnQzMlRhZzpcbiAgICAgICAgICByZXR1cm4gY2xvbmVUeXBlZEFycmF5KG9iamVjdCwgaXNEZWVwKTtcblxuICAgICAgICBjYXNlIG1hcFRhZzpcbiAgICAgICAgICByZXR1cm4gY2xvbmVNYXAob2JqZWN0LCBpc0RlZXAsIGNsb25lRnVuYyk7XG5cbiAgICAgICAgY2FzZSBudW1iZXJUYWc6XG4gICAgICAgIGNhc2Ugc3RyaW5nVGFnOlxuICAgICAgICAgIHJldHVybiBuZXcgQ3RvcihvYmplY3QpO1xuXG4gICAgICAgIGNhc2UgcmVnZXhwVGFnOlxuICAgICAgICAgIHJldHVybiBjbG9uZVJlZ0V4cChvYmplY3QpO1xuXG4gICAgICAgIGNhc2Ugc2V0VGFnOlxuICAgICAgICAgIHJldHVybiBjbG9uZVNldChvYmplY3QsIGlzRGVlcCwgY2xvbmVGdW5jKTtcblxuICAgICAgICBjYXNlIHN5bWJvbFRhZzpcbiAgICAgICAgICByZXR1cm4gY2xvbmVTeW1ib2wob2JqZWN0KTtcbiAgICAgIH1cbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBJbnNlcnRzIHdyYXBwZXIgYGRldGFpbHNgIGluIGEgY29tbWVudCBhdCB0aGUgdG9wIG9mIHRoZSBgc291cmNlYCBib2R5LlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge3N0cmluZ30gc291cmNlIFRoZSBzb3VyY2UgdG8gbW9kaWZ5LlxuICAgICAqIEByZXR1cm5zIHtBcnJheX0gZGV0YWlscyBUaGUgZGV0YWlscyB0byBpbnNlcnQuXG4gICAgICogQHJldHVybnMge3N0cmluZ30gUmV0dXJucyB0aGUgbW9kaWZpZWQgc291cmNlLlxuICAgICAqL1xuICAgIGZ1bmN0aW9uIGluc2VydFdyYXBEZXRhaWxzKHNvdXJjZSwgZGV0YWlscykge1xuICAgICAgdmFyIGxlbmd0aCA9IGRldGFpbHMubGVu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xlXG4gICAgICpcbiAgICAgKiB2YXIgYXJyYXkgPSBbMSwgMl07XG4gICAgICogdmFyIHdyYXBwZWQgPSBfKGFycmF5KS5wdXNoKDMpO1xuICAgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXkpO1xuICAgICAqIC8vID0+IFsxLCAyXVxuICAgICAqXG4gICAgICogd3JhcHBlZCA9IHdyYXBwZWQuY29tbWl0KCk7XG4gICAgICogY29uc29sZS5sb2coYXJyYXkpO1xuICAgICAqIC8vID0+IFsxLCAyLCAzXVxuICAgICAqXG4gICAgICogd3JhcHBlZC5sYXN0KCk7XG4gICAgICogLy8gPT4gM1xuICAgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXkpO1xuICAgICAqIC8vID0+IFsxLCAyLCAzXVxuICAgICAqL1xuICAgIGZ1bmN0aW9uIHdyYXBwZXJDb21taXQoKSB7XG4gICAgICByZXR1cm4gbmV3IExvZGFzaFdyYXBwZXIodGhpcy52YWx1ZSgpLCB0aGlzLl9fY2hhaW5fXyk7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogR2V0cyB0aGUgbmV4dCB2YWx1ZSBvbiBhIHdyYXBwZWQgb2JqZWN0IGZvbGxvd2luZyB0aGVcbiAgICAgKiBbaXRlcmF0b3IgcHJvdG9jb2xdKGh0dHBzOi8vbWRuLmlvL2l0ZXJhdGlvbl9wcm90b2NvbHMjaXRlcmF0b3IpLlxuICAgICAqXG4gICAgICogQG5hbWUgbmV4dFxuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMC4wXG4gICAgICogQGNhdGVnb3J5IFNlcVxuICAgICAqIEByZXR1cm5zIHtPYmplY3R9IFJldHVybnMgdGhlIG5leHQgaXRlcmF0b3IgdmFsdWUuXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIHZhciB3cmFwcGVkID0gXyhbMSwgMl0pO1xuICAgICAqXG4gICAgICogd3JhcHBlZC5uZXh0KCk7XG4gICAgICogLy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xuICAgICAgICBsYXN0QXJncyA9IGxhc3RDYWxsVGltZSA9IGxhc3RUaGlzID0gdGltZXJJZCA9IHVuZGVmaW5lZDtcbiAgICAgIH1cblxuICAgICAgZnVuY3Rpb24gZmx1c2goKSB7XG4gICAgICAgIHJldHVybiB0aW1lcklkID09PSB1bmRlZmluZWQgPyByZXN1bHQgOiB0cmFpbGluZ0VkZ2Uobm93KCkpO1xuICAgICAgfVxuXG4gICAgICBmdW5jdGlvbiBkZWJvdW5jZWQoKSB7XG4gICAgICAgIHZhciB0aW1lID0gbm93KCksXG4gICAgICAgICAgICBpc0ludm9raW5nID0gc2hvdWxkSW52b2tlKHRpbWUpO1xuXG4gICAgICAgIGxhc3RBcmdzID0gYXJndW1lbnRzO1xuICAgICAgICBsYXN0VGhpcyA9IHRoaXM7XG4gICAgICAgIGxhc3RDYWxsVGltZSA9IHRpbWU7XG5cbiAgICAgICAgaWYgKGlzSW52b2tpbmcpIHtcbiAgICAgICAgICBpZiAodGltZXJJZCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICByZXR1cm4gbGVhZGluZ0VkZ2UobGFzdENhbGxUaW1lKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKG1heGluZykge1xuICAgICAgICAgICAgLy8gSGFuZGxlIGludm9jYXRpb25zIGluIGEgdGlnaHQgbG9vcC5cbiAgICAgICAgICAgIHRpbWVySWQgPSBzZXRUaW1lb3V0KHRpbWVyRXhwaXJlZCwgd2FpdCk7XG4gICAgICAgICAgICByZXR1cm4gaW52b2tlRnVuYyhsYXN0Q2FsbFRpbWUpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGltZXJJZCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgdGltZXJJZCA9IHNldFRpbWVvdXQodGltZXJFeHBpcmVkLCB3YWl0KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgfVxuICAgICAgZGVib3Vu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ZnVuY3Rpb24gaW52b2tlZCBwZXIgaXRlcmF0aW9uLlxuICAgICAqIEByZXR1cm5zIHtPYmplY3R9IFJldHVybnMgYG9iamVjdGAuXG4gICAgICogQHNlZSBfLmZvck93blxuICAgICAqIEBleGFtcGxlXG4gICAgICpcbiAgICAgKiBmdW5jdGlvbiBGb28oKSB7XG4gICAgICogICB0aGlzLmEgPSAxO1xuICAgICAqICAgdGhpcy5iID0gMjtcbiAgICAgKiB9XG4gICAgICpcbiAgICAgKiBGb28ucHJvdG90eXBlLmMgPSAzO1xuICAgICAqXG4gICAgICogXy5mb3JPd25SaWdodChuZXcgRm9vLCBmdW5jdGlvbih2YWx1ZSwga2V5KSB7XG4gICAgICogICBjb25zb2xlLmxvZyhrZXkpO1xuICAgICAqIH0pO1xuICAgICAqIC8vID0+IExvZ3MgJ2InIHRoZW4gJ2EnIGFzc3VtaW5nIGBfLmZvck93bmAgbG9ncyAnYScgdGhlbiAnYicuXG4gICAgICovXG4gICAgZnVuY3Rpb24gZm9yT3duUmlnaHQob2JqZWN0LCBpdGVyYXRlZSkge1xuICAgICAgcmV0dXJuIG9iamVjdCAmJiBiYXNlRm9yT3duUmlnaHQob2JqZWN0LCBnZXRJdGVyYXRlZShpdGVyYXRlZSwgMykpO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIENyZWF0ZXMgYW4gYXJyYXkgb2YgZnVuY3Rpb24gcHJvcGVydHkgbmFtZXMgZnJvbSBvd24gZW51bWVyYWJsZSBwcm9wZXJ0aWVzXG4gICAgICogb2YgYG9iamVjdGAuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQHNpbmNlIDAuMS4wXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAY2F0ZWdvcnkgT2JqZWN0XG4gICAgICogQHBhcmFtIHtPYmplY3R9IG9iamVjdCBUaGUgb2JqZWN0IHRvIGluc3BlY3QuXG4gICAgICogQHJldHVybnMge0FycmF5fSBSZXR1cm5zIHRoZSBmdW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YXRhIG9iamVjdCB0byB0aGUgdG9wIG9mIHRoZSBzY29wZSBjaGFpbi5cbiAgICAgIHZhciB2YXJpYWJsZSA9IG9wdGlvbnMudmFyaWFibGU7XG4gICAgICBpZiAoIXZhcmlhYmxlKSB7XG4gICAgICAgIHNvdXJjZSA9ICd3aXRoIChvYmopIHtcXG4nICsgc291cmNlICsgJ1xcbn1cXG4nO1xuICAgICAgfVxuICAgICAgLy8gQ2xlYW51cCBjb2RlIGJ5IHN0cmlwcGluZyBlbXB0eSBzdHJpbmdzLlxuICAgICAgc291cmNlID0gKGlzRXZhbHVhdGluZyA/IHNvdXJjZS5yZXBsYWNlKHJlRW1wdHlTdHJpbmdMZWFkaW5nLCAnJykgOiBzb3VyY2UpXG4gICAgICAgIC5yZXBsYWNlKHJlRW1wdHlTdHJpbmdNaWRkbGUsICckMScpXG4gICAgICAgIC5yZXBsYWNlKHJlRW1wdHlTdHJpbmdUcmFpbGluZywgJyQxOycpO1xuXG4gICAgICAvLyBGcmFtZSBjb2RlIGFzIHRoZSBmdW5jdGlvbiBib2R5LlxuICAgICAgc291cmNlID0gJ2Z1bmN0aW9uKCcgKyAodmFyaWFibGUgfHwgJ29iaicpICsgJykge1xcbicgK1xuICAgICAgICAodmFyaWFibGVcbiAgICAgICAgICA/ICcnXG4gICAgICAgICAgOiAnb2JqIHx8IChvYmogPSB7fSk7XFxuJ1xuICAgICAgICApICtcbiAgICAgICAgXCJ2YXIgX190LCBfX3AgPSAnJ1wiICtcbiAgICAgICAgKGlzRXNjYXBpbmdcbiAgICAgICAgICAgPyAnLCBfX2UgPSBfLmVzY2FwZSdcbiAgICAgICAgICAgOiAnJ1xuICAgICAgICApICtcbiAgICAgICAgKGlzRXZhbHVhdGluZ1xuICAgICAgICAgID8gJywgX19qID0gQXJyYXkucHJvdG90eXBlLmpvaW47XFxuJyArXG4gICAgICAgICAgICBcImZ1bmN0aW9uIHByaW50KCkgeyBfX3AgKz0gX19qLmNhbGwoYXJndW1lbnRzLCA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H0gUmV0dXJucyBgb2JqZWN0YC5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogZnVuY3Rpb24gdm93ZWxzKHN0cmluZykge1xuICAgICAqICAgcmV0dXJuIF8uZmlsdGVyKHN0cmluZywgZnVuY3Rpb24odikge1xuICAgICAqICAgICByZXR1cm4gL1thZWlvdV0vaS50ZXN0KHYpO1xuICAgICAqICAgfSk7XG4gICAgICogfVxuICAgICAqXG4gICAgICogXy5taXhpbih7ICd2b3dlbHMnOiB2b3dlbHMgfSk7XG4gICAgICogXy52b3dlbHMoJ2ZyZWQnKTtcbiAgICAgKiAvLyA9PiBbJ2UnXVxuICAgICAqXG4gICAgICogXygnZnJlZCcpLnZvd2VscygpLnZhbHVlKCk7XG4gICAgICogLy8gPT4gWydlJ11cbiAgICAgKlxuICAgICAqIF8ubWl4aW4oeyAndm93ZWxzJzogdm93ZWxzIH0sIHsgJ2NoYWluJzogZmFsc2UgfSk7XG4gICAgICogXygnZnJlZCcpLnZvd2VscygpO1xuICAgICAqIC8vID0+IFsnZSddXG4gICAgICovXG4gICAgZnVuY3Rpb24gbWl4aW4ob2JqZWN0LCBzb3VyY2UsIG9wdGlvbnMpIHtcbiAgICAgIHZhciBwcm9wcyA9IGtleXMoc291cmNlKSxcbiAgICAgICAgICBtZXRob2ROYW1lcyA9IGJhc2VGdW5jdGlvbnMoc291cmNlLCBwcm9wcyk7XG5cbiAgICAgIGlmIChvcHRpb25zID09IG51bGwgJiZcbiAgICAgICAgICAhKGlzT2JqZWN0KHNvdXJjZSkgJiYgKG1ldGhvZE5hbWVzLmxlbmd0aCB8fCAhcHJvcHMubGVuZ3RoKSkpIHtcbiAgICAgICAgb3B0aW9ucyA9IHNvdXJjZTtcbiAgICAgICAgc291cmNlID0gb2JqZWN0O1xuICAgICAgICBvYmplY3QgPSB0aGlzO1xuICAgICAgICBtZXRob2ROYW1lcyA9IGJhc2VGdW5jdGlvbnMoc291cmNlLCBrZXlzKHNvdXJjZSkpO1xuICAgICAgfVxuICAgICAgdmFyIGNoYWluID0gIShpc09iamVjdChvcHRpb25zKSAmJiAnY2hhaW4nIGluIG9wdGlvbnMpIHx8ICEhb3B0aW9ucy5jaGFpbixcbiAgICAgICAgICBpc0Z1bmMgPSBpc0Z1bmN0aW9uKG9iamVjdCk7XG5cbiAgICAgIGFycmF5RWFjaChtZXRob2ROYW1lcywgZnVuY3Rpb24obWV0aG9kTmFtZSkge1xuICAgICAgICB2YXIgZnVuYyA9IHNvdXJjZVttZXRob2ROYW1lXTtcbiAgICAgICAgb2JqZWN0W21ldGhvZE5hbWVdID0gZnVuYztcbiAgICAgICAgaWYgKGlzRnVuYykge1xuICAgICAgICAgIG9iamVjdC5wcm90b3R5cGVbbWV0aG9kTmFtZV0gPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHZhciBjaGFpbkFsbCA9IHRoaXMuX19jaGFpbl9fO1xuICAgICAgICAgICAgaWYgKGNoYWluIHx8IGNoYWluQWxsKSB7XG4gICAgICAgICAgICAgIHZhciByZXN1bHQgPSBvYmplY3QodGhpcy5fX3dyYXBwZWRfXyksXG4gICAgICAgICAgICAgICAgICBhY3Rpb25zID0gcmVzdWx0Ll9fYWN0aW9uc19fID0gY29weUFycmF5KHRoaXMuX19hY3Rpb25zX18pO1xuXG4gICAgICAgICAgICAgIGFjdGlvbnMucHVzaCh7ICdmdW5jJzogZnVuYywgJ2FyZ3MnOiBhcmd1bWVudHMsICd0aGlzQXJnJzogb2JqZWN0IH0pO1xuICAgICAgICAgICAgICByZXN1bHQuX19jaGFpbl9fID0gY2hhaW5BbGw7XG4gICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gZnVuYy5hcHBseShvYmplY3QsIGFycmF5UHVzaChbdGhpcy52YWx1ZSgpXSwgYXJndW1lbnRzKSk7XG4gICAgICAgICAgfTtcbiAgICAgICAgfVxuICAgICAgfSk7XG5cbiAgICAgIHJldH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AgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXlzKTtcbiAgICAgKiAvLyA9PiBbW10sIFtdXVxuICAgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXlzWzBdID09PSBhcnJheXNbMV0pO1xuICAgICAqIC8vID0+IGZhbHNlXG4gICAgICovXG4gICAgZnVuY3Rpb24gc3R1YkFycmF5KCkge1xuICAgICAgcmV0dXJuIFtdO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYGZhbHNlYC5cbiAgICAgKlxuICAgICAqIEBzdGF0aWNcbiAgICAgKiBAbWVtYmVyT2YgX1xuICAgICAqIEBzaW5jZSA0LjEzLjBcbiAgICAgKiBAY2F0ZWdvcnkgVXRpbFxuICAgICAqIEByZXR1cm5zIHtib29sZWFufSBSZXR1cm5zIGBmYWxzZWAuXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIF8udGltZXMoMiwgXy5zdHViRmFsc2UpO1xuICAgICAqIC8vID0+IFtmYWxzZSwgZmFsc2VdXG4gICAgICovXG4gICAgZnVuY3Rpb24gc3R1YkZhbHNlKCkge1xuICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYSBuZXcgZW1wdHkgb2JqZWN0LlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMTMuMFxuICAgICAqIEBjYXRlZ29yeSBVdGlsXG4gICAgICogQHJldHVybnMge09iamVjdH0gUmV0dXJucyB0aGUgbmV3IGVtcHR5IG9iamVjdC5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogdmFyIG9iamVjdHMgPSBfLnRpbWVzKDIsIF8uc3R1Yk9iamVjdCk7XG4gICAgICpcbiAgICAgKiBjb25zb2xlLmxvZyhvYmplY3RzKTtcbiAgICAgKiAvLyA9PiBbe30sIHt9XVxuICAgICAqXG4gICAgICogY29uc29sZS5sb2cob2JqZWN0c1swXSA9PT0gb2JqZWN0c1sxXSk7XG4gICAgICogLy8gPT4gZmFsc2VcbiAgICAgKi9cbiAgICBmdW5jdGlvbiBzdHViT2JqZWN0KCkge1xuICAgICAgcmV0dXJuIHt9O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYW4gZW1wdHkgc3RyaW5nLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMTMuMFxuICAgICAqIEBjYXRlZ29yeSBVdGlsXG4gICAgICogQHJldHVybnMge3N0cmluZ30gUmV0dXJucyB0aGUgZW1wdHkgc3RyaW5nLlxuICAgICAqIEBleGFtcGxlXG4gICAgICpcbiAgICAgKiBfLnRpbWVzKDIsIF8uc3R1YlN0cmluZyk7XG4gICAgICogLy8gPT4gWycnLCAnJ11cbiAgICAgKi9cbiAgICBmdW5jdGlvbiBzdHViU3RyaW5nKCkge1xuICAgICAgcmV0dXJuICcnO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYHRydWVgLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMTMuMFxuICAgICAqIEBjYXRlZ29yeSBVdGlsXG4gICAgICogQHJldHVybnMge2Jvb2xlYW59IFJldHVybnMgYHRydWVgLlxuICAgICAqIEBleGFtcGxlXG4gICAgICpcbiAgICAgKiBfLnRpbWVzKDIsIF8uc3R1YlRydWUpO1xuICAgICAqIC8vID0+IFt0cnVlLCB0cnVlXVxuICAgICAqL1xuICAgIGZ1bmN0aW9uIHN0dWJUcnVlKCkge1xuICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogSW52b2tlcyB0aGUgaXRl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gPSBfbisrIC8vIH1cbiAgLCAgIE9QRU5fQVJSQVkgICAgICAgICAgID0gX24rKyAvLyBbXG4gICwgICBDTE9TRV9BUlJBWSAgICAgICAgICA9IF9uKysgLy8gXVxuICAsICAgU1RSSU5HICAgICAgICAgICAgICAgPSBfbisrIC8vIFwiXCJcbiAgLCAgIE9QRU5fS0VZICAgICAgICAgICAgID0gX24rKyAvLyAsIFwiYVwiXG4gICwgICBDTE9TRV9LRVkgICAgICAgICAgICA9IF9uKysgLy8gOlxuICAsICAgVFJVRSAgICAgICAgICAgICAgICAgPSBfbisrIC8vIHJcbiAgLCAgIFRSVUUyICAgICAgICAgICAgICAgID0gX24rKyAvLyB1XG4gICwgICBUUlVFMyAgICAgICAgICAgICAgICA9IF9uKysgLy8gZVxuICAsICAgRkFMU0UgICAgICAgICAgICAgICAgPSBfbisrIC8vIGFcbiAgLCAgIEZBTFNFMiAgICAgICAgICAgICAgID0gX24rKyAvLyBsXG4gICwgICBGQUxTRTMgICAgICAgICAgICAgICA9IF9uKysgLy8gc1xuICAsICAgRkFMU0U0ICAgICAgICAgICAgICAgPSBfbisrIC8vIGVcbiAgLCAgIE5VTEwgICAgICAgICAgICAgICAgID0gX24rKyAvLyB1XG4gICwgICBOVUxMMiAgICAgICAgICAgICAgICA9IF9uKysgLy8gbFxuICAsICAgTlVMTDMgICAgICAgICAgICAgICAgPSBfbisrIC8vIGxcbiAgLCAgIE5VTUJFUl9ERUNJTUFMX1BPSU5UID0gX24rKyAvLyAuXG4gICwgICBOVU1CRVJfRElHSVQgICAgICAgICA9IF9uICAgLy8gWzAtOV1cblxuICAgICAgLy8gc2V0dXAgaW5pdGlhbCBwYXJzZXIgdmFsdWVzXG4gICwgICBidWZmZXJDaGVja1Bvc2l0aW9uICA9IE1BWF9CVUZGRVJfTEVOR1RIXG4gICwgICBsYXRlc3RFcnJvciAgICAgICAgICAgICAgICBcbiAgLCAgIGMgICAgICAgICAgICAgICAgICAgIFxuICAsICAgcCAgICAgICAgICAgICAgICAgICAgXG4gICwgICB0ZXh0Tm9kZSAgICAgICAgICAgICA9IHVuZGVmaW5lZFxuICAsICAgbnVtYmVyTm9kZSAgICAgICAgICAgPSBcIlwiICAgICBcbiAgLCAgIHNsYXNoZWQgICAgICAgICAgICAgID0gZmFsc2VcbiAgLCAgIGNsb3NlZCAgICAgICAgICAgICAgID0gZmFsc2VcbiAgLCAgIHN0YXRlICAgICAgICAgICAgICAgID0gQkVHSU5cbiAgLCAgIHN0YWNrICAgICAgICAgICAgICAgID0gW11cbiAgLCAgIHVuaWNvZGVTICAgICAgICAgICAgID0gbnVsbFxuICAsICAgdW5pY29kZUkgICAgICAgICAgICAgPSAwXG4gICwgICBkZXB0aCAgICAgICAgICAgICAgICA9IDBcbiAgLCAgIHBvc2l0aW9uICAgICAgICAgICAgID0gMFxuICAsICAgY29sdW1uICAgICAgICAgICAgICAgPSAwICAvL21vc3RseSBmb3IgZXJyb3IgcmVwb3J0aW5nXG4gICwgICBsaW5lICAgICAgICAgICAgICAgICA9IDFcbiAgO1xuXG4gIGZ1bmN0aW9uIGNoZWNrQnVmZmVyTGVuZ3RoICgpIHtcbiAgICAgXG4gICAgdmFyIG1heEFjdHVhbCA9IDA7XG4gICAgIFxuICAgIGlmICh0ZXh0Tm9kZSAhPT0gdW5kZWZpbmVkICYmIHRleHROb2RlLmxlbmd0aCA+IE1BWF9CVUZGRVJfTEVOR1RIKSB7XG4gICAgICBlbWl0RXJyb3IoXCJNYXggYnVmZmVyIGxlbmd0aCBleGNlZWRlZDogdGV4dE5vZGVcIik7XG4gICAgICBtYXhBY3R1YWwgPSBNYXRoLm1heChtYXhBY3R1YWwsIHRleHROb2RlLmxlbmd0aCk7XG4gICAgfVxuICAgIGlmIChudW1iZXJOb2RlLmxlbmd0aCA+IE1BWF9CVUZGRVJfTEVOR1RIKSB7XG4gICAgICBlbWl0RXJyb3IoXCJNYXggYnVmZmVyIGxlbmd0aCBleGNlZWRlZDogbnVtYmVyTm9kZVwiKTtcb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IGNsb3NlXCIpO1xuICAgIH1cblxuICAgIHZhciBpID0gMDtcbiAgICBjID0gY2h1bmtbMF07IFxuXG4gICAgd2hpbGUgKGMpIHtcbiAgICAgIHAgPSBjO1xuICAgICAgYyA9IGNodW5rW2krK107XG4gICAgICBpZighYykgYnJlYWs7XG5cbiAgICAgIHBvc2l0aW9uICsrO1xuICAgICAgaWYgKGMgPT0gXCJcXG5cIikge1xuICAgICAgICBsaW5lICsrO1xuICAgICAgICBjb2x1bW4gPSAwO1xuICAgICAgfSBlbHNlIGNvbHVtbiArKztcbiAgICAgIHN3aXRjaCAoc3RhdGUpIHtcblxuICAgICAgICBjYXNlIEJFR0lOOlxuICAgICAgICAgIGlmIChjID09PSBcIntcIikgc3RhdGUgPSBPUEVOX09CSkVDVDtcbiAgICAgICAgICBlbHNlIGlmIChjID09PSBcIltcIikgc3RhdGUgPSBPUEVOX0FSUkFZO1xuICAgICAgICAgIGVsc2UgaWYgKCF3aGl0ZXNwYWNlKGMpKVxuICAgICAgICAgICAgcmV0dXJuIGVtaXRFcnJvcihcIk5vbi13aGl0ZXNwYWNlIGJlZm9yZSB7Wy5cIik7XG4gICAgICAgIGNvbnRpbnVlO1xuXG4gICAgICAgIGNhc2UgT1BFTl9LRVk6XG4gICAgICAgIGNhc2UgT1BFTl9PQkpFQ1Q6XG4gICAgICAgICAgaWYgKHdoaXRlc3BhY2UoYykpIGNvbnRpbnVlO1xuICAgICAgICAgIGlmKHN0YXRlID09PSBPUEVOX0tFWSkgc3RhY2sucHVzaChDTE9TRV9LRVkpO1xuICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgaWYoYyA9PT0gJ30nKSB7XG4gICAgICAgICAgICAgIGVtaXRWYWx1ZU9wZW4oe30pO1xuICAgICAgICAgICAgICBlbWl0VmFsdWVDbG9zZSgpO1xuICAgICAgICAgICAgICBzdGF0ZSA9IHN0YWNrLnBvcCgpIHx8IFZBTFVFO1xuICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH0gZWxzZSAgc3RhY2sucHVzaChDTE9TRV9PQkpFQ1QpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZihjID09PSAnXCInKVxuICAgICAgICAgICAgIHN0YXRlID0gU1RSSU5HO1xuICAgICAgICAgIGVsc2VcbiAgICAgICAgICAgICByZXR1cm4gZW1pdEVycm9yKFwiTWFsZm9ybWVkIG9iamVjdCBrZXkgc2hvdWxkIHN0YXJ0IHdpdGggXFxcIiBcIik7XG4gICAgICAgIGNvbnRpbnVlO1xuXG4gICAgICAgIGNhc2UgQ0xPU0VfS0VZOlxuICAgICAgICBjYXNlIENMT1NFX09CSkVDVDpcbiAgICAgICAgICBpZiAod2hpdGVzcGFjZShjKSkgY29udGludWU7XG5cbiAgICAgICAgICBpZihjPT09JzonKSB7XG4gICAgICAgICAgICBpZihzdGF0ZSA9PT0gQ0xPU0VfT0JKRUNUKSB7XG4gICAgICAgICAgICAgIHN0YWNrLnB1c2goQ0xPU0VfT0JKRUNUKTtcblxuICAgICAgICAgICAgICAgaWYgKHRleHROb2RlICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgIC8vIHdhcyBwcmV2aW91c2x5IChpbiB1cHN0cmVhbSBDbGFyaW5ldCkgb25lIGV2ZW50XG4gICAgICAgICAgICAgICAgICAvLyAgLSBvYmplY3Qgb3BlbiBjYW1lIHdpdGggdGhlIHRleHQgb2YgdGhlIGZpcnN0XG4gICAgICAgICAgICAgICAgICBlbWl0VmFsdWVPcGVuKHt9KTtcbiAgICAgICAgICAgICAgICAgIGVtaXRTYXhLZXkodGV4dE5vZGUpO1xuICAgICAgICAgICAgICAgICAgdGV4dE5vZGUgPSB1bmRlZmluZWQ7XG4gICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICBkZXB0aCsrO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgIGlmICh0ZXh0Tm9kZSAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgICBlbWl0U2F4S2V5KHRleHROb2RlKTtcbiAgICAgICAgICAgICAgICAgIHRleHROb2RlID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgIHN0YXRlICA9IFZBTFVFO1xuICAgICAgICAgIH0gZWxzZSBpZiAoYz09PSd9Jykge1xuICAgICAgICAgICAgIGlmICh0ZXh0Tm9kZSAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgZW1pdFZhbHVlT3Blbih0ZXh0Tm9kZSk7XG4gICAgICAgICAgICAgICAgZW1pdFZhbHVlQ2xvc2UoKTtcbiAgICAgICAgICAgICAgICB0ZXh0Tm9kZSA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgZW1pdFZhbHVlQ2xvc2UoKTtcbiAgICAgICAgICAgIGRlcHRoLS07XG4gICAgICAgICAgICBzdGF0ZSA9IHN0YWNrLnBvcCgpIHx8IFZBTFVFO1xuICAgICAgICAgIH0gZWxzZSBpZihjPT09JywnKSB7XG4gICAgICAgICAgICBpZihzdGF0ZSA9PT0gQ0xPU0VfT0JKRUNUKVxuICAgICAgICAgICAgICBzdGFjay5wdXNoKENMT1NFX09CSkVDVCk7XG4gICAgICAgICAgICAgaWYgKHRleHROb2RlICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICBlbWl0VmFsdWVPcGVuKHRleHROb2RlKTtcbiAgICAgICAgICAgICAgICBlbWl0VmFsdWVDbG9zZSgpO1xuICAgICAgICAgICAgICAgIHRleHROb2RlID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICBzdGF0ZSAgPSBPUEVOX0tFWTtcbiAgICAgICAgICB9IGVsc2UgXG4gICAgICAgICAgICAgcmV0dXJuIGVtaXRFcnJvcignQmFkIG9iamVjdCcpO1xuICAgICAgICBjb250aW51ZTtcblxuICAgICAgICBjYXNlIE9QRU5fQVJSQVk6IC8vIGFmdGVyIGFuIGFycmF5IHRoZXJlIGFsd2F5cyBhIHZhbHVlXG4gICAgICAgIGNhc2UgVkFMVUU6XG4gICAgICAgICAgaWYgKHdoaXRlc3BhY2UoYykpIGNvbnRpbnVlO1xuICAgICAgICAgIGlmKHN0YXRlPT09T1BFTl9BUlJBWSkge1xuICAgICAgICAgICAgZW1pdFZhbHVlT3BlbihbXSk7XG4gICAgICAgICAgICBkZXB0aCsrOyAgICAgICAgICAgICBcbiAgICAgICAgICAgIHN0YXRlID0gVkFMVUU7XG4gICAgICAgICAgICBpZihjID09PSAnXScpIHtcbiAgICAgICAgICAgICAgZW1pdFZhbHVlQ2xvc2UoKTtcbiAgICAgICAgICAgICAgZGVwdGgtLTtcbiAgICAgICAgICAgICAgc3RhdGUgPSBzdGFjay5wb3AoKSB8fCBWQUxVRTtcbiAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBzdGFjay5wdXNoKENMT1NFX0FSUkFZKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgICAgICBpZihjID09PSAnXCInKSBzdGF0ZSA9IFNUUklORztcbiAgICAgICAgICBlbHNlIGlmKGMgPT09ICd7Jykgc3RhdGUgPSBPUEVOX09CSkVDVDtcbiAgICAgICAgICBlbHNlIGlmKGMgPT09ICdbJykgc3RhdGUgPSBPUEVOX0FSUkFZO1xuICAgICAgICAgIGVsc2UgaWYoYyA9PT0gJ3QnKSBzdGF0ZSA9IFRSVUU7XG4gICAgICAgICAgZWxzZSBpZihjID09PSAnZicpIHN0YXRlID0gRkFMU0U7XG4gICAgICAgICAgZWxzZSBpZihjID09PSAnbicpIHN0YXRlID0gTlVMTDtcbiAgICAgICAgICBlbHNlIGlmKGMgPT09ICctJykgeyAvLyBrZWVwIGFuZCBjb250aW51ZVxuICAgICAgICAgICAgbnVtYmVyTm9kZSArPSBjO1xuICAgICAgICAgIH0gZWxzZSBpZihjPT09JzAnKSB7XG4gICAgICAgICAgICBudW1iZXJOb2RlICs9IGM7XG4gICAgICAgICAgICBzdGF0ZSA9IE5VTUJFUl9ESUdJVDtcbiAgICAgICAgICB9IGVsc2UgaWYoJzEyMzQ1Njc4OScuaW5kZXhPZihjKSAhPT0gLTEpIHtcbiAgICAgICAgICAgIG51bWJlck5vZGUgKz0gYztcbiAgICAgICAgICAgIHN0YXRlID0gTlVNQkVSX0RJR0lUO1xuICAgICAgICAgIH0gZWxzZSAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgcmV0dXJuIGVtaXRFcnJvcihcIkJhZCB2YWx1ZVwiKTtcbiAgICAgICAgY29udGludWU7XG5cbiAgICAgICAgY2FzZSBDTE9TRV9BUlJBWTpcbiAgICAgICAgICBpZihjPT09JywnKSB7XG4gICAgICAgICAgICBzdGFjay5wdXNoKENMT1NFX0FSUkFZKTtcbiAgICAgICAgICAgICBpZiAodGV4dE5vZGUgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIGVtaXRWYWx1ZU9wZW4odGV4dE5vZGUpO1xuICAgICAgICAgICAgICAgIGVtaXRWYWx1ZUNsb3NlKCk7XG4gICAgICAgICAgICAgICAgdGV4dE5vZGUgPSB1bmRlZmluZWQ7XG4gICAgICAgICAgICAgfVxuICAgICAgICAgICAgIHN0YXRlICA9IFZBTFVFO1xuICAgICAgICAgIH0gZWxzZSBpZiAoYz09PSddJykge1xuICAgICAgICAgICAgIGlmICh0ZXh0Tm9kZSAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgZW1pdFZhbHVlT3Blbih0ZXh0Tm9kZSk7XG4gICAgICAgICAgICAgICAgZW1pdFZhbHVlQ2xvc2UoKTtcbiAgICAgICAgICAgICAgICB0ZXh0Tm9kZSA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgZW1pdFZhbHVlQ2xvc2UoKTtcbiAgICAgICAgICAgIGRlcHRoLS07XG4gICAgICAgICAgICBzdGF0ZSA9IHN0YWNrLnBvcCgpIHx8IFZBTFVFO1xuICAgICAgICAgIH0gZWxzZSBpZiAod2hpdGVzcGFjZShjKSlcbiAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgZWxzZSBcbiAgICAgICAgICAgICByZXR1cm4gZW1pdEVycm9yKCdCYWQgYXJyYXknKTtcbiAgICAgICAgY29udGludWU7XG5cbiAgICAgICAgY2FzZSBTVFJJTkc6XG4gICAgICAgICAgaWYgKHRleHROb2RlID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgdGV4dE5vZGUgPSBcIlwiO1xuICAgICAgICAgIH1cblxuICAgICAgICAgIC8vIHRoYW5rcyB0aGVqaCwgdGhpcyBpcyBhbiBhYm91dCA1MCUgcGVyZm9ybWFuY2UgaW1wcm92ZW1lbnQuXG4gICAgICAgICAgdmFyIHN0YXJ0aSAgICAgICAgICAgICAgPSBpLTE7XG4gICAgICAgICAgIFxuICAgICAgICAgIFNUUklOR19CSUdMT09QOiB3aGlsZSAodHJ1ZSkge1xuXG4gICAgICAgICAgICAvLyB6ZXJvIG1lYW5zIFwibm8gdW5pY29kZSBhY3RpdmVcIi4gMS00IG1lYW4gXCJwYXJzZSBzb21lIG1vcmVcIi4gZW5kIGFmdGVyIDQuXG4gICAgICAgICAgICB3aGlsZSAodW5pY29kZUkgPiAwKSB7XG4gICAgICAgICAgICAgIHVuaWNvZGVTICs9IGM7XG4gICAgICAgICAgICAgIGMgPSBjaHVuay5jaGFyQXQoaSsrKTtcbiAgICAgICAgICAgICAgaWYgKHVuaWNvZGVJID09PSA0KSB7XG4gICAgICAgICAgICAgICAgLy8gVE9ETyB0aGlzIG1pZ2h0IGJlIHNsb3c/IHdlbGwsIHByb2JhYmx5IG5vdCB1c2VkIHRvbyBvZnRlbiBhbnl3YXlcbiAgICAgICAgICAgICAgICB0ZXh0Tm9kZSArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKHBhcnNlSW50KHVuaWNvZGVTLCAxNikpO1xuICAgICAgICAgICAgICAgIHVuaWNvZGVJID0gMDtcbiAgICAgICAgICAgICAgICBzdGFydGkgPSBpLTE7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdW5pY29kZUkrKztcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAvLyB3ZSBjYW4ganVzdCBicmVhayBoZXJlOiBubyBzdHVmZiB3ZSBza2lwcGVkIHRoYXQgc3RpbGwgaGFzIHRvIGJlIHNsaWNlZCBvdXQgb3Igc29cbiAgICAgICAgICAgICAgaWYgKCFjKSBicmVhayBTVFJJTkdfQklHTE9PUDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChjID09PSAnXCInICYmICFzbGFzaGVkKSB7XG4gICAgICAgICAgICAgIHN0YXRlID0gc3RhY2sucG9wKCkgfHwgVkFMVUU7XG4gICAgICAgICAgICAgIHRleHROb2RlICs9IGNodW5rLnN1YnN0cmluZyhzdGFydGksIGktMSk7XG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGMgPT09ICdcXFxcJyAmJiAhc2xhc2hlZCkge1xuICAgICAgICAgICAgICBzbGFzaGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgdGV4dE5vZGUgKz0gY2h1bmsuc3Vic3RyaW5nKHN0YXJ0aSwgaS0xKTtcbiAgICAgICAgICAgICAgIGMgPSBjaHVuay5jaGFyQXQoaSsrKTtcbiAgICAgICAgICAgICAgaWYgKCFjKSBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzbGFzaGVkKSB7XG4gICAgICAgICAgICAgIHNsYXNoZWQgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICBpZiAoYyA9PT0gJ24nKSB7IHRleHROb2RlICs9ICdcXG4nOyB9XG4gICAgICAgICAgICAgIGVsc2UgaWYgKGMgPT09ICdyJykgeyB0ZXh0Tm9kZSArPSAnXFxyJzsgfVxuICAgICAgICAgICAgICBlbHNlIGlmIChjID09PSAndCcpIHsgdGV4dE5vZGUgKz0gJ1xcdCc7IH1cbiAgICAgICAgICAgICAgZWxzZSBpZiAoYyA9PT0gJ2YnKSB7IHRleHROb2RlICs9ICdcXGYnOyB9XG4gICAgICAgICAgICAgIGVsc2UgaWYgKGMgPT09ICdiJykgeyB0ZXh0Tm9kZSArPSAnXFxiJzsgfVxuICAgICAgICAgICAgICBlbHNlIGlmIChjID09PSAndScpIHtcbiAgICAgICAgICAgICAgICAvLyBcXHV4eHh4LiBtZWghXG4gICAgICAgICAgICAgICAgdW5pY29kZUkgPSAxO1xuICAgICAgICAgICAgICAgIHVuaWNvZGVTID0gJyc7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGV4dE5vZGUgKz0gYztcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBjID0gY2h1bmsuY2hhckF0KGkrKyk7XG4gICAgICAgICAgICAgIHN0YXJ0aSA9IGktMTtcbiAgICAgICAgICAgICAgaWYgKCFjKSBicmVhaztcbiAgICAgICAgICAgICAgZWxzZSBjb250aW51ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgc3RyaW5nVG9rZW5QYXR0ZXJuLmxhc3RJbmRleCA9IGk7XG4gICAgICAgICAgICB2YXIgcmVSZXN1bHQgPSBzdHJpbmdUb2tlblBhdHRlcm4uZXhlYyhjaHVuayk7XG4gICAgICAgICAgICBpZiAoIXJlUmVzdWx0KSB7XG4gICAgICAgICAgICAgIGkgPSBjaHVuay5sZW5ndGgrMTtcbiAgICAgICAgICAgICAgdGV4dE5vZGUgKz0gY2h1bmsuc3Vic3RyaW5nKHN0YXJ0aSwgaS0xKTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpID0gcmVSZXN1bHQuaW5kZXgrMTtcbiAgICAgICAgICAgIGMgPSBjaHVuay5jaGFyQXQocmVSZXN1bHQuaW5kZXgpO1xuICAgICAgICAgICAgaWYgKCFjKSB7XG4gICAgICAgICAgICAgIHRleHROb2RlICs9IGNodW5rLnN1YnN0cmluZyhzdGFydGksIGktMSk7XG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgY29udGludWU7XG5cbiAgICAgICAgY2FzZSBUUlVFOlxuICAgICAgICAgIGlmICghYykgIGNvbnRpbnVlOyAvLyBzdHJhbmdlIGJ1ZmZlcnNcbiAgICAgICAgICBpZiAoYz09PSdyJykgc3RhdGUgPSBUUlVFMjtcbiAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgcmV0dXJuIGVtaXRFcnJvciggJ0ludmFsaWQgdHJ1ZSBzdGFydGVkIHdpdGggdCcrIGMpO1xuICAgICAgICBjb250aW51ZTtcblxuICAgICAgICBjYXNlIFRSVUUyOlxuICAgICAgICAgIGlmICghYykgIGNvbnRpbnVlO1xuICAgICAgICAgIGlmIChjPT09J3UnKSBzdGF0ZSA9IFRSVUUzO1xuICAgICAgICAgIGVsc2VcbiAgICAgICAgICAgICByZXR1cm4gZW1pdEVycm9yKCdJbnZhbGlkIHRydWUgc3RhcnRlZCB3aXRoIHRyJysgYyk7XG4gICAgICAgIGNvbnRpbnVlO1xuXG4gICAgICAgIGNhc2UgVFJVRTM6XG4gICAgICAgICAgaWYgKCFjKSBjb250aW51ZTtcbiAgICAgICAgICBpZihjPT09J2UnKSB7XG4gICAgICAgICAgICBlbWl0VmFsdWVPcGVuKHRydWUpO1xuICAgICAgICAgICAgZW1pdFZhbHVlQ2xvc2UoKTtcbiAgICAgICAgICAgIHN0YXRlID0gc3RhY2sucG9wKCkgfHwgVkFMVUU7XG4gICAgICAgICAgfSBlbHNlXG4gICAgICAgICAgICAgcmV0dXJuIGVtaXRFcnJvcignSW52YWxpZCB0cnVlIHN0YXJ0ZWQgd2l0aCB0cnUnKyBjKTtcbiAgICAgICAgY29udGludWU7XG5cbiAgICAgICAgY2FzZSBGQUxTRTpcbiAgICAgICAgICBpZiAoIWMpICBjb250aW51ZTtcbiAgICAgICAgICBpZiAoYz09PSdhJykgc3RhdGUgPSBGQUxTRTI7XG4gICAgICAgICAgZWxzZVxuICAgICAgICAgICAgIHJldHVybiBlbWl0RXJyb3IoJ0ludmFsaWQgZmFsc2Ugc3RhcnRlZCB3aXRoIGYnKyBjKTtcbiAgICAgICAgY29udGludWU7XG5cbiAgICAgICAgY2FzZSBGQUxTRTI6XG4gICAgICAgICAgaWYgKCFjKSAgY29udGludWU7XG4gICAgICAgICAgaWYgKGM9PT0nbCcpIHN0YXRlID0gRkFMU0UzO1xuICAgICAgICAgIGVsc2VcbiAgICAgICAgICAgICByZXR1cm4gZW1pdEVycm9yKCdJbnZhbGlkIGZhbHNlIHN0YXJ0ZWQgd2l0aCBmYScrIGMpO1xuICAgICAgICBjb250aW51ZTtcblxuICAgICAgICBjYXNlIEZBTFNFMzpcbiAgICAgICAgICBpZiAoIWMpICBjb250aW51ZTtcbiAgICAgICAgICBpZiAoYz09PSdzJykgc3RhdGUgPSBGQUxTRTQ7XG4gICAgICAgICAgZWxzZVxuICAgICAgICAgICAgIHJldHVybiBlbWl0RXJyb3IoJ0ludmFsaWQgZmFsc2Ugc3RhcnRlZCB3aXRoIGZhbCcrIGMpO1xuICAgICAgICBjb250aW51ZTtcblxuICAgICAgICBjYXNlIEZBTFNFNDpcbiAgICAgICAgICBpZiAoIWMpICBjb250aW51ZTtcbiAgICAgICAgICBpZiAoYz09PSdlJykge1xuICAgICAgICAgICAgZW1pdFZhbHVlT3BlbihmYWxzZSk7XG4gICAgICAgICAgICBlbWl0VmFsdWVDbG9zZSgpO1xuICAgICAgICAgICAgc3RhdGUgPSBzdGFjay5wb3AoKSB8fCBWQUxVRTtcbiAgICAgICAgICB9IGVsc2VcbiAgICAgICAgICAgICByZXR1cm4gZW1pdEVycm9yKCdJbnZhbGlkIGZhbHNlIHN0YXJ0ZWQgd2l0aCBmYWxzJysgYyk7XG4gICAgICAgIGNvbnRpbnVlO1xuXG4gICAgICAgIGNhc2UgTlVMTDpcbiAgICAgICAgICBpZiAoIWMpICBjb250aW51ZTtcbiAgICAgICAgICBpZiAoYz09PSd1Jykgc3RhdGUgPSBOVUxMMjtcbiAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgcmV0dXJuIGVtaXRFcnJvcignSW52YWxpZCBudWxsIHN0YXJ0ZWQgd2l0aCBuJysgYyk7XG4gICAgICAgIGNvbnRpbnVlO1xuXG4gICAgICAgIGNhc2UgTlVMTDI6XG4gICAgICAgICAgaWYgKCFjKSAgY29udGludWU7XG4gICAgICAgICAgaWYgKGM9PT0nbCcpIHN0YXRlID0gTlVMTDM7XG4gICAgICAgICAgZWxzZVxuICAgICAgICAgICAgIHJldHVybiBlbWl0RXJyb3IoJ0ludmFsaWQgbnVsbCBzdGFydGVkIHdpdGggbnUnKyBjKTtcbiAgICAgICAgY29udGludWU7XG5cbiAgICAgICAgY2FzZSBOVUxMMzpcbiAgICAgICAgICBpZiAoIWMpIGNvbnRpbnVlO1xuICAgICAgICAgIGlmKGM9PT0nbCcpIHtcbiAgICAgICAgICAgIGVtaXRWYWx1ZU9wZW4obnVsbCk7XG4gICAgICAgICAgICBlbWl0VmFsdWVDbG9zZSgpO1xuICAgICAgICAgICAgc3RhdGUgPSBzdGFjay5wb3AoKSB8fCBWQUxVRTtcbiAgICAgICAgICB9IGVsc2UgXG4gICAgICAgICAgICAgcmV0dXJuIGVtaXRFcnJvcignSW52YWxpZCBudWxsIHN0YXJ0ZWQgd2l0aCBudWwnKyBjKTtcbiAgICAgICAgY29udGludWU7XG5cbiAgICAgICAgY2FzZSBOVU1CRVJfREVDSU1BTF9QT0lOVDpcbiAgICAgICAgICBpZihjPT09Jy4nKSB7XG4gICAgICAgICAgICBudW1iZXJOb2RlICs9IGM7XG4gICAgICAgICAgICBzdGF0ZSAgICAgICA9IE5VTUJFUl9ESUdJVDtcbiAgICAgICAgICB9IGVsc2UgXG4gICAgICAgICAgICAgcmV0dXJuIGVtaXRFcnJvcignTGVhZGluZyB6ZXJvIG5vdCBmb2xsb3dlZCBieSAuJyk7XG4gICAgICAgIGNvbnRpbnVlO1xuXG4gICAgICAgIGNhc2UgTlVNQkVSX0RJR0lUOlxuICAgICAgICAgIGlmKCcwMTIzNDU2Nzg5Jy5pbmRleE9mKGMpICE9PSAtMSkgbnVtYmVyTm9kZSArPSBjO1xuICAgICAgICAgIGVsc2UgaWYgKGM9PT0nLicpIHtcbiAgICAgICAgICAgIGlmKG51bWJlck5vZGUuaW5kZXhPZignLicpIT09LTEpXG4gICAgICAgICAgICAgICByZXR1cm4gZW1pdEVycm9yKCdJbnZhbGlkIG51bWJlciBoYXMgdHdvIGRvdHMnKTtcbiAgICAgICAgICAgIG51bWJlck5vZGUgKz0gYztcbiAgICAgICAgICB9IGVsc2UgaWYgKGM9PT0nZScgfHwgYz09PSdFJykge1xuICAgICAgICAgICAgaWYobnVtYmVyTm9kZS5pbmRleE9mKCdlJykhPT0tMSB8fFxuICAgICAgICAgICAgICAgbnVtYmVyTm9kZS5pbmRleE9mKCdFJykhPT0tMSApXG4gICAgICAgICAgICAgICByZXR1cm4gZW1pdEVycm9yKCdJbnZhbGlkIG51bWJlciBoYXMgdHdvIGV4cG9uZW50aWFsJyk7XG4gICAgICAgICAgICBudW1iZXJOb2RlICs9IGM7XG4gICAgICAgICAgfSBlbHNlIGlmIChjPT09XCIrXCIgfHwgYz09PVwiLVwiKSB7XG4gICAgICAgICAgICBpZighKHA9PT0nZScgfHwgcD09PSdFJykpXG4gICAgICAgICAgICAgICByZXR1cm4gZW1pdEVycm9yKCdJbnZhbGlkIHN5bWJvbCBpbiBudW1iZXInKTtcbiAgICAgICAgICAgIG51bWJlck5vZGUgKz0gYztcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKG51bWJlck5vZGUpIHtcbiAgICAgICAgICAgICAgZW1p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AgICcoaHR0cDovL25vZGVqcy5vcmcvYXBpL3N0cmVhbS5odG1sI3N0cmVhbV9jbGFzc19zdHJlYW1fcmVhZGFibGUpIGxpa2UgJyArIFxuICAgICAgICAgICAgJ29ib2UoZnMuY3JlYXRlUmVhZFN0cmVhbShcIm15X2ZpbGVcIikpLiBJIHdhcyBnaXZlbiB0aGUgVVJMOiAnICtcbiAgICAgICAgICAgIGNvbnRlbnRTb3VyY2VcbiAgICAgICAgICk7XG4gICAgICB9XG4gICAgICBcbiAgICAgIHZhciByZXEgPSBvcGVuVXJsQXNTdHJlYW0oY29udGVudFNvdXJjZSk7XG4gICAgICBcbiAgICAgIHJlcS5vbigncmVzcG9uc2UnLCBmdW5jdGlvbihyZXMpe1xuICAgICAgICAgdmFyIHN0YXR1c0NvZGUgPSByZXMuc3RhdHVzQ29kZSxcbiAgICAgICAgICAgICBzdWNjZXNzZnVsID0gU3RyaW5nKHN0YXR1c0NvZGUpWzBdID09IDI7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcbiAgICAgICAgIG9ib2VCdXMoSFRUUF9TVEFSVCkuZW1pdCggcmVzLnN0YXR1c0NvZGUsIHJlcy5oZWFkZXJzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXG4gICAgICAgICBpZiggc3VjY2Vzc2Z1bCApIHsgICAgICAgICAgXG4gICAgICAgICAgICAgICBcbiAgICAgICAgICAgIHJlYWRTdHJlYW1Ub0V2ZW50QnVzKHJlcylcbiAgICAgICAgICAgIFxuICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJlYWRTdHJlYW1Ub0VuZChyZXMsIGZ1bmN0aW9uKGVycm9yQm9keSl7XG4gICAgICAgICAgICAgICBvYm9lQnVzKEZBSUxfRVZFTlQpLmVtaXQoIFxuICAgICAgICAgICAgICAgICAgZXJyb3JSZXBvcnQoIHN0YXR1c0NvZGUsIGVycm9yQm9keSApXG4gICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICB9ICAgICAgXG4gICAgICB9KTtcbiAgICAgIFxuICAgICAgcmVxLm9uKCdlcnJvcicsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgIG9ib2VCdXMoRkFJTF9FVkVOVCkuZW1pdCggXG4gICAgICAgICAgICBlcnJvclJlcG9ydCh1bmRlZmluZWQsIHVuZGVmaW5lZCwgZSApXG4gICAgICAgICApO1xuICAgICAgfSk7XG4gICAgICBcbiAgICAgIG9ib2VCdXMoQUJPUlRJTkcpLm9uKCBmdW5jdGlvbigpe1xuICAgICAgICAgYWJvcnRlZCA9IHRydWU7XG4gICAgICAgICByZXEuYWJvcnQoKTtcbiAgICAgIH0pO1xuICAgICAgICAgXG4gICAgICBpZiggZGF0YSApIHtcbiAgICAgICAgIHJlcS53cml0ZShkYXRhKTtcbiAgICAgIH1cbiAgICAgIFxuICAgICAgcmVxLmVuZCgpOyAgICAgICAgIFxuICAgfVxuICAgXG4gICBpZiggaXNTdHJpbmcoY29udGVudFNvdXJjZSkgKSB7XG4gICAgICBmZXRjaFVybChjb250ZW50U291cmNlKTtcbiAgIH0gZWxzZSB7XG4gICAgICAvLyBjb250ZW50c291cmNlIGlzIGEgc3RyZWFtXG4gICAgICByZWFkU3RyZWFtVG9FdmVudEJ1cyhjb250ZW50U291cmNlKTsgICBcbiAgIH1cblxufVxuXG52YXIganNvblBhdGhTeW50YXggPSAoZnVuY3Rpb24oKSB7XG4gXG4gICB2YXJcbiAgIFxuICAgLyoqIFxuICAgICogRXhwb3J0IGEgcmVndWxhciBleHByZXNzaW9uIGFzIGEgc2ltcGxlIGZ1bmN0aW9uIGJ5IGV4cG9zaW5nIGp1c3QgXG4gICAgKiB0aGUgUmVnZXgjZXhlYy4gVGhpcyBhbGxvd3MgcmVnZXggdGVzdHMgdG8gYmUgdXNlZCB1bmRlciB0aGUgc2FtZSBcbiAgICAqIGludGVyZmFjZSBhcyBkaWZmZXJlbnRseSBpb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G5cbiAgICAgICAgICAgIC8vIFRoZSByZWd1bGFyIGV4cHJlc3Npb25zIGFsbCBzdGFydCB3aXRoIF4gYmVjYXVzZSB3ZSBcbiAgICAgICAgICAgIC8vIG9ubHkgd2FudCB0byBmaW5kIG1hdGNoZXMgYXQgdGhlIHN0YXJ0IG9mIHRoZSBcbiAgICAgICAgICAgIC8vIEpTT05QYXRoIGZyYWdtZW50IHdlIGFyZSBpbnNwZWN0aW5nICAgICAgICAgICBcbiAgICAgICAgICAgIGNvbXBvbmVudFJlZ2V4ZXMudW5zaGlmdCgvXi8pO1xuICAgICAgICAgICAgXG4gICAgICAgICAgICByZXR1cm4gICByZWdleERlc2NyaXB0b3IoXG4gICAgICAgICAgICAgICAgICAgICAgICBSZWdFeHAoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRSZWdleGVzLm1hcChhdHRyKCdzb3VyY2UnKSkuam9pbignJylcbiAgICAgICAgICAgICAgICAgICAgICAgIClcbiAgICAgICAgICAgICAgICAgICAgICk7XG4gICAgICAgfSlcbiAgICAgICBcbiAgICwgICBwb3NzaWJseUNhcHR1cmluZyA9ICAgICAgICAgICAvKFxcJD8pL1xuICAgLCAgIG5hbWVkTm9kZSA9ICAgICAgICAgICAgICAgICAgIC8oW1xcdy1fXSt8XFwqKS9cbiAgICwgICBuYW1lUGxhY2Vob2xkZXIgPSAgICAgICAgICAgICAvKCkvXG4gICAsICAgbm9kZUluQXJyYXlOb3RhdGlvbiA9ICAgICAgICAgL1xcW1wiKFteXCJdKylcIlxcXS9cbiAgICwgICBudW1iZXJlZE5vZGVJbkFycmF5Tm90YXRpb24gPSAvXFxbKFxcZCt8XFwqKVxcXS9cbiAgICwgICBmaWVsZExpc3QgPSAgICAgICAgICAgICAgICAgICAgICAveyhbXFx3IF0qPyl9L1xuICAgLCAgIG9wdGlvbmFsRmllbGRMaXN0ID0gICAgICAgICAgIC8oPzp7KFtcXHcgXSo/KX0pPy9cbiAgICBcblxuICAgICAgIC8vICAgZm9vIG9yICogICAgICAgICAgICAgICAgICBcbiAgICwgICBqc29uUGF0aE5hbWVkTm9kZUluT2JqZWN0Tm90YXRpb24gICA9IGpzb25QYXRoQ2xhdXNlKCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvc3NpYmx5Q2FwdHVyaW5nLCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWVkTm9kZSwgXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25hbEZpZWxkTGlzdFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXG4gICAgICAgLy8gICBbXCJmb29cIl0gICBcbiAgICwgICBqc29uUGF0aE5hbWVkTm9kZUluQXJyYXlOb3RhdGlvbiAgICA9IGpzb25QYXRoQ2xhdXNlKCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvc3NpYmx5Q2FwdHVyaW5nLCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGVJbkFycmF5Tm90YXRpb24sIFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxGaWVsZExpc3RcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICkgIFxuXG4gICAgICAgLy8gICBbMl0gb3IgWypdICAgICAgIFxuICAgLCAgIGpzb25QYXRoTnVtYmVyZWROb2RlSW5BcnJheU5vdGF0aW9uID0ganNvblBhdGhDbGF1c2UoIFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9zc2libHlDYXB0dXJpbmcsIFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbnVtYmVyZWROb2RlSW5BcnJheU5vdGF0aW9uLCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbmFsRmllbGRMaXN0XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApXG5cbiAgICAgICAvLyAgIHthIGIgY30gICAgICBcbiAgICwgICBqc29uUGF0aFB1cmVEdWNrVHlwaW5nICAgICAgICAgICAgICA9IGpzb25QYXRoQ2xhdXNlKCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvc3NpYmx5Q2FwdHVyaW5nLCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWVQbGFjZWhvbGRlciwgXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZExpc3RcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIClcbiAgIFxuICAgICAgIC8vICAgLi5cbiAgICwgICBqc29uUGF0aERvdWJsZURvdCAgICAgICAgICAgICAgICAgICA9IGpzb25QYXRoQ2xhdXNlKC9cXC5cXC4vKSAgICAgICAgICAgICAgICAgIFxuICAgXG4gICAgICAgLy8gICAuXG4gICAsICAganNvblBhdGhEb3QgICAgICAgICAgICAgICAgICAgICAgICAgPSBqc29uUGF0aENsYXVzZSgvXFwuLykgICAgICAgICAgICAgICAgICAgIFxuICAgXG4gICAgICAgLy8gICAhXG4gICAsICAganNvblBhdGhCYW5nICAgICAgICAgICAgICAgICAgICAgICAgPSBqc29uUGF0aENsYXVzZShcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvc3NpYmx5Q2FwdHVyaW5nLCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8hL1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKSAgXG4gICBcbiAgICAgICAvLyAgIG5hZGEhXG4gICAsICAgZW1wdHlTdHJpbmcgICAgICAgICAgICAgICAgICAgICAgICAgPSBqc29uUGF0aENsYXVzZSgvJC8pICAgICAgICAgICAgICAgICAgICAgXG4gICBcbiAgIDtcbiAgIFxuICBcbiAgIC8qIFdlIGV4cG9ydCBvbmx5IGEgc2luZ2xlIGZ1bmN0aW9uLiBXaGVuIGNhbGxlZCwgdGhpcyBmdW5jdGlvbiBpbmplY3RzIFxuICAgICAgaW50byBhbm90aGVyIGZ1bmN0aW9uIHRoZSBkZXNjcmlwdG9ycyBmcm9tIGFib3ZlLiAgICAgICAgICAgICBcbiAgICAqL1xuICAgcmV0dXJuIGZ1bmN0aW9uIChmbil7ICAgICAgXG4gICAgICByZXR1cm4gZm4oICAgICAgXG4gICAgICAgICBsYXp5VW5pb24oXG4gICAgICAgICAgICBqc29uUGF0aE5hbWVkTm9kZUluT2JqZWN0Tm90YXRpb25cbiAgICAgICAgICwgIGpzb25QYXRoTmFtZWROb2RlSW5BcnJheU5vdGF0aW9uXG4gICAgICAgICAsICBqc29uUGF0aE51bWJlcmVkTm9kZUluQXJyYXlOb3RhdGlvblxuICAgICAgICAgLCAganNvblBhdGhQdXJlRHVja1R5cGluZyBcbiAgICAgICAgIClcbiAgICAgICwgIGpzb25QYXRoRG91YmxlRG90XG4gICAgICAsICBqc29uUGF0aERvdFxuICAgICAgLCAganNvblBhdGhCYW5nXG4gICAgICAsICBlbXB0eVN0cmluZyBcbiAgICAgICk7XG4gICB9OyBcblxufSgpKTtcbi8qKlxuICogR2V0IGEgbmV3IGtleS0+bm9kZSBtYXBwaW5nXG4gKiBcbiAqIEBwYXJhbSB7U3RyaW5nfE51bWJlcn0ga2V5XG4gKiBAcGFyYW0ge09iamVjdHxBcnJheXxTdHJpbmd8TnVtYmVyfG51bGx9IG5vZGUgYSB2YWx1ZSBm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9kZVxuICAgICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICAgOiAgXG4gICAgICAgICAgICAgICAgICAvLyBub3RoaW5nIG5lZWRlZCwgcmV0dXJuIHVuY2hhbmdlZFxuICAgICAgICAgICAgICAgICAgcG9zc2libHlJbmNvbnNpc3RlbnRBc2NlbnQgXG4gICAgICAgICAgICAgICA7XG4gICB9XG4gICAgICAgICAgICAgICAgIFxuICAgZnVuY3Rpb24gbm9kZU9wZW5lZCggYXNjZW50LCBuZXdEZWVwZXN0Tm9kZSApIHtcbiAgICAgIFxuICAgICAgaWYoICFhc2NlbnQgKSB7XG4gICAgICAgICAvLyB3ZSBkaXNjb3ZlcmVkIHRoZSByb290IG5vZGUsICAgICAgICAgXG4gICAgICAgICBlbWl0Um9vdE9wZW5lZCggbmV3RGVlcGVzdE5vZGUpO1xuICAgICAgICAgICAgICAgICAgICBcbiAgICAgICAgIHJldHVybiBrZXlGb3VuZCggYXNjZW50LCBST09UX1BBVEgsIG5ld0RlZXBlc3ROb2RlKTsgICAgICAgICBcbiAgICAgIH1cblxuICAgICAgLy8gd2UgZGlzY292ZXJlZCBhIG5vbi1yb290IG5vZGVcbiAgICAgICAgICAgICAgICAgXG4gICAgICB2YXIgYXJyYXlDb25zaXN0ZW50QXNjZW50ICA9IGFycmF5SW5kaWNlc0FyZUtleXMoIGFzY2VudCwgbmV3RGVlcGVzdE5vZGUpLCAgICAgIFxuICAgICAgICAgIGFuY2VzdG9yQnJhbmNoZXMgICAgICAgPSB0YWlsKCBhcnJheUNvbnNpc3RlbnRBc2NlbnQpLFxuICAgICAgICAgIHByZXZpb3VzbHlVbm1hcHBlZE5hbWUgPSBrZXlPZiggaGVhZCggYXJyYXlDb25zaXN0ZW50QXNjZW50KSk7XG4gICAgICAgICAgXG4gICAgICBhcHBlbmRCdWlsdENvbnRlbnQoIFxuICAgICAgICAgYW5jZXN0b3JCcmFuY2hlcywgXG4gICAgICAgICBwcmV2aW91c2x5VW5tYXBwZWROYW1lLCBcbiAgICAgICAgIG5ld0RlZXBlc3ROb2RlIFxuICAgICAgKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxuICAgICAgcmV0dXJuIGNvbnMoIFxuICAgICAgICAgICAgICAgbmFtZWROb2RlKCBwcmV2aW91c2x5VW5tYXBwZWROYW1lLCBuZXdEZWVwZXN0Tm9kZSApLCBcbiAgICAgICAgICAgICAgIGFuY2VzdG9yQnJhbmNoZXNcbiAgICAgICk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcbiAgIH1cblxuXG4gICAvKipcbiAgICAqIEFkZCBhIG5ldyB2YWx1ZSB0byB0aGUgb2JqZWN0IHdlIGFyZSBidWlsZGluZyB1cCB0byByZXByZXNlbnQgdGhlXG4gICAgKiBwYXJzZWQgSlNPTlxuICAgICovXG4gICBmdW5jdGlvbiBhcHBlbmRCdWlsdENvbnRlbnQoIGFuY2VzdG9yQnJhbmNoZXMsIGtleSwgbm9kZSApe1xuICAgICBcbiAgICAgIG5vZGVPZiggaGVhZCggYW5jZXN0b3JCcmFuY2hlcykpW2tleV0gPSBub2RlO1xuICAgfVxuXG4gICAgIFxuICAgLyoqXG4gICAgKiBGb3Igd2hlbiB3ZSBmaW5kIGEgbmV3IGtleSBpbiB0aGUganNvbi5cbiAgICAqIFxuICAgICogQHBhcmFtIHtTdHJpbmd8TnVtYmVyfE9iamVjdH0gbmV3RGVlcGVzdE5hbWUgdGhlIGtleS4gSWYgd2UgYXJlIGluIGFuIFxuICAgICogICAgYXJyYXkgd2lsbCBiZSBhIG51bWJlciwgb3RoZXJ3aXNlIGEgc3RyaW5nLiBNYXkgdGFrZSB0aGUgc3BlY2lhbCBcbiAgICAqICAgIHZhbHVlIFJPT1RfUEFUSCBpZiB0aGUgcm9vdCBub2RlIGhhcyBqdXN0IGJlZW4gZm91bmRcbiAgICAqICAgIFxuICAgICogQHBhcmFtIHtTdHJpbmd8TnVtYmVyfE9iamVjdHxBcnJheXxOdWxsfHVuZGVmaW5lZH0gW21heWJlTmV3RGVlcGVzdE5vZGVdIFxuICAgICogICAgdXN1YWxseSB0aGlzIHdvbid0IGJlIGtub3duIHNvIGNhbiBiZSB1bmRlZmluZWQuIENhbid0IHVzZSBudWxsIFxuICAgICogICAgdG8gcmVwcmVzZW50IHVua25vd24gYmVjYXVzZSBudWxsIGlzIGEgdmFsaWQgdmFsdWUgaW4gSlNPTlxuICAgICoqLyAgXG4gICBmdW5jdGlvbiBrZXlGb3VuZChhc2NlbnQsIG5ld0RlZXBlc3ROYW1lLCBtYXliZU5ld0RlZXBlc3ROb2RlKSB7XG5cbiAgICAgIGlmKCBhc2NlbnQgKSB7IC8vIGlmIG5vdCByb290XG4gICAgICBcbiAgICAgICAgIC8vIElmIHdlIGhhdmUgdGhlIGtleSBidXQgKHVubGVzcyBhZGRpbmcgdG8gYW4gYXJyYXkpIG5vIGtub3duIHZhbHVlXG4gICAgICAgICAvLyB5ZXQuIFB1dCB0aGF0IGtleSBpbiB0aGUgb3V0cHV0IGJ1dCBhZ2FpbnN0IG5vIGRlZmluZWQgdmFsdWU6ICAgICAgXG4gICAgICAgICBhcHBlbmRCdWlsdENvbnRlbnQoIGFzY2VudCwgbmV3RGVlcGVzdE5hbWUsIG1heWJlTmV3RGVlcGVzdE5vZGUgKTtcbiAgICAgIH1cbiAgIFxuICAgICAgdmFyIGFzY2VudFdpdGhOZXdQYXRoID0gY29ucyggXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lZE5vZGUoIG5ld0RlZXBlc3ROYW1lLCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF5YmVOZXdEZWVwZXN0Tm9kZSksIFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC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hwb3NlZC4gVGhpcyBmdW5jdGlvbiB0YWtlcyBhIFN0cmluZyBKU09OUGF0aCBzcGVjIGFuZCBcbiAqIHJldHVybnMgYSBmdW5jdGlvbiB0byB0ZXN0IGNhbmRpZGF0ZSBhc2NlbnRzIGZvciBtYXRjaGVzLlxuICogXG4gKiAgU3RyaW5nIGpzb25QYXRoIC0+IChMaXN0IGFzY2VudCkgLT4gQm9vbGVhbnxPYmplY3RcbiAqXG4gKiBUaGlzIGZpbGUgaXMgY29kZWQgaW4gYSBwdXJlIGZ1bmN0aW9uYWwgc3R5bGUuIFRoYXQgaXMsIG5vIGZ1bmN0aW9uIGhhcyBcbiAqIHNpZGUgZWZmZWN0cywgZXZlcnkgZnVuY3Rpb24gZXZhbHVhdGVzIHRvIHRoZSBzYW1lIHZhbHVlIGZvciB0aGUgc2FtZSBcbiAqIGFyZ3VtZW50cyBhbmQgbm8gdmFyaWFibGVzIGFyZSByZWFzc2lnbmVkLlxuICovICBcbi8vIHRoZSBjYWxsIHRvIGpzb25QYXRoU3ludGF4IGluamVjdHMgdGhlIHRva2VuIHN5bnRheGVzIHRoYXQgYXJlIG5lZWRlZCBcbi8vIGluc2lkZSB0aGUgY29tcGlsZXJcbnZhciBqc29uUGF0aENvbXBpbGVyID0ganNvblBhdGhTeW50YXgoZnVuY3Rpb24gKHBhdGhOb2RlU3ludGF4LCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvdWJsZURvdFN5bnRheCwgXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb3RTeW50YXgsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYW5nU3ludGF4LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW1wdHlTeW50YXggKSB7XG5cbiAgIHZhciBDQVBUVVJJTkdfSU5ERVggPSAxO1xuICAgdmFyIE5BTUVfSU5ERVggPSAyO1xuICAgdmFyIEZJRUxEX0xJU1RfSU5ERVggPSAzO1xuXG4gICB2YXIgaGVhZEtleSAgPSBjb21wb3NlMihrZXlPZiwgaGVhZCksXG4gICAgICAgaGVhZE5vZGUgPSBjb21wb3NlMihub2RlT2YsIGhlYWQpO1xuICAgICAgICAgICAgICAgICAgIFxuICAgLyoqXG4gICAgKiBDcmVhdGUgYW4gZXZhbHVhdG9yIGZ1bmN0aW9uIGZvciBhIG5hbWVkIHBhdGggbm9kZSwgZXhwcmVzc2VkIGluIHRoZVxuICAgICogSlNPTlBhdGggbGlrZTpcbiAgICAqICAgIGZvb1xuICAgICogICAgW1wiYmFyXCJdXG4gICAgKiAgICBbMl0gICBcbiAgICAqL1xuICAgZnVuY3Rpb24gbmFtZUNsYXVzZShwcmV2aW91c0V4cHIsIGRldGVjdGlvbiApIHtcbiAgICAgXG4gICAgICB2YXIgbmFtZSA9IGRldGVjdGlvbltOQU1FX0lOREVYXSxcbiAgICAgICAgICAgIFxuICAgICAgICAgIG1hdGNoZXNOYW1lID0gKCAhbmFtZSB8fCBuYW1lID09ICcqJyApIFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgPyAgYWx3YXlzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICA6ICBmdW5jdGlvbihhc2NlbnQpe3JldHVybiBoZWFkS2V5KGFzY2VudCkgPT0gbmFtZX07XG4gICAgIFxuXG4gICAgICByZXR1cm4gbGF6eUludGVyc2VjdGlvbihtYXRjaGVzTmFtZSwgcHJldmlvdXNFeHByKTtcbiAgIH1cblxuICAgLyoqXG4gICAgKiBDcmVhdGUgYW4gZXZhbHVhdG9yIGZ1bmN0aW9uIGZvciBhIGEgZHVjay10eXBlZCBub2RlLCBleHByZXNzZWQgbGlrZTpcbiAgICAqIFxuICAgICogICAge3NwaW4sIHRhc3RlLCBjb2xvdXJ9XG4gICAgKiAgICAucGFydGljbGV7c3BpbiwgdGFzdGUsIGNvbG91cn1cbiAgICAqICAgICp7c3BpbiwgdGFzdGUsIGNvbG91cn1cbiAgICAqL1xuICAgZnVuY3Rpb24gZHVja1R5cGVDbGF1c2UocHJldmlvdXNFeHByLCBkZXRlY3Rpb24pIHtcblxuICAgICAgdmFyIGZpZWxkTGlzdFN0ciA9IGRldGVjdGlvbltGSUVMRF9MSVNUX0lOREVYXTtcblxuICAgICAgaWYgKCFmaWVsZExpc3RTdHIpIFxuICAgICAgICAgcmV0dXJuIHByZXZpb3VzRXhwcjsgLy8gZG9uJ3Qgd3JhcCBhdCBhbGwsIHJldHVybiBnaXZlbiBleHByIGFzLWlzICAgICAgXG5cbiAgICAgIHZhciBoYXNBbGxyZXF1aXJlZEZpZWxkcyA9IHBhcnRpYWxDb21wbGV0ZShcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc0FsbFByb3BlcnRpZXMsIFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJyYXlBc0xpc3QoZmllbGRMaXN0U3RyLnNwbGl0KC9cXFcrLykpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXG4gICAgICAgICAgaXNNYXRjaCA9ICBjb21wb3NlMiggXG4gICAgICAgICAgICAgICAgICAgICAgICBoYXNBbGxyZXF1aXJlZEZpZWxkcywgXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkTm9kZVxuICAgICAgICAgICAgICAgICAgICAgKTtcblxuICAgICAgcmV0dXJuIGxhenlJbnRlcnNlY3Rpb24oaXNNYXRjaCwgcHJldmlvdXNFeHByKTtcbiAgIH1cblxuICAgLyoqXG4gICAgKiBFeHByZXNzaW9uIGZvciAkLCByZXR1cm5zIHRoZSBldmFsdWF0b3IgZnVuY3Rpb25cbiAgICAqL1xuICAgZnVuY3Rpb24gY2FwdHVyZSggcHJldmlvdXNFeHByLCBkZXRlY3Rpb24gKSB7XG5cbiAgICAgIC8vIGV4dHJhY3Q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gICAgICAgIHJlYWNoZXMgdGhlIGxhc3QgaXRlbSBpbiB0aGUgbGlzdC4gKi9cbiAgICAgICAgICAgICAgIG5vdEF0Um9vdCxcbiAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgLyogV2UgYXJlIG5vdCBhdCB0aGUgcm9vdCBvZiB0aGUgYXNjZW50IHlldC5cbiAgICAgICAgICAgICAgICAgIE1vdmUgdG8gdGhlIG5leHQgbGV2ZWwgb2YgdGhlIGFzY2VudCBieSBoYW5kaW5nIG9ubHkgXG4gICAgICAgICAgICAgICAgICB0aGUgdGFpbCB0byB0aGUgcHJldmlvdXMgZXhwcmVzc2lvbiAqLyBcbiAgICAgICAgICAgICAgIGNvbXBvc2UyKHByZXZpb3VzRXhwciwgdGFpbCkgXG4gICAgICApO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXG4gICB9ICAgXG4gICBcbiAgIC8qKlxuICAgICogQ3JlYXRlIGFuIGV2YWx1YXRvciBmdW5jdGlvbiBmb3IgdGhlIC4uIChkb3VibGUgZG90KSB0b2tlbi4gQ29uc3VtZXNcbiAgICAqIHplcm8gb3IgbW9yZSBsZXZlbHMgb2YgdGhlIGFzY2VudCwgdGhlIGZld2VzdCB0aGF0IGFyZSByZXF1aXJlZCB0byBmaW5kXG4gICAgKiBhIG1hdGNoIHdoZW4gZ2l2ZW4gdG8gcHJldmlvdXNFeHByLlxuICAgICovICAgXG4gICBmdW5jdGlvbiBza2lwTWFueShwcmV2aW91c0V4cHIpIHtcblxuICAgICAgaWYoIHByZXZpb3VzRXhwciA9PSBhbHdheXMgKSB7XG4gICAgICAgICAvKiBJZiB0aGVyZSBpcyBubyBwcmV2aW91cyBleHByZXNzaW9uIHRoaXMgY29uc3VtZSBjb21tYW5kIFxuICAgICAgICAgICAgaXMgYXQgdGhlIHN0YXJ0IG9mIHRoZSBqc29uUGF0aC5cbiAgICAgICAgICAgIFNpbmNlIEpTT05QYXRoIHNwZWNpZmllcyB3aGF0IHdlJ2QgbGlrZSB0byBmaW5kIGJ1dCBub3QgXG4gICAgICAgICAgICBuZWNlc3NhcmlseSBldmVyeXRoaW5nIGxlYWRpbmcgZG93biB0byBpdCwgd2hlbiBydW5uaW5nXG4gICAgICAgICAgICBvdXQgb2YgSlNPTlBhdGggdG8gY2hlY2sgYWdhaW5zdCB3ZSBkZWZhdWx0IHRvIHRydWUgKi8gICAgICAgICAgICBcbiAgICAgICAgIHJldHVybiBhbHdheXM7XG4gICAgICB9XG4gICAgICAgICAgXG4gICAgICB2YXIgXG4gICAgICAgICAgLy8gSW4gSlNPTlBhdGggLi4gaXMgZXF1aXZhbGVudCB0byAhLi4gc28gaWYgLi4gcmVhY2hlcyB0aGUgcm9vdFxuICAgICAgICAgIC8vIHRoZSBtYXRjaCBoYXMgc3VjY2VlZGVkLiBJZSwgd2UgbWlnaHQgd3JpdGUgLi5mb28gb3IgIS4uZm9vXG4gICAgICAgICAgLy8gYW5kIGJvdGggc2hvdWxkIG1hdGNoIGlkZW50aWNhbGx5LlxuICAgICAgICAgIHRlcm1pbmFsQ2FzZVdoZW5BcnJpdmluZ0F0Um9vdCA9IHJvb3RFeHByKCksXG4gICAgICAgICAgdGVybWluYWxDYXNlV2hlblByZXZpb3VzRXhwcmVzc2lvbklzU2F0aXNmaWVkID0gcHJldmlvdXNFeHByLFxuICAgICAgICAgIHJlY3Vyc2l2ZUNhc2UgPSBza2lwMShmdW5jdGlvbihhc2NlbnQpIHtcbiAgICAgICAgICAgICByZXR1cm4gY2FzZXMoYXNjZW50KTtcbiAgICAgICAgICB9KSxcblxuICAgICAgICAgIGNhc2VzID0gbGF6eVVuaW9uKFxuICAgICAgICAgICAgICAgICAgICAgdGVybWluYWxDYXNlV2hlbkFycml2aW5nQXRSb290XG4gICAgICAgICAgICAgICAgICAsICB0ZXJtaW5hbENhc2VXaG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HByZXNzaW9uc1JlYWRlcihcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsYXVzZUV2YWx1YXRvckdlbmVyYXRvcnMsIFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2VyR2VuZXJhdGVkU29GYXIsIFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV0ZWN0ZWRcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICksXG4gICAgICAgICBcbiAgICAgICAgICAgICByZW1haW5pbmdVbnBhcnNlZEpzb25QYXRoID0ganNvblBhdGguc3Vic3RyKGxlbihkZXRlY3RlZFswXSkpOyAgICAgICAgICAgICAgICBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcbiAgICAgICAgIHJldHVybiBvblN1Y2Nlc3MocmVtYWluaW5nVW5wYXJzZWRKc29uUGF0aCwgY29tcGlsZWRQYXJzZXIpO1xuICAgICAgfSAgICAgICAgIFxuICAgfVxuICAgICAgICAgICAgICAgICBcbiAgIC8qKlxuICAgICogUGFydGlhbGx5IGNvbXBsZXRlcyBnZW5lcmF0ZUNsYXVzZVJlYWRlcklmVG9rZW5Gb3VuZCBhYm92ZS4gXG4gICAgKi9cbiAgIGZ1bmN0aW9uIGNsYXVzZU1hdGNoZXIodG9rZW5EZXRlY3RvciwgZXhwcnMpIHtcbiAgICAgICAgXG4gICAgICByZXR1cm4gICBwYXJ0aWFsQ29tcGxldGUoIFxuICAgICAgICAgICAgICAgICAgZ2VuZXJhdGVDbGF1c2VSZWFkZXJJZlRva2VuRm91bmQsIFxuICAgICAgICAgICAgICAgICAgdG9rZW5EZXRlY3RvciwgXG4gICAgICAgICAgICAgICAgICBleHBycyBcbiAgICAgICAgICAgICAgICk7XG4gICB9XG5cbiAgIC8qKlxuICAgICogY2xhdXNlRm9ySnNvblBhdGggaXMgYSBmdW5jdGlvbiB3aGljaCBhdHRlbXB0cyB0byBtYXRjaCBhZ2FpbnN0IFxuICAgICogc2V2ZXJhbCBjbGF1c2UgbWF0Y2hlcnMgaW4gb3JkZXIgdW50aWwgb25lIG1hdGNoZXMuIElmIG5vbiBtYXRjaCB0aGVcbiAgICAqIGpzb25QYXRoIGV4cHJlc3Npb24gaXMgaW52YWxpZCBhbmQgYW4gZXJyb3IgaXMgdGhyb3duLlxuICAgICogXG4gICAgKiBUaGUgcGFyYW1ldGVyIGxpc3QgaXMgdGhlIHNhbWUgYXMgYSBzaW5nbGUgY2xhdXNlTWF0Y2hlcjpcbiAgICAqIFxuICAgICogICAgKGpzb25QYXRoLCBwYXJzZXJHZW5lcmF0ZWRTb0Zhciwgb25TdWNjZXNzKVxuICAgICovICAgICBcbiAgIHZhciBjbGF1c2VGb3JKc29uUGF0aCA9IGxhenlVbmlvbihcblxuICAgICAgY2xhdXNlTWF0Y2hlcihwYXRoTm9kZVN5bnRheCAgICwgbGlzdCggY2FwdHVyZSwgXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkdWNrVHlwZUNsYXVzZSwgXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lQ2xhdXNlLCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNraXAxICkpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxuICAgLCAgY2xhdXNlTWF0Y2hlcihkb3VibGVEb3RTeW50YXggICwgbGlzdCggc2tpcE1hbnkpKVxuICAgICAgIFxuICAgICAgIC8vIGRvdCBpcyBhIHNlcGFyYXRvciBvbmx5IChsaWtlIHdoaXRlc3BhY2UgaW4gb3RoZXIgbGFuZ3VhZ2VzKSBidXQgXG4gICAgICAgLy8gcmF0aGVyIHRoYW4gbWFrZSBpdCBhIHNwZWNpYWwgY2FzZSwgdXNlIGFuIGVtcHR5IGxpc3Qgb2YgXG4gICAgICAgLy8gZXhwcmVzc2lvbnMgd2hlbiB0aGlzIHRva2VuIGlzIGZvdW5kXG4gICAsICBjbGF1c2VNYXRjaGVyKGRvdFN5bnRheCAgICAgICAgLCBsaXN0KCkgKSAgXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxuICAgLCAgY2xhdXNlTWF0Y2hlcihiYW5nU3ludGF4ICAgICAgICwgbGlzdCggY2FwdHVyZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvb3RFeHByKSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcbiAgICwgIGNsYXVzZU1hdGNoZXIoZW1wdHlTeW50YXggICAgICAsIGxpc3QoIHN0YXRlbWVudEV4cHIpKVxuICAgXG4gICAsICBmdW5jdGlvbiAoanNvblBhdGgpIHtcbiAgICAgICAgIHRocm93IEVycm9yKCdcIicgKyBqc29uUGF0aCArICdcIiBjb3VsZCBub3QgYmUgdG9rZW5pc2VkJykgICAgICBcbiAgICAgIH1cbiAgICk7XG5cblxuICAgLyoqXG4gICAgKiBPbmUgb2YgdHdvIHBvc3NpYmxlIHZhbHVlcyBmb3IgdGhlIG9uU3VjY2VzcyBhcmd1bWVudCBvZiBcbiAgICAqIGdlbmVyYXRlQ2xhdXNlUmVhZGVySWZUb2tlbkZvdW5kLlxuICAgICogXG4gICAgKiBXaGVuIHRoaXMgZnVuY3Rpb24gaXMgdXNlZCwgZ2VuZXJhdGVDbGF1c2VSZWFkZXJJZlRva2VuRm91bmQgc2ltcGx5IFxuICAgICogcmV0dXJucyB0aGUgY29tcGlsZWRQYXJzZXIgdGhhdCBpdCBtYWRlLCByZWdhcmRsZXNzIG9mIGlmIHRoZXJlIGlzIFxuICAgICogYW55IHJlbWFpbmluZyBqc29uUGF0aCB0byBiZSBjb21waWxlZC5cbiAgICAqL1xuICAgZnVuY3Rpb24gcmV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0aGF0IHdlIGhhdmUgZm91bmQgc28gZmFyLlxuICAgICAgICovXG4gICAgICB2YXIgb25GaW5kID0gICAgICB1bmNvbXBpbGVkSnNvblBhdGhcbiAgICAgICAgICAgICAgICAgICAgID8gIGNvbXBpbGVKc29uUGF0aFRvRnVuY3Rpb24gXG4gICAgICAgICAgICAgICAgICAgICA6ICByZXR1cm5Gb3VuZFBhcnNlcjtcbiAgICAgICAgICAgICAgICAgICBcbiAgICAgIHJldHVybiAgIGNsYXVzZUZvckpzb25QYXRoKCBcbiAgICAgICAgICAgICAgICAgIHVuY29tcGlsZWRKc29uUGF0aCwgXG4gICAgICAgICAgICAgICAgICBwYXJzZXJHZW5lcmF0ZWRTb0ZhciwgXG4gICAgICAgICAgICAgICAgICBvbkZpbmRcbiAgICAgICAgICAgICAgICk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXG4gICB9XG5cbiAgIC8qKlxuICAgICogVGhpcyBpcyB0aGUgZnVuY3Rpb24gdGhhdCB3ZSBleHBvc2UgdG8gdGhlIHJlc3Qgb2YgdGhlIGxpYnJhcnkuXG4gICAgKi9cbiAgIHJldHVybiBmdW5jdGlvbihqc29uUGF0aCl7XG4gICAgICAgIFxuICAgICAgdHJ5IHtcbiAgICAgICAgIC8vIEtpY2sgb2ZmIHRoZSByZWN1cnNpdmUgcGFyc2luZyBvZiB0aGUganNvblBhdGggXG4gICAgICAgICByZXR1cm4gY29tcGlsZUpzb25QYXRoVG9GdW5jdGlvbihqc29uUGF0aCwgYWx3YXlzKTtcbiAgICAgICAgIFxuICAgICAgfSBjYXRjaCggZSApIHtcbiAgICAgICAgIHRocm93IEVycm9yKCAnQ291bGQgbm90IGNvbXBpbGUgXCInICsganNvblBhdGggKyBcbiAgICAgICAgICAgICAgICAgICAgICAnXCIgYmVjYXVzZSAnICsgZS5tZXNzYWdlXG4gICAgICAgICApO1xuICAgICAgfVxuICAgfVxuXG59KTtcblxuLyoqIFxuICogQSBwdWIvc3ViIHdoaWNoIG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ZXJUdXBsZUxpc3QgKTtcbiAgICAgICAgIGxpc3RlbmVyTGlzdCAgICAgID0gY29ucyggbGlzdGVuZXIsIGxpc3RlbmVyTGlzdCAgICAgICk7XG5cbiAgICAgICAgIHJldHVybiB0aGlzOyAvLyBjaGFpbmluZ1xuICAgICAgfSxcbiAgICAgXG4gICAgICBlbWl0OmZ1bmN0aW9uICgpIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXG4gICAgICAgICBhcHBseUVhY2goIGxpc3RlbmVyTGlzdCwgYXJndW1lbnRzICk7XG4gICAgICB9LFxuICAgICAgXG4gICAgICB1bjogZnVuY3Rpb24oIGxpc3RlbmVySWQgKSB7XG4gICAgICAgICAgICAgXG4gICAgICAgICB2YXIgcmVtb3ZlZDsgICAgICAgICAgICAgXG4gICAgICAgICAgICAgIFxuICAgICAgICAgbGlzdGVuZXJUdXBsZUxpc3QgPSB3aXRob3V0KFxuICAgICAgICAgICAgbGlzdGVuZXJUdXBsZUxpc3QsXG4gICAgICAgICAgICBoYXNJZChsaXN0ZW5lcklkKSxcbiAgICAgICAgICAgIGZ1bmN0aW9uKHR1cGxlKXtcbiAgICAgICAgICAgICAgIHJlbW92ZWQgPSB0dXBsZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICk7ICAgIFxuICAgICAgICAgXG4gICAgICAgICBpZiggcmVtb3ZlZCApIHtcbiAgICAgICAgICAgIGxpc3RlbmVyTGlzdCA9IHdpdGhvdXQoIGxpc3RlbmVyTGlzdCwgZnVuY3Rpb24obGlzdGVuZXIpe1xuICAgICAgICAgICAgICAgcmV0dXJuIGxpc3RlbmVyID09IHJlbW92ZWQubGlzdGVuZXI7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgIFxuICAgICAgICAgICAgaWYoIHJlbW92ZUxpc3RlbmVyICkge1xuICAgICAgICAgICAgICAgcmVtb3ZlTGlz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G4gICAgICAgICAgICBpZiggb2JvZUFwaVtldmVudElkXSApIHtcblxuICAgICAgICAgICAgICAgLy8gZm9yIGV2ZW50cyBhZGRlZCBhcyAub24oZXZlbnQsIGNhbGxiYWNrKSwgaWYgdGhlcmUgaXMgYVxuICAgICAgICAgICAgICAgLy8gLmV2ZW50KCkgZXF1aXZhbGVudCB3aXRoIHNwZWNpYWwgYmVoYXZpb3VyICwgcGFzcyB0aHJvdWdoXG4gICAgICAgICAgICAgICAvLyB0byB0aGF0OlxuICAgICAgICAgICAgICAgYXBwbHkocGFyYW1ldGVycywgb2JvZUFwaVtldmVudElkXSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuXG4gICAgICAgICAgICAgICAvLyB3ZSBoYXZlIGEgc3RhbmRhcmQgTm9kZS5qcyBFdmVudEVtaXR0ZXIgMi1hcmd1bWVudCBjYWxsLlxuICAgICAgICAgICAgICAgLy8gVGhlIGZpcnN0IHBhcmFtZXRlciBpcyB0aGUgbGlzdGVuZXIuXG4gICAgICAgICAgICAgICB2YXIgZXZlbnQgPSBvYm9lQnVzKGV2ZW50SWQpLFxuICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyID0gcGFyYW1ldGVyc1swXTtcblxuICAgICAgICAgICAgICAgaWYoIGZ1bGx5UXVhbGlmaWVkTmFtZVBhdHRlcm4udGVzdChldmVudElkKSApIHtcblxuICAgICAgICAgICAgICAgICAgLy8gYWxsb3cgZnVsbHktcXVhbGlmaWVkIG5vZGUvcGF0aCBsaXN0ZW5lcnNcbiAgICAgICAgICAgICAgICAgIC8vIHRvIGJlIGFkZGVkXG4gICAgICAgICAgICAgICAgICBhZGRGb3JnZXR0YWJsZUNhbGxiYWNrKGV2ZW50LCBsaXN0ZW5lcik7XG4gICAgICAgICAgICAgICB9IGVsc2UgIHtcblxuICAgICAgICAgICAgICAgICAgLy8gdGhlIGV2ZW50IGhhcyBubyBzcGVjaWFsIGhhbmRsaW5nLCBwYXNzIHRocm91Z2hcbiAgICAgICAgICAgICAgICAgIC8vIGRpcmVjdGx5IG9udG8gdGhlIGV2ZW50IGJ1czpcbiAgICAgICAgICAgICAgICAgIGV2ZW50Lm9uKCBsaXN0ZW5lcik7XG4gICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiBvYm9lQXBpOyAvLyBjaGFpbmluZ1xuICAgICAgIH0pLFxuXG4gICAgICAgLyoqXG4gICAgICAgICogUmVtb3ZlIGFueSBraW5kIG9mIGxpc3RlbmVyIHRoYXQgdGhlIGluc3RhbmNlIGFwaSBleHBvc2VzXG4gICAgICAgICovXG4gICAgICAgcmVtb3ZlTGlzdGVuZXIgPSBmdW5jdGlvbiggZXZlbnRJZCwgcDIsIHAzICl7XG5cbiAgICAgICAgICAgIGlmKCBldmVudElkID09ICdkb25lJyApIHtcblxuICAgICAgICAgICAgICAgcm9vdE5vZGVGaW5pc2hlZEV2ZW50LnVuKHAyKTtcblxuICAgICAgICAgICAgfSBlbHNlIGlmKCBldmVudElkID09ICdub2RlJyB8fCBldmVudElkID09ICdwYXRoJyApIHtcblxuICAgICAgICAgICAgICAgLy8gYWxsb3cgcmVtb3ZhbCBvZiBub2RlIGFuZCBwYXRoXG4gICAgICAgICAgICAgICBvYm9lQnVzLnVuKGV2ZW50SWQgKyAnOicgKyBwMiwgcDMpO1xuICAgICAgICAgICAgfSBlbHNlIHtcblxuICAgICAgICAgICAgICAgLy8gd2UgaGF2ZSBhIHN0YW5kYXJkIE5vZGUuanMgRXZlbnRFbWl0dGVyIDItYXJndW1lbnQgY2FsbC5cbiAgICAgICAgICAgICAgIC8vIFRoZSBzZWNvbmQgcGFyYW1ldGVyIGlzIHRoZSBsaXN0ZW5lci4gVGhpcyBtYXkgYmUgYSBjYWxsXG4gICAgICAgICAgICAgICAvLyB0byByZW1vdmUgYSBmdWxseS1xdWFsaWZpZWQgbm9kZS9wYXRoIGxpc3RlbmVyIGJ1dCByZXF1aXJlc1xuICAgICAgICAgICAgICAgL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mFtZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5hbWUgPyBoZWFkZXJzW25hbWVdXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IGhlYWRlcnNcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgIH0pO1xuXG4gICAvKipcbiAgICAqIENvbnN0cnVjdCBhbmQgcmV0dXJuIHRoZSBwdWJsaWMgQVBJIG9mIHRoZSBPYm9lIGluc3RhbmNlIHRvIGJlXG4gICAgKiByZXR1cm5lZCB0byB0aGUgY2FsbGluZyBhcHBsaWNhdGlvblxuICAgICovXG4gICByZXR1cm4gb2JvZUFwaSA9IHtcbiAgICAgIG9uICAgICAgICAgICAgIDogYWRkTGlzdGVuZXIsXG4gICAgICBhZGRMaXN0ZW5lciAgICA6IGFkZExpc3RlbmVyLFxuICAgICAgcmVtb3ZlTGlzdGVuZXIgOiByZW1vdmVMaXN0ZW5lcixcbiAgICAgIGVtaXQgICAgICAgICAgIDogb2JvZUJ1cy5lbWl0LFxuXG4gICAgICBub2RlICAgICAgICAgICA6IHBhcnRpYWxDb21wbGV0ZShhZGROb2RlT3JQYXRoTGlzdGVuZXJBcGksICdub2RlJyksXG4gICAgICBwYXRoICAgICAgICAgICA6IHBhcnRpYWxDb21wbGV0ZShhZGROb2RlT3JQYXRoTGlzdGVuZXJBcGksICdwYXRoJyksXG5cbiAgICAgIGRvbmUgICAgICAgICAgIDogcGFydGlhbENvbXBsZXRlKGFkZEZvcmdldHRhYmxlQ2FsbGJhY2ssIHJvb3ROb2RlRmluaXNoZWRFdmVudCksXG4gICAgICBzdGFydCAgICAgICAgICA6IHBhcnRpYWxDb21wbGV0ZShhZGRQcm90ZWN0ZWRDYWxsYmFjaywgSFRUUF9TVEFSVCApLFxuXG4gICAgICAvLyBmYWlsIGRvZXNuJ3QgdXNlIHByb3RlY3RlZENhbGxi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C8vICBzaW1wbGUgdmVyc2lvbiBmb3IgR0VUcy4gU2lnbmF0dXJlIGlzOlxuICAgICAgICAgLy8gICAgb2JvZSggdXJsIClcbiAgICAgICAgIC8vICBvciwgdW5kZXIgbm9kZTpcbiAgICAgICAgIC8vICAgIG9ib2UoIHJlYWRhYmxlU3RyZWFtIClcbiAgICAgICAgIHJldHVybiBhcHBseURlZmF1bHRzKFxuICAgICAgICAgICAgd2lyZSxcbiAgICAgICAgICAgIGFyZzEgLy8gdXJsXG4gICAgICAgICApO1xuXG4gICAgICB9IGVsc2Uge1xuXG4gICAgICAgICAvLyBtZXRob2Qgc2lnbmF0dXJlIGlzOlxuICAgICAgICAgLy8gICAgb2JvZSh7bWV0aG9kOm0sIHVybDp1LCBib2R5OmIsIGhlYWRlcnM6ey4uLn19KVxuXG4gICAgICAgICByZXR1cm4gYXBwbHlEZWZhdWx0cyhcbiAgICAgICAgICAgIHdpcmUsXG4gICAgICAgICAgICBhcmcxLnVybCxcbiAgICAgICAgICAgIGFyZzEubWV0aG9kLFxuICAgICAgICAgICAgYXJnMS5ib2R5LFxuICAgICAgICAgICAgYXJnMS5oZWFkZXJzLFxuICAgICAgICAgICAgYXJnMS53aXRoQ3JlZGVudGlhbHMsXG4gICAgICAgICAgICBhcmcxLmNhY2hlZFxuICAgICAgICAgKTtcbiAgICAgICAgIFxuICAgICAgfVxuICAgfSBlbHNlIHtcbiAgICAgIC8vIHdpcmUgdXAgYSBuby1BSkFYLCBuby1zdHJlYW0gT2JvZS4gV2lsbCBoYXZlIHRvIGhhdmUgY29udGVudCBcbiAgICAgIC8vIGZlZCBpbiBleHRlcm5hbGx5IGFuZCB1c2luZyAuZW1pdC5cbiAgICAgIHJldHVybiB3aXJlKCk7XG4gICB9XG59XG5cbi8qIG9ib2UuZHJvcCBpcyBhIHNwZWNpYWwgdmFsdWUuIElmIGEgbm9kZSBjYWxsYmFjayByZXR1cm5zIHRoaXMgdmFsdWUgdGhlXG4gICBwYXJzZWQgbm9k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RlclF1ZXVlLnBvcCgpO1xuICAgICAgICAgICAgcnVuU2luZ2xlKHRhc2spO1xuICAgICAgICB9XG4gICAgICAgIGZsdXNoaW5nID0gZmFsc2U7XG4gICAgfVxuICAgIC8vIHJ1bnMgYSBzaW5nbGUgZnVuY3Rpb24gaW4gdGhlIGFzeW5jIHF1ZXVlXG4gICAgZnVuY3Rpb24gcnVuU2luZ2xlKHRhc2ssIGRvbWFpbikge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgdGFzaygpO1xuXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIGlmIChpc05vZGVKUykge1xuICAgICAgICAgICAgICAgIC8vIEluIG5vZGUsIHVuY2F1Z2h0IGV4Y2VwdGlvbnMgYXJlIGNvbnNpZGVyZWQgZmF0YWwgZXJyb3JzLlxuICAgICAgICAgICAgICAgIC8vIFJlLXRocm93IHRoZW0gc3luY2hyb25vdXNseSB0byBpbnRlcnJ1cHQgZmx1c2hpbmchXG5cbiAgICAgICAgICAgICAgICAvLyBFbnN1cmUgY29udGludWF0aW9uIGlmIHRoZSB1bmNhdWdodCBleGNlcHRpb24gaXMgc3VwcHJlc3NlZFxuICAgICAgICAgICAgICAgIC8vIGxpc3RlbmluZyBcInVuY2F1Z2h0RXhjZXB0aW9uXCIgZXZlbnRzIChhcyBkb21haW5zIGRvZXMpLlxuICAgICAgICAgICAgICAgIC8vIENvbnRpbnVlIGluIG5leHQgZXZlbnQgdG8gYXZvaWQgdGljayByZWN1cnNpb24uXG4gICAgICAgICAgICAgICAgaWYgKGRvbWFpbikge1xuICAgICAgICAgICAgICAgICAgICBkb21haW4uZXhpdCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZsdXNoLCAwKTtcbiAgICAgICAgICAgICAgICBpZiAoZG9tYWluKSB7XG4gICAgICAgICAgICAgICAgICAgIGRvbWFpbi5lbnRlcigpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHRocm93IGU7XG5cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgLy8gSW4gYnJvd3NlcnMsIHVuY2F1Z2h0IGV4Y2VwdGlvbnMgYXJlIG5vdCBmYXRhbC5cbiAgICAgICAgICAgICAgICAvLyBSZS10aHJvdyB0aGVtIGFzeW5jaHJvbm91c2x5IHRvIGF2b2lkIHNsb3ctZG93bnMuXG4gICAgICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IGU7XG4gICAgICAgICAgICAgICAgfSwgMCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoZG9tYWluKSB7XG4gICAgICAgICAgICBkb21haW4uZXhpdCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgbmV4dFRpY2sgPSBmdW5jdGlvbiAodGFzaykge1xuICAgICAgICB0YWlsID0gdGFpbC5uZXh0ID0ge1xuICAgICAgICAgICAgdGFzazogdGFzayxcbiAgICAgICAgICAgIGRvbWFpbjogaXNOb2RlSlMgJiYgcHJvY2Vzcy5kb21haW4sXG4gICAgICAgICAgICBuZXh0OiBudWxsXG4gICAgICAgIH07XG5cbiAgICAgICAgaWYgKCFmbHVzaGluZykge1xuICAgICAgICAgICAgZmx1c2hpbmcgPSB0cnVlO1xuICAgICAgICAgICAgcmVxdWVzdFRpY2soKTtcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBpZiAodHlwZW9mIHByb2Nlc3MgPT09IFwib2JqZWN0XCIgJiZcbiAgICAgICAgcHJvY2Vzcy50b1N0cmluZygpID09PSBcIltvYmplY3QgcHJvY2Vzc11cIiAmJiBwcm9jZXNzLm5leHRUaWNrKSB7XG4gICAgICAgIC8vIEVuc3VyZSBRIGlzIGluIGEgcmVhbCBOb2RlIGVudmlyb25tZW50LCB3aXRoIGEgYHByb2Nlc3MubmV4dFRpY2tgLlxuICAg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dHlwZS5yZWR1Y2UgfHwgZnVuY3Rpb24gKGNhbGxiYWNrLCBiYXNpcykge1xuICAgICAgICB2YXIgaW5kZXggPSAwLFxuICAgICAgICAgICAgbGVuZ3RoID0gdGhpcy5sZW5ndGg7XG4gICAgICAgIC8vIGNvbmNlcm5pbmcgdGhlIGluaXRpYWwgdmFsdWUsIGlmIG9uZSBpcyBub3QgcHJvdmlkZWRcbiAgICAgICAgaWYgKGFyZ3VtZW50cy5sZW5ndGggPT09IDEpIHtcbiAgICAgICAgICAgIC8vIHNlZWsgdG8gdGhlIGZpcnN0IHZhbHVlIGluIHRoZSBhcnJheSwgYWNjb3VudGluZ1xuICAgICAgICAgICAgLy8gZm9yIHRoZSBwb3NzaWJpbGl0eSB0aGF0IGlzIGlzIGEgc3BhcnNlIGFycmF5XG4gICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgaWYgKGluZGV4IGluIHRoaXMpIHtcbiAgICAgICAgICAgICAgICAgICAgYmFzaXMgPSB0aGlzW2luZGV4KytdO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKCsraW5kZXggPj0gbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IHdoaWxlICgxKTtcbiAgICAgICAgfVxuICAgICAgICAvLyByZWR1Y2VcbiAgICAgICAgZm9yICg7IGluZGV4IDwgbGVuZ3RoOyBpbmRleCsrKSB7XG4gICAgICAgICAgICAvLyBhY2NvdW50IGZvciB0aGUgcG9zc2liaWxpdHkgdGhhdCB0aGUgYXJyYXkgaXMgc3BhcnNlXG4gICAgICAgICAgICBpZiAoaW5kZXggaW4gdGhpcykge1xuICAgICAgICAgICAgICAgIGJhc2lzID0gY2FsbGJhY2soYmFzaXMsIHRoaXNbaW5kZXhdLCBpbmRleCk7XG4gICAgIC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taXNlID0gb2JqZWN0X2NyZWF0ZShQcm9taXNlLnByb3RvdHlwZSk7XG5cbiAgICBwcm9taXNlLnByb21pc2VEaXNwYXRjaCA9IGZ1bmN0aW9uIChyZXNvbHZlLCBvcCwgYXJncykge1xuICAgICAgICB2YXIgcmVzdWx0O1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3Jbb3BdKSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0ID0gZGVzY3JpcHRvcltvcF0uYXBwbHkocHJvbWlzZSwgYXJncyk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJlc3VsdCA9IGZhbGxiYWNrLmNhbGwocHJvbWlzZSwgb3AsIGFyZ3MpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGNhdGNoIChleGNlcHRpb24pIHtcbiAgICAgICAgICAgIHJlc3VsdCA9IHJlamVjdChleGNlcHRpb24pO1xuICAgICAgICB9XG4gICAgICAgIGlmIChyZXNvbHZlKSB7XG4gICAgICAgICAgICByZXNvbHZlKHJlc3VsdCk7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgcHJvbWlzZS5pbnNwZWN0ID0gaW5zcGVjdDtcblxuICAgIC8vIFhYWCBkZXByZWNhdGVkIGB2YWx1ZU9mYCBhbmQgYGV4Y2VwdGlvbmAgc3VwcG9ydFxuICAgIGlmIChpbnNwZWN0KSB7XG4gICAgICAgIHZhciBpbnNwZWN0ZWQgPSBpbnNwZWN0KCk7XG4gICAgICAgIGlmIChpbnNwZWN0ZWQuc3RhdGUgPT09IFwicmVqZWN0ZWRcIikge1xuICAgICAgICAgICAgcHJvbWlzZS5leGNlcHRpb24gPSBpbnNwZWN0ZWQucmVhc29uO1xuICAgICAgICB9XG5cbiAgICAgICAgcHJvbWlzZS52YWx1ZU9mID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgdmFyIGluc3BlY3RlZCA9IGluc3BlY3QoKTtcbiAgICAgICAgIC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BvZlxuICAgICAgICAgICAgLy8gb3V0ZGF0ZWQgRVM2IGRyYWZ0cy4gIFdlIHdvdWxkIGxpa2UgdG8gc3VwcG9ydCBFUzYsIGJ1dCB3ZSdkIGFsc29cbiAgICAgICAgICAgIC8vIGxpa2UgdG8gbWFrZSBpdCBwb3NzaWJsZSB0byB1c2UgZ2VuZXJhdG9ycyBpbiBkZXBsb3llZCBicm93c2Vycywgc29cbiAgICAgICAgICAgIC8vIHdlIGFsc28gc3VwcG9ydCBQeXRob24tc3R5bGUgZ2VuZXJhdG9ycy4gIEF0IHNvbWUgcG9pbnQgd2UgY2FuIHJlbW92ZVxuICAgICAgICAgICAgLy8gdGhpcyBibG9jay5cblxuICAgICAgICAgICAgaWYgKHR5cGVvZiBTdG9wSXRlcmF0aW9uID09PSBcInVuZGVmaW5lZFwiKSB7XG4gICAgICAgICAgICAgICAgLy8gRVM2IEdlbmVyYXRvcnNcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBnZW5lcmF0b3JbdmVyYl0oYXJnKTtcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChleGNlcHRpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlamVjdChleGNlcHRpb24pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdWx0LmRvbmUpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFEocmVzdWx0LnZhbHVlKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gd2hlbihyZXN1bHQudmFsdWUsIGNhbGxiYWNrLCBlcnJiYWNrKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8vIFNwaWRlck1vbmtleSBHZW5lcmF0b3JzXG4gICAgICAgICAgICAgICAgLy8gRklYTUU6IFJlbW92ZSB0aGlzIGNhc2Ugd2hlbiBTTSBkb2VzIEVTNiBnZW5lcmF0b3JzLlxuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IGdlbmVyYXRvclt2ZXJiXShhcmcpO1xuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4Y2VwdGlvbikge1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNTdG9wSXRlcmF0aW9uKGV4Y2VwdGlvbikpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBRKGV4Y2VwdGlvbi52YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVqZWN0KGV4Y2VwdGlvbik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHdoZW4ocmVzdWx0LCBjYWxsYmFjaywgZXJyYmFjayk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGdlbmVyYXRvciA9IG1ha2VHZW5lcmF0b3IuYXBwbHkodGhpcywgYXJndW1lbnRzKTtcbiAgICAgICAgdmFyIGNhbGxiYWNrID0gY29udGludWVyLmJpbmQoY29udGludWVyLCBcIm5leHRcIik7XG4gICAgICAgIHZhciBlcnJiYWNrID0gY29udGludWVyLmJpbmQoY29udGludWVyLCBcInRocm93XCIpO1xuICAgICAgICByZXR1cm4gY2FsbGJhY2soKTtcbiAgICB9O1xufVxuXG4vKipcbiAqIFRoZSBzcGF3biBmdW5jdGlvbiBpcyBhIHNtYWxsIHdyYXBwZXIgYXJvdW5kIGFzeW5jIHRoYXQgaW1tZWRpYXRlbHlcbiAqIGNhbGxzIHRoZSBnZW5lcmF0b3IgYW5kIGFsc28gZW5kcyB0aGUgcHJvbWlzZSBjaGFpbiwgc28gdGhhdCBhbnlcbiAqIHVuaGFuZGxlZCBlcnJvcnMg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iB3aGVuKHByb21pc2VzLCBmdW5jdGlvbiAocHJvbWlzZXMpIHtcbiAgICAgICAgdmFyIHBlbmRpbmdDb3VudCA9IDA7XG4gICAgICAgIHZhciBkZWZlcnJlZCA9IGRlZmVyKCk7XG4gICAgICAgIGFycmF5X3JlZHVjZShwcm9taXNlcywgZnVuY3Rpb24gKHVuZGVmaW5lZCwgcHJvbWlzZSwgaW5kZXgpIHtcbiAgICAgICAgICAgIHZhciBzbmFwc2hvdDtcbiAgICAgICAgICAgIGlmIChcbiAgICAgICAgICAgICAgICBpc1Byb21pc2UocHJvbWlzZSkgJiZcbiAgICAgICAgICAgICAgICAoc25hcHNob3QgPSBwcm9taXNlLmluc3BlY3QoKSkuc3RhdGUgPT09IFwiZnVsZmlsbGVkXCJcbiAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICAgIHByb21pc2VzW2luZGV4XSA9IHNuYXBzaG90LnZhbHVlO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICArK3BlbmRpbmdDb3VudDtcbiAgICAgICAgICAgICAgICB3aGVuKFxuICAgICAgICAgICAgICAgICAgICBwcm9taXNlLFxuICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb21pc2VzW2luZGV4XSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKC0tcGVuZGluZ0NvdW50ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmZXJyZWQucmVzb2x2ZShwcm9taXNlcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIGRlZmVycmVkLnJlamVjdCxcbiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gKHByb2dyZXNzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZlcnJlZC5ub3RpZnkoeyBpbmR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W5nQ291bnQgPSAwO1xuICAgIGFycmF5X3JlZHVjZShwcm9taXNlcywgZnVuY3Rpb24gKHByZXYsIGN1cnJlbnQsIGluZGV4KSB7XG4gICAgICAgIHZhciBwcm9taXNlID0gcHJvbWlzZXNbaW5kZXhdO1xuXG4gICAgICAgIHBlbmRpbmdDb3VudCsrO1xuXG4gICAgICAgIHdoZW4ocHJvbWlzZSwgb25GdWxmaWxsZWQsIG9uUmVqZWN0ZWQsIG9uUHJvZ3Jlc3MpO1xuICAgICAgICBmdW5jdGlvbiBvbkZ1bGZpbGxlZChyZXN1bHQpIHtcbiAgICAgICAgICAgIGRlZmVycmVkLnJlc29sdmUocmVzdWx0KTtcbiAgICAgICAgfVxuICAgICAgICBmdW5jdGlvbiBvblJlamVjdGVkKCkge1xuICAgICAgICAgICAgcGVuZGluZ0NvdW50LS07XG4gICAgICAgICAgICBpZiAocGVuZGluZ0NvdW50ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgZGVmZXJyZWQucmVqZWN0KG5ldyBFcnJvcihcbiAgICAgICAgICAgICAgICAgICAgXCJDYW4ndCBnZXQgZnVsZmlsbG1lbnQgdmFsdWUgZnJvbSBhbnkgcHJvbWlzZSwgYWxsIFwiICtcbiAgICAgICAgICAgICAgICAgICAgXCJwcm9taXNlcyB3ZXJlIHJlamVjdGVkLlwiXG4gICAgICAgICAgICAgICAgKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZnVuY3Rpb24gb25Qcm9ncmVzcyhwcm9ncmVzcykge1xuICAgICAgICAgICAgZGVmZXJyZWQubm90aWZ5KHtcbiAgICAgICAgICAgICAgICBpbmRleDogaW5kZXgsXG4gICAgICAgICAgICAgICAgdmFsdWU6IHByb2dyZXNzXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH0sIHVuZGVmaW5lZCk7XG5cbiAgICByZXR1cm4gZGVmZXJyZWQucHJvbWlzZTtcbn1cblxuUHJvbWlzZS5wcm90b3R5c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9kZWJhY2ssIHRoZSByZXN1bHQgd2lsbCBiZSBzZW50IHRoZXJlLiAgSWYgdGhleSBkbyBub3RcbiAqIHBhc3MgYSBub2RlYmFjaywgdGhleSB3aWxsIHJlY2VpdmUgdGhlIHJlc3VsdCBwcm9taXNlLlxuICogQHBhcmFtIG9iamVjdCBhIHJlc3VsdCAob3IgYSBwcm9taXNlIGZvciBhIHJlc3VsdClcbiAqIEBwYXJhbSB7RnVuY3Rpb259IG5vZGViYWNrIGEgTm9kZS5qcy1zdHlsZSBjYWxsYmFja1xuICogQHJldHVybnMgZWl0aGVyIHRoZSBwcm9taXNlIG9yIG5vdGhpbmdcbiAqL1xuUS5ub2RlaWZ5ID0gbm9kZWlmeTtcbmZ1bmN0aW9uIG5vZGVpZnkob2JqZWN0LCBub2RlYmFjaykge1xuICAgIHJldHVybiBRKG9iamVjdCkubm9kZWlmeShub2RlYmFjayk7XG59XG5cblByb21pc2UucHJvdG90eXBlLm5vZGVpZnkgPSBmdW5jdGlvbiAobm9kZWJhY2spIHtcbiAgICBpZiAobm9kZWJhY2spIHtcbiAgICAgICAgdGhpcy50aGVuKGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgUS5uZXh0VGljayhmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgbm9kZWJhY2sobnVsbCwgdmFsdWUpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0sIGZ1bmN0aW9uIChlcnJvcikge1xuICAgICAgICAgICAgUS5uZXh0VGljayhmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgbm9kZWJhY2soZXJyb3IpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH0gZWxzZSB7XG4gICAgICAgIHJldHVybiB0aGlzO1xuICAgIH1cbn07XG5cblEubm9Db25mbGljdCA9IGZ1bmN0aW9uKCkge1xuICAgIHRocm93IG5ldyBFcnJvcihcIlEubm9Db25mbGljdCBvbmx5IHdvcmtzIHdoZ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3VtZW50cyk7XG4gICAgICAgIHJlc3VsdHMub25seSh0KTtcbiAgICAgICAgcmV0dXJuIHQ7XG4gICAgfTtcbiAgICB0ZXN0Ll9leGl0Q29kZSA9IDA7XG4gICAgXG4gICAgdGVzdC5jbG9zZSA9IGZ1bmN0aW9uICgpIHsgcmVzdWx0cy5jbG9zZSgpIH07XG4gICAgXG4gICAgcmV0dXJuIHRlc3Q7XG59XG4iXX0= +},{"./lib/default_stream":408,"./lib/results":409,"./lib/test":410,"_process":40,"defined":14,"through":411}]},{},[2]) +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJsaWIvaW1wb3J0ZXIuanMiLCJsaWIvaW5kZXguanMiLCJub2RlX21vZHVsZXMvYmFzZTY0LWpzL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2Jyb3dzZXItcmVzb2x2ZS9lbXB0eS5qcyIsIm5vZGVfbW9kdWxlcy9idWZmZXIvaW5kZXguanMiLCJub2RlX21vZHVsZXMvYnVmZmVyL25vZGVfbW9kdWxlcy9pc2FycmF5L2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2Nhbi1uYW1lc3BhY2UvY2FuLW5hbWVzcGFjZS5qcyIsIm5vZGVfbW9kdWxlcy9jb3JlLXV0aWwtaXMvbGliL3V0aWwuanMiLCJub2RlX21vZHVsZXMvZGVlcC1lcXVhbC9pbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9kZWVwLWVxdWFsL2xpYi9pc19hcmd1bWVudHMuanMiLCJub2RlX21vZHVsZXMvZGVlcC1lcXVhbC9saWIva2V5cy5qcyIsIm5vZGVfbW9kdWxlcy9kZWZpbmUtcHJvcGVydGllcy9pbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9kZWZpbmVkL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2VzLWFic3RyYWN0L2V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0Y2goZGF0YV9wYXRoICsgJy9fbWFuaWZlc3QuanNvbicpXG4gICAgICAgIC50aGVuKGZ1bmN0aW9uKHJlc3BvbnNlKSB7XG4gICAgICAgICAgICBpZighcmVzcG9uc2Uub2spe1xuICAgICAgICAgICAgICAgIHJldHVybiBldmVudHMubmV4dCh7XG4gICAgICAgICAgICAgICAgICAgIG1lc3NhZ2U6IFwiZXJyb3JcIixcbiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IFwibWFuaWZlc3Qgbm90IGZvdW5kXCJcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlLmpzb24oKTtcbiAgICAgICAgfSkudGhlbihmdW5jdGlvbihtYW5pZmVzdCl7XG4gICAgICAgICAgICBldmVudHMubmV4dCh7XG4gICAgICAgICAgICAgICAgbWVzc2FnZTogXCJtYW5pZmVzdFwiLFxuICAgICAgICAgICAgICAgIHZhbHVlOiBtYW5pZmVzdFxuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIHZhciBkZWxSZXEgPSBpbmRleGVkREIuZGVsZXRlRGF0YWJhc2UoaWRiX25hbWUpO1xuXG4gICAgICAgICAgICBkZWxSZXEub25ibG9ja2VkID0gZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygnZGF0YWJhc2UgZGVsZXRlIGJsb2NrZWQnKTtcbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgIHZhciBmaWxsSURCID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIGRlbGV0ZSBpbXBvcnRlZF9pZGJzW2lkYl9uYW1lXTtcbiAgICAgICAgICAgICAgICBjb21taXRsb2NhbFN0b3JhZ2UoKTtcblxuICAgICAgICAgICAgICAgIGV2ZW50cy5uZXh0KHtcbiAgICAgICAgICAgICAgICAgICAgbWVzc2FnZTogXCJvbGRfaWRiX2RlbGV0ZWRcIlxuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgdmFyIHBhZ2VzX3dyaXR0ZW4gPSAwO1xuICAgICAgICAgICAgICAgIHZhciB0b3RhbF9wYWdlcyA9IDA7XG5cbiAgICAgICAgICAgICAgICB2YXIgb3BlbiA9IGluZGV4ZWREQi5vcGVuKGlkYl9uYW1lLCAxKTtcblxuICAgICAgICAgICAgICAgIG9wZW4ub25lcnJvciA9IGZ1bmN0aW9uKGV2ZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdlcnJvciBvcGVuaW5nIGluZGV4ZWREQicpO1xuICAgICAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgICAgICB2YXIgcmVwb3J0UHJvZ3Jlc3MgPSBmdW5jdGlvbihwcm9ncmVzcyl7XG4gICAgICAgICAgICAgICAgICAgIGV2ZW50cy5uZXh0KHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2U6IFwicHJvZ3Jlc3NcIixcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwcm9ncmVzc1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9O1xuXG5cbiAgICAgICAgICAgICAgICB2YXIgbWlncmF0ZSA9IGZ1bmN0aW9uKGV2ZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBkYiA9IGV2ZW50LnRhcmdldC5yZXN1bHQ7XG4gICAgICAgICAgICAgICAgICAgIHZhciBzdG9yZV9wcm9taXNlcyA9IFtdO1xuXG4gICAgICAgICAgICAgICAgICAgIHZhciBmYWlsb3V0ID0gZnVuY3Rpb24ocmVhc29uKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50cy5uZXh0KHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlOiBcImVycm9yXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHJlYXNvblxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIGRiLmNsb3NlKCk7XG4gICAgICAgICAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgICAgICAgICAgXy5lYWNoKG1hbmlmZXN0LCBmdW5jdGlvbiAoX21hbmlmZXN0LCBrZXkpIHtcblxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHBrZXlfaW5kaWNlcyA9IHt9O1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0b3JlX29wdHMgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5UGF0aDogX21hbmlmZXN0LnByaW1hcnlfa2V5c1swXVxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgaWYoX21hbmlmZXN0LnByaW1hcnlfa2V5cy5sZW5ndGggPiAxKXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwa2V5X2luZGljZXNbXCJpZHhfbXVsdGlwbGVfcGtleXNcIl0gPSBfbWFuaWZlc3QucHJpbWFyeV9rZXlzO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBzdG9yZV9vcHRzLmtleVBhdGg7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzdG9yZSA9IGRiLmNyZWF0ZU9iamVjdFN0b3JlKGtleSwgIHN0b3JlX29wdHMpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBfLmVhY2goXy5leHRlbmQocGtleV9pbmRpY2VzLCBfbWFuaWZlc3QuaW5kaWNlcyksIGZ1bmN0aW9uKGNvbHVtbnMsIGlkeF9uYW1lKXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yZS5jcmVhdGVJbmRleChpZHhfbmFtZSwgY29sdW1ucyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0b3JlX2RlZmVycmVkID0gcS5kZWZlcigpO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmVfcHJvbWlzZXMucHVzaChzdG9yZV9kZWZlcnJlZC5wcm9taXNlKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHBhZ2VzID0gcGFyc2VJbnQoX21hbmlmZXN0LnJvd19jb3VudCAvIG9wdGlvbnMuaXRlbXNfcGVyX3BhZ2UpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBpZihfbWFuaWZlc3Qucm93X2NvdW50ICUgb3B0aW9ucy5pdGVtc19wZXJfcGFnZSAhPSAwKXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlcyArPSAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgdG90YWxfcGFnZXMgKz0gcGFnZXM7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwYWdlX3Byb21pc2VzID0gbmV3IEFycmF5KHBhZ2VzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwYWdlX2RlZmVycmVkcyA9IG5ldyBBcnJheShwYWdlcyk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIF8uZWFjaChwYWdlX3Byb21pc2VzLCBmdW5jdGlvbih1bnVzZWQsIGkpe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkID0gcS5kZWZlcigpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VfZGVmZXJyZWRzW2ldID0gZDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlX3Byb21pc2VzW2ldID0gZC5wcm9taXNlO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZC5wcm9taXNlLnRoZW4oZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlc193cml0dGVuICs9IDE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcG9ydFByb2dyZXNzKHBhZ2VzX3dyaXR0ZW4gLyB0b3RhbF9wYWdlcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmYWlsb3V0KCdwYWdlX3N0b3JhZ2VfZmFpbGVkJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgcS5hbGwocGFnZV9wcm9taXNlcykudGhlbihzdG9yZV9kZWZlcnJlZC5yZXNvbHZlLCBzdG9yZV9kZWZlcnJlZC5yZWplY3QpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBzdG9yZS50cmFuc2FjdGlvbi5hZGRFdmVudExpc3RlbmVyKCdjb21wbGV0ZScsIGZ1bmN0aW9uKCl7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgY3VycmVudF9wYWdlID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcGFnZV9pdGVtcyA9IFtdO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0b3JlX3BhZ2UgPSBmdW5jdGlvbihfcGFnZSwgX2l0ZW1zKXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHR4ID0gZGIudHJhbnNhY3Rpb24oW2tleV0sIFwicmVhZHdyaXRlXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3N0b3JlID0gdHgub2JqZWN0U3RvcmUoa2V5KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfLmVhY2goX2l0ZW1zLCBmdW5jdGlvbiAoaXRlbSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9yZXN1bHQ7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKF9tYW5pZmVzdC5wcmltYXJ5X2tleXMubGVuZ3RoID4gMSl7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIG11bHRpS2V5ID0gXy5tYXAoX21hbmlmZXN0LnByaW1hcnlfa2V5cywgZnVuY3Rpb24gKHBrZXkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1bcGtleV07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkuam9pbignXycpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9yZXN1bHQgPSBfc3RvcmUucHV0KGl0ZW0sIG11bHRpS2V5KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1lbHNle1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9yZXN1bHQgPSBfc3RvcmUucHV0KGl0ZW0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfcmVzdWx0Lm9uZXJyb3IgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZV9kZWZlcnJlZHNbX3BhZ2VdLnJlamVjdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHguYWRkRXZlbnRMaXN0ZW5lcignY29tcGxldGUnLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlX2RlZmVycmVkc1tfcGFnZV0ucmVzb2x2ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xuXG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmZXRjaChkYXRhX3BhdGggKyAnLycgKyBrZXkgKyAnLm5kanNvbicpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uKHJlc3BvbnNlKXtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoIXJlc3BvbnNlLm9rKXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFpbG91dCgnb2JvZV9yZWFkX2ZhaWxlZCcpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmRqc29uU3RyZWFtKHJlc3BvbnNlLmJvZHkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KS50aGVuKGZ1bmN0aW9uKHJvd3NTdHJlYW0pe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHJlYWRlciA9IHJvd3NTdHJlYW0uZ2V0UmVhZGVyKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZG9SZWFkID0gZnVuY3Rpb24gKHJlc3VsdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHQuZG9uZSkgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciByb3cgPSByZXN1bHQudmFsdWU7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlX2l0ZW1zLnB1c2gocm93KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKHBhZ2VfaXRlbXMubGVuZ3RoID49IG9wdGlvbnMuaXRlbXNfcGVyX3BhZ2UgfHxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudF9wYWdlID09IChwYWdlcyAtIDEpICYmXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlX2l0ZW1zLmxlbmd0aCA+PSAoX21hbmlmZXN0LnJvd19jb3VudCAlIG9wdGlvbnMuaXRlbXNfcGVyX3BhZ2UpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIClcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yZV9wYWdlKGN1cnJlbnRfcGFnZSwgcGFnZV9pdGVtcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VfaXRlbXMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudF9wYWdlICs9IDE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyLnJlYWQoKS50aGVuKGRvUmVhZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkZXIucmVhZCgpLnRoZW4oZG9SZWFkKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBzdG9yZS50cmFuc2FjdGlvbi5hZGRFdmVudExpc3RlbmVyKCdlcnJvcicsIGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZmFpbG91dCgnaWRiX3NjaGVtYV9mYWlsZWQnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgIHEuYWxsKHN0b3JlX3Byb21pc2VzKS50aGVuKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGltcG9ydGVkX2lkYnNbaWRiX25hbWVdID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdGxvY2FsU3RvcmFnZSgpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBldmVudHMubmV4dCh7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZTogXCJzdWNjZXNzXCJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgZGIuY2xvc2UoKTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgb3Blbi5vbnVwZ3JhZGVuZWVkZWQgPSBtaWdyYXRlO1xuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgZGVsUmVxLm9uc3VjY2VzcyA9IGZpbGxJREI7XG4gICAgICAgICAgICBkZWxSZXEub25lcnJvciA9IGZpbGxJREI7XG5cbiAgICAgICAgfSk7XG5cbiAgICByZXR1cm4gZXZlbnRzO1xufTtcblxubW9kdWxlLmV4cG9ydHMuaWRiSW1wb3J0ZWQgPSBmdW5jdGlvbihpZGJfbmFtZSl7XG4gICAgdmFyIGxpc3QgPSBKU09OLnBhcnNlKHdpbmRvdy5sb2NhbFN0b3JhZ2UuZ2V0SXRlbSgnX19pZGJfaW1wb3J0X2NvbXBsZXRlJykpIHx8IHt9O1xuICAgIHJldHVybiBsaXN0W2lkYl9uYW1lXSB8fCBmYWxzZTtcbn07IiwiJ3VzZSBzdHJp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ICAgICAgICAgaWYgKChzZWNvbmRCeXRlICYgMHhDMCkgPT09IDB4ODApIHtcbiAgICAgICAgICAgIHRlbXBDb2RlUG9pbnQgPSAoZmlyc3RCeXRlICYgMHgxRikgPDwgMHg2IHwgKHNlY29uZEJ5dGUgJiAweDNGKVxuICAgICAgICAgICAgaWYgKHRlbXBDb2RlUG9pbnQgPiAweDdGKSB7XG4gICAgICAgICAgICAgIGNvZGVQb2ludCA9IHRlbXBDb2RlUG9pbnRcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWtcbiAgICAgICAgY2FzZSAzOlxuICAgICAgICAgIHNlY29uZEJ5dGUgPSBidWZbaSArIDFdXG4gICAgICAgICAgdGhpcmRCeXRlID0gYnVmW2kgKyAyXVxuICAgICAgICAgIGlmICgoc2Vjb25kQnl0ZSAmIDB4QzApID09PSAweDgwICYmICh0aGlyZEJ5dGUgJiAweEMwKSA9PT0gMHg4MCkge1xuICAgICAgICAgICAgdGVtcENvZGVQb2ludCA9IChmaXJzdEJ5dGUgJiAweEYpIDw8IDB4QyB8IChzZWNvbmRCeXRlICYgMHgzRikgPDwgMHg2IHwgKHRoaXJkQnl0ZSAmIDB4M0YpXG4gICAgICAgICAgICBpZiAodGVtcENvZGVQb2ludCA+IDB4N0ZGICYmICh0ZW1wQ29kZVBvaW50IDwgMHhEODAwIHx8IHRlbXBDb2RlUG9pbnQgPiAweERGRkYpKSB7XG4gICAgICAgICAgICAgIGNvZGVQb2ludCA9IHRlbXBDb2RlUG9pbnRcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWtcbiAgICAgICAgY2FzZSA0OlxuICAgICAgICAgIHNlY29uZEJ5dGUgPSBidWZbaSArIDFdXG4gICAgICAgICAgdGhpcmRCeXRlID0gYnVmW2kgKyAyXVxuICAgICAgICAgIGZvdXJ0aEJ5dGUgPSBidWZbaSArIDNdXG4gICAgICAgICAgaWYgKChzZWNvbmRCeXRlIC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RlQXQoaSlcblxuICAgIC8vIGlzIHN1cnJvZ2F0ZSBjb21wb25lbnRcbiAgICBpZiAoY29kZVBvaW50ID4gMHhEN0ZGICYmIGNvZGVQb2ludCA8IDB4RTAwMCkge1xuICAgICAgLy8gbGFzdCBjaGFyIHdhcyBhIGxlYWRcbiAgICAgIGlmICghbGVhZFN1cnJvZ2F0ZSkge1xuICAgICAgICAvLyBubyBsZWFkIHlldFxuICAgICAgICBpZiAoY29kZVBvaW50ID4gMHhEQkZGKSB7XG4gICAgICAgICAgLy8gdW5leHBlY3RlZCB0cmFpbFxuICAgICAgICAgIGlmICgodW5pdHMgLT0gMykgPiAtMSkgYnl0ZXMucHVzaCgweEVGLCAweEJGLCAweEJEKVxuICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgIH0gZWxzZSBpZiAoaSArIDEgPT09IGxlbmd0aCkge1xuICAgICAgICAgIC8vIHVucGFpcmVkIGxlYWRcbiAgICAgICAgICBpZiAoKHVuaXRzIC09IDMpID4gLTEpIGJ5dGVzLnB1c2goMHhFRiwgMHhCRiwgMHhCRClcbiAgICAgICAgICBjb250aW51ZVxuICAgICAgICB9XG5cbiAgICAgICAgLy8gdmFsaWQgbGVhZFxuICAgICAgICBsZWFkU3Vycm9nYXRlID0gY29kZVBvaW50XG5cbiAgICAgICAgY29udGludWVcbiAgICAgIH1cblxuICAgICAgLy8gMiBsZWFkcyBpbiBhIHJvd1xuICAgICAgaWYgKGNvZGVQb2ludCA8IDB4REMwMCkge1xuICAgICAgICBpZiAoKHVuaXRzIC09IDMpID4gLTEpIGJ5dGVzLnB1c2goMHhFRiwgMHhCRiwgMHhCRClcbiAgICAgICAgbGVhZFN1cnJvZ2F0ZSA9IGNvZGVQb2ludFxuICAgICAgICBjb250aW51ZVxuICAgICAgfVxuXG4gICAgICAvLyB2YWxpZCBzdXJyb2dhdGUgcGFpclxuICAgICAgY29kZVBvaW50ID0gKGxlYWRTdXJyb2dhdGUgLSAweEQ4MDAgPDwgMTAgfC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RzLCAxKTtcblxuICAgIHZhciBib3VuZDtcbiAgICB2YXIgYmluZGVyID0gZnVuY3Rpb24gKCkge1xuICAgICAgICBpZiAodGhpcyBpbnN0YW5jZW9mIGJvdW5kKSB7XG4gICAgICAgICAgICB2YXIgcmVzdWx0ID0gdGFyZ2V0LmFwcGx5KFxuICAgICAgICAgICAgICAgIHRoaXMsXG4gICAgICAgICAgICAgICAgYXJncy5jb25jYXQoc2xpY2UuY2FsbChhcmd1bWVudHMpKVxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIGlmIChPYmplY3QocmVzdWx0KSA9PT0gcmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRhcmdldC5hcHBseShcbiAgICAgICAgICAgICAgICB0aGF0LFxuICAgICAgICAgICAgICAgIGFyZ3MuY29uY2F0KHNsaWNlLmNhbGwoYXJndW1lbnRzKSlcbiAgICAgICAgICAgICk7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgdmFyIGJvdW5kTGVuZ3RoID0gTWF0aC5tYXgoMCwgdGFyZ2V0Lmxlbmd0aCAtIGFyZ3MubGVuZ3RoKTtcbiAgICB2YXIgYm91bmRBcmdzID0gW107XG4gICAgZm9yICh2YXIgaSA9IDA7IGkgPCBib3VuZExlbmd0aDsgaSsrKSB7XG4gICAgICAgIGJvdW5kQXJncy5wdXNoKCckJyArIGkpO1xuICAgIH1cblxuICAgIGJvdW5kID0gRnVuY3Rpb24oJ2JpbmRlcicsICdyZXR1cm4gZnVuY3Rpb24gKCcgKyBib3VuZEFyZ3Muam9pbignLCcpICsgJyl7IHJldHVybiBiaW5kZXIuYXBwbHkodGhpcyxhcmd1bWVudHMpOyB9JykoYmluZGVyKTtcblxuICAgIGlmICh0YXJnZXQucHJvdG90eXBlKSB7XG4gICA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ZiBvYmouaW5zcGVjdCA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICByZXR1cm4gb2JqLmluc3BlY3QoKTtcbiAgICB9XG4gICAgaWYgKGlzTWFwKG9iaikpIHtcbiAgICAgICAgdmFyIHBhcnRzID0gW107XG4gICAgICAgIG1hcEZvckVhY2guY2FsbChvYmosIGZ1bmN0aW9uICh2YWx1ZSwga2V5KSB7XG4gICAgICAgICAgICBwYXJ0cy5wdXNoKGluc3BlY3Qoa2V5LCBvYmopICsgJyA9PiAnICsgaW5zcGVjdCh2YWx1ZSwgb2JqKSk7XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gY29sbGVjdGlvbk9mKCdNYXAnLCBtYXBTaXplLmNhbGwob2JqKSwgcGFydHMpO1xuICAgIH1cbiAgICBpZiAoaXNTZXQob2JqKSkge1xuICAgICAgICB2YXIgcGFydHMgPSBbXTtcbiAgICAgICAgc2V0Rm9yRWFjaC5jYWxsKG9iaiwgZnVuY3Rpb24gKHZhbHVlICkge1xuICAgICAgICAgICAgcGFydHMucHVzaChpbnNwZWN0KHZhbHVlLCBvYmopKTtcbiAgICAgICAgfSk7XG4gICAgICAgIHJldHVybiBjb2xsZWN0aW9uT2YoJ1NldCcsIHNldFNpemUuY2FsbChvYmopLCBwYXJ0cyk7XG4gICAgfVxuICAgIGlmIChpc051bWJlcihvYmopKSB7XG4gICAgICAgIHJldHVybiBtYXJrQm94ZWQoTnVtYmVyKG9iaikpO1xuICAgIH1cbiAgICBpZiAoaXNCb29sZWFuKG9iaikpIHtcbiAgICAgICAgcmV0dXJuIG1hcmtCb3hlZChib29sZWFuVmFsdWVPZi5jYWxsKG9iaikpO1xuICAgIH1cbiAgICBpZiAoaXNTdHJpbmcob2JqKSkge1xuICAgICAgICByZXR1cm4gbWFya0JveGVkKGluc3BlY3QoU3RyaW5nKG9iaikpKTtcbiAgICB9XG4gICAgaWYgKCFpc0RhdGUob2JqKSAmJiAhaXNSZWdFeHAob2JqKSkge1xuICA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yIHggPSB7IDg6ICdiJywgOTogJ3QnLCAxMDogJ24nLCAxMjogJ2YnLCAxMzogJ3InIH1bbl07XG4gICAgaWYgKHgpIHJldHVybiAnXFxcXCcgKyB4O1xuICAgIHJldHVybiAnXFxcXHgnICsgKG4gPCAweDEwID8gJzAnIDogJycpICsgbi50b1N0cmluZygxNik7XG59XG5cbmZ1bmN0aW9uIG1hcmtCb3hlZCAoc3RyKSB7XG4gICAgcmV0dXJuICdPYmplY3QoJyArIHN0ciArICcpJztcbn1cblxuZnVuY3Rpb24gY29sbGVjdGlvbk9mICh0eXBlLCBzaXplLCBlbnRyaWVzKSB7XG4gICAgcmV0dXJuIHR5cGUgKyAnICgnICsgc2l6ZSArICcpIHsnICsgZW50cmllcy5qb2luKCcsICcpICsgJ30nO1xufVxuXG5mdW5jdGlvbiBhcnJPYmpLZXlzIChvYmosIGluc3BlY3QpIHtcbiAgICB2YXIgaXNBcnIgPSBpc0FycmF5KG9iaik7XG4gICAgdmFyIHhzID0gW107XG4gICAgaWYgKGlzQXJyKSB7XG4gICAgICAgIHhzLmxlbmd0aCA9IG9iai5sZW5ndGg7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgb2JqLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICB4c1tpXSA9IGhhcyhvYmosIGkpID8gaW5zcGVjdChvYmpbaV0sIG9iaikgOiAnJztcbiAgICAgICAgfVxuICAgIH1cbiAgICBmb3IgKHZhciBrZXkgaW4gb2JqKSB7XG4gICAgICAgIGlmICghaGFzKG9iaiwga2V5KSkgY29udGludWU7XG4gICAgICAgIGlmIChpc0FyciAmJiBTdHJpbmcoTnVtYmVyKGtleSkpID09PSBrZXkgJiYga2V5IDwgb2JqLmxlbmd0aCkgY29udGludWU7XG4gICAgICAgIGlmICgvW15cXHckXS8udGVzdChrZXkpKSB7XG4gICAgICAgICAgICB4cy5wdXNoKGluc3BlY3Qoa2V5LCBvYmopICsgJzogJyArIGluc3BlY3Qob2JqW2t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ICAgICAgICAgICAgaWYgKHN1YnNjcmlwdGlvbikge1xuICAgICAgICAgICAgICAgICAgICAvLyBpZiB0aGVyZSBpcyBhIHN1YnNjcmlwdGlvbiwgdGhlbiB3ZSBjYW4gc3VybWlzZVxuICAgICAgICAgICAgICAgICAgICAvLyB0aGUgbmV4dCBoYW5kbGluZyBpcyBhc3luY2hyb25vdXMuIEFueSBlcnJvcnMgdGhyb3duXG4gICAgICAgICAgICAgICAgICAgIC8vIG5lZWQgdG8gYmUgcmVqZWN0ZWQgZXhwbGljaXRseSBhbmQgdW5zdWJzY3JpYmUgbXVzdCBiZVxuICAgICAgICAgICAgICAgICAgICAvLyBjYWxsZWQgbWFudWFsbHlcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIGlmIHRoZXJlIGlzIE5PIHN1YnNjcmlwdGlvbiwgdGhlbiB3ZSdyZSBnZXR0aW5nIGEgbmV4dGVkXG4gICAgICAgICAgICAgICAgICAgIC8vIHZhbHVlIHN5bmNocm9ub3VzbHkgZHVyaW5nIHN1YnNjcmlwdGlvbi4gV2UgY2FuIGp1c3QgY2FsbCBpdC5cbiAgICAgICAgICAgICAgICAgICAgLy8gSWYgaXQgZXJyb3JzLCBPYnNlcnZhYmxlJ3MgYHN1YnNjcmliZWAgd2lsbCBlbnN1cmUgdGhlXG4gICAgICAgICAgICAgICAgICAgIC8vIHVuc3Vic2NyaXB0a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cGUubmV4dCA9IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICBpZiAodGhpcy5jbG9zZWQpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBPYmplY3RVbnN1YnNjcmliZWRFcnJvcl8xLk9iamVjdFVuc3Vic2NyaWJlZEVycm9yKCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCF0aGlzLmlzU3RvcHBlZCkge1xuICAgICAgICAgICAgdmFyIG9ic2VydmVycyA9IHRoaXMub2JzZXJ2ZXJzO1xuICAgICAgICAgICAgdmFyIGxlbiA9IG9ic2VydmVycy5sZW5ndGg7XG4gICAgICAgICAgICB2YXIgY29weSA9IG9ic2VydmVycy5zbGljZSgpO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgICAgICAgIGNvcHlbaV0ubmV4dCh2YWx1ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFN1YmplY3QucHJvdG90eXBlLmVycm9yID0gZnVuY3Rpb24gKGVycikge1xuICAgICAgICBpZiAodGhpcy5jbG9zZWQpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBPYmplY3RVbnN1YnNjcmliZWRFcnJvcl8xLk9iamVjdFVuc3Vic2NyaWJlZEVycm9yKCk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5oYXNFcnJvciA9IHRydWU7XG4gICAgICAgIHRoaXMudGhyb3duRXJyb3IgPSBlcnI7XG4gICAgICAgIHRoaXMuaXNTdG9wcGVkID0gdHJ1ZTtcbiAgICAgICAgdmFyIG9ic2VydmVycyA9IHRoaXMub2JzZXJ2ZXJzO1xuICAgICAgICB2YXIgbGVuID0gb2JzZXJ2ZXJzLmxlbmd0aDtcbiAgICAgICAgdmFyIGNvcHkgPSBvYnNlcnZlcnMuc2xpY2UoKTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykge1xuICAgICAgICA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gY29tcGxldGVgIGNhbGxiYWNrIG9mIGFuXG4gICAgICogT2JzZXJ2ZXIuXG4gICAgICovXG4gICAgZnVuY3Rpb24gU3Vic2NyaWJlcihkZXN0aW5hdGlvbk9yTmV4dCwgZXJyb3IsIGNvbXBsZXRlKSB7XG4gICAgICAgIF9zdXBlci5jYWxsKHRoaXMpO1xuICAgICAgICB0aGlzLnN5bmNFcnJvclZhbHVlID0gbnVsbDtcbiAgICAgICAgdGhpcy5zeW5jRXJyb3JUaHJvd24gPSBmYWxzZTtcbiAgICAgICAgdGhpcy5zeW5jRXJyb3JUaHJvd2FibGUgPSBmYWxzZTtcbiAgICAgICAgdGhpcy5pc1N0b3BwZWQgPSBmYWxzZTtcbiAgICAgICAgc3dpdGNoIChhcmd1bWVudHMubGVuZ3RoKSB7XG4gICAgICAgICAgICBjYXNlIDA6XG4gICAgICAgICAgICAgICAgdGhpcy5kZXN0aW5hdGlvbiA9IE9ic2VydmVyXzEuZW1wdHk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIDE6XG4gICAgICAgICAgICAgICAgaWYgKCFkZXN0aW5hdGlvbk9yTmV4dCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3RpbmF0aW9uID0gT2JzZXJ2ZXJfMS5lbXB0eTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZGVzdGluYXRpb25Pck5leHQgPT09ICdvYmplY3QnKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChkZXN0aW5hdGlvbk9yTmV4dCBpbnN0YW5jZW9mIFN1YnNjcmliZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdGluYXRpb24gPSBkZXN0aW5hdGlvbk9yTmV4dDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdGluYXRpb24uYWRkKHRoaXMpO1xuICA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Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9fdHJ5T3JTZXRFcnJvcihfcGFyZW50LCB0aGlzLl9lcnJvciwgZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKCFfcGFyZW50LnN5bmNFcnJvclRocm93YWJsZSkge1xuICAgICAgICAgICAgICAgIHRoaXMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBfcGFyZW50LnN5bmNFcnJvclZhbHVlID0gZXJyO1xuICAgICAgICAgICAgICAgIF9wYXJlbnQuc3luY0Vycm9yVGhyb3duID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFNhZmVTdWJzY3JpYmVyLnByb3RvdHlwZS5jb21wbGV0ZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgaWYgKCF0aGlzLmlzU3RvcHBlZCkge1xuICAgICAgICAgICAgdmFyIF9wYXJlbnQgPSB0aGlzLl9wYXJlbnQ7XG4gICAgICAgICAgICBpZiAodGhpcy5fY29tcGxldGUpIHtcbiAgICAgICAgICAgICAgICBpZiAoIV9wYXJlbnQuc3luY0Vycm9yVGhyb3dhYmxlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX190cnlPclVuc3ViKHRoaXMuX2NvbXBsZXRlKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fX3RyeU9yU2V0RXJyb3IoX3BhcmVudCwgdGhpcy5fY29tcGxldGUpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbiAgICBTYWZlU3Vic2NyaWJlci5wcm90b3R5cGUuX190cnlPclVuc3ViID0gZnVuY3Rpb24gKGZuLCB2YWx1ZSkge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgZm4uY2FsbCh0aGlzLl9jb250ZXh0LCB2YWx1ZSk7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgdGhyb3cgZXJyO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBTYWZlU3Vic2NyaWJlci5wcm90b3R5cGUuX190cnlPclNldEVycm9yID0gZnVuY3Rpb24gKHBhcmVudCwgZm4sIHZhbHVlKSB7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICBmbi5jYWxsKHRoaXMuX2NvbnRleHQsIHZhbHVlKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICBwYXJlbnQuc3luY0Vycm9yVmFsdWUgPSBlcnI7XG4gICAgICAgICAgICBwYXJlbnQuc3luY0Vycm9yVGhyb3duID0gdHJ1ZTtcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9O1xuICAgIFNhZmVTdWJzY3JpYmVyLnByb3RvdHlwZS5fdW5zdWJzY3JpYmUgPSBmdW5jdGlvbiAoKSB7XG4g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c2goZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoaXNBcnJheV8xLmlzQXJyYXkoX3N1YnNjcmlwdGlvbnMpKSB7XG4gICAgICAgICAgICB2YXIgaW5kZXggPSAtMTtcbiAgICAgICAgICAgIHZhciBsZW4gPSBfc3Vic2NyaXB0aW9ucy5sZW5ndGg7XG4gICAgICAgICAgICB3aGlsZSAoKytpbmRleCA8IGxlbikge1xuICAgICAgICAgICAgICAgIHZhciBzdWIgPSBfc3Vic2NyaXB0aW9uc1tpbmRleF07XG4gICAgICAgICAgICAgICAgaWYgKGlzT2JqZWN0XzEuaXNPYmplY3Qoc3ViKSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdHJpYWwgPSB0cnlDYXRjaF8xLnRyeUNhdGNoKHN1Yi51bnN1YnNjcmliZSkuY2FsbChzdWIpO1xuICAgICAgICAgICAgICAgICAgICBpZiAodHJpYWwgPT09IGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGhhc0Vycm9ycyA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBlcnJvcnMgfHwgW107XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgZXJyID0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVyciBpbnN0YW5jZW9mIFVuc3Vic2NyaXB0aW9uRXJyb3JfMS5VbnN1YnNjcmlwdGlvbkVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JzID0gZXJyb3JzLmNvbmNhdChlcnIuZXJyb3JzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9ycy5wdXN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kIHRvIGJlXG4gICAgICogYWRkZWQgdG8gdGhlIGlubmVyIHN1YnNjcmlwdGlvbnMgbGlzdC4gVGhpcyBTdWJzY3JpcHRpb24gY2FuIGJlIHVzZWQgd2l0aFxuICAgICAqIGByZW1vdmUoKWAgdG8gcmVtb3ZlIHRoZSBwYXNzZWQgdGVhcmRvd24gbG9naWMgZnJvbSB0aGUgaW5uZXIgc3Vic2NyaXB0aW9uc1xuICAgICAqIGxpc3QuXG4gICAgICovXG4gICAgU3Vic2NyaXB0aW9uLnByb3RvdHlwZS5hZGQgPSBmdW5jdGlvbiAodGVhcmRvd24pIHtcbiAgICAgICAgaWYgKCF0ZWFyZG93biB8fCAodGVhcmRvd24gPT09IFN1YnNjcmlwdGlvbi5FTVBUWSkpIHtcbiAgICAgICAgICAgIHJldHVybiBTdWJzY3JpcHRpb24uRU1QVFk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRlYXJkb3duID09PSB0aGlzKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfVxuICAgICAgICB2YXIgc3ViID0gdGVhcmRvd247XG4gICAgICAgIHN3aXRjaCAodHlwZW9mIHRlYXJkb3duKSB7XG4gICAgICAgICAgICBjYXNlICdmdW5jdGlvbic6XG4gICAgICAgICAgICAgICAgc3ViID0gbmV3IFN1YnNjcmlwdGlvbih0ZWFyZG93bik7XG4gICAgICAgICAgICBjYXNlICdvYmplY3QnOlxuICAgICAgICAgICAgICAgIGlmIChzdWIuY2xvc2VkIHx8IHR5cGVvZiBzdWIudW5zdWJzY3JpYmUgIT09ICdmdW5jdGlvbicpIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2UgaWYgKHRoaXMuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgIHN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNl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biAgICAgICAgICAgIGlmICghc3ViamVjdCkge1xuICAgICAgICAgICAgICAgIHN1YmplY3QgPSB0aGlzLnN1YmplY3QgPSBuZXcgQXN5bmNTdWJqZWN0XzEuQXN5bmNTdWJqZWN0KCk7XG4gICAgICAgICAgICAgICAgdmFyIGhhbmRsZXIgPSBmdW5jdGlvbiBoYW5kbGVyRm4oKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpbm5lckFyZ3MgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgX2kgPSAwOyBfaSA8IGFyZ3VtZW50cy5sZW5ndGg7IF9pKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyQXJnc1tfaSAtIDBdID0gYXJndW1lbnRzW19pXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB2YXIgc291cmNlID0gaGFuZGxlckZuLnNvdXJjZTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHNlbGVjdG9yID0gc291cmNlLnNlbGVjdG9yLCBzdWJqZWN0ID0gc291cmNlLnN1YmplY3Q7XG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxlY3Rvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdF8xID0gdHJ5Q2F0Y2hfMS50cnlDYXRjaChzZWxlY3RvcikuYXBwbHkodGhpcywgaW5uZXJBcmdzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHRfMSA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YmplY3QuZXJyb3IoZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YmplY3QubmV4dChyZXN1bHRfMSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5uZXh0KGlubmVyQXJncy5sZW5ndGggPT09IDEgPyBpbm5lckFyZ3NbMF0gOiBpbm5lckFyZ3MpO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAvLyB1c2UgbmFtZWQgZnVuY3Rpb24gaW5zdGFuY2UgdG8gYXZvaWQgY2xvc3VyZS5cbiAgICAgICAgICAgICAgICBoYW5kbGVyLnNvdXJjZSA9IHRoaXM7XG4gICAgICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2goY2FsbGJhY2tGdW5jKS5hcHBseSh0aGlzLCBhcmdzLmNvbmNhdChoYW5kbGVyKSk7XG4gICAgICAgICAgICAgICAgaWYgKHJlc3VsdCA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgICAgICBzdWJqZWN0LmVycm9yKGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QuZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHN1YmplY3Quc3Vic2NyaWJlKHN1YnNjcmliZXIpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHNjaGVkdWxlci5zY2hlZHVsZShCb3VuZENhbGxiYWNrT2JzZXJ2YWJsZS5kaXNwYXRjaCwgMCwgeyBzb3VyY2U6IHRoaXMsIHN1YnNjcmliZXI6IHN1YnNjcmliZXIgfSk7XG4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F0Y2goc2VsZWN0b3IpLmFwcGx5KHRoaXMsIGlubmVyQXJncyk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHRfMiA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5hZGQoc2NoZWR1bGVyLnNjaGVkdWxlKGRpc3BhdGNoRXJyb3IsIDAsIHsgZXJyOiBlcnJvck9iamVjdF8xLmVycm9yT2JqZWN0LmUsIHN1YmplY3Q6IHN1YmplY3QgfSkpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5hZGQoc2NoZWR1bGVyLnNjaGVkdWxlKGRpc3BhdGNoTmV4dCwgMCwgeyB2YWx1ZTogcmVzdWx0XzIsIHN1YmplY3Q6IHN1YmplY3QgfSkpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBpbm5lckFyZ3MubGVuZ3RoID09PSAxID8gaW5uZXJBcmdzWzBdIDogaW5uZXJBcmdzO1xuICAgICAgICAgICAgICAgICAgICBzZWxmLmFkZChzY2hlZHVsZXIuc2NoZWR1bGUoZGlzcGF0Y2hOZXh0LCAwLCB7IHZhbHVlOiB2YWx1ZSwgc3ViamVjdDogc3ViamVjdCB9KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIC8vIHVzZSBuYW1lZCBmdW5jdGlvbiB0byBwYXNzIHZhbHVlcyBpbiB3aXRob3V0IGNsb3N1cmVcbiAgICAgICAgICAgIGhhbmRsZXIuc291cmNlID0gc291cmNlO1xuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2goY2FsbGJhY2tGdW5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XJBcmdzLnNoaWZ0KCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YmplY3QuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIGlmIChzZWxlY3Rvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdF8xID0gdHJ5Q2F0Y2hfMS50cnlDYXRjaChzZWxlY3RvcikuYXBwbHkodGhpcywgaW5uZXJBcmdzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHRfMSA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YmplY3QuZXJyb3IoZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YmplY3QubmV4dChyZXN1bHRfMSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5uZXh0KGlubmVyQXJncy5sZW5ndGggPT09IDEgPyBpbm5lckFyZ3NbMF0gOiBpbm5lckFyZ3MpO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAvLyB1c2UgbmFtZWQgZnVuY3Rpb24gaW5zdGFuY2UgdG8gYXZvaWQgY2xvc3VyZS5cbiAgICAgICAgICAgIC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24gKF9zdXBlcikge1xuICAgIF9fZXh0ZW5kcyhSZWZDb3VudFN1YnNjcmliZXIsIF9zdXBlcik7XG4gICAgZnVuY3Rpb24gUmVmQ291bnRTdWJzY3JpYmVyKGRlc3RpbmF0aW9uLCBjb25uZWN0YWJsZSkge1xuICAgICAgICBfc3VwZXIuY2FsbCh0aGlzLCBkZXN0aW5hdGlvbik7XG4gICAgICAgIHRoaXMuY29ubmVjdGFibGUgPSBjb25uZWN0YWJsZTtcbiAgICB9XG4gICAgUmVmQ291bnRTdWJzY3JpYmVyLnByb3RvdHlwZS5fdW5zdWJzY3JpYmUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBjb25uZWN0YWJsZSA9IHRoaXMuY29ubmVjdGFibGU7XG4gICAgICAgIGlmICghY29ubmVjdGFibGUpIHtcbiAgICAgICAgICAgIHRoaXMuY29ubmVjdGlvbiA9IG51bGw7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5jb25uZWN0YWJsZSA9IG51bGw7XG4gICAgICAgIHZhciByZWZDb3VudCA9IGNvbm5lY3RhYmxlLl9yZWZDb3VudDtcbiAgICAgICAgaWYgKHJlZkNvdW50IDw9IDApIHtcbiAgICAgICAgICAgIHRoaXMuY29ubmVjdGlvbiA9IG51bGw7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgY29ubmVjdGFibGUuX3JlZkNvdW50ID0gcmVmQ291bnQgLSAxO1xuICAgICAgICBpZiAocmVmQ291bnQgPiAxKSB7XG4gICAgICAgICAgICB0aGlzLmNvbm5lY3Rpb24gPSBudWxsO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIC8vL1xuICAgICAgICAvLyBDb21wYXJlIHRoZSBsb2NhbCBSZWZDb3VudFN1YnNjcmliZXIncyBjb25uZWN0aW9uIFN1YnNjcmlwdGlvbiB0byB0aGVcbiAgICAgICAgLy8gY29ubmVjd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cikge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuc2NoZWR1bGVyLnNjaGVkdWxlKEdlbmVyYXRlT2JzZXJ2YWJsZS5kaXNwYXRjaCwgMCwge1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZXI6IHN1YnNjcmliZXIsXG4gICAgICAgICAgICAgICAgaXRlcmF0ZTogdGhpcy5pdGVyYXRlLFxuICAgICAgICAgICAgICAgIGNvbmRpdGlvbjogdGhpcy5jb25kaXRpb24sXG4gICAgICAgICAgICAgICAgcmVzdWx0U2VsZWN0b3I6IHRoaXMucmVzdWx0U2VsZWN0b3IsXG4gICAgICAgICAgICAgICAgc3RhdGU6IHN0YXRlIH0pO1xuICAgICAgICB9XG4gICAgICAgIHZhciBfYSA9IHRoaXMsIGNvbmRpdGlvbiA9IF9hLmNvbmRpdGlvbiwgcmVzdWx0U2VsZWN0b3IgPSBfYS5yZXN1bHRTZWxlY3RvciwgaXRlcmF0ZSA9IF9hLml0ZXJhdGU7XG4gICAgICAgIGRvIHtcbiAgICAgICAgICAgIGlmIChjb25kaXRpb24pIHtcbiAgICAgICAgICAgICAgICB2YXIgY29uZGl0aW9uUmVzdWx0ID0gdm9pZCAwO1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbmRpdGlvblJlc3VsdCA9IGNvbmRpdGlvbihzdGF0ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICghY29uZGl0aW9uUmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHZhbHVlID0gdm9pZCAwO1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICB2YWx1ZSA9IHJlc3VsdFNlbGVjdG9yKHN0YXRlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgIGlmIChzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBzdGF0ZSA9IGl0ZXJhdGUoc3RhdGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gd2hpbGUgKHRydWUpO1xuICAgIH07XG4gICAgR2VuZXJhdGVPYnNlcnZhYmxlLmRpc3BhdGNoID0gZnVuY3Rpb24gKHN0YXRlKSB7XG4gICAgICAgIHZhciBzdWJzY3JpYmVyID0gc3RhdGUuc3Vic2NyaWJlciwgY29uZGl0aW9uID0gc3RhdGUuY29uZGl0aW9uO1xuICAgICAgICBpZiAoc3Vic2NyaWJlci5jbG9zZWQpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAoc3RhdGUubmVlZEl0ZXJhdGUpIHtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgc3RhdGUuc3RhdGUgPSBzdGF0ZS5pdGVyYXRlKHN0YXRlLnN0YXRlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgc3RhdGUubmVlZEl0ZXJhdGUgPSB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIGlmIChjb25kaXRpb24pIHtcbiAgICAgICAgICAgIHZhciBjb25kaXRpb25SZXN1bHQgPSB2b2lkIDA7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIGNvbmRpdGlvblJlc3VsdCA9IGNvbmRpdGlvbihzdGF0ZS5zdGF0ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghY29uZGl0aW9uUmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB2YXIgdmFsdWU7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICB2YWx1ZSA9IHN0YXRlLnJlc3VsdFNlbGVjdG9yKHN0YXRlLnN0YXRlKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICBzdWJzY3JpYmVyLmVycm9yKGVycik7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgK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RlcmF0b3JPYnNlcnZhYmxlLmRpc3BhdGNoLCAwLCB7XG4gICAgICAgICAgICAgICAgaW5kZXg6IGluZGV4LCBpdGVyYXRvcjogaXRlcmF0b3IsIHN1YnNjcmliZXI6IHN1YnNjcmliZXJcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSBpdGVyYXRvci5uZXh0KCk7XG4gICAgICAgICAgICAgICAgaWYgKHJlc3VsdC5kb25lKSB7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQocmVzdWx0LnZhbHVlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHN1YnNjcmliZXIuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gd2hpbGUgKHRydWUpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICByZXR1cm4gSXRlcmF0b3JPYnNlcnZhYmxlO1xufShPYnNlcnZhYmxlXzEuT2JzZXJ2YWJsZSkpO1xuZXhwb3J0cy5JdGVyYXRvck9ic2VydmFibGUgPSBJdGVyYXRvck9ic2VydmFibGU7XG52YXIgU3RyaW5nSXRlcmF0b3IgPSAoZnVuY3Rpb24gKCkge1xuICAgIGZ1bmN0aW9uIFN0cmluZ0l0ZXJhdG9yKHN0ciwgaWR4LCBsZW4pIHtcbiAgICAgICAgaWYgKGlkeCA9PT0gdm9pZCAwKSB7IGlkeCA9IDA7IH1cbiAgICAgICAgaWYgKGxlbiA9PT0gdm9pZCAwKSB7IGxlbiA9IHN0ci5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iAocHJvbWlzZSwgc2NoZWR1bGVyKSB7XG4gICAgICAgIHJldHVybiBuZXcgUHJvbWlzZU9ic2VydmFibGUocHJvbWlzZSwgc2NoZWR1bGVyKTtcbiAgICB9O1xuICAgIFByb21pc2VPYnNlcnZhYmxlLnByb3RvdHlwZS5fc3Vic2NyaWJlID0gZnVuY3Rpb24gKHN1YnNjcmliZXIpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgdmFyIHByb21pc2UgPSB0aGlzLnByb21pc2U7XG4gICAgICAgIHZhciBzY2hlZHVsZXIgPSB0aGlzLnNjaGVkdWxlcjtcbiAgICAgICAgaWYgKHNjaGVkdWxlciA9PSBudWxsKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5faXNTY2FsYXIpIHtcbiAgICAgICAgICAgICAgICBpZiAoIXN1YnNjcmliZXIuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dCh0aGlzLnZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHByb21pc2UudGhlbihmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMudmFsdWUgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMuX2lzU2NhbGFyID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAgICAgLnRoZW4obnVsbCwgZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgICAgICAvLyBlc2NhcGUgdGhlIHByb21pc2UgdHJhcCwgdGhyb3cgdW5oYW5kbGVkIGVycm9yc1xuICAgICAgICAgICAgICAgICAgICByb290XzEucm9vdC5zZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHsgdGhyb3cgZXJyOyB9KTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9pc1NjYWxhcikge1xuICAgICAgICAgICAgICAgIGlmICghc3Vic2NyaWJlci5jbG9zZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNjaGVkdWxlci5zY2hlZHVsZShkaXNwYXRjaE5leHQsIDAsIHsgdmFsdWU6IHRoaXMudmFsdWUsIHN1YnNjcmliZXI6IHN1YnNjcmliZXIgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgcHJvbWlzZS50aGVuKGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy52YWx1ZSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy5faXNTY2FsYXIgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICBpZiAoIXN1YnNjcmliZXIuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmFkZChzY2hlZHVsZXIuc2NoZWR1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Cwgc3Vic2NyaWJlcjogc3Vic2NyaWJlclxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgaWYgKGluZGV4KysgPj0gY291bnQpIHtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHN0YXJ0KyspO1xuICAgICAgICAgICAgICAgIGlmIChzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IHdoaWxlICh0cnVlKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgcmV0dXJuIFJhbmdlT2JzZXJ2YWJsZTtcbn0oT2JzZXJ2YWJsZV8xLk9ic2VydmFibGUpKTtcbmV4cG9ydHMuUmFuZ2VPYnNlcnZhYmxlID0gUmFuZ2VPYnNlcnZhYmxlO1xuLy8jIHNvdXJjZU1hcHBpbmdVUkw9UmFuZ2VPYnNlcnZhYmxlLmpzLm1hcCIsIlwidXNlIHN0cmljdFwiO1xudmFyIF9fZXh0ZW5kcyA9ICh0aGlzICYmIHRoaXMuX19leHRlbmRzKSB8fCBmdW5jdGlvbiAoZCwgYikge1xuICAgIGZvciAodmFyIHAgaW4gYikgaWYgKGIuaGFzT3duUHJvcGVydHkocCkpIGRbcF0gPSBiW3BdO1xuICAgIGZ1bmN0aW9uIF9fKCkgeyB0aGlzLmNvbnN0cnVjdG9yID0gZDsgfVxuICAgIGQucHJvdG90eXBlID0gYiA9PT0gbnVsbCA/IE9iamVjdC5jcmVhdGUoYikgOiAoX18ucHJvdG90eXBlID0gYi5wcm90b3R5cGUsIG5ldyBfXygpKTtcbn07XG52YXIgT2JzZXJ2YWJsZV8xID0g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TUmVxdWVzdC5jYWxsKHRoaXMpIDogZ2V0WE1MSHR0cFJlcXVlc3QoKTtcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjcm9zc0RvbWFpbjogZmFsc2UsXG4gICAgICAgICAgICB3aXRoQ3JlZGVudGlhbHM6IGZhbHNlLFxuICAgICAgICAgICAgaGVhZGVyczoge30sXG4gICAgICAgICAgICBtZXRob2Q6ICdHRVQnLFxuICAgICAgICAgICAgcmVzcG9uc2VUeXBlOiAnanNvbicsXG4gICAgICAgICAgICB0aW1lb3V0OiAwXG4gICAgICAgIH07XG4gICAgICAgIGlmICh0eXBlb2YgdXJsT3JSZXF1ZXN0ID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgcmVxdWVzdC51cmwgPSB1cmxPclJlcXVlc3Q7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBmb3IgKHZhciBwcm9wIGluIHVybE9yUmVxdWVzdCkge1xuICAgICAgICAgICAgICAgIGlmICh1cmxPclJlcXVlc3QuaGFzT3duUHJvcGVydHkocHJvcCkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVxdWVzdFtwcm9wXSA9IHVybE9yUmVxdWVzdFtwcm9wXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5yZXF1ZXN0ID0gcmVxdWVzdDtcbiAgICB9XG4gICAgQWpheE9ic2VydmFibGUucHJvdG90eXBlLl9zdWJzY3JpYmUgPSBmdW5jdGlvbiAoc3Vic2NyaWJlcikge1xuICAgICAgICByZXR1cm4gbmV3IEFqYXhTdWJzY3JpYmVyKHN1YnNjcmliZXIsIHRoaXMucmVxdWVzdCk7XG4gICAgfTtcbiAgICAvKipcbiAgICAgKiBDcmVhdGVzIGFuIG9ic2VydmFibGUgZm9yIGFuIEFqYXggcmVxdWVzdCB3aXRoIGVpdGhlciBhIHJlcXVlc3Qgb2JqZWN0IHdpdGhcbiAg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cbiAgICAgICAgICAgIHRoaXMuZXJyb3IoZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lKTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMueGhyID0geGhyO1xuICAgICAgICAgICAgLy8gb3BlbiBYSFIgZmlyc3RcbiAgICAgICAgICAgIHZhciByZXN1bHQgPSB2b2lkIDA7XG4gICAgICAgICAgICBpZiAodXNlcikge1xuICAgICAgICAgICAgICAgIHJlc3VsdCA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2goeGhyLm9wZW4pLmNhbGwoeGhyLCBtZXRob2QsIHVybCwgYXN5bmMsIHVzZXIsIHBhc3N3b3JkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHJlc3VsdCA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2goeGhyLm9wZW4pLmNhbGwoeGhyLCBtZXRob2QsIHVybCwgYXN5bmMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHJlc3VsdCA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgIHRoaXMuZXJyb3IoZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdC5lKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIHRpbWVvdXQgYW5kIHJlc3BvbnNlVHlwZSBjYW4gYmUgc2V0IG9uY2UgdGhlIFhIUiBpcyBvcGVuXG4gICAgICAgICAgICB4aHIudGltZW91dCA9IHJlcXVlc3QudGltZW91dDtcbiAgICAgICAgICAgIHhoci5yZXNwb25zZVR5cGUgPSByZXF1ZXN0LnJlc3BvbnNlVHlwZTtcbiAgICAgICAgICAgIC8vIHNldCBoZWFkZXJzXG4gICAgICAgICAgICB0aGlzLnNldEhlYWRlcnMoeGhyLCBoZWFkZXJzKTtcbiAgICAgICAgICAgIC8vIG5vdyBzZXQgdXAgdGhlIGV2ZW50c1xuICAgICAgICAgICAgdGhpcy5zZXR1cEV2ZW50cyh4aHIsIHJlcXVlc3QpO1xuICAgICAgICAgICAgLy8gZmluYWxseSBzZW5kIHRoZSByZXF1ZXN0XG4gICAgICAgICAgICBpZiAoYm9keSkge1xuICAgICAgICAgICAgICAgIHhoci5zZW5kKGJvZHkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgeGhyLnNlbmQoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4geGhyO1xuICAgIH07XG4gICAgQWpheFN1YnNjcmliZXIucHJvdG90eXBlLnNlcmlhbGl6ZUJvZHkgPSBmdW5jdGlvbiAoYm9keSwgY29udGVudFR5cGUpIHtcbiAgICAgICAgaWYgKCFib2R5IHx8IHR5cGVvZiBib2R5ID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgcmV0dXJuIGJvZHk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAocm9vdF8xLnJvb3QuRm9ybURhdGEgJiYgYm9keSBpbnN0YW5jZW9mIHJvb3RfMS5yb290LkZvcm1EYXRhKSB7XG4gICAgICAgICAgICByZXR1cm4gYm9keTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoY29udGVudFR5cGUpIHtcbiAgICAgICAgICAgIHZhciBzcGxpdEluZGV4ID0gY29udGVudFR5cGUuaW5kZXhPZignOycpO1xuICAgICAgICAgICAgaWYgKHNwbGl0SW5kZXggIT09IC0xKSB7XG4gICAgICAgICAgICAgICAgY29udGVudFR5cGUgPSBjb250ZW50VHlwZS5zdWJzdHJpbmcoMCwgc3BsaXRJbmRleCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgc3dpdGNoIChjb250ZW50VHlwZSkge1xuICAgICAgICAgICAgY2FzZSAnYXBwbGljYXRpb24veC13d3ctZm9ybS11cmx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gX2EucmVxdWVzdDtcbiAgICAgICAgICAgIGlmIChwcm9ncmVzc1N1YnNjcmliZXIpIHtcbiAgICAgICAgICAgICAgICBwcm9ncmVzc1N1YnNjcmliZXIuZXJyb3IoZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzdWJzY3JpYmVyLmVycm9yKG5ldyBBamF4VGltZW91dEVycm9yKHRoaXMsIHJlcXVlc3QpKTsgLy9UT0RPOiBNYWtlIGJldHRlcmVyLlxuICAgICAgICB9O1xuICAgICAgICB4aHIub250aW1lb3V0LnJlcXVlc3QgPSByZXF1ZXN0O1xuICAgICAgICB4aHIub250aW1lb3V0LnN1YnNjcmliZXIgPSB0aGlzO1xuICAgICAgICB4aHIub250aW1lb3V0LnByb2dyZXNzU3Vic2NyaWJlciA9IHByb2dyZXNzU3Vic2NyaWJlcjtcbiAgICAgICAgaWYgKHhoci51cGxvYWQgJiYgJ3dpdGhDcmVkZW50aWFscycgaW4geGhyICYmIHJvb3RfMS5yb290LlhEb21haW5SZXF1ZXN0KSB7XG4gICAgICAgICAgICBpZiAocHJvZ3Jlc3NTdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICAgICAgeGhyLm9ucHJvZ3Jlc3MgPSBmdW5jdGlvbiB4aHJQcm9ncmVzcyhlKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBwcm9ncmVzc1N1YnNjcmliZXIgPSB4aHJQcm9ncmVzcy5wcm9ncmVzc1N1YnNjcmliZXI7XG4gICAgICAgICAgICAgICAgICAgIHByb2dyZXNzU3Vic2NyaWJlci5uZXh0KGUpO1xuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgeGhyLm9ucHJvZ3Jlc3MucHJvZ3Jlc3NTdWJzY3JpYmVyID0gcHJvZ3Jlc3NTdWJzY3JpYmVyO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgeGhyLm9uZXJyb3IgPSBmdW5jdGlvbiB4aHJFcnJvcihlKSB7XG4gICAgICAgICAgICAg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RhdHVzXzEgPSB0aGlzLnN0YXR1cyA9PT0gMTIyMyA/IDIwNCA6IHRoaXMuc3RhdHVzO1xuICAgICAgICAgICAgICAgIHZhciByZXNwb25zZSA9ICh0aGlzLnJlc3BvbnNlVHlwZSA9PT0gJ3RleHQnID8gKHRoaXMucmVzcG9uc2UgfHwgdGhpcy5yZXNwb25zZVRleHQpIDogdGhpcy5yZXNwb25zZSk7XG4gICAgICAgICAgICAgICAgLy8gZml4IHN0YXR1cyBjb2RlIHdoZW4gaXQgaXMgMCAoMCBzdGF0dXMgaXMgdW5kb2N1bWVudGVkKS5cbiAgICAgICAgICAgICAgICAvLyBPY2N1cnMgd2hlbiBhY2Nlc3NpbmcgZmlsZSByZXNvdXJjZXMgb3Igb24gQW5kcm9pZCA0LjEgc3RvY2sgYnJvd3NlclxuICAgICAgICAgICAgICAgIC8vIHdoaWxlIHJldHJpZXZpbmcgZmlsZXMgZnJvbSBhcHBsaWNhdGlvbiBjYWNoZS5cbiAgICAgICAgICAgICAgICBpZiAoc3RhdHVzXzEgPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzXzEgPSByZXNwb25zZSA/IDIwMCA6IDA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICgyMDAgPD0gc3RhdHVzXzEgJiYgc3RhdHVzXzEgPCAzMDApIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHByb2dyZXNzU3Vic2NyaWJlcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NTdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KGUpO1xuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBpZiAocHJv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cmxDb25maWdPclNvdXJjZSA9PT0gJ3N0cmluZycpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnVybCA9IHVybENvbmZpZ09yU291cmNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgLy8gV0FSTklORzogY29uZmlnIG9iamVjdCBjb3VsZCBvdmVycmlkZSBpbXBvcnRhbnQgbWVtYmVycyBoZXJlLlxuICAgICAgICAgICAgICAgIGFzc2lnbl8xLmFzc2lnbih0aGlzLCB1cmxDb25maWdPclNvdXJjZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIXRoaXMuV2ViU29ja2V0Q3Rvcikge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignbm8gV2ViU29ja2V0IGNvbnN0cnVjdG9yIGNhbiBiZSBmb3VuZCcpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5kZXN0aW5hdGlvbiA9IG5ldyBSZXBsYXlTdWJqZWN0XzEuUmVwbGF5U3ViamVjdCgpO1xuICAgICAgICB9XG4gICAgfVxuICAgIFdlYlNvY2tldFN1YmplY3QucHJvdG90eXBlLnJlc3VsdFNlbGVjdG9yID0gZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgcmV0dXJuIEpTT04ucGFyc2UoZS5kYXRhKTtcbiAgICB9O1xuICAgIC8qKlxuICAgICAqIEBwYXJhbSB1cmxDb25maWdPclNvdXJjZVxuICAgICAqIEByZXR1cm4ge1dlYlNvY2tldFN1YmplY3R9XG4gICAgICogQHN0YXRpYyB0cnVlXG4gICAgICogQG5hbWUgd2ViU29ja2V0XG4gICAgICogQG93bmVyIE9ic2VydmFibGVcbiAgICAgKi9cbiAgICBXZWJTb2NrZXRTdWJqZWN0LmNyZWF0ZSA9IGZ1bmN0aW9uICh1cmxDb25maWdPclNvdXJjZSkge1xuICAgICAgICByZXR1cm4gbmV3IFdlYlNvY2tldFN1YmplY3QodXJsQ29uZ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B2YXIgcmVzdWx0ID0gdHJ5Q2F0Y2hfMS50cnlDYXRjaChtZXNzYWdlRmlsdGVyKSh4KTtcbiAgICAgICAgICAgICAgICBpZiAocmVzdWx0ID09PSBlcnJvck9iamVjdF8xLmVycm9yT2JqZWN0KSB7XG4gICAgICAgICAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QuZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2UgaWYgKHJlc3VsdCkge1xuICAgICAgICAgICAgICAgICAgICBvYnNlcnZlci5uZXh0KHgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChlcnIpIHsgcmV0dXJuIG9ic2VydmVyLmVycm9yKGVycik7IH0sIGZ1bmN0aW9uICgpIHsgcmV0dXJuIG9ic2VydmVyLmNvbXBsZXRlKCk7IH0pO1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gdHJ5Q2F0Y2hfMS50cnlDYXRjaCh1bnN1Yk1zZykoKTtcbiAgICAgICAgICAgICAgICBpZiAocmVzdWx0ID09PSBlcnJvck9iamVjdF8xLmVycm9yT2JqZWN0KSB7XG4gICAgICAgICAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QuZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLm5leHQocmVzdWx0KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9KTtcbiAgICB9O1xuICAgIFdlYlNvY2tldFN1YmplY3QucHJvdG90eXBlLl9jb25uZWN0U29ja2V0ID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICB2YXIgV2ViU29ja2V0Q3RvciA9IHRoaXMuV2ViU29ja2V0Q3RvcjtcbiAgICAgICAgdmFyIG9ic2VydmVyID0gdGhpcy5fb3V0cHV0O1xuICAgICAgICB2YXIgc29ja2V0ID0gbnVsbDtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHNvY2tldCA9IHRoaXMucHJvdG9jb2wgP1xuICAgICAgICAgICAgICAgIG5ldyBXZWJTb2NrZXRDdG9yKHRoaXMudXJsLCB0aGlzLnByb3RvY29sKSA6XG4gICAgICAgICAgICAgICAgbmV3IFdlYlNvY2tldEN0b3IodGhpcy51cmwpO1xuICAgICAgICAgICAgdGhpcy5zb2NrZXQgPSBzb2NrZXQ7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKGUpO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHZhciBzdWJzY3JpcHRpb24gPSBuZXcgU3Vic2NyaXB0aW9uXzEuU3Vic2NyaXB0aW9uKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIF90aGlzLnNvY2tldCA9IG51bGw7XG4gICAgICAgICAgICBpZiAoc29ja2V0ICYmIHNvY2tldC5yZWFkeVN0YXRlID09PSAxKSB7XG4gICAgICAgICAgICAgICAgc29ja2V0LmNsb3NlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICBzb2NrZXQub25vcGVuID0gZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgICAgIHZhciBvcGVuT2JzZXJ2ZXIgPSBfdGhpcy5vcGVuT2JzZXJ2ZXI7XG4gICAgICAgICAgICBpZiAob3Blbk9ic2VydmVyKSB7XG4gICAgICAgICAgICAgICAgb3Blbk9ic2VydmVyLm5leHQoZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgcXVldWUgPSBfdGhpcy5kZXN0aW5hdGlvbjtcbiAgICAgICAgICAgIF90aGlzLmRlc3RpbmF0aW9uID0gU3Vic2NyaWJlcl8xLlN1YnNjcmliZXIuY3JlYXRlKGZ1bmN0aW9uICh4KSB7IHJldHVybiBzb2NrZXQucmVhZHlTdGF0ZSA9PT0gMSAmJiBzb2NrZXQuc2VuZCh4KTsgfSwgZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgICAgICAgICB2YXIgY2xvc2luZ09ic2VydmVyID0gX3RoaXMuY2xvc2luZ09ic2VydmVyO1xuICAgICAgICAgICAgICAgIGlmIChjbG9zaW5nT2JzZXJ2ZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgY2xvc2luZ09ic2VydmVyLm5leHQodW5kZWZpbmVkKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGUgJiYgZS5jb2RlKSB7XG4gICAgICAgICAgICAgICAgICAgIHNvY2tldC5jbG9zZShlLmNvZGUsIGUucmVhc29uKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKG5ldyBUeXBlRXJyb3IoJ1dlYlNvY2tldFN1YmplY3QuZXJyb3IgbXVzdCBiZSBjYWxsZWQgd2l0aCBhbiBvYmplY3Qgd2l0aCBhbiBlcnJvciBjb2RlLCAnICtcbiAgICAgICAgICAgICAgICAgICAgICAgICdhbmQgYW4gb3B0aW9uYWwgcmVhc29uOiB7IGNvZGU6IG51bWJlciwgcmVhc29uOiBzdHJpbmcgfScpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgX3RoaXMuZGVzdGluYXRpb24gPSBuZXcgUmVwbGF5U3ViamVjdF8xLlJlcGxheVN1YmplY3QoKTtcbiAgICAgICAgICAgICAgICBfdGhpcy5zb2NrZXQgPSBudWxsO1xuICAgICAgICAg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jb21wbGV0ZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgb2JzZXJ2ZXIuZXJyb3IoZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICAgIHNvY2tldC5vbm1lc3NhZ2UgPSBmdW5jdGlvbiAoZSkge1xuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2goX3RoaXMucmVzdWx0U2VsZWN0b3IpKGUpO1xuICAgICAgICAgICAgaWYgKHJlc3VsdCA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QuZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBvYnNlcnZlci5uZXh0KHJlc3VsdCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfTtcbiAgICBXZWJTb2NrZXRTdWJqZWN0LnByb3RvdHlwZS5fc3Vic2NyaWJlID0gZnVuY3Rpb24gKHN1YnNjcmliZXIpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgdmFyIHNvdXJjZSA9IHRoaXMuc291cmNlO1xuICAgICAgICBpZiAoc291cmNlKSB7XG4gICAgICAgICAgICByZXR1cm4gc291cmNlLnN1YnNjcmliZShzdWJzY3JpYmVyKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXRoaXMuc29ja2V0KSB7XG4gICAgICAgICAgICB0aGlzLl9jb25uZWN0U29ja2V0KCk7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHN1YnNjcmlwdGlvbiA9IG5ldyBTdWJzY3JpcHRpb25fMS5TdWJzY3JpcHRpb24oKTtcbiAgICAgICAgc3Vic2NyaXB0aW9uLmFkZCh0aGlzLl9vdXRwdXQuc3Vic2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A9IGdldFN1YmplY3QoKTtcbiAgICAgICAgICAgIG91dGVyU3ViID0gc291cmNlLnN1YnNjcmliZShmdW5jdGlvbiAodmFsdWUpIHsgcmV0dXJuIHN1YmplY3QubmV4dCh2YWx1ZSk7IH0sIGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgICAgICAgICB2YXIgcyA9IHN1YmplY3Q7XG4gICAgICAgICAgICAgICAgc3ViamVjdCA9IG51bGw7XG4gICAgICAgICAgICAgICAgcy5lcnJvcihlcnIpO1xuICAgICAgICAgICAgfSwgZnVuY3Rpb24gKCkgeyByZXR1cm4gc3ViamVjdC5jb21wbGV0ZSgpOyB9KTtcbiAgICAgICAgfVxuICAgICAgICByZWZzKys7XG4gICAgICAgIGlmICghc3ViamVjdCkge1xuICAgICAgICAgICAgc3ViamVjdCA9IGdldFN1YmplY3QoKTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgaW5uZXJTdWIgPSBzdWJqZWN0LnN1YnNjcmliZShvYnNlcnZlcik7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICByZWZzLS07XG4gICAgICAgICAgICBpZiAoaW5uZXJTdWIpIHtcbiAgICAgICAgICAgICAgICBpbm5lclN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHJlZnMgPT09IDApIHtcbiAgICAgICAgICAgICAgICBvdXRlclN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH0pO1xufVxuZXhwb3J0cy5jYWNoZSA9IGNhY2hlO1xuLy8jIHNvdXJjZU1hcHBpbmdVUkw9Y2FjaGUuanMubWFwIiwiXCJ1c2Ugc3RyaWN0XCI7XG52YXIgX19leHRlbmRzID0gKHRoaXMgJiYgdGhpcy5fX2V4dGVuZHMpIHx8IGZ1bmN0aW9uIChkLCBiKSB7XG4gICAgZm9yICh2YXIgcCBpbiBiKSBpZiAoYi5oYXN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iaW5lTGF0ZXN0U3Vic2NyaWJlci5wcm90b3R5cGUubm90aWZ5TmV4dCA9IGZ1bmN0aW9uIChvdXRlclZhbHVlLCBpbm5lclZhbHVlLCBvdXRlckluZGV4LCBpbm5lckluZGV4LCBpbm5lclN1Yikge1xuICAgICAgICB2YXIgdmFsdWVzID0gdGhpcy52YWx1ZXM7XG4gICAgICAgIHZhciBvbGRWYWwgPSB2YWx1ZXNbb3V0ZXJJbmRleF07XG4gICAgICAgIHZhciB0b1Jlc3BvbmQgPSAhdGhpcy50b1Jlc3BvbmRcbiAgICAgICAgICAgID8gMFxuICAgICAgICAgICAgOiBvbGRWYWwgPT09IG5vbmUgPyAtLXRoaXMudG9SZXNwb25kIDogdGhpcy50b1Jlc3BvbmQ7XG4gICAgICAgIHZhbHVlc1tvdXRlckluZGV4XSA9IGlubmVyVmFsdWU7XG4gICAgICAgIGlmICh0b1Jlc3BvbmQgPT09IDApIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnByb2plY3QpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90cnlQcm9qZWN0KHZhbHVlcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLmRlc3RpbmF0aW9uLm5leHQodmFsdWVzLnNsaWNlKCkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbiAgICBDb21iaW5lTGF0ZXN0U3Vic2NyaWJlci5wcm90b3R5cGUuX3RyeVByb2plY3QgPSBmdW5jdGlvbiAodmFsdWVzKSB7XG4gICAgICAgIHZhciByZXN1bHQ7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICByZXN1bHQgPSB0aGlzLnByb2plY3QuYXBwbHkodGhpcywgdmFsdWVzKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICB0aGlzLmRlc3RpbmF0aW9uLmVycm9yKGVycik7XG4gICAgICAgICAgICByZXR1cm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GUuX25leHQgPSBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgdmFyIGluZGV4ID0gdGhpcy5pbmRleCsrO1xuICAgICAgICBpZiAodGhpcy5wcmVkaWNhdGUpIHtcbiAgICAgICAgICAgIHRoaXMuX3RyeVByZWRpY2F0ZSh2YWx1ZSwgaW5kZXgpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fZW1pdCh2YWx1ZSwgaW5kZXgpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBGaXJzdFN1YnNjcmliZXIucHJvdG90eXBlLl90cnlQcmVkaWNhdGUgPSBmdW5jdGlvbiAodmFsdWUsIGluZGV4KSB7XG4gICAgICAgIHZhciByZXN1bHQ7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICByZXN1bHQgPSB0aGlzLnByZWRpY2F0ZSh2YWx1ZSwgaW5kZXgsIHRoaXMuc291cmNlKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICB0aGlzLmRlc3RpbmF0aW9uLmVycm9yKGVycik7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHJlc3VsdCkge1xuICAgICAgICAgICAgdGhpcy5fZW1pdCh2YWx1ZSwgaW5kZXgpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBGaXJzdFN1YnNjcmliZXIucHJvdG90eXBlLl9lbWl0ID0gZnVuY3Rpb24gKHZhbHVlLCBpbmRleCkge1xuICAgICAgICBpZiAodGhpcy5yZXN1bHRTZWxlY3Rvcikge1xuICAgICAgICAgICAgdGhpcy5fdHJ5UmVzdWx0U2VsZWN0b3IodmFsdWUsIGluZGV4KTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9lbWl0RmluYWwodmFsdWUpO1xuICAgIH07XG4gICAgRmlyc3RTdWJzY3JpYmVyLnByb3RvdHlwZS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cy5kdXJhdGlvblNlbGVjdG9yKSB7XG4gICAgICAgICAgICAgICAgdmFyIGR1cmF0aW9uID0gdm9pZCAwO1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGR1cmF0aW9uID0gdGhpcy5kdXJhdGlvblNlbGVjdG9yKG5ldyBHcm91cGVkT2JzZXJ2YWJsZShrZXksIGdyb3VwKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuYWRkKGR1cmF0aW9uLnN1YnNjcmliZShuZXcgR3JvdXBEdXJhdGlvblN1YnNjcmliZXIoa2V5LCBncm91cCwgdGhpcykpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoIWdyb3VwLmNsb3NlZCkge1xuICAgICAgICAgICAgZ3JvdXAubmV4dChlbGVtZW50KTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgR3JvdXBCeVN1YnNjcmliZXIucHJvdG90eXBlLl9lcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgdmFyIGdyb3VwcyA9IHRoaXMuZ3JvdXBzO1xuICAgICAgICBpZiAoZ3JvdXBzKSB7XG4gICAgICAgICAgICBncm91cHMuZm9yRWFjaChmdW5jdGlvbiAoZ3JvdXAsIGtleSkge1xuICAgICAgICAgICAgICAgIGdyb3VwLmVycm9yKGVycik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGdyb3Vwcy5jbGVhcigpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuZGVzdGluYXRpb24uZXJyb3IoZXJyKTtcbiAgICB9O1xuICAgIEdyb3VwQnlTdWJzY3JpYmVyLnByb3RvdHlwZS5fY29tcGxldGUg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2YgZGVmYXVsdFZhbHVlICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgdGhpcy5sYXN0VmFsdWUgPSBkZWZhdWx0VmFsdWU7XG4gICAgICAgICAgICB0aGlzLmhhc1ZhbHVlID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBMYXN0U3Vic2NyaWJlci5wcm90b3R5cGUuX25leHQgPSBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgdmFyIGluZGV4ID0gdGhpcy5pbmRleCsrO1xuICAgICAgICBpZiAodGhpcy5wcmVkaWNhdGUpIHtcbiAgICAgICAgICAgIHRoaXMuX3RyeVByZWRpY2F0ZSh2YWx1ZSwgaW5kZXgpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMucmVzdWx0U2VsZWN0b3IpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90cnlSZXN1bHRTZWxlY3Rvcih2YWx1ZSwgaW5kZXgpO1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMubGFzdFZhbHVlID0gdmFsdWU7XG4gICAgICAgICAgICB0aGlzLmhhc1ZhbHVlID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgTGFzdFN1YnNjcmliZXIucHJvdG90eXBlLl90cnlQcmVkaWNhdGUgPSBmdW5jdGlvbiAodmFsdWUsIGluZGV4KSB7XG4gICAgICAgIHZhciByZXN1bHQ7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICByZXN1bHQgPSB0aGlzLnByZWRpY2F0ZSh2YWx1ZSwgaW5kZXgsIHRoaXMuc291cmNlKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICB0aGlzLmRlc3RpbmF0aW9uLmVycm9yKGVycik7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaW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ZTtcbiAgICB9XG4gICAgUmVwZWF0V2hlblN1YnNjcmliZXIucHJvdG90eXBlLmNvbXBsZXRlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICBpZiAoIXRoaXMuaXNTdG9wcGVkKSB7XG4gICAgICAgICAgICB2YXIgbm90aWZpY2F0aW9ucyA9IHRoaXMubm90aWZpY2F0aW9ucztcbiAgICAgICAgICAgIHZhciByZXRyaWVzID0gdGhpcy5yZXRyaWVzO1xuICAgICAgICAgICAgdmFyIHJldHJpZXNTdWJzY3JpcHRpb24gPSB0aGlzLnJldHJpZXNTdWJzY3JpcHRpb247XG4gICAgICAgICAgICBpZiAoIXJldHJpZXMpIHtcbiAgICAgICAgICAgICAgICBub3RpZmljYXRpb25zID0gbmV3IFN1YmplY3RfMS5TdWJqZWN0KCk7XG4gICAgICAgICAgICAgICAgcmV0cmllcyA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2godGhpcy5ub3RpZmllcikobm90aWZpY2F0aW9ucyk7XG4gICAgICAgICAgICAgICAgaWYgKHJldHJpZXMgPT09IGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9zdXBlci5wcm90b3R5cGUuY29tcGxldGUuY2FsbCh0aGlzKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0cmllc1N1YnNjcmlwdGlvbiA9IHN1YnNjcmliZVRvUmVzdWx0XzEuc3Vic2NyaWJlVG9SZXN1bHQodGhpcywgcmV0cmllcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLm5vdGlmaWNhdGlvbnMgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMucmV0cmllc1N1YnNjcmlwdGlvbiA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB0aGlzLmN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yY2U7XG4gICAgfVxuICAgIFJldHJ5V2hlblN1YnNjcmliZXIucHJvdG90eXBlLmVycm9yID0gZnVuY3Rpb24gKGVycikge1xuICAgICAgICBpZiAoIXRoaXMuaXNTdG9wcGVkKSB7XG4gICAgICAgICAgICB2YXIgZXJyb3JzID0gdGhpcy5lcnJvcnM7XG4gICAgICAgICAgICB2YXIgcmV0cmllcyA9IHRoaXMucmV0cmllcztcbiAgICAgICAgICAgIHZhciByZXRyaWVzU3Vic2NyaXB0aW9uID0gdGhpcy5yZXRyaWVzU3Vic2NyaXB0aW9uO1xuICAgICAgICAgICAgaWYgKCFyZXRyaWVzKSB7XG4gICAgICAgICAgICAgICAgZXJyb3JzID0gbmV3IFN1YmplY3RfMS5TdWJqZWN0KCk7XG4gICAgICAgICAgICAgICAgcmV0cmllcyA9IHRyeUNhdGNoXzEudHJ5Q2F0Y2godGhpcy5ub3RpZmllcikoZXJyb3JzKTtcbiAgICAgICAgICAgICAgICBpZiAocmV0cmllcyA9PT0gZXJyb3JPYmplY3RfMS5lcnJvck9iamVjdCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3N1cGVyLnByb3RvdHlwZS5lcnJvci5jYWxsKHRoaXMsIGVycm9yT2JqZWN0XzEuZXJyb3JPYmplY3QuZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHJpZXNTdWJzY3JpcHRpb24gPSBzdWJzY3JpYmVUb1Jlc3VsdF8xLnN1YnNjcmliZVRvUmVzdWx0KHRoaXMsIHJldHJpZXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5lcnJvcnMgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMucmV0cmllc1N1YnNjcmlwdGlvbiA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB0aGlzLmNsb3NlZ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zLnJpbmcgPSBuZXcgQXJyYXkoKTtcbiAgICAgICAgdGhpcy5jb3VudCA9IDA7XG4gICAgfVxuICAgIFRha2VMYXN0U3Vic2NyaWJlci5wcm90b3R5cGUuX25leHQgPSBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgdmFyIHJpbmcgPSB0aGlzLnJpbmc7XG4gICAgICAgIHZhciB0b3RhbCA9IHRoaXMudG90YWw7XG4gICAgICAgIHZhciBjb3VudCA9IHRoaXMuY291bnQrKztcbiAgICAgICAgaWYgKHJpbmcubGVuZ3RoIDwgdG90YWwpIHtcbiAgICAgICAgICAgIHJpbmcucHVzaCh2YWx1ZSk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICB2YXIgaW5kZXggPSBjb3VudCAlIHRvdGFsO1xuICAgICAgICAgICAgcmluZ1tpbmRleF0gPSB2YWx1ZTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgVGFrZUxhc3RTdWJzY3JpYmVyLnByb3RvdHlwZS5fY29tcGxldGUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBkZXN0aW5hdGlvbiA9IHRoaXMuZGVzdGluYXRpb247XG4gICAgICAgIHZhciBjb3VudCA9IHRoaXMuY291bnQ7XG4gICAgICAgIGlmIChjb3VudCA+IDApIHtcbiAgICAgICAgICAgIHZhciB0b3RhbCA9IHRoaXMuY291bnQgPj0gdGhpcy50b3RhbCA/IHRoaXMudG90YWwgOiB0aGlzLmNvdW50O1xuICAgICAgICAgICAgdmFyIHJpbmcgPSB0aGlzLnJpbmc7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHRvdGFsOyBpKyspIHtcbiAgICAgICAgICAgICAgICB2YXIgaWR4ID0gKGNvdW50KyspICUgdG90YWw7XG4gICAgICAgICAgICAgICAgZGVzdGluYXRpb24ubmV4dChyaW5nW2lkeF0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGRlc3R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LnNoaWZ0KCkuY29tcGxldGUoKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoKyt0aGlzLmNvdW50ICUgc3RhcnRXaW5kb3dFdmVyeSA9PT0gMCAmJiAhdGhpcy5jbG9zZWQpIHtcbiAgICAgICAgICAgIHZhciB3aW5kb3dfMSA9IG5ldyBTdWJqZWN0XzEuU3ViamVjdCgpO1xuICAgICAgICAgICAgd2luZG93cy5wdXNoKHdpbmRvd18xKTtcbiAgICAgICAgICAgIGRlc3RpbmF0aW9uLm5leHQod2luZG93XzEpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBXaW5kb3dDb3VudFN1YnNjcmliZXIucHJvdG90eXBlLl9lcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgdmFyIHdpbmRvd3MgPSB0aGlzLndpbmRvd3M7XG4gICAgICAgIGlmICh3aW5kb3dzKSB7XG4gICAgICAgICAgICB3aGlsZSAod2luZG93cy5sZW5ndGggPiAwICYmICF0aGlzLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgIHdpbmRvd3Muc2hpZnQoKS5lcnJvcihlcnIpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHRoaXMuZGVzdGluYXRpb24uZXJyb3IoZXJyKTtcbiAgICB9O1xuICAgIFdpbmRvd0NvdW50U3Vic2NyaWJlci5wcm90b3R5cGUuX2NvbXBsZXRlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgd2luZG93cyA9IHRoaXMud2luZG93cztcbiAgICAgICAgaWYgKHdpbmRvd3MpIHtcbiAgICAgICAgICAgIHdoaWxlICh3aW5kb3dzLmxlbmd0aCA+IDAgJiYgIXRoaXMuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgd2luZG93cy5zaGlmdCgpLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5jb21wbGV0ZSgpO1xuICAgIH07X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+IDApIHtcbiAgICAgICAgICAgIHdpbmRvd3Muc2hpZnQoKS5lcnJvcihlcnIpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuZGVzdGluYXRpb24uZXJyb3IoZXJyKTtcbiAgICB9O1xuICAgIFdpbmRvd1RpbWVTdWJzY3JpYmVyLnByb3RvdHlwZS5fY29tcGxldGUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciB3aW5kb3dzID0gdGhpcy53aW5kb3dzO1xuICAgICAgICB3aGlsZSAod2luZG93cy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICB2YXIgd2luZG93XzQgPSB3aW5kb3dzLnNoaWZ0KCk7XG4gICAgICAgICAgICBpZiAoIXdpbmRvd180LmNsb3NlZCkge1xuICAgICAgICAgICAgICAgIHdpbmRvd180LmNvbXBsZXRlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5jb21wbGV0ZSgpO1xuICAgIH07XG4gICAgV2luZG93VGltZVN1YnNjcmliZXIucHJvdG90eXBlLm9wZW5XaW5kb3cgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciB3aW5kb3cgPSBuZXcgU3ViamVjdF8xLlN1YmplY3QoKTtcbiAgICAgICAgdGhpcy53aW5kb3dzLnB1c2god2luZG93KTtcbiAgICAgICAgdmFyIGRlc3RpbmF0aW9uID0gdGhpcy5kZXN0aW5hdGlvbjtcbiAgICAgICAgZGVzdGluYXRpb24ubmV4dCh3aW5kb3cpO1xuICAgICAgICByZXR1cm4gd2luZG93O1xuICAgIH07XG4gICAgV2luZG93VGltZVN1YnNjcmliZXIucHJvdG90eXBlLmNsb3NlV2luZG93ID0gZnVuY3Rpb24gKHdpbmRvdykge1xuICAgICAgICB3aW5kb3cuY29tcGxldGUoKTtcbiAgICAgICAgdmFyIHdpbmRvd3MgPSB0aGlzLndpbmRvd3M7XG4gICAgICAgIHdpbmRvd3Muc3BsaWNlKHdp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W5pbmdzLCBvcGVuaW5ncykpO1xuICAgIH1cbiAgICBXaW5kb3dUb2dnbGVTdWJzY3JpYmVyLnByb3RvdHlwZS5fbmV4dCA9IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICB2YXIgY29udGV4dHMgPSB0aGlzLmNvbnRleHRzO1xuICAgICAgICBpZiAoY29udGV4dHMpIHtcbiAgICAgICAgICAgIHZhciBsZW4gPSBjb250ZXh0cy5sZW5ndGg7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgY29udGV4dHNbaV0ud2luZG93Lm5leHQodmFsdWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbiAgICBXaW5kb3dUb2dnbGVTdWJzY3JpYmVyLnByb3RvdHlwZS5fZXJyb3IgPSBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgIHZhciBjb250ZXh0cyA9IHRoaXMuY29udGV4dHM7XG4gICAgICAgIHRoaXMuY29udGV4dHMgPSBudWxsO1xuICAgICAgICBpZiAoY29udGV4dHMpIHtcbiAgICAgICAgICAgIHZhciBsZW4gPSBjb250ZXh0cy5sZW5ndGg7XG4gICAgICAgICAgICB2YXIgaW5kZXggPSAtMTtcbiAgICAgICAgICAgIHdoaWxlICgrK2luZGV4IDwgbGVuKSB7XG4gICAgICAgICAgICAgICAgdmFyIGNvbnRleHQgPSBjb250ZXh0c1tpbmRleF07XG4gICAgICAgICAgICAgICAgY29udGV4dC53aW5kb3cuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICBjb250ZXh0LnN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIF9zdXBlci5wcm90b3R5cGUuX2Vycm9yLmNhbGwodGhpcywgZXJyKTtcbiAgICB9O1xuICAgIFdpbmRvd1RvZ2dsZVN1YnNjcmliZXIucHJvdG90eXBlLl9jb21wbGV0ZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdmFyIGNvbnRleHRzID0gdGhpcy5jb250ZXh0cztcbiAgICAgICAgdGhpcy5jb250ZXh0cyA9IG51bGw7XG4gICAgICAgIGlmIChjb250ZXh0cykge1xuICAgICAgICAgICAgdmFyIGxlbiA9IGNvbnRleHRzLmxlbmd0aDtcbiAgICAgICAgICAgIHZhciBpbmRleCA9IC0xO1xuICAgICAgICAgICAgd2hpbGUgKCsraW5kZXggPCBsZW4pIHtcbiAgICAgICAgICAgICAgICB2YXIgY29udGV4dCA9IGNvbnRleHRzW2luZGV4XTtcbiAgICAgICAgICAgICAgICBjb250ZXh0LndpbmRvdy5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIGNvbnRleHQuc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgX3N1cGVyLnByb3RvdHlwZS5fY29tcGxldGUuY2FsbCh0aGlzKTtcbiAgICB9O1xuICAgIFdpbmRvd1RvZ2dsZVN1YnNjcmliZXIucHJvdG90eXBlLl91bnN1YnNjcmliZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdmFyIGNvbnRleHRzID0gdGhpcy5jb250ZXh0cztcbiAgICAgICAgdGhpcy5jb250ZXh0cyA9IG51bGw7XG4gICAgICAgIGlmIChjb250ZXh0cykge1xuICAgICAgICAgICAgdmFyIGxlbiA9IGNvbnRleHRzLmxlbmd0aDtcbiAgICAgICAgICAgIHZhciBpbmRleCA9IC0xO1xuICAgICAgICAgICAgd2hpbGUgKCsraW5kZXggPCBsZW4pIHtcbiAgICAgICAgICAgICAgICB2YXIgY29udGV4dCA9IGNvbnRleHRzW2luZGV4XTtcbiAgICAgICAgICAgICAgICBjb250ZXh0LndpbmRvdy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIGNvbnRleHQuc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJ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yaWJlVG9SZXN1bHQodGhpcywgY2xvc2luZ05vdGlmaWVyLCBjb250ZXh0KTtcbiAgICAgICAgICAgICAgICBpZiAoaW5uZXJTdWJzY3JpcHRpb24uY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VXaW5kb3codGhpcy5jb250ZXh0cy5sZW5ndGggLSAxKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGlubmVyU3Vic2NyaXB0aW9uLmNvbnRleHQgPSBjb250ZXh0O1xuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24uYWRkKGlubmVyU3Vic2NyaXB0aW9uKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5uZXh0KHdpbmRvd18xKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuY2xvc2VXaW5kb3codGhpcy5jb250ZXh0cy5pbmRleE9mKG91dGVyVmFsdWUpKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgV2luZG93VG9nZ2xlU3Vic2NyaWJlci5wcm90b3R5cGUubm90aWZ5RXJyb3IgPSBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgIHRoaXMuZXJyb3IoZXJyKTtcbiAgICB9O1xuICAgIFdpbmRvd1RvZ2dsZVN1YnNjcmliZXIucHJvdG90eXBlLm5vdGlmeUNvbXBsZXRlID0gZnVuY3Rpb24gKGlubmVyKSB7XG4gICAgICAgIGlmIChpbm5lciAhPT0gdGhpcy5vcGVuU3Vic2NyaXB0aW9uKSB7XG4gICAgICAgICAgICB0aGlzLmNsb3NlV2luZG93KHRoaXMuY29udGV4dHMuaW5kZXhPZihpbm5lci5jb250ZXh0KSk7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFdpbmRvd1RvZ2dsZVN1YnNjc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V0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgYXJncy5wdXNoKHJlc3VsdC52YWx1ZSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMucHJvamVjdCkge1xuICAgICAgICAgICAgdGhpcy5fdHJ5UHJvamVjdChhcmdzKTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGRlc3RpbmF0aW9uLm5leHQoYXJncyk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHNob3VsZENvbXBsZXRlKSB7XG4gICAgICAgICAgICBkZXN0aW5hdGlvbi5jb21wbGV0ZSgpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBaaXBTdWJzY3JpYmVyLnByb3RvdHlwZS5fdHJ5UHJvamVjdCA9IGZ1bmN0aW9uIChhcmdzKSB7XG4gICAgICAgIHZhciByZXN1bHQ7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICByZXN1bHQgPSB0aGlzLnByb2plY3QuYXBwbHkodGhpcywgYXJncyk7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5lcnJvcihlcnIpO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuZGVzdGluYXRpb24ubmV4dChyZXN1bHQpO1xuICAgIH07XG4gICAgcmV0dXJuIFppcFN1YnNjcmliZXI7XG59KFN1YnNjcmliZXJfMS5TdWJzY3JpYmVyKSk7XG5leHBvcnRzLlppcFN1YnNjcmliZXIgPSBaaXBTdWJzY3JpYmVyO1xudmFyIFN0YXRpY0l0ZXJhdG9yID0gKGZ1bmN0aW9uICgpIHtcbiAgICBmdW5jdGlvbiBTdGF0aWNJdGVyYXRvcihpdGVyYXRvcikge1xuICAgICAgICB0aGlzLml0ZXJhdG9yID0gaXRlcmF0b3I7XG4gICAgICAgIHRoaXMubmV4dFJlc3VsdCA9IGl0ZXJh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m9yVmFsdWUgPSB1bmRlZmluZWQ7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICB0aGlzLndvcmsoc3RhdGUpO1xuICAgICAgICB9XG4gICAgICAgIGNhdGNoIChlKSB7XG4gICAgICAgICAgICBlcnJvcmVkID0gdHJ1ZTtcbiAgICAgICAgICAgIGVycm9yVmFsdWUgPSAhIWUgJiYgZSB8fCBuZXcgRXJyb3IoZSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGVycm9yZWQpIHtcbiAgICAgICAgICAgIHRoaXMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgIHJldHVybiBlcnJvclZhbHVlO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBBc3luY0FjdGlvbi5wcm90b3R5cGUuX3Vuc3Vic2NyaWJlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgaWQgPSB0aGlzLmlkO1xuICAgICAgICB2YXIgc2NoZWR1bGVyID0gdGhpcy5zY2hlZHVsZXI7XG4gICAgICAgIHZhciBhY3Rpb25zID0gc2NoZWR1bGVyLmFjdGlvbnM7XG4gICAgICAgIHZhciBpbmRleCA9IGFjdGlvbnMuaW5kZXhPZih0aGlzKTtcbiAgICAgICAgdGhpcy53b3JrID0gbnVsbDtcbiAgICAgICAgdGhpcy5kZWxheSA9IG51bGw7XG4gICAgICAgIHRoaXMuc3RhdGUgPSBudWxsO1xuICAgICAgICB0aGlzLnBlbmRpbmcgPSBmYWxzZTtcbiAgICAgICAgdGhpcy5zY2hlZHVsZXIgPSBudWxsO1xuICAgICAgICBpZiAoaW5kZXggIT09IC0xKSB7XG4gICAgICAgICAgICBhY3Rpb25zLnNwbGljZShpbmRleCwgMSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGlkICE9IG51bGwpIHtcbiAgICAgICAgICAgIHRoaXMuaWQgPSB0aGlzLnJlY3ljbGVBc3luY0lkKHNjaGVkdWxlciwgaWQsIG51bGwpO1xuICAgICAgICB9XG4gICAgfTtcb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LmV4cGVjdGVkKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgVGVzdFNjaGVkdWxlci5wYXJzZU1hcmJsZXNBc1N1YnNjcmlwdGlvbnMgPSBmdW5jdGlvbiAobWFyYmxlcykge1xuICAgICAgICBpZiAodHlwZW9mIG1hcmJsZXMgIT09ICdzdHJpbmcnKSB7XG4gICAgICAgICAgICByZXR1cm4gbmV3IFN1YnNjcmlwdGlvbkxvZ18xLlN1YnNjcmlwdGlvbkxvZyhOdW1iZXIuUE9TSVRJVkVfSU5GSU5JVFkpO1xuICAgICAgICB9XG4gICAgICAgIHZhciBsZW4gPSBtYXJibGVzLmxlbmd0aDtcbiAgICAgICAgdmFyIGdyb3VwU3RhcnQgPSAtMTtcbiAgICAgICAgdmFyIHN1YnNjcmlwdGlvbkZyYW1lID0gTnVtYmVyLlBPU0lUSVZFX0lORklOSVRZO1xuICAgICAgICB2YXIgdW5zdWJzY3JpcHRpb25GcmFtZSA9IE51bWJlci5QT1NJVElWRV9JTkZJTklUWTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgICAgdmFyIGZyYW1lID0gaSAqIHRoaXMuZnJhbWVUaW1lRmFjdG9yO1xuICAgICAgICAgICAgdmFyIGMgPSBtYXJibGVzW2ldO1xuICAgICAgICAgICAgc3dpdGNoIChjKSB7XG4gICAgICAgICAgICAgICAgY2FzZSAnLSc6XG4gICAgICAgICAgICAgICAgY2FzZSAnICc6XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgJygnOlxuICAgICAgICAgICAgICAgICAgICBncm91cFN0YXJ0ID0gZnJhbWU7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgJyknOlxuICAgICAgICAgICAgICAgICAgICBncm91cFN0YXJ0ID0gLTE7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgJ14nOlxuICAgICAgICAgICAgICAgICAgICBpZiAoc3Vic2NyaXB0aW9uRnJhbWUgIT09IE51bWJlci5QT1NJVElWRV9JTkZJTklUWSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdmb3VuZCBhIHNlY29uZCBzdWJzY3JpcHRpb24gcG9pbnQgXFwnXlxcJyBpbiBhICcgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdzdWJzY3JpcHRpb24gbWFyYmxlIGRpYWdyYW0uIFRoZXJlIGNhbiBvbmx5IGJlIG9uZS4nKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb25GcmFtZSA9IGdyb3VwU3RhcnQgPiAtMSA/IGdyb3VwU3RhcnQgOiBmcmFtZTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgY2FzZSAnISc6XG4gICAgICAgICAgICAgICAgICAgIGlmICh1bnN1YnNjcmlwdGlvbkZyYW1lICE9PSBOdW1iZXIuUE9TSVRJVkVfSU5GSU5JVFkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignZm91bmQgYSBzZWNvbmQgc3Vic2NyaXB0aW9uIHBvaW50IFxcJ15cXCcgaW4gYSAnICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnc3Vic2NyaXB0aW9uIG1hcmJsZSBkaWFncmFtLiBUaGVyZSBjYW4gb25seSBiZSBvbmUuJyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgdW5zdWJzY3JpcHRpb25GcmFtZSA9IGdyb3VwU3RhcnQgPiAtMSA/IGdyb3VwU3RhcnQgOiBmcmFtZTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAgICAgdGhyb3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yIGxlbiA9IG1hcmJsZXMubGVuZ3RoO1xuICAgICAgICB2YXIgdGVzdE1lc3NhZ2VzID0gW107XG4gICAgICAgIHZhciBzdWJJbmRleCA9IG1hcmJsZXMuaW5kZXhPZignXicpO1xuICAgICAgICB2YXIgZnJhbWVPZmZzZXQgPSBzdWJJbmRleCA9PT0gLTEgPyAwIDogKHN1YkluZGV4ICogLXRoaXMuZnJhbWVUaW1lRmFjdG9yKTtcbiAgICAgICAgdmFyIGdldFZhbHVlID0gdHlwZW9mIHZhbHVlcyAhPT0gJ29iamVjdCcgP1xuICAgICAgICAgICAgZnVuY3Rpb24gKHgpIHsgcmV0dXJuIHg7IH0gOlxuICAgICAgICAgICAgZnVuY3Rpb24gKHgpIHtcbiAgICAgICAgICAgICAgICAvLyBTdXBwb3J0IE9ic2VydmFibGUtb2YtT2JzZXJ2YWJsZXNcbiAgICAgICAgICAgICAgICBpZiAobWF0ZXJpYWxpemVJbm5lck9ic2VydmFibGVzICYmIHZhbHVlc1t4XSBpbnN0YW5jZW9mIENvbGRPYnNlcnZhYmxlXzEuQ29sZE9ic2VydmFibGUpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlc1t4XS5tZXNzYWdlcztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlc1t4XTtcbiAgICAgICAgICAgIH07XG4gICAgICAgIHZhciBncm91cFN0YXJ0ID0gLTE7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbGVuOyBpKyspIHtcbiAgICAgICAgICAgIHZhciBmcmFtZSA9IGkgKiB0aGlzLmZyYW1lVGltZUZhY3RvciArIGZyYW1lT2Zmc2V0O1xuICAgICAgICAgICAgdmFyIG5vdGlmaWNhdGlvbiA9IHZvaWQgMDtcbiAgICAgICAgICAgIHZhciBjID0gbWFyYmxlc1tpXTtcbiAgICAgICAgICAgIHN3aXRjaCAoYykge1xuICAgICAgICAgICAgICAgIGNhc2UgJy0nOlxuICAgICAgICAgICAgICAgIGNhc2UgJyAnOlxuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICcoJzpcbiAgICAgICAgICAgICAgICAgICAgZ3JvdXBTdGFydCA9IGZyYW1lO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICcpJzpcbiAgICAgICAgICAgICAgICAgICAgZ3JvdXBTdGFydCA9IC0xO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICd8JzpcbiAgICAgICAgICAgICAgICAgICAgbm90aWZpY2F0aW9uID0gTm90aWZpY2F0aW9uXzEuTm90aWZpY2F0aW9uLmNyZWF0ZUNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgJ14nOlxuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICcjJzpcbiAgICAgICAgICAgICAgICAgICAgbm90aWZpY2F0aW9uID0gTm90aWZpY2F0aW9uXzEuTm90aWZpY2F0aW9uLmNyZWF0ZUVycm9yKGVycm9yVmFsdWUgfHwgJ2Vycm9yJyk7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgICAgIG5vdGlmaWNhdGlvbiA9IE5vdGlmaWNhdGlvbl8xLk5vdGlmaWNhdGlvbi5jcmVhdGVOZXh0KGdldFZhbHVlKGMpKTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAobm90aWZpY2F0aW9uKSB7XG4gICAgICAgICAgICAgICAgdGVzdE1lc3NhZ2VzLnB1c2goeyBmcmFtZTogZ3JvdXBTdGFydCA+IC0xID8gZ3JvdXBTdGFydCA6IGZyYW1lLCBub3RpZmljYXRpb246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W1lXzFdID0gYmFzZUN0b3IucHJvdG90eXBlW25hbWVfMV07XG4gICAgICAgIH1cbiAgICB9XG59XG5leHBvcnRzLmFwcGx5TWl4aW5zID0gYXBwbHlNaXhpbnM7XG4vLyMgc291cmNlTWFwcGluZ1VSTD1hcHBseU1peGlucy5qcy5tYXAiLCJcInVzZSBzdHJpY3RcIjtcbnZhciByb290XzEgPSByZXF1aXJlKCcuL3Jvb3QnKTtcbnZhciBPYmplY3QgPSByb290XzEucm9vdC5PYmplY3Q7XG5pZiAodHlwZW9mIE9iamVjdC5hc3NpZ24gIT0gJ2Z1bmN0aW9uJykge1xuICAgIChmdW5jdGlvbiAoKSB7XG4gICAgICAgIE9iamVjdC5hc3NpZ24gPSBmdW5jdGlvbiBhc3NpZ25Qb2x5ZmlsbCh0YXJnZXQpIHtcbiAgICAgICAgICAgIHZhciBzb3VyY2VzID0gW107XG4gICAgICAgICAgICBmb3IgKHZhciBfaSA9IDE7IF9pIDwgYXJndW1lbnRzLmxlbmd0aDsgX2krKykge1xuICAgICAgICAgICAgICAgIHNvdXJjZXNbX2kgLSAxXSA9IGFyZ3VtZW50c1tfaV07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGFyZ2V0ID09PSB1bmRlZmluZWQgfHwgdGFyZ2V0ID09PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcignY2Fubm90IGNvbnZlcnQgdW5kZWZpbmVkIG9yIG51bGwgdG8gb2JqZWN0Jyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgb3V0cHV0ID0gT2JqZWN0KHRhcmdldCk7XG4gICAgICAgICAgICB2YXIgbGVuID0gc291cmNlcy5sZW5ndGg7XG4gICAgICAgICAgICBmb3IgKHZhciBpbmRleCA9IDA7IGluZGV4IDwgbGVuOyBpbmRleCsrKSB7XG4gICAgICAgICAgICAgICAgdmFyIHNvdXJjZSA9IHNvdXJjZXNbaW5kZXhdO1xuICAg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nVuY3Rpb24gUmVzdWx0cyAoKSB7XG4gICAgaWYgKCEodGhpcyBpbnN0YW5jZW9mIFJlc3VsdHMpKSByZXR1cm4gbmV3IFJlc3VsdHM7XG4gICAgdGhpcy5jb3VudCA9IDA7XG4gICAgdGhpcy5mYWlsID0gMDtcbiAgICB0aGlzLnBhc3MgPSAwO1xuICAgIHRoaXMuX3N0cmVhbSA9IHRocm91Z2goKTtcbiAgICB0aGlzLnRlc3RzID0gW107XG4gICAgdGhpcy5fb25seSA9IG51bGw7XG59XG5cblJlc3VsdHMucHJvdG90eXBlLmNyZWF0ZVN0cmVhbSA9IGZ1bmN0aW9uIChvcHRzKSB7XG4gICAgaWYgKCFvcHRzKSBvcHRzID0ge307XG4gICAgdmFyIHNlbGYgPSB0aGlzO1xuICAgIHZhciBvdXRwdXQsIHRlc3RJZCA9IDA7XG4gICAgaWYgKG9wdHMub2JqZWN0TW9kZSkge1xuICAgICAgICBvdXRwdXQgPSB0aHJvdWdoKCk7XG4gICAgICAgIHNlbGYub24oJ19wdXNoJywgZnVuY3Rpb24gb250ZXN0ICh0LCBleHRyYSkge1xuICAgICAgICAgICAgaWYgKCFleHRyYSkgZXh0cmEgPSB7fTtcbiAgICAgICAgICAgIHZhciBpZCA9IHRlc3RJZCsrO1xuICAgICAgICAgICAgdC5vbmNlKCdwcmVydW4nLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJvdyA9IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogJ3Rlc3QnLFxuICAgICAgICAgICAgICAgICAgICBuYW1lOiB0Lm5hbWUsXG4gICAgICAgICAgICAgICAgICAgIGlkOiBpZFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgaWYgKGhhcyhleHRyYSwgJ3BhcmVudCcpKSB7XG4gICAgICAgICAgICAgICAgICAgIHJvdy5wYXJlbnQgPSBleHRyYS5wYXJlbnQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICA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1xcbic7XG4gICAgaWYgKHJlcy5vaykgcmV0dXJuIG91dHB1dDtcbiAgICBcbiAgICB2YXIgb3V0ZXIgPSAnICAnO1xuICAgIHZhciBpbm5lciA9IG91dGVyICsgJyAgJztcbiAgICBvdXRwdXQgKz0gb3V0ZXIgKyAnLS0tXFxuJztcbiAgICBvdXRwdXQgKz0gaW5uZXIgKyAnb3BlcmF0b3I6ICcgKyByZXMub3BlcmF0b3IgKyAnXFxuJztcbiAgICBcbiAgICBpZiAoaGFzKHJlcywgJ2V4cGVjdGVkJykgfHwgaGFzKHJlcywgJ2FjdHVhbCcpKSB7XG4gICAgICAgIHZhciBleCA9IGluc3BlY3QocmVzLmV4cGVjdGVkLCB7ZGVwdGg6IHJlcy5vYmplY3RQcmludERlcHRofSk7XG4gICAgICAgIHZhciBhYyA9IGluc3BlY3QocmVzLmFjdHVhbCwge2RlcHRoOiByZXMub2JqZWN0UHJpbnREZXB0aH0pO1xuICAgICAgICBcbiAgICAgICAgaWYgKE1hdGgubWF4KGV4Lmxlbmd0aCwgYWMubGVuZ3RoKSA+IDY1IHx8IGludmFsaWRZYW1sKGV4KSB8fCBpbnZhbGlkWWFtbChhYykpIHtcbiAgICAgICAgICAgIG91dHB1dCArPSBpbm5lciArICdleHBlY3RlZDogfC1cXG4nICsgaW5uZXIgKyAnICAnICsgZXggKyAnXFxuJztcbiAgICAgICAgICAgIG91dHB1dCArPSBpbm5lciArICdhY3R1YWw6IHwtXFxuJyArIGlubmVyICsgJyAgJyArIGFjICsgJ1xcbic7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBvdXRwdXQgKz0gaW5uZXIgKyAnZXhwZWN0ZWQ6ICcgKyBleCArICdcXG4nO1xuICAgICAgICAgICAgb3V0cHV0ICs9IGlubmVyICsgJ2FjdHVhbDogICAnICsgYWMgKyAnXFxuJztcbiAgICAgICAgfVxuICAgIH1cbiAgICBpZiAocmVzLmF0KSB7XG4gICAgICAgIG91dHB1dCArPSBpbm5lciAr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ID0gQm9vbGVhbih0aGlzLl9vayAmJiBvayk7XG4gICAgXG4gICAgaWYgKCFvaykge1xuICAgICAgICByZXMuZXJyb3IgPSBkZWZpbmVkKGV4dHJhLmVycm9yLCBvcHRzLmVycm9yLCBuZXcgRXJyb3IocmVzLm5hbWUpKTtcbiAgICB9XG4gICAgXG4gICAgaWYgKCFvaykge1xuICAgICAgICB2YXIgZSA9IG5ldyBFcnJvcignZXhjZXB0aW9uJyk7XG4gICAgICAgIHZhciBlcnIgPSAoZS5zdGFjayB8fCAnJykuc3BsaXQoJ1xcbicpO1xuICAgICAgICB2YXIgZGlyID0gcGF0aC5kaXJuYW1lKF9fZGlybmFtZSkgKyBwYXRoLnNlcDtcbiAgICAgICAgXG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgZXJyLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICB2YXIgbSA9IC9eW15cXHNdKlxccypcXGJhdFxccysoLispLy5leGVjKGVycltpXSk7XG4gICAgICAgICAgICBpZiAoIW0pIHtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIFxuICAgICAgICAgICAgdmFyIHMgPSBtWzFdLnNwbGl0KC9cXHMrLyk7XG4gICAgICAgICAgICB2YXIgZmlsZW0gPSAvKCg/OlxcL3xbQS1aXTpcXFxcKVteOlxcc10rOihcXGQrKSg/OjooXFxkKykpPykvLmV4ZWMoc1sxXSk7XG4gICAgICAgICAgICBpZiAoIWZpbGVtKSB7XG4gICAgICAgICAgICAgICAgZmlsZW0gPSAvKCg/OlxcL3xbQS1aXTpcXFxcKVteOlxcc10rOihcXGQrKSg/OjooXFxkKykpPykvLmV4ZWMoc1syXSk7XG4gICAgICAgICAgICAgICAgXG4gICAgICAgICAgICAgICAgaWYgKCFmaWxlbSkge1xuICAgICAgICAgICAgICAgICAgICBmaWxlbSA9IC8oKD86XFwvfFtBLVpdOlxcXFwpW146XFxzXSs6KFxcZCspKD86OihcXGQrKSk/KS8uZXhlYyhzWzNdKTtcblxuICAgICAgICAgICAgICAgICAgICBpZiAoIWZpbGVtKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIFxuICAgICAgICAgICAgaWYgKGZpbGVtWzFdLnNsaWNlKDAsIGRpci5sZW5ndGgpID09PSBkaXIpIHtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIFxuICAgICAgICAgICAgcmVzLmZ1bmN0aW9uTmFtZSA9IHNbMF07XG4gICAgICAgICAgICByZXMuZmlsZSA9IGZpbGVtWzFdO1xuICAgICAgICAgICAgcmVzLmxpbmUgPSBOdW1iZXIoZmlsZW1bMl0pO1xuICAgICAgICAgICAgaWYgKGZpbGVtWzNdKSByZXMuY29sdW1uID0gZmlsZW1bM107XG4gICAgICAgICAgICBcbiAgICAgICAgICAgIHJlcy5hdCA9IG1bMV07XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNlbGYuZW1pdCgncmVzdWx0JywgcmVzKTtcbiAgICBcbiAgICB2YXIgcGVuZGluZ0Fzc2VydHMgPSBzZWxmLl9wZW5kaW5nQXNzZXJ0cygpO1xuICAgIGlmICghcGVuZGluZ0Fzc2VydHMpIHtcbiAgICAgICAgaWYgKGV4dHJhLmV4aXRpbmcpIHtcbiAgICAgICAgICAgIHNlbGYuX2VuZCgpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbmV4dFRpY2soZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIHNlbGYuX2VuZCgpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgXG4gICAgaWYgKCFzZWxmLl9wbGFuRXJyb3IgJiYgcGVuZGluZ0Fzc2VydHMgPCA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yIGlzX3JlYWRlciwgY2FuY2VsbGF0aW9uUmVxdWVzdCA9IGZhbHNlO1xuICByZXR1cm4gbmV3IFJlYWRhYmxlU3RyZWFtKHtcbiAgICBzdGFydDogZnVuY3Rpb24oY29udHJvbGxlcikge1xuICAgICAgdmFyIHJlYWRlciA9IHJlc3BvbnNlLmdldFJlYWRlcigpO1xuICAgICAgaXNfcmVhZGVyID0gcmVhZGVyO1xuICAgICAgdmFyIGRlY29kZXIgPSBuZXcgVGV4dERlY29kZXIoKTtcbiAgICAgIHZhciBkYXRhX2J1ZiA9IFwiXCI7XG5cbiAgICAgIHJlYWRlci5yZWFkKCkudGhlbihmdW5jdGlvbiBwcm9jZXNzUmVzdWx0KHJlc3VsdCkge1xuICAgICAgICBpZiAocmVzdWx0LmRvbmUpIHtcbiAgICAgICAgICBpZiAoY2FuY2VsbGF0aW9uUmVxdWVzdCkge1xuICAgICAgICAgICAgLy8gSW1tZWRpYXRlbHkgZXhpdFxuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgIH1cblxuICAgICAgICAgIGRhdGFfYnVmID0gZGF0YV9idWYudHJpbSgpO1xuICAgICAgICAgIGlmIChkYXRhX2J1Zi5sZW5ndGggIT09IDApIHtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgIHZhciBkYXRhX2wgPSBKU09OLnBhcnNlKGRhdGFfYnVmKTtcbiAgICAgICAgICAgICAgY29udHJvbGxlci5lbnF1ZXVlKGRhdGFfbCk7XG4gICAgICAgICAgICB9IGNhdGNoKGUpIHtcbiAgICAgICAgICAgICAgY29udHJvbGxlci5lcnJvcihlKTtcbiAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250cm9sbGVyLmNsb3NlKCk7XG4gICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIGRhdGEgPSBkZWNvZGVyLmRlY29kZShyZXN1bHQudmFsdWUsIHtzdHJlYW06IHRydWV9KTtcbiAgICAgICAgZGF0YV9idWYgKz0gZGF0YTtcbiAgICAgICAgdmFyIGxpbmVzID0gZGF0YV9idWYuc3BsaXQoXCJcXG5cIik7XG4gICAgICAgIGZvcih2YXIgaSA9IDA7IGkgPCBsaW5lcy5sZW5ndGggLSAxOyArK2kpIHtcbiAgICAgICAgICB2YXIgbCA9IGxpbmVzW2ldLnRyaW0oKTtcbiAgICAgICAgICBpZiAobC5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICB2YXIgZGF0YV9saW5lID0gSlNPTi5wYXJzZShsKTtcbiAgICAgICAgICAgICAgY29udHJvbGxlci5lbnF1ZXVlKGRhdGFfbGluZSk7XG4gICAgICAgICAgICB9IGNhdGNoKGUpIHtcbiAgICAgICAgICAgICAgY29udHJvbGxlci5lcnJvcihlKTtcbiAgICAgICAgICAgICAgY2FuY2VsbGF0aW9uUmVxdWVzdCA9IHRydWU7XG4gICAgICAgICAgICAgIHJlYWRlci5jYW5jZWwoKTtcbiAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBkYXRhX2J1ZiA9IGxpbmVzW2xpbmVzLmxlbmd0aC0xXTtcblxuICAgICAgICByZXR1cm4gcmVhZGVyLnJlYWQoKS50aGVuKHByb2Nlc3NSZXN1bHQpO1xuICAgICAgfSk7XG5cbiAgICB9LFxuICAgIGNhbmNlbDogZnVuY3Rpb24ocmVhc29uKSB7XG4gICAgICBjb25zb2xlLmxvZyhcIkNhbmNlbCByZWdpc3RlcmVkIGR1ZSB0byBcIiwgcmVhc29uKTtcbiAgICAgIGNhbmNlbGxhdGlvblJlcXVlc3QgPSB0cnVlO1xuICAgICAgaXNfcmVhZGVyLmNhbmNlbCgpO1xuICAgIH1cbiAgfSk7XG59O1xuXG5tb2R1bGUuZXhwb3J0cyA9IG5hbWVzcGFjZS5uZGpzb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Roc1tpbmRleF0pO1xuICAgICAgfVxuICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBUaGUgYmFzZSBpbXBsZW1lbnRhdGlvbiBvZiBgXy5jbGFtcGAgd2hpY2ggZG9lc24ndCBjb2VyY2UgYXJndW1lbnRzLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge251bWJlcn0gbnVtYmVyIFRoZSBudW1iZXIgdG8gY2xhbXAuXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IFtsb3dlcl0gVGhlIGxvd2VyIGJvdW5kLlxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSB1cHBlciBUaGUgdXBwZXIgYm91bmQuXG4gICAgICogQHJldHVybnMge251bWJlcn0gUmV0dXJucyB0aGUgY2xhbXBlZCBudW1iZXIuXG4gICAgICovXG4gICAgZnVuY3Rpb24gYmFzZUNsYW1wKG51bWJlciwgbG93ZXIsIHVwcGVyKSB7XG4gICAgICBpZiAobnVtYmVyID09PSBudW1iZXIpIHtcbiAgICAgICAgaWYgKHVwcGVyICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICBudW1iZXIgPSBudW1iZXIgPD0gdXBwZXIgPyBudW1iZXIgOiB1cHBlcjtcbiAgICAgICAgfVxuICAgICAgICBpZiAobG93ZXIgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgIG51bWJlciA9IG51bWJlciA+PSBsb3dlciA/IG51bWJlciA6IGxvd2VyO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gbnVtYmVyO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoZSBiYXNlIGltcGxlbWVudGF0aW9uIG9mIGBfLmNsb25lYCBhbmQgYF8uY2xvbmVEZWVwYCB3aGljaCB0cmFja3NcbiAgICAgKiB0cmF2ZXJzZWQgb2JqZWN0cy5cbiAgICAgKlxuICAgICAqIEBwcml2YXRlXG4gICAgICogQHBhc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FjaGVIYXMoc2VlbiwgY29tcHV0ZWQpXG4gICAgICAgICAgICAgIDogaW5jbHVkZXMocmVzdWx0LCBjb21wdXRlZCwgY29tcGFyYXRvcilcbiAgICAgICAgICAgICkpIHtcbiAgICAgICAgICBvdGhJbmRleCA9IG90aExlbmd0aDtcbiAgICAgICAgICB3aGlsZSAoLS1vdGhJbmRleCkge1xuICAgICAgICAgICAgdmFyIGNhY2hlID0gY2FjaGVzW290aEluZGV4XTtcbiAgICAgICAgICAgIGlmICghKGNhY2hlXG4gICAgICAgICAgICAgICAgICA/IGNhY2hlSGFzKGNhY2hlLCBjb21wdXRlZClcbiAgICAgICAgICAgICAgICAgIDogaW5jbHVkZXMoYXJyYXlzW290aEluZGV4XSwgY29tcHV0ZWQsIGNvbXBhcmF0b3IpKVxuICAgICAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICBjb250aW51ZSBvdXRlcjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHNlZW4pIHtcbiAgICAgICAgICAgIHNlZW4ucHVzaChjb21wdXRlZCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHJlc3VsdC5wdXNoKHZhbHVlKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBUaGUgYmFzZSBpbXBsZW1lbnRhdGlvbiBvZiBgXy5pbnZlcnRgIGFuZCBgXy5pbnZlcnRCeWAgd2hpY2ggaW52ZXJ0c1xuICAgICAqIGBvYmplY3RgIHdpdGggdmFsdWVzIHRyYW5zZm9ybWVkIGJ5IGBpdGVyYXRlZWAgYW5kIHNldCBieSBgc2V0dGVyYC5cbiAgICAgKlxuICAgICAqIEBwcml2YXRlXG4gICAgICogQHBhcmFtIHtPYmplY3R9IG9iamVjdCBUaGUgb2JqZWN0IHRvIGl0ZXJhdGUgb3Zlci5cbiAgICAgKiBAcGFyYW0ge0Z1bmN0aW9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hbEZ1bmMsIHN0YWNrKSB7XG4gICAgICB2YXIgb2JqSXNBcnIgPSBpc0FycmF5KG9iamVjdCksXG4gICAgICAgICAgb3RoSXNBcnIgPSBpc0FycmF5KG90aGVyKSxcbiAgICAgICAgICBvYmpUYWcgPSBvYmpJc0FyciA/IGFycmF5VGFnIDogZ2V0VGFnKG9iamVjdCksXG4gICAgICAgICAgb3RoVGFnID0gb3RoSXNBcnIgPyBhcnJheVRhZyA6IGdldFRhZyhvdGhlcik7XG5cbiAgICAgIG9ialRhZyA9IG9ialRhZyA9PSBhcmdzVGFnID8gb2JqZWN0VGFnIDogb2JqVGFnO1xuICAgICAgb3RoVGFnID0gb3RoVGFnID09IGFyZ3NUYWcgPyBvYmplY3RUYWcgOiBvdGhUYWc7XG5cbiAgICAgIHZhciBvYmpJc09iaiA9IG9ialRhZyA9PSBvYmplY3RUYWcsXG4gICAgICAgICAgb3RoSXNPYmogPSBvdGhUYWcgPT0gb2JqZWN0VGFnLFxuICAgICAgICAgIGlzU2FtZVRhZyA9IG9ialRhZyA9PSBvdGhUYWc7XG5cbiAgICAgIGlmIChpc1NhbWVUYWcgJiYgaXNCdWZmZXIob2JqZWN0KSkge1xuICAgICAgICBpZiAoIWlzQnVmZmVyKG90aGVyKSkge1xuICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBvYmpJc0FyciA9IHRydWU7XG4gICAgICAgIG9iaklzT2JqID0gZmFsc2U7XG4gICAgICB9XG4gICAgICBpZiAoaXNTYW1lVGFnICYmICFvYmpJc09iaikge1xuICAgICAgICBzdGFjayB8fCAoc3RhY2sgPSBuZXcgU3RhY2spO1xuICAgICAgICByZXR1cm4gKG9iaklzQXJyIHx8IGlzVHlwZWRBcnJheShvYmplY3QpKVxuICAgICAgICAgID8gZXF1YWxBcnJheXMob2JqZWN0LCBvdGhlciwgYml0bWFzaywgY3VzdG9taXplciwgZXF1YWxGdW5jLCBzdGFjaylcbiAgICAgICAgICA6IGVx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cbiAgICAgKi9cbiAgICBmdW5jdGlvbiBiYXNlSXNNYXRjaChvYmplY3QsIHNvdXJjZSwgbWF0Y2hEYXRhLCBjdXN0b21pemVyKSB7XG4gICAgICB2YXIgaW5kZXggPSBtYXRjaERhdGEubGVuZ3RoLFxuICAgICAgICAgIGxlbmd0aCA9IGluZGV4LFxuICAgICAgICAgIG5vQ3VzdG9taXplciA9ICFjdXN0b21pemVyO1xuXG4gICAgICBpZiAob2JqZWN0ID09IG51bGwpIHtcbiAgICAgICAgcmV0dXJuICFsZW5ndGg7XG4gICAgICB9XG4gICAgICBvYmplY3QgPSBPYmplY3Qob2JqZWN0KTtcbiAgICAgIHdoaWxlIChpbmRleC0tKSB7XG4gICAgICAgIHZhciBkYXRhID0gbWF0Y2hEYXRhW2luZGV4XTtcbiAgICAgICAgaWYgKChub0N1c3RvbWl6ZXIgJiYgZGF0YVsyXSlcbiAgICAgICAgICAgICAgPyBkYXRhWzFdICE9PSBvYmplY3RbZGF0YVswXV1cbiAgICAgICAgICAgICAgOiAhKGRhdGFbMF0gaW4gb2JqZWN0KVxuICAgICAgICAgICAgKSB7XG4gICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICB3aGlsZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICBkYXRhID0gbWF0Y2hEYXRhW2luZGV4XTtcbiAgICAgICAgdmFyIGtleSA9IGRhdGFbMF0sXG4gICAgICAgICAgICBvYmpWYWx1ZSA9IG9iamVjdFtrZXldLFxuICAgICAgICAgICAgc3JjVmFsdWUgPSBkYXRhWzFdO1xuXG4gICAgICAgIGlmIChub0N1c3RvbWl6ZXIgJiYgZGF0YVsyXSkge1xuICAgICAgICAgIGlmIChvYmpWYWx1ZSA9PT0gdW5kZWZpbmVkICYmICEoa2V5IGluIG9iamVjdCkpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7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ICAgICByZXN1bHQgPSB0cnVlLFxuICAgICAgICAgIHNlZW4gPSAoYml0bWFzayAmIENPTVBBUkVfVU5PUkRFUkVEX0ZMQUcpID8gbmV3IFNldENhY2hlIDogdW5kZWZpbmVkO1xuXG4gICAgICBzdGFjay5zZXQoYXJyYXksIG90aGVyKTtcbiAgICAgIHN0YWNrLnNldChvdGhlciwgYXJyYXkpO1xuXG4gICAgICAvLyBJZ25vcmUgbm9uLWluZGV4IHByb3BlcnRpZXMuXG4gICAgICB3aGlsZSAoKytpbmRleCA8IGFyckxlbmd0aCkge1xuICAgICAgICB2YXIgYXJyVmFsdWUgPSBhcnJheVtpbmRleF0sXG4gICAgICAgICAgICBvdGhWYWx1ZSA9IG90aGVyW2luZGV4XTtcblxuICAgICAgICBpZiAoY3VzdG9taXplcikge1xuICAgICAgICAgIHZhciBjb21wYXJlZCA9IGlzUGFydGlhbFxuICAgICAgICAgICAgPyBjdXN0b21pemVyKG90aFZhbHVlLCBhcnJWYWx1ZSwgaW5kZXgsIG90aGVyLCBhcnJheSwgc3RhY2spXG4gICAgICAgICAgICA6IGN1c3RvbWl6ZXIoYXJyVmFsdWUsIG90aFZhbHVlLCBpbmRleCwgYXJyYXksIG90aGVyLCBzdGFjayk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGNvbXBhcmVkICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICBpZiAoY29tcGFyZWQpIHtcbiAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgIH1cbiAgICAgICAgICByZXN1bHQgPSBmYWxzZTtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICAvLyBSZWN1cnNpdmVseSBjb21wYXJlIGFycmF5cyAoc3VzY2VwdGlibGUgdG8gY2FsbCBzdGFjayBsaW1pdHMpLlxuICAgICAgICBpZiAoc2Vlbikge1xuICAgICAgICAgIGlmICghYXJyYXlTb21lKG90aGVyLCBmdW5jdGlvbihvdGhWYWx1ZSwgb3RoSW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cpIHtcbiAgICAgICAgY2FzZSBkYXRhVmlld1RhZzpcbiAgICAgICAgICBpZiAoKG9iamVjdC5ieXRlTGVuZ3RoICE9IG90aGVyLmJ5dGVMZW5ndGgpIHx8XG4gICAgICAgICAgICAgIChvYmplY3QuYnl0ZU9mZnNldCAhPSBvdGhlci5ieXRlT2Zmc2V0KSkge1xuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgIH1cbiAgICAgICAgICBvYmplY3QgPSBvYmplY3QuYnVmZmVyO1xuICAgICAgICAgIG90aGVyID0gb3RoZXIuYnVmZmVyO1xuXG4gICAgICAgIGNhc2UgYXJyYXlCdWZmZXJUYWc6XG4gICAgICAgICAgaWYgKChvYmplY3QuYnl0ZUxlbmd0aCAhPSBvdGhlci5ieXRlTGVuZ3RoKSB8fFxuICAgICAgICAgICAgICAhZXF1YWxGdW5jKG5ldyBVaW50OEFycmF5KG9iamVjdCksIG5ldyBVaW50OEFycmF5KG90aGVyKSkpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICB9XG4gICAgICAgICAgcmV0dXJuIHRydWU7XG5cbiAgICAgICAgY2FzZSBib29sVGFnOlxuICAgICAgICBjYXNlIGRhdGVUYWc6XG4gICAgICAgIGNhc2UgbnVtYmVyVGFnOlxuICAgICAgICAgIC8vIENvZXJjZSBib29sZWFucyB0byBgMWAgb3IgYDBgIGFuZCBkYXRlcyB0byBtaWxsaXNlY29uZHMuXG4gICAgICAgICAgLy8gSW52YWxpZCBkYXRlcyBhcmUgY29lcmNlZCB0byBgTmFOYC5cbiAgICAgICAgICByZXR1cm4gZXEoK29iamVjdCwgK290aGVyKTtcblxuICAgICAgICBjYXNlIGVycm9yVGFnOlxuICAgICAgICAgIHJldHVybiBvYmplY3QubmFtZSA9PSBvdGhlci5uYW1lICYmIG9iamVjdC5tZXNzYWdlID09IG90aGVyLm1lc3NhZ2U7XG5cbiAgICAgICAgY2FzZSByZWdleHBUYWc6XG4gIC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lciwga2V5KSkpIHtcbiAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIC8vIEFzc3VtZSBjeWNsaWMgdmFsdWVzIGFyZSBlcXVhbC5cbiAgICAgIHZhciBzdGFja2VkID0gc3RhY2suZ2V0KG9iamVjdCk7XG4gICAgICBpZiAoc3RhY2tlZCAmJiBzdGFjay5nZXQob3RoZXIpKSB7XG4gICAgICAgIHJldHVybiBzdGFja2VkID09IG90aGVyO1xuICAgICAgfVxuICAgICAgdmFyIHJlc3VsdCA9IHRydWU7XG4gICAgICBzdGFjay5zZXQob2JqZWN0LCBvdGhlcik7XG4gICAgICBzdGFjay5zZXQob3RoZXIsIG9iamVjdCk7XG5cbiAgICAgIHZhciBza2lwQ3RvciA9IGlzUGFydGlhbDtcbiAgICAgIHdoaWxlICgrK2luZGV4IDwgb2JqTGVuZ3RoKSB7XG4gICAgICAgIGtleSA9IG9ialByb3BzW2luZGV4XTtcbiAgICAgICAgdmFyIG9ialZhbHVlID0gb2JqZWN0W2tleV0sXG4gICAgICAgICAgICBvdGhWYWx1ZSA9IG90aGVyW2tleV07XG5cbiAgICAgICAgaWYgKGN1c3RvbWl6ZXIpIHtcbiAgICAgICAgICB2YXIgY29tcGFyZWQgPSBpc1BhcnRpYWxcbiAgICAgICAgICAgID8gY3VzdG9taXplcihvdGhWYWx1ZSwgb2JqVmFsdWUsIGtleSwgb3RoZXIsIG9iamVjdCwgc3RhY2spXG4gICAgICAgICAgICA6IGN1c3RvbWl6ZXIob2JqVmFsdWUsIG90aFZhbHVlLCBrZXksIG9iamVjdCwgb3RoZXIsIHN0YWNrKTtcbiAgICAgICAgfVxuICAgICAgICAvLyBSZWN1cnNpdmVseSBjb21wYXJlIG9iamVjdHMgKHN1c2NlcHRpYmxlIHRvIGNhbGwgc3RhY2sgbGltaXRzKS5cbiAgICAgICAgaWYgKCEoY29tcGFyZWQgPT09IHVuZGVmaW5lZFxuICAgICAgICAgICAgICA/IChvYmpWYWx1ZSA9PT0gb3RoVmFsdWUgfHwgZXF1YWxGdW5jKG9ialZhbHVlLCBvdGhWYWx1ZSwgYml0bWFzaywgY3VzdG9taXplciwgc3RhY2spKVxuICAgICAgICAgICAgICA6IGNvbXBhcmVkXG4gICAgICAgICAgICApKSB7XG4gICAgICAgICAgcmVzdWx0ID0gZmFsc2U7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgc2tpcEN0b3IgfHwgKHNraXBDdG9yID0ga2V5ID09ICdjb25zdHJ1Y3RvcicpO1xuICAgICAgfVxuICAgICAgaWYgKHJlc3VsdCAmJiAhc2tpcEN0b3IpIHtcbiAgICAgICAgdmFyIG9iakN0b3IgPSBvYmplY3QuY29uc3RydWN0b3IsXG4gICAgICAgICAgICBvdGhDdG9yID0gb3RoZXIuY29uc3RydWN0b3I7XG5cbiAgICAgICAgLy8gTm9uIGBPYmplY3RgIG9iamVjdCBpbnN0YW5jZXMgd2l0aCBkaWZmZXJlbnQgY29uc3RydWN0b3JzIGFyZSBub3QgZXF1YWwuXG4gICAgICAgIGlmIChvYmpDdG9yICE9IG90aEN0b3IgJiZcbiAgICAgICAgICAgICgnY29uc3RydWN0b3InIGluIG9iamVjdCAmJiAnY29uc3RydWN0b3InIGluIG90aGVyKSAmJlxuICAgICAgICAgICAgISh0eXBlb2Ygb2JqQ3RvciA9PSAnZnVuY3Rpb24nICYmIG9iakN0b3IgaW5zdGFuY2VvZiBvYmpDdG9yICYmXG4gICAgICAgICAgICAgIHR5cGVvZiBvdGhDdG9yID09ICdmdW5jdGlvbicgJiYgb3RoQ3RvciBpbnN0YW5jZW9mIG90aEN0b3IpKSB7XG4gICAgICAgICAgcmVzdWx0ID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHN0YWNrWydkZWxldGUnXShvYmplY3QpO1xuICAgICAgc3RhY2tbJ2RlbGV0ZSddKG90aGVyKTtcbiAgICAgIHJldHVybiByZXN1bHQ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NrIHByb3BlcnRpZXMuXG4gICAgICogQHJldHVybnMge2Jvb2xlYW59IFJldHVybnMgYHRydWVgIGlmIGBwYXRoYCBleGlzdHMsIGVsc2UgYGZhbHNlYC5cbiAgICAgKi9cbiAgICBmdW5jdGlvbiBoYXNQYXRoKG9iamVjdCwgcGF0aCwgaGFzRnVuYykge1xuICAgICAgcGF0aCA9IGNhc3RQYXRoKHBhdGgsIG9iamVjdCk7XG5cbiAgICAgIHZhciBpbmRleCA9IC0xLFxuICAgICAgICAgIGxlbmd0aCA9IHBhdGgubGVuZ3RoLFxuICAgICAgICAgIHJlc3VsdCA9IGZhbHNlO1xuXG4gICAgICB3aGlsZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICB2YXIga2V5ID0gdG9LZXkocGF0aFtpbmRleF0pO1xuICAgICAgICBpZiAoIShyZXN1bHQgPSBvYmplY3QgIT0gbnVsbCAmJiBoYXNGdW5jKG9iamVjdCwga2V5KSkpIHtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBvYmplY3QgPSBvYmplY3Rba2V5XTtcbiAgICAgIH1cbiAgICAgIGlmIChyZXN1bHQgfHwgKytpbmRleCAhPSBsZW5ndGgpIHtcbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgIH1cbiAgICAgIGxlbmd0aCA9IG9iamVjdCA9PSBudWxsID8gMCA6IG9iamVjdC5sZW5ndGg7XG4gICAgICByZXR1cm4gISFsZW5ndGggJiYgaXNMZW5ndGgobGVuZ3RoKSAmJiBpc0luZGV4KGtleSwgbGVuZ3RoKSAmJlxuICAgICAgICAoaXNBcnJheShvYmplY3QpIHx8IGlzQXJndW1lbnRzKG9iamVjdCkpO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIEluaXRpYWxpemVzIGFuIGFycmF5IGNsb25lLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge0FycmF5fSBhcnJheSBUaGUgYXJyYXkgd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RoZSB2YWx1ZXMgdG8gY29uY2F0ZW5hdGUuXG4gICAgICogQHJldHVybnMge0FycmF5fSBSZXR1cm5zIHRoZSBuZXcgY29uY2F0ZW5hdGVkIGFycmF5LlxuICAgICAqIEBleGFtcGxlXG4gICAgICpcbiAgICAgKiB2YXIgYXJyYXkgPSBbMV07XG4gICAgICogdmFyIG90aGVyID0gXy5jb25jYXQoYXJyYXksIDIsIFszXSwgW1s0XV0pO1xuICAgICAqXG4gICAgICogY29uc29sZS5sb2cob3RoZXIpO1xuICAgICAqIC8vID0+IFsxLCAyLCAzLCBbNF1dXG4gICAgICpcbiAgICAgKiBjb25zb2xlLmxvZyhhcnJheSk7XG4gICAgICogLy8gPT4gWzFdXG4gICAgICovXG4gICAgZnVuY3Rpb24gY29uY2F0KCkge1xuICAgICAgdmFyIGxlbmd0aCA9IGFyZ3VtZW50cy5sZW5ndGg7XG4gICAgICBpZiAoIWxlbmd0aCkge1xuICAgICAgICByZXR1cm4gW107XG4gICAgICB9XG4gICAgICB2YXIgYXJncyA9IEFycmF5KGxlbmd0aCAtIDEpLFxuICAgICAgICAgIGFycmF5ID0gYXJndW1lbnRzWzBdLFxuICAgICAgICAgIGluZGV4ID0gbGVuZ3RoO1xuXG4gICAgICB3aGlsZSAoaW5kZXgtLSkge1xuICAgICAgICBhcmdzW2luZGV4IC0gMV0gPSBhcmd1bWVudHNbaW5kZXhdO1xuICAgICAgfVxuICAgICAgcmV0dXJuIGFycmF5UHVzaChpc0FycmF5KGFycmF5KSA/IGNvcHlBcnJheShhcnJheSkgOiBbYXJyYXldLCBiYXNlRmxhdHRlbihhcmdzLCAxKSk7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQ3JlYXRlcyBhbiBhcnJheSBvZiBgYXJyYXlgIHZhbHVlcyBub3QgaW5jbHVkZWQgaW4gdGhlIG90aGVyIGdpdmVuIGFycmF5c1xuICAgICAqIHVzaW5nIFtgU2FtZVZhbHVlWmVyb2BdKGh0dHA6Ly9lY21hL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ubHkgaW52b2tlIGlmIHdlIGhhdmUgYGxhc3RBcmdzYCB3aGljaCBtZWFucyBgZnVuY2AgaGFzIGJlZW5cbiAgICAgICAgLy8gZGVib3VuY2VkIGF0IGxlYXN0IG9uY2UuXG4gICAgICAgIGlmICh0cmFpbGluZyAmJiBsYXN0QXJncykge1xuICAgICAgICAgIHJldHVybiBpbnZva2VGdW5jKHRpbWUpO1xuICAgICAgICB9XG4gICAgICAgIGxhc3RBcmdzID0gbGFzdFRoaXMgPSB1bmRlZmluZWQ7XG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICB9XG5cbiAgICAgIGZ1bmN0aW9uIGNhbmNlbCgpIHtcbiAgICAgICAgaWYgKHRpbWVySWQgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgIGNsZWFyVGltZW91dCh0aW1lcklkKTtcbiAgICAgICAgfVxuICAgICAgICBsYXN0SW52b2tlVGltZSA9IDA7XG4gICAgICAgIGxhc3RBcmdzID0gbGFzdENhbGxUaW1lID0gbGFzdFRoaXMgPSB0aW1lcklkID0gdW5kZWZpbmVkO1xuICAgICAgfVxuXG4gICAgICBmdW5jdGlvbiBmbHVzaCgpIHtcbiAgICAgICAgcmV0dXJuIHRpbWVySWQgPT09IHVuZGVmaW5lZCA/IHJlc3VsdCA6IHRyYWlsaW5nRWRnZShub3coKSk7XG4gICAgICB9XG5cbiAgICAgIGZ1bmN0aW9uIGRlYm91bmNlZCgpIHtcbiAgICAgICAgdmFyIHRpbWUgPSBub3coKSxcbiAgICAgICAgICAgIGlzSW52b2tpbmcgPSBzaG91bGRJbnZva2UodGltZSk7XG5cbiAgICAgICAgbGFzdEFyZ3MgPSBhcmd1bWVudHM7XG4gICAgICAgIGxhc3RUaGlzID0gdGhpcztcbiAgICAgICAgbGFzdENhbGxUaW1lID0gdGltZTtcblxuICAgICAgICBpZiAoaXNJbnZva2luZykge1xuICAgICAgICAgIGlmICh0aW1lcklkID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgIHJldHVybiBsZWFkaW5nRWRnZShsYXN0Q2FsbFRpbWUpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAobWF4aW5nKSB7XG4gICAgICAgICAgICAvLyBIYW5kbGUgaW52b2NhdGlvbnMgaW4gYSB0aWdodCBsb29wLlxuICAgICAgICAgICAgdGltZXJJZCA9IHNldFRpbWVvdXQodGltZXJFeHBpcmVkLCB3YWl0KTtcbiAgICAgICAgICAgIHJldHVybiBpbnZva2VGdW5jKGxhc3RDYWxsVGltZSk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aW1lcklkID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICB0aW1lcklkID0gc2V0VGltZW91dCh0aW1lckV4cGlyZWQsIHdhaXQpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICB9XG4gICAgICBkZWJvdW5jZWQuY2FuY2VsID0gY2FuY2VsO1xuICAgICAgZGVib3VuY2VkLmZsdXNoID0gZmx1c2g7XG4gICAgICByZXR1cm4gZGVib3VuY2VkO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIERlZmVycyBpbnZva2luZyB0aGUgYGZ1bmNgIHVudGlsIHRoZSBjdXJyZW50IGNhbGwgc3RhY2sgaGFzIGNsZWFyZWQuIEFueVxuICAgICAqIGFkZGl0aW9uYWwgYXJndW1lbnRzIGFyZSBwcm92aWRlZCB0byBgZnVuY2Agd2hlbiBpdCdzIGludm9rZWQuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAc2luY2UgMC4xLjBcbiAgICAgKiBAY2F0ZWdvcnkgRnVuY3Rpb25cbiAgICAgKiBAcGFyYW0ge0Z1bmN0aW9ufSBmdW5jIFRoZSBmdW5jdGlvbiB0byBkZWZlci5cbiAgICAgKiBAcGFyYW0gey4uLip9IFthcmdzXSBUaGUgYXJndW1lbnRzIHRvIGludm9rZSBg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GggYSBgW1tQcm90b3R5cGVdXWAgb2YgYG51bGxgLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDAuOC4wXG4gICAgICogQGNhdGVnb3J5IExhbmdcbiAgICAgKiBAcGFyYW0geyp9IHZhbHVlIFRoZSB2YWx1ZSB0byBjaGVjay5cbiAgICAgKiBAcmV0dXJucyB7Ym9vbGVhbn0gUmV0dXJucyBgdHJ1ZWAgaWYgYHZhbHVlYCBpcyBhIHBsYWluIG9iamVjdCwgZWxzZSBgZmFsc2VgLlxuICAgICAqIEBleGFtcGxlXG4gICAgICpcbiAgICAgKiBmdW5jdGlvbiBGb28oKSB7XG4gICAgICogICB0aGlzLmEgPSAxO1xuICAgICAqIH1cbiAgICAgKlxuICAgICAqIF8uaXNQbGFpbk9iamVjdChuZXcgRm9vKTtcbiAgICAgKiAvLyA9PiBmYWxzZVxuICAgICAqXG4gICAgICogXy5pc1BsYWluT2JqZWN0KFsxLCAyLCAzXSk7XG4gICAgICogLy8gPT4gZmFsc2VcbiAgICAgKlxuICAgICAqIF8uaXNQbGFpbk9iamVjdCh7ICd4JzogMCwgJ3knOiAwIH0pO1xuICAgICAqIC8vID0+IHRydWVcbiAgICAgKlxuICAgICAqIF8uaXNQbGFpbk9iamVjdChPYmplY3QuY3JlYXRlKG51bGwpKTtcbiAgICAgKiAvLyA9PiB0cnVlXG4gICAgICovXG4gICAgZnVuY3Rpb24gaXNQbGFpbk9iamVjdCh2YWx1ZSkge1xuICAgICAgaWYgKCFpc09iamVjdExpa2UodmFsdWUpIHx8IGJhc2VHZXRUYWcodmFsdWUpICE9IG9iamVjdFRhZykge1xuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICB9XG4gICAgICB2YXIgcHJvdG8gPSBnZXRQcm90b3R5cGUodmFsdWUpO1xuICAgICAgaWYgKHByb3RvID09PSBudWxsKSB7XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIC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biAgICAgKlxuICAgICAqIF8udG9MZW5ndGgoJzMuMicpO1xuICAgICAqIC8vID0+IDNcbiAgICAgKi9cbiAgICBmdW5jdGlvbiB0b0xlbmd0aCh2YWx1ZSkge1xuICAgICAgcmV0dXJuIHZhbHVlID8gYmFzZUNsYW1wKHRvSW50ZWdlcih2YWx1ZSksIDAsIE1BWF9BUlJBWV9MRU5HVEgpIDogMDtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBDb252ZXJ0cyBgdmFsdWVgIHRvIGEgbnVtYmVyLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMC4wXG4gICAgICogQGNhdGVnb3J5IExhbmdcbiAgICAgKiBAcGFyYW0geyp9IHZhbHVlIFRoZSB2YWx1ZSB0byBwcm9jZXNzLlxuICAgICAqIEByZXR1cm5zIHtudW1iZXJ9IFJldHVybnMgdGhlIG51bWJlci5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogXy50b051bWJlcigzLjIpO1xuICAgICAqIC8vID0+IDMuMlxuICAgICAqXG4gICAgICogXy50b051bWJlcihOdW1iZXIuTUlOX1ZBTFVFKTtcbiAgICAgKiAvLyA9PiA1ZS0zMjRcbiAgICAgKlxuICAgICAqIF8udG9OdW1iZXIoSW5maW5pdHkpO1xuICAgICAqIC8vID0+IEluZmluaXR5XG4gICAgICpcbiAgICAgKiBfLnRvTnVtYmVyKCczLjInKTtcbiAgICAgKiAvLyA9PiAzLjJcbiAgICAgKi9cbiAgICBmdW5jdGlvbiB0b051bWJlcih2YWx1ZSkge1xuICAgICAgaWYgKHR5cGVvZiB2YWx1ZSA9PSAnbnVtYmVyJykge1xuICAgICAgICByZXR1cm4gdmFsdWU7XG4gICAgICB9XG4gICAgICBpZiAoaXNTeW1ib2wodmFsdWUpKSB7XG4gICAgICAgIHJldHVybiBOQU47XG4gICAgICB9XG4gICAgICBpZiAoaXNPYmplY3QodmF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HVybnMge09iamVjdH0gUmV0dXJucyB0aGUgY29udmVydGVkIHBsYWluIG9iamVjdC5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogZnVuY3Rpb24gRm9vKCkge1xuICAgICAqICAgdGhpcy5iID0gMjtcbiAgICAgKiB9XG4gICAgICpcbiAgICAgKiBGb28ucHJvdG90eXBlLmMgPSAzO1xuICAgICAqXG4gICAgICogXy5hc3NpZ24oeyAnYSc6IDEgfSwgbmV3IEZvbyk7XG4gICAgICogLy8gPT4geyAnYSc6IDEsICdiJzogMiB9XG4gICAgICpcbiAgICAgKiBfLmFzc2lnbih7ICdhJzogMSB9LCBfLnRvUGxhaW5PYmplY3QobmV3IEZvbykpO1xuICAgICAqIC8vID0+IHsgJ2EnOiAxLCAnYic6IDIsICdjJzogMyB9XG4gICAgICovXG4gICAgZnVuY3Rpb24gdG9QbGFpbk9iamVjdCh2YWx1ZSkge1xuICAgICAgcmV0dXJuIGNvcHlPYmplY3QodmFsdWUsIGtleXNJbih2YWx1ZSkpO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIENvbnZlcnRzIGB2YWx1ZWAgdG8gYSBzYWZlIGludGVnZXIuIEEgc2FmZSBpbnRlZ2VyIGNhbiBiZSBjb21wYXJlZCBhbmRcbiAgICAgKiByZXByZXNlbnRlZCBjb3JyZWN0bHkuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAc2luY2UgNC4wLjBcbiAgICAgKiBAY2F0ZWdvcnkgTGFuZ1xuICAgICAqIEBwYXJhbSB7Kn0gdmFsdWUgVGhlIHZhbHVlIHRvIGNvbnZlcnQuXG4gICAgICogQHJldHVybnMge251bWJlcn0gUmV0dXJucyB0aGUgY29udmVydGVkIGludGVnZXIuXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIF8udG9TYWZlSW50ZWdlcigzLjIpO1xuICAgICAqIC8vID0+IDNcbiAgICAgKlxu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amVjdHMuXG4gICAgICogQHJldHVybnMge09iamVjdH0gUmV0dXJucyBgb2JqZWN0YC5cbiAgICAgKiBAc2VlIF8uYXNzaWduSW5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogZnVuY3Rpb24gRm9vKCkge1xuICAgICAqICAgdGhpcy5hID0gMTtcbiAgICAgKiB9XG4gICAgICpcbiAgICAgKiBmdW5jdGlvbiBCYXIoKSB7XG4gICAgICogICB0aGlzLmMgPSAzO1xuICAgICAqIH1cbiAgICAgKlxuICAgICAqIEZvby5wcm90b3R5cGUuYiA9IDI7XG4gICAgICogQmFyLnByb3RvdHlwZS5kID0gNDtcbiAgICAgKlxuICAgICAqIF8uYXNzaWduKHsgJ2EnOiAwIH0sIG5ldyBGb28sIG5ldyBCYXIpO1xuICAgICAqIC8vID0+IHsgJ2EnOiAxLCAnYyc6IDMgfVxuICAgICAqL1xuICAgIHZhciBhc3NpZ24gPSBjcmVhdGVBc3NpZ25lcihmdW5jdGlvbihvYmplY3QsIHNvdXJjZSkge1xuICAgICAgaWYgKGlzUHJvdG90eXBlKHNvdXJjZSkgfHwgaXNBcnJheUxpa2Uoc291cmNlKSkge1xuICAgICAgICBjb3B5T2JqZWN0KHNvdXJjZSwga2V5cyhzb3VyY2UpLCBvYmplY3QpO1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG4gICAgICBmb3IgKHZhciBrZXkgaW4gc291cmNlKSB7XG4gICAgICAgIGlmIChoYXNPd25Qcm9wZXJ0eS5jYWxsKHNvdXJjZSwga2V5KSkge1xuICAgICAgICAgIGFzc2lnblZhbHVlKG9iamVjdCwga2V5LCBzb3VyY2Vba2V5XSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9KTtcblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIGlzIGxpa2UgYF8uYXNzaWduYCBleGNlcHQgdGhhdCBpdCBpdGVyYXRlcyBvdmVyIG93biBhbmRcbiAgICAgKiBpbmhlcml0ZWQ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A6IHt9O1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgIGFjY3VtdWxhdG9yID0ge307XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIChpc0Fyckxpa2UgPyBhcnJheUVhY2ggOiBiYXNlRm9yT3duKShvYmplY3QsIGZ1bmN0aW9uKHZhbHVlLCBpbmRleCwgb2JqZWN0KSB7XG4gICAgICAgIHJldHVybiBpdGVyYXRlZShhY2N1bXVsYXRvciwgdmFsdWUsIGluZGV4LCBvYmplY3QpO1xuICAgICAgfSk7XG4gICAgICByZXR1cm4gYWNjdW11bGF0b3I7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogUmVtb3ZlcyB0aGUgcHJvcGVydHkgYXQgYHBhdGhgIG9mIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogKipOb3RlOioqIFRoaXMgbWV0aG9kIG11dGF0ZXMgYG9iamVjdGAuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAc2luY2UgNC4wLjBcbiAgICAgKiBAY2F0ZWdvcnkgT2JqZWN0XG4gICAgICogQHBhcmFtIHtPYmplY3R9IG9iamVjdCBUaGUgb2JqZWN0IHRvIG1vZGlmeS5cbiAgICAgKiBAcGFyYW0ge0FycmF5fHN0cmluZ30gcGF0aCBUaGUgcGF0aCBvZiB0aGUgcHJvcGVydHkgdG8gdW5zZXQuXG4gICAgICogQHJldHVybnMge2Jvb2xlYW59IFJldHVybnMgYHRydWVgIGlmIHRoZSBwcm9wZXJ0eSBpcyBkZWxldGVkLCBlbHNlIGBmYWxzZWAuXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIHZhciBvYmplY3QgPSB7ICdhJzogW3sgJ2InOiB7ICdjJzogNyB9IH1dIH07XG4gICAgICogXy51bnNldChvYmplY3QsICdhWzBdLmIuYycpO1xuICAgICAqIC8vID0+IHRydWVcbiAgICAgKlxuICAgICAqIGNvbnNvb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7XFxuJyArXG4gICAgICAgICh2YXJpYWJsZVxuICAgICAgICAgID8gJydcbiAgICAgICAgICA6ICdvYmogfHwgKG9iaiA9IHt9KTtcXG4nXG4gICAgICAgICkgK1xuICAgICAgICBcInZhciBfX3QsIF9fcCA9ICcnXCIgK1xuICAgICAgICAoaXNFc2NhcGluZ1xuICAgICAgICAgICA/ICcsIF9fZSA9IF8uZXNjYXBlJ1xuICAgICAgICAgICA6ICcnXG4gICAgICAgICkgK1xuICAgICAgICAoaXNFdmFsdWF0aW5nXG4gICAgICAgICAgPyAnLCBfX2ogPSBBcnJheS5wcm90b3R5cGUuam9pbjtcXG4nICtcbiAgICAgICAgICAgIFwiZnVuY3Rpb24gcHJpbnQoKSB7IF9fcCArPSBfX2ouY2FsbChhcmd1bWVudHMsICcnKSB9XFxuXCJcbiAgICAgICAgICA6ICc7XFxuJ1xuICAgICAgICApICtcbiAgICAgICAgc291cmNlICtcbiAgICAgICAgJ3JldHVybiBfX3BcXG59JztcblxuICAgICAgdmFyIHJlc3VsdCA9IGF0dGVtcHQoZnVuY3Rpb24oKSB7XG4gICAgICAgIHJldHVybiBGdW5jdGlvbihpbXBvcnRzS2V5cywgc291cmNlVVJMICsgJ3JldHVybiAnICsgc291cmNlKVxuICAgICAgICAgIC5hcHBseSh1bmRlZmluZWQsIGltcG9ydHNWYWx1ZXMpO1xuICAgICAgfSk7XG5cbiAgICAgIC8vIFByb3ZpZGUgdGhlIGNvbXBpbGVkIGZ1bmN0aW9uJ3Mgc291cmNlIGJ5IGl0cyBgdG9TdHJpbmdgIG1ldGhvZCBvclxuICAgICAgLy8gdGhlIGBzb3VyY2VgIHByb3BlcnR5IGFzIGEgY29udmVuaWVuY2UgZm9yIGlubGluaW5nIGNvbXBpbGVkIHRlbXBsYXRlcy5cbiAgICAgIHJlc3VsdC5zb3VyY2UgPSBzb3VyY2U7XG4gICAgICBpZiAoaXNFcnJvcihyZXN1bHQpKSB7XG4gICAgICAgIHRocm93IHJlc3VsdDtcb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lzb3I7XG4gICAgfSwgMSk7XG5cbiAgICAvKipcbiAgICAgKiBDb21wdXRlcyBgbnVtYmVyYCByb3VuZGVkIGRvd24gdG8gYHByZWNpc2lvbmAuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAc2luY2UgMy4xMC4wXG4gICAgICogQGNhdGVnb3J5IE1hdGhcbiAgICAgKiBAcGFyYW0ge251bWJlcn0gbnVtYmVyIFRoZSBudW1iZXIgdG8gcm91bmQgZG93bi5cbiAgICAgKiBAcGFyYW0ge251bWJlcn0gW3ByZWNpc2lvbj0wXSBUaGUgcHJlY2lzaW9uIHRvIHJvdW5kIGRvd24gdG8uXG4gICAgICogQHJldHVybnMge251bWJlcn0gUmV0dXJucyB0aGUgcm91bmRlZCBkb3duIG51bWJlci5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogXy5mbG9vcig0LjAwNik7XG4gICAgICogLy8gPT4gNFxuICAgICAqXG4gICAgICogXy5mbG9vcigwLjA0NiwgMik7XG4gICAgICogLy8gPT4gMC4wNFxuICAgICAqXG4gICAgICogXy5mbG9vcig0MDYwLCAtMik7XG4gICAgICogLy8gPT4gNDAwMFxuICAgICAqL1xuICAgIHZhciBmbG9vciA9IGNyZWF0ZVJvdW5kKCdmbG9vcicpO1xuXG4gICAgLyoqXG4gICAgICogQ29tcHV0ZXMgdGhlIG1heGltdW0gdmFsdWUgb2YgYGFycmF5YC4gSWYgYGFycmF5YCBpcyBlbXB0eSBvciBmYWxzZXksXG4gICAgICogYHVuZGVmaW5lZGAgaXMgcmV0dXJuZWQuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQHNpbmNlIDAuMS4wXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAY2F0ZWdvcnkgTWF0aFxuICAgICAqIEBwYXJhbSB7QXJyYXl9IGFycmF5IFRoZSBhcnJheSB0byBpdGVyYXRlIG92ZXIuXG4gICA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nXG4gICAgdmFyIGxhdGVyUXVldWUgPSBbXTtcblxuICAgIGZ1bmN0aW9uIGZsdXNoKCkge1xuICAgICAgICAvKiBqc2hpbnQgbG9vcGZ1bmM6IHRydWUgKi9cbiAgICAgICAgdmFyIHRhc2ssIGRvbWFpbjtcblxuICAgICAgICB3aGlsZSAoaGVhZC5uZXh0KSB7XG4gICAgICAgICAgICBoZWFkID0gaGVhZC5uZXh0O1xuICAgICAgICAgICAgdGFzayA9IGhlYWQudGFzaztcbiAgICAgICAgICAgIGhlYWQudGFzayA9IHZvaWQgMDtcbiAgICAgICAgICAgIGRvbWFpbiA9IGhlYWQuZG9tYWluO1xuXG4gICAgICAgICAgICBpZiAoZG9tYWluKSB7XG4gICAgICAgICAgICAgICAgaGVhZC5kb21haW4gPSB2b2lkIDA7XG4gICAgICAgICAgICAgICAgZG9tYWluLmVudGVyKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBydW5TaW5nbGUodGFzaywgZG9tYWluKTtcblxuICAgICAgICB9XG4gICAgICAgIHdoaWxlIChsYXRlclF1ZXVlLmxlbmd0aCkge1xuICAgICAgICAgICAgdGFzayA9IGxhdGVyUXVldWUucG9wKCk7XG4gICAgICAgICAgICBydW5TaW5nbGUodGFzayk7XG4gICAgICAgIH1cbiAgICAgICAgZmx1c2hpbmcgPSBmYWxzZTtcbiAgICB9XG4gICAgLy8gcnVucyBhIHNpbmdsZSBmdW5jdGlvbiBpbiB0aGUgYXN5bmMgcXVldWVcbiAgICBmdW5jdGlvbiBydW5TaW5nbGUodGFzaywgZG9tYWluKSB7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICB0YXNrKCk7XG5cbiAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgaWYgKGlzTm9kZUpTKSB7XG4gICAgICAgICAgICAgICAgLy8gSW4gbm9kZSwgdW5jYXVnaHQgZXhjZXB0aW9ucyBhcmUgY29uc2lkZXJlZCBmYXRhbCBlcnJvcnMuXG4gICAgICAgICAgICAgICAgLy8gUmUtdGhyb3cgdGhlbSBzeW5jaHJvbm91c2x5IHRvIGludGVycnVwdCBmbHVzaGluZyFcblxuICAgICAgICAgICAgICAgIC8vIEVuc3VyZSBjb250aW51YXRpb24gaWYgdGhlIHVuY2F1Z2h0IGV4Y2VwdGlvbiBpcyBzdXBwcmVzc2VkXG4gICAgICAgICAgICAgICAgLy8gbGlzdGVuaW5nIFwidW5jYXVnaHRFeGNlcHRpb25cIiBldmVudHMgKGFzIGRvbWFpbnMgZG9lcykuXG4gICAgICAgICAgICAgICAgLy8gQ29udGludWUgaW4gbmV4dCBldmVudCB0byBhdm9pZCB0aWNrIHJlY3Vyc2lvbi5cbiAgICAgICAgICAgICAgICBpZiAoZG9tYWluKSB7XG4gICAgICAgICAgICAgICAgICAgIGRvbWFpbi5leGl0KCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoZmx1c2gsIDApO1xuICAgICAgICAgICAgICAgIGlmIChkb21haW4pIHtcbiAgICAgICAgICAgICAgICAgICAgZG9tYWluLmVudGVyKCk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdGhyb3cgZTtcblxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAvLyBJbiBicm93c2VycywgdW5jYXVnaHQgZXhjZXB0aW9ucyBhcmUgbm90IGZhdGFsLlxuICAgICAgICAgICAgICAgIC8vIFJlLXRocm93IHRoZW0gYXN5bmNocm9ub3VzbHkgdG8gYXZvaWQgc2xvdy1kb3ducy5cbiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgZTtcbiAgICAgICAgICAgICAgICB9LCAwKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChkb21haW4pIHtcbiAgICAgICAgICAgIGRvbWFpbi5leGl0KCk7XG4gIC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ICAgIGRvIHtcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggaW4gdGhpcykge1xuICAgICAgICAgICAgICAgICAgICBiYXNpcyA9IHRoaXNbaW5kZXgrK107XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoKytpbmRleCA+PSBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gd2hpbGUgKDEpO1xuICAgICAgICB9XG4gICAgICAgIC8vIHJlZHVjZVxuICAgICAgICBmb3IgKDsgaW5kZXggPCBsZW5ndGg7IGluZGV4KyspIHtcbiAgICAgICAgICAgIC8vIGFjY291bnQgZm9yIHRoZSBwb3NzaWJpbGl0eSB0aGF0IHRoZSBhcnJheSBpcyBzcGFyc2VcbiAgICAgICAgICAgIGlmIChpbmRleCBpbiB0aGlzKSB7XG4gICAgICAgICAgICAgICAgYmFzaXMgPSBjYWxsYmFjayhiYXNpcywgdGhpc1tpbmRleF0sIGluZGV4KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gYmFzaXM7XG4gICAgfVxuKTtcblxudmFyIGFycmF5X2luZGV4T2YgPSB1bmN1cnJ5VGhpcyhcbiAgICBBcnJheS5wcm90b3R5cGUuaW5kZXhPZiB8fCBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgLy8gbm90IGEgdmVyeSBnb29kIHNoaW0sIGJ1dCBnb29kIGVub3VnaCBmb3Igb3VyIG9uZSB1c2Ugb2YgaXRcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCB0aGlzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICBpZiAodGhpc1tpXSA9PT0gdmFsdWUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gaTtcbiAgICAgICAgICAgIH1cbiAg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50cyk7XG4gICAgICAgIGlmIChtZXNzYWdlcykge1xuICAgICAgICAgICAgbWVzc2FnZXMucHVzaChhcmdzKTtcbiAgICAgICAgICAgIGlmIChvcCA9PT0gXCJ3aGVuXCIgJiYgb3BlcmFuZHNbMV0pIHsgLy8gcHJvZ3Jlc3Mgb3BlcmFuZFxuICAgICAgICAgICAgICAgIHByb2dyZXNzTGlzdGVuZXJzLnB1c2gob3BlcmFuZHNbMV0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgUS5uZXh0VGljayhmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgcmVzb2x2ZWRQcm9taXNlLnByb21pc2VEaXNwYXRjaC5hcHBseShyZXNvbHZlZFByb21pc2UsIGFyZ3MpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgLy8gWFhYIGRlcHJlY2F0ZWRcbiAgICBwcm9taXNlLnZhbHVlT2YgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIGlmIChtZXNzYWdlcykge1xuICAgICAgICAgICAgcmV0dXJuIHByb21pc2U7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIG5lYXJlclZhbHVlID0gbmVhcmVyKHJlc29sdmVkUHJvbWlzZSk7XG4gICAgICAgIGlmIChpc1Byb21pc2UobmVhcmVyVmFsdWUpKSB7XG4gICAgICAgICAgICByZXNvbHZlZFByb21pc2UgPSBuZWFyZXJWYWx1ZTsgLy8gc2hvcnRlbiBjaGFpblxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBuZWFyZXJWYWx1ZTtcbiAgICB9O1xuXG4gICAgcHJvbWlzZS5pbnNwZWN0ID0gZnVuY3Rpb24gKCkge1xuICAgICAgICBpZiAoIXJlc29sdmVkUHJvbWlzZSkge1xuICAgICAgICAgICAgcmV0dXJuIHsgc3RhdGU6IFwicGVuZGluZ1wiIH07XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHJ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yZWV2ZXIgcHJvbWlzZXMgYXJlXG4gKiBib3VnaHQgYW5kIHNvbGQuXG4gKi9cblEubWFrZVByb21pc2UgPSBQcm9taXNlO1xuZnVuY3Rpb24gUHJvbWlzZShkZXNjcmlwdG9yLCBmYWxsYmFjaywgaW5zcGVjdCkge1xuICAgIGlmIChmYWxsYmFjayA9PT0gdm9pZCAwKSB7XG4gICAgICAgIGZhbGxiYWNrID0gZnVuY3Rpb24gKG9wKSB7XG4gICAgICAgICAgICByZXR1cm4gcmVqZWN0KG5ldyBFcnJvcihcbiAgICAgICAgICAgICAgICBcIlByb21pc2UgZG9lcyBub3Qgc3VwcG9ydCBvcGVyYXRpb246IFwiICsgb3BcbiAgICAgICAgICAgICkpO1xuICAgICAgICB9O1xuICAgIH1cbiAgICBpZiAoaW5zcGVjdCA9PT0gdm9pZCAwKSB7XG4gICAgICAgIGluc3BlY3QgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICByZXR1cm4ge3N0YXRlOiBcInVua25vd25cIn07XG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgdmFyIHByb21pc2UgPSBvYmplY3RfY3JlYXRlKFByb21pc2UucHJvdG90eXBlKTtcblxuICAgIHByb21pc2UucHJvbWlzZURpc3BhdGNoID0gZnVuY3Rpb24gKHJlc29sdmUsIG9wLCBhcmdzKSB7XG4gICAgICAgIHZhciByZXN1bHQ7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICBpZiAoZGVzY3JpcHRvcltvcF0pIHtcbiAgICAgICAgICAgICAgICByZXN1bHQgPSBkZXNjcmlwdG9yW29wXS5hcHBseShwcm9taXNlLCBhcmdzKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0ID0gZmFsbGJhY2suY2FsbChwcm9taXNlLCBvcCwgYXJncyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gY2F0Y2ggKGV4Y2VwdGlvbikge1xuICAgICAgICAgICAgcmVzdWx0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kID09PSBcImZ1bmN0aW9uXCIgPyBwcm9ncmVzc2VkKHZhbHVlKSA6IHZhbHVlO1xuICAgIH1cblxuICAgIFEubmV4dFRpY2soZnVuY3Rpb24gKCkge1xuICAgICAgICBzZWxmLnByb21pc2VEaXNwYXRjaChmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgIGlmIChkb25lKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZG9uZSA9IHRydWU7XG5cbiAgICAgICAgICAgIGRlZmVycmVkLnJlc29sdmUoX2Z1bGZpbGxlZCh2YWx1ZSkpO1xuICAgICAgICB9LCBcIndoZW5cIiwgW2Z1bmN0aW9uIChleGNlcHRpb24pIHtcbiAgICAgICAgICAgIGlmIChkb25lKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZG9uZSA9IHRydWU7XG5cbiAgICAgICAgICAgIGRlZmVycmVkLnJlc29sdmUoX3JlamVjdGVkKGV4Y2VwdGlvbikpO1xuICAgICAgICB9XSk7XG4gICAgfSk7XG5cbiAgICAvLyBQcm9ncmVzcyBwcm9wYWdhdG9yIG5lZWQgdG8gYmUgYXR0YWNoZWQgaW4gdGhlIGN1cnJlbnQgdGljay5cbiAgICBzZWxmLnByb21pc2VEaXNwYXRjaCh2b2lkIDAsIFwid2hlblwiLCBbdm9pZCAwLCBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgdmFyIG5ld1ZhbHVlO1xuICAgICAgICB2YXIgdGhyZXcgPSBmYWxzZTtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIG5ld1ZhbHVlID0gX3Byb2dyZXNzZWQodmFsdWUpO1xuICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICB0aHJldyA9IHRydWU7XG4gICAgICAgICAgICBpZiAoUS5vbmVycm9yKSB7XG4gICAgICAgICAgICAgICAgUS5vbmVycm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cmVmZXJlbmNlXG4gKi9cblEuZnVsZmlsbCA9IGZ1bGZpbGw7XG5mdW5jdGlvbiBmdWxmaWxsKHZhbHVlKSB7XG4gICAgcmV0dXJuIFByb21pc2Uoe1xuICAgICAgICBcIndoZW5cIjogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgcmV0dXJuIHZhbHVlO1xuICAgICAgICB9LFxuICAgICAgICBcImdldFwiOiBmdW5jdGlvbiAobmFtZSkge1xuICAgICAgICAgICAgcmV0dXJuIHZhbHVlW25hbWVdO1xuICAgICAgICB9LFxuICAgICAgICBcInNldFwiOiBmdW5jdGlvbiAobmFtZSwgcmhzKSB7XG4gICAgICAgICAgICB2YWx1ZVtuYW1lXSA9IHJocztcbiAgICAgICAgfSxcbiAgICAgICAgXCJkZWxldGVcIjogZnVuY3Rpb24gKG5hbWUpIHtcbiAgICAgICAgICAgIGRlbGV0ZSB2YWx1ZVtuYW1lXTtcbiAgICAgICAgfSxcbiAgICAgICAgXCJwb3N0XCI6IGZ1bmN0aW9uIChuYW1lLCBhcmdzKSB7XG4gICAgICAgICAgICAvLyBNYXJrIE1pbGxlciBwcm9wb3NlcyB0aGF0IHBvc3Qgd2l0aCBubyBuYW1lIHNob3VsZCBhcHBseSBhXG4gICAgICAgICAgICAvLyBwcm9taXNlZCBmdW5jdGlvbi5cbiAgICAgICAgICAgIGlmIChuYW1lID09PSBudWxsIHx8IG5hbWUgPT09IHZvaWQgMCkge1xuICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZS5hcHBseSh2b2lkIDAsIGFyZ3MpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWVbbmFtZV0uYXBwbHkodmFsdWUsIGFyZ3MpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBcImFwcGx5XCI6IGZ1bmN0aW9uICh0aGlzcCwgYXJncykge1xuICAgICAgICAgICAgcmV0dXJuIHZhbHVlLmFwcGx5KHR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G9yc1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IGdlbmVyYXRvclt2ZXJiXShhcmcpO1xuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4Y2VwdGlvbikge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVqZWN0KGV4Y2VwdGlvbik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChyZXN1bHQuZG9uZSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gUShyZXN1bHQudmFsdWUpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB3aGVuKHJlc3VsdC52YWx1ZSwgY2FsbGJhY2ssIGVycmJhY2spO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgLy8gU3BpZGVyTW9ua2V5IEdlbmVyYXRvcnNcbiAgICAgICAgICAgICAgICAvLyBGSVhNRTogUmVtb3ZlIHRoaXMgY2FzZSB3aGVuIFNNIGRvZXMgRVM2IGdlbmVyYXRvcnMuXG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gZ2VuZXJhdG9yW3ZlcmJdKGFyZyk7XG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZXhjZXB0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc1N0b3BJdGVyYXRpb24oZXhjZXB0aW9uKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFEoZXhjZXB0aW9uLnZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZWplY3QoZXhjZXB0aW9uKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICA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Nob3QudmFsdWU7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICsrcGVuZGluZ0NvdW50O1xuICAgICAgICAgICAgICAgIHdoZW4oXG4gICAgICAgICAgICAgICAgICAgIHByb21pc2UsXG4gICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXNbaW5kZXhdID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoLS1wZW5kaW5nQ291bnQgPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZlcnJlZC5yZXNvbHZlKHByb21pc2VzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgZGVmZXJyZWQucmVqZWN0LFxuICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiAocHJvZ3Jlc3MpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmVycmVkLm5vdGlmeSh7IGluZGV4OiBpbmRleCwgdmFsdWU6IHByb2dyZXNzIH0pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSwgdm9pZCAwKTtcbiAgICAgICAgaWYgKHBlbmRpbmdDb3VudCA9PT0gMCkge1xuICAgICAgICAgICAgZGVmZXJyZWQucmVzb2x2ZShwcm9taXNlcyk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGRlZmVycmVkLnByb21pc2U7XG4gICAgfSk7XG59XG5cblByb21pc2UucHJvdG90eXBlLmFsbCA9IGZ1bmN0aW9uICgpIHtcbiAgICByZXR1cm4gYWxsKHRoaXMpO1xufTtcblxuLyoqXG4gKiBSZXR1cm5zIHRoZSBmaXJzdCByZXNvbHZlZCBwcm9taXNlIG9mIGFuIGFycmF5LiBQcmlvciByZWplY3RlZ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1cm4gdDtcbiAgICB9O1xuICAgIHRlc3QuX3Jlc3VsdHMgPSByZXN1bHRzO1xuICAgIFxuICAgIHRlc3QuX3Rlc3RzID0gW107XG4gICAgXG4gICAgdGVzdC5jcmVhdGVTdHJlYW0gPSBmdW5jdGlvbiAob3B0cykge1xuICAgICAgICByZXR1cm4gcmVzdWx0cy5jcmVhdGVTdHJlYW0ob3B0cyk7XG4gICAgfTtcblxuICAgIHRlc3Qub25GaW5pc2ggPSBmdW5jdGlvbiAoY2IpIHtcbiAgICAgICAgcmVzdWx0cy5vbignZG9uZScsIGNiKTtcbiAgICB9O1xuICAgIFxuICAgIHZhciBvbmx5ID0gZmFsc2U7XG4gICAgdGVzdC5vbmx5ID0gZnVuY3Rpb24gKCkge1xuICAgICAgICBpZiAob25seSkgdGhyb3cgbmV3IEVycm9yKCd0aGVyZSBjYW4gb25seSBiZSBvbmUgb25seSB0ZXN0Jyk7XG4gICAgICAgIG9ubHkgPSB0cnVlO1xuICAgICAgICB2YXIgdCA9IHRlc3QuYXBwbHkobnVsbCwgYXJndW1lbnRzKTtcbiAgICAgICAgcmVzdWx0cy5vbmx5KHQpO1xuICAgICAgICByZXR1cm4gdDtcbiAgICB9O1xuICAgIHRlc3QuX2V4aXRDb2RlID0gMDtcbiAgICBcbiAgICB0ZXN0LmNsb3NlID0gZnVuY3Rpb24gKCkgeyByZXN1bHRzLmNsb3NlKCkgfTtcbiAgICBcbiAgICByZXR1cm4gdGVzdDtcbn1cbiJdfQ== diff --git a/lib/exporter.js b/lib/exporter.js index cd80c36..39df2a3 100755 --- a/lib/exporter.js +++ b/lib/exporter.js @@ -164,7 +164,7 @@ module.exports = function(conf){ "SELECT row_to_json(d) FROM (SELECT * FROM " + table_name + ") AS d " + "LIMIT " + results_per_page + " OFFSET " + (page * results_per_page) + ";"; pool.query(query).then(function (res) { - var outfile_path = path.join(outpath, table_name+'.json'); + var outfile_path = path.join(outpath, table_name+'.ndjson'); var outfile_exists = fs.existsSync(outfile_path); var outfile_flags = 'w'; var outfile_size = 0; @@ -180,21 +180,13 @@ module.exports = function(conf){ start: outfile_size }); - if(page == 0){ - wstream.write("[\n"); - } - _.each(res.rows, function(row, row_idx){ if(row_idx != 0 || page > 0){ - wstream.write(',\n'); + wstream.write('\n'); } wstream.write(JSON.stringify(row.row_to_json)); }); - if(page == pages - 1){ - wstream.write("\n]"); - } - wstream.end(); wstream.on('close', function () { pages_defs[page].resolve(); diff --git a/lib/importer.js b/lib/importer.js index 04691ac..b3f456f 100755 --- a/lib/importer.js +++ b/lib/importer.js @@ -1,6 +1,6 @@ 'use strict'; -var oboe = require('oboe'); +var ndjsonStream = require('can-ndjson-stream'); var Rx = require('rxjs'); var _ = require('lodash'); var q = require('q'); @@ -33,8 +33,17 @@ module.exports.import = function( data_path, idb_name, options ){ //retreive manifest - oboe(data_path + '/_manifest.json') - .done(function(manifest) { + fetch(data_path + '/_manifest.json') + .then(function(response) { + if(!response.ok){ + return events.next({ + message: "error", + value: "manifest not found" + }); + } + + return response.json(); + }).then(function(manifest){ events.next({ message: "manifest", value: manifest @@ -163,9 +172,20 @@ module.exports.import = function( data_path, idb_name, options ){ }; - oboe(data_path + '/' + key + '.json') - .node({ - '!.*': function(row){ + fetch(data_path + '/' + key + '.ndjson') + .then(function(response){ + + if(!response.ok){ + return failout('oboe_read_failed'); + } + + return ndjsonStream(response.body); + }).then(function(rowsStream){ + var reader = rowsStream.getReader(); + var doRead = function (result) { + if (result.done) return; + var row = result.value; + page_items.push(row); if(page_items.length >= options.items_per_page || @@ -179,15 +199,14 @@ module.exports.import = function( data_path, idb_name, options ){ current_page += 1; } - return oboe.drop; //allows to read files bigger than available RAM - } - }) - .fail(function(){ - failout('oboe_read_failed'); - }); + reader.read().then(doRead); + }; + reader.read().then(doRead); - }); + }); + + }); store.transaction.addEventListener('error', function(){ failout('idb_schema_failed'); @@ -213,12 +232,6 @@ module.exports.import = function( data_path, idb_name, options ){ delReq.onsuccess = fillIDB; delReq.onerror = fillIDB; - }) - .fail(function(){ - events.next({ - message: "error", - value: "manifest not found" - }); }); return events; diff --git a/package.json b/package.json index 126a90d..d28464a 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,14 @@ "path": "0.12.7", "del": "2.2.2", "rxjs": "5.0.0-beta.12", - "oboe": "2.1.3", + "can-ndjson-stream": "0.1.7", + "ndjson": "1.5.0", "tape": "latest" }, "clientDependencies": [ "lodash", - "oboe", + "can-ndjson-stream", + "ndjson", "q", "tape" ], diff --git a/test/test.html b/test/test.html index 1c21087..613f074 100644 --- a/test/test.html +++ b/test/test.html @@ -12,7 +12,7 @@ var tape = require('tape'); var q = require('q'); var _ = require('lodash'); - var oboe = require('oboe'); + var ndjsonStream = require('can-ndjson-stream'); console.log = function(value){ var el = document.createElement("div"); @@ -66,54 +66,71 @@ var table_def = q.defer(); table_promises.push(table_def.promise); - oboe(data_path + '/' + table_name + '.json').done(function (_d) { - var tx = db.transaction([table_name], "readwrite"); - var store = tx.objectStore(table_name); - - var index; - if(_m.primary_keys.length > 1){ - index = store.index("idx_multiple_pkeys"); - } - - var count_def = q.defer(); - var count_request = store.count(); - count_request.onsuccess = function() { - t.equal(count_request.result, _m.row_count, table_name + " manifest.row_count matches idb count"); - - count_def.resolve(count_request.result); - }; - - //pick 3 random datums - _.each(new Array(3), function () { - var random_idx = parseInt(Math.random() * 1000000) % _d.length; - var source_datum = _d[random_idx]; - - var pkeys = []; - _.each(_m.primary_keys, function (pkey_name) { - pkeys.push(source_datum[pkey_name]); - }); - - var idb_def = q.defer(); - - var idb_result; - if(_m.primary_keys.length > 1){ - idb_result = index.get(pkeys); - }else{ - idb_result = store.get(source_datum[_m.primary_keys[0]]); - } - - idb_result.onsuccess = function () { - var idb_datum = idb_result.result; - _.each(idb_datum, function (_v, _k) { - t.equal(_v, source_datum[_k], "assert " + table_name + "_" + source_datum[_m.primary_keys[0]] + " idb data is equal to source"); - }); - - idb_def.resolve(); + fetch(data_path + '/' + table_name + '.ndjson') + .then(function (response) { + return ndjsonStream(response.body); + }).then(function (dataStream) { + var reader = dataStream.getReader(); + var all_data = []; + var readDatum = function (result) { + if(result.done){ + var tx = db.transaction([table_name], "readwrite"); + var store = tx.objectStore(table_name); + + var index; + if(_m.primary_keys.length > 1){ + index = store.index("idx_multiple_pkeys"); + } + + var count_def = q.defer(); + var count_request = store.count(); + count_request.onsuccess = function() { + t.equal(count_request.result, _m.row_count, table_name + " manifest.row_count matches idb count"); + + count_def.resolve(count_request.result); + }; + +//pick 3 random datums + _.each(new Array(3), function () { + var random_idx = parseInt(Math.random() * 1000000) % all_data.length; + var source_datum = all_data[random_idx]; + + var pkeys = []; + _.each(_m.primary_keys, function (pkey_name) { + pkeys.push(source_datum[pkey_name]); + }); + + var idb_def = q.defer(); + + var idb_result; + if(_m.primary_keys.length > 1){ + idb_result = index.get(pkeys); + }else{ + idb_result = store.get(source_datum[_m.primary_keys[0]]); + } + + idb_result.onsuccess = function () { + var idb_datum = idb_result.result; + _.each(idb_datum, function (_v, _k) { + t.equal(_v, source_datum[_k], "assert " + table_name + "_" + source_datum[_m.primary_keys[0]] + " idb data is equal to source"); + }); + + idb_def.resolve(); + }; + + q.all([count_def.promise, idb_def.promise]).then(table_def.resolve); + }); + + return; + } + + all_data.push(result.value); + + reader.read().then(readDatum); }; - q.all([count_def.promise, idb_def.promise]).then(table_def.resolve); + reader.read().then(readDatum); }); - }); }); q.all(table_promises).then(function () { diff --git a/test/test.js b/test/test.js index 2c79097..077de7a 100755 --- a/test/test.js +++ b/test/test.js @@ -11,6 +11,7 @@ var tape = require('tape'); var fs = require('fs'); var q = require('q'); var path = require('path'); +var ndjson = require('ndjson'); var conf = { db: { @@ -51,59 +52,79 @@ q.all([export_promise, db_schema_promise]).then(function () { t.equals(output_filenames.length - 1, db_tables.length); //minus one for manifest + var output_ars = {}; + var output_ps = []; _.each(db_tables, function (table_name) { - var output_ar = require(path.join(__dirname, 'export_data', table_name + '.json')); - t.equal(manifest[table_name].row_count, output_ar.length); + var output_def = q.defer(); + output_ps.push(output_def.promise); + + var outputStream = ndjson.parse(); + fs.createReadStream(path.join(__dirname, 'export_data', table_name + '.ndjson')).pipe(outputStream); + + output_ars[table_name] = []; + + outputStream.on('data', function (datum) { + output_ars[table_name].push(datum); + }); + + outputStream.on('end', function () { + t.equal(manifest[table_name].row_count, output_ars[table_name].length); + output_def.resolve(); + }); }); - var pool = new pg.Pool(conf.db); - pool.connect(function (err, client, done) { + q.all(output_ps).then(function () { + var pool = new pg.Pool(conf.db); + pool.connect(function (err, client, done) { - var query_promises = []; - _.each(db_tables, function (table_name) { - var query_def = q.defer(); - query_promises.push(query_def.promise) - var output_ar = require(path.join(__dirname, 'export_data', table_name + '.json')); - t.equal(manifest[table_name].row_count, output_ar.length); - var random_item = output_ar[parseInt(Math.random()*1000) % manifest[table_name].row_count]; + var query_promises = []; + _.each(db_tables, function (table_name) { - var where_ar = []; - _.each(manifest[table_name].primary_keys, function (pk_name) { - where_ar.push([pk_name, random_item[pk_name]].join(' = ')); - }); + var output_ar = output_ars[table_name]; + var query_def = q.defer(); + query_promises.push(query_def.promise) + + t.equal(manifest[table_name].row_count, output_ar.length); + var random_item = output_ar[parseInt(Math.random()*1000) % manifest[table_name].row_count]; + + var where_ar = []; + _.each(manifest[table_name].primary_keys, function (pk_name) { + where_ar.push([pk_name, random_item[pk_name]].join(' = ')); + }); - pool.query("SELECT * FROM " + table_name + " WHERE " + where_ar.join(' AND '), []).then(function (result) { - var row = result.rows[0]; - _.each(row, function (value, key) { - var _exp_v = random_item[key] - var _db_v = value; - - if(value instanceof Date){ - //some simple conversions for postgresql dates to javascript dates. - var psql_date = random_item[key]; - if(psql_date.length == 10) - psql_date += ' 00:00:00'; - var _d = new Date(psql_date.replace('T', ' ')); - - _exp_v = _d.getTime(); - _db_v = value.getTime(); - } - - if(value instanceof Uint8Array){ - //such a pain in the ass to test... - return; - } - - t.ok(_exp_v == _db_v); + pool.query("SELECT * FROM " + table_name + " WHERE " + where_ar.join(' AND '), []).then(function (result) { + var row = result.rows[0]; + _.each(row, function (value, key) { + var _exp_v = random_item[key] + var _db_v = value; + + if(value instanceof Date){ + //some simple conversions for postgresql dates to javascript dates. + var psql_date = random_item[key]; + if(psql_date.length == 10) + psql_date += ' 00:00:00'; + var _d = new Date(psql_date.replace('T', ' ')); + + _exp_v = _d.getTime(); + _db_v = value.getTime(); + } + + if(value instanceof Uint8Array){ + //such a pain in the ass to test... + return; + } + + t.ok(_exp_v == _db_v); + }); + query_def.resolve(); }); - query_def.resolve(); }); - }); - q.all(query_promises).then(function () { - done(); - pool.end().then(function () { - t.end(); + q.all(query_promises).then(function () { + done(); + pool.end().then(function () { + t.end(); + }); }); }); });