diff --git a/package.json b/package.json index d5e25e6..6a8f5e1 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,14 @@ "babel-core": "^6.18.2", "babel-loader": "^6.2.8", "babel-preset-es2015": "^6.18.0", + "bufferutil": "^1.2.1", + "ignore-loader": "^0.1.2", "json-loader": "^0.5.4", "parallel-webpack": "^1.5.0", + "utf-8-validate": "^1.2.1", "webpack": "^1.13.3" + }, + "browser": { + "ws": false } } diff --git a/src/Constants.js b/src/Constants.js index 8b7e76d..39210e7 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -71,7 +71,65 @@ module.exports.ChannelTypes = { GUILD_VOICE: 2 }; -module.exports.Endpoints = { - channelMessages: (cID) => `/channels/${cID}/messages`, - channelMessage: (cID, mID) => `/channels/${cID}/messages/${mID}` -} +// stolen from discord.js +const Endpoints = module.exports.Endpoints = { + // general + login: '/auth/login', + logout: '/auth/logout', + gateway: '/gateway', + botGateway: '/gateway/bot', + invite: (id) => `/invite/${id}`, + inviteLink: (id) => `https://discord.gg/${id}`, + CDN: 'https://cdn.discordapp.com', + + // users + user: (userID) => `/users/${userID}`, + userChannels: (userID) => `${Endpoints.user(userID)}/channels`, + userProfile: (userID) => `${Endpoints.user(userID)}/profile`, + avatar: (userID, avatar) => userID === '1' ? avatar : `${Endpoints.user(userID)}/avatars/${avatar}.jpg`, + me: '/users/@me', + meGuild: (guildID) => `${Endpoints.me}/guilds/${guildID}`, + relationships: (userID) => `${Endpoints.user(userID)}/relationships`, + note: (userID) => `${Endpoints.me}/notes/${userID}`, + + // guilds + guilds: '/guilds', + guild: (guildID) => `${Endpoints.guilds}/${guildID}`, + guildIcon: (guildID, hash) => `${Endpoints.guild(guildID)}/icons/${hash}.jpg`, + guildPrune: (guildID) => `${Endpoints.guild(guildID)}/prune`, + guildEmbed: (guildID) => `${Endpoints.guild(guildID)}/embed`, + guildInvites: (guildID) => `${Endpoints.guild(guildID)}/invites`, + guildRoles: (guildID) => `${Endpoints.guild(guildID)}/roles`, + guildRole: (guildID, roleID) => `${Endpoints.guildRoles(guildID)}/${roleID}`, + guildBans: (guildID) => `${Endpoints.guild(guildID)}/bans`, + guildIntegrations: (guildID) => `${Endpoints.guild(guildID)}/integrations`, + guildMembers: (guildID) => `${Endpoints.guild(guildID)}/members`, + guildMember: (guildID, memberID) => `${Endpoints.guildMembers(guildID)}/${memberID}`, + guildMemberRole: (guildID, memberID, roleID) => `${Endpoints.guildMember(guildID, memberID)}/roles/${roleID}}`, + stupidInconsistentGuildEndpoint: (guildID) => `${Endpoints.guildMember(guildID, '@me')}/nick`, + guildChannels: (guildID) => `${Endpoints.guild(guildID)}/channels`, + guildEmojis: (guildID) => `${Endpoints.guild(guildID)}/emojis`, + + // channels + channels: '/channels', + channel: (channelID) => `${Endpoints.channels}/${channelID}`, + channelMessages: (channelID) => `${Endpoints.channel(channelID)}/messages`, + channelInvites: (channelID) => `${Endpoints.channel(channelID)}/invites`, + channelTyping: (channelID) => `${Endpoints.channel(channelID)}/typing`, + channelPermissions: (channelID) => `${Endpoints.channel(channelID)}/permissions`, + channelMessage: (channelID, messageID) => `${Endpoints.channelMessages(channelID)}/${messageID}`, + channelWebhooks: (channelID) => `${Endpoints.channel(channelID)}/webhooks`, + + // message reactions + messageReactions: (channelID, messageID) => `${Endpoints.channelMessage(channelID, messageID)}/reactions`, + messageReaction: (channel, msg, emoji, limit) => `${Endpoints.messageReactions(channel, msg)}/${emoji}${limit ? `?limit=${limit}` : ''}`, + selfMessageReaction: (channel, msg, emoji, limit) => `${Endpoints.messageReaction(channel, msg, emoji, limit)}/@me`, + userMessageReaction: (channel, msg, emoji, limit, id) => `${Endpoints.messageReaction(channel, msg, emoji, limit)}/${id}`, + + // webhooks + webhook: (webhookID, token) => `/webhooks/${webhookID}${token ? `/${token}` : ''}`, + + // oauth + myApplication: '/oauth2/applications/@me', + getApp: (id) => `/oauth2/authorize?client_id=${id}` +}; diff --git a/webpack/rpc.1.1.2.js b/webpack/rpc.1.1.2.js index c7859fe..be29629 100644 --- a/webpack/rpc.1.1.2.js +++ b/webpack/rpc.1.1.2.js @@ -49,8 +49,8 @@ module.exports = { version: __webpack_require__(1).version, Client: __webpack_require__(2), - Rest: __webpack_require__(102), - Constants: __webpack_require__(93) + Rest: __webpack_require__(15), + Constants: __webpack_require__(5) }; if (typeof window !== 'undefined') window.DiscordRPC = module.exports; @@ -87,9 +87,15 @@ "babel-core": "^6.18.2", "babel-loader": "^6.2.8", "babel-preset-es2015": "^6.18.0", + "bufferutil": "^1.2.1", + "ignore-loader": "^0.1.2", "json-loader": "^0.5.4", "parallel-webpack": "^1.5.0", + "utf-8-validate": "^1.2.1", "webpack": "^1.13.3" + }, + "browser": { + "ws": false } }; @@ -109,17 +115,17 @@ */ var WebSocket = typeof window !== 'undefined' ? window.WebSocket : __webpack_require__(3); // eslint-disable-line no-undef - var EventEmitter = __webpack_require__(20).EventEmitter; + var EventEmitter = __webpack_require__(4).EventEmitter; - var _require = __webpack_require__(93), + var _require = __webpack_require__(5), RPCCommands = _require.RPCCommands, RPCEvents = _require.RPCEvents, RPCErrors = _require.RPCErrors; - var superagent = __webpack_require__(94); - var lodash = __webpack_require__(99); - var uuid = __webpack_require__(100).v4; - var RESTClient = __webpack_require__(102); + var superagent = __webpack_require__(6); + var lodash = __webpack_require__(11); + var uuid = __webpack_require__(13).v4; + var RESTClient = __webpack_require__(15); function getEventName(cmd, nonce, evt) { return cmd + ':' + (nonce || evt); @@ -396,21527 +402,320 @@ /***/ }, /* 3 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - /*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - var WS = module.exports = __webpack_require__(4); - - WS.Server = __webpack_require__(92); - WS.Sender = __webpack_require__(59); - WS.Receiver = __webpack_require__(85); - - /** - * Create a new WebSocket server. - * - * @param {Object} options Server options - * @param {Function} fn Optional connection listener. - * @returns {WS.Server} - * @api public - */ - WS.createServer = function createServer(options, fn) { - var server = new WS.Server(options); - - if (typeof fn === 'function') { - server.on('connection', fn); - } - - return server; - }; - - /** - * Create a new WebSocket connection. - * - * @param {String} address The URL/address we need to connect to. - * @param {Function} fn Open listener. - * @returns {WS} - * @api public - */ - WS.connect = WS.createConnection = function connect(address, fn) { - var client = new WS(address); - - if (typeof fn === 'function') { - client.on('open', fn); - } - - return client; - }; +/***/ function(module, exports) { + /* (ignored) */ /***/ }, /* 4 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer, process) {'use strict'; - - /*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - var url = __webpack_require__(10) - , util = __webpack_require__(16) - , http = __webpack_require__(19) - , https = __webpack_require__(40) - , crypto = __webpack_require__(41) - , stream = __webpack_require__(22) - , Ultron = __webpack_require__(56) - , Options = __webpack_require__(57) - , Sender = __webpack_require__(59) - , Receiver = __webpack_require__(85) - , SenderHixie = __webpack_require__(89) - , ReceiverHixie = __webpack_require__(90) - , Extensions = __webpack_require__(91) - , PerMessageDeflate = __webpack_require__(63) - , EventEmitter = __webpack_require__(20).EventEmitter; - - /** - * Constants - */ - - // Default protocol version - - var protocolVersion = 13; - - // Close timeout - - var closeTimeout = 30 * 1000; // Allow 30 seconds to terminate the connection cleanly - - /** - * WebSocket implementation - * - * @constructor - * @param {String} address Connection address. - * @param {String|Array} protocols WebSocket protocols. - * @param {Object} options Additional connection options. - * @api public - */ - function WebSocket(address, protocols, options) { - if (this instanceof WebSocket === false) { - return new WebSocket(address, protocols, options); - } - - EventEmitter.call(this); - - if (protocols && !Array.isArray(protocols) && 'object' === typeof protocols) { - // accept the "options" Object as the 2nd argument - options = protocols; - protocols = null; - } - - if ('string' === typeof protocols) { - protocols = [ protocols ]; - } +/***/ function(module, exports) { - if (!Array.isArray(protocols)) { - protocols = []; - } + // 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. - this._socket = null; - this._ultron = null; - this._closeReceived = false; - this.bytesReceived = 0; - this.readyState = null; - this.supports = {}; - this.extensions = {}; - this._binaryType = 'nodebuffer'; - - if (Array.isArray(address)) { - initAsServerClient.apply(this, address.concat(options)); - } else { - initAsClient.apply(this, [address, protocols, options]); - } + function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; } + module.exports = EventEmitter; - /** - * Inherits from EventEmitter. - */ - util.inherits(WebSocket, EventEmitter); - - /** - * Ready States - */ - ["CONNECTING", "OPEN", "CLOSING", "CLOSED"].forEach(function each(state, index) { - WebSocket.prototype[state] = WebSocket[state] = index; - }); - - /** - * Gracefully closes the connection, after sending a description message to the server - * - * @param {Object} data to be sent to the server - * @api public - */ - WebSocket.prototype.close = function close(code, data) { - if (this.readyState === WebSocket.CLOSED) return; - - if (this.readyState === WebSocket.CONNECTING) { - this.readyState = WebSocket.CLOSED; - return; - } - - if (this.readyState === WebSocket.CLOSING) { - if (this._closeReceived && this._isServer) { - this.terminate(); - } - return; - } - - var self = this; - try { - this.readyState = WebSocket.CLOSING; - this._closeCode = code; - this._closeMessage = data; - var mask = !this._isServer; - this._sender.close(code, data, mask, function(err) { - if (err) self.emit('error', err); - - if (self._closeReceived && self._isServer) { - self.terminate(); - } else { - // ensure that the connection is cleaned up even when no response of closing handshake. - clearTimeout(self._closeTimer); - self._closeTimer = setTimeout(cleanupWebsocketResources.bind(self, true), closeTimeout); - } - }); - } catch (e) { - this.emit('error', e); - } - }; - - /** - * Pause the client stream - * - * @api public - */ - WebSocket.prototype.pause = function pauser() { - if (this.readyState !== WebSocket.OPEN) throw new Error('not opened'); - - return this._socket.pause(); - }; - - /** - * Sends a ping - * - * @param {Object} data to be sent to the server - * @param {Object} Members - mask: boolean, binary: boolean - * @param {boolean} dontFailWhenClosed indicates whether or not to throw if the connection isnt open - * @api public - */ - WebSocket.prototype.ping = function ping(data, options, dontFailWhenClosed) { - if (this.readyState !== WebSocket.OPEN) { - if (dontFailWhenClosed === true) return; - throw new Error('not opened'); - } - - options = options || {}; - - if (typeof options.mask === 'undefined') options.mask = !this._isServer; - - this._sender.ping(data, options); - }; - - /** - * Sends a pong - * - * @param {Object} data to be sent to the server - * @param {Object} Members - mask: boolean, binary: boolean - * @param {boolean} dontFailWhenClosed indicates whether or not to throw if the connection isnt open - * @api public - */ - WebSocket.prototype.pong = function(data, options, dontFailWhenClosed) { - if (this.readyState !== WebSocket.OPEN) { - if (dontFailWhenClosed === true) return; - throw new Error('not opened'); - } - - options = options || {}; - - if (typeof options.mask === 'undefined') options.mask = !this._isServer; + // Backwards-compat with node 0.10.x + EventEmitter.EventEmitter = EventEmitter; - this._sender.pong(data, options); - }; + EventEmitter.prototype._events = undefined; + EventEmitter.prototype._maxListeners = undefined; - /** - * Resume the client stream - * - * @api public - */ - WebSocket.prototype.resume = function resume() { - if (this.readyState !== WebSocket.OPEN) throw new Error('not opened'); + // By default EventEmitters will print a warning if more than 10 listeners are + // added to it. This is a useful default which helps finding memory leaks. + EventEmitter.defaultMaxListeners = 10; - return this._socket.resume(); + // Obviously not all Emitters should be limited to 10. This function allows + // that to be increased. Set to zero for unlimited. + EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; }; - /** - * Sends a piece of data - * - * @param {Object} data to be sent to the server - * @param {Object} Members - mask: boolean, binary: boolean, compress: boolean - * @param {function} Optional callback which is executed after the send completes - * @api public - */ + EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; - WebSocket.prototype.send = function send(data, options, cb) { - if (typeof options === 'function') { - cb = options; - options = {}; - } + if (!this._events) + this._events = {}; - if (this.readyState !== WebSocket.OPEN) { - if (typeof cb === 'function') cb(new Error('not opened')); - else throw new Error('not opened'); - return; + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } } - if (!data) data = ''; - if (this._queue) { - var self = this; - this._queue.push(function() { self.send(data, options, cb); }); - return; - } + handler = this._events[type]; - options = options || {}; - options.fin = true; - - if (typeof options.binary === 'undefined') { - options.binary = (data instanceof ArrayBuffer || data instanceof Buffer || - data instanceof Uint8Array || - data instanceof Uint16Array || - data instanceof Uint32Array || - data instanceof Int8Array || - data instanceof Int16Array || - data instanceof Int32Array || - data instanceof Float32Array || - data instanceof Float64Array); - } + if (isUndefined(handler)) + return false; - if (typeof options.mask === 'undefined') options.mask = !this._isServer; - if (typeof options.compress === 'undefined') options.compress = true; - if (!this.extensions[PerMessageDeflate.extensionName]) { - options.compress = false; + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); } - var readable = typeof stream.Readable === 'function' - ? stream.Readable - : stream.Stream; - - if (data instanceof readable) { - startQueue(this); - var self = this; - - sendStream(this, data, options, function send(error) { - process.nextTick(function tock() { - executeQueueSends(self); - }); - - if (typeof cb === 'function') cb(error); - }); - } else { - this._sender.send(data, options, cb); - } + return true; }; - /** - * Streams data through calls to a user supplied function - * - * @param {Object} Members - mask: boolean, binary: boolean, compress: boolean - * @param {function} 'function (error, send)' which is executed on successive ticks of which send is 'function (data, final)'. - * @api public - */ - WebSocket.prototype.stream = function stream(options, cb) { - if (typeof options === 'function') { - cb = options; - options = {}; - } - - var self = this; - - if (typeof cb !== 'function') throw new Error('callback must be provided'); - - if (this.readyState !== WebSocket.OPEN) { - if (typeof cb === 'function') cb(new Error('not opened')); - else throw new Error('not opened'); - return; - } + EventEmitter.prototype.addListener = function(type, listener) { + var m; - if (this._queue) { - this._queue.push(function () { self.stream(options, cb); }); - return; - } + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - options = options || {}; + if (!this._events) + this._events = {}; - if (typeof options.mask === 'undefined') options.mask = !this._isServer; - if (typeof options.compress === 'undefined') options.compress = true; - if (!this.extensions[PerMessageDeflate.extensionName]) { - options.compress = false; - } + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); - startQueue(this); + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; - function send(data, final) { - try { - if (self.readyState !== WebSocket.OPEN) throw new Error('not opened'); - options.fin = final === true; - self._sender.send(data, options); - if (!final) process.nextTick(cb.bind(null, null, send)); - else executeQueueSends(self); - } catch (e) { - if (typeof cb === 'function') cb(e); - else { - delete self._queue; - self.emit('error', e); - } + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; } - } - - process.nextTick(cb.bind(null, null, send)); - }; - /** - * Immediately shuts down the connection - * - * @api public - */ - WebSocket.prototype.terminate = function terminate() { - if (this.readyState === WebSocket.CLOSED) return; - - if (this._socket) { - this.readyState = WebSocket.CLOSING; - - // End the connection - try { this._socket.end(); } - catch (e) { - // Socket error during end() call, so just destroy it right now - cleanupWebsocketResources.call(this, true); - return; - } - - // Add a timeout to ensure that the connection is completely - // cleaned up within 30 seconds, even if the clean close procedure - // fails for whatever reason - // First cleanup any pre-existing timeout from an earlier "terminate" call, - // if one exists. Otherwise terminate calls in quick succession will leak timeouts - // and hold the program open for `closeTimout` time. - if (this._closeTimer) { clearTimeout(this._closeTimer); } - this._closeTimer = setTimeout(cleanupWebsocketResources.bind(this, true), closeTimeout); - } else if (this.readyState === WebSocket.CONNECTING) { - cleanupWebsocketResources.call(this, true); - } - }; - - /** - * Expose bufferedAmount - * - * @api public - */ - Object.defineProperty(WebSocket.prototype, 'bufferedAmount', { - get: function get() { - var amount = 0; - if (this._socket) { - amount = this._socket.bufferSize || 0; - } - return amount; - } - }); - - /** - * Expose binaryType - * - * This deviates from the W3C interface since ws doesn't support the required - * default "blob" type (instead we define a custom "nodebuffer" type). - * - * @see http://dev.w3.org/html5/websockets/#the-websocket-interface - * @api public - */ - Object.defineProperty(WebSocket.prototype, 'binaryType', { - get: function get() { - return this._binaryType; - }, - set: function set(type) { - if (type === 'arraybuffer' || type === 'nodebuffer') - this._binaryType = type; - else - throw new SyntaxError('unsupported binaryType: must be either "nodebuffer" or "arraybuffer"'); - } - }); - - /** - * Emulates the W3C Browser based WebSocket interface using function members. - * - * @see http://dev.w3.org/html5/websockets/#the-websocket-interface - * @api public - */ - ['open', 'error', 'close', 'message'].forEach(function(method) { - Object.defineProperty(WebSocket.prototype, 'on' + method, { - /** - * Returns the current listener - * - * @returns {Mixed} the set function or undefined - * @api public - */ - get: function get() { - var listener = this.listeners(method)[0]; - return listener ? (listener._listener ? listener._listener : listener) : undefined; - }, - - /** - * Start listening for events - * - * @param {Function} listener the listener - * @returns {Mixed} the set function or undefined - * @api public - */ - set: function set(listener) { - this.removeAllListeners(method); - this.addEventListener(method, listener); - } - }); - }); - - /** - * Emulates the W3C Browser based WebSocket interface using addEventListener. - * - * @see https://developer.mozilla.org/en/DOM/element.addEventListener - * @see http://dev.w3.org/html5/websockets/#the-websocket-interface - * @api public - */ - WebSocket.prototype.addEventListener = function(method, listener) { - var target = this; - - function onMessage (data, flags) { - if (flags.binary && this.binaryType === 'arraybuffer') - data = new Uint8Array(data).buffer; - listener.call(target, new MessageEvent(data, !!flags.binary, target)); - } - - function onClose (code, message) { - listener.call(target, new CloseEvent(code, message, target)); - } - - function onError (event) { - event.type = 'error'; - event.target = target; - listener.call(target, event); - } - - function onOpen () { - listener.call(target, new OpenEvent(target)); - } - - if (typeof listener === 'function') { - if (method === 'message') { - // store a reference so we can return the original function from the - // addEventListener hook - onMessage._listener = listener; - this.on(method, onMessage); - } else if (method === 'close') { - // store a reference so we can return the original function from the - // addEventListener hook - onClose._listener = listener; - this.on(method, onClose); - } else if (method === 'error') { - // store a reference so we can return the original function from the - // addEventListener hook - onError._listener = listener; - this.on(method, onError); - } else if (method === 'open') { - // store a reference so we can return the original function from the - // addEventListener hook - onOpen._listener = listener; - this.on(method, onOpen); - } else { - this.on(method, listener); - } - } - }; - - module.exports = WebSocket; - module.exports.buildHostHeader = buildHostHeader - - /** - * W3C MessageEvent - * - * @see http://www.w3.org/TR/html5/comms.html - * @constructor - * @api private - */ - function MessageEvent(dataArg, isBinary, target) { - this.type = 'message'; - this.data = dataArg; - this.target = target; - this.binary = isBinary; // non-standard. - } - - /** - * W3C CloseEvent - * - * @see http://www.w3.org/TR/html5/comms.html - * @constructor - * @api private - */ - function CloseEvent(code, reason, target) { - this.type = 'close'; - this.wasClean = (typeof code === 'undefined' || code === 1000); - this.code = code; - this.reason = reason; - this.target = target; - } - - /** - * W3C OpenEvent - * - * @see http://www.w3.org/TR/html5/comms.html - * @constructor - * @api private - */ - function OpenEvent(target) { - this.type = 'open'; - this.target = target; - } - - // Append port number to Host header, only if specified in the url - // and non-default - function buildHostHeader(isSecure, hostname, port) { - var headerHost = hostname; - if (hostname) { - if ((isSecure && (port != 443)) || (!isSecure && (port != 80))){ - headerHost = headerHost + ':' + port; - } - } - return headerHost; - } - - /** - * Entirely private apis, - * which may or may not be bound to a sepcific WebSocket instance. - */ - function initAsServerClient(req, socket, upgradeHead, options) { - options = new Options({ - protocolVersion: protocolVersion, - protocol: null, - extensions: {}, - maxPayload: 0 - }).merge(options); - - // expose state properties - this.protocol = options.value.protocol; - this.protocolVersion = options.value.protocolVersion; - this.extensions = options.value.extensions; - this.supports.binary = (this.protocolVersion !== 'hixie-76'); - this.upgradeReq = req; - this.readyState = WebSocket.CONNECTING; - this._isServer = true; - this.maxPayload = options.value.maxPayload; - // establish connection - if (options.value.protocolVersion === 'hixie-76') { - establishConnection.call(this, ReceiverHixie, SenderHixie, socket, upgradeHead); - } else { - establishConnection.call(this, Receiver, Sender, socket, upgradeHead); - } - } - - function initAsClient(address, protocols, options) { - options = new Options({ - origin: null, - protocolVersion: protocolVersion, - host: null, - headers: null, - protocol: protocols.join(','), - agent: null, - - // ssl-related options - pfx: null, - key: null, - passphrase: null, - cert: null, - ca: null, - ciphers: null, - rejectUnauthorized: null, - perMessageDeflate: true, - localAddress: null - }).merge(options); - - if (options.value.protocolVersion !== 8 && options.value.protocolVersion !== 13) { - throw new Error('unsupported protocol version'); - } - - // verify URL and establish http class - var serverUrl = url.parse(address); - var isUnixSocket = serverUrl.protocol === 'ws+unix:'; - if (!serverUrl.host && !isUnixSocket) throw new Error('invalid url'); - var isSecure = serverUrl.protocol === 'wss:' || serverUrl.protocol === 'https:'; - var httpObj = isSecure ? https : http; - var port = serverUrl.port || (isSecure ? 443 : 80); - var auth = serverUrl.auth; - - // prepare extensions - var extensionsOffer = {}; - var perMessageDeflate; - if (options.value.perMessageDeflate) { - perMessageDeflate = new PerMessageDeflate(typeof options.value.perMessageDeflate !== true ? options.value.perMessageDeflate : {}, false); - extensionsOffer[PerMessageDeflate.extensionName] = perMessageDeflate.offer(); - } - - // expose state properties - this._isServer = false; - this.url = address; - this.protocolVersion = options.value.protocolVersion; - this.supports.binary = (this.protocolVersion !== 'hixie-76'); - - // begin handshake - var key = new Buffer(options.value.protocolVersion + '-' + Date.now()).toString('base64'); - var shasum = crypto.createHash('sha1'); - shasum.update(key + '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'); - var expectedServerKey = shasum.digest('base64'); - - var agent = options.value.agent; - - var headerHost = buildHostHeader(isSecure, serverUrl.hostname, port) - - var requestOptions = { - port: port, - host: serverUrl.hostname, - headers: { - 'Connection': 'Upgrade', - 'Upgrade': 'websocket', - 'Host': headerHost, - 'Sec-WebSocket-Version': options.value.protocolVersion, - 'Sec-WebSocket-Key': key - } - }; - - // If we have basic auth. - if (auth) { - requestOptions.headers.Authorization = 'Basic ' + new Buffer(auth).toString('base64'); - } - - if (options.value.protocol) { - requestOptions.headers['Sec-WebSocket-Protocol'] = options.value.protocol; - } - - if (options.value.host) { - requestOptions.headers.Host = options.value.host; - } - - if (options.value.headers) { - for (var header in options.value.headers) { - if (options.value.headers.hasOwnProperty(header)) { - requestOptions.headers[header] = options.value.headers[header]; - } - } - } - - if (Object.keys(extensionsOffer).length) { - requestOptions.headers['Sec-WebSocket-Extensions'] = Extensions.format(extensionsOffer); - } - - if (options.isDefinedAndNonNull('pfx') - || options.isDefinedAndNonNull('key') - || options.isDefinedAndNonNull('passphrase') - || options.isDefinedAndNonNull('cert') - || options.isDefinedAndNonNull('ca') - || options.isDefinedAndNonNull('ciphers') - || options.isDefinedAndNonNull('rejectUnauthorized')) { - - if (options.isDefinedAndNonNull('pfx')) requestOptions.pfx = options.value.pfx; - if (options.isDefinedAndNonNull('key')) requestOptions.key = options.value.key; - if (options.isDefinedAndNonNull('passphrase')) requestOptions.passphrase = options.value.passphrase; - if (options.isDefinedAndNonNull('cert')) requestOptions.cert = options.value.cert; - if (options.isDefinedAndNonNull('ca')) requestOptions.ca = options.value.ca; - if (options.isDefinedAndNonNull('ciphers')) requestOptions.ciphers = options.value.ciphers; - if (options.isDefinedAndNonNull('rejectUnauthorized')) requestOptions.rejectUnauthorized = options.value.rejectUnauthorized; - - if (!agent) { - // global agent ignores client side certificates - agent = new httpObj.Agent(requestOptions); - } - } - - requestOptions.path = serverUrl.path || '/'; - - if (agent) { - requestOptions.agent = agent; - } - - if (isUnixSocket) { - requestOptions.socketPath = serverUrl.pathname; - } - - if (options.value.localAddress) { - requestOptions.localAddress = options.value.localAddress; - } - - if (options.value.origin) { - if (options.value.protocolVersion < 13) requestOptions.headers['Sec-WebSocket-Origin'] = options.value.origin; - else requestOptions.headers.Origin = options.value.origin; - } - - var self = this; - var req = httpObj.request(requestOptions); - - req.on('error', function onerror(error) { - self.emit('error', error); - cleanupWebsocketResources.call(self, error); - }); - - req.once('response', function response(res) { - var error; - - if (!self.emit('unexpected-response', req, res)) { - error = new Error('unexpected server response (' + res.statusCode + ')'); - req.abort(); - self.emit('error', error); - } - - cleanupWebsocketResources.call(self, error); - }); - - req.once('upgrade', function upgrade(res, socket, upgradeHead) { - if (self.readyState === WebSocket.CLOSED) { - // client closed before server accepted connection - self.emit('close'); - self.removeAllListeners(); - socket.end(); - return; - } - - var serverKey = res.headers['sec-websocket-accept']; - if (typeof serverKey === 'undefined' || serverKey !== expectedServerKey) { - self.emit('error', 'invalid server key'); - self.removeAllListeners(); - socket.end(); - return; - } - - var serverProt = res.headers['sec-websocket-protocol']; - var protList = (options.value.protocol || "").split(/, */); - var protError = null; - - if (!options.value.protocol && serverProt) { - protError = 'server sent a subprotocol even though none requested'; - } else if (options.value.protocol && !serverProt) { - protError = 'server sent no subprotocol even though requested'; - } else if (serverProt && protList.indexOf(serverProt) === -1) { - protError = 'server responded with an invalid protocol'; - } - - if (protError) { - self.emit('error', protError); - self.removeAllListeners(); - socket.end(); - return; - } else if (serverProt) { - self.protocol = serverProt; - } - - var serverExtensions = Extensions.parse(res.headers['sec-websocket-extensions']); - if (perMessageDeflate && serverExtensions[PerMessageDeflate.extensionName]) { - try { - perMessageDeflate.accept(serverExtensions[PerMessageDeflate.extensionName]); - } catch (err) { - self.emit('error', 'invalid extension parameter'); - self.removeAllListeners(); - socket.end(); - return; - } - self.extensions[PerMessageDeflate.extensionName] = perMessageDeflate; - } - - establishConnection.call(self, Receiver, Sender, socket, upgradeHead); - - // perform cleanup on http resources - req.removeAllListeners(); - req = null; - agent = null; - }); - - req.end(); - this.readyState = WebSocket.CONNECTING; - } - - function establishConnection(ReceiverClass, SenderClass, socket, upgradeHead) { - var ultron = this._ultron = new Ultron(socket) - , called = false - , self = this; - - socket.setTimeout(0); - socket.setNoDelay(true); - - this._receiver = new ReceiverClass(this.extensions,this.maxPayload); - this._socket = socket; - - // socket cleanup handlers - ultron.on('end', cleanupWebsocketResources.bind(this)); - ultron.on('close', cleanupWebsocketResources.bind(this)); - ultron.on('error', cleanupWebsocketResources.bind(this)); - - // ensure that the upgradeHead is added to the receiver - function firstHandler(data) { - if (called || self.readyState === WebSocket.CLOSED) return; - - called = true; - socket.removeListener('data', firstHandler); - ultron.on('data', realHandler); - - if (upgradeHead && upgradeHead.length > 0) { - realHandler(upgradeHead); - upgradeHead = null; - } - - if (data) realHandler(data); - } - - // subsequent packets are pushed straight to the receiver - function realHandler(data) { - self.bytesReceived += data.length; - self._receiver.add(data); - } - - ultron.on('data', firstHandler); - - // if data was passed along with the http upgrade, - // this will schedule a push of that on to the receiver. - // this has to be done on next tick, since the caller - // hasn't had a chance to set event handlers on this client - // object yet. - process.nextTick(firstHandler); - - // receiver event handlers - self._receiver.ontext = function ontext(data, flags) { - flags = flags || {}; - - self.emit('message', data, flags); - }; - - self._receiver.onbinary = function onbinary(data, flags) { - flags = flags || {}; - - flags.binary = true; - self.emit('message', data, flags); - }; - - self._receiver.onping = function onping(data, flags) { - flags = flags || {}; - - self.pong(data, { - mask: !self._isServer, - binary: flags.binary === true - }, true); - - self.emit('ping', data, flags); - }; - - self._receiver.onpong = function onpong(data, flags) { - self.emit('pong', data, flags || {}); - }; - - self._receiver.onclose = function onclose(code, data, flags) { - flags = flags || {}; - - self._closeReceived = true; - self.close(code, data); - }; - - self._receiver.onerror = function onerror(reason, errorCode) { - // close the connection when the receiver reports a HyBi error code - self.close(typeof errorCode !== 'undefined' ? errorCode : 1002, ''); - self.emit('error', (reason instanceof Error) ? reason : (new Error(reason))); - }; - - // finalize the client - this._sender = new SenderClass(socket, this.extensions); - this._sender.on('error', function onerror(error) { - self.close(1002, ''); - self.emit('error', error); - }); - - this.readyState = WebSocket.OPEN; - this.emit('open'); - } - - function startQueue(instance) { - instance._queue = instance._queue || []; - } - - function executeQueueSends(instance) { - var queue = instance._queue; - if (typeof queue === 'undefined') return; - - delete instance._queue; - for (var i = 0, l = queue.length; i < l; ++i) { - queue[i](); - } - } - - function sendStream(instance, stream, options, cb) { - stream.on('data', function incoming(data) { - if (instance.readyState !== WebSocket.OPEN) { - if (typeof cb === 'function') cb(new Error('not opened')); - else { - delete instance._queue; - instance.emit('error', new Error('not opened')); - } - return; - } - - options.fin = false; - instance._sender.send(data, options); - }); - - stream.on('end', function end() { - if (instance.readyState !== WebSocket.OPEN) { - if (typeof cb === 'function') cb(new Error('not opened')); - else { - delete instance._queue; - instance.emit('error', new Error('not opened')); - } - return; - } - - options.fin = true; - instance._sender.send(null, options); - - if (typeof cb === 'function') cb(null); - }); - } - - function cleanupWebsocketResources(error) { - if (this.readyState === WebSocket.CLOSED) return; - - this.readyState = WebSocket.CLOSED; - - clearTimeout(this._closeTimer); - this._closeTimer = null; - - // If the connection was closed abnormally (with an error), or if - // the close control frame was not received then the close code - // must default to 1006. - if (error || !this._closeReceived) { - this._closeCode = 1006; - } - this.emit('close', this._closeCode || 1000, this._closeMessage || ''); - - if (this._socket) { - if (this._ultron) this._ultron.destroy(); - this._socket.on('error', function onerror() { - try { this.destroy(); } - catch (e) {} - }); - - try { - if (!error) this._socket.end(); - else this._socket.destroy(); - } catch (e) { /* Ignore termination errors */ } - - this._socket = null; - this._ultron = null; - } - - if (this._sender) { - this._sender.removeAllListeners(); - this._sender = null; - } - - if (this._receiver) { - this._receiver.cleanup(); - this._receiver = null; - } - - if (this.extensions[PerMessageDeflate.extensionName]) { - this.extensions[PerMessageDeflate.extensionName].cleanup(); - } - - this.extensions = null; - - this.removeAllListeners(); - this.on('error', function onerror() {}); // catch all errors after this - delete this._queue; - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer, __webpack_require__(9))) - -/***/ }, -/* 5 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer, global) {/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ - /* eslint-disable no-proto */ - - 'use strict' - - var base64 = __webpack_require__(6) - var ieee754 = __webpack_require__(7) - var isArray = __webpack_require__(8) - - exports.Buffer = Buffer - exports.SlowBuffer = SlowBuffer - exports.INSPECT_MAX_BYTES = 50 - - /** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * Due to various browser bugs, sometimes the Object implementation will be used even - * when the browser supports typed arrays. - * - * Note: - * - * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. - * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. - * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. - - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they - * get the Object implementation, which is slower but behaves correctly. - */ - Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined - ? global.TYPED_ARRAY_SUPPORT - : typedArraySupport() - - /* - * Export kMaxLength after typed array support is determined. - */ - exports.kMaxLength = kMaxLength() - - function typedArraySupport () { - try { - var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} - return arr.foo() === 42 && // typed array instances can be augmented - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` - } catch (e) { - return false - } - } - - function kMaxLength () { - return Buffer.TYPED_ARRAY_SUPPORT - ? 0x7fffffff - : 0x3fffffff - } - - function createBuffer (that, length) { - if (kMaxLength() < length) { - throw new RangeError('Invalid typed array length') - } - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = new Uint8Array(length) - that.__proto__ = Buffer.prototype - } else { - // Fallback: Return an object instance of the Buffer class - if (that === null) { - that = new Buffer(length) - } - that.length = length - } - - return that - } - - /** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ - - function Buffer (arg, encodingOrOffset, length) { - if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { - return new Buffer(arg, encodingOrOffset, length) - } - - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new Error( - 'If encoding is specified then the first argument must be a string' - ) - } - return allocUnsafe(this, arg) - } - return from(this, arg, encodingOrOffset, length) - } - - Buffer.poolSize = 8192 // not used by this implementation - - // TODO: Legacy, not needed anymore. Remove in next major version. - Buffer._augment = function (arr) { - arr.__proto__ = Buffer.prototype - return arr - } - - function from (that, value, encodingOrOffset, length) { - if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number') - } - - if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { - return fromArrayBuffer(that, value, encodingOrOffset, length) - } - - if (typeof value === 'string') { - return fromString(that, value, encodingOrOffset) - } - - return fromObject(that, value) - } - - /** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ - Buffer.from = function (value, encodingOrOffset, length) { - return from(null, value, encodingOrOffset, length) - } - - if (Buffer.TYPED_ARRAY_SUPPORT) { - Buffer.prototype.__proto__ = Uint8Array.prototype - Buffer.__proto__ = Uint8Array - if (typeof Symbol !== 'undefined' && Symbol.species && - Buffer[Symbol.species] === Buffer) { - // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true - }) - } - } - - function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be a number') - } else if (size < 0) { - throw new RangeError('"size" argument must not be negative') - } - } - - function alloc (that, size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(that, size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(that, size).fill(fill, encoding) - : createBuffer(that, size).fill(fill) - } - return createBuffer(that, size) - } - - /** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ - Buffer.alloc = function (size, fill, encoding) { - return alloc(null, size, fill, encoding) - } - - function allocUnsafe (that, size) { - assertSize(size) - that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < size; ++i) { - that[i] = 0 - } - } - return that - } - - /** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ - Buffer.allocUnsafe = function (size) { - return allocUnsafe(null, size) - } - /** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ - Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(null, size) - } - - function fromString (that, string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } - - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('"encoding" must be a valid string encoding') - } - - var length = byteLength(string, encoding) | 0 - that = createBuffer(that, length) - - var actual = that.write(string, encoding) - - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - that = that.slice(0, actual) - } - - return that - } - - function fromArrayLike (that, array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - that = createBuffer(that, length) - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that - } - - function fromArrayBuffer (that, array, byteOffset, length) { - array.byteLength // this throws if `array` is not a valid ArrayBuffer - - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('\'offset\' is out of bounds') - } - - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('\'length\' is out of bounds') - } - - if (byteOffset === undefined && length === undefined) { - array = new Uint8Array(array) - } else if (length === undefined) { - array = new Uint8Array(array, byteOffset) - } else { - array = new Uint8Array(array, byteOffset, length) - } - - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = array - that.__proto__ = Buffer.prototype - } else { - // Fallback: Return an object instance of the Buffer class - that = fromArrayLike(that, array) - } - return that - } - - function fromObject (that, obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - that = createBuffer(that, len) - - if (that.length === 0) { - return that - } - - obj.copy(that, 0, 0, len) - return that - } - - if (obj) { - if ((typeof ArrayBuffer !== 'undefined' && - obj.buffer instanceof ArrayBuffer) || 'length' in obj) { - if (typeof obj.length !== 'number' || isnan(obj.length)) { - return createBuffer(that, 0) - } - return fromArrayLike(that, obj) - } - - if (obj.type === 'Buffer' && isArray(obj.data)) { - return fromArrayLike(that, obj.data) - } - } - - throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') - } - - function checked (length) { - // Note: cannot use `length < kMaxLength()` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= kMaxLength()) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + kMaxLength().toString(16) + ' bytes') - } - return length | 0 - } - - function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) - } - - Buffer.isBuffer = function isBuffer (b) { - return !!(b != null && b._isBuffer) - } - - Buffer.compare = function compare (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers') - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 - } - - Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } - } - - Buffer.concat = function concat (list, length) { - if (!isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - - if (list.length === 0) { - return Buffer.alloc(0) - } - - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } - - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - buf.copy(buffer, pos) - pos += buf.length - } - return buffer - } - - function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && - (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { - return string.byteLength - } - if (typeof string !== 'string') { - string = '' + string - } - - var len = string.length - if (len === 0) return 0 - - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - case undefined: - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) return utf8ToBytes(string).length // assume utf8 - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } - } - Buffer.byteLength = byteLength - - function slowToString (encoding, start, end) { - var loweredCase = false - - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. - - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' - } - - if (end === undefined || end > this.length) { - end = this.length - } - - if (end <= 0) { - return '' - } - - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 - - if (end <= start) { - return '' - } - - if (!encoding) encoding = 'utf8' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } - } - - // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect - // Buffer instances. - Buffer.prototype._isBuffer = true - - function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i - } - - Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this - } - - Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) - } - return this - } - - Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this - } - - Buffer.prototype.toString = function toString () { - var length = this.length | 0 - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) - } - - Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 - } - - Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } - return '' - } - - Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (!Buffer.isBuffer(target)) { - throw new TypeError('Argument must be a Buffer') - } - - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } - - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } - - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } - - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 - - if (this === target) return 0 - - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) - - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) - - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 - } - - // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, - // OR the last index of `val` in `buffer` at offset <= `byteOffset`. - // - // Arguments: - // - buffer - a Buffer to search - // - val - a string, Buffer, or number - // - byteOffset - an index into `buffer`; will be clamped to an int32 - // - encoding - an optional encoding, relevant is val is a string - // - dir - true for indexOf, false for lastIndexOf - function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 - - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (isNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } - - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } - - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (Buffer.TYPED_ARRAY_SUPPORT && - typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } - } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } - - throw new TypeError('val must be string, number or Buffer') - } - - function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length - - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 - } - } - - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } - } - - var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i - } - } - - return -1 - } - - Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 - } - - Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) - } - - Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) - } - - function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - // must be an even number of digits - var strLen = string.length - if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (isNaN(parsed)) return i - buf[offset + i] = parsed - } - return i - } - - function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) - } - - function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) - } - - function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) - } - - function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) - } - - function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) - } - - Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset | 0 - if (isFinite(length)) { - length = length | 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - // legacy write(string, encoding, offset, length) - remove in v0.13 - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) - } - - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - return asciiWrite(this, string, offset, length) - - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } - } - - Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } - } - - function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } - } - - function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] - - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } - - res.push(codePoint) - i += bytesPerSequence - } - - return decodeCodePointsArray(res) - } - - // Based on http://stackoverflow.com/a/22747272/680742, the browser with - // the lowest limit is Chrome, with 0x10000 args. - // We go 1 magnitude less, for safety - var MAX_ARGUMENTS_LENGTH = 0x1000 - - function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res - } - - function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret - } - - function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) - } - return ret - } - - function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) - } - return out - } - - function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) - } - return res - } - - Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf - if (Buffer.TYPED_ARRAY_SUPPORT) { - newBuf = this.subarray(start, end) - newBuf.__proto__ = Buffer.prototype - } else { - var sliceLen = end - start - newBuf = new Buffer(sliceLen, undefined) - for (var i = 0; i < sliceLen; ++i) { - newBuf[i] = this[i + start] - } - } - - return newBuf - } - - /* - * Need to make sure that buffer isn't trying to write out of bounds. - */ - function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') - } - - Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val - } - - Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val - } - - Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] - } - - Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) - } - - Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] - } - - Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) - } - - Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) - } - - Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val - } - - Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val - } - - Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) - } - - Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val - } - - Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val - } - - Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) - } - - Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) - } - - Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) - } - - Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) - } - - Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) - } - - Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) - } - - function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') - } - - Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength - } - - Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength - } - - Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - this[offset] = (value & 0xff) - return offset + 1 - } - - function objectWriteUInt16 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { - buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> - (littleEndian ? i : 1 - i) * 8 - } - } - - Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } - return offset + 2 - } - - Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - } else { - objectWriteUInt16(this, value, offset, false) - } - return offset + 2 - } - - function objectWriteUInt32 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffffffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { - buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff - } - } - - Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, true) - } - return offset + 4 - } - - Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, false) - } - return offset + 4 - } - - Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength - } - - Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength - } - - Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 - } - - Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } - return offset + 2 - } - - Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - } else { - objectWriteUInt16(this, value, offset, false) - } - return offset + 2 - } - - Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - } else { - objectWriteUInt32(this, value, offset, true) - } - return offset + 4 - } - - Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, false) - } - return offset + 4 - } - - function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') - } - - function writeFloat (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 - } - - Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) - } - - Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) - } - - function writeDouble (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 - } - - Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) - } - - Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) - } - - // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) - Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - var len = end - start - var i - - if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] - } - } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { - // ascending copy from start - for (i = 0; i < len; ++i) { - target[i + targetStart] = this[i + start] - } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, start + len), - targetStart - ) - } - - return len - } - - // Usage: - // buffer.fill(number[, offset[, end]]) - // buffer.fill(buffer[, offset[, end]]) - // buffer.fill(string[, offset[, end]][, encoding]) - Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length - } - if (val.length === 1) { - var code = val.charCodeAt(0) - if (code < 256) { - val = code - } - } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') - } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - } else if (typeof val === 'number') { - val = val & 255 - } - - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } - - if (end <= start) { - return this - } - - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 - - if (!val) val = 0 - - var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val - } - } else { - var bytes = Buffer.isBuffer(val) - ? val - : utf8ToBytes(new Buffer(val, encoding).toString()) - var len = bytes.length - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] - } - } - - return this - } - - // HELPER FUNCTIONS - // ================ - - var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g - - function base64clean (str) { - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = stringtrim(str).replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str - } - - function stringtrim (str) { - if (str.trim) return str.trim() - return str.replace(/^\s+|\s+$/g, '') - } - - function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) - } - - function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes - } - - function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray - } - - function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray - } - - function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) - } - - function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i - } - - function isnan (val) { - return val !== val // eslint-disable-line no-self-compare - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer, (function() { return this; }()))) - -/***/ }, -/* 6 */ -/***/ function(module, exports) { - - 'use strict' - - exports.byteLength = byteLength - exports.toByteArray = toByteArray - exports.fromByteArray = fromByteArray - - var lookup = [] - var revLookup = [] - var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - - var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' - for (var i = 0, len = code.length; i < len; ++i) { - lookup[i] = code[i] - revLookup[code.charCodeAt(i)] = i - } - - revLookup['-'.charCodeAt(0)] = 62 - revLookup['_'.charCodeAt(0)] = 63 - - function placeHoldersCount (b64) { - var len = b64.length - if (len % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 - } - - function byteLength (b64) { - // base64 is 4/3 + up to two characters of the original data - return b64.length * 3 / 4 - placeHoldersCount(b64) - } - - function toByteArray (b64) { - var i, j, l, tmp, placeHolders, arr - var len = b64.length - placeHolders = placeHoldersCount(b64) - - 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) { - 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 - arr[L++] = tmp & 0xFF - } - - if (placeHolders === 2) { - tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[L++] = tmp & 0xFF - } else if (placeHolders === 1) { - tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF - } - - return arr - } - - function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] - } - - function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output.push(tripletToBase64(tmp)) - } - return output.join('') - } - - function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var output = '' - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 - - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - output += lookup[tmp >> 2] - output += lookup[(tmp << 4) & 0x3F] - output += '==' - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) - output += lookup[tmp >> 10] - output += lookup[(tmp >> 4) & 0x3F] - output += lookup[(tmp << 2) & 0x3F] - output += '=' - } - - parts.push(output) - - return parts.join('') - } - - -/***/ }, -/* 7 */ -/***/ function(module, exports) { - - exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = nBytes * 8 - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d - - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} - - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} - - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) - } - - exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = nBytes * 8 - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - - value = Math.abs(value) - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } - - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - - buffer[offset + i - d] |= s * 128 - } - - -/***/ }, -/* 8 */ -/***/ function(module, exports) { - - var toString = {}.toString; - - module.exports = Array.isArray || function (arr) { - return toString.call(arr) == '[object Array]'; - }; - - -/***/ }, -/* 9 */ -/***/ function(module, exports) { - - // shim for using process in browser - var process = module.exports = {}; - - // cached from whatever global is present so that test runners that stub it - // don't break things. But we need to wrap it in a try catch in case it is - // wrapped in strict mode code which doesn't define any globals. It's inside a - // function because try/catches deoptimize in certain engines. - - var cachedSetTimeout; - var cachedClearTimeout; - - function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); - } - function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); - } - (function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } - } ()) - function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - - } - function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - - } - var queue = []; - var draining = false; - var currentQueue; - var queueIndex = -1; - - function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } - } - - function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); - } - - process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } - }; - - // v8 likes predictible objects - function Item(fun, array) { - this.fun = fun; - this.array = array; - } - Item.prototype.run = function () { - this.fun.apply(null, this.array); - }; - process.title = 'browser'; - process.browser = true; - process.env = {}; - process.argv = []; - process.version = ''; // empty string to avoid regexp issues - process.versions = {}; - - function noop() {} - - process.on = noop; - process.addListener = noop; - process.once = noop; - process.off = noop; - process.removeListener = noop; - process.removeAllListeners = noop; - process.emit = noop; - - process.binding = function (name) { - throw new Error('process.binding is not supported'); - }; - - process.cwd = function () { return '/' }; - process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); - }; - process.umask = function() { return 0; }; - - -/***/ }, -/* 10 */ -/***/ function(module, exports, __webpack_require__) { - - // 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. - - var punycode = __webpack_require__(11); - - 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]*$/, - - // 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 = __webpack_require__(13); - - function urlParse(url, parseQueryString, slashesDenoteHost) { - if (url && 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 (!isString(url)) { - throw new TypeError("Parameter 'url' must be a string, not " + typeof url); - } - - var rest = url; - - // trim before proceeding. - // This is to support parse stuff like " http://foo.com \n" - rest = rest.trim(); - - 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; - } - } - - if (!hostlessProtocol[proto] && - (slashes || (proto && !slashedProtocol[proto]))) { - - // 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 - - // v0.12 TODO(isaacs): This is not quite how Chrome does things. - // Review our test case against browsers more comprehensively. - - // 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('@'); - } 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; - } - } - } - } - - if (this.hostname.length > hostnameMaxLen) { - this.hostname = ''; - } else { - // hostnames are always lower case. - this.hostname = this.hostname.toLowerCase(); - } - - if (!ipv6Hostname) { - // IDNA Support: Returns a puny coded representation of "domain". - // It only converts the part of the domain name that - // has non ASCII characters. I.e. it dosent matter if - // you call it with a domain that already is in ASCII. - var domainArray = this.hostname.split('.'); - var newOut = []; - for (var i = 0; i < domainArray.length; ++i) { - var s = domainArray[i]; - newOut.push(s.match(/[^A-Za-z0-9_-]/) ? - 'xn--' + punycode.encode(s) : s); - } - this.hostname = newOut.join('.'); - } - - 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; - } - } - } - - // 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]; - var esc = encodeURIComponent(ae); - if (esc === ae) { - esc = escape(ae); - } - rest = rest.split(ae).join(esc); - } - } - - - // 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); - } - 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 = '/'; - } - - //to support http.request - if (this.pathname || this.search) { - var p = this.pathname || ''; - var s = this.search || ''; - this.path = p + s; - } - - // 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 (isString(obj)) obj = urlParse(obj); - if (!(obj instanceof Url)) return Url.prototype.format.call(obj); - return obj.format(); - } - - Url.prototype.format = function() { - var auth = this.auth || ''; - if (auth) { - auth = encodeURIComponent(auth); - auth = auth.replace(/%3A/i, ':'); - auth += '@'; - } - - var protocol = this.protocol || '', - pathname = this.pathname || '', - hash = this.hash || '', - host = false, - query = ''; - - 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; - } - } - - if (this.query && - isObject(this.query) && - Object.keys(this.query).length) { - query = querystring.stringify(this.query); - } - - var search = this.search || (query && ('?' + query)) || ''; - - if (protocol && protocol.substr(-1) !== ':') protocol += ':'; - - // 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 = ''; - } - - if (hash && hash.charAt(0) !== '#') hash = '#' + hash; - if (search && search.charAt(0) !== '?') search = '?' + search; - - pathname = pathname.replace(/[?#]/g, function(match) { - return encodeURIComponent(match); - }); - search = search.replace('#', '%23'); - - return protocol + host + pathname + search + hash; - }; - - function urlResolve(source, relative) { - return urlParse(source, false, true).resolve(relative); - } - - Url.prototype.resolve = function(relative) { - return this.resolveObject(urlParse(relative, false, true)).format(); - }; - - function urlResolveObject(source, relative) { - if (!source) return relative; - return urlParse(source, false, true).resolveObject(relative); - } - - Url.prototype.resolveObject = function(relative) { - if (isString(relative)) { - var rel = new Url(); - rel.parse(relative, false, true); - relative = rel; - } - - var result = new Url(); - Object.keys(this).forEach(function(k) { - result[k] = this[k]; - }, this); - - // 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; - } - - // hrefs like //foo/bar always cut to the protocol. - if (relative.slashes && !relative.protocol) { - // take everything except the protocol from relative - Object.keys(relative).forEach(function(k) { - if (k !== 'protocol') - result[k] = relative[k]; - }); - - //urlParse appends trailing / to urls like http://www.example.com - if (slashedProtocol[result.protocol] && - result.hostname && !result.pathname) { - result.path = result.pathname = '/'; - } - - 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]) { - Object.keys(relative).forEach(function(k) { - result[k] = relative[k]; - }); - result.href = result.format(); - return result; - } - - 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('/'); - } 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; - } - - 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 (!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 especialy 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 (!isNull(result.pathname) || !isNull(result.search)) { - result.path = (result.pathname ? result.pathname : '') + - (result.search ? result.search : ''); - } - result.href = result.format(); - return result; - } - - 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; - } else { - result.path = null; - } - 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) && (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 the path is allowed to go above the root, restore leading ..s - if (!mustEndAbs && !removeAllDots) { - for (; up--; up) { - srcPath.unshift('..'); - } - } - - if (mustEndAbs && srcPath[0] !== '' && - (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { - srcPath.unshift(''); - } - - if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { - srcPath.push(''); - } - - var isAbsolute = srcPath[0] === '' || - (srcPath[0] && srcPath[0].charAt(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 especialy 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(); - } - } - - mustEndAbs = mustEndAbs || (result.host && srcPath.length); - - if (mustEndAbs && !isAbsolute) { - srcPath.unshift(''); - } - - if (!srcPath.length) { - result.pathname = null; - result.path = null; - } else { - result.pathname = srcPath.join('/'); - } - - //to support request.http - if (!isNull(result.pathname) || !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; - }; - - 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 isString(arg) { - return typeof arg === "string"; - } - - function isObject(arg) { - return typeof arg === 'object' && arg !== null; - } - - function isNull(arg) { - return arg === null; - } - function isNullOrUndefined(arg) { - return arg == null; - } - - -/***/ }, -/* 11 */ -/***/ function(module, exports, __webpack_require__) { - - var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module, global) {/*! https://mths.be/punycode v1.3.2 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 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. - * http://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.3.2', - /** - * 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 ( - true - ) { - !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { - return punycode; - }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else if (freeExports && freeModule) { - if (module.exports == freeExports) { // in Node.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)); - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(12)(module), (function() { return this; }()))) - -/***/ }, -/* 12 */ -/***/ function(module, exports) { - - module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - module.children = []; - module.webpackPolyfill = 1; - } - return module; - } - - -/***/ }, -/* 13 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.decode = exports.parse = __webpack_require__(14); - exports.encode = exports.stringify = __webpack_require__(15); - - -/***/ }, -/* 14 */ -/***/ function(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 (Array.isArray(obj[k])) { - obj[k].push(v); - } else { - obj[k] = [obj[k], v]; - } - } - - return obj; - }; - - -/***/ }, -/* 15 */ -/***/ function(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 Object.keys(obj).map(function(k) { - var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; - if (Array.isArray(obj[k])) { - return obj[k].map(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)); - }; - - -/***/ }, -/* 16 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(global, process) {// 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. - - 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 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]'; - } - 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; - }; - - - // 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 (process.noDeprecation === true) { - return fn; - } - - 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); - } - - return deprecated; - }; - - - 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 { - debugs[set] = function() {}; - } - } - return debugs[set]; - }; - - - /** - * 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; - } - } - - - function stylizeNoColor(str, styleType) { - return str; - } - - - function arrayToHash(array) { - var hash = {}; - - array.forEach(function(val, idx) { - hash[val] = true; - }); - - return hash; - } - - - 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); - } - return ret; - } - - // Primitive types cannot have properties - var primitive = formatPrimitive(ctx, value); - if (primitive) { - return primitive; - } - - // Look up the keys of the object. - var keys = Object.keys(value); - var visibleKeys = arrayToHash(keys); - - if (ctx.showHidden) { - keys = Object.getOwnPropertyNames(value); - } - - // 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); - } - - // 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); - } - } - - var base = '', array = false, braces = ['{', '}']; - - // Make Array say that they are Array - if (isArray(value)) { - array = true; - braces = ['[', ']']; - } - - // Make functions say that they are functions - if (isFunction(value)) { - var n = value.name ? ': ' + value.name : ''; - base = ' [Function' + n + ']'; - } - - // Make RegExps say that they are RegExps - if (isRegExp(value)) { - base = ' ' + RegExp.prototype.toString.call(value); - } - - // Make dates with properties first say the date - if (isDate(value)) { - base = ' ' + Date.prototype.toUTCString.call(value); - } - - // Make error with message first say the error - if (isError(value)) { - base = ' ' + formatError(value); - } - - if (keys.length === 0 && (!array || value.length == 0)) { - return braces[0] + base + braces[1]; - } - - if (recurseTimes < 0) { - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } else { - return ctx.stylize('[Object]', 'special'); - } - } - - ctx.seen.push(value); - - 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); - }); - } - - ctx.seen.pop(); - - return reduceToSingleString(output, base, braces); - } - - - 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'); - } - - - function formatError(value) { - return '[' + Error.prototype.toString.call(value) + ']'; - } - - - 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(''); - } - } - keys.forEach(function(key) { - if (!key.match(/^\d+$/)) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - key, true)); - } - }); - return output; - } - - - 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 { - str = ctx.stylize('[Getter]', 'special'); - } - } else { - if (desc.set) { - str = ctx.stylize('[Setter]', 'special'); - } - } - if (!hasOwnProperty(visibleKeys, key)) { - name = '[' + key + ']'; - } - 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 { - str = ctx.stylize('[Circular]', 'special'); - } - } - if (isUndefined(name)) { - if (array && key.match(/^\d+$/)) { - return str; - } - 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'); - } - } - - return name + ': ' + str; - } - - - 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); - - if (length > 60) { - return braces[0] + - (base === '' ? '' : base + '\n ') + - ' ' + - output.join(',\n ') + - ' ' + - braces[1]; - } - - return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; - } - - - // 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; - - function isBoolean(arg) { - return typeof arg === 'boolean'; - } - exports.isBoolean = isBoolean; - - function isNull(arg) { - return arg === null; - } - exports.isNull = isNull; - - function isNullOrUndefined(arg) { - return arg == null; - } - exports.isNullOrUndefined = isNullOrUndefined; - - function isNumber(arg) { - return typeof arg === 'number'; - } - exports.isNumber = isNumber; - - function isString(arg) { - return typeof arg === 'string'; - } - exports.isString = isString; - - function isSymbol(arg) { - return typeof arg === 'symbol'; - } - exports.isSymbol = isSymbol; - - function isUndefined(arg) { - return arg === void 0; - } - exports.isUndefined = isUndefined; - - function isRegExp(re) { - return isObject(re) && objectToString(re) === '[object RegExp]'; - } - exports.isRegExp = isRegExp; - - function isObject(arg) { - return typeof arg === 'object' && arg !== null; - } - exports.isObject = isObject; - - function isDate(d) { - return isObject(d) && objectToString(d) === '[object Date]'; - } - exports.isDate = isDate; - - 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 = __webpack_require__(17); - - 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)); - }; - - - /** - * Inherit the prototype methods from one constructor into another. - * - * 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 = __webpack_require__(18); - - 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]]; - } - return origin; - }; - - function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); - } - - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(9))) - -/***/ }, -/* 17 */ -/***/ function(module, exports) { - - module.exports = function isBuffer(arg) { - return arg && typeof arg === 'object' - && typeof arg.copy === 'function' - && typeof arg.fill === 'function' - && typeof arg.readUInt8 === 'function'; - } - -/***/ }, -/* 18 */ -/***/ function(module, exports) { - - if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; - } else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } - } - - -/***/ }, -/* 19 */ -/***/ function(module, exports, __webpack_require__) { - - var http = module.exports; - var EventEmitter = __webpack_require__(20).EventEmitter; - var Request = __webpack_require__(21); - var url = __webpack_require__(10) - - http.request = function (params, cb) { - if (typeof params === 'string') { - params = url.parse(params) - } - if (!params) params = {}; - if (!params.host && !params.port) { - params.port = parseInt(window.location.port, 10); - } - if (!params.host && params.hostname) { - params.host = params.hostname; - } - - if (!params.protocol) { - if (params.scheme) { - params.protocol = params.scheme + ':'; - } else { - params.protocol = window.location.protocol; - } - } - - if (!params.host) { - params.host = window.location.hostname || window.location.host; - } - if (/:/.test(params.host)) { - if (!params.port) { - params.port = params.host.split(':')[1]; - } - params.host = params.host.split(':')[0]; - } - if (!params.port) params.port = params.protocol == 'https:' ? 443 : 80; - - var req = new Request(new xhrHttp, params); - if (cb) req.on('response', cb); - return req; - }; - - http.get = function (params, cb) { - params.method = 'GET'; - var req = http.request(params, cb); - req.end(); - return req; - }; - - http.Agent = function () {}; - http.Agent.defaultMaxSockets = 4; - - var xhrHttp = (function () { - if (typeof window === 'undefined') { - throw new Error('no window object present'); - } - else if (window.XMLHttpRequest) { - return window.XMLHttpRequest; - } - else if (window.ActiveXObject) { - var axs = [ - 'Msxml2.XMLHTTP.6.0', - 'Msxml2.XMLHTTP.3.0', - 'Microsoft.XMLHTTP' - ]; - for (var i = 0; i < axs.length; i++) { - try { - var ax = new(window.ActiveXObject)(axs[i]); - return function () { - if (ax) { - var ax_ = ax; - ax = null; - return ax_; - } - else { - return new(window.ActiveXObject)(axs[i]); - } - }; - } - catch (e) {} - } - throw new Error('ajax not supported in this browser') - } - else { - throw new Error('ajax not supported in this browser'); - } - })(); - - http.STATUS_CODES = { - 100 : 'Continue', - 101 : 'Switching Protocols', - 102 : 'Processing', // RFC 2518, obsoleted by RFC 4918 - 200 : 'OK', - 201 : 'Created', - 202 : 'Accepted', - 203 : 'Non-Authoritative Information', - 204 : 'No Content', - 205 : 'Reset Content', - 206 : 'Partial Content', - 207 : 'Multi-Status', // RFC 4918 - 300 : 'Multiple Choices', - 301 : 'Moved Permanently', - 302 : 'Moved Temporarily', - 303 : 'See Other', - 304 : 'Not Modified', - 305 : 'Use Proxy', - 307 : 'Temporary 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 Time-out', - 409 : 'Conflict', - 410 : 'Gone', - 411 : 'Length Required', - 412 : 'Precondition Failed', - 413 : 'Request Entity Too Large', - 414 : 'Request-URI Too Large', - 415 : 'Unsupported Media Type', - 416 : 'Requested Range Not Satisfiable', - 417 : 'Expectation Failed', - 418 : 'I\'m a teapot', // RFC 2324 - 422 : 'Unprocessable Entity', // RFC 4918 - 423 : 'Locked', // RFC 4918 - 424 : 'Failed Dependency', // RFC 4918 - 425 : 'Unordered Collection', // RFC 4918 - 426 : 'Upgrade Required', // RFC 2817 - 428 : 'Precondition Required', // RFC 6585 - 429 : 'Too Many Requests', // RFC 6585 - 431 : 'Request Header Fields Too Large',// RFC 6585 - 500 : 'Internal Server Error', - 501 : 'Not Implemented', - 502 : 'Bad Gateway', - 503 : 'Service Unavailable', - 504 : 'Gateway Time-out', - 505 : 'HTTP Version Not Supported', - 506 : 'Variant Also Negotiates', // RFC 2295 - 507 : 'Insufficient Storage', // RFC 4918 - 509 : 'Bandwidth Limit Exceeded', - 510 : 'Not Extended', // RFC 2774 - 511 : 'Network Authentication Required' // RFC 6585 - }; - -/***/ }, -/* 20 */ -/***/ function(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. - - function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; - } - module.exports = EventEmitter; - - // Backwards-compat with node 0.10.x - EventEmitter.EventEmitter = EventEmitter; - - EventEmitter.prototype._events = undefined; - EventEmitter.prototype._maxListeners = undefined; - - // By default EventEmitters will print a warning if more than 10 listeners are - // added to it. This is a useful default which helps finding memory leaks. - EventEmitter.defaultMaxListeners = 10; - - // Obviously not all Emitters should be limited to 10. This function allows - // that to be increased. Set to zero for unlimited. - EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; - }; - - EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; - - if (!this._events) - this._events = {}; - - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } - } - - handler = this._events[type]; - - if (isUndefined(handler)) - return false; - - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); - } - - return true; - }; - - EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; - - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); - - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; - } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } - } - - return this; - }; - - EventEmitter.prototype.on = EventEmitter.prototype.addListener; - - EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); - - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } - - g.listener = listener; - this.on(type, g); - - return this; - }; - - // emits a 'removeListener' event iff the listener was removed - EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } - } - - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } - - return this; - }; - - EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } - - listeners = this._events[type]; - - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; - - return this; - }; - - EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; - }; - - EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; - - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; - } - return 0; - }; - - EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); - }; - - function isFunction(arg) { - return typeof arg === 'function'; - } - - function isNumber(arg) { - return typeof arg === 'number'; - } - - function isObject(arg) { - return typeof arg === 'object' && arg !== null; - } - - function isUndefined(arg) { - return arg === void 0; - } - - -/***/ }, -/* 21 */ -/***/ function(module, exports, __webpack_require__) { - - var Stream = __webpack_require__(22); - var Response = __webpack_require__(38); - var Base64 = __webpack_require__(39); - var inherits = __webpack_require__(23); - - var Request = module.exports = function (xhr, params) { - var self = this; - self.writable = true; - self.xhr = xhr; - self.body = []; - - self.uri = (params.protocol || 'http:') + '//' - + params.host - + (params.port ? ':' + params.port : '') - + (params.path || '/') - ; - - if (typeof params.withCredentials === 'undefined') { - params.withCredentials = true; - } - - try { xhr.withCredentials = params.withCredentials } - catch (e) {} - - if (params.responseType) try { xhr.responseType = params.responseType } - catch (e) {} - - xhr.open( - params.method || 'GET', - self.uri, - true - ); - - xhr.onerror = function(event) { - self.emit('error', new Error('Network error')); - }; - - self._headers = {}; - - if (params.headers) { - var keys = objectKeys(params.headers); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (!self.isSafeRequestHeader(key)) continue; - var value = params.headers[key]; - self.setHeader(key, value); - } - } - - if (params.auth) { - //basic auth - this.setHeader('Authorization', 'Basic ' + Base64.btoa(params.auth)); - } - - var res = new Response; - res.on('close', function () { - self.emit('close'); - }); - - res.on('ready', function () { - self.emit('response', res); - }); - - res.on('error', function (err) { - self.emit('error', err); - }); - - xhr.onreadystatechange = function () { - // Fix for IE9 bug - // SCRIPT575: Could not complete the operation due to error c00c023f - // It happens when a request is aborted, calling the success callback anyway with readyState === 4 - if (xhr.__aborted) return; - res.handle(xhr); - }; - }; - - inherits(Request, Stream); - - Request.prototype.setHeader = function (key, value) { - this._headers[key.toLowerCase()] = value - }; - - Request.prototype.getHeader = function (key) { - return this._headers[key.toLowerCase()] - }; - - Request.prototype.removeHeader = function (key) { - delete this._headers[key.toLowerCase()] - }; - - Request.prototype.write = function (s) { - this.body.push(s); - }; - - Request.prototype.destroy = function (s) { - this.xhr.__aborted = true; - this.xhr.abort(); - this.emit('close'); - }; - - Request.prototype.end = function (s) { - if (s !== undefined) this.body.push(s); - - var keys = objectKeys(this._headers); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - var value = this._headers[key]; - if (isArray(value)) { - for (var j = 0; j < value.length; j++) { - this.xhr.setRequestHeader(key, value[j]); - } - } - else this.xhr.setRequestHeader(key, value) - } - - if (this.body.length === 0) { - this.xhr.send(''); - } - else if (typeof this.body[0] === 'string') { - this.xhr.send(this.body.join('')); - } - else if (isArray(this.body[0])) { - var body = []; - for (var i = 0; i < this.body.length; i++) { - body.push.apply(body, this.body[i]); - } - this.xhr.send(body); - } - else if (/Array/.test(Object.prototype.toString.call(this.body[0]))) { - var len = 0; - for (var i = 0; i < this.body.length; i++) { - len += this.body[i].length; - } - var body = new(this.body[0].constructor)(len); - var k = 0; - - for (var i = 0; i < this.body.length; i++) { - var b = this.body[i]; - for (var j = 0; j < b.length; j++) { - body[k++] = b[j]; - } - } - this.xhr.send(body); - } - else if (isXHR2Compatible(this.body[0])) { - this.xhr.send(this.body[0]); - } - else { - var body = ''; - for (var i = 0; i < this.body.length; i++) { - body += this.body[i].toString(); - } - this.xhr.send(body); - } - }; - - // Taken from http://dxr.mozilla.org/mozilla/mozilla-central/content/base/src/nsXMLHttpRequest.cpp.html - Request.unsafeHeaders = [ - "accept-charset", - "accept-encoding", - "access-control-request-headers", - "access-control-request-method", - "connection", - "content-length", - "cookie", - "cookie2", - "content-transfer-encoding", - "date", - "expect", - "host", - "keep-alive", - "origin", - "referer", - "te", - "trailer", - "transfer-encoding", - "upgrade", - "user-agent", - "via" - ]; - - Request.prototype.isSafeRequestHeader = function (headerName) { - if (!headerName) return false; - return indexOf(Request.unsafeHeaders, headerName.toLowerCase()) === -1; - }; - - var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) keys.push(key); - return keys; - }; - - var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; - }; - - var indexOf = function (xs, x) { - if (xs.indexOf) return xs.indexOf(x); - for (var i = 0; i < xs.length; i++) { - if (xs[i] === x) return i; - } - return -1; - }; - - var isXHR2Compatible = function (obj) { - if (typeof Blob !== 'undefined' && obj instanceof Blob) return true; - if (typeof ArrayBuffer !== 'undefined' && obj instanceof ArrayBuffer) return true; - if (typeof FormData !== 'undefined' && obj instanceof FormData) return true; - }; - - -/***/ }, -/* 22 */ -/***/ function(module, exports, __webpack_require__) { - - // 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 = Stream; - - var EE = __webpack_require__(20).EventEmitter; - var inherits = __webpack_require__(23); - - inherits(Stream, EE); - Stream.Readable = __webpack_require__(24); - Stream.Writable = __webpack_require__(34); - Stream.Duplex = __webpack_require__(35); - Stream.Transform = __webpack_require__(36); - Stream.PassThrough = __webpack_require__(37); - - // Backwards-compat with node 0.4.x - Stream.Stream = Stream; - - - - // old-style streams. Note that the pipe method (the only relevant - // part of this class) is overridden in the Readable class. - - function Stream() { - EE.call(this); - } - - Stream.prototype.pipe = function(dest, options) { - var source = this; - - function ondata(chunk) { - if (dest.writable) { - if (false === dest.write(chunk) && source.pause) { - source.pause(); - } - } - } - - source.on('data', ondata); - - function ondrain() { - if (source.readable && source.resume) { - source.resume(); - } - } - - dest.on('drain', ondrain); - - // If the 'end' option is not supplied, dest.end() will be called when - // source gets the 'end' or 'close' events. Only dest.end() once. - if (!dest._isStdio && (!options || options.end !== false)) { - source.on('end', onend); - source.on('close', onclose); - } - - var didOnEnd = false; - function onend() { - if (didOnEnd) return; - didOnEnd = true; - - dest.end(); - } - - - function onclose() { - if (didOnEnd) return; - didOnEnd = true; - - if (typeof dest.destroy === 'function') dest.destroy(); - } - - // don't leave dangling pipes when there are errors. - function onerror(er) { - cleanup(); - if (EE.listenerCount(this, 'error') === 0) { - throw er; // Unhandled stream error in pipe. - } - } - - source.on('error', onerror); - dest.on('error', onerror); - - // remove all the event listeners that were added. - function cleanup() { - source.removeListener('data', ondata); - dest.removeListener('drain', ondrain); - - source.removeListener('end', onend); - source.removeListener('close', onclose); - - source.removeListener('error', onerror); - dest.removeListener('error', onerror); - - source.removeListener('end', cleanup); - source.removeListener('close', cleanup); - - dest.removeListener('close', cleanup); - } - - source.on('end', cleanup); - source.on('close', cleanup); - - dest.on('close', cleanup); - - dest.emit('pipe', source); - - // Allow for unix-like usage: A.pipe(B).pipe(C) - return dest; - }; - - -/***/ }, -/* 23 */ -/***/ function(module, exports) { - - if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; - } else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } - } - - -/***/ }, -/* 24 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {exports = module.exports = __webpack_require__(25); - exports.Stream = __webpack_require__(22); - exports.Readable = exports; - exports.Writable = __webpack_require__(30); - exports.Duplex = __webpack_require__(29); - exports.Transform = __webpack_require__(32); - exports.PassThrough = __webpack_require__(33); - if (!process.browser && process.env.READABLE_STREAM === 'disable') { - module.exports = __webpack_require__(22); - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) - -/***/ }, -/* 25 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {// 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; - - /**/ - var isArray = __webpack_require__(26); - /**/ - - - /**/ - var Buffer = __webpack_require__(5).Buffer; - /**/ - - Readable.ReadableState = ReadableState; - - var EE = __webpack_require__(20).EventEmitter; - - /**/ - if (!EE.listenerCount) EE.listenerCount = function(emitter, type) { - return emitter.listeners(type).length; - }; - /**/ - - var Stream = __webpack_require__(22); - - /**/ - var util = __webpack_require__(27); - util.inherits = __webpack_require__(23); - /**/ - - var StringDecoder; - - - /**/ - var debug = __webpack_require__(28); - if (debug && debug.debuglog) { - debug = debug.debuglog('stream'); - } else { - debug = function () {}; - } - /**/ - - - util.inherits(Readable, Stream); - - function ReadableState(options, stream) { - var Duplex = __webpack_require__(29); - - options = options || {}; - - // 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 = options.objectMode ? 16 : 16 * 1024; - this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; - - // cast to ints. - this.highWaterMark = ~~this.highWaterMark; - - this.buffer = []; - this.length = 0; - this.pipes = null; - this.pipesCount = 0; - this.flowing = null; - this.ended = false; - 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. - 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; - - - // 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.readableObjectMode; - - // 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; - - // if true, a maybeReadMore has been scheduled - this.readingMore = false; - - this.decoder = null; - this.encoding = null; - if (options.encoding) { - if (!StringDecoder) - StringDecoder = __webpack_require__(31).StringDecoder; - this.decoder = new StringDecoder(options.encoding); - this.encoding = options.encoding; - } - } - - function Readable(options) { - var Duplex = __webpack_require__(29); - - if (!(this instanceof Readable)) - return new Readable(options); - - this._readableState = new ReadableState(options, this); - - // legacy - this.readable = true; - - Stream.call(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; - - if (util.isString(chunk) && !state.objectMode) { - encoding = encoding || state.defaultEncoding; - if (encoding !== state.encoding) { - chunk = new Buffer(chunk, encoding); - encoding = ''; - } - } - - return readableAddChunk(this, state, chunk, encoding, false); - }; - - // 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 readableAddChunk(stream, state, chunk, encoding, addToFront) { - var er = chunkInvalid(state, chunk); - if (er) { - stream.emit('error', er); - } else if (util.isNullOrUndefined(chunk)) { - state.reading = false; - if (!state.ended) - 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 { - if (state.decoder && !addToFront && !encoding) - chunk = state.decoder.write(chunk); - - if (!addToFront) - state.reading = false; - - // 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); - - if (state.needReadable) - emitReadable(stream); - } - - maybeReadMore(stream, state); - } - } else if (!addToFront) { - state.reading = false; - } - - return needMoreData(state); - } - - - - // 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); - } - - // backwards compatibility. - Readable.prototype.setEncoding = function(enc) { - if (!StringDecoder) - StringDecoder = __webpack_require__(31).StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; - return this; - }; - - // Don't raise the hwm > 128MB - var MAX_HWM = 0x800000; - function roundUpToNextPowerOf2(n) { - if (n >= MAX_HWM) { - n = MAX_HWM; - } else { - // Get the next highest power of 2 - n--; - for (var p = 1; p < 32; p <<= 1) n |= n >> p; - n++; - } - return n; - } - - function howMuchToRead(n, state) { - if (state.length === 0 && state.ended) - return 0; - - if (state.objectMode) - return n === 0 ? 0 : 1; - - if (isNaN(n) || util.isNull(n)) { - // only flow one buffer at a time - if (state.flowing && state.buffer.length) - return state.buffer[0].length; - else - return state.length; - } - - if (n <= 0) - return 0; - - // If we're asking for more than the target buffer level, - // then raise the water mark. Bump up to the next highest - // power of 2, to prevent increasing it excessively in tiny - // amounts. - if (n > state.highWaterMark) - state.highWaterMark = roundUpToNextPowerOf2(n); - - // don't have that much. return null, unless we've ended. - if (n > state.length) { - if (!state.ended) { - state.needReadable = true; - return 0; - } else - return state.length; - } - - return n; - } - - // you can override either this method, or the async _read(n) below. - Readable.prototype.read = function(n) { - debug('read', n); - var state = this._readableState; - var nOrig = n; - - if (!util.isNumber(n) || 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; - } - - // 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); - } - - 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 (doRead && !state.reading) - n = howMuchToRead(nOrig, state); - - var ret; - if (n > 0) - ret = fromList(n, state); - else - ret = null; - - if (util.isNull(ret)) { - state.needReadable = true; - n = 0; - } - - state.length -= n; - - // If we have nothing in the buffer, then we want to know - // as soon as we *do* get something into the buffer. - if (state.length === 0 && !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 && state.length === 0) - endReadable(this); - - if (!util.isNull(ret)) - this.emit('data', ret); - - return ret; - }; - - function chunkInvalid(state, chunk) { - var er = null; - if (!util.isBuffer(chunk) && - !util.isString(chunk) && - !util.isNullOrUndefined(chunk) && - !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - return er; - } - - - function onEofChunk(stream, state) { - if (state.decoder && !state.ended) { - 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); - } - - // 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) - process.nextTick(function() { - emitReadable_(stream); - }); - else - emitReadable_(stream); - } - } - - function emitReadable_(stream) { - debug('emit readable'); - stream.emit('readable'); - flow(stream); - } - - - // 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; - process.nextTick(function() { - maybeReadMore_(stream, state); - }); - } - } - - 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; - } - - // 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('not implemented')); - }; - - Readable.prototype.pipe = function(dest, pipeOpts) { - var src = this; - var state = this._readableState; - - 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); - - var doEnd = (!pipeOpts || pipeOpts.end !== false) && - dest !== process.stdout && - dest !== process.stderr; - - var endFn = doEnd ? onend : cleanup; - if (state.endEmitted) - process.nextTick(endFn); - else - src.once('end', endFn); - - dest.on('unpipe', onunpipe); - function onunpipe(readable) { - debug('onunpipe'); - if (readable === src) { - cleanup(); - } - } - - 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); - - 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); - - // 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(); - } - - src.on('data', ondata); - function ondata(chunk) { - debug('ondata'); - var ret = dest.write(chunk); - if (false === ret) { - debug('false write response, pause', - src._readableState.awaitDrain); - src._readableState.awaitDrain++; - src.pause(); - } - } - - // 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 (EE.listenerCount(dest, 'error') === 0) - dest.emit('error', er); - } - // This is a brutally ugly hack to make sure that our error handler - // is attached before any userland ones. NEVER DO THIS. - if (!dest._events || !dest._events.error) - dest.on('error', onerror); - else if (isArray(dest._events.error)) - dest._events.error.unshift(onerror); - else - dest._events.error = [onerror, dest._events.error]; - - - - // 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; - }; - - function pipeOnDrain(src) { - return function() { - var state = src._readableState; - debug('pipeOnDrain', state.awaitDrain); - if (state.awaitDrain) - state.awaitDrain--; - if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) { - state.flowing = true; - flow(src); - } - }; - } - - - 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 i = indexOf(state.pipes, dest); - if (i === -1) - return this; - - state.pipes.splice(i, 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 listening to data, and it has not explicitly been paused, - // then call resume to start the flow of data on the next tick. - if (ev === 'data' && false !== this._readableState.flowing) { - this.resume(); - } - - if (ev === 'readable' && this.readable) { - var state = this._readableState; - if (!state.readableListening) { - state.readableListening = true; - state.emittedReadable = false; - state.needReadable = true; - if (!state.reading) { - var self = this; - process.nextTick(function() { - debug('readable nexttick read 0'); - self.read(0); - }); - } else if (state.length) { - emitReadable(this, state); - } - } - } - - return res; - }; - Readable.prototype.addListener = Readable.prototype.on; - - // 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; - if (!state.reading) { - debug('resume read 0'); - this.read(0); - } - resume(this, state); - } - return this; - }; - - function resume(stream, state) { - if (!state.resumeScheduled) { - state.resumeScheduled = true; - process.nextTick(function() { - resume_(stream, state); - }); - } - } - - function resume_(stream, state) { - state.resumeScheduled = false; - 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; - }; - - function flow(stream) { - var state = stream._readableState; - debug('flow', state.flowing); - if (state.flowing) { - do { - var chunk = stream.read(); - } while (null !== chunk && state.flowing); - } - } - - // 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); - if (!chunk || !state.objectMode && !chunk.length) - return; - - var ret = self.push(chunk); - if (!ret) { - paused = true; - stream.pause(); - } - }); - - // proxy all the other methods. - // important when wrapping filters and duplexes. - for (var i in stream) { - if (util.isFunction(stream[i]) && util.isUndefined(this[i])) { - 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)); - }); - - // 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; - }; - - - - // exposed for testing purposes only. - Readable._fromList = fromList; - - // Pluck off n bytes from an array of buffers. - // Length is the combined lengths of all the buffers in the list. - function fromList(n, state) { - var list = state.buffer; - var length = state.length; - var stringMode = !!state.decoder; - var objectMode = !!state.objectMode; - var ret; - - // nothing in the list, definitely empty. - if (list.length === 0) - return null; - - if (length === 0) - ret = null; - else if (objectMode) - ret = list.shift(); - else if (!n || n >= length) { - // read it all, truncate the array. - if (stringMode) - ret = list.join(''); - else - ret = Buffer.concat(list, length); - list.length = 0; - } else { - // read just some of it. - if (n < list[0].length) { - // just take a part of the first list item. - // slice is the same for buffers and strings. - var buf = list[0]; - ret = buf.slice(0, n); - list[0] = buf.slice(n); - } else if (n === list[0].length) { - // first list is a perfect match - ret = list.shift(); - } else { - // complex case. - // we have enough to cover it, but it spans past the first buffer. - if (stringMode) - ret = ''; - else - ret = new Buffer(n); - - var c = 0; - for (var i = 0, l = list.length; i < l && c < n; i++) { - var buf = list[0]; - var cpy = Math.min(n - c, buf.length); - - if (stringMode) - ret += buf.slice(0, cpy); - else - buf.copy(ret, c, 0, cpy); - - if (cpy < buf.length) - list[0] = buf.slice(cpy); - else - list.shift(); - - c += cpy; - } - } - } - - return ret; - } - - function endReadable(stream) { - var state = stream._readableState; - - // 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'); - - if (!state.endEmitted) { - state.ended = true; - process.nextTick(function() { - // Check that we didn't get one last unshift. - if (!state.endEmitted && state.length === 0) { - state.endEmitted = true; - stream.readable = false; - stream.emit('end'); - } - }); - } - } - - function forEach (xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xs[i], i); - } - } - - function indexOf (xs, x) { - for (var i = 0, l = xs.length; i < l; i++) { - if (xs[i] === x) return i; - } - return -1; - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) - -/***/ }, -/* 26 */ -/***/ function(module, exports) { - - module.exports = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) == '[object Array]'; - }; - - -/***/ }, -/* 27 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {// 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. - - // NOTE: These type checking functions intentionally don't use `instanceof` - // because it is fragile and can be easily faked with `Object.create()`. - - function isArray(arg) { - if (Array.isArray) { - return Array.isArray(arg); - } - return objectToString(arg) === '[object Array]'; - } - exports.isArray = isArray; - - function isBoolean(arg) { - return typeof arg === 'boolean'; - } - exports.isBoolean = isBoolean; - - function isNull(arg) { - return arg === null; - } - exports.isNull = isNull; - - function isNullOrUndefined(arg) { - return arg == null; - } - exports.isNullOrUndefined = isNullOrUndefined; - - function isNumber(arg) { - return typeof arg === 'number'; - } - exports.isNumber = isNumber; - - function isString(arg) { - return typeof arg === 'string'; - } - exports.isString = isString; - - function isSymbol(arg) { - return typeof arg === 'symbol'; - } - exports.isSymbol = isSymbol; - - function isUndefined(arg) { - return arg === void 0; - } - exports.isUndefined = isUndefined; - - function isRegExp(re) { - return objectToString(re) === '[object RegExp]'; - } - exports.isRegExp = isRegExp; - - function isObject(arg) { - return typeof arg === 'object' && arg !== null; - } - exports.isObject = isObject; - - function isDate(d) { - return objectToString(d) === '[object Date]'; - } - exports.isDate = isDate; - - function isError(e) { - return (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 = Buffer.isBuffer; - - function objectToString(o) { - return Object.prototype.toString.call(o); - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 28 */ -/***/ function(module, exports) { - - /* (ignored) */ - -/***/ }, -/* 29 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {// 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 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 - // Writable. - - module.exports = Duplex; - - /**/ - var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) keys.push(key); - return keys; - } - /**/ - - - /**/ - var util = __webpack_require__(27); - util.inherits = __webpack_require__(23); - /**/ - - var Readable = __webpack_require__(25); - var Writable = __webpack_require__(30); - - util.inherits(Duplex, Readable); - - forEach(objectKeys(Writable.prototype), function(method) { - if (!Duplex.prototype[method]) - Duplex.prototype[method] = Writable.prototype[method]; - }); - - function Duplex(options) { - if (!(this instanceof Duplex)) - return new Duplex(options); - - Readable.call(this, options); - Writable.call(this, options); - - if (options && options.readable === false) - this.readable = false; - - if (options && options.writable === false) - this.writable = false; - - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) - this.allowHalfOpen = false; - - this.once('end', onend); - } - - // the no-half-open enforcer - function onend() { - // if we allow half-open state, or if the writable side ended, - // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) - return; - - // no more data can be written. - // But allow more writes to happen in this tick. - process.nextTick(this.end.bind(this)); - } - - function forEach (xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xs[i], i); - } - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) - -/***/ }, -/* 30 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {// 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, cb), and it'll handle all - // the drain event emission and buffering. - - module.exports = Writable; - - /**/ - var Buffer = __webpack_require__(5).Buffer; - /**/ - - Writable.WritableState = WritableState; - - - /**/ - var util = __webpack_require__(27); - util.inherits = __webpack_require__(23); - /**/ - - var Stream = __webpack_require__(22); - - util.inherits(Writable, Stream); - - function WriteReq(chunk, encoding, cb) { - this.chunk = chunk; - this.encoding = encoding; - this.callback = cb; - } - - function WritableState(options, stream) { - var Duplex = __webpack_require__(29); - - options = options || {}; - - // 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 = options.objectMode ? 16 : 16 * 1024; - this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; - - // 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; - - // cast to ints. - this.highWaterMark = ~~this.highWaterMark; - - 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; - - // 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.buffer = []; - - // number of pending user-supplied write callbacks - // this must be 0 before 'finish' can be emitted - this.pendingcb = 0; - - // emit prefinish if the only thing we're waiting for is _write cbs - // This is relevant for synchronous Transform streams - this.prefinished = false; - - // True if the error was already emitted and should not be thrown again - this.errorEmitted = false; - } - - function Writable(options) { - var Duplex = __webpack_require__(29); - - // Writable ctor is applied to Duplexes, though they're not - // instanceof Writable, they're instanceof Readable. - if (!(this instanceof Writable) && !(this instanceof Duplex)) - return new Writable(options); - - this._writableState = new WritableState(options, this); - - // legacy. - this.writable = true; - - 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 writeAfterEnd(stream, state, cb) { - var er = new Error('write after end'); - // TODO: defer error events consistently everywhere, not just the cb - stream.emit('error', er); - process.nextTick(function() { - 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. - function validChunk(stream, state, chunk, cb) { - var valid = true; - if (!util.isBuffer(chunk) && - !util.isString(chunk) && - !util.isNullOrUndefined(chunk) && - !state.objectMode) { - var er = new TypeError('Invalid non-string/buffer chunk'); - stream.emit('error', er); - process.nextTick(function() { - cb(er); - }); - valid = false; - } - return valid; - } - - Writable.prototype.write = function(chunk, encoding, cb) { - var state = this._writableState; - var ret = false; - - if (util.isFunction(encoding)) { - cb = encoding; - encoding = null; - } - - if (util.isBuffer(chunk)) - encoding = 'buffer'; - else if (!encoding) - encoding = state.defaultEncoding; - - if (!util.isFunction(cb)) - cb = function() {}; - - if (state.ended) - writeAfterEnd(this, state, cb); - else if (validChunk(this, state, chunk, cb)) { - state.pendingcb++; - ret = writeOrBuffer(this, state, chunk, encoding, cb); - } - - return ret; - }; - - Writable.prototype.cork = function() { - var state = this._writableState; - - state.corked++; - }; - - Writable.prototype.uncork = function() { - var state = this._writableState; - - if (state.corked) { - state.corked--; - - if (!state.writing && - !state.corked && - !state.finished && - !state.bufferProcessing && - state.buffer.length) - clearBuffer(this, state); - } - }; - - function decodeChunk(state, chunk, encoding) { - if (!state.objectMode && - state.decodeStrings !== false && - util.isString(chunk)) { - chunk = new Buffer(chunk, encoding); - } - 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); - if (util.isBuffer(chunk)) - encoding = 'buffer'; - var len = state.objectMode ? 1 : chunk.length; - - state.length += len; - - var ret = state.length < state.highWaterMark; - // we must ensure that previous needDrain will not be reset to false. - if (!ret) - state.needDrain = true; - - if (state.writing || state.corked) - state.buffer.push(new WriteReq(chunk, encoding, cb)); - else - doWrite(stream, state, false, len, chunk, encoding, cb); - - return ret; - } - - 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; - } - - function onwriteError(stream, state, sync, er, cb) { - if (sync) - process.nextTick(function() { - state.pendingcb--; - cb(er); - }); - else { - state.pendingcb--; - cb(er); - } - - stream._writableState.errorEmitted = true; - stream.emit('error', er); - } - - 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); - - 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(stream, state); - - if (!finished && - !state.corked && - !state.bufferProcessing && - state.buffer.length) { - clearBuffer(stream, state); - } - - if (sync) { - process.nextTick(function() { - afterWrite(stream, state, finished, cb); - }); - } else { - afterWrite(stream, state, finished, cb); - } - } - } - - function afterWrite(stream, state, finished, cb) { - if (!finished) - onwriteDrain(stream, state); - state.pendingcb--; - cb(); - finishMaybe(stream, state); - } - - // 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 there's something in the buffer waiting, then process it - function clearBuffer(stream, state) { - state.bufferProcessing = true; - - if (stream._writev && state.buffer.length > 1) { - // Fast case, write everything using _writev() - var cbs = []; - for (var c = 0; c < state.buffer.length; c++) - cbs.push(state.buffer[c].callback); - - // count the one we are adding, as well. - // TODO(isaacs) clean this up - state.pendingcb++; - doWrite(stream, state, true, state.length, state.buffer, '', function(err) { - for (var i = 0; i < cbs.length; i++) { - state.pendingcb--; - cbs[i](err); - } - }); - - // Clear buffer - state.buffer = []; - } else { - // Slow case, write chunks one-by-one - for (var c = 0; c < state.buffer.length; c++) { - var entry = state.buffer[c]; - var chunk = entry.chunk; - var encoding = entry.encoding; - var cb = entry.callback; - var len = state.objectMode ? 1 : chunk.length; - - doWrite(stream, state, false, len, chunk, encoding, cb); - - // 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) { - c++; - break; - } - } - - if (c < state.buffer.length) - state.buffer = state.buffer.slice(c); - else - state.buffer.length = 0; - } - - state.bufferProcessing = false; - } - - Writable.prototype._write = function(chunk, encoding, cb) { - cb(new Error('not implemented')); - - }; - - Writable.prototype._writev = null; - - Writable.prototype.end = function(chunk, encoding, cb) { - var state = this._writableState; - - if (util.isFunction(chunk)) { - cb = chunk; - chunk = null; - encoding = null; - } else if (util.isFunction(encoding)) { - cb = encoding; - encoding = null; - } - - if (!util.isNullOrUndefined(chunk)) - this.write(chunk, encoding); - - // .end() fully uncorks - if (state.corked) { - state.corked = 1; - this.uncork(); - } - - // ignore unnecessary end() calls. - if (!state.ending && !state.finished) - endWritable(this, state, cb); - }; - - - function needFinish(stream, state) { - return (state.ending && - state.length === 0 && - !state.finished && - !state.writing); - } - - function prefinish(stream, state) { - if (!state.prefinished) { - state.prefinished = true; - stream.emit('prefinish'); - } - } - - function finishMaybe(stream, state) { - var need = needFinish(stream, state); - if (need) { - if (state.pendingcb === 0) { - prefinish(stream, state); - state.finished = true; - stream.emit('finish'); - } else - prefinish(stream, state); - } - return need; - } - - function endWritable(stream, state, cb) { - state.ending = true; - finishMaybe(stream, state); - if (cb) { - if (state.finished) - process.nextTick(cb); - else - stream.once('finish', cb); - } - state.ended = true; - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) - -/***/ }, -/* 31 */ -/***/ function(module, exports, __webpack_require__) { - - // 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. - - var Buffer = __webpack_require__(5).Buffer; - - 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; - } - } - - - function assertEncoding(encoding) { - if (encoding && !isBufferEncoding(encoding)) { - throw new Error('Unknown encoding: ' + encoding); - } - } - - // 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; - } - - // 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; - }; - - - // 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; - - // add the new bytes to the char buffer - buffer.copy(this.charBuffer, this.charReceived, 0, available); - this.charReceived += available; - - if (this.charReceived < this.charLength) { - // still not enough chars in this buffer? wait for more ... - return ''; - } - - // remove bytes belonging to the current character from the buffer - buffer = buffer.slice(available, buffer.length); - - // get the character that was split - charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); - - // 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; - - // if there are no more bytes in this buffer, just emit our char - if (buffer.length === 0) { - return charStr; - } - break; - } - - // determine and set charLength / charReceived - this.detectIncompleteChar(buffer); - - 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; - } - - charStr += buffer.toString(this.encoding, 0, end); - - 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); - } - - // or just emit the charStr - return charStr; - }; - - // 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]; - - // See http://en.wikipedia.org/wiki/UTF-8#Description - - // 110XXXXX - if (i == 1 && c >> 5 == 0x06) { - this.charLength = 2; - break; - } - - // 1110XXXX - if (i <= 2 && c >> 4 == 0x0E) { - this.charLength = 3; - break; - } - - // 11110XXX - if (i <= 3 && c >> 3 == 0x1E) { - this.charLength = 4; - break; - } - } - this.charReceived = i; - }; - - StringDecoder.prototype.end = function(buffer) { - var res = ''; - if (buffer && buffer.length) - res = this.write(buffer); - - if (this.charReceived) { - var cr = this.charReceived; - var buf = this.charBuffer; - var enc = this.encoding; - res += buf.slice(0, cr).toString(enc); - } - - return res; - }; - - function passThroughWrite(buffer) { - return buffer.toString(this.encoding); - } - - function utf16DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 2; - this.charLength = this.charReceived ? 2 : 0; - } - - function base64DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 3; - this.charLength = this.charReceived ? 3 : 0; - } - - -/***/ }, -/* 32 */ -/***/ function(module, exports, __webpack_require__) { - - // 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 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 - // some bits pass through, and others are simply ignored. (That would - // be a valid example of a transform, of course.) - // - // While the output is causally related to the input, it's not a - // necessarily symmetric or synchronous transformation. For example, - // a zlib stream might take multiple plain-text writes(), and then - // emit a single compressed chunk some time in the future. - // - // Here's how this works: - // - // The Transform stream has all the aspects of the readable and writable - // stream classes. When you write(chunk), that calls _write(chunk,cb) - // internally, and returns false if there's a lot of pending writes - // buffered up. When you call read(), that calls _read(n) until - // there's enough pending readable data buffered up. - // - // In a transform stream, the written data is placed in a buffer. When - // _read(n) is called, it transforms the queued up data, calling the - // buffered _write cb's as it consumes chunks. If consuming a single - // written chunk would result in multiple output chunks, then the first - // outputted bit calls the readcb, and subsequent chunks just go into - // the read buffer, and will cause it to emit 'readable' if necessary. - // - // This way, back-pressure is actually determined by the reading side, - // since _read has to be called to start processing a new chunk. However, - // a pathological inflate type of transform can cause excessive buffering - // here. For example, imagine a stream where every byte of input is - // interpreted as an integer from 0-255, and then results in that many - // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in - // 1kb of data being output. In this case, you could write a very small - // amount of input, and end up with a very large amount of output. In - // such a pathological inflating mechanism, there'd be no way to tell - // the system to stop doing the transform. A single 4MB write could - // cause the system to run out of memory. - // - // However, even in such a pathological case, only a single written chunk - // would be consumed, and then the rest would wait (un-transformed) until - // the results of the previous transformed chunk were consumed. - - module.exports = Transform; - - var Duplex = __webpack_require__(29); - - /**/ - var util = __webpack_require__(27); - util.inherits = __webpack_require__(23); - /**/ - - util.inherits(Transform, Duplex); - - - function TransformState(options, stream) { - this.afterTransform = function(er, data) { - return afterTransform(stream, er, data); - }; - - this.needTransform = false; - this.transforming = false; - this.writecb = null; - this.writechunk = null; - } - - function afterTransform(stream, er, data) { - var ts = stream._transformState; - ts.transforming = false; - - var cb = ts.writecb; - - if (!cb) - return stream.emit('error', new Error('no writecb in Transform class')); - - ts.writechunk = null; - ts.writecb = null; - - if (!util.isNullOrUndefined(data)) - stream.push(data); - - if (cb) - cb(er); - - var rs = stream._readableState; - rs.reading = false; - if (rs.needReadable || rs.length < rs.highWaterMark) { - stream._read(rs.highWaterMark); - } - } - - - function Transform(options) { - if (!(this instanceof Transform)) - return new Transform(options); - - Duplex.call(this, options); - - this._transformState = new TransformState(options, this); - - // when the writable side finishes, then flush out anything remaining. - var stream = this; - - // start out asking for a readable event once data is transformed. - this._readableState.needReadable = true; - - // we have implemented the _read method, and done the other things - // that Readable wants before the first _read call, so unset the - // sync guard flag. - this._readableState.sync = false; - - this.once('prefinish', function() { - if (util.isFunction(this._flush)) - this._flush(function(er) { - done(stream, er); - }); - else - done(stream); - }); - } - - Transform.prototype.push = function(chunk, encoding) { - this._transformState.needTransform = false; - return Duplex.prototype.push.call(this, chunk, encoding); - }; - - // This is the part where you do stuff! - // override this function in implementation classes. - // 'chunk' is an input chunk. - // - // Call `push(newChunk)` to pass along transformed output - // to the readable side. You may call 'push' zero or more times. - // - // Call `cb(err)` when you are done with this chunk. If you pass - // an error, then that'll put the hurt on the whole operation. If you - // never call cb(), then you'll never get another chunk. - Transform.prototype._transform = function(chunk, encoding, cb) { - throw new Error('not implemented'); - }; - - Transform.prototype._write = function(chunk, encoding, cb) { - var ts = this._transformState; - ts.writecb = cb; - ts.writechunk = chunk; - ts.writeencoding = encoding; - if (!ts.transforming) { - var rs = this._readableState; - if (ts.needTransform || - rs.needReadable || - rs.length < rs.highWaterMark) - this._read(rs.highWaterMark); - } - }; - - // Doesn't matter what the args are here. - // _transform does all the work. - // That we got here means that the readable side wants more data. - Transform.prototype._read = function(n) { - var ts = this._transformState; - - if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) { - ts.transforming = true; - this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); - } else { - // mark that we need a transform, so that any data that comes in - // will get processed, now that we've asked for it. - ts.needTransform = true; - } - }; - - - function done(stream, er) { - if (er) - return stream.emit('error', er); - - // if there's nothing in the write buffer, then that means - // that nothing more will ever be provided - var ws = stream._writableState; - var ts = stream._transformState; - - if (ws.length) - throw new Error('calling transform done when ws.length != 0'); - - if (ts.transforming) - throw new Error('calling transform done when still transforming'); - - return stream.push(null); - } - - -/***/ }, -/* 33 */ -/***/ function(module, exports, __webpack_require__) { - - // 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. - - module.exports = PassThrough; - - var Transform = __webpack_require__(32); - - /**/ - var util = __webpack_require__(27); - util.inherits = __webpack_require__(23); - /**/ - - util.inherits(PassThrough, Transform); - - function PassThrough(options) { - if (!(this instanceof PassThrough)) - return new PassThrough(options); - - Transform.call(this, options); - } - - PassThrough.prototype._transform = function(chunk, encoding, cb) { - cb(null, chunk); - }; - - -/***/ }, -/* 34 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(30) - - -/***/ }, -/* 35 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(29) - - -/***/ }, -/* 36 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(32) - - -/***/ }, -/* 37 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(33) - - -/***/ }, -/* 38 */ -/***/ function(module, exports, __webpack_require__) { - - var Stream = __webpack_require__(22); - var util = __webpack_require__(16); - - var Response = module.exports = function (res) { - this.offset = 0; - this.readable = true; - }; - - util.inherits(Response, Stream); - - var capable = { - streaming : true, - status2 : true - }; - - function parseHeaders (res) { - var lines = res.getAllResponseHeaders().split(/\r?\n/); - var headers = {}; - for (var i = 0; i < lines.length; i++) { - var line = lines[i]; - if (line === '') continue; - - var m = line.match(/^([^:]+):\s*(.*)/); - if (m) { - var key = m[1].toLowerCase(), value = m[2]; - - if (headers[key] !== undefined) { - - if (isArray(headers[key])) { - headers[key].push(value); - } - else { - headers[key] = [ headers[key], value ]; - } - } - else { - headers[key] = value; - } - } - else { - headers[line] = true; - } - } - return headers; - } - - Response.prototype.getResponse = function (xhr) { - var respType = String(xhr.responseType).toLowerCase(); - if (respType === 'blob') return xhr.responseBlob || xhr.response; - if (respType === 'arraybuffer') return xhr.response; - return xhr.responseText; - } - - Response.prototype.getHeader = function (key) { - return this.headers[key.toLowerCase()]; - }; - - Response.prototype.handle = function (res) { - if (res.readyState === 2 && capable.status2) { - try { - this.statusCode = res.status; - this.headers = parseHeaders(res); - } - catch (err) { - capable.status2 = false; - } - - if (capable.status2) { - this.emit('ready'); - } - } - else if (capable.streaming && res.readyState === 3) { - try { - if (!this.statusCode) { - this.statusCode = res.status; - this.headers = parseHeaders(res); - this.emit('ready'); - } - } - catch (err) {} - - try { - this._emitData(res); - } - catch (err) { - capable.streaming = false; - } - } - else if (res.readyState === 4) { - if (!this.statusCode) { - this.statusCode = res.status; - this.emit('ready'); - } - this._emitData(res); - - if (res.error) { - this.emit('error', this.getResponse(res)); - } - else this.emit('end'); - - this.emit('close'); - } - }; - - Response.prototype._emitData = function (res) { - var respBody = this.getResponse(res); - if (respBody.toString().match(/ArrayBuffer/)) { - this.emit('data', new Uint8Array(respBody, this.offset)); - this.offset = respBody.byteLength; - return; - } - if (respBody.length > this.offset) { - this.emit('data', respBody.slice(this.offset)); - this.offset = respBody.length; - } - }; - - var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; - }; - - -/***/ }, -/* 39 */ -/***/ function(module, exports, __webpack_require__) { - - ;(function () { - - var object = true ? exports : this; // #8: web workers - var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - - function InvalidCharacterError(message) { - this.message = message; - } - InvalidCharacterError.prototype = new Error; - InvalidCharacterError.prototype.name = 'InvalidCharacterError'; - - // encoder - // [https://gist.github.com/999166] by [https://github.com/nignag] - object.btoa || ( - object.btoa = function (input) { - for ( - // initialize result and counter - var block, charCode, idx = 0, map = chars, output = ''; - // if the next input index does not exist: - // change the mapping table to "=" - // check if d has no fractional digits - input.charAt(idx | 0) || (map = '=', idx % 1); - // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8 - output += map.charAt(63 & block >> 8 - idx % 1 * 8) - ) { - charCode = input.charCodeAt(idx += 3/4); - if (charCode > 0xFF) { - throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range."); - } - block = block << 8 | charCode; - } - return output; - }); - - // decoder - // [https://gist.github.com/1020396] by [https://github.com/atk] - object.atob || ( - object.atob = function (input) { - input = input.replace(/=+$/, ''); - if (input.length % 4 == 1) { - throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded."); - } - for ( - // initialize result and counters - var bc = 0, bs, buffer, idx = 0, output = ''; - // get next character - buffer = input.charAt(idx++); - // character found in table? initialize bit storage and add its ascii value; - ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, - // and if not first of each 4 characters, - // convert the first 8 bits to one ascii character - bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 - ) { - // try to find character in table (0-63, not found => -1) - buffer = chars.indexOf(buffer); - } - return output; - }); - - }()); - - -/***/ }, -/* 40 */ -/***/ function(module, exports, __webpack_require__) { - - var http = __webpack_require__(19); - - 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'; - return http.request.call(this, params, cb); - } - - -/***/ }, -/* 41 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {var rng = __webpack_require__(42) - - function error () { - var m = [].slice.call(arguments).join(' ') - throw new Error([ - m, - 'we accept pull requests', - 'http://github.com/dominictarr/crypto-browserify' - ].join('\n')) - } - - exports.createHash = __webpack_require__(44) - - exports.createHmac = __webpack_require__(53) - - exports.randomBytes = function(size, callback) { - if (callback && callback.call) { - try { - callback.call(this, undefined, new Buffer(rng(size))) - } catch (err) { callback(err) } - } else { - return new Buffer(rng(size)) - } - } - - function each(a, f) { - for(var i in a) - f(a[i], i) - } - - exports.getHashes = function () { - return ['sha1', 'sha256', 'sha512', 'md5', 'rmd160'] - } - - var p = __webpack_require__(54)(exports) - exports.pbkdf2 = p.pbkdf2 - exports.pbkdf2Sync = p.pbkdf2Sync - - - // the least I can do is make error messages for the rest of the node.js/crypto api. - each(['createCredentials' - , 'createCipher' - , 'createCipheriv' - , 'createDecipher' - , 'createDecipheriv' - , 'createSign' - , 'createVerify' - , 'createDiffieHellman' - ], function (name) { - exports[name] = function () { - error('sorry,', name, 'is not implemented yet') - } - }) - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 42 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(global, Buffer) {(function() { - var g = ('undefined' === typeof window ? global : window) || {} - _crypto = ( - g.crypto || g.msCrypto || __webpack_require__(43) - ) - module.exports = function(size) { - // Modern Browsers - if(_crypto.getRandomValues) { - var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array - /* This will not work in older browsers. - * See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues - */ - - _crypto.getRandomValues(bytes); - return bytes; - } - else if (_crypto.randomBytes) { - return _crypto.randomBytes(size) - } - else - throw new Error( - 'secure random number generation not supported by this browser\n'+ - 'use chrome, FireFox or Internet Explorer 11' - ) - } - }()) - - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(5).Buffer)) - -/***/ }, -/* 43 */ -/***/ function(module, exports) { - - /* (ignored) */ - -/***/ }, -/* 44 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(45) - - var md5 = toConstructor(__webpack_require__(50)) - var rmd160 = toConstructor(__webpack_require__(52)) - - function toConstructor (fn) { - return function () { - var buffers = [] - var m= { - update: function (data, enc) { - if(!Buffer.isBuffer(data)) data = new Buffer(data, enc) - buffers.push(data) - return this - }, - digest: function (enc) { - var buf = Buffer.concat(buffers) - var r = fn(buf) - buffers = null - return enc ? r.toString(enc) : r - } - } - return m - } - } - - module.exports = function (alg) { - if('md5' === alg) return new md5() - if('rmd160' === alg) return new rmd160() - return createHash(alg) - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 45 */ -/***/ function(module, exports, __webpack_require__) { - - var exports = module.exports = function (alg) { - var Alg = exports[alg] - if(!Alg) throw new Error(alg + ' is not supported (we accept pull requests)') - return new Alg() - } - - var Buffer = __webpack_require__(5).Buffer - var Hash = __webpack_require__(46)(Buffer) - - exports.sha1 = __webpack_require__(47)(Buffer, Hash) - exports.sha256 = __webpack_require__(48)(Buffer, Hash) - exports.sha512 = __webpack_require__(49)(Buffer, Hash) - - -/***/ }, -/* 46 */ -/***/ function(module, exports) { - - module.exports = function (Buffer) { - - //prototype class for hash functions - function Hash (blockSize, finalSize) { - this._block = new Buffer(blockSize) //new Uint32Array(blockSize/4) - this._finalSize = finalSize - this._blockSize = blockSize - this._len = 0 - this._s = 0 - } - - Hash.prototype.init = function () { - this._s = 0 - this._len = 0 - } - - Hash.prototype.update = function (data, enc) { - if ("string" === typeof data) { - enc = enc || "utf8" - data = new Buffer(data, enc) - } - - var l = this._len += data.length - var s = this._s = (this._s || 0) - var f = 0 - var buffer = this._block - - while (s < l) { - var t = Math.min(data.length, f + this._blockSize - (s % this._blockSize)) - var ch = (t - f) - - for (var i = 0; i < ch; i++) { - buffer[(s % this._blockSize) + i] = data[i + f] - } - - s += ch - f += ch - - if ((s % this._blockSize) === 0) { - this._update(buffer) - } - } - this._s = s - - return this - } - - Hash.prototype.digest = function (enc) { - // Suppose the length of the message M, in bits, is l - var l = this._len * 8 - - // Append the bit 1 to the end of the message - this._block[this._len % this._blockSize] = 0x80 - - // and then k zero bits, where k is the smallest non-negative solution to the equation (l + 1 + k) === finalSize mod blockSize - this._block.fill(0, this._len % this._blockSize + 1) - - if (l % (this._blockSize * 8) >= this._finalSize * 8) { - this._update(this._block) - this._block.fill(0) - } - - // to this append the block which is equal to the number l written in binary - // TODO: handle case where l is > Math.pow(2, 29) - this._block.writeInt32BE(l, this._blockSize - 4) - - var hash = this._update(this._block) || this._hash() - - return enc ? hash.toString(enc) : hash - } - - Hash.prototype._update = function () { - throw new Error('_update must be implemented by subclass') - } - - return Hash - } - - -/***/ }, -/* 47 */ -/***/ function(module, exports, __webpack_require__) { - - /* - * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined - * in FIPS PUB 180-1 - * Version 2.1a Copyright Paul Johnston 2000 - 2002. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * Distributed under the BSD License - * See http://pajhome.org.uk/crypt/md5 for details. - */ - - var inherits = __webpack_require__(16).inherits - - module.exports = function (Buffer, Hash) { - - var A = 0|0 - var B = 4|0 - var C = 8|0 - var D = 12|0 - var E = 16|0 - - var W = new (typeof Int32Array === 'undefined' ? Array : Int32Array)(80) - - var POOL = [] - - function Sha1 () { - if(POOL.length) - return POOL.pop().init() - - if(!(this instanceof Sha1)) return new Sha1() - this._w = W - Hash.call(this, 16*4, 14*4) - - this._h = null - this.init() - } - - inherits(Sha1, Hash) - - Sha1.prototype.init = function () { - this._a = 0x67452301 - this._b = 0xefcdab89 - this._c = 0x98badcfe - this._d = 0x10325476 - this._e = 0xc3d2e1f0 - - Hash.prototype.init.call(this) - return this - } - - Sha1.prototype._POOL = POOL - Sha1.prototype._update = function (X) { - - var a, b, c, d, e, _a, _b, _c, _d, _e - - a = _a = this._a - b = _b = this._b - c = _c = this._c - d = _d = this._d - e = _e = this._e - - var w = this._w - - for(var j = 0; j < 80; j++) { - var W = w[j] = j < 16 ? X.readInt32BE(j*4) - : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1) - - var t = add( - add(rol(a, 5), sha1_ft(j, b, c, d)), - add(add(e, W), sha1_kt(j)) - ) - - e = d - d = c - c = rol(b, 30) - b = a - a = t - } - - this._a = add(a, _a) - this._b = add(b, _b) - this._c = add(c, _c) - this._d = add(d, _d) - this._e = add(e, _e) - } - - Sha1.prototype._hash = function () { - if(POOL.length < 100) POOL.push(this) - var H = new Buffer(20) - //console.log(this._a|0, this._b|0, this._c|0, this._d|0, this._e|0) - H.writeInt32BE(this._a|0, A) - H.writeInt32BE(this._b|0, B) - H.writeInt32BE(this._c|0, C) - H.writeInt32BE(this._d|0, D) - H.writeInt32BE(this._e|0, E) - return H - } - - /* - * Perform the appropriate triplet combination function for the current - * iteration - */ - function sha1_ft(t, b, c, d) { - if(t < 20) return (b & c) | ((~b) & d); - if(t < 40) return b ^ c ^ d; - if(t < 60) return (b & c) | (b & d) | (c & d); - return b ^ c ^ d; - } - - /* - * Determine the appropriate additive constant for the current iteration - */ - function sha1_kt(t) { - return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 : - (t < 60) ? -1894007588 : -899497514; - } - - /* - * Add integers, wrapping at 2^32. This uses 16-bit operations internally - * to work around bugs in some JS interpreters. - * //dominictarr: this is 10 years old, so maybe this can be dropped?) - * - */ - function add(x, y) { - return (x + y ) | 0 - //lets see how this goes on testling. - // var lsw = (x & 0xFFFF) + (y & 0xFFFF); - // var msw = (x >> 16) + (y >> 16) + (lsw >> 16); - // return (msw << 16) | (lsw & 0xFFFF); - } - - /* - * Bitwise rotate a 32-bit number to the left. - */ - function rol(num, cnt) { - return (num << cnt) | (num >>> (32 - cnt)); - } - - return Sha1 - } - - -/***/ }, -/* 48 */ -/***/ function(module, exports, __webpack_require__) { - - - /** - * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined - * in FIPS 180-2 - * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * - */ - - var inherits = __webpack_require__(16).inherits - - module.exports = function (Buffer, Hash) { - - var K = [ - 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, - 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, - 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, - 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, - 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, - 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, - 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, - 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, - 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, - 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, - 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, - 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, - 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, - 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, - 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, - 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 - ] - - var W = new Array(64) - - function Sha256() { - this.init() - - this._w = W //new Array(64) - - Hash.call(this, 16*4, 14*4) - } - - inherits(Sha256, Hash) - - Sha256.prototype.init = function () { - - this._a = 0x6a09e667|0 - this._b = 0xbb67ae85|0 - this._c = 0x3c6ef372|0 - this._d = 0xa54ff53a|0 - this._e = 0x510e527f|0 - this._f = 0x9b05688c|0 - this._g = 0x1f83d9ab|0 - this._h = 0x5be0cd19|0 - - this._len = this._s = 0 - - return this - } - - function S (X, n) { - return (X >>> n) | (X << (32 - n)); - } - - function R (X, n) { - return (X >>> n); - } - - function Ch (x, y, z) { - return ((x & y) ^ ((~x) & z)); - } - - function Maj (x, y, z) { - return ((x & y) ^ (x & z) ^ (y & z)); - } - - function Sigma0256 (x) { - return (S(x, 2) ^ S(x, 13) ^ S(x, 22)); - } - - function Sigma1256 (x) { - return (S(x, 6) ^ S(x, 11) ^ S(x, 25)); - } - - function Gamma0256 (x) { - return (S(x, 7) ^ S(x, 18) ^ R(x, 3)); - } - - function Gamma1256 (x) { - return (S(x, 17) ^ S(x, 19) ^ R(x, 10)); - } - - Sha256.prototype._update = function(M) { - - var W = this._w - var a, b, c, d, e, f, g, h - var T1, T2 - - a = this._a | 0 - b = this._b | 0 - c = this._c | 0 - d = this._d | 0 - e = this._e | 0 - f = this._f | 0 - g = this._g | 0 - h = this._h | 0 - - for (var j = 0; j < 64; j++) { - var w = W[j] = j < 16 - ? M.readInt32BE(j * 4) - : Gamma1256(W[j - 2]) + W[j - 7] + Gamma0256(W[j - 15]) + W[j - 16] - - T1 = h + Sigma1256(e) + Ch(e, f, g) + K[j] + w - - T2 = Sigma0256(a) + Maj(a, b, c); - h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; - } - - this._a = (a + this._a) | 0 - this._b = (b + this._b) | 0 - this._c = (c + this._c) | 0 - this._d = (d + this._d) | 0 - this._e = (e + this._e) | 0 - this._f = (f + this._f) | 0 - this._g = (g + this._g) | 0 - this._h = (h + this._h) | 0 - - }; - - Sha256.prototype._hash = function () { - var H = new Buffer(32) - - H.writeInt32BE(this._a, 0) - H.writeInt32BE(this._b, 4) - H.writeInt32BE(this._c, 8) - H.writeInt32BE(this._d, 12) - H.writeInt32BE(this._e, 16) - H.writeInt32BE(this._f, 20) - H.writeInt32BE(this._g, 24) - H.writeInt32BE(this._h, 28) - - return H - } - - return Sha256 - - } - - -/***/ }, -/* 49 */ -/***/ function(module, exports, __webpack_require__) { - - var inherits = __webpack_require__(16).inherits - - module.exports = function (Buffer, Hash) { - var K = [ - 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, - 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, - 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, - 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, - 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, - 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, - 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, - 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, - 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, - 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, - 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, - 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, - 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, - 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, - 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, - 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, - 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, - 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, - 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, - 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, - 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, - 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, - 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, - 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, - 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, - 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, - 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, - 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, - 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, - 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, - 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, - 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, - 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, - 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, - 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, - 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, - 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, - 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, - 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, - 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 - ] - - var W = new Array(160) - - function Sha512() { - this.init() - this._w = W - - Hash.call(this, 128, 112) - } - - inherits(Sha512, Hash) - - Sha512.prototype.init = function () { - - this._a = 0x6a09e667|0 - this._b = 0xbb67ae85|0 - this._c = 0x3c6ef372|0 - this._d = 0xa54ff53a|0 - this._e = 0x510e527f|0 - this._f = 0x9b05688c|0 - this._g = 0x1f83d9ab|0 - this._h = 0x5be0cd19|0 - - this._al = 0xf3bcc908|0 - this._bl = 0x84caa73b|0 - this._cl = 0xfe94f82b|0 - this._dl = 0x5f1d36f1|0 - this._el = 0xade682d1|0 - this._fl = 0x2b3e6c1f|0 - this._gl = 0xfb41bd6b|0 - this._hl = 0x137e2179|0 - - this._len = this._s = 0 - - return this - } - - function S (X, Xl, n) { - return (X >>> n) | (Xl << (32 - n)) - } - - function Ch (x, y, z) { - return ((x & y) ^ ((~x) & z)); - } - - function Maj (x, y, z) { - return ((x & y) ^ (x & z) ^ (y & z)); - } - - Sha512.prototype._update = function(M) { - - var W = this._w - var a, b, c, d, e, f, g, h - var al, bl, cl, dl, el, fl, gl, hl - - a = this._a | 0 - b = this._b | 0 - c = this._c | 0 - d = this._d | 0 - e = this._e | 0 - f = this._f | 0 - g = this._g | 0 - h = this._h | 0 - - al = this._al | 0 - bl = this._bl | 0 - cl = this._cl | 0 - dl = this._dl | 0 - el = this._el | 0 - fl = this._fl | 0 - gl = this._gl | 0 - hl = this._hl | 0 - - for (var i = 0; i < 80; i++) { - var j = i * 2 - - var Wi, Wil - - if (i < 16) { - Wi = W[j] = M.readInt32BE(j * 4) - Wil = W[j + 1] = M.readInt32BE(j * 4 + 4) - - } else { - var x = W[j - 15*2] - var xl = W[j - 15*2 + 1] - var gamma0 = S(x, xl, 1) ^ S(x, xl, 8) ^ (x >>> 7) - var gamma0l = S(xl, x, 1) ^ S(xl, x, 8) ^ S(xl, x, 7) - - x = W[j - 2*2] - xl = W[j - 2*2 + 1] - var gamma1 = S(x, xl, 19) ^ S(xl, x, 29) ^ (x >>> 6) - var gamma1l = S(xl, x, 19) ^ S(x, xl, 29) ^ S(xl, x, 6) - - // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] - var Wi7 = W[j - 7*2] - var Wi7l = W[j - 7*2 + 1] - - var Wi16 = W[j - 16*2] - var Wi16l = W[j - 16*2 + 1] - - Wil = gamma0l + Wi7l - Wi = gamma0 + Wi7 + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0) - Wil = Wil + gamma1l - Wi = Wi + gamma1 + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0) - Wil = Wil + Wi16l - Wi = Wi + Wi16 + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0) - - W[j] = Wi - W[j + 1] = Wil - } - - var maj = Maj(a, b, c) - var majl = Maj(al, bl, cl) - - var sigma0h = S(a, al, 28) ^ S(al, a, 2) ^ S(al, a, 7) - var sigma0l = S(al, a, 28) ^ S(a, al, 2) ^ S(a, al, 7) - var sigma1h = S(e, el, 14) ^ S(e, el, 18) ^ S(el, e, 9) - var sigma1l = S(el, e, 14) ^ S(el, e, 18) ^ S(e, el, 9) - - // t1 = h + sigma1 + ch + K[i] + W[i] - var Ki = K[j] - var Kil = K[j + 1] - - var ch = Ch(e, f, g) - var chl = Ch(el, fl, gl) - - var t1l = hl + sigma1l - var t1 = h + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0) - t1l = t1l + chl - t1 = t1 + ch + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0) - t1l = t1l + Kil - t1 = t1 + Ki + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0) - t1l = t1l + Wil - t1 = t1 + Wi + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0) - - // t2 = sigma0 + maj - var t2l = sigma0l + majl - var t2 = sigma0h + maj + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0) - - h = g - hl = gl - g = f - gl = fl - f = e - fl = el - el = (dl + t1l) | 0 - e = (d + t1 + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0 - d = c - dl = cl - c = b - cl = bl - b = a - bl = al - al = (t1l + t2l) | 0 - a = (t1 + t2 + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0 - } - - this._al = (this._al + al) | 0 - this._bl = (this._bl + bl) | 0 - this._cl = (this._cl + cl) | 0 - this._dl = (this._dl + dl) | 0 - this._el = (this._el + el) | 0 - this._fl = (this._fl + fl) | 0 - this._gl = (this._gl + gl) | 0 - this._hl = (this._hl + hl) | 0 - - this._a = (this._a + a + ((this._al >>> 0) < (al >>> 0) ? 1 : 0)) | 0 - this._b = (this._b + b + ((this._bl >>> 0) < (bl >>> 0) ? 1 : 0)) | 0 - this._c = (this._c + c + ((this._cl >>> 0) < (cl >>> 0) ? 1 : 0)) | 0 - this._d = (this._d + d + ((this._dl >>> 0) < (dl >>> 0) ? 1 : 0)) | 0 - this._e = (this._e + e + ((this._el >>> 0) < (el >>> 0) ? 1 : 0)) | 0 - this._f = (this._f + f + ((this._fl >>> 0) < (fl >>> 0) ? 1 : 0)) | 0 - this._g = (this._g + g + ((this._gl >>> 0) < (gl >>> 0) ? 1 : 0)) | 0 - this._h = (this._h + h + ((this._hl >>> 0) < (hl >>> 0) ? 1 : 0)) | 0 - } - - Sha512.prototype._hash = function () { - var H = new Buffer(64) - - function writeInt64BE(h, l, offset) { - H.writeInt32BE(h, offset) - H.writeInt32BE(l, offset + 4) - } - - writeInt64BE(this._a, this._al, 0) - writeInt64BE(this._b, this._bl, 8) - writeInt64BE(this._c, this._cl, 16) - writeInt64BE(this._d, this._dl, 24) - writeInt64BE(this._e, this._el, 32) - writeInt64BE(this._f, this._fl, 40) - writeInt64BE(this._g, this._gl, 48) - writeInt64BE(this._h, this._hl, 56) - - return H - } - - return Sha512 - - } - - -/***/ }, -/* 50 */ -/***/ function(module, exports, __webpack_require__) { - - /* - * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message - * Digest Algorithm, as defined in RFC 1321. - * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * Distributed under the BSD License - * See http://pajhome.org.uk/crypt/md5 for more info. - */ - - var helpers = __webpack_require__(51); - - /* - * Calculate the MD5 of an array of little-endian words, and a bit length - */ - function core_md5(x, len) - { - /* append padding */ - x[len >> 5] |= 0x80 << ((len) % 32); - x[(((len + 64) >>> 9) << 4) + 14] = len; - - var a = 1732584193; - var b = -271733879; - var c = -1732584194; - var d = 271733878; - - for(var i = 0; i < x.length; i += 16) - { - var olda = a; - var oldb = b; - var oldc = c; - var oldd = d; - - a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); - d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); - c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); - b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); - a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); - d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); - c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); - b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); - a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); - d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); - c = md5_ff(c, d, a, b, x[i+10], 17, -42063); - b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); - a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); - d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); - c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); - b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); - - a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); - d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); - c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); - b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); - a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); - d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); - c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); - b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); - a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); - d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); - c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); - b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); - a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); - d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); - c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); - b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); - - a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); - d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); - c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); - b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); - a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); - d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); - c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); - b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); - a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); - d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); - c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); - b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); - a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); - d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); - c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); - b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); - - a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); - d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); - c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); - b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); - a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); - d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); - c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); - b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); - a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); - d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); - c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); - b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); - a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); - d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); - c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); - b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); - - a = safe_add(a, olda); - b = safe_add(b, oldb); - c = safe_add(c, oldc); - d = safe_add(d, oldd); - } - return Array(a, b, c, d); - - } - - /* - * These functions implement the four basic operations the algorithm uses. - */ - function md5_cmn(q, a, b, x, s, t) - { - return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); - } - function md5_ff(a, b, c, d, x, s, t) - { - return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); - } - function md5_gg(a, b, c, d, x, s, t) - { - return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); - } - function md5_hh(a, b, c, d, x, s, t) - { - return md5_cmn(b ^ c ^ d, a, b, x, s, t); - } - function md5_ii(a, b, c, d, x, s, t) - { - return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); - } - - /* - * Add integers, wrapping at 2^32. This uses 16-bit operations internally - * to work around bugs in some JS interpreters. - */ - function safe_add(x, y) - { - var lsw = (x & 0xFFFF) + (y & 0xFFFF); - var msw = (x >> 16) + (y >> 16) + (lsw >> 16); - return (msw << 16) | (lsw & 0xFFFF); - } - - /* - * Bitwise rotate a 32-bit number to the left. - */ - function bit_rol(num, cnt) - { - return (num << cnt) | (num >>> (32 - cnt)); - } - - module.exports = function md5(buf) { - return helpers.hash(buf, core_md5, 16); - }; - - -/***/ }, -/* 51 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {var intSize = 4; - var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0); - var chrsz = 8; - - function toArray(buf, bigEndian) { - if ((buf.length % intSize) !== 0) { - var len = buf.length + (intSize - (buf.length % intSize)); - buf = Buffer.concat([buf, zeroBuffer], len); - } - - var arr = []; - var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE; - for (var i = 0; i < buf.length; i += intSize) { - arr.push(fn.call(buf, i)); - } - return arr; - } - - function toBuffer(arr, size, bigEndian) { - var buf = new Buffer(size); - var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE; - for (var i = 0; i < arr.length; i++) { - fn.call(buf, arr[i], i * 4, true); - } - return buf; - } - - function hash(buf, fn, hashSize, bigEndian) { - if (!Buffer.isBuffer(buf)) buf = new Buffer(buf); - var arr = fn(toArray(buf, bigEndian), buf.length * chrsz); - return toBuffer(arr, hashSize, bigEndian); - } - - module.exports = { hash: hash }; - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 52 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) { - module.exports = ripemd160 - - - - /* - CryptoJS v3.1.2 - code.google.com/p/crypto-js - (c) 2009-2013 by Jeff Mott. All rights reserved. - code.google.com/p/crypto-js/wiki/License - */ - /** @preserve - (c) 2012 by Cédric Mesnil. All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - - 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. - */ - - // Constants table - var zl = [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, - 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, - 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, - 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]; - var zr = [ - 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, - 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, - 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, - 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, - 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]; - var sl = [ - 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, - 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, - 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, - 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, - 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]; - var sr = [ - 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, - 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, - 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, - 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, - 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]; - - var hl = [ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]; - var hr = [ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]; - - var bytesToWords = function (bytes) { - var words = []; - for (var i = 0, b = 0; i < bytes.length; i++, b += 8) { - words[b >>> 5] |= bytes[i] << (24 - b % 32); - } - return words; - }; - - var wordsToBytes = function (words) { - var bytes = []; - for (var b = 0; b < words.length * 32; b += 8) { - bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF); - } - return bytes; - }; - - var processBlock = function (H, M, offset) { - - // Swap endian - for (var i = 0; i < 16; i++) { - var offset_i = offset + i; - var M_offset_i = M[offset_i]; - - // Swap - M[offset_i] = ( - (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | - (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) - ); - } - - // Working variables - var al, bl, cl, dl, el; - var ar, br, cr, dr, er; - - ar = al = H[0]; - br = bl = H[1]; - cr = cl = H[2]; - dr = dl = H[3]; - er = el = H[4]; - // Computation - var t; - for (var i = 0; i < 80; i += 1) { - t = (al + M[offset+zl[i]])|0; - if (i<16){ - t += f1(bl,cl,dl) + hl[0]; - } else if (i<32) { - t += f2(bl,cl,dl) + hl[1]; - } else if (i<48) { - t += f3(bl,cl,dl) + hl[2]; - } else if (i<64) { - t += f4(bl,cl,dl) + hl[3]; - } else {// if (i<80) { - t += f5(bl,cl,dl) + hl[4]; - } - t = t|0; - t = rotl(t,sl[i]); - t = (t+el)|0; - al = el; - el = dl; - dl = rotl(cl, 10); - cl = bl; - bl = t; - - t = (ar + M[offset+zr[i]])|0; - if (i<16){ - t += f5(br,cr,dr) + hr[0]; - } else if (i<32) { - t += f4(br,cr,dr) + hr[1]; - } else if (i<48) { - t += f3(br,cr,dr) + hr[2]; - } else if (i<64) { - t += f2(br,cr,dr) + hr[3]; - } else {// if (i<80) { - t += f1(br,cr,dr) + hr[4]; - } - t = t|0; - t = rotl(t,sr[i]) ; - t = (t+er)|0; - ar = er; - er = dr; - dr = rotl(cr, 10); - cr = br; - br = t; - } - // Intermediate hash value - t = (H[1] + cl + dr)|0; - H[1] = (H[2] + dl + er)|0; - H[2] = (H[3] + el + ar)|0; - H[3] = (H[4] + al + br)|0; - H[4] = (H[0] + bl + cr)|0; - H[0] = t; - }; - - function f1(x, y, z) { - return ((x) ^ (y) ^ (z)); - } - - function f2(x, y, z) { - return (((x)&(y)) | ((~x)&(z))); - } - - function f3(x, y, z) { - return (((x) | (~(y))) ^ (z)); - } - - function f4(x, y, z) { - return (((x) & (z)) | ((y)&(~(z)))); - } - - function f5(x, y, z) { - return ((x) ^ ((y) |(~(z)))); - } - - function rotl(x,n) { - return (x<>>(32-n)); - } - - function ripemd160(message) { - var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]; - - if (typeof message == 'string') - message = new Buffer(message, 'utf8'); - - var m = bytesToWords(message); - - var nBitsLeft = message.length * 8; - var nBitsTotal = message.length * 8; - - // Add padding - m[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); - m[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( - (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) | - (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00) - ); - - for (var i=0 ; i>> 24)) & 0x00ff00ff) | - (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); - } - - var digestbytes = wordsToBytes(H); - return new Buffer(digestbytes); - } - - - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 53 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(44) - - var zeroBuffer = new Buffer(128) - zeroBuffer.fill(0) - - module.exports = Hmac - - function Hmac (alg, key) { - if(!(this instanceof Hmac)) return new Hmac(alg, key) - this._opad = opad - this._alg = alg - - var blocksize = (alg === 'sha512') ? 128 : 64 - - key = this._key = !Buffer.isBuffer(key) ? new Buffer(key) : key - - if(key.length > blocksize) { - key = createHash(alg).update(key).digest() - } else if(key.length < blocksize) { - key = Buffer.concat([key, zeroBuffer], blocksize) - } - - var ipad = this._ipad = new Buffer(blocksize) - var opad = this._opad = new Buffer(blocksize) - - for(var i = 0; i < blocksize; i++) { - ipad[i] = key[i] ^ 0x36 - opad[i] = key[i] ^ 0x5C - } - - this._hash = createHash(alg).update(ipad) - } - - Hmac.prototype.update = function (data, enc) { - this._hash.update(data, enc) - return this - } - - Hmac.prototype.digest = function (enc) { - var h = this._hash.digest() - return createHash(this._alg).update(this._opad).update(h).digest(enc) - } - - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 54 */ -/***/ function(module, exports, __webpack_require__) { - - var pbkdf2Export = __webpack_require__(55) - - module.exports = function (crypto, exports) { - exports = exports || {} - - var exported = pbkdf2Export(crypto) - - exports.pbkdf2 = exported.pbkdf2 - exports.pbkdf2Sync = exported.pbkdf2Sync - - return exports - } - - -/***/ }, -/* 55 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {module.exports = function(crypto) { - function pbkdf2(password, salt, iterations, keylen, digest, callback) { - if ('function' === typeof digest) { - callback = digest - digest = undefined - } - - if ('function' !== typeof callback) - throw new Error('No callback provided to pbkdf2') - - setTimeout(function() { - var result - - try { - result = pbkdf2Sync(password, salt, iterations, keylen, digest) - } catch (e) { - return callback(e) - } - - callback(undefined, result) - }) - } - - function pbkdf2Sync(password, salt, iterations, keylen, digest) { - if ('number' !== typeof iterations) - throw new TypeError('Iterations not a number') - - if (iterations < 0) - throw new TypeError('Bad iterations') - - if ('number' !== typeof keylen) - throw new TypeError('Key length not a number') - - if (keylen < 0) - throw new TypeError('Bad key length') - - digest = digest || 'sha1' - - if (!Buffer.isBuffer(password)) password = new Buffer(password) - if (!Buffer.isBuffer(salt)) salt = new Buffer(salt) - - var hLen, l = 1, r, T - var DK = new Buffer(keylen) - var block1 = new Buffer(salt.length + 4) - salt.copy(block1, 0, 0, salt.length) - - for (var i = 1; i <= l; i++) { - block1.writeUInt32BE(i, salt.length) - - var U = crypto.createHmac(digest, password).update(block1).digest() - - if (!hLen) { - hLen = U.length - T = new Buffer(hLen) - l = Math.ceil(keylen / hLen) - r = keylen - (l - 1) * hLen - - if (keylen > (Math.pow(2, 32) - 1) * hLen) - throw new TypeError('keylen exceeds maximum length') - } - - U.copy(T, 0, 0, hLen) - - for (var j = 1; j < iterations; j++) { - U = crypto.createHmac(digest, password).update(U).digest() - - for (var k = 0; k < hLen; k++) { - T[k] ^= U[k] - } - } - - var destPos = (i - 1) * hLen - var len = (i == l ? r : hLen) - T.copy(DK, destPos, 0, len) - } - - return DK - } - - return { - pbkdf2: pbkdf2, - pbkdf2Sync: pbkdf2Sync - } - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 56 */ -/***/ function(module, exports) { - - 'use strict'; - - var has = Object.prototype.hasOwnProperty; - - /** - * An auto incrementing id which we can use to create "unique" Ultron instances - * so we can track the event emitters that are added through the Ultron - * interface. - * - * @type {Number} - * @private - */ - var id = 0; - - /** - * Ultron is high-intelligence robot. It gathers intelligence so it can start improving - * upon his rudimentary design. It will learn from your EventEmitting patterns - * and exterminate them. - * - * @constructor - * @param {EventEmitter} ee EventEmitter instance we need to wrap. - * @api public - */ - function Ultron(ee) { - if (!(this instanceof Ultron)) return new Ultron(ee); - - this.id = id++; - this.ee = ee; - } - - /** - * Register a new EventListener for the given event. - * - * @param {String} event Name of the event. - * @param {Functon} fn Callback function. - * @param {Mixed} context The context of the function. - * @returns {Ultron} - * @api public - */ - Ultron.prototype.on = function on(event, fn, context) { - fn.__ultron = this.id; - this.ee.on(event, fn, context); - - return this; - }; - /** - * Add an EventListener that's only called once. - * - * @param {String} event Name of the event. - * @param {Function} fn Callback function. - * @param {Mixed} context The context of the function. - * @returns {Ultron} - * @api public - */ - Ultron.prototype.once = function once(event, fn, context) { - fn.__ultron = this.id; - this.ee.once(event, fn, context); - - return this; - }; - - /** - * Remove the listeners we assigned for the given event. - * - * @returns {Ultron} - * @api public - */ - Ultron.prototype.remove = function remove() { - var args = arguments - , event; - - // - // When no event names are provided we assume that we need to clear all the - // events that were assigned through us. - // - if (args.length === 1 && 'string' === typeof args[0]) { - args = args[0].split(/[, ]+/); - } else if (!args.length) { - args = []; - - for (event in this.ee._events) { - if (has.call(this.ee._events, event)) args.push(event); - } - } - - for (var i = 0; i < args.length; i++) { - var listeners = this.ee.listeners(args[i]); - - for (var j = 0; j < listeners.length; j++) { - event = listeners[j]; - - // - // Once listeners have a `listener` property that stores the real listener - // in the EventEmitter that ships with Node.js. - // - if (event.listener) { - if (event.listener.__ultron !== this.id) continue; - delete event.listener.__ultron; - } else { - if (event.__ultron !== this.id) continue; - delete event.__ultron; - } - - this.ee.removeListener(args[i], event); - } - } - - return this; - }; - - /** - * Destroy the Ultron instance, remove all listeners and release all references. - * - * @returns {Boolean} - * @api public - */ - Ultron.prototype.destroy = function destroy() { - if (!this.ee) return false; - - this.remove(); - this.ee = null; - - return true; - }; - - // - // Expose the module. - // - module.exports = Ultron; - - -/***/ }, -/* 57 */ -/***/ function(module, exports, __webpack_require__) { - - /*! - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - var fs = __webpack_require__(58); - - function Options(defaults) { - var internalValues = {}; - var values = this.value = {}; - Object.keys(defaults).forEach(function(key) { - internalValues[key] = defaults[key]; - Object.defineProperty(values, key, { - get: function() { return internalValues[key]; }, - configurable: false, - enumerable: true - }); - }); - this.reset = function() { - Object.keys(defaults).forEach(function(key) { - internalValues[key] = defaults[key]; - }); - return this; - }; - this.merge = function(options, required) { - options = options || {}; - if (Object.prototype.toString.call(required) === '[object Array]') { - var missing = []; - for (var i = 0, l = required.length; i < l; ++i) { - var key = required[i]; - if (!(key in options)) { - missing.push(key); - } - } - if (missing.length > 0) { - if (missing.length > 1) { - throw new Error('options ' + - missing.slice(0, missing.length - 1).join(', ') + ' and ' + - missing[missing.length - 1] + ' must be defined'); - } - else throw new Error('option ' + missing[0] + ' must be defined'); - } - } - Object.keys(options).forEach(function(key) { - if (key in internalValues) { - internalValues[key] = options[key]; - } - }); - return this; - }; - this.copy = function(keys) { - var obj = {}; - Object.keys(defaults).forEach(function(key) { - if (keys.indexOf(key) !== -1) { - obj[key] = values[key]; - } - }); - return obj; - }; - this.read = function(filename, cb) { - if (typeof cb == 'function') { - var self = this; - fs.readFile(filename, function(error, data) { - if (error) return cb(error); - var conf = JSON.parse(data); - self.merge(conf); - cb(); - }); - } - else { - var conf = JSON.parse(fs.readFileSync(filename)); - this.merge(conf); - } - return this; - }; - this.isDefined = function(key) { - return typeof values[key] != 'undefined'; - }; - this.isDefinedAndNonNull = function(key) { - return typeof values[key] != 'undefined' && values[key] !== null; - }; - Object.freeze(values); - Object.freeze(this); - } - - module.exports = Options; - - -/***/ }, -/* 58 */ -/***/ function(module, exports) { - - - -/***/ }, -/* 59 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - var events = __webpack_require__(20) - , util = __webpack_require__(16) - , EventEmitter = events.EventEmitter - , ErrorCodes = __webpack_require__(60) - , bufferUtil = __webpack_require__(61).BufferUtil - , PerMessageDeflate = __webpack_require__(63); - - /** - * HyBi Sender implementation - */ - - function Sender(socket, extensions) { - if (this instanceof Sender === false) { - throw new TypeError("Classes can't be function-called"); - } - - events.EventEmitter.call(this); - - this._socket = socket; - this.extensions = extensions || {}; - this.firstFragment = true; - this.compress = false; - this.messageHandlers = []; - this.processing = false; - } - - /** - * Inherits from EventEmitter. - */ - - util.inherits(Sender, events.EventEmitter); - - /** - * Sends a close instruction to the remote party. - * - * @api public - */ - - Sender.prototype.close = function(code, data, mask, cb) { - if (typeof code !== 'undefined') { - if (typeof code !== 'number' || - !ErrorCodes.isValidErrorCode(code)) throw new Error('first argument must be a valid error code number'); - } - code = code || 1000; - var dataBuffer = new Buffer(2 + (data ? Buffer.byteLength(data) : 0)); - writeUInt16BE.call(dataBuffer, code, 0); - if (dataBuffer.length > 2) dataBuffer.write(data, 2); - - var self = this; - this.messageHandlers.push(function(callback) { - self.frameAndSend(0x8, dataBuffer, true, mask); - callback(); - if (typeof cb == 'function') cb(); - }); - this.flush(); - }; - - /** - * Sends a ping message to the remote party. - * - * @api public - */ - - Sender.prototype.ping = function(data, options) { - var mask = options && options.mask; - var self = this; - this.messageHandlers.push(function(callback) { - self.frameAndSend(0x9, data || '', true, mask); - callback(); - }); - this.flush(); - }; - - /** - * Sends a pong message to the remote party. - * - * @api public - */ - - Sender.prototype.pong = function(data, options) { - var mask = options && options.mask; - var self = this; - this.messageHandlers.push(function(callback) { - self.frameAndSend(0xa, data || '', true, mask); - callback(); - }); - this.flush(); - }; - - /** - * Sends text or binary data to the remote party. - * - * @api public - */ - - Sender.prototype.send = function(data, options, cb) { - var finalFragment = options && options.fin === false ? false : true; - var mask = options && options.mask; - var compress = options && options.compress; - var opcode = options && options.binary ? 2 : 1; - if (this.firstFragment === false) { - opcode = 0; - compress = false; - } else { - this.firstFragment = false; - this.compress = compress; - } - if (finalFragment) this.firstFragment = true - - var compressFragment = this.compress; - - var self = this; - this.messageHandlers.push(function(callback) { - self.applyExtensions(data, finalFragment, compressFragment, function(err, data) { - if (err) { - if (typeof cb == 'function') cb(err); - else self.emit('error', err); - return; - } - self.frameAndSend(opcode, data, finalFragment, mask, compress, cb); - callback(); - }); - }); - this.flush(); - }; - - /** - * Frames and sends a piece of data according to the HyBi WebSocket protocol. - * - * @api private - */ - - Sender.prototype.frameAndSend = function(opcode, data, finalFragment, maskData, compressed, cb) { - var canModifyData = false; - - if (!data) { - try { - this._socket.write(new Buffer([opcode | (finalFragment ? 0x80 : 0), 0 | (maskData ? 0x80 : 0)].concat(maskData ? [0, 0, 0, 0] : [])), 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - return; - } - - if (!Buffer.isBuffer(data)) { - canModifyData = true; - if (data && (typeof data.byteLength !== 'undefined' || typeof data.buffer !== 'undefined')) { - data = getArrayBuffer(data); - } else { - // - // If people want to send a number, this would allocate the number in - // bytes as memory size instead of storing the number as buffer value. So - // we need to transform it to string in order to prevent possible - // vulnerabilities / memory attacks. - // - if (typeof data === 'number') data = data.toString(); - - data = new Buffer(data); - } - } - - var dataLength = data.length - , dataOffset = maskData ? 6 : 2 - , secondByte = dataLength; - - if (dataLength >= 65536) { - dataOffset += 8; - secondByte = 127; - } - else if (dataLength > 125) { - dataOffset += 2; - secondByte = 126; - } - - var mergeBuffers = dataLength < 32768 || (maskData && !canModifyData); - var totalLength = mergeBuffers ? dataLength + dataOffset : dataOffset; - var outputBuffer = new Buffer(totalLength); - outputBuffer[0] = finalFragment ? opcode | 0x80 : opcode; - if (compressed) outputBuffer[0] |= 0x40; - - switch (secondByte) { - case 126: - writeUInt16BE.call(outputBuffer, dataLength, 2); - break; - case 127: - writeUInt32BE.call(outputBuffer, 0, 2); - writeUInt32BE.call(outputBuffer, dataLength, 6); - } - - if (maskData) { - outputBuffer[1] = secondByte | 0x80; - var mask = getRandomMask(); - outputBuffer[dataOffset - 4] = mask[0]; - outputBuffer[dataOffset - 3] = mask[1]; - outputBuffer[dataOffset - 2] = mask[2]; - outputBuffer[dataOffset - 1] = mask[3]; - if (mergeBuffers) { - bufferUtil.mask(data, mask, outputBuffer, dataOffset, dataLength); - try { - this._socket.write(outputBuffer, 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - } - else { - bufferUtil.mask(data, mask, data, 0, dataLength); - try { - this._socket.write(outputBuffer, 'binary'); - this._socket.write(data, 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - } - } - else { - outputBuffer[1] = secondByte; - if (mergeBuffers) { - data.copy(outputBuffer, dataOffset); - try { - this._socket.write(outputBuffer, 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - } - else { - try { - this._socket.write(outputBuffer, 'binary'); - this._socket.write(data, 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - } - } - }; - - /** - * Execute message handler buffers - * - * @api private - */ - - Sender.prototype.flush = function() { - if (this.processing) return; - - var handler = this.messageHandlers.shift(); - if (!handler) return; - - this.processing = true; - - var self = this; - - handler(function() { - self.processing = false; - self.flush(); - }); - }; - - /** - * Apply extensions to message - * - * @api private - */ - - Sender.prototype.applyExtensions = function(data, fin, compress, callback) { - if (compress && data) { - if ((data.buffer || data) instanceof ArrayBuffer) { - data = getArrayBuffer(data); - } - this.extensions[PerMessageDeflate.extensionName].compress(data, fin, callback); - } else { - callback(null, data); - } - }; - - module.exports = Sender; - - function writeUInt16BE(value, offset) { - this[offset] = (value & 0xff00)>>8; - this[offset+1] = value & 0xff; - } - - function writeUInt32BE(value, offset) { - this[offset] = (value & 0xff000000)>>24; - this[offset+1] = (value & 0xff0000)>>16; - this[offset+2] = (value & 0xff00)>>8; - this[offset+3] = value & 0xff; - } - - function getArrayBuffer(data) { - // data is either an ArrayBuffer or ArrayBufferView. - var array = new Uint8Array(data.buffer || data) - , l = data.byteLength || data.length - , o = data.byteOffset || 0 - , buffer = new Buffer(l); - for (var i = 0; i < l; ++i) { - buffer[i] = array[o+i]; - } - return buffer; - } - - function getRandomMask() { - return new Buffer([ - ~~(Math.random() * 255), - ~~(Math.random() * 255), - ~~(Math.random() * 255), - ~~(Math.random() * 255) - ]); - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 60 */ -/***/ function(module, exports) { - - /*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - module.exports = { - isValidErrorCode: function(code) { - return (code >= 1000 && code <= 1011 && code != 1004 && code != 1005 && code != 1006) || - (code >= 3000 && code <= 4999); - }, - 1000: 'normal', - 1001: 'going away', - 1002: 'protocol error', - 1003: 'unsupported data', - 1004: 'reserved', - 1005: 'reserved for extensions', - 1006: 'reserved for extensions', - 1007: 'inconsistent or invalid data', - 1008: 'policy violation', - 1009: 'message too big', - 1010: 'extension handshake missing', - 1011: 'an unexpected condition prevented the request from being fulfilled', - }; - -/***/ }, -/* 61 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - /*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - try { - module.exports = __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"bufferutil\""); e.code = 'MODULE_NOT_FOUND'; throw e; }())); - } catch (e) { - module.exports = __webpack_require__(62); - } - - -/***/ }, -/* 62 */ -/***/ function(module, exports) { - - /*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - exports.BufferUtil = { - merge: function(mergedBuffer, buffers) { - var offset = 0; - for (var i = 0, l = buffers.length; i < l; ++i) { - var buf = buffers[i]; - buf.copy(mergedBuffer, offset); - offset += buf.length; - } - }, - mask: function(source, mask, output, offset, length) { - var maskNum = mask.readUInt32LE(0, true); - var i = 0; - for (; i < length - 3; i += 4) { - var num = maskNum ^ source.readUInt32LE(i, true); - if (num < 0) num = 4294967296 + num; - output.writeUInt32LE(num, offset + i, true); - } - switch (length % 4) { - case 3: output[offset + i + 2] = source[i + 2] ^ mask[2]; - case 2: output[offset + i + 1] = source[i + 1] ^ mask[1]; - case 1: output[offset + i] = source[i] ^ mask[0]; - case 0:; - } - }, - unmask: function(data, mask) { - var maskNum = mask.readUInt32LE(0, true); - var length = data.length; - var i = 0; - for (; i < length - 3; i += 4) { - var num = maskNum ^ data.readUInt32LE(i, true); - if (num < 0) num = 4294967296 + num; - data.writeUInt32LE(num, i, true); - } - switch (length % 4) { - case 3: data[i + 2] = data[i + 2] ^ mask[2]; - case 2: data[i + 1] = data[i + 1] ^ mask[1]; - case 1: data[i] = data[i] ^ mask[0]; - case 0:; - } - } - } - - -/***/ }, -/* 63 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) { - var zlib = __webpack_require__(64); - - var AVAILABLE_WINDOW_BITS = [8, 9, 10, 11, 12, 13, 14, 15]; - var DEFAULT_WINDOW_BITS = 15; - var DEFAULT_MEM_LEVEL = 8; - - PerMessageDeflate.extensionName = 'permessage-deflate'; - - /** - * Per-message Compression Extensions implementation - */ - - function PerMessageDeflate(options, isServer,maxPayload) { - if (this instanceof PerMessageDeflate === false) { - throw new TypeError("Classes can't be function-called"); - } - - this._options = options || {}; - this._isServer = !!isServer; - this._inflate = null; - this._deflate = null; - this.params = null; - this._maxPayload = maxPayload || 0; - } - - /** - * Create extension parameters offer - * - * @api public - */ - - PerMessageDeflate.prototype.offer = function() { - var params = {}; - if (this._options.serverNoContextTakeover) { - params.server_no_context_takeover = true; - } - if (this._options.clientNoContextTakeover) { - params.client_no_context_takeover = true; - } - if (this._options.serverMaxWindowBits) { - params.server_max_window_bits = this._options.serverMaxWindowBits; - } - if (this._options.clientMaxWindowBits) { - params.client_max_window_bits = this._options.clientMaxWindowBits; - } else if (this._options.clientMaxWindowBits == null) { - params.client_max_window_bits = true; - } - return params; - }; - - /** - * Accept extension offer - * - * @api public - */ - - PerMessageDeflate.prototype.accept = function(paramsList) { - paramsList = this.normalizeParams(paramsList); - - var params; - if (this._isServer) { - params = this.acceptAsServer(paramsList); - } else { - params = this.acceptAsClient(paramsList); - } - - this.params = params; - return params; - }; - - /** - * Releases all resources used by the extension - * - * @api public - */ - - PerMessageDeflate.prototype.cleanup = function() { - if (this._inflate) { - if (this._inflate.writeInProgress) { - this._inflate.pendingClose = true; - } else { - if (this._inflate.close) this._inflate.close(); - this._inflate = null; - } - } - if (this._deflate) { - if (this._deflate.writeInProgress) { - this._deflate.pendingClose = true; - } else { - if (this._deflate.close) this._deflate.close(); - this._deflate = null; - } - } - }; - - /** - * Accept extension offer from client - * - * @api private - */ - - PerMessageDeflate.prototype.acceptAsServer = function(paramsList) { - var accepted = {}; - var result = paramsList.some(function(params) { - accepted = {}; - if (this._options.serverNoContextTakeover === false && params.server_no_context_takeover) { - return; - } - if (this._options.serverMaxWindowBits === false && params.server_max_window_bits) { - return; - } - if (typeof this._options.serverMaxWindowBits === 'number' && - typeof params.server_max_window_bits === 'number' && - this._options.serverMaxWindowBits > params.server_max_window_bits) { - return; - } - if (typeof this._options.clientMaxWindowBits === 'number' && !params.client_max_window_bits) { - return; - } - - if (this._options.serverNoContextTakeover || params.server_no_context_takeover) { - accepted.server_no_context_takeover = true; - } - if (this._options.clientNoContextTakeover) { - accepted.client_no_context_takeover = true; - } - if (this._options.clientNoContextTakeover !== false && params.client_no_context_takeover) { - accepted.client_no_context_takeover = true; - } - if (typeof this._options.serverMaxWindowBits === 'number') { - accepted.server_max_window_bits = this._options.serverMaxWindowBits; - } else if (typeof params.server_max_window_bits === 'number') { - accepted.server_max_window_bits = params.server_max_window_bits; - } - if (typeof this._options.clientMaxWindowBits === 'number') { - accepted.client_max_window_bits = this._options.clientMaxWindowBits; - } else if (this._options.clientMaxWindowBits !== false && typeof params.client_max_window_bits === 'number') { - accepted.client_max_window_bits = params.client_max_window_bits; - } - return true; - }, this); - - if (!result) { - throw new Error('Doesn\'t support the offered configuration'); - } - - return accepted; - }; - - /** - * Accept extension response from server - * - * @api privaye - */ - - PerMessageDeflate.prototype.acceptAsClient = function(paramsList) { - var params = paramsList[0]; - if (this._options.clientNoContextTakeover != null) { - if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) { - throw new Error('Invalid value for "client_no_context_takeover"'); - } - } - if (this._options.clientMaxWindowBits != null) { - if (this._options.clientMaxWindowBits === false && params.client_max_window_bits) { - throw new Error('Invalid value for "client_max_window_bits"'); - } - if (typeof this._options.clientMaxWindowBits === 'number' && - (!params.client_max_window_bits || params.client_max_window_bits > this._options.clientMaxWindowBits)) { - throw new Error('Invalid value for "client_max_window_bits"'); - } - } - return params; - }; - - /** - * Normalize extensions parameters - * - * @api private - */ - - PerMessageDeflate.prototype.normalizeParams = function(paramsList) { - return paramsList.map(function(params) { - Object.keys(params).forEach(function(key) { - var value = params[key]; - if (value.length > 1) { - throw new Error('Multiple extension parameters for ' + key); - } - - value = value[0]; - - switch (key) { - case 'server_no_context_takeover': - case 'client_no_context_takeover': - if (value !== true) { - throw new Error('invalid extension parameter value for ' + key + ' (' + value + ')'); - } - params[key] = true; - break; - case 'server_max_window_bits': - case 'client_max_window_bits': - if (typeof value === 'string') { - value = parseInt(value, 10); - if (!~AVAILABLE_WINDOW_BITS.indexOf(value)) { - throw new Error('invalid extension parameter value for ' + key + ' (' + value + ')'); - } - } - if (!this._isServer && value === true) { - throw new Error('Missing extension parameter value for ' + key); - } - params[key] = value; - break; - default: - throw new Error('Not defined extension parameter (' + key + ')'); - } - }, this); - return params; - }, this); - }; - - /** - * Decompress message - * - * @api public - */ - - PerMessageDeflate.prototype.decompress = function (data, fin, callback) { - var endpoint = this._isServer ? 'client' : 'server'; - - if (!this._inflate) { - var maxWindowBits = this.params[endpoint + '_max_window_bits']; - this._inflate = zlib.createInflateRaw({ - windowBits: 'number' === typeof maxWindowBits ? maxWindowBits : DEFAULT_WINDOW_BITS - }); - } - this._inflate.writeInProgress = true; - - var self = this; - var buffers = []; - var cumulativeBufferLength=0; - - this._inflate.on('error', onError).on('data', onData); - this._inflate.write(data); - if (fin) { - this._inflate.write(new Buffer([0x00, 0x00, 0xff, 0xff])); - } - this._inflate.flush(function() { - cleanup(); - callback(null, Buffer.concat(buffers)); - }); - - function onError(err) { - cleanup(); - callback(err); - } - - function onData(data) { - if(self._maxPayload!==undefined && self._maxPayload!==null && self._maxPayload>0){ - cumulativeBufferLength+=data.length; - if(cumulativeBufferLength>self._maxPayload){ - buffers=[]; - cleanup(); - var err={type:1009}; - callback(err); - return; - } - } - buffers.push(data); - } - - function cleanup() { - if (!self._inflate) return; - self._inflate.removeListener('error', onError); - self._inflate.removeListener('data', onData); - self._inflate.writeInProgress = false; - if ((fin && self.params[endpoint + '_no_context_takeover']) || self._inflate.pendingClose) { - if (self._inflate.close) self._inflate.close(); - self._inflate = null; - } - } - }; - - /** - * Compress message - * - * @api public - */ - - PerMessageDeflate.prototype.compress = function (data, fin, callback) { - var endpoint = this._isServer ? 'server' : 'client'; - - if (!this._deflate) { - var maxWindowBits = this.params[endpoint + '_max_window_bits']; - this._deflate = zlib.createDeflateRaw({ - flush: zlib.Z_SYNC_FLUSH, - windowBits: 'number' === typeof maxWindowBits ? maxWindowBits : DEFAULT_WINDOW_BITS, - memLevel: this._options.memLevel || DEFAULT_MEM_LEVEL - }); - } - this._deflate.writeInProgress = true; - - var self = this; - var buffers = []; - - this._deflate.on('error', onError).on('data', onData); - this._deflate.write(data); - this._deflate.flush(function() { - cleanup(); - var data = Buffer.concat(buffers); - if (fin) { - data = data.slice(0, data.length - 4); - } - callback(null, data); - }); - - function onError(err) { - cleanup(); - callback(err); - } - - function onData(data) { - buffers.push(data); - } - - function cleanup() { - if (!self._deflate) return; - self._deflate.removeListener('error', onError); - self._deflate.removeListener('data', onData); - self._deflate.writeInProgress = false; - if ((fin && self.params[endpoint + '_no_context_takeover']) || self._deflate.pendingClose) { - if (self._deflate.close) self._deflate.close(); - self._deflate = null; - } - } - }; - - module.exports = PerMessageDeflate; - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 64 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer, process) {// 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. - - var Transform = __webpack_require__(65); - - var binding = __webpack_require__(72); - var util = __webpack_require__(16); - var assert = __webpack_require__(84).ok; - - // zlib doesn't provide these, so kludge them in following the same - // const naming scheme zlib uses. - binding.Z_MIN_WINDOWBITS = 8; - binding.Z_MAX_WINDOWBITS = 15; - binding.Z_DEFAULT_WINDOWBITS = 15; - - // fewer than 64 bytes per chunk is stupid. - // technically it could work with as few as 8, but even 64 bytes - // is absurdly low. Usually a MB or more is best. - binding.Z_MIN_CHUNK = 64; - binding.Z_MAX_CHUNK = Infinity; - binding.Z_DEFAULT_CHUNK = (16 * 1024); - - binding.Z_MIN_MEMLEVEL = 1; - binding.Z_MAX_MEMLEVEL = 9; - binding.Z_DEFAULT_MEMLEVEL = 8; - - binding.Z_MIN_LEVEL = -1; - binding.Z_MAX_LEVEL = 9; - binding.Z_DEFAULT_LEVEL = binding.Z_DEFAULT_COMPRESSION; - - // expose all the zlib constants - Object.keys(binding).forEach(function(k) { - if (k.match(/^Z/)) exports[k] = binding[k]; - }); - - // translation table for return codes. - exports.codes = { - Z_OK: binding.Z_OK, - Z_STREAM_END: binding.Z_STREAM_END, - Z_NEED_DICT: binding.Z_NEED_DICT, - Z_ERRNO: binding.Z_ERRNO, - Z_STREAM_ERROR: binding.Z_STREAM_ERROR, - Z_DATA_ERROR: binding.Z_DATA_ERROR, - Z_MEM_ERROR: binding.Z_MEM_ERROR, - Z_BUF_ERROR: binding.Z_BUF_ERROR, - Z_VERSION_ERROR: binding.Z_VERSION_ERROR - }; - - Object.keys(exports.codes).forEach(function(k) { - exports.codes[exports.codes[k]] = k; - }); - - exports.Deflate = Deflate; - exports.Inflate = Inflate; - exports.Gzip = Gzip; - exports.Gunzip = Gunzip; - exports.DeflateRaw = DeflateRaw; - exports.InflateRaw = InflateRaw; - exports.Unzip = Unzip; - - exports.createDeflate = function(o) { - return new Deflate(o); - }; - - exports.createInflate = function(o) { - return new Inflate(o); - }; - - exports.createDeflateRaw = function(o) { - return new DeflateRaw(o); - }; - - exports.createInflateRaw = function(o) { - return new InflateRaw(o); - }; - - exports.createGzip = function(o) { - return new Gzip(o); - }; - - exports.createGunzip = function(o) { - return new Gunzip(o); - }; - - exports.createUnzip = function(o) { - return new Unzip(o); - }; - - - // Convenience methods. - // compress/decompress a string or buffer in one step. - exports.deflate = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new Deflate(opts), buffer, callback); - }; - - exports.deflateSync = function(buffer, opts) { - return zlibBufferSync(new Deflate(opts), buffer); - }; - - exports.gzip = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new Gzip(opts), buffer, callback); - }; - - exports.gzipSync = function(buffer, opts) { - return zlibBufferSync(new Gzip(opts), buffer); - }; - - exports.deflateRaw = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new DeflateRaw(opts), buffer, callback); - }; - - exports.deflateRawSync = function(buffer, opts) { - return zlibBufferSync(new DeflateRaw(opts), buffer); - }; - - exports.unzip = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new Unzip(opts), buffer, callback); - }; - - exports.unzipSync = function(buffer, opts) { - return zlibBufferSync(new Unzip(opts), buffer); - }; - - exports.inflate = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new Inflate(opts), buffer, callback); - }; - - exports.inflateSync = function(buffer, opts) { - return zlibBufferSync(new Inflate(opts), buffer); - }; - - exports.gunzip = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new Gunzip(opts), buffer, callback); - }; - - exports.gunzipSync = function(buffer, opts) { - return zlibBufferSync(new Gunzip(opts), buffer); - }; - - exports.inflateRaw = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new InflateRaw(opts), buffer, callback); - }; - - exports.inflateRawSync = function(buffer, opts) { - return zlibBufferSync(new InflateRaw(opts), buffer); - }; - - function zlibBuffer(engine, buffer, callback) { - var buffers = []; - var nread = 0; - - engine.on('error', onError); - engine.on('end', onEnd); - - engine.end(buffer); - flow(); - - function flow() { - var chunk; - while (null !== (chunk = engine.read())) { - buffers.push(chunk); - nread += chunk.length; - } - engine.once('readable', flow); - } - - function onError(err) { - engine.removeListener('end', onEnd); - engine.removeListener('readable', flow); - callback(err); - } - - function onEnd() { - var buf = Buffer.concat(buffers, nread); - buffers = []; - callback(null, buf); - engine.close(); - } - } - - function zlibBufferSync(engine, buffer) { - if (typeof buffer === 'string') - buffer = new Buffer(buffer); - if (!Buffer.isBuffer(buffer)) - throw new TypeError('Not a string or buffer'); - - var flushFlag = binding.Z_FINISH; - - return engine._processChunk(buffer, flushFlag); - } - - // generic zlib - // minimal 2-byte header - function Deflate(opts) { - if (!(this instanceof Deflate)) return new Deflate(opts); - Zlib.call(this, opts, binding.DEFLATE); - } - - function Inflate(opts) { - if (!(this instanceof Inflate)) return new Inflate(opts); - Zlib.call(this, opts, binding.INFLATE); - } - - - - // gzip - bigger header, same deflate compression - function Gzip(opts) { - if (!(this instanceof Gzip)) return new Gzip(opts); - Zlib.call(this, opts, binding.GZIP); - } - - function Gunzip(opts) { - if (!(this instanceof Gunzip)) return new Gunzip(opts); - Zlib.call(this, opts, binding.GUNZIP); - } - - - - // raw - no header - function DeflateRaw(opts) { - if (!(this instanceof DeflateRaw)) return new DeflateRaw(opts); - Zlib.call(this, opts, binding.DEFLATERAW); - } - - function InflateRaw(opts) { - if (!(this instanceof InflateRaw)) return new InflateRaw(opts); - Zlib.call(this, opts, binding.INFLATERAW); - } - - - // auto-detect header. - function Unzip(opts) { - if (!(this instanceof Unzip)) return new Unzip(opts); - Zlib.call(this, opts, binding.UNZIP); - } - - - // the Zlib class they all inherit from - // This thing manages the queue of requests, and returns - // true or false if there is anything in the queue when - // you call the .write() method. - - function Zlib(opts, mode) { - this._opts = opts = opts || {}; - this._chunkSize = opts.chunkSize || exports.Z_DEFAULT_CHUNK; - - Transform.call(this, opts); - - if (opts.flush) { - if (opts.flush !== binding.Z_NO_FLUSH && - opts.flush !== binding.Z_PARTIAL_FLUSH && - opts.flush !== binding.Z_SYNC_FLUSH && - opts.flush !== binding.Z_FULL_FLUSH && - opts.flush !== binding.Z_FINISH && - opts.flush !== binding.Z_BLOCK) { - throw new Error('Invalid flush flag: ' + opts.flush); - } - } - this._flushFlag = opts.flush || binding.Z_NO_FLUSH; - - if (opts.chunkSize) { - if (opts.chunkSize < exports.Z_MIN_CHUNK || - opts.chunkSize > exports.Z_MAX_CHUNK) { - throw new Error('Invalid chunk size: ' + opts.chunkSize); - } - } - - if (opts.windowBits) { - if (opts.windowBits < exports.Z_MIN_WINDOWBITS || - opts.windowBits > exports.Z_MAX_WINDOWBITS) { - throw new Error('Invalid windowBits: ' + opts.windowBits); - } - } - - if (opts.level) { - if (opts.level < exports.Z_MIN_LEVEL || - opts.level > exports.Z_MAX_LEVEL) { - throw new Error('Invalid compression level: ' + opts.level); - } - } - - if (opts.memLevel) { - if (opts.memLevel < exports.Z_MIN_MEMLEVEL || - opts.memLevel > exports.Z_MAX_MEMLEVEL) { - throw new Error('Invalid memLevel: ' + opts.memLevel); - } - } - - if (opts.strategy) { - if (opts.strategy != exports.Z_FILTERED && - opts.strategy != exports.Z_HUFFMAN_ONLY && - opts.strategy != exports.Z_RLE && - opts.strategy != exports.Z_FIXED && - opts.strategy != exports.Z_DEFAULT_STRATEGY) { - throw new Error('Invalid strategy: ' + opts.strategy); - } - } - - if (opts.dictionary) { - if (!Buffer.isBuffer(opts.dictionary)) { - throw new Error('Invalid dictionary: it should be a Buffer instance'); - } - } - - this._binding = new binding.Zlib(mode); - - var self = this; - this._hadError = false; - this._binding.onerror = function(message, errno) { - // there is no way to cleanly recover. - // continuing only obscures problems. - self._binding = null; - self._hadError = true; - - var error = new Error(message); - error.errno = errno; - error.code = exports.codes[errno]; - self.emit('error', error); - }; - - var level = exports.Z_DEFAULT_COMPRESSION; - if (typeof opts.level === 'number') level = opts.level; - - var strategy = exports.Z_DEFAULT_STRATEGY; - if (typeof opts.strategy === 'number') strategy = opts.strategy; - - this._binding.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS, - level, - opts.memLevel || exports.Z_DEFAULT_MEMLEVEL, - strategy, - opts.dictionary); - - this._buffer = new Buffer(this._chunkSize); - this._offset = 0; - this._closed = false; - this._level = level; - this._strategy = strategy; - - this.once('end', this.close); - } - - util.inherits(Zlib, Transform); - - Zlib.prototype.params = function(level, strategy, callback) { - if (level < exports.Z_MIN_LEVEL || - level > exports.Z_MAX_LEVEL) { - throw new RangeError('Invalid compression level: ' + level); - } - if (strategy != exports.Z_FILTERED && - strategy != exports.Z_HUFFMAN_ONLY && - strategy != exports.Z_RLE && - strategy != exports.Z_FIXED && - strategy != exports.Z_DEFAULT_STRATEGY) { - throw new TypeError('Invalid strategy: ' + strategy); - } - - if (this._level !== level || this._strategy !== strategy) { - var self = this; - this.flush(binding.Z_SYNC_FLUSH, function() { - self._binding.params(level, strategy); - if (!self._hadError) { - self._level = level; - self._strategy = strategy; - if (callback) callback(); - } - }); - } else { - process.nextTick(callback); - } - }; - - Zlib.prototype.reset = function() { - return this._binding.reset(); - }; - - // This is the _flush function called by the transform class, - // internally, when the last chunk has been written. - Zlib.prototype._flush = function(callback) { - this._transform(new Buffer(0), '', callback); - }; - - Zlib.prototype.flush = function(kind, callback) { - var ws = this._writableState; - - if (typeof kind === 'function' || (kind === void 0 && !callback)) { - callback = kind; - kind = binding.Z_FULL_FLUSH; - } - - if (ws.ended) { - if (callback) - process.nextTick(callback); - } else if (ws.ending) { - if (callback) - this.once('end', callback); - } else if (ws.needDrain) { - var self = this; - this.once('drain', function() { - self.flush(callback); - }); - } else { - this._flushFlag = kind; - this.write(new Buffer(0), '', callback); - } - }; - - Zlib.prototype.close = function(callback) { - if (callback) - process.nextTick(callback); - - if (this._closed) - return; - - this._closed = true; - - this._binding.close(); - - var self = this; - process.nextTick(function() { - self.emit('close'); - }); - }; - - Zlib.prototype._transform = function(chunk, encoding, cb) { - var flushFlag; - var ws = this._writableState; - var ending = ws.ending || ws.ended; - var last = ending && (!chunk || ws.length === chunk.length); - - if (!chunk === null && !Buffer.isBuffer(chunk)) - return cb(new Error('invalid input')); - - // If it's the last chunk, or a final flush, we use the Z_FINISH flush flag. - // If it's explicitly flushing at some other time, then we use - // Z_FULL_FLUSH. Otherwise, use Z_NO_FLUSH for maximum compression - // goodness. - if (last) - flushFlag = binding.Z_FINISH; - else { - flushFlag = this._flushFlag; - // once we've flushed the last of the queue, stop flushing and - // go back to the normal behavior. - if (chunk.length >= ws.length) { - this._flushFlag = this._opts.flush || binding.Z_NO_FLUSH; - } - } - - var self = this; - this._processChunk(chunk, flushFlag, cb); - }; - - Zlib.prototype._processChunk = function(chunk, flushFlag, cb) { - var availInBefore = chunk && chunk.length; - var availOutBefore = this._chunkSize - this._offset; - var inOff = 0; - - var self = this; - - var async = typeof cb === 'function'; - - if (!async) { - var buffers = []; - var nread = 0; - - var error; - this.on('error', function(er) { - error = er; - }); - - do { - var res = this._binding.writeSync(flushFlag, - chunk, // in - inOff, // in_off - availInBefore, // in_len - this._buffer, // out - this._offset, //out_off - availOutBefore); // out_len - } while (!this._hadError && callback(res[0], res[1])); - - if (this._hadError) { - throw error; - } - - var buf = Buffer.concat(buffers, nread); - this.close(); - - return buf; - } - - var req = this._binding.write(flushFlag, - chunk, // in - inOff, // in_off - availInBefore, // in_len - this._buffer, // out - this._offset, //out_off - availOutBefore); // out_len - - req.buffer = chunk; - req.callback = callback; - - function callback(availInAfter, availOutAfter) { - if (self._hadError) - return; - - var have = availOutBefore - availOutAfter; - assert(have >= 0, 'have should not go down'); - - if (have > 0) { - var out = self._buffer.slice(self._offset, self._offset + have); - self._offset += have; - // serve some output to the consumer. - if (async) { - self.push(out); - } else { - buffers.push(out); - nread += out.length; - } - } - - // exhausted the output buffer, or used all the input create a new one. - if (availOutAfter === 0 || self._offset >= self._chunkSize) { - availOutBefore = self._chunkSize; - self._offset = 0; - self._buffer = new Buffer(self._chunkSize); - } - - if (availOutAfter === 0) { - // Not actually done. Need to reprocess. - // Also, update the availInBefore to the availInAfter value, - // so that if we have to hit it a third (fourth, etc.) time, - // it'll have the correct byte counts. - inOff += (availInBefore - availInAfter); - availInBefore = availInAfter; - - if (!async) - return true; - - var newReq = self._binding.write(flushFlag, - chunk, - inOff, - availInBefore, - self._buffer, - self._offset, - self._chunkSize); - newReq.callback = callback; // this same function - newReq.buffer = chunk; - return; - } - - if (!async) - return false; - - // finished with the chunk. - cb(); - } - }; - - util.inherits(Deflate, Zlib); - util.inherits(Inflate, Zlib); - util.inherits(Gzip, Zlib); - util.inherits(Gunzip, Zlib); - util.inherits(DeflateRaw, Zlib); - util.inherits(InflateRaw, Zlib); - util.inherits(Unzip, Zlib); - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer, __webpack_require__(9))) - -/***/ }, -/* 65 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(66) - - -/***/ }, -/* 66 */ -/***/ function(module, exports, __webpack_require__) { - - // 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 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 - // some bits pass through, and others are simply ignored. (That would - // be a valid example of a transform, of course.) - // - // While the output is causally related to the input, it's not a - // necessarily symmetric or synchronous transformation. For example, - // a zlib stream might take multiple plain-text writes(), and then - // emit a single compressed chunk some time in the future. - // - // Here's how this works: - // - // The Transform stream has all the aspects of the readable and writable - // stream classes. When you write(chunk), that calls _write(chunk,cb) - // internally, and returns false if there's a lot of pending writes - // buffered up. When you call read(), that calls _read(n) until - // there's enough pending readable data buffered up. - // - // In a transform stream, the written data is placed in a buffer. When - // _read(n) is called, it transforms the queued up data, calling the - // buffered _write cb's as it consumes chunks. If consuming a single - // written chunk would result in multiple output chunks, then the first - // outputted bit calls the readcb, and subsequent chunks just go into - // the read buffer, and will cause it to emit 'readable' if necessary. - // - // This way, back-pressure is actually determined by the reading side, - // since _read has to be called to start processing a new chunk. However, - // a pathological inflate type of transform can cause excessive buffering - // here. For example, imagine a stream where every byte of input is - // interpreted as an integer from 0-255, and then results in that many - // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in - // 1kb of data being output. In this case, you could write a very small - // amount of input, and end up with a very large amount of output. In - // such a pathological inflating mechanism, there'd be no way to tell - // the system to stop doing the transform. A single 4MB write could - // cause the system to run out of memory. - // - // However, even in such a pathological case, only a single written chunk - // would be consumed, and then the rest would wait (un-transformed) until - // the results of the previous transformed chunk were consumed. - - module.exports = Transform; - - var Duplex = __webpack_require__(67); - - /**/ - var util = __webpack_require__(27); - util.inherits = __webpack_require__(23); - /**/ - - util.inherits(Transform, Duplex); - - - function TransformState(options, stream) { - this.afterTransform = function(er, data) { - return afterTransform(stream, er, data); - }; - - this.needTransform = false; - this.transforming = false; - this.writecb = null; - this.writechunk = null; - } - - function afterTransform(stream, er, data) { - var ts = stream._transformState; - ts.transforming = false; - - var cb = ts.writecb; - - if (!cb) - return stream.emit('error', new Error('no writecb in Transform class')); - - ts.writechunk = null; - ts.writecb = null; - - if (!util.isNullOrUndefined(data)) - stream.push(data); - - if (cb) - cb(er); - - var rs = stream._readableState; - rs.reading = false; - if (rs.needReadable || rs.length < rs.highWaterMark) { - stream._read(rs.highWaterMark); - } - } - - - function Transform(options) { - if (!(this instanceof Transform)) - return new Transform(options); - - Duplex.call(this, options); - - this._transformState = new TransformState(options, this); - - // when the writable side finishes, then flush out anything remaining. - var stream = this; - - // start out asking for a readable event once data is transformed. - this._readableState.needReadable = true; - - // we have implemented the _read method, and done the other things - // that Readable wants before the first _read call, so unset the - // sync guard flag. - this._readableState.sync = false; - - this.once('prefinish', function() { - if (util.isFunction(this._flush)) - this._flush(function(er) { - done(stream, er); - }); - else - done(stream); - }); - } - - Transform.prototype.push = function(chunk, encoding) { - this._transformState.needTransform = false; - return Duplex.prototype.push.call(this, chunk, encoding); - }; - - // This is the part where you do stuff! - // override this function in implementation classes. - // 'chunk' is an input chunk. - // - // Call `push(newChunk)` to pass along transformed output - // to the readable side. You may call 'push' zero or more times. - // - // Call `cb(err)` when you are done with this chunk. If you pass - // an error, then that'll put the hurt on the whole operation. If you - // never call cb(), then you'll never get another chunk. - Transform.prototype._transform = function(chunk, encoding, cb) { - throw new Error('not implemented'); - }; - - Transform.prototype._write = function(chunk, encoding, cb) { - var ts = this._transformState; - ts.writecb = cb; - ts.writechunk = chunk; - ts.writeencoding = encoding; - if (!ts.transforming) { - var rs = this._readableState; - if (ts.needTransform || - rs.needReadable || - rs.length < rs.highWaterMark) - this._read(rs.highWaterMark); - } - }; - - // Doesn't matter what the args are here. - // _transform does all the work. - // That we got here means that the readable side wants more data. - Transform.prototype._read = function(n) { - var ts = this._transformState; - - if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) { - ts.transforming = true; - this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); - } else { - // mark that we need a transform, so that any data that comes in - // will get processed, now that we've asked for it. - ts.needTransform = true; - } - }; - - - function done(stream, er) { - if (er) - return stream.emit('error', er); - - // if there's nothing in the write buffer, then that means - // that nothing more will ever be provided - var ws = stream._writableState; - var ts = stream._transformState; - - if (ws.length) - throw new Error('calling transform done when ws.length != 0'); - - if (ts.transforming) - throw new Error('calling transform done when still transforming'); - - return stream.push(null); - } - - -/***/ }, -/* 67 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {// 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 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 - // Writable. - - module.exports = Duplex; - - /**/ - var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) keys.push(key); - return keys; - } - /**/ - - - /**/ - var util = __webpack_require__(27); - util.inherits = __webpack_require__(23); - /**/ - - var Readable = __webpack_require__(68); - var Writable = __webpack_require__(71); - - util.inherits(Duplex, Readable); - - forEach(objectKeys(Writable.prototype), function(method) { - if (!Duplex.prototype[method]) - Duplex.prototype[method] = Writable.prototype[method]; - }); - - function Duplex(options) { - if (!(this instanceof Duplex)) - return new Duplex(options); - - Readable.call(this, options); - Writable.call(this, options); - - if (options && options.readable === false) - this.readable = false; - - if (options && options.writable === false) - this.writable = false; - - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) - this.allowHalfOpen = false; - - this.once('end', onend); - } - - // the no-half-open enforcer - function onend() { - // if we allow half-open state, or if the writable side ended, - // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) - return; - - // no more data can be written. - // But allow more writes to happen in this tick. - process.nextTick(this.end.bind(this)); - } - - function forEach (xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xs[i], i); - } - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) - -/***/ }, -/* 68 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {// 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; - - /**/ - var isArray = __webpack_require__(69); - /**/ - - - /**/ - var Buffer = __webpack_require__(5).Buffer; - /**/ - - Readable.ReadableState = ReadableState; - - var EE = __webpack_require__(20).EventEmitter; - - /**/ - if (!EE.listenerCount) EE.listenerCount = function(emitter, type) { - return emitter.listeners(type).length; - }; - /**/ - - var Stream = __webpack_require__(22); - - /**/ - var util = __webpack_require__(27); - util.inherits = __webpack_require__(23); - /**/ - - var StringDecoder; - - - /**/ - var debug = __webpack_require__(70); - if (debug && debug.debuglog) { - debug = debug.debuglog('stream'); - } else { - debug = function () {}; - } - /**/ - - - util.inherits(Readable, Stream); - - function ReadableState(options, stream) { - var Duplex = __webpack_require__(67); - - options = options || {}; - - // 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 = options.objectMode ? 16 : 16 * 1024; - this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; - - // cast to ints. - this.highWaterMark = ~~this.highWaterMark; - - this.buffer = []; - this.length = 0; - this.pipes = null; - this.pipesCount = 0; - this.flowing = null; - this.ended = false; - 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. - 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; - - - // 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.readableObjectMode; - - // 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; - - // if true, a maybeReadMore has been scheduled - this.readingMore = false; - - this.decoder = null; - this.encoding = null; - if (options.encoding) { - if (!StringDecoder) - StringDecoder = __webpack_require__(31).StringDecoder; - this.decoder = new StringDecoder(options.encoding); - this.encoding = options.encoding; - } - } - - function Readable(options) { - var Duplex = __webpack_require__(67); - - if (!(this instanceof Readable)) - return new Readable(options); - - this._readableState = new ReadableState(options, this); - - // legacy - this.readable = true; - - Stream.call(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; - - if (util.isString(chunk) && !state.objectMode) { - encoding = encoding || state.defaultEncoding; - if (encoding !== state.encoding) { - chunk = new Buffer(chunk, encoding); - encoding = ''; - } - } - - return readableAddChunk(this, state, chunk, encoding, false); - }; - - // 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 readableAddChunk(stream, state, chunk, encoding, addToFront) { - var er = chunkInvalid(state, chunk); - if (er) { - stream.emit('error', er); - } else if (util.isNullOrUndefined(chunk)) { - state.reading = false; - if (!state.ended) - 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 { - if (state.decoder && !addToFront && !encoding) - chunk = state.decoder.write(chunk); - - if (!addToFront) - state.reading = false; - - // 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); - - if (state.needReadable) - emitReadable(stream); - } - - maybeReadMore(stream, state); - } - } else if (!addToFront) { - state.reading = false; - } - - return needMoreData(state); - } - - - - // 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); - } - - // backwards compatibility. - Readable.prototype.setEncoding = function(enc) { - if (!StringDecoder) - StringDecoder = __webpack_require__(31).StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; - return this; - }; - - // Don't raise the hwm > 128MB - var MAX_HWM = 0x800000; - function roundUpToNextPowerOf2(n) { - if (n >= MAX_HWM) { - n = MAX_HWM; - } else { - // Get the next highest power of 2 - n--; - for (var p = 1; p < 32; p <<= 1) n |= n >> p; - n++; - } - return n; - } - - function howMuchToRead(n, state) { - if (state.length === 0 && state.ended) - return 0; - - if (state.objectMode) - return n === 0 ? 0 : 1; - - if (isNaN(n) || util.isNull(n)) { - // only flow one buffer at a time - if (state.flowing && state.buffer.length) - return state.buffer[0].length; - else - return state.length; - } - - if (n <= 0) - return 0; - - // If we're asking for more than the target buffer level, - // then raise the water mark. Bump up to the next highest - // power of 2, to prevent increasing it excessively in tiny - // amounts. - if (n > state.highWaterMark) - state.highWaterMark = roundUpToNextPowerOf2(n); - - // don't have that much. return null, unless we've ended. - if (n > state.length) { - if (!state.ended) { - state.needReadable = true; - return 0; - } else - return state.length; - } - - return n; - } - - // you can override either this method, or the async _read(n) below. - Readable.prototype.read = function(n) { - debug('read', n); - var state = this._readableState; - var nOrig = n; - - if (!util.isNumber(n) || 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; - } - - // 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); - } - - 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 (doRead && !state.reading) - n = howMuchToRead(nOrig, state); - - var ret; - if (n > 0) - ret = fromList(n, state); - else - ret = null; - - if (util.isNull(ret)) { - state.needReadable = true; - n = 0; - } - - state.length -= n; - - // If we have nothing in the buffer, then we want to know - // as soon as we *do* get something into the buffer. - if (state.length === 0 && !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 && state.length === 0) - endReadable(this); - - if (!util.isNull(ret)) - this.emit('data', ret); - - return ret; - }; - - function chunkInvalid(state, chunk) { - var er = null; - if (!util.isBuffer(chunk) && - !util.isString(chunk) && - !util.isNullOrUndefined(chunk) && - !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - return er; - } - - - function onEofChunk(stream, state) { - if (state.decoder && !state.ended) { - 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); - } - - // 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) - process.nextTick(function() { - emitReadable_(stream); - }); - else - emitReadable_(stream); - } - } - - function emitReadable_(stream) { - debug('emit readable'); - stream.emit('readable'); - flow(stream); - } - - - // 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; - process.nextTick(function() { - maybeReadMore_(stream, state); - }); - } - } - - 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; - } - - // 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('not implemented')); - }; - - Readable.prototype.pipe = function(dest, pipeOpts) { - var src = this; - var state = this._readableState; - - 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); - - var doEnd = (!pipeOpts || pipeOpts.end !== false) && - dest !== process.stdout && - dest !== process.stderr; - - var endFn = doEnd ? onend : cleanup; - if (state.endEmitted) - process.nextTick(endFn); - else - src.once('end', endFn); - - dest.on('unpipe', onunpipe); - function onunpipe(readable) { - debug('onunpipe'); - if (readable === src) { - cleanup(); - } - } - - 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); - - 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); - - // 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(); - } - - src.on('data', ondata); - function ondata(chunk) { - debug('ondata'); - var ret = dest.write(chunk); - if (false === ret) { - debug('false write response, pause', - src._readableState.awaitDrain); - src._readableState.awaitDrain++; - src.pause(); - } - } - - // 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 (EE.listenerCount(dest, 'error') === 0) - dest.emit('error', er); - } - // This is a brutally ugly hack to make sure that our error handler - // is attached before any userland ones. NEVER DO THIS. - if (!dest._events || !dest._events.error) - dest.on('error', onerror); - else if (isArray(dest._events.error)) - dest._events.error.unshift(onerror); - else - dest._events.error = [onerror, dest._events.error]; - - - - // 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; - }; - - function pipeOnDrain(src) { - return function() { - var state = src._readableState; - debug('pipeOnDrain', state.awaitDrain); - if (state.awaitDrain) - state.awaitDrain--; - if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) { - state.flowing = true; - flow(src); - } - }; - } - - - 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 i = indexOf(state.pipes, dest); - if (i === -1) - return this; - - state.pipes.splice(i, 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 listening to data, and it has not explicitly been paused, - // then call resume to start the flow of data on the next tick. - if (ev === 'data' && false !== this._readableState.flowing) { - this.resume(); - } - - if (ev === 'readable' && this.readable) { - var state = this._readableState; - if (!state.readableListening) { - state.readableListening = true; - state.emittedReadable = false; - state.needReadable = true; - if (!state.reading) { - var self = this; - process.nextTick(function() { - debug('readable nexttick read 0'); - self.read(0); - }); - } else if (state.length) { - emitReadable(this, state); - } - } - } - - return res; - }; - Readable.prototype.addListener = Readable.prototype.on; - - // 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; - if (!state.reading) { - debug('resume read 0'); - this.read(0); - } - resume(this, state); - } - return this; - }; - - function resume(stream, state) { - if (!state.resumeScheduled) { - state.resumeScheduled = true; - process.nextTick(function() { - resume_(stream, state); - }); - } - } - - function resume_(stream, state) { - state.resumeScheduled = false; - 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; - }; - - function flow(stream) { - var state = stream._readableState; - debug('flow', state.flowing); - if (state.flowing) { - do { - var chunk = stream.read(); - } while (null !== chunk && state.flowing); - } - } - - // 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); - if (!chunk || !state.objectMode && !chunk.length) - return; - - var ret = self.push(chunk); - if (!ret) { - paused = true; - stream.pause(); - } - }); - - // proxy all the other methods. - // important when wrapping filters and duplexes. - for (var i in stream) { - if (util.isFunction(stream[i]) && util.isUndefined(this[i])) { - 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)); - }); - - // 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; - }; - - - - // exposed for testing purposes only. - Readable._fromList = fromList; - - // Pluck off n bytes from an array of buffers. - // Length is the combined lengths of all the buffers in the list. - function fromList(n, state) { - var list = state.buffer; - var length = state.length; - var stringMode = !!state.decoder; - var objectMode = !!state.objectMode; - var ret; - - // nothing in the list, definitely empty. - if (list.length === 0) - return null; - - if (length === 0) - ret = null; - else if (objectMode) - ret = list.shift(); - else if (!n || n >= length) { - // read it all, truncate the array. - if (stringMode) - ret = list.join(''); - else - ret = Buffer.concat(list, length); - list.length = 0; - } else { - // read just some of it. - if (n < list[0].length) { - // just take a part of the first list item. - // slice is the same for buffers and strings. - var buf = list[0]; - ret = buf.slice(0, n); - list[0] = buf.slice(n); - } else if (n === list[0].length) { - // first list is a perfect match - ret = list.shift(); - } else { - // complex case. - // we have enough to cover it, but it spans past the first buffer. - if (stringMode) - ret = ''; - else - ret = new Buffer(n); - - var c = 0; - for (var i = 0, l = list.length; i < l && c < n; i++) { - var buf = list[0]; - var cpy = Math.min(n - c, buf.length); - - if (stringMode) - ret += buf.slice(0, cpy); - else - buf.copy(ret, c, 0, cpy); - - if (cpy < buf.length) - list[0] = buf.slice(cpy); - else - list.shift(); - - c += cpy; - } - } - } - - return ret; - } - - function endReadable(stream) { - var state = stream._readableState; - - // 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'); - - if (!state.endEmitted) { - state.ended = true; - process.nextTick(function() { - // Check that we didn't get one last unshift. - if (!state.endEmitted && state.length === 0) { - state.endEmitted = true; - stream.readable = false; - stream.emit('end'); - } - }); - } - } - - function forEach (xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xs[i], i); - } - } - - function indexOf (xs, x) { - for (var i = 0, l = xs.length; i < l; i++) { - if (xs[i] === x) return i; - } - return -1; - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) - -/***/ }, -/* 69 */ -/***/ function(module, exports) { - - module.exports = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) == '[object Array]'; - }; - - -/***/ }, -/* 70 */ -/***/ function(module, exports) { - - /* (ignored) */ - -/***/ }, -/* 71 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {// 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, cb), and it'll handle all - // the drain event emission and buffering. - - module.exports = Writable; - - /**/ - var Buffer = __webpack_require__(5).Buffer; - /**/ - - Writable.WritableState = WritableState; - - - /**/ - var util = __webpack_require__(27); - util.inherits = __webpack_require__(23); - /**/ - - var Stream = __webpack_require__(22); - - util.inherits(Writable, Stream); - - function WriteReq(chunk, encoding, cb) { - this.chunk = chunk; - this.encoding = encoding; - this.callback = cb; - } - - function WritableState(options, stream) { - var Duplex = __webpack_require__(67); - - options = options || {}; - - // 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 = options.objectMode ? 16 : 16 * 1024; - this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; - - // 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; - - // cast to ints. - this.highWaterMark = ~~this.highWaterMark; - - 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; - - // 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.buffer = []; - - // number of pending user-supplied write callbacks - // this must be 0 before 'finish' can be emitted - this.pendingcb = 0; - - // emit prefinish if the only thing we're waiting for is _write cbs - // This is relevant for synchronous Transform streams - this.prefinished = false; - - // True if the error was already emitted and should not be thrown again - this.errorEmitted = false; - } - - function Writable(options) { - var Duplex = __webpack_require__(67); - - // Writable ctor is applied to Duplexes, though they're not - // instanceof Writable, they're instanceof Readable. - if (!(this instanceof Writable) && !(this instanceof Duplex)) - return new Writable(options); - - this._writableState = new WritableState(options, this); - - // legacy. - this.writable = true; - - 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 writeAfterEnd(stream, state, cb) { - var er = new Error('write after end'); - // TODO: defer error events consistently everywhere, not just the cb - stream.emit('error', er); - process.nextTick(function() { - 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. - function validChunk(stream, state, chunk, cb) { - var valid = true; - if (!util.isBuffer(chunk) && - !util.isString(chunk) && - !util.isNullOrUndefined(chunk) && - !state.objectMode) { - var er = new TypeError('Invalid non-string/buffer chunk'); - stream.emit('error', er); - process.nextTick(function() { - cb(er); - }); - valid = false; - } - return valid; - } - - Writable.prototype.write = function(chunk, encoding, cb) { - var state = this._writableState; - var ret = false; - - if (util.isFunction(encoding)) { - cb = encoding; - encoding = null; - } - - if (util.isBuffer(chunk)) - encoding = 'buffer'; - else if (!encoding) - encoding = state.defaultEncoding; - - if (!util.isFunction(cb)) - cb = function() {}; - - if (state.ended) - writeAfterEnd(this, state, cb); - else if (validChunk(this, state, chunk, cb)) { - state.pendingcb++; - ret = writeOrBuffer(this, state, chunk, encoding, cb); - } - - return ret; - }; - - Writable.prototype.cork = function() { - var state = this._writableState; - - state.corked++; - }; - - Writable.prototype.uncork = function() { - var state = this._writableState; - - if (state.corked) { - state.corked--; - - if (!state.writing && - !state.corked && - !state.finished && - !state.bufferProcessing && - state.buffer.length) - clearBuffer(this, state); - } - }; - - function decodeChunk(state, chunk, encoding) { - if (!state.objectMode && - state.decodeStrings !== false && - util.isString(chunk)) { - chunk = new Buffer(chunk, encoding); - } - 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); - if (util.isBuffer(chunk)) - encoding = 'buffer'; - var len = state.objectMode ? 1 : chunk.length; - - state.length += len; - - var ret = state.length < state.highWaterMark; - // we must ensure that previous needDrain will not be reset to false. - if (!ret) - state.needDrain = true; - - if (state.writing || state.corked) - state.buffer.push(new WriteReq(chunk, encoding, cb)); - else - doWrite(stream, state, false, len, chunk, encoding, cb); - - return ret; - } - - 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; - } - - function onwriteError(stream, state, sync, er, cb) { - if (sync) - process.nextTick(function() { - state.pendingcb--; - cb(er); - }); - else { - state.pendingcb--; - cb(er); - } - - stream._writableState.errorEmitted = true; - stream.emit('error', er); - } - - 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); - - 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(stream, state); - - if (!finished && - !state.corked && - !state.bufferProcessing && - state.buffer.length) { - clearBuffer(stream, state); - } - - if (sync) { - process.nextTick(function() { - afterWrite(stream, state, finished, cb); - }); - } else { - afterWrite(stream, state, finished, cb); - } - } - } - - function afterWrite(stream, state, finished, cb) { - if (!finished) - onwriteDrain(stream, state); - state.pendingcb--; - cb(); - finishMaybe(stream, state); - } - - // 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 there's something in the buffer waiting, then process it - function clearBuffer(stream, state) { - state.bufferProcessing = true; - - if (stream._writev && state.buffer.length > 1) { - // Fast case, write everything using _writev() - var cbs = []; - for (var c = 0; c < state.buffer.length; c++) - cbs.push(state.buffer[c].callback); - - // count the one we are adding, as well. - // TODO(isaacs) clean this up - state.pendingcb++; - doWrite(stream, state, true, state.length, state.buffer, '', function(err) { - for (var i = 0; i < cbs.length; i++) { - state.pendingcb--; - cbs[i](err); - } - }); - - // Clear buffer - state.buffer = []; - } else { - // Slow case, write chunks one-by-one - for (var c = 0; c < state.buffer.length; c++) { - var entry = state.buffer[c]; - var chunk = entry.chunk; - var encoding = entry.encoding; - var cb = entry.callback; - var len = state.objectMode ? 1 : chunk.length; - - doWrite(stream, state, false, len, chunk, encoding, cb); - - // 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) { - c++; - break; - } - } - - if (c < state.buffer.length) - state.buffer = state.buffer.slice(c); - else - state.buffer.length = 0; - } - - state.bufferProcessing = false; - } - - Writable.prototype._write = function(chunk, encoding, cb) { - cb(new Error('not implemented')); - - }; - - Writable.prototype._writev = null; - - Writable.prototype.end = function(chunk, encoding, cb) { - var state = this._writableState; - - if (util.isFunction(chunk)) { - cb = chunk; - chunk = null; - encoding = null; - } else if (util.isFunction(encoding)) { - cb = encoding; - encoding = null; - } - - if (!util.isNullOrUndefined(chunk)) - this.write(chunk, encoding); - - // .end() fully uncorks - if (state.corked) { - state.corked = 1; - this.uncork(); - } - - // ignore unnecessary end() calls. - if (!state.ending && !state.finished) - endWritable(this, state, cb); - }; - - - function needFinish(stream, state) { - return (state.ending && - state.length === 0 && - !state.finished && - !state.writing); - } - - function prefinish(stream, state) { - if (!state.prefinished) { - state.prefinished = true; - stream.emit('prefinish'); - } - } - - function finishMaybe(stream, state) { - var need = needFinish(stream, state); - if (need) { - if (state.pendingcb === 0) { - prefinish(stream, state); - state.finished = true; - stream.emit('finish'); - } else - prefinish(stream, state); - } - return need; - } - - function endWritable(stream, state, cb) { - state.ending = true; - finishMaybe(stream, state); - if (cb) { - if (state.finished) - process.nextTick(cb); - else - stream.once('finish', cb); - } - state.ended = true; - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) - -/***/ }, -/* 72 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process, Buffer) {var msg = __webpack_require__(73); - var zstream = __webpack_require__(74); - var zlib_deflate = __webpack_require__(75); - var zlib_inflate = __webpack_require__(80); - var constants = __webpack_require__(83); - - for (var key in constants) { - exports[key] = constants[key]; - } - - // zlib modes - exports.NONE = 0; - exports.DEFLATE = 1; - exports.INFLATE = 2; - exports.GZIP = 3; - exports.GUNZIP = 4; - exports.DEFLATERAW = 5; - exports.INFLATERAW = 6; - exports.UNZIP = 7; - - /** - * Emulate Node's zlib C++ layer for use by the JS layer in index.js - */ - function Zlib(mode) { - if (mode < exports.DEFLATE || mode > exports.UNZIP) - throw new TypeError("Bad argument"); - - this.mode = mode; - this.init_done = false; - this.write_in_progress = false; - this.pending_close = false; - this.windowBits = 0; - this.level = 0; - this.memLevel = 0; - this.strategy = 0; - this.dictionary = null; - } - - Zlib.prototype.init = function(windowBits, level, memLevel, strategy, dictionary) { - this.windowBits = windowBits; - this.level = level; - this.memLevel = memLevel; - this.strategy = strategy; - // dictionary not supported. - - if (this.mode === exports.GZIP || this.mode === exports.GUNZIP) - this.windowBits += 16; - - if (this.mode === exports.UNZIP) - this.windowBits += 32; - - if (this.mode === exports.DEFLATERAW || this.mode === exports.INFLATERAW) - this.windowBits = -this.windowBits; - - this.strm = new zstream(); - - switch (this.mode) { - case exports.DEFLATE: - case exports.GZIP: - case exports.DEFLATERAW: - var status = zlib_deflate.deflateInit2( - this.strm, - this.level, - exports.Z_DEFLATED, - this.windowBits, - this.memLevel, - this.strategy - ); - break; - case exports.INFLATE: - case exports.GUNZIP: - case exports.INFLATERAW: - case exports.UNZIP: - var status = zlib_inflate.inflateInit2( - this.strm, - this.windowBits - ); - break; - default: - throw new Error("Unknown mode " + this.mode); - } - - if (status !== exports.Z_OK) { - this._error(status); - return; - } - - this.write_in_progress = false; - this.init_done = true; - }; - - Zlib.prototype.params = function() { - throw new Error("deflateParams Not supported"); - }; - - Zlib.prototype._writeCheck = function() { - if (!this.init_done) - throw new Error("write before init"); - - if (this.mode === exports.NONE) - throw new Error("already finalized"); - - if (this.write_in_progress) - throw new Error("write already in progress"); - - if (this.pending_close) - throw new Error("close is pending"); - }; - - Zlib.prototype.write = function(flush, input, in_off, in_len, out, out_off, out_len) { - this._writeCheck(); - this.write_in_progress = true; - - var self = this; - process.nextTick(function() { - self.write_in_progress = false; - var res = self._write(flush, input, in_off, in_len, out, out_off, out_len); - self.callback(res[0], res[1]); - - if (self.pending_close) - self.close(); - }); - - return this; - }; - - // set method for Node buffers, used by pako - function bufferSet(data, offset) { - for (var i = 0; i < data.length; i++) { - this[offset + i] = data[i]; - } - } - - Zlib.prototype.writeSync = function(flush, input, in_off, in_len, out, out_off, out_len) { - this._writeCheck(); - return this._write(flush, input, in_off, in_len, out, out_off, out_len); - }; - - Zlib.prototype._write = function(flush, input, in_off, in_len, out, out_off, out_len) { - this.write_in_progress = true; - - if (flush !== exports.Z_NO_FLUSH && - flush !== exports.Z_PARTIAL_FLUSH && - flush !== exports.Z_SYNC_FLUSH && - flush !== exports.Z_FULL_FLUSH && - flush !== exports.Z_FINISH && - flush !== exports.Z_BLOCK) { - throw new Error("Invalid flush value"); - } - - if (input == null) { - input = new Buffer(0); - in_len = 0; - in_off = 0; - } - - if (out._set) - out.set = out._set; - else - out.set = bufferSet; - - var strm = this.strm; - strm.avail_in = in_len; - strm.input = input; - strm.next_in = in_off; - strm.avail_out = out_len; - strm.output = out; - strm.next_out = out_off; - - switch (this.mode) { - case exports.DEFLATE: - case exports.GZIP: - case exports.DEFLATERAW: - var status = zlib_deflate.deflate(strm, flush); - break; - case exports.UNZIP: - case exports.INFLATE: - case exports.GUNZIP: - case exports.INFLATERAW: - var status = zlib_inflate.inflate(strm, flush); - break; - default: - throw new Error("Unknown mode " + this.mode); - } - - if (status !== exports.Z_STREAM_END && status !== exports.Z_OK) { - this._error(status); - } - - this.write_in_progress = false; - return [strm.avail_in, strm.avail_out]; - }; - - Zlib.prototype.close = function() { - if (this.write_in_progress) { - this.pending_close = true; - return; - } - - this.pending_close = false; - - if (this.mode === exports.DEFLATE || this.mode === exports.GZIP || this.mode === exports.DEFLATERAW) { - zlib_deflate.deflateEnd(this.strm); - } else { - zlib_inflate.inflateEnd(this.strm); - } - - this.mode = exports.NONE; - }; - - Zlib.prototype.reset = function() { - switch (this.mode) { - case exports.DEFLATE: - case exports.DEFLATERAW: - var status = zlib_deflate.deflateReset(this.strm); - break; - case exports.INFLATE: - case exports.INFLATERAW: - var status = zlib_inflate.inflateReset(this.strm); - break; - } - - if (status !== exports.Z_OK) { - this._error(status); - } - }; - - Zlib.prototype._error = function(status) { - this.onerror(msg[status] + ': ' + this.strm.msg, status); - - this.write_in_progress = false; - if (this.pending_close) - this.close(); - }; - - exports.Zlib = Zlib; - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9), __webpack_require__(5).Buffer)) - -/***/ }, -/* 73 */ -/***/ function(module, exports) { - - 'use strict'; - - module.exports = { - 2: 'need dictionary', /* Z_NEED_DICT 2 */ - 1: 'stream end', /* Z_STREAM_END 1 */ - 0: '', /* Z_OK 0 */ - '-1': 'file error', /* Z_ERRNO (-1) */ - '-2': 'stream error', /* Z_STREAM_ERROR (-2) */ - '-3': 'data error', /* Z_DATA_ERROR (-3) */ - '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */ - '-5': 'buffer error', /* Z_BUF_ERROR (-5) */ - '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */ - }; - - -/***/ }, -/* 74 */ -/***/ function(module, exports) { - - 'use strict'; - - - function ZStream() { - /* next input byte */ - this.input = null; // JS specific, because we have no pointers - this.next_in = 0; - /* number of bytes available at input */ - this.avail_in = 0; - /* total number of input bytes read so far */ - this.total_in = 0; - /* next output byte should be put there */ - this.output = null; // JS specific, because we have no pointers - this.next_out = 0; - /* remaining free space at output */ - this.avail_out = 0; - /* total number of bytes output so far */ - this.total_out = 0; - /* last error message, NULL if no error */ - this.msg = ''/*Z_NULL*/; - /* not visible by applications */ - this.state = null; - /* best guess about the data type: binary or text */ - this.data_type = 2/*Z_UNKNOWN*/; - /* adler32 value of the uncompressed data */ - this.adler = 0; - } - - module.exports = ZStream; - - -/***/ }, -/* 75 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(76); - var trees = __webpack_require__(77); - var adler32 = __webpack_require__(78); - var crc32 = __webpack_require__(79); - var msg = __webpack_require__(73); - - /* Public constants ==========================================================*/ - /* ===========================================================================*/ - - - /* Allowed flush values; see deflate() and inflate() below for details */ - var Z_NO_FLUSH = 0; - var Z_PARTIAL_FLUSH = 1; - //var Z_SYNC_FLUSH = 2; - var Z_FULL_FLUSH = 3; - var Z_FINISH = 4; - var Z_BLOCK = 5; - //var Z_TREES = 6; - - - /* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - var Z_OK = 0; - var Z_STREAM_END = 1; - //var Z_NEED_DICT = 2; - //var Z_ERRNO = -1; - var Z_STREAM_ERROR = -2; - var Z_DATA_ERROR = -3; - //var Z_MEM_ERROR = -4; - var Z_BUF_ERROR = -5; - //var Z_VERSION_ERROR = -6; - - - /* compression levels */ - //var Z_NO_COMPRESSION = 0; - //var Z_BEST_SPEED = 1; - //var Z_BEST_COMPRESSION = 9; - var Z_DEFAULT_COMPRESSION = -1; - - - var Z_FILTERED = 1; - var Z_HUFFMAN_ONLY = 2; - var Z_RLE = 3; - var Z_FIXED = 4; - var Z_DEFAULT_STRATEGY = 0; - - /* Possible values of the data_type field (though see inflate()) */ - //var Z_BINARY = 0; - //var Z_TEXT = 1; - //var Z_ASCII = 1; // = Z_TEXT - var Z_UNKNOWN = 2; - - - /* The deflate compression method */ - var Z_DEFLATED = 8; - - /*============================================================================*/ - - - var MAX_MEM_LEVEL = 9; - /* Maximum value for memLevel in deflateInit2 */ - var MAX_WBITS = 15; - /* 32K LZ77 window */ - var DEF_MEM_LEVEL = 8; - - - var LENGTH_CODES = 29; - /* number of length codes, not counting the special END_BLOCK code */ - var LITERALS = 256; - /* number of literal bytes 0..255 */ - var L_CODES = LITERALS + 1 + LENGTH_CODES; - /* number of Literal or Length codes, including the END_BLOCK code */ - var D_CODES = 30; - /* number of distance codes */ - var BL_CODES = 19; - /* number of codes used to transfer the bit lengths */ - var HEAP_SIZE = 2 * L_CODES + 1; - /* maximum heap size */ - var MAX_BITS = 15; - /* All codes must not exceed MAX_BITS bits */ - - var MIN_MATCH = 3; - var MAX_MATCH = 258; - var MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1); - - var PRESET_DICT = 0x20; - - var INIT_STATE = 42; - var EXTRA_STATE = 69; - var NAME_STATE = 73; - var COMMENT_STATE = 91; - var HCRC_STATE = 103; - var BUSY_STATE = 113; - var FINISH_STATE = 666; - - var BS_NEED_MORE = 1; /* block not completed, need more input or more output */ - var BS_BLOCK_DONE = 2; /* block flush performed */ - var BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */ - var BS_FINISH_DONE = 4; /* finish done, accept no more input or output */ - - var OS_CODE = 0x03; // Unix :) . Don't detect, use this default. - - function err(strm, errorCode) { - strm.msg = msg[errorCode]; - return errorCode; - } - - function rank(f) { - return ((f) << 1) - ((f) > 4 ? 9 : 0); - } - - function zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } } - - - /* ========================================================================= - * Flush as much pending output as possible. All deflate() output goes - * through this function so some applications may wish to modify it - * to avoid allocating a large strm->output buffer and copying into it. - * (See also read_buf()). - */ - function flush_pending(strm) { - var s = strm.state; - - //_tr_flush_bits(s); - var len = s.pending; - if (len > strm.avail_out) { - len = strm.avail_out; - } - if (len === 0) { return; } - - utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out); - strm.next_out += len; - s.pending_out += len; - strm.total_out += len; - strm.avail_out -= len; - s.pending -= len; - if (s.pending === 0) { - s.pending_out = 0; - } - } - - - function flush_block_only(s, last) { - trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last); - s.block_start = s.strstart; - flush_pending(s.strm); - } - - - function put_byte(s, b) { - s.pending_buf[s.pending++] = b; - } - - - /* ========================================================================= - * Put a short in the pending buffer. The 16-bit value is put in MSB order. - * IN assertion: the stream state is correct and there is enough room in - * pending_buf. - */ - function putShortMSB(s, b) { - // put_byte(s, (Byte)(b >> 8)); - // put_byte(s, (Byte)(b & 0xff)); - s.pending_buf[s.pending++] = (b >>> 8) & 0xff; - s.pending_buf[s.pending++] = b & 0xff; - } - - - /* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->input buffer and copying from it. - * (See also flush_pending()). - */ - function read_buf(strm, buf, start, size) { - var len = strm.avail_in; - - if (len > size) { len = size; } - if (len === 0) { return 0; } - - strm.avail_in -= len; - - // zmemcpy(buf, strm->next_in, len); - utils.arraySet(buf, strm.input, strm.next_in, len, start); - if (strm.state.wrap === 1) { - strm.adler = adler32(strm.adler, buf, len, start); - } - - else if (strm.state.wrap === 2) { - strm.adler = crc32(strm.adler, buf, len, start); - } - - strm.next_in += len; - strm.total_in += len; - - return len; - } - - - /* =========================================================================== - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - * OUT assertion: the match length is not greater than s->lookahead. - */ - function longest_match(s, cur_match) { - var chain_length = s.max_chain_length; /* max hash chain length */ - var scan = s.strstart; /* current string */ - var match; /* matched string */ - var len; /* length of current match */ - var best_len = s.prev_length; /* best match length so far */ - var nice_match = s.nice_match; /* stop if match long enough */ - var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ? - s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/; - - var _win = s.window; // shortcut - - var wmask = s.w_mask; - var prev = s.prev; - - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. - */ - - var strend = s.strstart + MAX_MATCH; - var scan_end1 = _win[scan + best_len - 1]; - var scan_end = _win[scan + best_len]; - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - /* Do not waste too much time if we already have a good match: */ - if (s.prev_length >= s.good_match) { - chain_length >>= 2; - } - /* Do not look for matches beyond the end of the input. This is necessary - * to make deflate deterministic. - */ - if (nice_match > s.lookahead) { nice_match = s.lookahead; } - - // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - do { - // Assert(cur_match < s->strstart, "no future"); - match = cur_match; - - /* Skip to next match if the match length cannot increase - * or if the match length is less than 2. Note that the checks below - * for insufficient lookahead only occur occasionally for performance - * reasons. Therefore uninitialized memory will be accessed, and - * conditional jumps will be made that depend on those values. - * However the length of the match is limited to the lookahead, so - * the output of deflate is not affected by the uninitialized values. - */ - - if (_win[match + best_len] !== scan_end || - _win[match + best_len - 1] !== scan_end1 || - _win[match] !== _win[scan] || - _win[++match] !== _win[scan + 1]) { - continue; - } - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2; - match++; - // Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - /*jshint noempty:false*/ - } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && - _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && - _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && - _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && - scan < strend); - - // Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (strend - scan); - scan = strend - MAX_MATCH; - - if (len > best_len) { - s.match_start = cur_match; - best_len = len; - if (len >= nice_match) { - break; - } - scan_end1 = _win[scan + best_len - 1]; - scan_end = _win[scan + best_len]; - } - } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0); - - if (best_len <= s.lookahead) { - return best_len; - } - return s.lookahead; - } - - - /* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ - function fill_window(s) { - var _w_size = s.w_size; - var p, n, m, more, str; - - //Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); - - do { - more = s.window_size - s.lookahead - s.strstart; - - // JS ints have 32 bit, block below not needed - /* Deal with !@#$% 64K limit: */ - //if (sizeof(int) <= 2) { - // if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - // more = wsize; - // - // } else if (more == (unsigned)(-1)) { - // /* Very unlikely, but possible on 16 bit machine if - // * strstart == 0 && lookahead == 1 (input done a byte at time) - // */ - // more--; - // } - //} - - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) { - - utils.arraySet(s.window, s.window, _w_size, _w_size, 0); - s.match_start -= _w_size; - s.strstart -= _w_size; - /* we now have strstart >= MAX_DIST */ - s.block_start -= _w_size; - - /* Slide the hash table (could be avoided with 32 bit values - at the expense of memory usage). We slide even when level == 0 - to keep the hash table consistent if we switch back to level > 0 - later. (Using level 0 permanently is not an optimal usage of - zlib, so we don't care about this pathological case.) - */ - - n = s.hash_size; - p = n; - do { - m = s.head[--p]; - s.head[p] = (m >= _w_size ? m - _w_size : 0); - } while (--n); - - n = _w_size; - p = n; - do { - m = s.prev[--p]; - s.prev[p] = (m >= _w_size ? m - _w_size : 0); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); - - more += _w_size; - } - if (s.strm.avail_in === 0) { - break; - } - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - //Assert(more >= 2, "more < 2"); - n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more); - s.lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s.lookahead + s.insert >= MIN_MATCH) { - str = s.strstart - s.insert; - s.ins_h = s.window[str]; - - /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */ - s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask; - //#if MIN_MATCH != 3 - // Call update_hash() MIN_MATCH-3 more times - //#endif - while (s.insert) { - /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */ - s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask; - - s.prev[str & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = str; - str++; - s.insert--; - if (s.lookahead + s.insert < MIN_MATCH) { - break; - } - } - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0); - - /* If the WIN_INIT bytes after the end of the current data have never been - * written, then zero those bytes in order to avoid memory check reports of - * the use of uninitialized (or uninitialised as Julian writes) bytes by - * the longest match routines. Update the high water mark for the next - * time through here. WIN_INIT is set to MAX_MATCH since the longest match - * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. - */ - // if (s.high_water < s.window_size) { - // var curr = s.strstart + s.lookahead; - // var init = 0; - // - // if (s.high_water < curr) { - // /* Previous high water mark below current data -- zero WIN_INIT - // * bytes or up to end of window, whichever is less. - // */ - // init = s.window_size - curr; - // if (init > WIN_INIT) - // init = WIN_INIT; - // zmemzero(s->window + curr, (unsigned)init); - // s->high_water = curr + init; - // } - // else if (s->high_water < (ulg)curr + WIN_INIT) { - // /* High water mark at or above current data, but below current data - // * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up - // * to end of window, whichever is less. - // */ - // init = (ulg)curr + WIN_INIT - s->high_water; - // if (init > s->window_size - s->high_water) - // init = s->window_size - s->high_water; - // zmemzero(s->window + s->high_water, (unsigned)init); - // s->high_water += init; - // } - // } - // - // Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, - // "not enough room for search"); - } - - /* =========================================================================== - * Copy without compression as much as possible from the input stream, return - * the current block state. - * This function does not insert new strings in the dictionary since - * uncompressible data is probably not useful. This function is used - * only for the level=0 compression option. - * NOTE: this function should be optimized to avoid extra copying from - * window to pending_buf. - */ - function deflate_stored(s, flush) { - /* Stored blocks are limited to 0xffff bytes, pending_buf is limited - * to pending_buf_size, and each stored block has a 5 byte header: - */ - var max_block_size = 0xffff; - - if (max_block_size > s.pending_buf_size - 5) { - max_block_size = s.pending_buf_size - 5; - } - - /* Copy as much as possible from input to output: */ - for (;;) { - /* Fill the window as much as possible: */ - if (s.lookahead <= 1) { - - //Assert(s->strstart < s->w_size+MAX_DIST(s) || - // s->block_start >= (long)s->w_size, "slide too late"); - // if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) || - // s.block_start >= s.w_size)) { - // throw new Error("slide too late"); - // } - - fill_window(s); - if (s.lookahead === 0 && flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - - if (s.lookahead === 0) { - break; - } - /* flush the current block */ - } - //Assert(s->block_start >= 0L, "block gone"); - // if (s.block_start < 0) throw new Error("block gone"); - - s.strstart += s.lookahead; - s.lookahead = 0; - - /* Emit a stored block if pending_buf will be full: */ - var max_start = s.block_start + max_block_size; - - if (s.strstart === 0 || s.strstart >= max_start) { - /* strstart == 0 is possible when wraparound on 16-bit machine */ - s.lookahead = s.strstart - max_start; - s.strstart = max_start; - /*** FLUSH_BLOCK(s, 0); ***/ - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - /***/ - - - } - /* Flush if we may have to slide, otherwise block_start may become - * negative and the data will be gone: - */ - if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) { - /*** FLUSH_BLOCK(s, 0); ***/ - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - /***/ - } - } - - s.insert = 0; - - if (flush === Z_FINISH) { - /*** FLUSH_BLOCK(s, 1); ***/ - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; - } - /***/ - return BS_FINISH_DONE; - } - - if (s.strstart > s.block_start) { - /*** FLUSH_BLOCK(s, 0); ***/ - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - /***/ - } - - return BS_NEED_MORE; - } - - /* =========================================================================== - * Compress as much as possible from the input stream, return the current - * block state. - * This function does not perform lazy evaluation of matches and inserts - * new strings in the dictionary only for unmatched strings or for short - * matches. It is used only for the fast compression options. - */ - function deflate_fast(s, flush) { - var hash_head; /* head of the hash chain */ - var bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s.lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - if (s.lookahead === 0) { - break; /* flush the current block */ - } - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - hash_head = 0/*NIL*/; - if (s.lookahead >= MIN_MATCH) { - /*** INSERT_STRING(s, s.strstart, hash_head); ***/ - s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; - hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = s.strstart; - /***/ - } - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match_length < MIN_MATCH - */ - if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - s.match_length = longest_match(s, hash_head); - /* longest_match() sets match_start */ - } - if (s.match_length >= MIN_MATCH) { - // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only - - /*** _tr_tally_dist(s, s.strstart - s.match_start, - s.match_length - MIN_MATCH, bflush); ***/ - bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH); - - s.lookahead -= s.match_length; - - /* Insert new strings in the hash table only if the match length - * is not too large. This saves time but degrades compression. - */ - if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) { - s.match_length--; /* string at strstart already in table */ - do { - s.strstart++; - /*** INSERT_STRING(s, s.strstart, hash_head); ***/ - s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; - hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = s.strstart; - /***/ - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. - */ - } while (--s.match_length !== 0); - s.strstart++; - } else - { - s.strstart += s.match_length; - s.match_length = 0; - s.ins_h = s.window[s.strstart]; - /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */ - s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask; - - //#if MIN_MATCH != 3 - // Call UPDATE_HASH() MIN_MATCH-3 more times - //#endif - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not - * matter since it will be recomputed at next deflate call. - */ - } - } else { - /* No match, output a literal byte */ - //Tracevv((stderr,"%c", s.window[s.strstart])); - /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/ - bflush = trees._tr_tally(s, 0, s.window[s.strstart]); - - s.lookahead--; - s.strstart++; - } - if (bflush) { - /*** FLUSH_BLOCK(s, 0); ***/ - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - /***/ - } - } - s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1); - if (flush === Z_FINISH) { - /*** FLUSH_BLOCK(s, 1); ***/ - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; - } - /***/ - return BS_FINISH_DONE; - } - if (s.last_lit) { - /*** FLUSH_BLOCK(s, 0); ***/ - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - /***/ - } - return BS_BLOCK_DONE; - } - - /* =========================================================================== - * Same as above, but achieves better compression. We use a lazy - * evaluation for matches: a match is finally adopted only if there is - * no better match at the next window position. - */ - function deflate_slow(s, flush) { - var hash_head; /* head of hash chain */ - var bflush; /* set if current block must be flushed */ - - var max_insert; - - /* Process the input block. */ - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s.lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - if (s.lookahead === 0) { break; } /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - hash_head = 0/*NIL*/; - if (s.lookahead >= MIN_MATCH) { - /*** INSERT_STRING(s, s.strstart, hash_head); ***/ - s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; - hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = s.strstart; - /***/ - } - - /* Find the longest match, discarding those <= prev_length. - */ - s.prev_length = s.match_length; - s.prev_match = s.match_start; - s.match_length = MIN_MATCH - 1; - - if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match && - s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - s.match_length = longest_match(s, hash_head); - /* longest_match() sets match_start */ - - if (s.match_length <= 5 && - (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) { - - /* If prev_match is also MIN_MATCH, match_start is garbage - * but we will ignore the current match anyway. - */ - s.match_length = MIN_MATCH - 1; - } - } - /* If there was a match at the previous step and the current - * match is not better, output the previous match: - */ - if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) { - max_insert = s.strstart + s.lookahead - MIN_MATCH; - /* Do not insert strings in hash table beyond this. */ - - //check_match(s, s.strstart-1, s.prev_match, s.prev_length); - - /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match, - s.prev_length - MIN_MATCH, bflush);***/ - bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH); - /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. If there is not - * enough lookahead, the last two strings are not inserted in - * the hash table. - */ - s.lookahead -= s.prev_length - 1; - s.prev_length -= 2; - do { - if (++s.strstart <= max_insert) { - /*** INSERT_STRING(s, s.strstart, hash_head); ***/ - s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; - hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = s.strstart; - /***/ - } - } while (--s.prev_length !== 0); - s.match_available = 0; - s.match_length = MIN_MATCH - 1; - s.strstart++; - - if (bflush) { - /*** FLUSH_BLOCK(s, 0); ***/ - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - /***/ - } - - } else if (s.match_available) { - /* If there was no match at the previous position, output a - * single literal. If there was a match but the current match - * is longer, truncate the previous match to a single literal. - */ - //Tracevv((stderr,"%c", s->window[s->strstart-1])); - /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/ - bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]); - - if (bflush) { - /*** FLUSH_BLOCK_ONLY(s, 0) ***/ - flush_block_only(s, false); - /***/ - } - s.strstart++; - s.lookahead--; - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } else { - /* There is no previous match to compare with, wait for - * the next step to decide. - */ - s.match_available = 1; - s.strstart++; - s.lookahead--; - } - } - //Assert (flush != Z_NO_FLUSH, "no flush?"); - if (s.match_available) { - //Tracevv((stderr,"%c", s->window[s->strstart-1])); - /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/ - bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]); - - s.match_available = 0; - } - s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1; - if (flush === Z_FINISH) { - /*** FLUSH_BLOCK(s, 1); ***/ - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; - } - /***/ - return BS_FINISH_DONE; - } - if (s.last_lit) { - /*** FLUSH_BLOCK(s, 0); ***/ - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - /***/ - } - - return BS_BLOCK_DONE; - } - - - /* =========================================================================== - * For Z_RLE, simply look for runs of bytes, generate matches only of distance - * one. Do not maintain a hash table. (It will be regenerated if this run of - * deflate switches away from Z_RLE.) - */ - function deflate_rle(s, flush) { - var bflush; /* set if current block must be flushed */ - var prev; /* byte at distance one to match */ - var scan, strend; /* scan goes up to strend for length of run */ - - var _win = s.window; - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the longest run, plus one for the unrolled loop. - */ - if (s.lookahead <= MAX_MATCH) { - fill_window(s); - if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - if (s.lookahead === 0) { break; } /* flush the current block */ - } - - /* See how many times the previous byte repeats */ - s.match_length = 0; - if (s.lookahead >= MIN_MATCH && s.strstart > 0) { - scan = s.strstart - 1; - prev = _win[scan]; - if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) { - strend = s.strstart + MAX_MATCH; - do { - /*jshint noempty:false*/ - } while (prev === _win[++scan] && prev === _win[++scan] && - prev === _win[++scan] && prev === _win[++scan] && - prev === _win[++scan] && prev === _win[++scan] && - prev === _win[++scan] && prev === _win[++scan] && - scan < strend); - s.match_length = MAX_MATCH - (strend - scan); - if (s.match_length > s.lookahead) { - s.match_length = s.lookahead; - } - } - //Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan"); - } - - /* Emit match if have run of MIN_MATCH or longer, else emit literal */ - if (s.match_length >= MIN_MATCH) { - //check_match(s, s.strstart, s.strstart - 1, s.match_length); - - /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/ - bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH); - - s.lookahead -= s.match_length; - s.strstart += s.match_length; - s.match_length = 0; - } else { - /* No match, output a literal byte */ - //Tracevv((stderr,"%c", s->window[s->strstart])); - /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/ - bflush = trees._tr_tally(s, 0, s.window[s.strstart]); - - s.lookahead--; - s.strstart++; - } - if (bflush) { - /*** FLUSH_BLOCK(s, 0); ***/ - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - /***/ - } - } - s.insert = 0; - if (flush === Z_FINISH) { - /*** FLUSH_BLOCK(s, 1); ***/ - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; - } - /***/ - return BS_FINISH_DONE; - } - if (s.last_lit) { - /*** FLUSH_BLOCK(s, 0); ***/ - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - /***/ - } - return BS_BLOCK_DONE; - } - - /* =========================================================================== - * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. - * (It will be regenerated if this run of deflate switches away from Huffman.) - */ - function deflate_huff(s, flush) { - var bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we have a literal to write. */ - if (s.lookahead === 0) { - fill_window(s); - if (s.lookahead === 0) { - if (flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - break; /* flush the current block */ - } - } - - /* Output a literal byte */ - s.match_length = 0; - //Tracevv((stderr,"%c", s->window[s->strstart])); - /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/ - bflush = trees._tr_tally(s, 0, s.window[s.strstart]); - s.lookahead--; - s.strstart++; - if (bflush) { - /*** FLUSH_BLOCK(s, 0); ***/ - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - /***/ - } - } - s.insert = 0; - if (flush === Z_FINISH) { - /*** FLUSH_BLOCK(s, 1); ***/ - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; - } - /***/ - return BS_FINISH_DONE; - } - if (s.last_lit) { - /*** FLUSH_BLOCK(s, 0); ***/ - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - /***/ - } - return BS_BLOCK_DONE; - } - - /* Values for max_lazy_match, good_match and max_chain_length, depending on - * the desired pack level (0..9). The values given below have been tuned to - * exclude worst case performance for pathological files. Better values may be - * found for specific files. - */ - function Config(good_length, max_lazy, nice_length, max_chain, func) { - this.good_length = good_length; - this.max_lazy = max_lazy; - this.nice_length = nice_length; - this.max_chain = max_chain; - this.func = func; - } - - var configuration_table; - - configuration_table = [ - /* good lazy nice chain */ - new Config(0, 0, 0, 0, deflate_stored), /* 0 store only */ - new Config(4, 4, 8, 4, deflate_fast), /* 1 max speed, no lazy matches */ - new Config(4, 5, 16, 8, deflate_fast), /* 2 */ - new Config(4, 6, 32, 32, deflate_fast), /* 3 */ - - new Config(4, 4, 16, 16, deflate_slow), /* 4 lazy matches */ - new Config(8, 16, 32, 32, deflate_slow), /* 5 */ - new Config(8, 16, 128, 128, deflate_slow), /* 6 */ - new Config(8, 32, 128, 256, deflate_slow), /* 7 */ - new Config(32, 128, 258, 1024, deflate_slow), /* 8 */ - new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */ - ]; - - - /* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ - function lm_init(s) { - s.window_size = 2 * s.w_size; - - /*** CLEAR_HASH(s); ***/ - zero(s.head); // Fill with NIL (= 0); - - /* Set the default configuration parameters: - */ - s.max_lazy_match = configuration_table[s.level].max_lazy; - s.good_match = configuration_table[s.level].good_length; - s.nice_match = configuration_table[s.level].nice_length; - s.max_chain_length = configuration_table[s.level].max_chain; - - s.strstart = 0; - s.block_start = 0; - s.lookahead = 0; - s.insert = 0; - s.match_length = s.prev_length = MIN_MATCH - 1; - s.match_available = 0; - s.ins_h = 0; - } - - - function DeflateState() { - this.strm = null; /* pointer back to this zlib stream */ - this.status = 0; /* as the name implies */ - this.pending_buf = null; /* output still pending */ - this.pending_buf_size = 0; /* size of pending_buf */ - this.pending_out = 0; /* next pending byte to output to the stream */ - this.pending = 0; /* nb of bytes in the pending buffer */ - this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */ - this.gzhead = null; /* gzip header information to write */ - this.gzindex = 0; /* where in extra, name, or comment */ - this.method = Z_DEFLATED; /* can only be DEFLATED */ - this.last_flush = -1; /* value of flush param for previous deflate call */ - - this.w_size = 0; /* LZ77 window size (32K by default) */ - this.w_bits = 0; /* log2(w_size) (8..16) */ - this.w_mask = 0; /* w_size - 1 */ - - this.window = null; - /* Sliding window. Input bytes are read into the second half of the window, - * and move to the first half later to keep a dictionary of at least wSize - * bytes. With this organization, matches are limited to a distance of - * wSize-MAX_MATCH bytes, but this ensures that IO is always - * performed with a length multiple of the block size. - */ - - this.window_size = 0; - /* Actual size of window: 2*wSize, except when the user input buffer - * is directly used as sliding window. - */ - - this.prev = null; - /* Link to older string with same hash index. To limit the size of this - * array to 64K, this link is maintained only for the last 32K strings. - * An index in this array is thus a window index modulo 32K. - */ - - this.head = null; /* Heads of the hash chains or NIL. */ - - this.ins_h = 0; /* hash index of string to be inserted */ - this.hash_size = 0; /* number of elements in hash table */ - this.hash_bits = 0; /* log2(hash_size) */ - this.hash_mask = 0; /* hash_size-1 */ - - this.hash_shift = 0; - /* Number of bits by which ins_h must be shifted at each input - * step. It must be such that after MIN_MATCH steps, the oldest - * byte no longer takes part in the hash key, that is: - * hash_shift * MIN_MATCH >= hash_bits - */ - - this.block_start = 0; - /* Window position at the beginning of the current output block. Gets - * negative when the window is moved backwards. - */ - - this.match_length = 0; /* length of best match */ - this.prev_match = 0; /* previous match */ - this.match_available = 0; /* set if previous match exists */ - this.strstart = 0; /* start of string to insert */ - this.match_start = 0; /* start of matching string */ - this.lookahead = 0; /* number of valid bytes ahead in window */ - - this.prev_length = 0; - /* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - this.max_chain_length = 0; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. - */ - - this.max_lazy_match = 0; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. - */ - // That's alias to max_lazy_match, don't use directly - //this.max_insert_length = 0; - /* Insert new strings in the hash table only if the match length is not - * greater than this length. This saves time but degrades compression. - * max_insert_length is used only for compression levels <= 3. - */ - - this.level = 0; /* compression level (1..9) */ - this.strategy = 0; /* favor or force Huffman coding*/ - - this.good_match = 0; - /* Use a faster search when the previous match is longer than this */ - - this.nice_match = 0; /* Stop searching when current match exceeds this */ - - /* used by trees.c: */ - - /* Didn't use ct_data typedef below to suppress compiler warning */ - - // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ - // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ - // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ - - // Use flat array of DOUBLE size, with interleaved fata, - // because JS does not support effective - this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2); - this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2); - this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2); - zero(this.dyn_ltree); - zero(this.dyn_dtree); - zero(this.bl_tree); - - this.l_desc = null; /* desc. for literal tree */ - this.d_desc = null; /* desc. for distance tree */ - this.bl_desc = null; /* desc. for bit length tree */ - - //ush bl_count[MAX_BITS+1]; - this.bl_count = new utils.Buf16(MAX_BITS + 1); - /* number of codes at each bit length for an optimal tree */ - - //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */ - zero(this.heap); - - this.heap_len = 0; /* number of elements in the heap */ - this.heap_max = 0; /* element of largest frequency */ - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - - this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1]; - zero(this.depth); - /* Depth of each subtree used as tie breaker for trees of equal frequency - */ - - this.l_buf = 0; /* buffer index for literals or lengths */ - - this.lit_bufsize = 0; - /* Size of match buffer for literals/lengths. There are 4 reasons for - * limiting lit_bufsize to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input - * data is still in the window so we can still emit a stored block even - * when input comes from standard input. (This can also be done for - * all blocks if lit_bufsize is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * This is applicable only for zip (not gzip or zlib). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting - * trees more frequently. - * - I can't count above 4 - */ - - this.last_lit = 0; /* running index in l_buf */ - - this.d_buf = 0; - /* Buffer index for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ - - this.opt_len = 0; /* bit length of current block with optimal trees */ - this.static_len = 0; /* bit length of current block with static trees */ - this.matches = 0; /* number of string matches in current block */ - this.insert = 0; /* bytes at end of window left to insert */ - - - this.bi_buf = 0; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ - this.bi_valid = 0; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - - // Used for window memory init. We safely ignore it for JS. That makes - // sense only for pointers and memory check tools. - //this.high_water = 0; - /* High water mark offset in window for initialized bytes -- bytes above - * this are set to zero in order to avoid memory check warnings when - * longest match routines access bytes past the input. This is then - * updated to the new high water mark. - */ - } - - - function deflateResetKeep(strm) { - var s; - - if (!strm || !strm.state) { - return err(strm, Z_STREAM_ERROR); - } - - strm.total_in = strm.total_out = 0; - strm.data_type = Z_UNKNOWN; - - s = strm.state; - s.pending = 0; - s.pending_out = 0; - - if (s.wrap < 0) { - s.wrap = -s.wrap; - /* was made negative by deflate(..., Z_FINISH); */ - } - s.status = (s.wrap ? INIT_STATE : BUSY_STATE); - strm.adler = (s.wrap === 2) ? - 0 // crc32(0, Z_NULL, 0) - : - 1; // adler32(0, Z_NULL, 0) - s.last_flush = Z_NO_FLUSH; - trees._tr_init(s); - return Z_OK; - } - - - function deflateReset(strm) { - var ret = deflateResetKeep(strm); - if (ret === Z_OK) { - lm_init(strm.state); - } - return ret; - } - - - function deflateSetHeader(strm, head) { - if (!strm || !strm.state) { return Z_STREAM_ERROR; } - if (strm.state.wrap !== 2) { return Z_STREAM_ERROR; } - strm.state.gzhead = head; - return Z_OK; - } - - - function deflateInit2(strm, level, method, windowBits, memLevel, strategy) { - if (!strm) { // === Z_NULL - return Z_STREAM_ERROR; - } - var wrap = 1; - - if (level === Z_DEFAULT_COMPRESSION) { - level = 6; - } - - if (windowBits < 0) { /* suppress zlib wrapper */ - wrap = 0; - windowBits = -windowBits; - } - - else if (windowBits > 15) { - wrap = 2; /* write gzip wrapper instead */ - windowBits -= 16; - } - - - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED || - windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_FIXED) { - return err(strm, Z_STREAM_ERROR); - } - - - if (windowBits === 8) { - windowBits = 9; - } - /* until 256-byte window bug fixed */ - - var s = new DeflateState(); - - strm.state = s; - s.strm = strm; - - s.wrap = wrap; - s.gzhead = null; - s.w_bits = windowBits; - s.w_size = 1 << s.w_bits; - s.w_mask = s.w_size - 1; - - s.hash_bits = memLevel + 7; - s.hash_size = 1 << s.hash_bits; - s.hash_mask = s.hash_size - 1; - s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH); - - s.window = new utils.Buf8(s.w_size * 2); - s.head = new utils.Buf16(s.hash_size); - s.prev = new utils.Buf16(s.w_size); - - // Don't need mem init magic for JS. - //s.high_water = 0; /* nothing written to s->window yet */ - - s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - - s.pending_buf_size = s.lit_bufsize * 4; - - //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); - //s->pending_buf = (uchf *) overlay; - s.pending_buf = new utils.Buf8(s.pending_buf_size); - - // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`) - //s->d_buf = overlay + s->lit_bufsize/sizeof(ush); - s.d_buf = 1 * s.lit_bufsize; - - //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; - s.l_buf = (1 + 2) * s.lit_bufsize; - - s.level = level; - s.strategy = strategy; - s.method = method; - - return deflateReset(strm); - } - - function deflateInit(strm, level) { - return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); - } - - - function deflate(strm, flush) { - var old_flush, s; - var beg, val; // for gzip header write only - - if (!strm || !strm.state || - flush > Z_BLOCK || flush < 0) { - return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR; - } - - s = strm.state; - - if (!strm.output || - (!strm.input && strm.avail_in !== 0) || - (s.status === FINISH_STATE && flush !== Z_FINISH)) { - return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR); - } - - s.strm = strm; /* just in case */ - old_flush = s.last_flush; - s.last_flush = flush; - - /* Write the header */ - if (s.status === INIT_STATE) { - - if (s.wrap === 2) { // GZIP header - strm.adler = 0; //crc32(0L, Z_NULL, 0); - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (!s.gzhead) { // s->gzhead == Z_NULL - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s.level === 9 ? 2 : - (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? - 4 : 0)); - put_byte(s, OS_CODE); - s.status = BUSY_STATE; - } - else { - put_byte(s, (s.gzhead.text ? 1 : 0) + - (s.gzhead.hcrc ? 2 : 0) + - (!s.gzhead.extra ? 0 : 4) + - (!s.gzhead.name ? 0 : 8) + - (!s.gzhead.comment ? 0 : 16) - ); - put_byte(s, s.gzhead.time & 0xff); - put_byte(s, (s.gzhead.time >> 8) & 0xff); - put_byte(s, (s.gzhead.time >> 16) & 0xff); - put_byte(s, (s.gzhead.time >> 24) & 0xff); - put_byte(s, s.level === 9 ? 2 : - (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? - 4 : 0)); - put_byte(s, s.gzhead.os & 0xff); - if (s.gzhead.extra && s.gzhead.extra.length) { - put_byte(s, s.gzhead.extra.length & 0xff); - put_byte(s, (s.gzhead.extra.length >> 8) & 0xff); - } - if (s.gzhead.hcrc) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0); - } - s.gzindex = 0; - s.status = EXTRA_STATE; - } - } - else // DEFLATE header - { - var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8; - var level_flags = -1; - - if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) { - level_flags = 0; - } else if (s.level < 6) { - level_flags = 1; - } else if (s.level === 6) { - level_flags = 2; - } else { - level_flags = 3; - } - header |= (level_flags << 6); - if (s.strstart !== 0) { header |= PRESET_DICT; } - header += 31 - (header % 31); - - s.status = BUSY_STATE; - putShortMSB(s, header); - - /* Save the adler32 of the preset dictionary: */ - if (s.strstart !== 0) { - putShortMSB(s, strm.adler >>> 16); - putShortMSB(s, strm.adler & 0xffff); - } - strm.adler = 1; // adler32(0L, Z_NULL, 0); - } - } - - //#ifdef GZIP - if (s.status === EXTRA_STATE) { - if (s.gzhead.extra/* != Z_NULL*/) { - beg = s.pending; /* start of bytes to update crc */ - - while (s.gzindex < (s.gzhead.extra.length & 0xffff)) { - if (s.pending === s.pending_buf_size) { - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - } - flush_pending(strm); - beg = s.pending; - if (s.pending === s.pending_buf_size) { - break; - } - } - put_byte(s, s.gzhead.extra[s.gzindex] & 0xff); - s.gzindex++; - } - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - } - if (s.gzindex === s.gzhead.extra.length) { - s.gzindex = 0; - s.status = NAME_STATE; - } - } - else { - s.status = NAME_STATE; - } - } - if (s.status === NAME_STATE) { - if (s.gzhead.name/* != Z_NULL*/) { - beg = s.pending; /* start of bytes to update crc */ - //int val; - - do { - if (s.pending === s.pending_buf_size) { - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - } - flush_pending(strm); - beg = s.pending; - if (s.pending === s.pending_buf_size) { - val = 1; - break; - } - } - // JS specific: little magic to add zero terminator to end of string - if (s.gzindex < s.gzhead.name.length) { - val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff; - } else { - val = 0; - } - put_byte(s, val); - } while (val !== 0); - - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - } - if (val === 0) { - s.gzindex = 0; - s.status = COMMENT_STATE; - } - } - else { - s.status = COMMENT_STATE; - } - } - if (s.status === COMMENT_STATE) { - if (s.gzhead.comment/* != Z_NULL*/) { - beg = s.pending; /* start of bytes to update crc */ - //int val; - - do { - if (s.pending === s.pending_buf_size) { - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - } - flush_pending(strm); - beg = s.pending; - if (s.pending === s.pending_buf_size) { - val = 1; - break; - } - } - // JS specific: little magic to add zero terminator to end of string - if (s.gzindex < s.gzhead.comment.length) { - val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff; - } else { - val = 0; - } - put_byte(s, val); - } while (val !== 0); - - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - } - if (val === 0) { - s.status = HCRC_STATE; - } - } - else { - s.status = HCRC_STATE; - } - } - if (s.status === HCRC_STATE) { - if (s.gzhead.hcrc) { - if (s.pending + 2 > s.pending_buf_size) { - flush_pending(strm); - } - if (s.pending + 2 <= s.pending_buf_size) { - put_byte(s, strm.adler & 0xff); - put_byte(s, (strm.adler >> 8) & 0xff); - strm.adler = 0; //crc32(0L, Z_NULL, 0); - s.status = BUSY_STATE; - } - } - else { - s.status = BUSY_STATE; - } - } - //#endif - - /* Flush as much pending output as possible */ - if (s.pending !== 0) { - flush_pending(strm); - if (strm.avail_out === 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: - */ - s.last_flush = -1; - return Z_OK; - } - - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUF_ERROR. - */ - } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && - flush !== Z_FINISH) { - return err(strm, Z_BUF_ERROR); - } - - /* User must not provide more input after the first FINISH: */ - if (s.status === FINISH_STATE && strm.avail_in !== 0) { - return err(strm, Z_BUF_ERROR); - } - - /* Start a new block or continue the current one. - */ - if (strm.avail_in !== 0 || s.lookahead !== 0 || - (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) { - var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) : - (s.strategy === Z_RLE ? deflate_rle(s, flush) : - configuration_table[s.level].func(s, flush)); - - if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) { - s.status = FINISH_STATE; - } - if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) { - if (strm.avail_out === 0) { - s.last_flush = -1; - /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call - * of deflate should use the same flush parameter to make sure - * that the flush is complete. So we don't have to output an - * empty block here, this will be done at next call. This also - * ensures that for a very small output buffer, we emit at most - * one empty block. - */ - } - if (bstate === BS_BLOCK_DONE) { - if (flush === Z_PARTIAL_FLUSH) { - trees._tr_align(s); - } - else if (flush !== Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */ - - trees._tr_stored_block(s, 0, 0, false); - /* For a full flush, this empty block will be recognized - * as a special marker by inflate_sync(). - */ - if (flush === Z_FULL_FLUSH) { - /*** CLEAR_HASH(s); ***/ /* forget history */ - zero(s.head); // Fill with NIL (= 0); - - if (s.lookahead === 0) { - s.strstart = 0; - s.block_start = 0; - s.insert = 0; - } - } - } - flush_pending(strm); - if (strm.avail_out === 0) { - s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } - } - } - //Assert(strm->avail_out > 0, "bug2"); - //if (strm.avail_out <= 0) { throw new Error("bug2");} - - if (flush !== Z_FINISH) { return Z_OK; } - if (s.wrap <= 0) { return Z_STREAM_END; } - - /* Write the trailer */ - if (s.wrap === 2) { - put_byte(s, strm.adler & 0xff); - put_byte(s, (strm.adler >> 8) & 0xff); - put_byte(s, (strm.adler >> 16) & 0xff); - put_byte(s, (strm.adler >> 24) & 0xff); - put_byte(s, strm.total_in & 0xff); - put_byte(s, (strm.total_in >> 8) & 0xff); - put_byte(s, (strm.total_in >> 16) & 0xff); - put_byte(s, (strm.total_in >> 24) & 0xff); - } - else - { - putShortMSB(s, strm.adler >>> 16); - putShortMSB(s, strm.adler & 0xffff); - } - - flush_pending(strm); - /* If avail_out is zero, the application will call deflate again - * to flush the rest. - */ - if (s.wrap > 0) { s.wrap = -s.wrap; } - /* write the trailer only once! */ - return s.pending !== 0 ? Z_OK : Z_STREAM_END; - } - - function deflateEnd(strm) { - var status; - - if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) { - return Z_STREAM_ERROR; - } - - status = strm.state.status; - if (status !== INIT_STATE && - status !== EXTRA_STATE && - status !== NAME_STATE && - status !== COMMENT_STATE && - status !== HCRC_STATE && - status !== BUSY_STATE && - status !== FINISH_STATE - ) { - return err(strm, Z_STREAM_ERROR); - } - - strm.state = null; - - return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK; - } - - - /* ========================================================================= - * Initializes the compression dictionary from the given byte - * sequence without producing any compressed output. - */ - function deflateSetDictionary(strm, dictionary) { - var dictLength = dictionary.length; - - var s; - var str, n; - var wrap; - var avail; - var next; - var input; - var tmpDict; - - if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) { - return Z_STREAM_ERROR; - } - - s = strm.state; - wrap = s.wrap; - - if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) { - return Z_STREAM_ERROR; - } - - /* when using zlib wrappers, compute Adler-32 for provided dictionary */ - if (wrap === 1) { - /* adler32(strm->adler, dictionary, dictLength); */ - strm.adler = adler32(strm.adler, dictionary, dictLength, 0); - } - - s.wrap = 0; /* avoid computing Adler-32 in read_buf */ - - /* if dictionary would fill window, just replace the history */ - if (dictLength >= s.w_size) { - if (wrap === 0) { /* already empty otherwise */ - /*** CLEAR_HASH(s); ***/ - zero(s.head); // Fill with NIL (= 0); - s.strstart = 0; - s.block_start = 0; - s.insert = 0; - } - /* use the tail */ - // dictionary = dictionary.slice(dictLength - s.w_size); - tmpDict = new utils.Buf8(s.w_size); - utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0); - dictionary = tmpDict; - dictLength = s.w_size; - } - /* insert dictionary into window and hash */ - avail = strm.avail_in; - next = strm.next_in; - input = strm.input; - strm.avail_in = dictLength; - strm.next_in = 0; - strm.input = dictionary; - fill_window(s); - while (s.lookahead >= MIN_MATCH) { - str = s.strstart; - n = s.lookahead - (MIN_MATCH - 1); - do { - /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */ - s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask; - - s.prev[str & s.w_mask] = s.head[s.ins_h]; - - s.head[s.ins_h] = str; - str++; - } while (--n); - s.strstart = str; - s.lookahead = MIN_MATCH - 1; - fill_window(s); - } - s.strstart += s.lookahead; - s.block_start = s.strstart; - s.insert = s.lookahead; - s.lookahead = 0; - s.match_length = s.prev_length = MIN_MATCH - 1; - s.match_available = 0; - strm.next_in = next; - strm.input = input; - strm.avail_in = avail; - s.wrap = wrap; - return Z_OK; - } - - - exports.deflateInit = deflateInit; - exports.deflateInit2 = deflateInit2; - exports.deflateReset = deflateReset; - exports.deflateResetKeep = deflateResetKeep; - exports.deflateSetHeader = deflateSetHeader; - exports.deflate = deflate; - exports.deflateEnd = deflateEnd; - exports.deflateSetDictionary = deflateSetDictionary; - exports.deflateInfo = 'pako deflate (from Nodeca project)'; - - /* Not implemented - exports.deflateBound = deflateBound; - exports.deflateCopy = deflateCopy; - exports.deflateParams = deflateParams; - exports.deflatePending = deflatePending; - exports.deflatePrime = deflatePrime; - exports.deflateTune = deflateTune; - */ - - -/***/ }, -/* 76 */ -/***/ function(module, exports) { - - 'use strict'; - - - var TYPED_OK = (typeof Uint8Array !== 'undefined') && - (typeof Uint16Array !== 'undefined') && - (typeof Int32Array !== 'undefined'); - - - exports.assign = function (obj /*from1, from2, from3, ...*/) { - var sources = Array.prototype.slice.call(arguments, 1); - while (sources.length) { - var source = sources.shift(); - if (!source) { continue; } - - if (typeof source !== 'object') { - throw new TypeError(source + 'must be non-object'); - } - - for (var p in source) { - if (source.hasOwnProperty(p)) { - obj[p] = source[p]; - } - } - } - - return obj; - }; - - - // reduce buffer size, avoiding mem copy - exports.shrinkBuf = function (buf, size) { - if (buf.length === size) { return buf; } - if (buf.subarray) { return buf.subarray(0, size); } - buf.length = size; - return buf; - }; - - - var fnTyped = { - arraySet: function (dest, src, src_offs, len, dest_offs) { - if (src.subarray && dest.subarray) { - dest.set(src.subarray(src_offs, src_offs + len), dest_offs); - return; - } - // Fallback to ordinary array - for (var i = 0; i < len; i++) { - dest[dest_offs + i] = src[src_offs + i]; - } - }, - // Join array of chunks to single array. - flattenChunks: function (chunks) { - var i, l, len, pos, chunk, result; - - // calculate data length - len = 0; - for (i = 0, l = chunks.length; i < l; i++) { - len += chunks[i].length; - } - - // join chunks - result = new Uint8Array(len); - pos = 0; - for (i = 0, l = chunks.length; i < l; i++) { - chunk = chunks[i]; - result.set(chunk, pos); - pos += chunk.length; - } - - return result; - } - }; - - var fnUntyped = { - arraySet: function (dest, src, src_offs, len, dest_offs) { - for (var i = 0; i < len; i++) { - dest[dest_offs + i] = src[src_offs + i]; - } - }, - // Join array of chunks to single array. - flattenChunks: function (chunks) { - return [].concat.apply([], chunks); - } - }; - - - // Enable/Disable typed arrays use, for testing - // - exports.setTyped = function (on) { - if (on) { - exports.Buf8 = Uint8Array; - exports.Buf16 = Uint16Array; - exports.Buf32 = Int32Array; - exports.assign(exports, fnTyped); - } else { - exports.Buf8 = Array; - exports.Buf16 = Array; - exports.Buf32 = Array; - exports.assign(exports, fnUntyped); - } - }; - - exports.setTyped(TYPED_OK); - - -/***/ }, -/* 77 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - - var utils = __webpack_require__(76); - - /* Public constants ==========================================================*/ - /* ===========================================================================*/ - - - //var Z_FILTERED = 1; - //var Z_HUFFMAN_ONLY = 2; - //var Z_RLE = 3; - var Z_FIXED = 4; - //var Z_DEFAULT_STRATEGY = 0; - - /* Possible values of the data_type field (though see inflate()) */ - var Z_BINARY = 0; - var Z_TEXT = 1; - //var Z_ASCII = 1; // = Z_TEXT - var Z_UNKNOWN = 2; - - /*============================================================================*/ - - - function zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } } - - // From zutil.h - - var STORED_BLOCK = 0; - var STATIC_TREES = 1; - var DYN_TREES = 2; - /* The three kinds of block type */ - - var MIN_MATCH = 3; - var MAX_MATCH = 258; - /* The minimum and maximum match lengths */ - - // From deflate.h - /* =========================================================================== - * Internal compression state. - */ - - var LENGTH_CODES = 29; - /* number of length codes, not counting the special END_BLOCK code */ - - var LITERALS = 256; - /* number of literal bytes 0..255 */ - - var L_CODES = LITERALS + 1 + LENGTH_CODES; - /* number of Literal or Length codes, including the END_BLOCK code */ - - var D_CODES = 30; - /* number of distance codes */ - - var BL_CODES = 19; - /* number of codes used to transfer the bit lengths */ - - var HEAP_SIZE = 2 * L_CODES + 1; - /* maximum heap size */ - - var MAX_BITS = 15; - /* All codes must not exceed MAX_BITS bits */ - - var Buf_size = 16; - /* size of bit buffer in bi_buf */ - - - /* =========================================================================== - * Constants - */ - - var MAX_BL_BITS = 7; - /* Bit length codes must not exceed MAX_BL_BITS bits */ - - var END_BLOCK = 256; - /* end of block literal code */ - - var REP_3_6 = 16; - /* repeat previous bit length 3-6 times (2 bits of repeat count) */ - - var REPZ_3_10 = 17; - /* repeat a zero length 3-10 times (3 bits of repeat count) */ - - var REPZ_11_138 = 18; - /* repeat a zero length 11-138 times (7 bits of repeat count) */ - - /* eslint-disable comma-spacing,array-bracket-spacing */ - var extra_lbits = /* extra bits for each length code */ - [0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]; - - var extra_dbits = /* extra bits for each distance code */ - [0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]; - - var extra_blbits = /* extra bits for each bit length code */ - [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]; - - var bl_order = - [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]; - /* eslint-enable comma-spacing,array-bracket-spacing */ - - /* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - - /* =========================================================================== - * Local data. These are initialized only once. - */ - - // We pre-fill arrays with 0 to avoid uninitialized gaps - - var DIST_CODE_LEN = 512; /* see definition of array dist_code below */ - - // !!!! Use flat array insdead of structure, Freq = i*2, Len = i*2+1 - var static_ltree = new Array((L_CODES + 2) * 2); - zero(static_ltree); - /* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init - * below). - */ - - var static_dtree = new Array(D_CODES * 2); - zero(static_dtree); - /* The static distance tree. (Actually a trivial tree since all codes use - * 5 bits.) - */ - - var _dist_code = new Array(DIST_CODE_LEN); - zero(_dist_code); - /* Distance codes. The first 256 values correspond to the distances - * 3 .. 258, the last 256 values correspond to the top 8 bits of - * the 15 bit distances. - */ - - var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1); - zero(_length_code); - /* length code for each normalized match length (0 == MIN_MATCH) */ - - var base_length = new Array(LENGTH_CODES); - zero(base_length); - /* First normalized length for each code (0 = MIN_MATCH) */ - - var base_dist = new Array(D_CODES); - zero(base_dist); - /* First normalized distance for each code (0 = distance of 1) */ - - - function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) { - - this.static_tree = static_tree; /* static tree or NULL */ - this.extra_bits = extra_bits; /* extra bits for each code or NULL */ - this.extra_base = extra_base; /* base index for extra_bits */ - this.elems = elems; /* max number of elements in the tree */ - this.max_length = max_length; /* max bit length for the codes */ - - // show if `static_tree` has data or dummy - needed for monomorphic objects - this.has_stree = static_tree && static_tree.length; - } - - - var static_l_desc; - var static_d_desc; - var static_bl_desc; - - - function TreeDesc(dyn_tree, stat_desc) { - this.dyn_tree = dyn_tree; /* the dynamic tree */ - this.max_code = 0; /* largest code with non zero frequency */ - this.stat_desc = stat_desc; /* the corresponding static tree */ - } - - - - function d_code(dist) { - return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)]; - } - - - /* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ - function put_short(s, w) { - // put_byte(s, (uch)((w) & 0xff)); - // put_byte(s, (uch)((ush)(w) >> 8)); - s.pending_buf[s.pending++] = (w) & 0xff; - s.pending_buf[s.pending++] = (w >>> 8) & 0xff; - } - - - /* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ - function send_bits(s, value, length) { - if (s.bi_valid > (Buf_size - length)) { - s.bi_buf |= (value << s.bi_valid) & 0xffff; - put_short(s, s.bi_buf); - s.bi_buf = value >> (Buf_size - s.bi_valid); - s.bi_valid += length - Buf_size; - } else { - s.bi_buf |= (value << s.bi_valid) & 0xffff; - s.bi_valid += length; - } - } - - - function send_code(s, c, tree) { - send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/); - } - - - /* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ - function bi_reverse(code, len) { - var res = 0; - do { - res |= code & 1; - code >>>= 1; - res <<= 1; - } while (--len > 0); - return res >>> 1; - } - - - /* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ - function bi_flush(s) { - if (s.bi_valid === 16) { - put_short(s, s.bi_buf); - s.bi_buf = 0; - s.bi_valid = 0; - - } else if (s.bi_valid >= 8) { - s.pending_buf[s.pending++] = s.bi_buf & 0xff; - s.bi_buf >>= 8; - s.bi_valid -= 8; - } - } - - - /* =========================================================================== - * Compute the optimal bit lengths for a tree and update the total bit length - * for the current block. - * IN assertion: the fields freq and dad are set, heap[heap_max] and - * above are the tree nodes sorted by increasing frequency. - * OUT assertions: the field len is set to the optimal bit length, the - * array bl_count contains the frequencies for each bit length. - * The length opt_len is updated; static_len is also updated if stree is - * not null. - */ - function gen_bitlen(s, desc) - // deflate_state *s; - // tree_desc *desc; /* the tree descriptor */ - { - var tree = desc.dyn_tree; - var max_code = desc.max_code; - var stree = desc.stat_desc.static_tree; - var has_stree = desc.stat_desc.has_stree; - var extra = desc.stat_desc.extra_bits; - var base = desc.stat_desc.extra_base; - var max_length = desc.stat_desc.max_length; - var h; /* heap index */ - var n, m; /* iterate over the tree elements */ - var bits; /* bit length */ - var xbits; /* extra bits */ - var f; /* frequency */ - var overflow = 0; /* number of elements with bit length too large */ - - for (bits = 0; bits <= MAX_BITS; bits++) { - s.bl_count[bits] = 0; - } - - /* In a first pass, compute the optimal bit lengths (which may - * overflow in the case of the bit length tree). - */ - tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */ - - for (h = s.heap_max + 1; h < HEAP_SIZE; h++) { - n = s.heap[h]; - bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1; - if (bits > max_length) { - bits = max_length; - overflow++; - } - tree[n * 2 + 1]/*.Len*/ = bits; - /* We overwrite tree[n].Dad which is no longer needed */ - - if (n > max_code) { continue; } /* not a leaf node */ - - s.bl_count[bits]++; - xbits = 0; - if (n >= base) { - xbits = extra[n - base]; - } - f = tree[n * 2]/*.Freq*/; - s.opt_len += f * (bits + xbits); - if (has_stree) { - s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits); - } - } - if (overflow === 0) { return; } - - // Trace((stderr,"\nbit length overflow\n")); - /* This happens for example on obj2 and pic of the Calgary corpus */ - - /* Find the first bit length which could increase: */ - do { - bits = max_length - 1; - while (s.bl_count[bits] === 0) { bits--; } - s.bl_count[bits]--; /* move one leaf down the tree */ - s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */ - s.bl_count[max_length]--; - /* The brother of the overflow item also moves one step up, - * but this does not affect bl_count[max_length] - */ - overflow -= 2; - } while (overflow > 0); - - /* Now recompute all bit lengths, scanning in increasing frequency. - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all - * lengths instead of fixing only the wrong ones. This idea is taken - * from 'ar' written by Haruhiko Okumura.) - */ - for (bits = max_length; bits !== 0; bits--) { - n = s.bl_count[bits]; - while (n !== 0) { - m = s.heap[--h]; - if (m > max_code) { continue; } - if (tree[m * 2 + 1]/*.Len*/ !== bits) { - // Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/; - tree[m * 2 + 1]/*.Len*/ = bits; - } - n--; - } - } - } - - - /* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ - function gen_codes(tree, max_code, bl_count) - // ct_data *tree; /* the tree to decorate */ - // int max_code; /* largest code with non zero frequency */ - // ushf *bl_count; /* number of codes at each bit length */ - { - var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */ - var code = 0; /* running code value */ - var bits; /* bit index */ - var n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = (code + bl_count[bits - 1]) << 1; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - //Assert (code + bl_count[MAX_BITS]-1 == (1< length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES - 1; code++) { - base_length[code] = length; - for (n = 0; n < (1 << extra_lbits[code]); n++) { - _length_code[length++] = code; - } - } - //Assert (length == 256, "tr_static_init: length != 256"); - /* Note that the length 255 (match length 258) can be represented - * in two different ways: code 284 + 5 bits or code 285, so we - * overwrite length_code[255] to use the best encoding: - */ - _length_code[length - 1] = code; - - /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ - dist = 0; - for (code = 0; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1 << extra_dbits[code]); n++) { - _dist_code[dist++] = code; - } - } - //Assert (dist == 256, "tr_static_init: dist != 256"); - dist >>= 7; /* from now on, all distances are divided by 128 */ - for (; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) { - _dist_code[256 + dist++] = code; - } - } - //Assert (dist == 256, "tr_static_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) { - bl_count[bits] = 0; - } - - n = 0; - while (n <= 143) { - static_ltree[n * 2 + 1]/*.Len*/ = 8; - n++; - bl_count[8]++; - } - while (n <= 255) { - static_ltree[n * 2 + 1]/*.Len*/ = 9; - n++; - bl_count[9]++; - } - while (n <= 279) { - static_ltree[n * 2 + 1]/*.Len*/ = 7; - n++; - bl_count[7]++; - } - while (n <= 287) { - static_ltree[n * 2 + 1]/*.Len*/ = 8; - n++; - bl_count[8]++; - } - /* Codes 286 and 287 do not exist, but we must include them in the - * tree construction to get a canonical Huffman tree (longest code - * all ones) - */ - gen_codes(static_ltree, L_CODES + 1, bl_count); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n * 2 + 1]/*.Len*/ = 5; - static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5); - } - - // Now data ready and we can init static trees - static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS); - static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS); - static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS); - - //static_init_done = true; - } - - - /* =========================================================================== - * Initialize a new block. - */ - function init_block(s) { - var n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; } - for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; } - for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; } - - s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1; - s.opt_len = s.static_len = 0; - s.last_lit = s.matches = 0; - } - - - /* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ - function bi_windup(s) - { - if (s.bi_valid > 8) { - put_short(s, s.bi_buf); - } else if (s.bi_valid > 0) { - //put_byte(s, (Byte)s->bi_buf); - s.pending_buf[s.pending++] = s.bi_buf; - } - s.bi_buf = 0; - s.bi_valid = 0; - } - - /* =========================================================================== - * Copy a stored block, storing first the length and its - * one's complement if requested. - */ - function copy_block(s, buf, len, header) - //DeflateState *s; - //charf *buf; /* the input data */ - //unsigned len; /* its length */ - //int header; /* true if block header must be written */ - { - bi_windup(s); /* align on byte boundary */ - - if (header) { - put_short(s, len); - put_short(s, ~len); - } - // while (len--) { - // put_byte(s, *buf++); - // } - utils.arraySet(s.pending_buf, s.window, buf, len, s.pending); - s.pending += len; - } - - /* =========================================================================== - * Compares to subtrees, using the tree depth as tie breaker when - * the subtrees have equal frequency. This minimizes the worst case length. - */ - function smaller(tree, n, m, depth) { - var _n2 = n * 2; - var _m2 = m * 2; - return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ || - (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m])); - } - - /* =========================================================================== - * Restore the heap property by moving down the tree starting at node k, - * exchanging a node with the smallest of its two sons if necessary, stopping - * when the heap property is re-established (each father smaller than its - * two sons). - */ - function pqdownheap(s, tree, k) - // deflate_state *s; - // ct_data *tree; /* the tree to restore */ - // int k; /* node to move down */ - { - var v = s.heap[k]; - var j = k << 1; /* left son of k */ - while (j <= s.heap_len) { - /* Set j to the smallest of the two sons: */ - if (j < s.heap_len && - smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) { - j++; - } - /* Exit if v is smaller than both sons */ - if (smaller(tree, v, s.heap[j], s.depth)) { break; } - - /* Exchange v with the smallest son */ - s.heap[k] = s.heap[j]; - k = j; - - /* And continue down the tree, setting j to the left son of k */ - j <<= 1; - } - s.heap[k] = v; - } - - - // inlined manually - // var SMALLEST = 1; - - /* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ - function compress_block(s, ltree, dtree) - // deflate_state *s; - // const ct_data *ltree; /* literal tree */ - // const ct_data *dtree; /* distance tree */ - { - var dist; /* distance of matched string */ - var lc; /* match length or unmatched char (if dist == 0) */ - var lx = 0; /* running index in l_buf */ - var code; /* the code to send */ - var extra; /* number of extra bits to send */ - - if (s.last_lit !== 0) { - do { - dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]); - lc = s.pending_buf[s.l_buf + lx]; - lx++; - - if (dist === 0) { - send_code(s, lc, ltree); /* send a literal byte */ - //Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code + LITERALS + 1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra !== 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - //Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra !== 0) { - dist -= base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ - //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, - // "pendingBuf overflow"); - - } while (lx < s.last_lit); - } - - send_code(s, END_BLOCK, ltree); - } - - - /* =========================================================================== - * Construct one Huffman tree and assigns the code bit strings and lengths. - * Update the total bit length for the current block. - * IN assertion: the field freq is set for all tree elements. - * OUT assertions: the fields len and code are set to the optimal bit length - * and corresponding code. The length opt_len is updated; static_len is - * also updated if stree is not null. The field max_code is set. - */ - function build_tree(s, desc) - // deflate_state *s; - // tree_desc *desc; /* the tree descriptor */ - { - var tree = desc.dyn_tree; - var stree = desc.stat_desc.static_tree; - var has_stree = desc.stat_desc.has_stree; - var elems = desc.stat_desc.elems; - var n, m; /* iterate over heap elements */ - var max_code = -1; /* largest code with non zero frequency */ - var node; /* new node being created */ - - /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - * heap[0] is not used. - */ - s.heap_len = 0; - s.heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n * 2]/*.Freq*/ !== 0) { - s.heap[++s.heap_len] = max_code = n; - s.depth[n] = 0; - - } else { - tree[n * 2 + 1]/*.Len*/ = 0; - } - } - - /* The pkzip format requires that at least one distance code exists, - * and that at least one bit should be sent even if there is only one - * possible code. So to avoid special checks later on we force at least - * two codes of non zero frequency. - */ - while (s.heap_len < 2) { - node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0); - tree[node * 2]/*.Freq*/ = 1; - s.depth[node] = 0; - s.opt_len--; - - if (has_stree) { - s.static_len -= stree[node * 2 + 1]/*.Len*/; - } - /* node is 0 or 1 so it does not have extra bits */ - } - desc.max_code = max_code; - - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - * establish sub-heaps of increasing lengths: - */ - for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); } - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - node = elems; /* next internal node of the tree */ - do { - //pqremove(s, tree, n); /* n = node of least frequency */ - /*** pqremove ***/ - n = s.heap[1/*SMALLEST*/]; - s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--]; - pqdownheap(s, tree, 1/*SMALLEST*/); - /***/ - - m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */ - - s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */ - s.heap[--s.heap_max] = m; - - /* Create a new node father of n and m */ - tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/; - s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1; - tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node; - - /* and insert the new node in the heap */ - s.heap[1/*SMALLEST*/] = node++; - pqdownheap(s, tree, 1/*SMALLEST*/); - - } while (s.heap_len >= 2); - - s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/]; - - /* At this point, the fields freq and dad are set. We can now - * generate the bit lengths. - */ - gen_bitlen(s, desc); - - /* The field len is now set, we can generate the bit codes */ - gen_codes(tree, max_code, s.bl_count); - } - - - /* =========================================================================== - * Scan a literal or distance tree to determine the frequencies of the codes - * in the bit length tree. - */ - function scan_tree(s, tree, max_code) - // deflate_state *s; - // ct_data *tree; /* the tree to be scanned */ - // int max_code; /* and its largest code of non zero frequency */ - { - var n; /* iterates over all tree elements */ - var prevlen = -1; /* last emitted length */ - var curlen; /* length of current code */ - - var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */ - - var count = 0; /* repeat count of the current code */ - var max_count = 7; /* max repeat count */ - var min_count = 4; /* min repeat count */ - - if (nextlen === 0) { - max_count = 138; - min_count = 3; - } - tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */ - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; - nextlen = tree[(n + 1) * 2 + 1]/*.Len*/; - - if (++count < max_count && curlen === nextlen) { - continue; - - } else if (count < min_count) { - s.bl_tree[curlen * 2]/*.Freq*/ += count; - - } else if (curlen !== 0) { - - if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; } - s.bl_tree[REP_3_6 * 2]/*.Freq*/++; - - } else if (count <= 10) { - s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++; - - } else { - s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++; - } - - count = 0; - prevlen = curlen; - - if (nextlen === 0) { - max_count = 138; - min_count = 3; - - } else if (curlen === nextlen) { - max_count = 6; - min_count = 3; - - } else { - max_count = 7; - min_count = 4; - } - } - } - - - /* =========================================================================== - * Send a literal or distance tree in compressed form, using the codes in - * bl_tree. - */ - function send_tree(s, tree, max_code) - // deflate_state *s; - // ct_data *tree; /* the tree to be scanned */ - // int max_code; /* and its largest code of non zero frequency */ - { - var n; /* iterates over all tree elements */ - var prevlen = -1; /* last emitted length */ - var curlen; /* length of current code */ - - var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */ - - var count = 0; /* repeat count of the current code */ - var max_count = 7; /* max repeat count */ - var min_count = 4; /* min repeat count */ - - /* tree[max_code+1].Len = -1; */ /* guard already set */ - if (nextlen === 0) { - max_count = 138; - min_count = 3; - } - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; - nextlen = tree[(n + 1) * 2 + 1]/*.Len*/; - - if (++count < max_count && curlen === nextlen) { - continue; - - } else if (count < min_count) { - do { send_code(s, curlen, s.bl_tree); } while (--count !== 0); - - } else if (curlen !== 0) { - if (curlen !== prevlen) { - send_code(s, curlen, s.bl_tree); - count--; - } - //Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(s, REP_3_6, s.bl_tree); - send_bits(s, count - 3, 2); - - } else if (count <= 10) { - send_code(s, REPZ_3_10, s.bl_tree); - send_bits(s, count - 3, 3); - - } else { - send_code(s, REPZ_11_138, s.bl_tree); - send_bits(s, count - 11, 7); - } - - count = 0; - prevlen = curlen; - if (nextlen === 0) { - max_count = 138; - min_count = 3; - - } else if (curlen === nextlen) { - max_count = 6; - min_count = 3; - - } else { - max_count = 7; - min_count = 4; - } - } - } - - - /* =========================================================================== - * Construct the Huffman tree for the bit lengths and return the index in - * bl_order of the last bit length code to send. - */ - function build_bl_tree(s) { - var max_blindex; /* index of last bit length code of non zero freq */ - - /* Determine the bit length frequencies for literal and distance trees */ - scan_tree(s, s.dyn_ltree, s.l_desc.max_code); - scan_tree(s, s.dyn_dtree, s.d_desc.max_code); - - /* Build the bit length tree: */ - build_tree(s, s.bl_desc); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - */ - - /* Determine the number of bit length codes to send. The pkzip format - * requires that at least 4 bit length codes be sent. (appnote.txt says - * 3 but the actual value used is 4.) - */ - for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { - if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) { - break; - } - } - /* Update opt_len to include the bit length tree and counts */ - s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; - //Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", - // s->opt_len, s->static_len)); - - return max_blindex; - } - - - /* =========================================================================== - * Send the header for a block using dynamic Huffman trees: the counts, the - * lengths of the bit length codes, the literal tree and the distance tree. - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - */ - function send_all_trees(s, lcodes, dcodes, blcodes) - // deflate_state *s; - // int lcodes, dcodes, blcodes; /* number of codes for each tree */ - { - var rank; /* index in bl_order */ - - //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); - //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, - // "too many codes"); - //Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes - 1, 5); - send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */ - for (rank = 0; rank < blcodes; rank++) { - //Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3); - } - //Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); - - send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */ - //Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); - - send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */ - //Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); - } - - - /* =========================================================================== - * Check if the data type is TEXT or BINARY, using the following algorithm: - * - TEXT if the two conditions below are satisfied: - * a) There are no non-portable control characters belonging to the - * "black list" (0..6, 14..25, 28..31). - * b) There is at least one printable character belonging to the - * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). - * - BINARY otherwise. - * - The following partially-portable control characters form a - * "gray list" that is ignored in this detection algorithm: - * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). - * IN assertion: the fields Freq of dyn_ltree are set. - */ - function detect_data_type(s) { - /* black_mask is the bit mask of black-listed bytes - * set bits 0..6, 14..25, and 28..31 - * 0xf3ffc07f = binary 11110011111111111100000001111111 - */ - var black_mask = 0xf3ffc07f; - var n; - - /* Check for non-textual ("black-listed") bytes. */ - for (n = 0; n <= 31; n++, black_mask >>>= 1) { - if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) { - return Z_BINARY; - } - } - - /* Check for textual ("white-listed") bytes. */ - if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 || - s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) { - return Z_TEXT; - } - for (n = 32; n < LITERALS; n++) { - if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) { - return Z_TEXT; - } - } - - /* There are no "black-listed" or "white-listed" bytes: - * this stream either is empty or has tolerated ("gray-listed") bytes only. - */ - return Z_BINARY; - } - - - var static_init_done = false; - - /* =========================================================================== - * Initialize the tree data structures for a new zlib stream. - */ - function _tr_init(s) - { - - if (!static_init_done) { - tr_static_init(); - static_init_done = true; - } - - s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc); - s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc); - s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc); - - s.bi_buf = 0; - s.bi_valid = 0; - - /* Initialize the first block of the first file: */ - init_block(s); - } - - - /* =========================================================================== - * Send a stored block - */ - function _tr_stored_block(s, buf, stored_len, last) - //DeflateState *s; - //charf *buf; /* input block */ - //ulg stored_len; /* length of input block */ - //int last; /* one if this is the last block for a file */ - { - send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */ - copy_block(s, buf, stored_len, true); /* with header */ - } - - - /* =========================================================================== - * Send one empty static block to give enough lookahead for inflate. - * This takes 10 bits, of which 7 may remain in the bit buffer. - */ - function _tr_align(s) { - send_bits(s, STATIC_TREES << 1, 3); - send_code(s, END_BLOCK, static_ltree); - bi_flush(s); - } - - - /* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. - */ - function _tr_flush_block(s, buf, stored_len, last) - //DeflateState *s; - //charf *buf; /* input block, or NULL if too old */ - //ulg stored_len; /* length of input block */ - //int last; /* one if this is the last block for a file */ - { - var opt_lenb, static_lenb; /* opt_len and static_len in bytes */ - var max_blindex = 0; /* index of last bit length code of non zero freq */ - - /* Build the Huffman trees unless a stored block is forced */ - if (s.level > 0) { - - /* Check if the file is binary or text */ - if (s.strm.data_type === Z_UNKNOWN) { - s.strm.data_type = detect_data_type(s); - } - - /* Construct the literal and distance trees */ - build_tree(s, s.l_desc); - // Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, - // s->static_len)); - - build_tree(s, s.d_desc); - // Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, - // s->static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ - - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(s); - - /* Determine the best encoding. Compute the block lengths in bytes. */ - opt_lenb = (s.opt_len + 3 + 7) >>> 3; - static_lenb = (s.static_len + 3 + 7) >>> 3; - - // Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", - // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - // s->last_lit)); - - if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; } - - } else { - // Assert(buf != (char*)0, "lost buf"); - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ - } - - if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) { - /* 4: two words for the lengths */ - - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - * Otherwise we can't have processed more than WSIZE input bytes since - * the last block flush, because compression would have been - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - * transform a block into a stored block. - */ - _tr_stored_block(s, buf, stored_len, last); - - } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) { - - send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3); - compress_block(s, static_ltree, static_dtree); - - } else { - send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3); - send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1); - compress_block(s, s.dyn_ltree, s.dyn_dtree); - } - // Assert (s->compressed_len == s->bits_sent, "bad compressed size"); - /* The above check is made mod 2^32, for files larger than 512 MB - * and uLong implemented on 32 bits. - */ - init_block(s); - - if (last) { - bi_windup(s); - } - // Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, - // s->compressed_len-7*last)); - } - - /* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ - function _tr_tally(s, dist, lc) - // deflate_state *s; - // unsigned dist; /* distance of matched string */ - // unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ - { - //var out_length, in_length, dcode; - - s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff; - s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff; - - s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff; - s.last_lit++; - - if (dist === 0) { - /* lc is the unmatched char */ - s.dyn_ltree[lc * 2]/*.Freq*/++; - } else { - s.matches++; - /* Here, lc is the match length - MIN_MATCH */ - dist--; /* dist = match distance - 1 */ - //Assert((ush)dist < (ush)MAX_DIST(s) && - // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && - // (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); - - s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++; - s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++; - } - - // (!) This block is disabled in zlib defailts, - // don't enable it for binary compatibility - - //#ifdef TRUNCATE_BLOCK - // /* Try to guess if it is profitable to stop the current block here */ - // if ((s.last_lit & 0x1fff) === 0 && s.level > 2) { - // /* Compute an upper bound for the compressed length */ - // out_length = s.last_lit*8; - // in_length = s.strstart - s.block_start; - // - // for (dcode = 0; dcode < D_CODES; dcode++) { - // out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]); - // } - // out_length >>>= 3; - // //Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", - // // s->last_lit, in_length, out_length, - // // 100L - out_length*100L/in_length)); - // if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) { - // return true; - // } - // } - //#endif - - return (s.last_lit === s.lit_bufsize - 1); - /* We avoid equality with lit_bufsize because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ - } - - exports._tr_init = _tr_init; - exports._tr_stored_block = _tr_stored_block; - exports._tr_flush_block = _tr_flush_block; - exports._tr_tally = _tr_tally; - exports._tr_align = _tr_align; - - -/***/ }, -/* 78 */ -/***/ function(module, exports) { - - 'use strict'; - - // Note: adler32 takes 12% for level 0 and 2% for level 6. - // It doesn't worth to make additional optimizationa as in original. - // Small size is preferable. - - function adler32(adler, buf, len, pos) { - var s1 = (adler & 0xffff) |0, - s2 = ((adler >>> 16) & 0xffff) |0, - n = 0; - - while (len !== 0) { - // Set limit ~ twice less than 5552, to keep - // s2 in 31-bits, because we force signed ints. - // in other case %= will fail. - n = len > 2000 ? 2000 : len; - len -= n; - - do { - s1 = (s1 + buf[pos++]) |0; - s2 = (s2 + s1) |0; - } while (--n); - - s1 %= 65521; - s2 %= 65521; - } - - return (s1 | (s2 << 16)) |0; - } - - - module.exports = adler32; - - -/***/ }, -/* 79 */ -/***/ function(module, exports) { - - 'use strict'; - - // Note: we can't get significant speed boost here. - // So write code to minimize size - no pregenerated tables - // and array tools dependencies. - - - // Use ordinary array, since untyped makes no boost here - function makeTable() { - var c, table = []; - - for (var n = 0; n < 256; n++) { - c = n; - for (var k = 0; k < 8; k++) { - c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1)); - } - table[n] = c; - } - - return table; - } - - // Create table on load. Just 255 signed longs. Not a problem. - var crcTable = makeTable(); - - - function crc32(crc, buf, len, pos) { - var t = crcTable, - end = pos + len; - - crc ^= -1; - - for (var i = pos; i < end; i++) { - crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF]; - } - - return (crc ^ (-1)); // >>> 0; - } - - - module.exports = crc32; - - -/***/ }, -/* 80 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - - var utils = __webpack_require__(76); - var adler32 = __webpack_require__(78); - var crc32 = __webpack_require__(79); - var inflate_fast = __webpack_require__(81); - var inflate_table = __webpack_require__(82); - - var CODES = 0; - var LENS = 1; - var DISTS = 2; - - /* Public constants ==========================================================*/ - /* ===========================================================================*/ - - - /* Allowed flush values; see deflate() and inflate() below for details */ - //var Z_NO_FLUSH = 0; - //var Z_PARTIAL_FLUSH = 1; - //var Z_SYNC_FLUSH = 2; - //var Z_FULL_FLUSH = 3; - var Z_FINISH = 4; - var Z_BLOCK = 5; - var Z_TREES = 6; - - - /* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - var Z_OK = 0; - var Z_STREAM_END = 1; - var Z_NEED_DICT = 2; - //var Z_ERRNO = -1; - var Z_STREAM_ERROR = -2; - var Z_DATA_ERROR = -3; - var Z_MEM_ERROR = -4; - var Z_BUF_ERROR = -5; - //var Z_VERSION_ERROR = -6; - - /* The deflate compression method */ - var Z_DEFLATED = 8; - - - /* STATES ====================================================================*/ - /* ===========================================================================*/ - - - var HEAD = 1; /* i: waiting for magic header */ - var FLAGS = 2; /* i: waiting for method and flags (gzip) */ - var TIME = 3; /* i: waiting for modification time (gzip) */ - var OS = 4; /* i: waiting for extra flags and operating system (gzip) */ - var EXLEN = 5; /* i: waiting for extra length (gzip) */ - var EXTRA = 6; /* i: waiting for extra bytes (gzip) */ - var NAME = 7; /* i: waiting for end of file name (gzip) */ - var COMMENT = 8; /* i: waiting for end of comment (gzip) */ - var HCRC = 9; /* i: waiting for header crc (gzip) */ - var DICTID = 10; /* i: waiting for dictionary check value */ - var DICT = 11; /* waiting for inflateSetDictionary() call */ - var TYPE = 12; /* i: waiting for type bits, including last-flag bit */ - var TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */ - var STORED = 14; /* i: waiting for stored size (length and complement) */ - var COPY_ = 15; /* i/o: same as COPY below, but only first time in */ - var COPY = 16; /* i/o: waiting for input or output to copy stored block */ - var TABLE = 17; /* i: waiting for dynamic block table lengths */ - var LENLENS = 18; /* i: waiting for code length code lengths */ - var CODELENS = 19; /* i: waiting for length/lit and distance code lengths */ - var LEN_ = 20; /* i: same as LEN below, but only first time in */ - var LEN = 21; /* i: waiting for length/lit/eob code */ - var LENEXT = 22; /* i: waiting for length extra bits */ - var DIST = 23; /* i: waiting for distance code */ - var DISTEXT = 24; /* i: waiting for distance extra bits */ - var MATCH = 25; /* o: waiting for output space to copy string */ - var LIT = 26; /* o: waiting for output space to write literal */ - var CHECK = 27; /* i: waiting for 32-bit check value */ - var LENGTH = 28; /* i: waiting for 32-bit length (gzip) */ - var DONE = 29; /* finished check, done -- remain here until reset */ - var BAD = 30; /* got a data error -- remain here until reset */ - var MEM = 31; /* got an inflate() memory error -- remain here until reset */ - var SYNC = 32; /* looking for synchronization bytes to restart inflate() */ - - /* ===========================================================================*/ - - - - var ENOUGH_LENS = 852; - var ENOUGH_DISTS = 592; - //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS); - - var MAX_WBITS = 15; - /* 32K LZ77 window */ - var DEF_WBITS = MAX_WBITS; - - - function zswap32(q) { - return (((q >>> 24) & 0xff) + - ((q >>> 8) & 0xff00) + - ((q & 0xff00) << 8) + - ((q & 0xff) << 24)); - } - - - function InflateState() { - this.mode = 0; /* current inflate mode */ - this.last = false; /* true if processing last block */ - this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */ - this.havedict = false; /* true if dictionary provided */ - this.flags = 0; /* gzip header method and flags (0 if zlib) */ - this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */ - this.check = 0; /* protected copy of check value */ - this.total = 0; /* protected copy of output count */ - // TODO: may be {} - this.head = null; /* where to save gzip header information */ - - /* sliding window */ - this.wbits = 0; /* log base 2 of requested window size */ - this.wsize = 0; /* window size or zero if not using window */ - this.whave = 0; /* valid bytes in the window */ - this.wnext = 0; /* window write index */ - this.window = null; /* allocated sliding window, if needed */ - - /* bit accumulator */ - this.hold = 0; /* input bit accumulator */ - this.bits = 0; /* number of bits in "in" */ - - /* for string and stored block copying */ - this.length = 0; /* literal or length of data to copy */ - this.offset = 0; /* distance back to copy string from */ - - /* for table and code decoding */ - this.extra = 0; /* extra bits needed */ - - /* fixed and dynamic code tables */ - this.lencode = null; /* starting table for length/literal codes */ - this.distcode = null; /* starting table for distance codes */ - this.lenbits = 0; /* index bits for lencode */ - this.distbits = 0; /* index bits for distcode */ - - /* dynamic table building */ - this.ncode = 0; /* number of code length code lengths */ - this.nlen = 0; /* number of length code lengths */ - this.ndist = 0; /* number of distance code lengths */ - this.have = 0; /* number of code lengths in lens[] */ - this.next = null; /* next available space in codes[] */ - - this.lens = new utils.Buf16(320); /* temporary storage for code lengths */ - this.work = new utils.Buf16(288); /* work area for code table building */ - - /* - because we don't have pointers in js, we use lencode and distcode directly - as buffers so we don't need codes - */ - //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */ - this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */ - this.distdyn = null; /* dynamic table for distance codes (JS specific) */ - this.sane = 0; /* if false, allow invalid distance too far */ - this.back = 0; /* bits back of last unprocessed length/lit */ - this.was = 0; /* initial length of match */ - } - - function inflateResetKeep(strm) { - var state; - - if (!strm || !strm.state) { return Z_STREAM_ERROR; } - state = strm.state; - strm.total_in = strm.total_out = state.total = 0; - strm.msg = ''; /*Z_NULL*/ - if (state.wrap) { /* to support ill-conceived Java test suite */ - strm.adler = state.wrap & 1; - } - state.mode = HEAD; - state.last = 0; - state.havedict = 0; - state.dmax = 32768; - state.head = null/*Z_NULL*/; - state.hold = 0; - state.bits = 0; - //state.lencode = state.distcode = state.next = state.codes; - state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS); - state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS); - - state.sane = 1; - state.back = -1; - //Tracev((stderr, "inflate: reset\n")); - return Z_OK; - } - - function inflateReset(strm) { - var state; - - if (!strm || !strm.state) { return Z_STREAM_ERROR; } - state = strm.state; - state.wsize = 0; - state.whave = 0; - state.wnext = 0; - return inflateResetKeep(strm); - - } - - function inflateReset2(strm, windowBits) { - var wrap; - var state; - - /* get the state */ - if (!strm || !strm.state) { return Z_STREAM_ERROR; } - state = strm.state; - - /* extract wrap request from windowBits parameter */ - if (windowBits < 0) { - wrap = 0; - windowBits = -windowBits; - } - else { - wrap = (windowBits >> 4) + 1; - if (windowBits < 48) { - windowBits &= 15; - } - } - - /* set number of window bits, free window if different */ - if (windowBits && (windowBits < 8 || windowBits > 15)) { - return Z_STREAM_ERROR; - } - if (state.window !== null && state.wbits !== windowBits) { - state.window = null; - } - - /* update state and reset the rest of it */ - state.wrap = wrap; - state.wbits = windowBits; - return inflateReset(strm); - } - - function inflateInit2(strm, windowBits) { - var ret; - var state; - - if (!strm) { return Z_STREAM_ERROR; } - //strm.msg = Z_NULL; /* in case we return an error */ - - state = new InflateState(); - - //if (state === Z_NULL) return Z_MEM_ERROR; - //Tracev((stderr, "inflate: allocated\n")); - strm.state = state; - state.window = null/*Z_NULL*/; - ret = inflateReset2(strm, windowBits); - if (ret !== Z_OK) { - strm.state = null/*Z_NULL*/; - } - return ret; - } - - function inflateInit(strm) { - return inflateInit2(strm, DEF_WBITS); - } - - - /* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ - var virgin = true; - - var lenfix, distfix; // We have no pointers in JS, so keep tables separate - - function fixedtables(state) { - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - var sym; - - lenfix = new utils.Buf32(512); - distfix = new utils.Buf32(32); - - /* literal/length table */ - sym = 0; - while (sym < 144) { state.lens[sym++] = 8; } - while (sym < 256) { state.lens[sym++] = 9; } - while (sym < 280) { state.lens[sym++] = 7; } - while (sym < 288) { state.lens[sym++] = 8; } - - inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 }); - - /* distance table */ - sym = 0; - while (sym < 32) { state.lens[sym++] = 5; } - - inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 }); - - /* do this just once */ - virgin = false; - } - - state.lencode = lenfix; - state.lenbits = 9; - state.distcode = distfix; - state.distbits = 5; - } - - - /* - Update the window with the last wsize (normally 32K) bytes written before - returning. If window does not exist yet, create it. This is only called - when a window is already in use, or when output has been written during this - inflate call, but the end of the deflate stream has not been reached yet. - It is also called to create a window for dictionary data when a dictionary - is loaded. - - Providing output buffers larger than 32K to inflate() should provide a speed - advantage, since only the last 32K of output is copied to the sliding window - upon return from inflate(), and since all distances after the first 32K of - output will fall in the output data, making match copies simpler and faster. - The advantage may be dependent on the size of the processor's data caches. - */ - function updatewindow(strm, src, end, copy) { - var dist; - var state = strm.state; - - /* if it hasn't been done already, allocate space for the window */ - if (state.window === null) { - state.wsize = 1 << state.wbits; - state.wnext = 0; - state.whave = 0; - - state.window = new utils.Buf8(state.wsize); - } - - /* copy state->wsize or less output bytes into the circular window */ - if (copy >= state.wsize) { - utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0); - state.wnext = 0; - state.whave = state.wsize; - } - else { - dist = state.wsize - state.wnext; - if (dist > copy) { - dist = copy; - } - //zmemcpy(state->window + state->wnext, end - copy, dist); - utils.arraySet(state.window, src, end - copy, dist, state.wnext); - copy -= dist; - if (copy) { - //zmemcpy(state->window, end - copy, copy); - utils.arraySet(state.window, src, end - copy, copy, 0); - state.wnext = copy; - state.whave = state.wsize; - } - else { - state.wnext += dist; - if (state.wnext === state.wsize) { state.wnext = 0; } - if (state.whave < state.wsize) { state.whave += dist; } - } - } - return 0; - } - - function inflate(strm, flush) { - var state; - var input, output; // input/output buffers - var next; /* next input INDEX */ - var put; /* next output INDEX */ - var have, left; /* available input and output */ - var hold; /* bit buffer */ - var bits; /* bits in bit buffer */ - var _in, _out; /* save starting available input and output */ - var copy; /* number of stored or match bytes to copy */ - var from; /* where to copy match bytes from */ - var from_source; - var here = 0; /* current decoding table entry */ - var here_bits, here_op, here_val; // paked "here" denormalized (JS specific) - //var last; /* parent table entry */ - var last_bits, last_op, last_val; // paked "last" denormalized (JS specific) - var len; /* length to copy for repeats, bits to drop */ - var ret; /* return code */ - var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */ - var opts; - - var n; // temporary var for NEED_BITS - - var order = /* permutation of code lengths */ - [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]; - - - if (!strm || !strm.state || !strm.output || - (!strm.input && strm.avail_in !== 0)) { - return Z_STREAM_ERROR; - } - - state = strm.state; - if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */ - - - //--- LOAD() --- - put = strm.next_out; - output = strm.output; - left = strm.avail_out; - next = strm.next_in; - input = strm.input; - have = strm.avail_in; - hold = state.hold; - bits = state.bits; - //--- - - _in = have; - _out = left; - ret = Z_OK; - - inf_leave: // goto emulation - for (;;) { - switch (state.mode) { - case HEAD: - if (state.wrap === 0) { - state.mode = TYPEDO; - break; - } - //=== NEEDBITS(16); - while (bits < 16) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */ - state.check = 0/*crc32(0L, Z_NULL, 0)*/; - //=== CRC2(state.check, hold); - hbuf[0] = hold & 0xff; - hbuf[1] = (hold >>> 8) & 0xff; - state.check = crc32(state.check, hbuf, 2, 0); - //===// - - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - state.mode = FLAGS; - break; - } - state.flags = 0; /* expect zlib header */ - if (state.head) { - state.head.done = false; - } - if (!(state.wrap & 1) || /* check if zlib header allowed */ - (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) { - strm.msg = 'incorrect header check'; - state.mode = BAD; - break; - } - if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) { - strm.msg = 'unknown compression method'; - state.mode = BAD; - break; - } - //--- DROPBITS(4) ---// - hold >>>= 4; - bits -= 4; - //---// - len = (hold & 0x0f)/*BITS(4)*/ + 8; - if (state.wbits === 0) { - state.wbits = len; - } - else if (len > state.wbits) { - strm.msg = 'invalid window size'; - state.mode = BAD; - break; - } - state.dmax = 1 << len; - //Tracev((stderr, "inflate: zlib header ok\n")); - strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/; - state.mode = hold & 0x200 ? DICTID : TYPE; - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - break; - case FLAGS: - //=== NEEDBITS(16); */ - while (bits < 16) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.flags = hold; - if ((state.flags & 0xff) !== Z_DEFLATED) { - strm.msg = 'unknown compression method'; - state.mode = BAD; - break; - } - if (state.flags & 0xe000) { - strm.msg = 'unknown header flags set'; - state.mode = BAD; - break; - } - if (state.head) { - state.head.text = ((hold >> 8) & 1); - } - if (state.flags & 0x0200) { - //=== CRC2(state.check, hold); - hbuf[0] = hold & 0xff; - hbuf[1] = (hold >>> 8) & 0xff; - state.check = crc32(state.check, hbuf, 2, 0); - //===// - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - state.mode = TIME; - /* falls through */ - case TIME: - //=== NEEDBITS(32); */ - while (bits < 32) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - if (state.head) { - state.head.time = hold; - } - if (state.flags & 0x0200) { - //=== CRC4(state.check, hold) - hbuf[0] = hold & 0xff; - hbuf[1] = (hold >>> 8) & 0xff; - hbuf[2] = (hold >>> 16) & 0xff; - hbuf[3] = (hold >>> 24) & 0xff; - state.check = crc32(state.check, hbuf, 4, 0); - //=== - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - state.mode = OS; - /* falls through */ - case OS: - //=== NEEDBITS(16); */ - while (bits < 16) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - if (state.head) { - state.head.xflags = (hold & 0xff); - state.head.os = (hold >> 8); - } - if (state.flags & 0x0200) { - //=== CRC2(state.check, hold); - hbuf[0] = hold & 0xff; - hbuf[1] = (hold >>> 8) & 0xff; - state.check = crc32(state.check, hbuf, 2, 0); - //===// - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - state.mode = EXLEN; - /* falls through */ - case EXLEN: - if (state.flags & 0x0400) { - //=== NEEDBITS(16); */ - while (bits < 16) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.length = hold; - if (state.head) { - state.head.extra_len = hold; - } - if (state.flags & 0x0200) { - //=== CRC2(state.check, hold); - hbuf[0] = hold & 0xff; - hbuf[1] = (hold >>> 8) & 0xff; - state.check = crc32(state.check, hbuf, 2, 0); - //===// - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - } - else if (state.head) { - state.head.extra = null/*Z_NULL*/; - } - state.mode = EXTRA; - /* falls through */ - case EXTRA: - if (state.flags & 0x0400) { - copy = state.length; - if (copy > have) { copy = have; } - if (copy) { - if (state.head) { - len = state.head.extra_len - state.length; - if (!state.head.extra) { - // Use untyped array for more conveniend processing later - state.head.extra = new Array(state.head.extra_len); - } - utils.arraySet( - state.head.extra, - input, - next, - // extra field is limited to 65536 bytes - // - no need for additional size check - copy, - /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ - len - ); - //zmemcpy(state.head.extra + len, next, - // len + copy > state.head.extra_max ? - // state.head.extra_max - len : copy); - } - if (state.flags & 0x0200) { - state.check = crc32(state.check, input, copy, next); - } - have -= copy; - next += copy; - state.length -= copy; - } - if (state.length) { break inf_leave; } - } - state.length = 0; - state.mode = NAME; - /* falls through */ - case NAME: - if (state.flags & 0x0800) { - if (have === 0) { break inf_leave; } - copy = 0; - do { - // TODO: 2 or 1 bytes? - len = input[next + copy++]; - /* use constant limit because in js we should not preallocate memory */ - if (state.head && len && - (state.length < 65536 /*state.head.name_max*/)) { - state.head.name += String.fromCharCode(len); - } - } while (len && copy < have); - - if (state.flags & 0x0200) { - state.check = crc32(state.check, input, copy, next); - } - have -= copy; - next += copy; - if (len) { break inf_leave; } - } - else if (state.head) { - state.head.name = null; - } - state.length = 0; - state.mode = COMMENT; - /* falls through */ - case COMMENT: - if (state.flags & 0x1000) { - if (have === 0) { break inf_leave; } - copy = 0; - do { - len = input[next + copy++]; - /* use constant limit because in js we should not preallocate memory */ - if (state.head && len && - (state.length < 65536 /*state.head.comm_max*/)) { - state.head.comment += String.fromCharCode(len); - } - } while (len && copy < have); - if (state.flags & 0x0200) { - state.check = crc32(state.check, input, copy, next); - } - have -= copy; - next += copy; - if (len) { break inf_leave; } - } - else if (state.head) { - state.head.comment = null; - } - state.mode = HCRC; - /* falls through */ - case HCRC: - if (state.flags & 0x0200) { - //=== NEEDBITS(16); */ - while (bits < 16) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - if (hold !== (state.check & 0xffff)) { - strm.msg = 'header crc mismatch'; - state.mode = BAD; - break; - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - } - if (state.head) { - state.head.hcrc = ((state.flags >> 9) & 1); - state.head.done = true; - } - strm.adler = state.check = 0; - state.mode = TYPE; - break; - case DICTID: - //=== NEEDBITS(32); */ - while (bits < 32) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - strm.adler = state.check = zswap32(hold); - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - state.mode = DICT; - /* falls through */ - case DICT: - if (state.havedict === 0) { - //--- RESTORE() --- - strm.next_out = put; - strm.avail_out = left; - strm.next_in = next; - strm.avail_in = have; - state.hold = hold; - state.bits = bits; - //--- - return Z_NEED_DICT; - } - strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/; - state.mode = TYPE; - /* falls through */ - case TYPE: - if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; } - /* falls through */ - case TYPEDO: - if (state.last) { - //--- BYTEBITS() ---// - hold >>>= bits & 7; - bits -= bits & 7; - //---// - state.mode = CHECK; - break; - } - //=== NEEDBITS(3); */ - while (bits < 3) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.last = (hold & 0x01)/*BITS(1)*/; - //--- DROPBITS(1) ---// - hold >>>= 1; - bits -= 1; - //---// - - switch ((hold & 0x03)/*BITS(2)*/) { - case 0: /* stored block */ - //Tracev((stderr, "inflate: stored block%s\n", - // state.last ? " (last)" : "")); - state.mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - //Tracev((stderr, "inflate: fixed codes block%s\n", - // state.last ? " (last)" : "")); - state.mode = LEN_; /* decode codes */ - if (flush === Z_TREES) { - //--- DROPBITS(2) ---// - hold >>>= 2; - bits -= 2; - //---// - break inf_leave; - } - break; - case 2: /* dynamic block */ - //Tracev((stderr, "inflate: dynamic codes block%s\n", - // state.last ? " (last)" : "")); - state.mode = TABLE; - break; - case 3: - strm.msg = 'invalid block type'; - state.mode = BAD; - } - //--- DROPBITS(2) ---// - hold >>>= 2; - bits -= 2; - //---// - break; - case STORED: - //--- BYTEBITS() ---// /* go to byte boundary */ - hold >>>= bits & 7; - bits -= bits & 7; - //---// - //=== NEEDBITS(32); */ - while (bits < 32) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) { - strm.msg = 'invalid stored block lengths'; - state.mode = BAD; - break; - } - state.length = hold & 0xffff; - //Tracev((stderr, "inflate: stored length %u\n", - // state.length)); - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - state.mode = COPY_; - if (flush === Z_TREES) { break inf_leave; } - /* falls through */ - case COPY_: - state.mode = COPY; - /* falls through */ - case COPY: - copy = state.length; - if (copy) { - if (copy > have) { copy = have; } - if (copy > left) { copy = left; } - if (copy === 0) { break inf_leave; } - //--- zmemcpy(put, next, copy); --- - utils.arraySet(output, input, next, copy, put); - //---// - have -= copy; - next += copy; - left -= copy; - put += copy; - state.length -= copy; - break; - } - //Tracev((stderr, "inflate: stored end\n")); - state.mode = TYPE; - break; - case TABLE: - //=== NEEDBITS(14); */ - while (bits < 14) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257; - //--- DROPBITS(5) ---// - hold >>>= 5; - bits -= 5; - //---// - state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1; - //--- DROPBITS(5) ---// - hold >>>= 5; - bits -= 5; - //---// - state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4; - //--- DROPBITS(4) ---// - hold >>>= 4; - bits -= 4; - //---// - //#ifndef PKZIP_BUG_WORKAROUND - if (state.nlen > 286 || state.ndist > 30) { - strm.msg = 'too many length or distance symbols'; - state.mode = BAD; - break; - } - //#endif - //Tracev((stderr, "inflate: table sizes ok\n")); - state.have = 0; - state.mode = LENLENS; - /* falls through */ - case LENLENS: - while (state.have < state.ncode) { - //=== NEEDBITS(3); - while (bits < 3) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.lens[order[state.have++]] = (hold & 0x07);//BITS(3); - //--- DROPBITS(3) ---// - hold >>>= 3; - bits -= 3; - //---// - } - while (state.have < 19) { - state.lens[order[state.have++]] = 0; - } - // We have separate tables & no pointers. 2 commented lines below not needed. - //state.next = state.codes; - //state.lencode = state.next; - // Switch to use dynamic table - state.lencode = state.lendyn; - state.lenbits = 7; - - opts = { bits: state.lenbits }; - ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts); - state.lenbits = opts.bits; - - if (ret) { - strm.msg = 'invalid code lengths set'; - state.mode = BAD; - break; - } - //Tracev((stderr, "inflate: code lengths ok\n")); - state.have = 0; - state.mode = CODELENS; - /* falls through */ - case CODELENS: - while (state.have < state.nlen + state.ndist) { - for (;;) { - here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/ - here_bits = here >>> 24; - here_op = (here >>> 16) & 0xff; - here_val = here & 0xffff; - - if ((here_bits) <= bits) { break; } - //--- PULLBYTE() ---// - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - //---// - } - if (here_val < 16) { - //--- DROPBITS(here.bits) ---// - hold >>>= here_bits; - bits -= here_bits; - //---// - state.lens[state.have++] = here_val; - } - else { - if (here_val === 16) { - //=== NEEDBITS(here.bits + 2); - n = here_bits + 2; - while (bits < n) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - //--- DROPBITS(here.bits) ---// - hold >>>= here_bits; - bits -= here_bits; - //---// - if (state.have === 0) { - strm.msg = 'invalid bit length repeat'; - state.mode = BAD; - break; - } - len = state.lens[state.have - 1]; - copy = 3 + (hold & 0x03);//BITS(2); - //--- DROPBITS(2) ---// - hold >>>= 2; - bits -= 2; - //---// - } - else if (here_val === 17) { - //=== NEEDBITS(here.bits + 3); - n = here_bits + 3; - while (bits < n) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - //--- DROPBITS(here.bits) ---// - hold >>>= here_bits; - bits -= here_bits; - //---// - len = 0; - copy = 3 + (hold & 0x07);//BITS(3); - //--- DROPBITS(3) ---// - hold >>>= 3; - bits -= 3; - //---// - } - else { - //=== NEEDBITS(here.bits + 7); - n = here_bits + 7; - while (bits < n) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - //--- DROPBITS(here.bits) ---// - hold >>>= here_bits; - bits -= here_bits; - //---// - len = 0; - copy = 11 + (hold & 0x7f);//BITS(7); - //--- DROPBITS(7) ---// - hold >>>= 7; - bits -= 7; - //---// - } - if (state.have + copy > state.nlen + state.ndist) { - strm.msg = 'invalid bit length repeat'; - state.mode = BAD; - break; - } - while (copy--) { - state.lens[state.have++] = len; - } - } - } - - /* handle error breaks in while */ - if (state.mode === BAD) { break; } - - /* check for end-of-block code (better have one) */ - if (state.lens[256] === 0) { - strm.msg = 'invalid code -- missing end-of-block'; - state.mode = BAD; - break; - } - - /* build code tables -- note: do not change the lenbits or distbits - values here (9 and 6) without reading the comments in inftrees.h - concerning the ENOUGH constants, which depend on those values */ - state.lenbits = 9; - - opts = { bits: state.lenbits }; - ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts); - // We have separate tables & no pointers. 2 commented lines below not needed. - // state.next_index = opts.table_index; - state.lenbits = opts.bits; - // state.lencode = state.next; - - if (ret) { - strm.msg = 'invalid literal/lengths set'; - state.mode = BAD; - break; - } - - state.distbits = 6; - //state.distcode.copy(state.codes); - // Switch to use dynamic table - state.distcode = state.distdyn; - opts = { bits: state.distbits }; - ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts); - // We have separate tables & no pointers. 2 commented lines below not needed. - // state.next_index = opts.table_index; - state.distbits = opts.bits; - // state.distcode = state.next; - - if (ret) { - strm.msg = 'invalid distances set'; - state.mode = BAD; - break; - } - //Tracev((stderr, 'inflate: codes ok\n')); - state.mode = LEN_; - if (flush === Z_TREES) { break inf_leave; } - /* falls through */ - case LEN_: - state.mode = LEN; - /* falls through */ - case LEN: - if (have >= 6 && left >= 258) { - //--- RESTORE() --- - strm.next_out = put; - strm.avail_out = left; - strm.next_in = next; - strm.avail_in = have; - state.hold = hold; - state.bits = bits; - //--- - inflate_fast(strm, _out); - //--- LOAD() --- - put = strm.next_out; - output = strm.output; - left = strm.avail_out; - next = strm.next_in; - input = strm.input; - have = strm.avail_in; - hold = state.hold; - bits = state.bits; - //--- - - if (state.mode === TYPE) { - state.back = -1; - } - break; - } - state.back = 0; - for (;;) { - here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/ - here_bits = here >>> 24; - here_op = (here >>> 16) & 0xff; - here_val = here & 0xffff; - - if (here_bits <= bits) { break; } - //--- PULLBYTE() ---// - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - //---// - } - if (here_op && (here_op & 0xf0) === 0) { - last_bits = here_bits; - last_op = here_op; - last_val = here_val; - for (;;) { - here = state.lencode[last_val + - ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)]; - here_bits = here >>> 24; - here_op = (here >>> 16) & 0xff; - here_val = here & 0xffff; - - if ((last_bits + here_bits) <= bits) { break; } - //--- PULLBYTE() ---// - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - //---// - } - //--- DROPBITS(last.bits) ---// - hold >>>= last_bits; - bits -= last_bits; - //---// - state.back += last_bits; - } - //--- DROPBITS(here.bits) ---// - hold >>>= here_bits; - bits -= here_bits; - //---// - state.back += here_bits; - state.length = here_val; - if (here_op === 0) { - //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - // "inflate: literal '%c'\n" : - // "inflate: literal 0x%02x\n", here.val)); - state.mode = LIT; - break; - } - if (here_op & 32) { - //Tracevv((stderr, "inflate: end of block\n")); - state.back = -1; - state.mode = TYPE; - break; - } - if (here_op & 64) { - strm.msg = 'invalid literal/length code'; - state.mode = BAD; - break; - } - state.extra = here_op & 15; - state.mode = LENEXT; - /* falls through */ - case LENEXT: - if (state.extra) { - //=== NEEDBITS(state.extra); - n = state.extra; - while (bits < n) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/; - //--- DROPBITS(state.extra) ---// - hold >>>= state.extra; - bits -= state.extra; - //---// - state.back += state.extra; - } - //Tracevv((stderr, "inflate: length %u\n", state.length)); - state.was = state.length; - state.mode = DIST; - /* falls through */ - case DIST: - for (;;) { - here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/ - here_bits = here >>> 24; - here_op = (here >>> 16) & 0xff; - here_val = here & 0xffff; - - if ((here_bits) <= bits) { break; } - //--- PULLBYTE() ---// - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - //---// - } - if ((here_op & 0xf0) === 0) { - last_bits = here_bits; - last_op = here_op; - last_val = here_val; - for (;;) { - here = state.distcode[last_val + - ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)]; - here_bits = here >>> 24; - here_op = (here >>> 16) & 0xff; - here_val = here & 0xffff; - - if ((last_bits + here_bits) <= bits) { break; } - //--- PULLBYTE() ---// - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - //---// - } - //--- DROPBITS(last.bits) ---// - hold >>>= last_bits; - bits -= last_bits; - //---// - state.back += last_bits; - } - //--- DROPBITS(here.bits) ---// - hold >>>= here_bits; - bits -= here_bits; - //---// - state.back += here_bits; - if (here_op & 64) { - strm.msg = 'invalid distance code'; - state.mode = BAD; - break; - } - state.offset = here_val; - state.extra = (here_op) & 15; - state.mode = DISTEXT; - /* falls through */ - case DISTEXT: - if (state.extra) { - //=== NEEDBITS(state.extra); - n = state.extra; - while (bits < n) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/; - //--- DROPBITS(state.extra) ---// - hold >>>= state.extra; - bits -= state.extra; - //---// - state.back += state.extra; - } - //#ifdef INFLATE_STRICT - if (state.offset > state.dmax) { - strm.msg = 'invalid distance too far back'; - state.mode = BAD; - break; - } - //#endif - //Tracevv((stderr, "inflate: distance %u\n", state.offset)); - state.mode = MATCH; - /* falls through */ - case MATCH: - if (left === 0) { break inf_leave; } - copy = _out - left; - if (state.offset > copy) { /* copy from window */ - copy = state.offset - copy; - if (copy > state.whave) { - if (state.sane) { - strm.msg = 'invalid distance too far back'; - state.mode = BAD; - break; - } - // (!) This block is disabled in zlib defailts, - // don't enable it for binary compatibility - //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - // Trace((stderr, "inflate.c too far\n")); - // copy -= state.whave; - // if (copy > state.length) { copy = state.length; } - // if (copy > left) { copy = left; } - // left -= copy; - // state.length -= copy; - // do { - // output[put++] = 0; - // } while (--copy); - // if (state.length === 0) { state.mode = LEN; } - // break; - //#endif - } - if (copy > state.wnext) { - copy -= state.wnext; - from = state.wsize - copy; - } - else { - from = state.wnext - copy; - } - if (copy > state.length) { copy = state.length; } - from_source = state.window; - } - else { /* copy from output */ - from_source = output; - from = put - state.offset; - copy = state.length; - } - if (copy > left) { copy = left; } - left -= copy; - state.length -= copy; - do { - output[put++] = from_source[from++]; - } while (--copy); - if (state.length === 0) { state.mode = LEN; } - break; - case LIT: - if (left === 0) { break inf_leave; } - output[put++] = state.length; - left--; - state.mode = LEN; - break; - case CHECK: - if (state.wrap) { - //=== NEEDBITS(32); - while (bits < 32) { - if (have === 0) { break inf_leave; } - have--; - // Use '|' insdead of '+' to make sure that result is signed - hold |= input[next++] << bits; - bits += 8; - } - //===// - _out -= left; - strm.total_out += _out; - state.total += _out; - if (_out) { - strm.adler = state.check = - /*UPDATE(state.check, put - _out, _out);*/ - (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out)); - - } - _out = left; - // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too - if ((state.flags ? hold : zswap32(hold)) !== state.check) { - strm.msg = 'incorrect data check'; - state.mode = BAD; - break; - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - //Tracev((stderr, "inflate: check matches trailer\n")); - } - state.mode = LENGTH; - /* falls through */ - case LENGTH: - if (state.wrap && state.flags) { - //=== NEEDBITS(32); - while (bits < 32) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - if (hold !== (state.total & 0xffffffff)) { - strm.msg = 'incorrect length check'; - state.mode = BAD; - break; - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - //Tracev((stderr, "inflate: length matches trailer\n")); - } - state.mode = DONE; - /* falls through */ - case DONE: - ret = Z_STREAM_END; - break inf_leave; - case BAD: - ret = Z_DATA_ERROR; - break inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - /* falls through */ - default: - return Z_STREAM_ERROR; - } - } - - // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave" - - /* - Return from inflate(), updating the total counts and the check value. - If there was no progress during the inflate() call, return a buffer - error. Call updatewindow() to create and/or update the window state. - Note: a memory error from inflate() is non-recoverable. - */ - - //--- RESTORE() --- - strm.next_out = put; - strm.avail_out = left; - strm.next_in = next; - strm.avail_in = have; - state.hold = hold; - state.bits = bits; - //--- - - if (state.wsize || (_out !== strm.avail_out && state.mode < BAD && - (state.mode < CHECK || flush !== Z_FINISH))) { - if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) { - state.mode = MEM; - return Z_MEM_ERROR; - } - } - _in -= strm.avail_in; - _out -= strm.avail_out; - strm.total_in += _in; - strm.total_out += _out; - state.total += _out; - if (state.wrap && _out) { - strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/ - (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out)); - } - strm.data_type = state.bits + (state.last ? 64 : 0) + - (state.mode === TYPE ? 128 : 0) + - (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0); - if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) { - ret = Z_BUF_ERROR; - } - return ret; - } - - function inflateEnd(strm) { - - if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) { - return Z_STREAM_ERROR; - } - - var state = strm.state; - if (state.window) { - state.window = null; - } - strm.state = null; - return Z_OK; - } - - function inflateGetHeader(strm, head) { - var state; - - /* check state */ - if (!strm || !strm.state) { return Z_STREAM_ERROR; } - state = strm.state; - if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; } - - /* save header structure */ - state.head = head; - head.done = false; - return Z_OK; - } - - function inflateSetDictionary(strm, dictionary) { - var dictLength = dictionary.length; - - var state; - var dictid; - var ret; - - /* check state */ - if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; } - state = strm.state; - - if (state.wrap !== 0 && state.mode !== DICT) { - return Z_STREAM_ERROR; - } - - /* check for correct dictionary identifier */ - if (state.mode === DICT) { - dictid = 1; /* adler32(0, null, 0)*/ - /* dictid = adler32(dictid, dictionary, dictLength); */ - dictid = adler32(dictid, dictionary, dictLength, 0); - if (dictid !== state.check) { - return Z_DATA_ERROR; - } - } - /* copy dictionary to window using updatewindow(), which will amend the - existing dictionary if appropriate */ - ret = updatewindow(strm, dictionary, dictLength, dictLength); - if (ret) { - state.mode = MEM; - return Z_MEM_ERROR; - } - state.havedict = 1; - // Tracev((stderr, "inflate: dictionary set\n")); - return Z_OK; - } - - exports.inflateReset = inflateReset; - exports.inflateReset2 = inflateReset2; - exports.inflateResetKeep = inflateResetKeep; - exports.inflateInit = inflateInit; - exports.inflateInit2 = inflateInit2; - exports.inflate = inflate; - exports.inflateEnd = inflateEnd; - exports.inflateGetHeader = inflateGetHeader; - exports.inflateSetDictionary = inflateSetDictionary; - exports.inflateInfo = 'pako inflate (from Nodeca project)'; - - /* Not implemented - exports.inflateCopy = inflateCopy; - exports.inflateGetDictionary = inflateGetDictionary; - exports.inflateMark = inflateMark; - exports.inflatePrime = inflatePrime; - exports.inflateSync = inflateSync; - exports.inflateSyncPoint = inflateSyncPoint; - exports.inflateUndermine = inflateUndermine; - */ - - -/***/ }, -/* 81 */ -/***/ function(module, exports) { - - 'use strict'; - - // See state defs from inflate.js - var BAD = 30; /* got a data error -- remain here until reset */ - var TYPE = 12; /* i: waiting for type bits, including last-flag bit */ - - /* - Decode literal, length, and distance codes and write out the resulting - literal and match bytes until either not enough input or output is - available, an end-of-block is encountered, or a data error is encountered. - When large enough input and output buffers are supplied to inflate(), for - example, a 16K input buffer and a 64K output buffer, more than 95% of the - inflate execution time is spent in this routine. - - Entry assumptions: - - state.mode === LEN - strm.avail_in >= 6 - strm.avail_out >= 258 - start >= strm.avail_out - state.bits < 8 - - On return, state.mode is one of: - - LEN -- ran out of enough output space or enough available input - TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data - - Notes: - - - The maximum input bits used by a length/distance pair is 15 bits for the - length code, 5 bits for the length extra, 15 bits for the distance code, - and 13 bits for the distance extra. This totals 48 bits, or six bytes. - Therefore if strm.avail_in >= 6, then there is enough input to avoid - checking for available input while decoding. - - - The maximum bytes that a single length/distance pair can output is 258 - bytes, which is the maximum length that can be coded. inflate_fast() - requires strm.avail_out >= 258 for each loop to avoid checking for - output space. - */ - module.exports = function inflate_fast(strm, start) { - var state; - var _in; /* local strm.input */ - var last; /* have enough input while in < last */ - var _out; /* local strm.output */ - var beg; /* inflate()'s initial strm.output */ - var end; /* while out < end, enough space available */ - //#ifdef INFLATE_STRICT - var dmax; /* maximum distance from zlib header */ - //#endif - var wsize; /* window size or zero if not using window */ - var whave; /* valid bytes in the window */ - var wnext; /* window write index */ - // Use `s_window` instead `window`, avoid conflict with instrumentation tools - var s_window; /* allocated sliding window, if wsize != 0 */ - var hold; /* local strm.hold */ - var bits; /* local strm.bits */ - var lcode; /* local strm.lencode */ - var dcode; /* local strm.distcode */ - var lmask; /* mask for first level of length codes */ - var dmask; /* mask for first level of distance codes */ - var here; /* retrieved table entry */ - var op; /* code bits, operation, extra bits, or */ - /* window position, window bytes to copy */ - var len; /* match length, unused bytes */ - var dist; /* match distance */ - var from; /* where to copy match from */ - var from_source; - - - var input, output; // JS specific, because we have no pointers - - /* copy state to local variables */ - state = strm.state; - //here = state.here; - _in = strm.next_in; - input = strm.input; - last = _in + (strm.avail_in - 5); - _out = strm.next_out; - output = strm.output; - beg = _out - (start - strm.avail_out); - end = _out + (strm.avail_out - 257); - //#ifdef INFLATE_STRICT - dmax = state.dmax; - //#endif - wsize = state.wsize; - whave = state.whave; - wnext = state.wnext; - s_window = state.window; - hold = state.hold; - bits = state.bits; - lcode = state.lencode; - dcode = state.distcode; - lmask = (1 << state.lenbits) - 1; - dmask = (1 << state.distbits) - 1; - - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - - top: - do { - if (bits < 15) { - hold += input[_in++] << bits; - bits += 8; - hold += input[_in++] << bits; - bits += 8; - } - - here = lcode[hold & lmask]; - - dolen: - for (;;) { // Goto emulation - op = here >>> 24/*here.bits*/; - hold >>>= op; - bits -= op; - op = (here >>> 16) & 0xff/*here.op*/; - if (op === 0) { /* literal */ - //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - // "inflate: literal '%c'\n" : - // "inflate: literal 0x%02x\n", here.val)); - output[_out++] = here & 0xffff/*here.val*/; - } - else if (op & 16) { /* length base */ - len = here & 0xffff/*here.val*/; - op &= 15; /* number of extra bits */ - if (op) { - if (bits < op) { - hold += input[_in++] << bits; - bits += 8; - } - len += hold & ((1 << op) - 1); - hold >>>= op; - bits -= op; - } - //Tracevv((stderr, "inflate: length %u\n", len)); - if (bits < 15) { - hold += input[_in++] << bits; - bits += 8; - hold += input[_in++] << bits; - bits += 8; - } - here = dcode[hold & dmask]; - - dodist: - for (;;) { // goto emulation - op = here >>> 24/*here.bits*/; - hold >>>= op; - bits -= op; - op = (here >>> 16) & 0xff/*here.op*/; - - if (op & 16) { /* distance base */ - dist = here & 0xffff/*here.val*/; - op &= 15; /* number of extra bits */ - if (bits < op) { - hold += input[_in++] << bits; - bits += 8; - if (bits < op) { - hold += input[_in++] << bits; - bits += 8; - } - } - dist += hold & ((1 << op) - 1); - //#ifdef INFLATE_STRICT - if (dist > dmax) { - strm.msg = 'invalid distance too far back'; - state.mode = BAD; - break top; - } - //#endif - hold >>>= op; - bits -= op; - //Tracevv((stderr, "inflate: distance %u\n", dist)); - op = _out - beg; /* max distance in output */ - if (dist > op) { /* see if copy from window */ - op = dist - op; /* distance back in window */ - if (op > whave) { - if (state.sane) { - strm.msg = 'invalid distance too far back'; - state.mode = BAD; - break top; - } - - // (!) This block is disabled in zlib defailts, - // don't enable it for binary compatibility - //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - // if (len <= op - whave) { - // do { - // output[_out++] = 0; - // } while (--len); - // continue top; - // } - // len -= op - whave; - // do { - // output[_out++] = 0; - // } while (--op > whave); - // if (op === 0) { - // from = _out - dist; - // do { - // output[_out++] = output[from++]; - // } while (--len); - // continue top; - // } - //#endif - } - from = 0; // window index - from_source = s_window; - if (wnext === 0) { /* very common case */ - from += wsize - op; - if (op < len) { /* some from window */ - len -= op; - do { - output[_out++] = s_window[from++]; - } while (--op); - from = _out - dist; /* rest from output */ - from_source = output; - } - } - else if (wnext < op) { /* wrap around window */ - from += wsize + wnext - op; - op -= wnext; - if (op < len) { /* some from end of window */ - len -= op; - do { - output[_out++] = s_window[from++]; - } while (--op); - from = 0; - if (wnext < len) { /* some from start of window */ - op = wnext; - len -= op; - do { - output[_out++] = s_window[from++]; - } while (--op); - from = _out - dist; /* rest from output */ - from_source = output; - } - } - } - else { /* contiguous in window */ - from += wnext - op; - if (op < len) { /* some from window */ - len -= op; - do { - output[_out++] = s_window[from++]; - } while (--op); - from = _out - dist; /* rest from output */ - from_source = output; - } - } - while (len > 2) { - output[_out++] = from_source[from++]; - output[_out++] = from_source[from++]; - output[_out++] = from_source[from++]; - len -= 3; - } - if (len) { - output[_out++] = from_source[from++]; - if (len > 1) { - output[_out++] = from_source[from++]; - } - } - } - else { - from = _out - dist; /* copy direct from output */ - do { /* minimum length is three */ - output[_out++] = output[from++]; - output[_out++] = output[from++]; - output[_out++] = output[from++]; - len -= 3; - } while (len > 2); - if (len) { - output[_out++] = output[from++]; - if (len > 1) { - output[_out++] = output[from++]; - } - } - } - } - else if ((op & 64) === 0) { /* 2nd level distance code */ - here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))]; - continue dodist; - } - else { - strm.msg = 'invalid distance code'; - state.mode = BAD; - break top; - } - - break; // need to emulate goto via "continue" - } - } - else if ((op & 64) === 0) { /* 2nd level length code */ - here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))]; - continue dolen; - } - else if (op & 32) { /* end-of-block */ - //Tracevv((stderr, "inflate: end of block\n")); - state.mode = TYPE; - break top; - } - else { - strm.msg = 'invalid literal/length code'; - state.mode = BAD; - break top; - } - - break; // need to emulate goto via "continue" - } - } while (_in < last && _out < end); - - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ - len = bits >> 3; - _in -= len; - bits -= len << 3; - hold &= (1 << bits) - 1; - - /* update state and return */ - strm.next_in = _in; - strm.next_out = _out; - strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last)); - strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end)); - state.hold = hold; - state.bits = bits; - return; - }; - - -/***/ }, -/* 82 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - - var utils = __webpack_require__(76); - - var MAXBITS = 15; - var ENOUGH_LENS = 852; - var ENOUGH_DISTS = 592; - //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS); - - var CODES = 0; - var LENS = 1; - var DISTS = 2; - - var lbase = [ /* Length codes 257..285 base */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 - ]; - - var lext = [ /* Length codes 257..285 extra */ - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78 - ]; - - var dbase = [ /* Distance codes 0..29 base */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577, 0, 0 - ]; - - var dext = [ /* Distance codes 0..29 extra */ - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, - 28, 28, 29, 29, 64, 64 - ]; - - module.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) - { - var bits = opts.bits; - //here = opts.here; /* table entry for duplication */ - - var len = 0; /* a code's length in bits */ - var sym = 0; /* index of code symbols */ - var min = 0, max = 0; /* minimum and maximum code lengths */ - var root = 0; /* number of index bits for root table */ - var curr = 0; /* number of index bits for current table */ - var drop = 0; /* code bits to drop for sub-table */ - var left = 0; /* number of prefix codes available */ - var used = 0; /* code entries in table used */ - var huff = 0; /* Huffman code */ - var incr; /* for incrementing code, index */ - var fill; /* index for replicating entries */ - var low; /* low bits for current root entry */ - var mask; /* mask for low root bits */ - var next; /* next available space in table */ - var base = null; /* base value table to use */ - var base_index = 0; - // var shoextra; /* extra bits table to use */ - var end; /* use base and extra for symbol > end */ - var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */ - var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */ - var extra = null; - var extra_index = 0; - - var here_bits, here_op, here_val; - - /* - Process a set of code lengths to create a canonical Huffman code. The - code lengths are lens[0..codes-1]. Each length corresponds to the - symbols 0..codes-1. The Huffman code is generated by first sorting the - symbols by length from short to long, and retaining the symbol order - for codes with equal lengths. Then the code starts with all zero bits - for the first code of the shortest length, and the codes are integer - increments for the same length, and zeros are appended as the length - increases. For the deflate format, these bits are stored backwards - from their more natural integer increment ordering, and so when the - decoding tables are built in the large loop below, the integer codes - are incremented backwards. - - This routine assumes, but does not check, that all of the entries in - lens[] are in the range 0..MAXBITS. The caller must assure this. - 1..MAXBITS is interpreted as that code length. zero means that that - symbol does not occur in this code. - - The codes are sorted by computing a count of codes for each length, - creating from that a table of starting indices for each length in the - sorted table, and then entering the symbols in order in the sorted - table. The sorted table is work[], with that space being provided by - the caller. - - The length counts are used for other purposes as well, i.e. finding - the minimum and maximum length codes, determining if there are any - codes at all, checking for a valid set of lengths, and looking ahead - at length counts to determine sub-table sizes when building the - decoding tables. - */ - - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ - for (len = 0; len <= MAXBITS; len++) { - count[len] = 0; - } - for (sym = 0; sym < codes; sym++) { - count[lens[lens_index + sym]]++; - } - - /* bound code lengths, force root to be within code lengths */ - root = bits; - for (max = MAXBITS; max >= 1; max--) { - if (count[max] !== 0) { break; } - } - if (root > max) { - root = max; - } - if (max === 0) { /* no symbols to code at all */ - //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */ - //table.bits[opts.table_index] = 1; //here.bits = (var char)1; - //table.val[opts.table_index++] = 0; //here.val = (var short)0; - table[table_index++] = (1 << 24) | (64 << 16) | 0; - - - //table.op[opts.table_index] = 64; - //table.bits[opts.table_index] = 1; - //table.val[opts.table_index++] = 0; - table[table_index++] = (1 << 24) | (64 << 16) | 0; - - opts.bits = 1; - return 0; /* no symbols, but wait for decoding to report error */ - } - for (min = 1; min < max; min++) { - if (count[min] !== 0) { break; } - } - if (root < min) { - root = min; - } - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) { - return -1; - } /* over-subscribed */ - } - if (left > 0 && (type === CODES || max !== 1)) { - return -1; /* incomplete set */ - } - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) { - offs[len + 1] = offs[len] + count[len]; - } - - /* sort symbols by length, by symbol order within each length */ - for (sym = 0; sym < codes; sym++) { - if (lens[lens_index + sym] !== 0) { - work[offs[lens[lens_index + sym]]++] = sym; - } - } - - /* - Create and fill in decoding tables. In this loop, the table being - filled is at next and has curr index bits. The code being used is huff - with length len. That code is converted to an index by dropping drop - bits off of the bottom. For codes where len is less than drop + curr, - those top drop + curr - len bits are incremented through all values to - fill the table with replicated entries. - - root is the number of index bits for the root table. When len exceeds - root, sub-tables are created pointed to by the root entry with an index - of the low root bits of huff. This is saved in low to check for when a - new sub-table should be started. drop is zero when the root table is - being filled, and drop is root when sub-tables are being filled. - - When a new sub-table is needed, it is necessary to look ahead in the - code lengths to determine what size sub-table is needed. The length - counts are used for this, and so count[] is decremented as codes are - entered in the tables. - - used keeps track of how many table entries have been allocated from the - provided *table space. It is checked for LENS and DIST tables against - the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in - the initial root table size constants. See the comments in inftrees.h - for more information. - - sym increments through all symbols, and the loop terminates when - all codes of length max, i.e. all codes, have been processed. This - routine permits incomplete codes, so another loop after this one fills - in the rest of the decoding tables with invalid code markers. - */ - - /* set up for code type */ - // poor man optimization - use if-else instead of switch, - // to avoid deopts in old v8 - if (type === CODES) { - base = extra = work; /* dummy value--not used */ - end = 19; - - } else if (type === LENS) { - base = lbase; - base_index -= 257; - extra = lext; - extra_index -= 257; - end = 256; - - } else { /* DISTS */ - base = dbase; - extra = dext; - end = -1; - } - - /* initialize opts for loop */ - huff = 0; /* starting code */ - sym = 0; /* starting code symbol */ - len = min; /* starting code length */ - next = table_index; /* current table to fill in */ - curr = root; /* current table index bits */ - drop = 0; /* current bits to drop from code for index */ - low = -1; /* trigger new sub-table when len > root */ - used = 1 << root; /* use root table entries */ - mask = used - 1; /* mask for comparing low */ - - /* check available table space */ - if ((type === LENS && used > ENOUGH_LENS) || - (type === DISTS && used > ENOUGH_DISTS)) { - return 1; - } - - var i = 0; - /* process all codes and make table entries */ - for (;;) { - i++; - /* create table entry */ - here_bits = len - drop; - if (work[sym] < end) { - here_op = 0; - here_val = work[sym]; - } - else if (work[sym] > end) { - here_op = extra[extra_index + work[sym]]; - here_val = base[base_index + work[sym]]; - } - else { - here_op = 32 + 64; /* end of block */ - here_val = 0; - } - - /* replicate for those indices with low len bits equal to huff */ - incr = 1 << (len - drop); - fill = 1 << curr; - min = fill; /* save offset to next table */ - do { - fill -= incr; - table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0; - } while (fill !== 0); - - /* backwards increment the len-bit code huff */ - incr = 1 << (len - 1); - while (huff & incr) { - incr >>= 1; - } - if (incr !== 0) { - huff &= incr - 1; - huff += incr; - } else { - huff = 0; - } - - /* go to next symbol, update count, len */ - sym++; - if (--count[len] === 0) { - if (len === max) { break; } - len = lens[lens_index + work[sym]]; - } - - /* create new sub-table if needed */ - if (len > root && (huff & mask) !== low) { - /* if first time, transition to sub-tables */ - if (drop === 0) { - drop = root; - } - - /* increment past last table */ - next += min; /* here min is 1 << curr */ - - /* determine length of next table */ - curr = len - drop; - left = 1 << curr; - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) { break; } - curr++; - left <<= 1; - } - - /* check for enough space */ - used += 1 << curr; - if ((type === LENS && used > ENOUGH_LENS) || - (type === DISTS && used > ENOUGH_DISTS)) { - return 1; - } - - /* point entry in root table to sub-table */ - low = huff & mask; - /*table.op[low] = curr; - table.bits[low] = root; - table.val[low] = next - opts.table_index;*/ - table[low] = (root << 24) | (curr << 16) | (next - table_index) |0; - } - } - - /* fill in remaining table entry if code is incomplete (guaranteed to have - at most one remaining entry, since if the code is incomplete, the - maximum code length that was allowed to get this far is one bit) */ - if (huff !== 0) { - //table.op[next + huff] = 64; /* invalid code marker */ - //table.bits[next + huff] = len - drop; - //table.val[next + huff] = 0; - table[next + huff] = ((len - drop) << 24) | (64 << 16) |0; - } - - /* set return parameters */ - //opts.table_index += used; - opts.bits = root; - return 0; - }; - - -/***/ }, -/* 83 */ -/***/ function(module, exports) { - - 'use strict'; - - - module.exports = { - - /* Allowed flush values; see deflate() and inflate() below for details */ - Z_NO_FLUSH: 0, - Z_PARTIAL_FLUSH: 1, - Z_SYNC_FLUSH: 2, - Z_FULL_FLUSH: 3, - Z_FINISH: 4, - Z_BLOCK: 5, - Z_TREES: 6, - - /* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - Z_OK: 0, - Z_STREAM_END: 1, - Z_NEED_DICT: 2, - Z_ERRNO: -1, - Z_STREAM_ERROR: -2, - Z_DATA_ERROR: -3, - //Z_MEM_ERROR: -4, - Z_BUF_ERROR: -5, - //Z_VERSION_ERROR: -6, - - /* compression levels */ - Z_NO_COMPRESSION: 0, - Z_BEST_SPEED: 1, - Z_BEST_COMPRESSION: 9, - Z_DEFAULT_COMPRESSION: -1, - - - Z_FILTERED: 1, - Z_HUFFMAN_ONLY: 2, - Z_RLE: 3, - Z_FIXED: 4, - Z_DEFAULT_STRATEGY: 0, - - /* Possible values of the data_type field (though see inflate()) */ - Z_BINARY: 0, - Z_TEXT: 1, - //Z_ASCII: 1, // = Z_TEXT (deprecated) - Z_UNKNOWN: 2, - - /* The deflate compression method */ - Z_DEFLATED: 8 - //Z_NULL: null // Use -1 or null inline, depending on var type - }; - - -/***/ }, -/* 84 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(global) {'use strict'; - - // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js - // original notice: - - /*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ - function compare(a, b) { - if (a === b) { - return 0; - } - - var x = a.length; - var y = b.length; - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i]; - y = b[i]; - break; - } - } - - if (x < y) { - return -1; - } - if (y < x) { - return 1; - } - return 0; - } - function isBuffer(b) { - if (global.Buffer && typeof global.Buffer.isBuffer === 'function') { - return global.Buffer.isBuffer(b); - } - return !!(b != null && b._isBuffer); - } - - // based on node assert, original notice: - - // http://wiki.commonjs.org/wiki/Unit_Testing/1.0 - // - // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! - // - // Originally from narwhal.js (http://narwhaljs.org) - // Copyright (c) 2009 Thomas Robinson <280north.com> - // - // 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 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. - - var util = __webpack_require__(16); - var hasOwn = Object.prototype.hasOwnProperty; - var pSlice = Array.prototype.slice; - var functionsHaveNames = (function () { - return function foo() {}.name === 'foo'; - }()); - function pToString (obj) { - return Object.prototype.toString.call(obj); - } - function isView(arrbuf) { - if (isBuffer(arrbuf)) { - return false; - } - if (typeof global.ArrayBuffer !== 'function') { - return false; - } - if (typeof ArrayBuffer.isView === 'function') { - return ArrayBuffer.isView(arrbuf); - } - if (!arrbuf) { - return false; - } - if (arrbuf instanceof DataView) { - return true; - } - if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) { - return true; - } - return false; - } - // 1. The assert module provides functions that throw - // AssertionError's when particular conditions are not met. The - // assert module must conform to the following interface. - - var assert = module.exports = ok; - - // 2. The AssertionError is defined in assert. - // new assert.AssertionError({ message: message, - // actual: actual, - // expected: expected }) - - var regex = /\s*function\s+([^\(\s]*)\s*/; - // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js - function getName(func) { - if (!util.isFunction(func)) { - return; - } - if (functionsHaveNames) { - return func.name; - } - var str = func.toString(); - var match = str.match(regex); - return match && match[1]; - } - assert.AssertionError = function AssertionError(options) { - this.name = 'AssertionError'; - this.actual = options.actual; - this.expected = options.expected; - this.operator = options.operator; - if (options.message) { - this.message = options.message; - this.generatedMessage = false; - } else { - this.message = getMessage(this); - this.generatedMessage = true; - } - var stackStartFunction = options.stackStartFunction || fail; - if (Error.captureStackTrace) { - Error.captureStackTrace(this, stackStartFunction); - } else { - // non v8 browsers so we can have a stacktrace - var err = new Error(); - if (err.stack) { - var out = err.stack; - - // try to strip useless frames - var fn_name = getName(stackStartFunction); - var idx = out.indexOf('\n' + fn_name); - if (idx >= 0) { - // once we have located the function frame - // we need to strip out everything before it (and its line) - var next_line = out.indexOf('\n', idx + 1); - out = out.substring(next_line + 1); - } - - this.stack = out; - } - } - }; - - // assert.AssertionError instanceof Error - util.inherits(assert.AssertionError, Error); - - function truncate(s, n) { - if (typeof s === 'string') { - return s.length < n ? s : s.slice(0, n); - } else { - return s; - } - } - function inspect(something) { - if (functionsHaveNames || !util.isFunction(something)) { - return util.inspect(something); - } - var rawname = getName(something); - var name = rawname ? ': ' + rawname : ''; - return '[Function' + name + ']'; - } - function getMessage(self) { - return truncate(inspect(self.actual), 128) + ' ' + - self.operator + ' ' + - truncate(inspect(self.expected), 128); - } - - // At present only the three keys mentioned above are used and - // understood by the spec. Implementations or sub modules can pass - // other keys to the AssertionError's constructor - they will be - // ignored. - - // 3. All of the following functions must throw an AssertionError - // when a corresponding condition is not met, with a message that - // may be undefined if not provided. All assertion methods provide - // both the actual and expected values to the assertion error for - // display purposes. - - function fail(actual, expected, message, operator, stackStartFunction) { - throw new assert.AssertionError({ - message: message, - actual: actual, - expected: expected, - operator: operator, - stackStartFunction: stackStartFunction - }); - } - - // EXTENSION! allows for well behaved errors defined elsewhere. - assert.fail = fail; - - // 4. Pure assertion tests whether a value is truthy, as determined - // by !!guard. - // assert.ok(guard, message_opt); - // This statement is equivalent to assert.equal(true, !!guard, - // message_opt);. To test strictly for the value true, use - // assert.strictEqual(true, guard, message_opt);. - - function ok(value, message) { - if (!value) fail(value, true, message, '==', assert.ok); - } - assert.ok = ok; - - // 5. The equality assertion tests shallow, coercive equality with - // ==. - // assert.equal(actual, expected, message_opt); - - assert.equal = function equal(actual, expected, message) { - if (actual != expected) fail(actual, expected, message, '==', assert.equal); - }; - - // 6. The non-equality assertion tests for whether two objects are not equal - // with != assert.notEqual(actual, expected, message_opt); - - assert.notEqual = function notEqual(actual, expected, message) { - if (actual == expected) { - fail(actual, expected, message, '!=', assert.notEqual); - } - }; - - // 7. The equivalence assertion tests a deep equality relation. - // assert.deepEqual(actual, expected, message_opt); - - assert.deepEqual = function deepEqual(actual, expected, message) { - if (!_deepEqual(actual, expected, false)) { - fail(actual, expected, message, 'deepEqual', assert.deepEqual); - } - }; - - assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { - if (!_deepEqual(actual, expected, true)) { - fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual); - } - }; - - function _deepEqual(actual, expected, strict, memos) { - // 7.1. All identical values are equivalent, as determined by ===. - if (actual === expected) { - return true; - } else if (isBuffer(actual) && isBuffer(expected)) { - return compare(actual, expected) === 0; - - // 7.2. If the expected value is a Date object, the actual value is - // equivalent if it is also a Date object that refers to the same time. - } else if (util.isDate(actual) && util.isDate(expected)) { - return actual.getTime() === expected.getTime(); - - // 7.3 If the expected value is a RegExp object, the actual value is - // equivalent if it is also a RegExp object with the same source and - // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). - } else if (util.isRegExp(actual) && util.isRegExp(expected)) { - return actual.source === expected.source && - actual.global === expected.global && - actual.multiline === expected.multiline && - actual.lastIndex === expected.lastIndex && - actual.ignoreCase === expected.ignoreCase; - - // 7.4. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. - } else if ((actual === null || typeof actual !== 'object') && - (expected === null || typeof expected !== 'object')) { - return strict ? actual === expected : actual == expected; - - // If both values are instances of typed arrays, wrap their underlying - // ArrayBuffers in a Buffer each to increase performance - // This optimization requires the arrays to have the same type as checked by - // Object.prototype.toString (aka pToString). Never perform binary - // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their - // bit patterns are not identical. - } else if (isView(actual) && isView(expected) && - pToString(actual) === pToString(expected) && - !(actual instanceof Float32Array || - actual instanceof Float64Array)) { - return compare(new Uint8Array(actual.buffer), - new Uint8Array(expected.buffer)) === 0; - - // 7.5 For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical 'prototype' property. Note: this - // accounts for both named and indexed properties on Arrays. - } else if (isBuffer(actual) !== isBuffer(expected)) { - return false; - } else { - memos = memos || {actual: [], expected: []}; - - var actualIndex = memos.actual.indexOf(actual); - if (actualIndex !== -1) { - if (actualIndex === memos.expected.indexOf(expected)) { - return true; - } - } - - memos.actual.push(actual); - memos.expected.push(expected); - - return objEquiv(actual, expected, strict, memos); - } - } - - function isArguments(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; - } - - function objEquiv(a, b, strict, actualVisitedObjects) { - if (a === null || a === undefined || b === null || b === undefined) - return false; - // if one is a primitive, the other must be same - if (util.isPrimitive(a) || util.isPrimitive(b)) - return a === b; - if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) - return false; - var aIsArgs = isArguments(a); - var bIsArgs = isArguments(b); - if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) - return false; - if (aIsArgs) { - a = pSlice.call(a); - b = pSlice.call(b); - return _deepEqual(a, b, strict); - } - var ka = objectKeys(a); - var kb = objectKeys(b); - var key, i; - // having the same number of owned properties (keys incorporates - // hasOwnProperty) - if (ka.length !== kb.length) - return false; - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] !== kb[i]) - return false; - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) - return false; - } - return true; - } - - // 8. The non-equivalence assertion tests for any deep inequality. - // assert.notDeepEqual(actual, expected, message_opt); - - assert.notDeepEqual = function notDeepEqual(actual, expected, message) { - if (_deepEqual(actual, expected, false)) { - fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); - } - }; - - assert.notDeepStrictEqual = notDeepStrictEqual; - function notDeepStrictEqual(actual, expected, message) { - if (_deepEqual(actual, expected, true)) { - fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual); - } - } - - - // 9. The strict equality assertion tests strict equality, as determined by ===. - // assert.strictEqual(actual, expected, message_opt); - - assert.strictEqual = function strictEqual(actual, expected, message) { - if (actual !== expected) { - fail(actual, expected, message, '===', assert.strictEqual); - } - }; - - // 10. The strict non-equality assertion tests for strict inequality, as - // determined by !==. assert.notStrictEqual(actual, expected, message_opt); - - assert.notStrictEqual = function notStrictEqual(actual, expected, message) { - if (actual === expected) { - fail(actual, expected, message, '!==', assert.notStrictEqual); - } - }; - - function expectedException(actual, expected) { - if (!actual || !expected) { - return false; - } - - if (Object.prototype.toString.call(expected) == '[object RegExp]') { - return expected.test(actual); - } - - try { - if (actual instanceof expected) { - return true; - } - } catch (e) { - // Ignore. The instanceof check doesn't work for arrow functions. - } - - if (Error.isPrototypeOf(expected)) { - return false; - } - - return expected.call({}, actual) === true; - } - - function _tryBlock(block) { - var error; - try { - block(); - } catch (e) { - error = e; - } - return error; - } - - function _throws(shouldThrow, block, expected, message) { - var actual; - - if (typeof block !== 'function') { - throw new TypeError('"block" argument must be a function'); - } - - if (typeof expected === 'string') { - message = expected; - expected = null; - } - - actual = _tryBlock(block); - - message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + - (message ? ' ' + message : '.'); - - if (shouldThrow && !actual) { - fail(actual, expected, 'Missing expected exception' + message); - } - - var userProvidedMessage = typeof message === 'string'; - var isUnwantedException = !shouldThrow && util.isError(actual); - var isUnexpectedException = !shouldThrow && actual && !expected; - - if ((isUnwantedException && - userProvidedMessage && - expectedException(actual, expected)) || - isUnexpectedException) { - fail(actual, expected, 'Got unwanted exception' + message); - } - - if ((shouldThrow && actual && expected && - !expectedException(actual, expected)) || (!shouldThrow && actual)) { - throw actual; - } - } - - // 11. Expected to throw an error: - // assert.throws(block, Error_opt, message_opt); - - assert.throws = function(block, /*optional*/error, /*optional*/message) { - _throws(true, block, error, message); - }; - - // EXTENSION! This is annoying to write outside this module. - assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { - _throws(false, block, error, message); - }; - - assert.ifError = function(err) { if (err) throw err; }; - - var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) { - if (hasOwn.call(obj, key)) keys.push(key); - } - return keys; - }; - - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) - -/***/ }, -/* 85 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - var util = __webpack_require__(16) - , Validation = __webpack_require__(86).Validation - , ErrorCodes = __webpack_require__(60) - , BufferPool = __webpack_require__(88) - , bufferUtil = __webpack_require__(61).BufferUtil - , PerMessageDeflate = __webpack_require__(63); - - /** - * HyBi Receiver implementation - */ - - function Receiver (extensions,maxPayload) { - if (this instanceof Receiver === false) { - throw new TypeError("Classes can't be function-called"); - } - if(typeof extensions==='number'){ - maxPayload=extensions; - extensions={}; - } - - - // memory pool for fragmented messages - var fragmentedPoolPrevUsed = -1; - this.fragmentedBufferPool = new BufferPool(1024, function(db, length) { - return db.used + length; - }, function(db) { - return fragmentedPoolPrevUsed = fragmentedPoolPrevUsed >= 0 ? - Math.ceil((fragmentedPoolPrevUsed + db.used) / 2) : - db.used; - }); - - // memory pool for unfragmented messages - var unfragmentedPoolPrevUsed = -1; - this.unfragmentedBufferPool = new BufferPool(1024, function(db, length) { - return db.used + length; - }, function(db) { - return unfragmentedPoolPrevUsed = unfragmentedPoolPrevUsed >= 0 ? - Math.ceil((unfragmentedPoolPrevUsed + db.used) / 2) : - db.used; - }); - this.extensions = extensions || {}; - this.maxPayload = maxPayload || 0; - this.currentPayloadLength = 0; - this.state = { - activeFragmentedOperation: null, - lastFragment: false, - masked: false, - opcode: 0, - fragmentedOperation: false - }; - this.overflow = []; - this.headerBuffer = new Buffer(10); - this.expectOffset = 0; - this.expectBuffer = null; - this.expectHandler = null; - this.currentMessage = []; - this.currentMessageLength = 0; - this.messageHandlers = []; - this.expectHeader(2, this.processPacket); - this.dead = false; - this.processing = false; - - this.onerror = function() {}; - this.ontext = function() {}; - this.onbinary = function() {}; - this.onclose = function() {}; - this.onping = function() {}; - this.onpong = function() {}; - } - - module.exports = Receiver; - - /** - * Add new data to the parser. - * - * @api public - */ - - Receiver.prototype.add = function(data) { - if (this.dead) return; - var dataLength = data.length; - if (dataLength == 0) return; - if (this.expectBuffer == null) { - this.overflow.push(data); - return; - } - var toRead = Math.min(dataLength, this.expectBuffer.length - this.expectOffset); - fastCopy(toRead, data, this.expectBuffer, this.expectOffset); - this.expectOffset += toRead; - if (toRead < dataLength) { - this.overflow.push(data.slice(toRead)); - } - while (this.expectBuffer && this.expectOffset == this.expectBuffer.length) { - var bufferForHandler = this.expectBuffer; - this.expectBuffer = null; - this.expectOffset = 0; - this.expectHandler.call(this, bufferForHandler); - } - }; - - /** - * Releases all resources used by the receiver. - * - * @api public - */ - - Receiver.prototype.cleanup = function() { - this.dead = true; - this.overflow = null; - this.headerBuffer = null; - this.expectBuffer = null; - this.expectHandler = null; - this.unfragmentedBufferPool = null; - this.fragmentedBufferPool = null; - this.state = null; - this.currentMessage = null; - this.onerror = null; - this.ontext = null; - this.onbinary = null; - this.onclose = null; - this.onping = null; - this.onpong = null; - }; - - /** - * Waits for a certain amount of header bytes to be available, then fires a callback. - * - * @api private - */ - - Receiver.prototype.expectHeader = function(length, handler) { - if (length == 0) { - handler(null); - return; - } - this.expectBuffer = this.headerBuffer.slice(this.expectOffset, this.expectOffset + length); - this.expectHandler = handler; - var toRead = length; - while (toRead > 0 && this.overflow.length > 0) { - var fromOverflow = this.overflow.pop(); - if (toRead < fromOverflow.length) this.overflow.push(fromOverflow.slice(toRead)); - var read = Math.min(fromOverflow.length, toRead); - fastCopy(read, fromOverflow, this.expectBuffer, this.expectOffset); - this.expectOffset += read; - toRead -= read; - } - }; - - /** - * Waits for a certain amount of data bytes to be available, then fires a callback. - * - * @api private - */ - - Receiver.prototype.expectData = function(length, handler) { - if (length == 0) { - handler(null); - return; - } - this.expectBuffer = this.allocateFromPool(length, this.state.fragmentedOperation); - this.expectHandler = handler; - var toRead = length; - while (toRead > 0 && this.overflow.length > 0) { - var fromOverflow = this.overflow.pop(); - if (toRead < fromOverflow.length) this.overflow.push(fromOverflow.slice(toRead)); - var read = Math.min(fromOverflow.length, toRead); - fastCopy(read, fromOverflow, this.expectBuffer, this.expectOffset); - this.expectOffset += read; - toRead -= read; - } - }; - - /** - * Allocates memory from the buffer pool. - * - * @api private - */ - - Receiver.prototype.allocateFromPool = function(length, isFragmented) { - return (isFragmented ? this.fragmentedBufferPool : this.unfragmentedBufferPool).get(length); - }; - - /** - * Start processing a new packet. - * - * @api private - */ - - Receiver.prototype.processPacket = function (data) { - if (this.extensions[PerMessageDeflate.extensionName]) { - if ((data[0] & 0x30) != 0) { - this.error('reserved fields (2, 3) must be empty', 1002); - return; - } - } else { - if ((data[0] & 0x70) != 0) { - this.error('reserved fields must be empty', 1002); - return; - } - } - this.state.lastFragment = (data[0] & 0x80) == 0x80; - this.state.masked = (data[1] & 0x80) == 0x80; - var compressed = (data[0] & 0x40) == 0x40; - var opcode = data[0] & 0xf; - if (opcode === 0) { - if (compressed) { - this.error('continuation frame cannot have the Per-message Compressed bits', 1002); - return; - } - // continuation frame - this.state.fragmentedOperation = true; - this.state.opcode = this.state.activeFragmentedOperation; - if (!(this.state.opcode == 1 || this.state.opcode == 2)) { - this.error('continuation frame cannot follow current opcode', 1002); - return; - } - } - else { - if (opcode < 3 && this.state.activeFragmentedOperation != null) { - this.error('data frames after the initial data frame must have opcode 0', 1002); - return; - } - if (opcode >= 8 && compressed) { - this.error('control frames cannot have the Per-message Compressed bits', 1002); - return; - } - this.state.compressed = compressed; - this.state.opcode = opcode; - if (this.state.lastFragment === false) { - this.state.fragmentedOperation = true; - this.state.activeFragmentedOperation = opcode; - } - else this.state.fragmentedOperation = false; - } - var handler = opcodes[this.state.opcode]; - if (typeof handler == 'undefined') this.error('no handler for opcode ' + this.state.opcode, 1002); - else { - handler.start.call(this, data); - } - }; - - /** - * Endprocessing a packet. - * - * @api private - */ - - Receiver.prototype.endPacket = function() { - if (this.dead) return; - if (!this.state.fragmentedOperation) this.unfragmentedBufferPool.reset(true); - else if (this.state.lastFragment) this.fragmentedBufferPool.reset(true); - this.expectOffset = 0; - this.expectBuffer = null; - this.expectHandler = null; - if (this.state.lastFragment && this.state.opcode === this.state.activeFragmentedOperation) { - // end current fragmented operation - this.state.activeFragmentedOperation = null; - } - this.currentPayloadLength = 0; - this.state.lastFragment = false; - this.state.opcode = this.state.activeFragmentedOperation != null ? this.state.activeFragmentedOperation : 0; - this.state.masked = false; - this.expectHeader(2, this.processPacket); - }; - - /** - * Reset the parser state. - * - * @api private - */ - - Receiver.prototype.reset = function() { - if (this.dead) return; - this.state = { - activeFragmentedOperation: null, - lastFragment: false, - masked: false, - opcode: 0, - fragmentedOperation: false - }; - this.fragmentedBufferPool.reset(true); - this.unfragmentedBufferPool.reset(true); - this.expectOffset = 0; - this.expectBuffer = null; - this.expectHandler = null; - this.overflow = []; - this.currentMessage = []; - this.currentMessageLength = 0; - this.messageHandlers = []; - this.currentPayloadLength = 0; - }; - - /** - * Unmask received data. - * - * @api private - */ - - Receiver.prototype.unmask = function (mask, buf, binary) { - if (mask != null && buf != null) bufferUtil.unmask(buf, mask); - if (binary) return buf; - return buf != null ? buf.toString('utf8') : ''; - }; - - /** - * Handles an error - * - * @api private - */ - - Receiver.prototype.error = function (reason, protocolErrorCode) { - if (this.dead) return; - this.reset(); - if(typeof reason == 'string'){ - this.onerror(new Error(reason), protocolErrorCode); - } - else if(reason.constructor == Error){ - this.onerror(reason, protocolErrorCode); - } - else{ - this.onerror(new Error("An error occured"),protocolErrorCode); - } - return this; - }; - - /** - * Execute message handler buffers - * - * @api private - */ - - Receiver.prototype.flush = function() { - if (this.processing || this.dead) return; - - var handler = this.messageHandlers.shift(); - if (!handler) return; - - this.processing = true; - var self = this; - - handler(function() { - self.processing = false; - self.flush(); - }); - }; - - /** - * Apply extensions to message - * - * @api private - */ - - Receiver.prototype.applyExtensions = function(messageBuffer, fin, compressed, callback) { - var self = this; - if (compressed) { - this.extensions[PerMessageDeflate.extensionName].decompress(messageBuffer, fin, function(err, buffer) { - if (self.dead) return; - if (err) { - callback(new Error('invalid compressed data')); - return; - } - callback(null, buffer); - }); - } else { - callback(null, messageBuffer); - } - }; - - /** - * Checks payload size, disconnects socket when it exceeds maxPayload - * - * @api private - */ - Receiver.prototype.maxPayloadExceeded = function(length) { - if (this.maxPayload=== undefined || this.maxPayload === null || this.maxPayload < 1) { - return false; - } - var fullLength = this.currentPayloadLength + length; - if (fullLength < this.maxPayload) { - this.currentPayloadLength = fullLength; - return false; - } - this.error('payload cannot exceed ' + this.maxPayload + ' bytes', 1009); - this.messageBuffer=[]; - this.cleanup(); - - return true; - }; - - /** - * Buffer utilities - */ - - function readUInt16BE(start) { - return (this[start]<<8) + - this[start+1]; - } - - function readUInt32BE(start) { - return (this[start]<<24) + - (this[start+1]<<16) + - (this[start+2]<<8) + - this[start+3]; - } - - function fastCopy(length, srcBuffer, dstBuffer, dstOffset) { - switch (length) { - default: srcBuffer.copy(dstBuffer, dstOffset, 0, length); break; - case 16: dstBuffer[dstOffset+15] = srcBuffer[15]; - case 15: dstBuffer[dstOffset+14] = srcBuffer[14]; - case 14: dstBuffer[dstOffset+13] = srcBuffer[13]; - case 13: dstBuffer[dstOffset+12] = srcBuffer[12]; - case 12: dstBuffer[dstOffset+11] = srcBuffer[11]; - case 11: dstBuffer[dstOffset+10] = srcBuffer[10]; - case 10: dstBuffer[dstOffset+9] = srcBuffer[9]; - case 9: dstBuffer[dstOffset+8] = srcBuffer[8]; - case 8: dstBuffer[dstOffset+7] = srcBuffer[7]; - case 7: dstBuffer[dstOffset+6] = srcBuffer[6]; - case 6: dstBuffer[dstOffset+5] = srcBuffer[5]; - case 5: dstBuffer[dstOffset+4] = srcBuffer[4]; - case 4: dstBuffer[dstOffset+3] = srcBuffer[3]; - case 3: dstBuffer[dstOffset+2] = srcBuffer[2]; - case 2: dstBuffer[dstOffset+1] = srcBuffer[1]; - case 1: dstBuffer[dstOffset] = srcBuffer[0]; - } - } - - function clone(obj) { - var cloned = {}; - for (var k in obj) { - if (obj.hasOwnProperty(k)) { - cloned[k] = obj[k]; - } - } - return cloned; - } - - /** - * Opcode handlers - */ - - var opcodes = { - // text - '1': { - start: function(data) { - var self = this; - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - if (self.maxPayloadExceeded(firstLength)){ - self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['1'].getData.call(self, firstLength); - } - else if (firstLength == 126) { - self.expectHeader(2, function(data) { - var length = readUInt16BE.call(data, 0); - if (self.maxPayloadExceeded(length)){ - self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['1'].getData.call(self, length); - }); - } - else if (firstLength == 127) { - self.expectHeader(8, function(data) { - if (readUInt32BE.call(data, 0) != 0) { - self.error('packets with length spanning more than 32 bit is currently not supported', 1008); - return; - } - var length = readUInt32BE.call(data, 4); - if (self.maxPayloadExceeded(length)){ - self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['1'].getData.call(self, readUInt32BE.call(data, 4)); - }); - } - }, - getData: function(length) { - var self = this; - if (self.state.masked) { - self.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['1'].finish.call(self, mask, data); - }); - }); - } - else { - self.expectData(length, function(data) { - opcodes['1'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - var packet = this.unmask(mask, data, true) || new Buffer(0); - var state = clone(this.state); - this.messageHandlers.push(function(callback) { - self.applyExtensions(packet, state.lastFragment, state.compressed, function(err, buffer) { - if (err) { - if(err.type===1009){ - return self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); - } - return self.error(err.message, 1007); - } - if (buffer != null) { - if( self.maxPayload==0 || (self.maxPayload > 0 && (self.currentMessageLength + buffer.length) < self.maxPayload) ){ - self.currentMessage.push(buffer); - } - else{ - self.currentMessage=null; - self.currentMessage = []; - self.currentMessageLength = 0; - self.error(new Error('Maximum payload exceeded. maxPayload: '+self.maxPayload), 1009); - return; - } - self.currentMessageLength += buffer.length; - } - if (state.lastFragment) { - var messageBuffer = Buffer.concat(self.currentMessage); - self.currentMessage = []; - self.currentMessageLength = 0; - if (!Validation.isValidUTF8(messageBuffer)) { - self.error('invalid utf8 sequence', 1007); - return; - } - self.ontext(messageBuffer.toString('utf8'), {masked: state.masked, buffer: messageBuffer}); - } - callback(); - }); - }); - this.flush(); - this.endPacket(); - } - }, - // binary - '2': { - start: function(data) { - var self = this; - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - if (self.maxPayloadExceeded(firstLength)){ - self.error('Max payload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['2'].getData.call(self, firstLength); - } - else if (firstLength == 126) { - self.expectHeader(2, function(data) { - var length = readUInt16BE.call(data, 0); - if (self.maxPayloadExceeded(length)){ - self.error('Max payload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['2'].getData.call(self, length); - }); - } - else if (firstLength == 127) { - self.expectHeader(8, function(data) { - if (readUInt32BE.call(data, 0) != 0) { - self.error('packets with length spanning more than 32 bit is currently not supported', 1008); - return; - } - var length = readUInt32BE.call(data, 4, true); - if (self.maxPayloadExceeded(length)){ - self.error('Max payload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['2'].getData.call(self, length); - }); - } - }, - getData: function(length) { - var self = this; - if (self.state.masked) { - self.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['2'].finish.call(self, mask, data); - }); - }); - } - else { - self.expectData(length, function(data) { - opcodes['2'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - var packet = this.unmask(mask, data, true) || new Buffer(0); - var state = clone(this.state); - this.messageHandlers.push(function(callback) { - self.applyExtensions(packet, state.lastFragment, state.compressed, function(err, buffer) { - if (err) { - if(err.type===1009){ - return self.error('Max payload exceeded in compressed binary message. Aborting...', 1009); - } - return self.error(err.message, 1007); - } - if (buffer != null) { - if( self.maxPayload==0 || (self.maxPayload > 0 && (self.currentMessageLength + buffer.length) < self.maxPayload) ){ - self.currentMessage.push(buffer); - } - else{ - self.currentMessage=null; - self.currentMessage = []; - self.currentMessageLength = 0; - self.error(new Error('Maximum payload exceeded'), 1009); - return; - } - self.currentMessageLength += buffer.length; - } - if (state.lastFragment) { - var messageBuffer = Buffer.concat(self.currentMessage); - self.currentMessage = []; - self.currentMessageLength = 0; - self.onbinary(messageBuffer, {masked: state.masked, buffer: messageBuffer}); - } - callback(); - }); - }); - this.flush(); - this.endPacket(); - } - }, - // close - '8': { - start: function(data) { - var self = this; - if (self.state.lastFragment == false) { - self.error('fragmented close is not supported', 1002); - return; - } - - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - opcodes['8'].getData.call(self, firstLength); - } - else { - self.error('control frames cannot have more than 125 bytes of data', 1002); - } - }, - getData: function(length) { - var self = this; - if (self.state.masked) { - self.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['8'].finish.call(self, mask, data); - }); - }); - } - else { - self.expectData(length, function(data) { - opcodes['8'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - data = self.unmask(mask, data, true); - - var state = clone(this.state); - this.messageHandlers.push(function() { - if (data && data.length == 1) { - self.error('close packets with data must be at least two bytes long', 1002); - return; - } - var code = data && data.length > 1 ? readUInt16BE.call(data, 0) : 1000; - if (!ErrorCodes.isValidErrorCode(code)) { - self.error('invalid error code', 1002); - return; - } - var message = ''; - if (data && data.length > 2) { - var messageBuffer = data.slice(2); - if (!Validation.isValidUTF8(messageBuffer)) { - self.error('invalid utf8 sequence', 1007); - return; - } - message = messageBuffer.toString('utf8'); - } - self.onclose(code, message, {masked: state.masked}); - self.reset(); - }); - this.flush(); - }, - }, - // ping - '9': { - start: function(data) { - var self = this; - if (self.state.lastFragment == false) { - self.error('fragmented ping is not supported', 1002); - return; - } - - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - opcodes['9'].getData.call(self, firstLength); - } - else { - self.error('control frames cannot have more than 125 bytes of data', 1002); - } - }, - getData: function(length) { - var self = this; - if (self.state.masked) { - self.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['9'].finish.call(self, mask, data); - }); - }); - } - else { - self.expectData(length, function(data) { - opcodes['9'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - data = this.unmask(mask, data, true); - var state = clone(this.state); - this.messageHandlers.push(function(callback) { - self.onping(data, {masked: state.masked, binary: true}); - callback(); - }); - this.flush(); - this.endPacket(); - } - }, - // pong - '10': { - start: function(data) { - var self = this; - if (self.state.lastFragment == false) { - self.error('fragmented pong is not supported', 1002); - return; - } - - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - opcodes['10'].getData.call(self, firstLength); - } - else { - self.error('control frames cannot have more than 125 bytes of data', 1002); - } - }, - getData: function(length) { - var self = this; - if (this.state.masked) { - this.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['10'].finish.call(self, mask, data); - }); - }); - } - else { - this.expectData(length, function(data) { - opcodes['10'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - data = self.unmask(mask, data, true); - var state = clone(this.state); - this.messageHandlers.push(function(callback) { - self.onpong(data, {masked: state.masked, binary: true}); - callback(); - }); - this.flush(); - this.endPacket(); - } - } - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 86 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - /*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - try { - module.exports = __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"utf-8-validate\""); e.code = 'MODULE_NOT_FOUND'; throw e; }())); - } catch (e) { - module.exports = __webpack_require__(87); - } - - -/***/ }, -/* 87 */ -/***/ function(module, exports) { - - /*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - exports.Validation = { - isValidUTF8: function(buffer) { - return true; - } - }; - - -/***/ }, -/* 88 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - var util = __webpack_require__(16); - - function BufferPool(initialSize, growStrategy, shrinkStrategy) { - if (this instanceof BufferPool === false) { - throw new TypeError("Classes can't be function-called"); - } - - if (typeof initialSize === 'function') { - shrinkStrategy = growStrategy; - growStrategy = initialSize; - initialSize = 0; - } - else if (typeof initialSize === 'undefined') { - initialSize = 0; - } - this._growStrategy = (growStrategy || function(db, size) { - return db.used + size; - }).bind(null, this); - this._shrinkStrategy = (shrinkStrategy || function(db) { - return initialSize; - }).bind(null, this); - this._buffer = initialSize ? new Buffer(initialSize) : null; - this._offset = 0; - this._used = 0; - this._changeFactor = 0; - this.__defineGetter__('size', function(){ - return this._buffer == null ? 0 : this._buffer.length; - }); - this.__defineGetter__('used', function(){ - return this._used; - }); - } - - BufferPool.prototype.get = function(length) { - if (this._buffer == null || this._offset + length > this._buffer.length) { - var newBuf = new Buffer(this._growStrategy(length)); - this._buffer = newBuf; - this._offset = 0; - } - this._used += length; - var buf = this._buffer.slice(this._offset, this._offset + length); - this._offset += length; - return buf; - } - - BufferPool.prototype.reset = function(forceNewBuffer) { - var len = this._shrinkStrategy(); - if (len < this.size) this._changeFactor -= 1; - if (forceNewBuffer || this._changeFactor < -2) { - this._changeFactor = 0; - this._buffer = len ? new Buffer(len) : null; - } - this._offset = 0; - this._used = 0; - } - - module.exports = BufferPool; - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 89 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - var events = __webpack_require__(20) - , util = __webpack_require__(16) - , EventEmitter = events.EventEmitter; - - /** - * Hixie Sender implementation - */ - - function Sender(socket) { - if (this instanceof Sender === false) { - throw new TypeError("Classes can't be function-called"); - } - - events.EventEmitter.call(this); - - this.socket = socket; - this.continuationFrame = false; - this.isClosed = false; - } - - module.exports = Sender; - - /** - * Inherits from EventEmitter. - */ - - util.inherits(Sender, events.EventEmitter); - - /** - * Frames and writes data. - * - * @api public - */ - - Sender.prototype.send = function(data, options, cb) { - if (this.isClosed) return; - - var isString = typeof data == 'string' - , length = isString ? Buffer.byteLength(data) : data.length - , lengthbytes = (length > 127) ? 2 : 1 // assume less than 2**14 bytes - , writeStartMarker = this.continuationFrame == false - , writeEndMarker = !options || !(typeof options.fin != 'undefined' && !options.fin) - , buffer = new Buffer((writeStartMarker ? ((options && options.binary) ? (1 + lengthbytes) : 1) : 0) + length + ((writeEndMarker && !(options && options.binary)) ? 1 : 0)) - , offset = writeStartMarker ? 1 : 0; - - if (writeStartMarker) { - if (options && options.binary) { - buffer.write('\x80', 'binary'); - // assume length less than 2**14 bytes - if (lengthbytes > 1) - buffer.write(String.fromCharCode(128+length/128), offset++, 'binary'); - buffer.write(String.fromCharCode(length&0x7f), offset++, 'binary'); - } else - buffer.write('\x00', 'binary'); - } - - if (isString) buffer.write(data, offset, 'utf8'); - else data.copy(buffer, offset, 0); - - if (writeEndMarker) { - if (options && options.binary) { - // sending binary, not writing end marker - } else - buffer.write('\xff', offset + length, 'binary'); - this.continuationFrame = false; - } - else this.continuationFrame = true; - - try { - this.socket.write(buffer, 'binary', cb); - } catch (e) { - this.error(e.toString()); - } - }; - - /** - * Sends a close instruction to the remote party. - * - * @api public - */ - - Sender.prototype.close = function(code, data, mask, cb) { - if (this.isClosed) return; - this.isClosed = true; - try { - if (this.continuationFrame) this.socket.write(new Buffer([0xff], 'binary')); - this.socket.write(new Buffer([0xff, 0x00]), 'binary', cb); - } catch (e) { - this.error(e.toString()); - } - }; - - /** - * Sends a ping message to the remote party. Not available for hixie. - * - * @api public - */ - - Sender.prototype.ping = function(data, options) {}; - - /** - * Sends a pong message to the remote party. Not available for hixie. - * - * @api public - */ - - Sender.prototype.pong = function(data, options) {}; - - /** - * Handles an error - * - * @api private - */ - - Sender.prototype.error = function (reason) { - this.emit('error', reason); - return this; - }; - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 90 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - var util = __webpack_require__(16); - - /** - * State constants - */ - - var EMPTY = 0 - , BODY = 1; - var BINARYLENGTH = 2 - , BINARYBODY = 3; - - /** - * Hixie Receiver implementation - */ - - function Receiver () { - if (this instanceof Receiver === false) { - throw new TypeError("Classes can't be function-called"); - } - - this.state = EMPTY; - this.buffers = []; - this.messageEnd = -1; - this.spanLength = 0; - this.dead = false; - - this.onerror = function() {}; - this.ontext = function() {}; - this.onbinary = function() {}; - this.onclose = function() {}; - this.onping = function() {}; - this.onpong = function() {}; - } - - module.exports = Receiver; - - /** - * Add new data to the parser. - * - * @api public - */ - - Receiver.prototype.add = function(data) { - if (this.dead) return; - var self = this; - function doAdd() { - if (self.state === EMPTY) { - if (data.length == 2 && data[0] == 0xFF && data[1] == 0x00) { - self.reset(); - self.onclose(); - return; - } - if (data[0] === 0x80) { - self.messageEnd = 0; - self.state = BINARYLENGTH; - data = data.slice(1); - } else { - - if (data[0] !== 0x00) { - self.error('payload must start with 0x00 byte', true); - return; - } - data = data.slice(1); - self.state = BODY; - - } - } - if (self.state === BINARYLENGTH) { - var i = 0; - while ((i < data.length) && (data[i] & 0x80)) { - self.messageEnd = 128 * self.messageEnd + (data[i] & 0x7f); - ++i; - } - if (i < data.length) { - self.messageEnd = 128 * self.messageEnd + (data[i] & 0x7f); - self.state = BINARYBODY; - ++i; - } - if (i > 0) - data = data.slice(i); - } - if (self.state === BINARYBODY) { - var dataleft = self.messageEnd - self.spanLength; - if (data.length >= dataleft) { - // consume the whole buffer to finish the frame - self.buffers.push(data); - self.spanLength += dataleft; - self.messageEnd = dataleft; - return self.parse(); - } - // frame's not done even if we consume it all - self.buffers.push(data); - self.spanLength += data.length; - return; - } - self.buffers.push(data); - if ((self.messageEnd = bufferIndex(data, 0xFF)) != -1) { - self.spanLength += self.messageEnd; - return self.parse(); - } - else self.spanLength += data.length; - } - while(data) data = doAdd(); - }; - - /** - * Releases all resources used by the receiver. - * - * @api public - */ - - Receiver.prototype.cleanup = function() { - this.dead = true; - this.state = EMPTY; - this.buffers = []; - }; - - /** - * Process buffered data. - * - * @api public - */ - - Receiver.prototype.parse = function() { - var output = new Buffer(this.spanLength); - var outputIndex = 0; - for (var bi = 0, bl = this.buffers.length; bi < bl - 1; ++bi) { - var buffer = this.buffers[bi]; - buffer.copy(output, outputIndex); - outputIndex += buffer.length; - } - var lastBuffer = this.buffers[this.buffers.length - 1]; - if (this.messageEnd > 0) lastBuffer.copy(output, outputIndex, 0, this.messageEnd); - if (this.state !== BODY) --this.messageEnd; - var tail = null; - if (this.messageEnd < lastBuffer.length - 1) { - tail = lastBuffer.slice(this.messageEnd + 1); - } - this.reset(); - this.ontext(output.toString('utf8')); - return tail; - }; - - /** - * Handles an error - * - * @api private - */ - - Receiver.prototype.error = function (reason, terminate) { - if (this.dead) return; - this.reset(); - if(typeof reason == 'string'){ - this.onerror(new Error(reason), terminate); - } - else if(reason.constructor == Error){ - this.onerror(reason, terminate); - } - else{ - this.onerror(new Error("An error occured"),terminate); - } - return this; - }; - - /** - * Reset parser state - * - * @api private - */ - - Receiver.prototype.reset = function (reason) { - if (this.dead) return; - this.state = EMPTY; - this.buffers = []; - this.messageEnd = -1; - this.spanLength = 0; - }; - - /** - * Internal api - */ - - function bufferIndex(buffer, byte) { - for (var i = 0, l = buffer.length; i < l; ++i) { - if (buffer[i] === byte) return i; - } - return -1; - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) - -/***/ }, -/* 91 */ -/***/ function(module, exports, __webpack_require__) { - - - var util = __webpack_require__(16); - - /** - * Module exports. - */ - - exports.parse = parse; - exports.format = format; - - /** - * Parse extensions header value - */ - - function parse(value) { - value = value || ''; - - var extensions = {}; - - value.split(',').forEach(function(v) { - var params = v.split(';'); - var token = params.shift().trim(); - var paramsList = extensions[token] = extensions[token] || []; - var parsedParams = {}; - - params.forEach(function(param) { - var parts = param.trim().split('='); - var key = parts[0]; - var value = parts[1]; - if (typeof value === 'undefined') { - value = true; - } else { - // unquote value - if (value[0] === '"') { - value = value.slice(1); - } - if (value[value.length - 1] === '"') { - value = value.slice(0, value.length - 1); - } - } - (parsedParams[key] = parsedParams[key] || []).push(value); - }); - - paramsList.push(parsedParams); - }); - - return extensions; - } - - /** - * Format extensions header value - */ - - function format(value) { - return Object.keys(value).map(function(token) { - var paramsList = value[token]; - if (!util.isArray(paramsList)) { - paramsList = [paramsList]; - } - return paramsList.map(function(params) { - return [token].concat(Object.keys(params).map(function(k) { - var p = params[k]; - if (!util.isArray(p)) p = [p]; - return p.map(function(v) { - return v === true ? k : k + '=' + v; - }).join('; '); - })).join('; '); - }).join(', '); - }).join(', '); - } - - -/***/ }, -/* 92 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - - var util = __webpack_require__(16) - , events = __webpack_require__(20) - , http = __webpack_require__(19) - , crypto = __webpack_require__(41) - , Options = __webpack_require__(57) - , WebSocket = __webpack_require__(4) - , Extensions = __webpack_require__(91) - , PerMessageDeflate = __webpack_require__(63) - , tls = __webpack_require__(58) - , url = __webpack_require__(10); - - /** - * WebSocket Server implementation - */ - - function WebSocketServer(options, callback) { - if (this instanceof WebSocketServer === false) { - return new WebSocketServer(options, callback); - } - - events.EventEmitter.call(this); - - options = new Options({ - host: '0.0.0.0', - port: null, - server: null, - verifyClient: null, - handleProtocols: null, - path: null, - noServer: false, - disableHixie: false, - clientTracking: true, - perMessageDeflate: true, - maxPayload: 100 * 1024 * 1024 - }).merge(options); - - if (!options.isDefinedAndNonNull('port') && !options.isDefinedAndNonNull('server') && !options.value.noServer) { - throw new TypeError('`port` or a `server` must be provided'); - } - - var self = this; - - if (options.isDefinedAndNonNull('port')) { - this._server = http.createServer(function (req, res) { - var body = http.STATUS_CODES[426]; - res.writeHead(426, { - 'Content-Length': body.length, - 'Content-Type': 'text/plain' - }); - res.end(body); - }); - this._server.allowHalfOpen = false; - this._server.listen(options.value.port, options.value.host, callback); - this._closeServer = function() { if (self._server) self._server.close(); }; - } - else if (options.value.server) { - this._server = options.value.server; - if (options.value.path) { - // take note of the path, to avoid collisions when multiple websocket servers are - // listening on the same http server - if (this._server._webSocketPaths && options.value.server._webSocketPaths[options.value.path]) { - throw new Error('two instances of WebSocketServer cannot listen on the same http server path'); - } - if (typeof this._server._webSocketPaths !== 'object') { - this._server._webSocketPaths = {}; - } - this._server._webSocketPaths[options.value.path] = 1; - } - } - if (this._server) { - this._onceServerListening = function() { self.emit('listening'); }; - this._server.once('listening', this._onceServerListening); - } - - if (typeof this._server != 'undefined') { - this._onServerError = function(error) { self.emit('error', error) }; - this._server.on('error', this._onServerError); - this._onServerUpgrade = function(req, socket, upgradeHead) { - //copy upgradeHead to avoid retention of large slab buffers used in node core - var head = new Buffer(upgradeHead.length); - upgradeHead.copy(head); - - self.handleUpgrade(req, socket, head, function(client) { - self.emit('connection'+req.url, client); - self.emit('connection', client); - }); - }; - this._server.on('upgrade', this._onServerUpgrade); - } - - this.options = options.value; - this.path = options.value.path; - this.clients = []; - } - - /** - * Inherits from EventEmitter. - */ - - util.inherits(WebSocketServer, events.EventEmitter); - - /** - * Immediately shuts down the connection. - * - * @api public - */ - - WebSocketServer.prototype.close = function(callback) { - // terminate all associated clients - var error = null; - try { - for (var i = 0, l = this.clients.length; i < l; ++i) { - this.clients[i].terminate(); - } - } - catch (e) { - error = e; - } - - // remove path descriptor, if any - if (this.path && this._server._webSocketPaths) { - delete this._server._webSocketPaths[this.path]; - if (Object.keys(this._server._webSocketPaths).length == 0) { - delete this._server._webSocketPaths; - } - } - - // close the http server if it was internally created - try { - if (typeof this._closeServer !== 'undefined') { - this._closeServer(); - } - } - finally { - if (this._server) { - this._server.removeListener('listening', this._onceServerListening); - this._server.removeListener('error', this._onServerError); - this._server.removeListener('upgrade', this._onServerUpgrade); - } - delete this._server; - } - if(callback) - callback(error); - else if(error) - throw error; - } - - /** - * Handle a HTTP Upgrade request. - * - * @api public - */ - - WebSocketServer.prototype.handleUpgrade = function(req, socket, upgradeHead, cb) { - // check for wrong path - if (this.options.path) { - var u = url.parse(req.url); - if (u && u.pathname !== this.options.path) return; + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } } - if (typeof req.headers.upgrade === 'undefined' || req.headers.upgrade.toLowerCase() !== 'websocket') { - abortConnection(socket, 400, 'Bad Request'); - return; - } + return this; + }; - if (req.headers['sec-websocket-key1']) handleHixieUpgrade.apply(this, arguments); - else handleHybiUpgrade.apply(this, arguments); - } + EventEmitter.prototype.on = EventEmitter.prototype.addListener; - module.exports = WebSocketServer; + EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - /** - * Entirely private apis, - * which may or may not be bound to a sepcific WebSocket instance. - */ + var fired = false; - function handleHybiUpgrade(req, socket, upgradeHead, cb) { - // handle premature socket errors - var errorHandler = function() { - try { socket.destroy(); } catch (e) {} - } - socket.on('error', errorHandler); + function g() { + this.removeListener(type, g); - // verify key presence - if (!req.headers['sec-websocket-key']) { - abortConnection(socket, 400, 'Bad Request'); - return; + if (!fired) { + fired = true; + listener.apply(this, arguments); + } } - // verify version - var version = parseInt(req.headers['sec-websocket-version']); - if ([8, 13].indexOf(version) === -1) { - abortConnection(socket, 400, 'Bad Request'); - return; - } + g.listener = listener; + this.on(type, g); - // verify protocol - var protocols = req.headers['sec-websocket-protocol']; + return this; + }; - // verify client - var origin = version < 13 ? - req.headers['sec-websocket-origin'] : - req.headers['origin']; + // emits a 'removeListener' event iff the listener was removed + EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; - // handle extensions offer - var extensionsOffer = Extensions.parse(req.headers['sec-websocket-extensions']); + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - // handler to call when the connection sequence completes - var self = this; - var completeHybiUpgrade2 = function(protocol) { + if (!this._events || !this._events[type]) + return this; - // calc key - var key = req.headers['sec-websocket-key']; - var shasum = crypto.createHash('sha1'); - shasum.update(key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"); - key = shasum.digest('base64'); + list = this._events[type]; + length = list.length; + position = -1; - var headers = [ - 'HTTP/1.1 101 Switching Protocols' - , 'Upgrade: websocket' - , 'Connection: Upgrade' - , 'Sec-WebSocket-Accept: ' + key - ]; + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); - if (typeof protocol != 'undefined') { - headers.push('Sec-WebSocket-Protocol: ' + protocol); + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } } - var extensions = {}; - try { - extensions = acceptExtensions.call(self, extensionsOffer); - } catch (err) { - abortConnection(socket, 400, 'Bad Request'); - return; - } + if (position < 0) + return this; - if (Object.keys(extensions).length) { - var serverExtensions = {}; - Object.keys(extensions).forEach(function(token) { - serverExtensions[token] = [extensions[token].params] - }); - headers.push('Sec-WebSocket-Extensions: ' + Extensions.format(serverExtensions)); + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); } - // allows external modification/inspection of handshake headers - self.emit('headers', headers); + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } - socket.setTimeout(0); - socket.setNoDelay(true); - try { - socket.write(headers.concat('', '').join('\r\n')); - } - catch (e) { - // if the upgrade write fails, shut the connection down hard - try { socket.destroy(); } catch (e) {} - return; - } + return this; + }; - var client = new WebSocket([req, socket, upgradeHead], { - protocolVersion: version, - protocol: protocol, - extensions: extensions, - maxPayload: self.options.maxPayload - }); + EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; - if (self.options.clientTracking) { - self.clients.push(client); - client.on('close', function() { - var index = self.clients.indexOf(client); - if (index != -1) { - self.clients.splice(index, 1); - } - }); - } + if (!this._events) + return this; - // signal upgrade complete - socket.removeListener('error', errorHandler); - cb(client); + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; } - // optionally call external protocol selection handler before - // calling completeHybiUpgrade2 - var completeHybiUpgrade1 = function() { - // choose from the sub-protocols - if (typeof self.options.handleProtocols == 'function') { - var protList = (protocols || "").split(/, */); - var callbackCalled = false; - var res = self.options.handleProtocols(protList, function(result, protocol) { - callbackCalled = true; - if (!result) abortConnection(socket, 401, 'Unauthorized'); - else completeHybiUpgrade2(protocol); - }); - if (!callbackCalled) { - // the handleProtocols handler never called our callback - abortConnection(socket, 501, 'Could not process protocols'); - } - return; - } else { - if (typeof protocols !== 'undefined') { - completeHybiUpgrade2(protocols.split(/, */)[0]); - } - else { - completeHybiUpgrade2(); - } + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; } - // optionally call external client verification handler - if (typeof this.options.verifyClient == 'function') { - var info = { - origin: origin, - secure: typeof req.connection.authorized !== 'undefined' || typeof req.connection.encrypted !== 'undefined', - req: req - }; - if (this.options.verifyClient.length == 2) { - this.options.verifyClient(info, function(result, code, name) { - if (typeof code === 'undefined') code = 401; - if (typeof name === 'undefined') name = http.STATUS_CODES[code]; + listeners = this._events[type]; - if (!result) abortConnection(socket, code, name); - else completeHybiUpgrade1(); - }); - return; - } - else if (!this.options.verifyClient(info)) { - abortConnection(socket, 401, 'Unauthorized'); - return; - } + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); } + delete this._events[type]; - completeHybiUpgrade1(); - } + return this; + }; - function handleHixieUpgrade(req, socket, upgradeHead, cb) { - // handle premature socket errors - var errorHandler = function() { - try { socket.destroy(); } catch (e) {} - } - socket.on('error', errorHandler); + EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; + }; - // bail if options prevent hixie - if (this.options.disableHixie) { - abortConnection(socket, 401, 'Hixie support disabled'); - return; - } + EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; - // verify key presence - if (!req.headers['sec-websocket-key2']) { - abortConnection(socket, 400, 'Bad Request'); - return; + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; } + return 0; + }; - var origin = req.headers['origin'] - , self = this; - - // setup handshake completion to run after client has been verified - var onClientVerified = function() { - var wshost; - if (!req.headers['x-forwarded-host']) - wshost = req.headers.host; - else - wshost = req.headers['x-forwarded-host']; - var location = ((req.headers['x-forwarded-proto'] === 'https' || socket.encrypted) ? 'wss' : 'ws') + '://' + wshost + req.url - , protocol = req.headers['sec-websocket-protocol']; - - // build the response header and return a Buffer - var buildResponseHeader = function() { - var headers = [ - 'HTTP/1.1 101 Switching Protocols' - , 'Upgrade: WebSocket' - , 'Connection: Upgrade' - , 'Sec-WebSocket-Location: ' + location - ]; - if (typeof protocol != 'undefined') headers.push('Sec-WebSocket-Protocol: ' + protocol); - if (typeof origin != 'undefined') headers.push('Sec-WebSocket-Origin: ' + origin); - - return new Buffer(headers.concat('', '').join('\r\n')); - }; - - // send handshake response before receiving the nonce - var handshakeResponse = function() { - - socket.setTimeout(0); - socket.setNoDelay(true); - - var headerBuffer = buildResponseHeader(); - - try { - socket.write(headerBuffer, 'binary', function(err) { - // remove listener if there was an error - if (err) socket.removeListener('data', handler); - return; - }); - } catch (e) { - try { socket.destroy(); } catch (e) {} - return; - }; - }; - - // handshake completion code to run once nonce has been successfully retrieved - var completeHandshake = function(nonce, rest, headerBuffer) { - // calculate key - var k1 = req.headers['sec-websocket-key1'] - , k2 = req.headers['sec-websocket-key2'] - , md5 = crypto.createHash('md5'); - - [k1, k2].forEach(function (k) { - var n = parseInt(k.replace(/[^\d]/g, '')) - , spaces = k.replace(/[^ ]/g, '').length; - if (spaces === 0 || n % spaces !== 0){ - abortConnection(socket, 400, 'Bad Request'); - return; - } - n /= spaces; - md5.update(String.fromCharCode( - n >> 24 & 0xFF, - n >> 16 & 0xFF, - n >> 8 & 0xFF, - n & 0xFF)); - }); - md5.update(nonce.toString('binary')); - - socket.setTimeout(0); - socket.setNoDelay(true); - - try { - var hashBuffer = new Buffer(md5.digest('binary'), 'binary'); - var handshakeBuffer = new Buffer(headerBuffer.length + hashBuffer.length); - headerBuffer.copy(handshakeBuffer, 0); - hashBuffer.copy(handshakeBuffer, headerBuffer.length); - - // do a single write, which - upon success - causes a new client websocket to be setup - socket.write(handshakeBuffer, 'binary', function(err) { - if (err) return; // do not create client if an error happens - var client = new WebSocket([req, socket, rest], { - protocolVersion: 'hixie-76', - protocol: protocol - }); - if (self.options.clientTracking) { - self.clients.push(client); - client.on('close', function() { - var index = self.clients.indexOf(client); - if (index != -1) { - self.clients.splice(index, 1); - } - }); - } - - // signal upgrade complete - socket.removeListener('error', errorHandler); - cb(client); - }); - } - catch (e) { - try { socket.destroy(); } catch (e) {} - return; - } - } - - // retrieve nonce - var nonceLength = 8; - if (upgradeHead && upgradeHead.length >= nonceLength) { - var nonce = upgradeHead.slice(0, nonceLength); - var rest = upgradeHead.length > nonceLength ? upgradeHead.slice(nonceLength) : null; - completeHandshake.call(self, nonce, rest, buildResponseHeader()); - } - else { - // nonce not present in upgradeHead - var nonce = new Buffer(nonceLength); - upgradeHead.copy(nonce, 0); - var received = upgradeHead.length; - var rest = null; - var handler = function (data) { - var toRead = Math.min(data.length, nonceLength - received); - if (toRead === 0) return; - data.copy(nonce, received, 0, toRead); - received += toRead; - if (received == nonceLength) { - socket.removeListener('data', handler); - if (toRead < data.length) rest = data.slice(toRead); - - // complete the handshake but send empty buffer for headers since they have already been sent - completeHandshake.call(self, nonce, rest, new Buffer(0)); - } - } - - // handle additional data as we receive it - socket.on('data', handler); - - // send header response before we have the nonce to fix haproxy buffering - handshakeResponse(); - } - } + EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); + }; - // verify client - if (typeof this.options.verifyClient == 'function') { - var info = { - origin: origin, - secure: typeof req.connection.authorized !== 'undefined' || typeof req.connection.encrypted !== 'undefined', - req: req - }; - if (this.options.verifyClient.length == 2) { - var self = this; - this.options.verifyClient(info, function(result, code, name) { - if (typeof code === 'undefined') code = 401; - if (typeof name === 'undefined') name = http.STATUS_CODES[code]; - - if (!result) abortConnection(socket, code, name); - else onClientVerified.apply(self); - }); - return; - } - else if (!this.options.verifyClient(info)) { - abortConnection(socket, 401, 'Unauthorized'); - return; - } - } + function isFunction(arg) { + return typeof arg === 'function'; + } - // no client verification required - onClientVerified(); + function isNumber(arg) { + return typeof arg === 'number'; } - function acceptExtensions(offer) { - var extensions = {}; - var options = this.options.perMessageDeflate; - var maxPayload = this.options.maxPayload; - if (options && offer[PerMessageDeflate.extensionName]) { - var perMessageDeflate = new PerMessageDeflate(options !== true ? options : {}, true, maxPayload); - perMessageDeflate.accept(offer[PerMessageDeflate.extensionName]); - extensions[PerMessageDeflate.extensionName] = perMessageDeflate; - } - return extensions; + function isObject(arg) { + return typeof arg === 'object' && arg !== null; } - function abortConnection(socket, code, name) { - try { - var response = [ - 'HTTP/1.1 ' + code + ' ' + name, - 'Content-type: text/html' - ]; - socket.write(response.concat('', '').join('\r\n')); - } - catch (e) { /* ignore errors - we've aborted this connection */ } - finally { - // ensure that an early aborted connection is shut down completely - try { socket.destroy(); } catch (e) {} - } + function isUndefined(arg) { + return arg === void 0; } - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) /***/ }, -/* 93 */ +/* 5 */ /***/ function(module, exports) { 'use strict'; @@ -21986,17 +785,145 @@ GUILD_VOICE: 2 }; - module.exports.Endpoints = { - channelMessages: function channelMessages(cID) { - return '/channels/' + cID + '/messages'; + // stolen from discord.js + var Endpoints = module.exports.Endpoints = { + // general + login: '/auth/login', + logout: '/auth/logout', + gateway: '/gateway', + botGateway: '/gateway/bot', + invite: function invite(id) { + return '/invite/' + id; + }, + inviteLink: function inviteLink(id) { + return 'https://discord.gg/' + id; + }, + CDN: 'https://cdn.discordapp.com', + + // users + user: function user(userID) { + return '/users/' + userID; + }, + userChannels: function userChannels(userID) { + return Endpoints.user(userID) + '/channels'; + }, + userProfile: function userProfile(userID) { + return Endpoints.user(userID) + '/profile'; + }, + avatar: function avatar(userID, _avatar) { + return userID === '1' ? _avatar : Endpoints.user(userID) + '/avatars/' + _avatar + '.jpg'; + }, + me: '/users/@me', + meGuild: function meGuild(guildID) { + return Endpoints.me + '/guilds/' + guildID; + }, + relationships: function relationships(userID) { + return Endpoints.user(userID) + '/relationships'; + }, + note: function note(userID) { + return Endpoints.me + '/notes/' + userID; + }, + + // guilds + guilds: '/guilds', + guild: function guild(guildID) { + return Endpoints.guilds + '/' + guildID; + }, + guildIcon: function guildIcon(guildID, hash) { + return Endpoints.guild(guildID) + '/icons/' + hash + '.jpg'; + }, + guildPrune: function guildPrune(guildID) { + return Endpoints.guild(guildID) + '/prune'; + }, + guildEmbed: function guildEmbed(guildID) { + return Endpoints.guild(guildID) + '/embed'; + }, + guildInvites: function guildInvites(guildID) { + return Endpoints.guild(guildID) + '/invites'; + }, + guildRoles: function guildRoles(guildID) { + return Endpoints.guild(guildID) + '/roles'; + }, + guildRole: function guildRole(guildID, roleID) { + return Endpoints.guildRoles(guildID) + '/' + roleID; + }, + guildBans: function guildBans(guildID) { + return Endpoints.guild(guildID) + '/bans'; + }, + guildIntegrations: function guildIntegrations(guildID) { + return Endpoints.guild(guildID) + '/integrations'; + }, + guildMembers: function guildMembers(guildID) { + return Endpoints.guild(guildID) + '/members'; + }, + guildMember: function guildMember(guildID, memberID) { + return Endpoints.guildMembers(guildID) + '/' + memberID; + }, + guildMemberRole: function guildMemberRole(guildID, memberID, roleID) { + return Endpoints.guildMember(guildID, memberID) + '/roles/' + roleID + '}'; + }, + stupidInconsistentGuildEndpoint: function stupidInconsistentGuildEndpoint(guildID) { + return Endpoints.guildMember(guildID, '@me') + '/nick'; + }, + guildChannels: function guildChannels(guildID) { + return Endpoints.guild(guildID) + '/channels'; + }, + guildEmojis: function guildEmojis(guildID) { + return Endpoints.guild(guildID) + '/emojis'; + }, + + // channels + channels: '/channels', + channel: function channel(channelID) { + return Endpoints.channels + '/' + channelID; + }, + channelMessages: function channelMessages(channelID) { + return Endpoints.channel(channelID) + '/messages'; + }, + channelInvites: function channelInvites(channelID) { + return Endpoints.channel(channelID) + '/invites'; + }, + channelTyping: function channelTyping(channelID) { + return Endpoints.channel(channelID) + '/typing'; + }, + channelPermissions: function channelPermissions(channelID) { + return Endpoints.channel(channelID) + '/permissions'; + }, + channelMessage: function channelMessage(channelID, messageID) { + return Endpoints.channelMessages(channelID) + '/' + messageID; + }, + channelWebhooks: function channelWebhooks(channelID) { + return Endpoints.channel(channelID) + '/webhooks'; + }, + + // message reactions + messageReactions: function messageReactions(channelID, messageID) { + return Endpoints.channelMessage(channelID, messageID) + '/reactions'; + }, + messageReaction: function messageReaction(channel, msg, emoji, limit) { + return Endpoints.messageReactions(channel, msg) + '/' + emoji + (limit ? '?limit=' + limit : ''); + }, + selfMessageReaction: function selfMessageReaction(channel, msg, emoji, limit) { + return Endpoints.messageReaction(channel, msg, emoji, limit) + '/@me'; + }, + userMessageReaction: function userMessageReaction(channel, msg, emoji, limit, id) { + return Endpoints.messageReaction(channel, msg, emoji, limit) + '/' + id; + }, + + // webhooks + webhook: function webhook(webhookID, token) { + return '/webhooks/' + webhookID + (token ? '/' + token : ''); }, - channelMessage: function channelMessage(cID, mID) { - return '/channels/' + cID + '/messages/' + mID; + + // oauth + myApplication: '/oauth2/applications/@me', + getApp: function getApp(id) { + return '/oauth2/authorize?client_id=' + id; } }; /***/ }, -/* 94 */ +/* 6 */ /***/ function(module, exports, __webpack_require__) { /** @@ -22013,9 +940,9 @@ root = this; } - var Emitter = __webpack_require__(95); - var requestBase = __webpack_require__(96); - var isObject = __webpack_require__(97); + var Emitter = __webpack_require__(7); + var requestBase = __webpack_require__(8); + var isObject = __webpack_require__(9); /** * Noop. @@ -22027,7 +954,7 @@ * Expose `request`. */ - var request = module.exports = __webpack_require__(98).bind(null, Request); + var request = module.exports = __webpack_require__(10).bind(null, Request); /** * Determine XHR. @@ -22978,7 +1905,7 @@ /***/ }, -/* 95 */ +/* 7 */ /***/ function(module, exports, __webpack_require__) { @@ -23147,13 +2074,13 @@ /***/ }, -/* 96 */ +/* 8 */ /***/ function(module, exports, __webpack_require__) { /** * Module of mixed-in functions shared between node and client code */ - var isObject = __webpack_require__(97); + var isObject = __webpack_require__(9); /** * Clear previous timeout. @@ -23525,7 +2452,7 @@ /***/ }, -/* 97 */ +/* 9 */ /***/ function(module, exports) { /** @@ -23544,7 +2471,7 @@ /***/ }, -/* 98 */ +/* 10 */ /***/ function(module, exports) { // The node and browser modules expose versions of this with the @@ -23582,7 +2509,7 @@ /***/ }, -/* 99 */ +/* 11 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(global, module) {/** @@ -40654,7 +19581,23 @@ /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(12)(module))) /***/ }, -/* 100 */ +/* 12 */ +/***/ function(module, exports) { + + module.exports = function(module) { + if(!module.webpackPolyfill) { + module.deprecate = function() {}; + module.paths = []; + // module.parent = undefined by default + module.children = []; + module.webpackPolyfill = 1; + } + return module; + } + + +/***/ }, +/* 13 */ /***/ function(module, exports, __webpack_require__) { // uuid.js @@ -40665,7 +19608,7 @@ // Unique ID creation requires a high quality random # generator. We feature // detect to determine the best RNG source, normalizing to a function that // returns 128-bits of randomness, since that's what's usually required - var _rng = __webpack_require__(101); + var _rng = __webpack_require__(14); // Maps for number <-> hex string conversion var _byteToHex = []; @@ -40843,7 +19786,7 @@ /***/ }, -/* 101 */ +/* 14 */ /***/ function(module, exports) { /* WEBPACK VAR INJECTION */(function(global) { @@ -40882,7 +19825,7 @@ /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, -/* 102 */ +/* 15 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -40891,9 +19834,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var superagent = __webpack_require__(94); + var superagent = __webpack_require__(6); - var _require = __webpack_require__(93), + var _require = __webpack_require__(5), Endpoints = _require.Endpoints; module.exports = function () { diff --git a/webpack/rpc.1.1.2.min.js b/webpack/rpc.1.1.2.min.js index 9ba2e56..002a930 100644 --- a/webpack/rpc.1.1.2.min.js +++ b/webpack/rpc.1.1.2.min.js @@ -1,98 +1,4 @@ -!function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";t.exports={version:n(1).version,Client:n(2),Rest:n(102),Constants:n(93)},"undefined"!=typeof window&&(window.DiscordRPC=t.exports)},function(t,e){t.exports={name:"discord-rpc",version:"1.1.2",description:"A simple RPC client for Discord somewhat stolen from the Discord StreamKit.",main:"src/index.js",repository:{type:"git",url:"git+https://github.com/GusCaplan/discord-rpc.git"},scripts:{"web-dist":"npm install && ./node_modules/parallel-webpack/bin/run.js"},author:"Gus Caplan ",license:"MIT",bugs:{url:"https://github.com/GusCaplan/discord-rpc/issues"},homepage:"https://github.com/GusCaplan/discord-rpc#readme",dependencies:{lodash:"^4.17.2",superagent:"^2.3.0",uuid:"^2.0.3",ws:"^1.1.1"},devDependencies:{"babel-core":"^6.18.2","babel-loader":"^6.2.8","babel-preset-es2015":"^6.18.0","json-loader":"^0.5.4","parallel-webpack":"^1.5.0",webpack:"^1.13.3"}}},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e,n){return t+":"+(e||n)}var o=function(){function t(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:this.accessToken,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.connected){this.accessToken=t;var n=6463+e%10;this.hostAndPort=p()+".discordapp.io:"+n,this.socket=new s("wss://"+this.hostAndPort+"/?v=1&client_id="+this.OAUTH2_CLIENT_ID),this.socket.onopen=this._handleOpen.bind(this),this.socket.onclose=this._handleClose.bind(this),this.socket.onmessage=this._handleMessage.bind(this)}}},{key:"disconnect",value:function(t){this.connected&&(this.requestedDisconnect=!0,this.socket.close(),t&&t())}},{key:"reconnect",value:function(){this.connected&&this.socket.close()}},{key:"authenticate",value:function(){var t=this;if(!this.authenticated)return this.accessToken?void this.request("AUTHENTICATE",{access_token:this.accessToken},function(e,n){return e&&e.code===h.INVALID_TOKEN?void t.authorize():(t.authenticated=!0,t.flushQueue(),void t.activeSubscriptions.forEach(function(e){return t.subscribe(e.evt,e.args,e.callback)}))}):void this.authorize()}},{key:"flushQueue",value:function(){var t=this.queue;this.queue=[],t.forEach(function(t){return t()})}},{key:"authorize",value:function(){var t=this;this.authenticated||l.get(this.API_ENDPOINT+"/token").then(function(e){if(!e.ok||!e.body.rpc_token)throw new Error("no rpc token");return t.request("AUTHORIZE",{client_id:t.OAUTH2_CLIENT_ID,scopes:["rpc","rpc.api"],rpc_token:e.body.rpc_token})}).then(function(e){return l.post(t.API_ENDPOINT+"/token").send({code:e.code})}).then(function(e){if(!e.ok)throw new Error("no access token");t.accessToken=e.body.access_token,t.authenticate()}).catch(function(e){setTimeout(t.authorize.bind(t),3e3)})}},{key:"request",value:function(t,e,n,r){var o=this;return"function"==typeof n&&(r=n,n=void 0),new Promise(function(s,a){if(!o.connected||!o.ready||!o.authenticated&&["AUTHORIZE","AUTHENTICATE"].indexOf(t)===-1)return void o.queue.push(function(){return o.request(t,e,n,r)});var u=p();o.evts.once(i(f.DISPATCH,u),function(t,e){r&&r(t,e),t?a(t):s(e)}),o.socket.send(JSON.stringify({cmd:t,args:e,evt:n,nonce:u}))})}},{key:"subscribe",value:function(t,e,n){var r=this;this.request(f.SUBSCRIBE,e,t,function(o){return o?void(n&&n(o)):void(r.activeSubscriptions.find(function(t){return n===t.callback})||(r.activeSubscriptions.push({evt:t,args:e,callback:n}),r.evts.on(i(f.DISPATCH,null,t),function(t){n&&n(null,t)})))})}},{key:"unsubscribe",value:function(t,e,n){var r=this;this.request(f.UNSUBSCRIBE,e,t,function(o){if(o)return void(n&&n(o));d.remove(r.activeSubscriptions,function(n){return t===n.evt&&d.isEqual(e,n.args)});var s=i(f.DISPATCH,null,t);r.evts.listeners(s).forEach(function(t){r.evts.removeListener(s,t)}),n&&n()})}},{key:"_handleOpen",value:function(){this.connected=!0,this.authenticate()}},{key:"_handleClose",value:function(t){var e=this;if(this.connected=!1,this.authenticated=!1,this.ready=!1,console.error("WS Closed:",t),this.requestedDisconnect)return void(this.requestedDisconnect=!1);try{this.socket.close()}catch(t){}setTimeout(function(){return e.connect(null,1006===t.code?++e.connectionTries:0)},250)}},{key:"_handleMessage",value:function(t){var e=null;try{e=JSON.parse(t.data)}catch(t){return void console.error("Payload not JSON:",e)}var n=e,r=n.cmd,o=n.evt,s=n.nonce,a=n.data;if(r===f.AUTHENTICATE){if(o===c.ERROR)return void this.evts.emit("ERROR",a);this.user=a.user,this.application=a.application,this.evts.emit("READY",a)}if(r===f.DISPATCH)return o===c.READY?(this.config=a.config,this.ready=!0,void this.flushQueue()):o===c.ERROR?(console.error("Dispatched Error",a),void this.socket.close()):void this.evts.emit(i(f.DISPATCH,null,o),a);var u=null;o===c.ERROR&&(u=new Error(a.message),u.code=a.code,a=null),this.evts.emit(i(f.DISPATCH,s),u,a)}}]),t}();t.exports=v},function(t,e,n){"use strict";/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -var r=t.exports=n(4);r.Server=n(92),r.Sender=n(59),r.Receiver=n(85),r.createServer=function(t,e){var n=new r.Server(t);return"function"==typeof e&&n.on("connection",e),n},r.connect=r.createConnection=function(t,e){var n=new r(t);return"function"==typeof e&&n.on("open",e),n}},function(t,e,n){(function(e,r){"use strict";function i(t,e,n){return this instanceof i==!1?new i(t,e,n):(O.call(this),e&&!Array.isArray(e)&&"object"==typeof e&&(n=e,e=null),"string"==typeof e&&(e=[e]),Array.isArray(e)||(e=[]),this._socket=null,this._ultron=null,this._closeReceived=!1,this.bytesReceived=0,this.readyState=null,this.supports={},this.extensions={},this._binaryType="nodebuffer",void(Array.isArray(t)?f.apply(this,t.concat(n)):c.apply(this,[t,e,n])))}function o(t,e,n){this.type="message",this.data=t,this.target=n,this.binary=e}function s(t,e,n){this.type="close",this.wasClean="undefined"==typeof t||1e3===t,this.code=t,this.reason=e,this.target=n}function a(t){this.type="open",this.target=t}function u(t,e,n){var r=e;return e&&(t&&443!=n||!t&&80!=n)&&(r=r+":"+n),r}function f(t,e,n,r){r=new k({protocolVersion:I,protocol:null,extensions:{},maxPayload:0}).merge(r),this.protocol=r.value.protocol,this.protocolVersion=r.value.protocolVersion,this.extensions=r.value.extensions,this.supports.binary="hixie-76"!==this.protocolVersion,this.upgradeReq=t,this.readyState=i.CONNECTING,this._isServer=!0,this.maxPayload=r.value.maxPayload,"hixie-76"===r.value.protocolVersion?h.call(this,T,A,e,n):h.call(this,S,x,e,n)}function c(t,n,r){if(r=new k({origin:null,protocolVersion:I,host:null,headers:null,protocol:n.join(","),agent:null,pfx:null,key:null,passphrase:null,cert:null,ca:null,ciphers:null,rejectUnauthorized:null,perMessageDeflate:!0,localAddress:null}).merge(r),8!==r.value.protocolVersion&&13!==r.value.protocolVersion)throw new Error("unsupported protocol version");var o=v.parse(t),s="ws+unix:"===o.protocol;if(!o.host&&!s)throw new Error("invalid url");var a,f="wss:"===o.protocol||"https:"===o.protocol,c=f?m:y,l=o.port||(f?443:80),d=o.auth,p={};r.value.perMessageDeflate&&(a=new L(typeof r.value.perMessageDeflate!==!0?r.value.perMessageDeflate:{},!1),p[L.extensionName]=a.offer()),this._isServer=!1,this.url=t,this.protocolVersion=r.value.protocolVersion,this.supports.binary="hixie-76"!==this.protocolVersion;var g=new e(r.value.protocolVersion+"-"+Date.now()).toString("base64"),b=w.createHash("sha1");b.update(g+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var E=b.digest("base64"),A=r.value.agent,T=u(f,o.hostname,l),O={port:l,host:o.hostname,headers:{Connection:"Upgrade",Upgrade:"websocket",Host:T,"Sec-WebSocket-Version":r.value.protocolVersion,"Sec-WebSocket-Key":g}};if(d&&(O.headers.Authorization="Basic "+new e(d).toString("base64")),r.value.protocol&&(O.headers["Sec-WebSocket-Protocol"]=r.value.protocol),r.value.host&&(O.headers.Host=r.value.host),r.value.headers)for(var C in r.value.headers)r.value.headers.hasOwnProperty(C)&&(O.headers[C]=r.value.headers[C]);Object.keys(p).length&&(O.headers["Sec-WebSocket-Extensions"]=R.format(p)),(r.isDefinedAndNonNull("pfx")||r.isDefinedAndNonNull("key")||r.isDefinedAndNonNull("passphrase")||r.isDefinedAndNonNull("cert")||r.isDefinedAndNonNull("ca")||r.isDefinedAndNonNull("ciphers")||r.isDefinedAndNonNull("rejectUnauthorized"))&&(r.isDefinedAndNonNull("pfx")&&(O.pfx=r.value.pfx),r.isDefinedAndNonNull("key")&&(O.key=r.value.key),r.isDefinedAndNonNull("passphrase")&&(O.passphrase=r.value.passphrase),r.isDefinedAndNonNull("cert")&&(O.cert=r.value.cert),r.isDefinedAndNonNull("ca")&&(O.ca=r.value.ca),r.isDefinedAndNonNull("ciphers")&&(O.ciphers=r.value.ciphers),r.isDefinedAndNonNull("rejectUnauthorized")&&(O.rejectUnauthorized=r.value.rejectUnauthorized),A||(A=new c.Agent(O))),O.path=o.path||"/",A&&(O.agent=A),s&&(O.socketPath=o.pathname),r.value.localAddress&&(O.localAddress=r.value.localAddress),r.value.origin&&(r.value.protocolVersion<13?O.headers["Sec-WebSocket-Origin"]=r.value.origin:O.headers.Origin=r.value.origin);var N=this,M=c.request(O);M.on("error",function(t){N.emit("error",t),_.call(N,t)}),M.once("response",function(t){var e;N.emit("unexpected-response",M,t)||(e=new Error("unexpected server response ("+t.statusCode+")"),M.abort(),N.emit("error",e)),_.call(N,e)}),M.once("upgrade",function(t,e,n){if(N.readyState===i.CLOSED)return N.emit("close"),N.removeAllListeners(),void e.end();var o=t.headers["sec-websocket-accept"];if("undefined"==typeof o||o!==E)return N.emit("error","invalid server key"),N.removeAllListeners(),void e.end();var s=t.headers["sec-websocket-protocol"],u=(r.value.protocol||"").split(/, */),f=null;if(!r.value.protocol&&s?f="server sent a subprotocol even though none requested":r.value.protocol&&!s?f="server sent no subprotocol even though requested":s&&u.indexOf(s)===-1&&(f="server responded with an invalid protocol"),f)return N.emit("error",f),N.removeAllListeners(),void e.end();s&&(N.protocol=s);var c=R.parse(t.headers["sec-websocket-extensions"]);if(a&&c[L.extensionName]){try{a.accept(c[L.extensionName])}catch(t){return N.emit("error","invalid extension parameter"),N.removeAllListeners(),void e.end()}N.extensions[L.extensionName]=a}h.call(N,S,x,e,n),M.removeAllListeners(),M=null,A=null}),M.end(),this.readyState=i.CONNECTING}function h(t,e,n,o){function s(t){f||c.readyState===i.CLOSED||(f=!0,n.removeListener("data",s),u.on("data",a),o&&o.length>0&&(a(o),o=null),t&&a(t))}function a(t){c.bytesReceived+=t.length,c._receiver.add(t)}var u=this._ultron=new E(n),f=!1,c=this;n.setTimeout(0),n.setNoDelay(!0),this._receiver=new t(this.extensions,this.maxPayload),this._socket=n,u.on("end",_.bind(this)),u.on("close",_.bind(this)),u.on("error",_.bind(this)),u.on("data",s),r.nextTick(s),c._receiver.ontext=function(t,e){e=e||{},c.emit("message",t,e)},c._receiver.onbinary=function(t,e){e=e||{},e.binary=!0,c.emit("message",t,e)},c._receiver.onping=function(t,e){e=e||{},c.pong(t,{mask:!c._isServer,binary:e.binary===!0},!0),c.emit("ping",t,e)},c._receiver.onpong=function(t,e){c.emit("pong",t,e||{})},c._receiver.onclose=function(t,e,n){n=n||{},c._closeReceived=!0,c.close(t,e)},c._receiver.onerror=function(t,e){c.close("undefined"!=typeof e?e:1002,""),c.emit("error",t instanceof Error?t:new Error(t))},this._sender=new e(n,this.extensions),this._sender.on("error",function(t){c.close(1002,""),c.emit("error",t)}),this.readyState=i.OPEN,this.emit("open")}function l(t){t._queue=t._queue||[]}function d(t){var e=t._queue;if("undefined"!=typeof e){delete t._queue;for(var n=0,r=e.length;n - * MIT Licensed - */ -var v=n(10),g=n(16),y=n(19),m=n(40),w=n(41),b=n(22),E=n(56),k=n(57),x=n(59),S=n(85),A=n(89),T=n(90),R=n(91),L=n(63),O=n(20).EventEmitter,I=13,C=3e4;g.inherits(i,O),["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(t,e){i.prototype[t]=i[t]=e}),i.prototype.close=function(t,e){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return void(this.readyState=i.CLOSED);if(this.readyState===i.CLOSING)return void(this._closeReceived&&this._isServer&&this.terminate());var n=this;try{this.readyState=i.CLOSING,this._closeCode=t,this._closeMessage=e;var r=!this._isServer;this._sender.close(t,e,r,function(t){t&&n.emit("error",t),n._closeReceived&&n._isServer?n.terminate():(clearTimeout(n._closeTimer),n._closeTimer=setTimeout(_.bind(n,!0),C))})}catch(t){this.emit("error",t)}}},i.prototype.pause=function(){if(this.readyState!==i.OPEN)throw new Error("not opened");return this._socket.pause()},i.prototype.ping=function(t,e,n){if(this.readyState!==i.OPEN){if(n===!0)return;throw new Error("not opened")}e=e||{},"undefined"==typeof e.mask&&(e.mask=!this._isServer),this._sender.ping(t,e)},i.prototype.pong=function(t,e,n){if(this.readyState!==i.OPEN){if(n===!0)return;throw new Error("not opened")}e=e||{},"undefined"==typeof e.mask&&(e.mask=!this._isServer),this._sender.pong(t,e)},i.prototype.resume=function(){if(this.readyState!==i.OPEN)throw new Error("not opened");return this._socket.resume()},i.prototype.send=function(t,n,o){if("function"==typeof n&&(o=n,n={}),this.readyState!==i.OPEN){if("function"!=typeof o)throw new Error("not opened");return void o(new Error("not opened"))}if(t||(t=""),this._queue){var s=this;return void this._queue.push(function(){s.send(t,n,o)})}n=n||{},n.fin=!0,"undefined"==typeof n.binary&&(n.binary=t instanceof ArrayBuffer||t instanceof e||t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof Float64Array),"undefined"==typeof n.mask&&(n.mask=!this._isServer),"undefined"==typeof n.compress&&(n.compress=!0),this.extensions[L.extensionName]||(n.compress=!1);var a="function"==typeof b.Readable?b.Readable:b.Stream;if(t instanceof a){l(this);var s=this;p(this,t,n,function(t){r.nextTick(function(){d(s)}),"function"==typeof o&&o(t)})}else this._sender.send(t,n,o)},i.prototype.stream=function(t,e){function n(s,a){try{if(o.readyState!==i.OPEN)throw new Error("not opened");t.fin=a===!0,o._sender.send(s,t),a?d(o):r.nextTick(e.bind(null,null,n))}catch(t){"function"==typeof e?e(t):(delete o._queue,o.emit("error",t))}}"function"==typeof t&&(e=t,t={});var o=this;if("function"!=typeof e)throw new Error("callback must be provided");if(this.readyState!==i.OPEN){if("function"!=typeof e)throw new Error("not opened");return void e(new Error("not opened"))}return this._queue?void this._queue.push(function(){o.stream(t,e)}):(t=t||{},"undefined"==typeof t.mask&&(t.mask=!this._isServer),"undefined"==typeof t.compress&&(t.compress=!0),this.extensions[L.extensionName]||(t.compress=!1),l(this),void r.nextTick(e.bind(null,null,n)))},i.prototype.terminate=function(){if(this.readyState!==i.CLOSED)if(this._socket){this.readyState=i.CLOSING;try{this._socket.end()}catch(t){return void _.call(this,!0)}this._closeTimer&&clearTimeout(this._closeTimer),this._closeTimer=setTimeout(_.bind(this,!0),C)}else this.readyState===i.CONNECTING&&_.call(this,!0)},Object.defineProperty(i.prototype,"bufferedAmount",{get:function(){var t=0;return this._socket&&(t=this._socket.bufferSize||0),t}}),Object.defineProperty(i.prototype,"binaryType",{get:function(){return this._binaryType},set:function(t){if("arraybuffer"!==t&&"nodebuffer"!==t)throw new SyntaxError('unsupported binaryType: must be either "nodebuffer" or "arraybuffer"');this._binaryType=t}}),["open","error","close","message"].forEach(function(t){Object.defineProperty(i.prototype,"on"+t,{get:function(){var e=this.listeners(t)[0];return e?e._listener?e._listener:e:void 0},set:function(e){this.removeAllListeners(t),this.addEventListener(t,e)}})}),i.prototype.addEventListener=function(t,e){function n(t,n){n.binary&&"arraybuffer"===this.binaryType&&(t=new Uint8Array(t).buffer),e.call(f,new o(t,!!n.binary,f))}function r(t,n){e.call(f,new s(t,n,f))}function i(t){t.type="error",t.target=f,e.call(f,t)}function u(){e.call(f,new a(f))}var f=this;"function"==typeof e&&("message"===t?(n._listener=e,this.on(t,n)):"close"===t?(r._listener=e,this.on(t,r)):"error"===t?(i._listener=e,this.on(t,i)):"open"===t?(u._listener=e,this.on(t,u)):this.on(t,e))},t.exports=i,t.exports.buildHostHeader=u}).call(e,n(5).Buffer,n(9))},function(t,e,n){(function(t,r){/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -"use strict";function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function o(){return t.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,n){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function v(e){return+e!=e&&(e=0),t.alloc(+e)}function g(e,n){if(t.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var i=!1;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(e).length;default:if(i)return W(e).length;n=(""+n).toLowerCase(),i=!0}}function y(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,e>>>=0,n<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return N(this,e,n);case"utf8":case"utf-8":return L(this,e,n);case"ascii":return I(this,e,n);case"latin1":case"binary":return C(this,e,n);case"base64":return R(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function m(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function w(e,n,r,i,o){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof n&&(n=t.from(n,i)),t.isBuffer(n))return 0===n.length?-1:b(e,n,r,i,o);if("number"==typeof n)return n&=255,t.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,n,r):Uint8Array.prototype.lastIndexOf.call(e,n,r):b(e,[n],r,i,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,n,r,i){function o(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}var s=1,a=t.length,u=e.length;if(void 0!==r&&(r=String(r).toLowerCase(),"ucs2"===r||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}var f;if(i){var c=-1;for(f=n;fa&&(n=a-u),f=n;f>=0;f--){for(var h=!0,l=0;li&&(r=i)):r=i;var o=e.length;if(o%2!==0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s239?4:o>223?3:o>191?2:1;if(i+a<=n){var u,f,c,h;switch(a){case 1:o<128&&(s=o);break;case 2:u=t[i+1],128===(192&u)&&(h=(31&o)<<6|63&u,h>127&&(s=h));break;case 3:u=t[i+1],f=t[i+2],128===(192&u)&&128===(192&f)&&(h=(15&o)<<12|(63&u)<<6|63&f,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:u=t[i+1],f=t[i+2],c=t[i+3],128===(192&u)&&128===(192&f)&&128===(192&c)&&(h=(15&o)<<18|(63&u)<<12|(63&f)<<6|63&c,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=a}return O(r)}function O(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var n="",r=0;rr)&&(n=r);for(var i="",o=e;on)throw new RangeError("Trying to access beyond buffer length")}function D(e,n,r,i,o,s){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>o||ne.length)throw new RangeError("Index out of range")}function P(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i>>8*(r?i:1-i)}function j(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i>>8*(r?i:3-i)&255}function U(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function z(t,e,n,r,i){return i||U(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),J.write(t,e,n,r,23,4),n+4}function F(t,e,n,r,i){return i||U(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),J.write(t,e,n,r,52,8),n+8}function H(t){if(t=q(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function q(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Z(t){return t<16?"0"+t.toString(16):t.toString(16)}function W(t,e){e=e||1/0;for(var n,r=t.length,i=null,o=[],s=0;s55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function V(t){for(var e=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function Y(t){return X.toByteArray(H(t))}function $(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function K(t){return t!==t}var X=n(6),J=n(7),Q=n(8);e.Buffer=t,e.SlowBuffer=v,e.INSPECT_MAX_BYTES=50,t.TYPED_ARRAY_SUPPORT=void 0!==r.TYPED_ARRAY_SUPPORT?r.TYPED_ARRAY_SUPPORT:i(),e.kMaxLength=o(),t.poolSize=8192,t._augment=function(e){return e.__proto__=t.prototype,e},t.from=function(t,e,n){return a(null,t,e,n)},t.TYPED_ARRAY_SUPPORT&&(t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0})),t.alloc=function(t,e,n){return f(null,t,e,n)},t.allocUnsafe=function(t){return c(null,t)},t.allocUnsafeSlow=function(t){return c(null,t)},t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.compare=function(e,n){if(!t.isBuffer(e)||!t.isBuffer(n))throw new TypeError("Arguments must be Buffers");if(e===n)return 0;for(var r=e.length,i=n.length,o=0,s=Math.min(r,i);o0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},t.prototype.compare=function(e,n,r,i,o){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),n<0||r>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&n>=r)return 0;if(i>=o)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,i>>>=0,o>>>=0,this===e)return 0;for(var s=o-i,a=r-n,u=Math.min(s,a),f=this.slice(i,o),c=e.slice(n,r),h=0;hi)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return E(this,t,e,n);case"utf8":case"utf-8":return k(this,t,e,n);case"ascii":return x(this,t,e,n);case"latin1":case"binary":return S(this,t,e,n);case"base64":return A(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;t.prototype.slice=function(e,n){var r=this.length;e=~~e,n=void 0===n?r:~~n,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),n<0?(n+=r,n<0&&(n=0)):n>r&&(n=r),n0&&(i*=256);)r+=this[t+--e]*i;return r},t.prototype.readUInt8=function(t,e){return e||B(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,e){return e||B(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,e){return e||B(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,e){return e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,e){return e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||B(t,e,this.length);for(var r=this[t],i=1,o=0;++o=i&&(r-=Math.pow(2,8*e)),r},t.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||B(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},t.prototype.readInt8=function(t,e){return e||B(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},t.prototype.readInt16LE=function(t,e){e||B(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt16BE=function(t,e){e||B(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt32LE=function(t,e){return e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,e){return e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,e){return e||B(t,4,this.length),J.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,e){return e||B(t,4,this.length),J.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,e){return e||B(t,8,this.length),J.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,e){return e||B(t,8,this.length),J.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,e,n,r){if(t=+t,e|=0,n|=0,!r){var i=Math.pow(2,8*n)-1;D(this,t,e,n,i,0)}var o=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+o]=t/s&255;return e+n},t.prototype.writeUInt8=function(e,n,r){return e=+e,n|=0,r||D(this,e,n,1,255,0),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[n]=255&e,n+1},t.prototype.writeUInt16LE=function(e,n,r){return e=+e,n|=0,r||D(this,e,n,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[n]=255&e,this[n+1]=e>>>8):P(this,e,n,!0),n+2},t.prototype.writeUInt16BE=function(e,n,r){return e=+e,n|=0,r||D(this,e,n,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[n]=e>>>8,this[n+1]=255&e):P(this,e,n,!1),n+2},t.prototype.writeUInt32LE=function(e,n,r){return e=+e,n|=0,r||D(this,e,n,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[n+3]=e>>>24,this[n+2]=e>>>16,this[n+1]=e>>>8,this[n]=255&e):j(this,e,n,!0),n+4},t.prototype.writeUInt32BE=function(e,n,r){return e=+e,n|=0,r||D(this,e,n,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=255&e):j(this,e,n,!1),n+4},t.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+n},t.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+n},t.prototype.writeInt8=function(e,n,r){return e=+e,n|=0,r||D(this,e,n,1,127,-128),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[n]=255&e,n+1},t.prototype.writeInt16LE=function(e,n,r){return e=+e,n|=0,r||D(this,e,n,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[n]=255&e,this[n+1]=e>>>8):P(this,e,n,!0),n+2},t.prototype.writeInt16BE=function(e,n,r){return e=+e,n|=0,r||D(this,e,n,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[n]=e>>>8,this[n+1]=255&e):P(this,e,n,!1),n+2},t.prototype.writeInt32LE=function(e,n,r){return e=+e,n|=0,r||D(this,e,n,4,2147483647,-2147483648),t.TYPED_ARRAY_SUPPORT?(this[n]=255&e,this[n+1]=e>>>8,this[n+2]=e>>>16,this[n+3]=e>>>24):j(this,e,n,!0),n+4},t.prototype.writeInt32BE=function(e,n,r){return e=+e,n|=0,r||D(this,e,n,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),t.TYPED_ARRAY_SUPPORT?(this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=255&e):j(this,e,n,!1),n+4},t.prototype.writeFloatLE=function(t,e,n){return z(this,t,e,!0,n)},t.prototype.writeFloatBE=function(t,e,n){return z(this,t,e,!1,n)},t.prototype.writeDoubleLE=function(t,e,n){return F(this,t,e,!0,n)},t.prototype.writeDoubleBE=function(t,e,n){return F(this,t,e,!1,n)},t.prototype.copy=function(e,n,r,i){if(r||(r=0),i||0===i||(i=this.length),n>=e.length&&(n=e.length),n||(n=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-n=0;--o)e[o+n]=this[o+r];else if(s<1e3||!t.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var s;if("number"==typeof e)for(s=n;s0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function r(t){return 3*t.length/4-n(t)}function i(t){var e,r,i,o,s,a,u=t.length;s=n(t),a=new c(3*u/4-s),i=s>0?u-4:u;var h=0;for(e=0,r=0;e>16&255,a[h++]=o>>8&255,a[h++]=255&o;return 2===s?(o=f[t.charCodeAt(e)]<<2|f[t.charCodeAt(e+1)]>>4,a[h++]=255&o):1===s&&(o=f[t.charCodeAt(e)]<<10|f[t.charCodeAt(e+1)]<<4|f[t.charCodeAt(e+2)]>>2,a[h++]=o>>8&255,a[h++]=255&o),a}function o(t){return u[t>>18&63]+u[t>>12&63]+u[t>>6&63]+u[63&t]}function s(t,e,n){for(var r,i=[],s=e;sc?c:f+a));return 1===r?(e=t[n-1],i+=u[e>>2],i+=u[e<<4&63],i+="=="):2===r&&(e=(t[n-2]<<8)+t[n-1],i+=u[e>>10],i+=u[e>>4&63],i+=u[e<<2&63],i+="="),o.push(i),o.join("")}e.byteLength=r,e.toByteArray=i,e.fromByteArray=a;for(var u=[],f=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,d=h.length;l>1,c=-7,h=n?i-1:0,l=n?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=a;c>0;o=256*o+t[e+h],h+=l,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;c>0;s=256*s+t[e+h],h+=l,c-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:(d?-1:1)*(1/0);s+=Math.pow(2,r),o-=f}return(d?-1:1)*s*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var s,a,u,f=8*o-i-1,c=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,_=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+h>=1?l/u:l*Math.pow(2,1-h),e*u>=2&&(s++,u/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[n+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;t[n+d]=255&s,d+=p,s/=256,f-=8);t[n+d-p]|=128*_}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function i(t){if(c===setTimeout)return setTimeout(t,0);if((c===n||!c)&&setTimeout)return c=setTimeout,setTimeout(t,0);try{return c(t,0)}catch(e){try{return c.call(null,t,0)}catch(e){return c.call(this,t,0)}}}function o(t){if(h===clearTimeout)return clearTimeout(t);if((h===r||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(t);try{return h(t)}catch(e){try{return h.call(null,t)}catch(e){return h.call(this,t)}}}function s(){_&&d&&(_=!1,d.length?p=d.concat(p):v=-1,p.length&&a())}function a(){if(!_){var t=i(s);_=!0;for(var e=p.length;e;){for(d=p,p=[];++v1)for(var n=1;n",'"',"`"," ","\r","\n","\t"],v=["{","}","|","\\","^","`"].concat(_),g=["'"].concat(v),y=["%","/","?",";","#"].concat(g),m=["/","?","#"],w=255,b=/^[a-z0-9A-Z_-]{0,63}$/,E=/^([a-z0-9A-Z_-]{0,63})(.*)$/,k={javascript:!0,"javascript:":!0},x={javascript:!0,"javascript:":!0},S={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},A=n(13);r.prototype.parse=function(t,e,n){if(!u(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var r=t;r=r.trim();var i=d.exec(r);if(i){i=i[0];var o=i.toLowerCase();this.protocol=o,r=r.substr(i.length)}if(n||i||r.match(/^\/\/[^@\/]+@[^@\/]+/)){var s="//"===r.substr(0,2);!s||i&&x[i]||(r=r.substr(2),this.slashes=!0)}if(!x[i]&&(s||i&&!S[i])){for(var a=-1,f=0;f127?"x":R[O];if(!L.match(b)){var C=v.slice(0,f),N=v.slice(f+1),M=R.match(E);M&&(C.push(M[1]),N.unshift(M[2])),N.length&&(r="/"+N.join(".")+r),this.hostname=C.join(".");break}}}if(this.hostname.length>w?this.hostname="":this.hostname=this.hostname.toLowerCase(),!_){for(var B=this.hostname.split("."),D=[],f=0;f0)&&n.host.split("@");v&&(n.auth=v.shift(),n.host=n.hostname=v.shift())}return n.search=t.search,n.query=t.query,c(n.pathname)&&c(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!p.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var g=p.slice(-1)[0],y=(n.host||t.host)&&("."===g||".."===g)||""===g,m=0,w=p.length;w>=0;w--)g=p[w],"."==g?p.splice(w,1):".."===g?(p.splice(w,1),m++):m&&(p.splice(w,1),m--);if(!l&&!d)for(;m--;m)p.unshift("..");!l||""===p[0]||p[0]&&"/"===p[0].charAt(0)||p.unshift(""),y&&"/"!==p.join("/").substr(-1)&&p.push("");var b=""===p[0]||p[0]&&"/"===p[0].charAt(0);if(_){n.hostname=n.host=b?"":p.length?p.shift():"";var v=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@");v&&(n.auth=v.shift(),n.host=n.hostname=v.shift())}return l=l||n.host&&p.length,l&&!b&&p.unshift(""),p.length?n.pathname=p.join("/"):(n.pathname=null,n.path=null),c(n.pathname)&&c(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=t.auth||n.auth,n.slashes=n.slashes||t.slashes,n.href=n.format(),n},r.prototype.parseHost=function(){var t=this.host,e=p.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,n){var r;(function(t,i){!function(o){function s(t){throw RangeError(C[t])}function a(t,e){for(var n=t.length,r=[];n--;)r[n]=e(t[n]);return r}function u(t,e){var n=t.split("@"),r="";n.length>1&&(r=n[0]+"@",t=n[1]),t=t.replace(I,".");var i=t.split("."),o=a(i,e).join(".");return r+o}function f(t){for(var e,n,r=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(t-=65536,e+=B(t>>>10&1023|55296),t=56320|1023&t),e+=B(t)}).join("")}function h(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:b}function l(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function d(t,e,n){var r=0;for(t=n?M(t/S):t>>1,t+=M(t/e);t>N*k>>1;r+=b)t=M(t/N);return M(r+(N+1)*t/(t+x))}function p(t){var e,n,r,i,o,a,u,f,l,p,_=[],v=t.length,g=0,y=T,m=A;for(n=t.lastIndexOf(R),n<0&&(n=0),r=0;r=128&&s("not-basic"), -_.push(t.charCodeAt(r));for(i=n>0?n+1:0;i=v&&s("invalid-input"),f=h(t.charCodeAt(i++)),(f>=b||f>M((w-g)/a))&&s("overflow"),g+=f*a,l=u<=m?E:u>=m+k?k:u-m,!(fM(w/p)&&s("overflow"),a*=p;e=_.length+1,m=d(g-o,e,0==o),M(g/e)>w-y&&s("overflow"),y+=M(g/e),g%=e,_.splice(g++,0,y)}return c(_)}function _(t){var e,n,r,i,o,a,u,c,h,p,_,v,g,y,m,x=[];for(t=f(t),v=t.length,e=T,n=0,o=A,a=0;a=e&&_M((w-n)/g)&&s("overflow"),n+=(u-e)*g,e=u,a=0;aw&&s("overflow"),_==e){for(c=n,h=b;p=h<=o?E:h>=o+k?k:h-o,!(c= 0x80 (not a basic code point)","invalid-input":"Invalid input"},N=b-E,M=Math.floor,B=String.fromCharCode;m={version:"1.3.2",ucs2:{decode:f,encode:c},decode:p,encode:_,toASCII:g,toUnicode:v},r=function(){return m}.call(e,n,e,t),!(void 0!==r&&(t.exports=r))}(this)}).call(e,n(12)(t),function(){return this}())},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e,n){"use strict";e.decode=e.parse=n(14),e.encode=e.stringify=n(15)},function(t,e){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,r,i){e=e||"&",r=r||"=";var o={};if("string"!=typeof t||0===t.length)return o;var s=/\+/g;t=t.split(e);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var u=t.length;a>0&&u>a&&(u=a);for(var f=0;f=0?(c=p.substr(0,_),h=p.substr(_+1)):(c=p,h=""),l=decodeURIComponent(c),d=decodeURIComponent(h),n(o,l)?Array.isArray(o[l])?o[l].push(d):o[l]=[o[l],d]:o[l]=d}return o}},function(t,e){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,r,i){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map(function(i){var o=encodeURIComponent(n(i))+r;return Array.isArray(t[i])?t[i].map(function(t){return o+encodeURIComponent(n(t))}).join(e):o+encodeURIComponent(n(t[i]))}).join(e):i?encodeURIComponent(n(i))+r+encodeURIComponent(n(t)):""}},function(t,e,n){(function(t,r){function i(t,n){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),_(n)?r.showHidden=n:n&&e._extend(r,n),b(r.showHidden)&&(r.showHidden=!1),b(r.depth)&&(r.depth=2),b(r.colors)&&(r.colors=!1),b(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,t,r.depth)}function o(t,e){var n=i.styles[e];return n?"["+i.colors[n][0]+"m"+t+"["+i.colors[n][1]+"m":t}function s(t,e){return t}function a(t){var e={};return t.forEach(function(t,n){e[t]=!0}),e}function u(t,n,r){if(t.customInspect&&n&&A(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,t);return m(i)||(i=u(t,i,r)),i}var o=f(t,n);if(o)return o;var s=Object.keys(n),_=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(n)),S(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return c(n);if(0===s.length){if(A(n)){var v=n.name?": "+n.name:"";return t.stylize("[Function"+v+"]","special")}if(E(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(x(n))return t.stylize(Date.prototype.toString.call(n),"date");if(S(n))return c(n)}var g="",y=!1,w=["{","}"];if(p(n)&&(y=!0,w=["[","]"]),A(n)){var b=n.name?": "+n.name:"";g=" [Function"+b+"]"}if(E(n)&&(g=" "+RegExp.prototype.toString.call(n)),x(n)&&(g=" "+Date.prototype.toUTCString.call(n)),S(n)&&(g=" "+c(n)),0===s.length&&(!y||0==n.length))return w[0]+g+w[1];if(r<0)return E(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special");t.seen.push(n);var k;return k=y?h(t,n,r,_,s):s.map(function(e){return l(t,n,r,_,e,y)}),t.seen.pop(),d(k,g,w)}function f(t,e){if(b(e))return t.stylize("undefined","undefined");if(m(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}return y(e)?t.stylize(""+e,"number"):_(e)?t.stylize(""+e,"boolean"):v(e)?t.stylize("null","null"):void 0}function c(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,n,r,i){for(var o=[],s=0,a=e.length;s-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),b(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function d(t,e,n){var r=0,i=t.reduce(function(t,e){return r++,e.indexOf("\n")>=0&&r++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1]:n[0]+e+" "+t.join(", ")+" "+n[1]}function p(t){return Array.isArray(t)}function _(t){return"boolean"==typeof t}function v(t){return null===t}function g(t){return null==t}function y(t){return"number"==typeof t}function m(t){return"string"==typeof t}function w(t){return"symbol"==typeof t}function b(t){return void 0===t}function E(t){return k(t)&&"[object RegExp]"===R(t)}function k(t){return"object"==typeof t&&null!==t}function x(t){return k(t)&&"[object Date]"===R(t)}function S(t){return k(t)&&("[object Error]"===R(t)||t instanceof Error)}function A(t){return"function"==typeof t}function T(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function R(t){return Object.prototype.toString.call(t)}function L(t){return t<10?"0"+t.toString(10):t.toString(10)}function O(){var t=new Date,e=[L(t.getHours()),L(t.getMinutes()),L(t.getSeconds())].join(":");return[t.getDate(),B[t.getMonth()],e].join(" ")}function I(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var C=/%[sdj%]/g;e.format=function(t){if(!m(t)){for(var e=[],n=0;n=o)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}}),a=r[n];n0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function n(){this.removeListener(t,n),i||(i=!0,e.apply(this,arguments))}if(!r(e))throw TypeError("listener must be a function");var i=!1;return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var n,i,s,a;if(!r(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],s=n.length,i=-1,n===e||r(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(n)){for(a=s;a-- >0;)if(n[a]===e||n[a].listener&&n[a].listener===e){i=a;break}if(i<0)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],r(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?r(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(r(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,n){var r=n(22),i=n(38),o=n(39),s=n(23),a=t.exports=function(t,e){var n=this;n.writable=!0,n.xhr=t,n.body=[],n.uri=(e.protocol||"http:")+"//"+e.host+(e.port?":"+e.port:"")+(e.path||"/"),"undefined"==typeof e.withCredentials&&(e.withCredentials=!0);try{t.withCredentials=e.withCredentials}catch(t){}if(e.responseType)try{t.responseType=e.responseType}catch(t){}if(t.open(e.method||"GET",n.uri,!0),t.onerror=function(t){n.emit("error",new Error("Network error"))},n._headers={},e.headers)for(var r=u(e.headers),s=0;s0)if(e.ended&&!i){var a=new Error("stream.push() after EOF");t.emit("error",a)}else if(e.endEmitted&&i){var a=new Error("stream.unshift() after end event");t.emit("error",a)}else!e.decoder||i||r||(n=e.decoder.write(n)),i||(e.reading=!1),e.flowing&&0===e.length&&!e.sync?(t.emit("data",n),t.read(0)):(e.length+=e.objectMode?1:n.length,i?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&h(t)),d(t,e);else i||(e.reading=!1);return s(e)}function s(t){return!t.ended&&(t.needReadable||t.length=O)t=O;else{t--;for(var e=1;e<32;e<<=1)t|=t>>e;t++}return t}function u(t,e){return 0===e.length&&e.ended?0:e.objectMode?0===t?0:1:isNaN(t)||T.isNull(t)?e.flowing&&e.buffer.length?e.buffer[0].length:e.length:t<=0?0:(t>e.highWaterMark&&(e.highWaterMark=a(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function f(t,e){var n=null;return T.isBuffer(e)||T.isString(e)||T.isNullOrUndefined(e)||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function c(t,e){if(e.decoder&&!e.ended){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,h(t)}function h(t){var n=t._readableState;n.needReadable=!1,n.emittedReadable||(L("emitReadable",n.flowing),n.emittedReadable=!0,n.sync?e.nextTick(function(){l(t)}):l(t))}function l(t){L("emit readable"),t.emit("readable"),y(t)}function d(t,n){n.readingMore||(n.readingMore=!0,e.nextTick(function(){p(t,n)}))}function p(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=i)n=o?r.join(""):x.concat(r,i),r.length=0;else if(t0)throw new Error("endReadable called on non-empty stream");n.endEmitted||(n.ended=!0,e.nextTick(function(){n.endEmitted||0!==n.length||(n.endEmitted=!0,t.readable=!1,t.emit("end"))}))}function b(t,e){for(var n=0,r=t.length;n0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return L("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?w(this):h(this),null;if(t=u(t,e),0===t&&e.ended)return 0===e.length&&w(this),null;var r=e.needReadable;L("need readable",r),(0===e.length||e.length-t0?m(t,e):null,T.isNull(i)&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),n!==t&&e.ended&&0===e.length&&w(this),T.isNull(i)||this.emit("data",i),i},i.prototype._read=function(t){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(t,n){function r(t){L("onunpipe"),t===h&&o()}function i(){L("onend"),t.end()}function o(){L("cleanup"),t.removeListener("close",u),t.removeListener("finish",f),t.removeListener("drain",v),t.removeListener("error",a),t.removeListener("unpipe",r),h.removeListener("end",i),h.removeListener("end",o),h.removeListener("data",s),!l.awaitDrain||t._writableState&&!t._writableState.needDrain||v()}function s(e){L("ondata");var n=t.write(e);!1===n&&(L("false write response, pause",h._readableState.awaitDrain),h._readableState.awaitDrain++,h.pause())}function a(e){L("onerror",e),c(),t.removeListener("error",a),0===S.listenerCount(t,"error")&&t.emit("error",e)}function u(){t.removeListener("finish",f),c()}function f(){L("onfinish"),t.removeListener("close",u),c()}function c(){L("unpipe"),h.unpipe(t)}var h=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=t;break;case 1:l.pipes=[l.pipes,t];break;default:l.pipes.push(t)}l.pipesCount+=1,L("pipe count=%d opts=%j",l.pipesCount,n);var d=(!n||n.end!==!1)&&t!==e.stdout&&t!==e.stderr,p=d?i:o;l.endEmitted?e.nextTick(p):h.once("end",p),t.on("unpipe",r);var v=_(h);return t.on("drain",v),h.on("data",s),t._events&&t._events.error?k(t._events.error)?t._events.error.unshift(a):t._events.error=[a,t._events.error]:t.on("error",a),t.once("close",u),t.once("finish",f),t.emit("pipe",h),l.flowing||(L("pipe resume"),h.resume()),t},i.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var n=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i1){for(var n=[],r=0;r=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived=55296&&r<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var i=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),e+=t.toString(this.encoding,0,i);var i=e.length-1,r=e.charCodeAt(i);if(r>=55296&&r<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,i)}return e},f.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var n=t[t.length-e];if(1==e&&n>>5==6){this.charLength=2;break}if(e<=2&&n>>4==14){this.charLength=3;break}if(e<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=e},f.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;e+=r.slice(0,n).toString(i)}return e}},function(t,e,n){function r(t,e){this.afterTransform=function(t,n){return i(e,t,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function i(t,e,n){var r=t._transformState;r.transforming=!1;var i=r.writecb;if(!i)return t.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,u.isNullOrUndefined(n)||t.push(n),i&&i(e);var o=t._readableState;o.reading=!1,(o.needReadable||o.lengththis.offset&&(this.emit("data",e.slice(this.offset)),this.offset=e.length))};var u=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,n){!function(){function t(t){this.message=t}var n=e,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.prototype=new Error,t.prototype.name="InvalidCharacterError",n.btoa||(n.btoa=function(e){for(var n,i,o=0,s=r,a="";e.charAt(0|o)||(s="=",o%1);a+=s.charAt(63&n>>8-o%1*8)){if(i=e.charCodeAt(o+=.75),i>255)throw new t("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");n=n<<8|i}return a}),n.atob||(n.atob=function(e){if(e=e.replace(/=+$/,""),e.length%4==1)throw new t("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,o=0,s=0,a="";i=e.charAt(s++);~i&&(n=o%4?64*n+i:i,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)i=r.indexOf(i);return a})}()},function(t,e,n){var r=n(19),i=t.exports;for(var o in r)r.hasOwnProperty(o)&&(i[o]=r[o]);i.request=function(t,e){return t||(t={}),t.scheme="https",r.request.call(this,t,e)}},function(t,e,n){(function(t){function r(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function i(t,e){for(var n in t)e(t[n],n)}var o=n(42);e.createHash=n(44),e.createHmac=n(53),e.randomBytes=function(e,n){if(!n||!n.call)return new t(o(e));try{n.call(this,void 0,new t(o(e)))}catch(t){n(t)}},e.getHashes=function(){return["sha1","sha256","sha512","md5","rmd160"]};var s=n(54)(e);e.pbkdf2=s.pbkdf2,e.pbkdf2Sync=s.pbkdf2Sync,i(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman"],function(t){e[t]=function(){r("sorry,",t,"is not implemented yet")}})}).call(e,n(5).Buffer)},function(t,e,n){(function(e,r){!function(){var i=("undefined"==typeof window?e:window)||{};_crypto=i.crypto||i.msCrypto||n(43),t.exports=function(t){if(_crypto.getRandomValues){var e=new r(t);return _crypto.getRandomValues(e),e}if(_crypto.randomBytes)return _crypto.randomBytes(t);throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}}()}).call(e,function(){return this}(),n(5).Buffer)},function(t,e){},function(t,e,n){(function(e){function r(t){return function(){var n=[],r={update:function(t,r){return e.isBuffer(t)||(t=new e(t,r)),n.push(t),this},digest:function(r){var i=e.concat(n),o=t(i);return n=null,r?o.toString(r):o}};return r}}var i=n(45),o=r(n(50)),s=r(n(52));t.exports=function(t){return"md5"===t?new o:"rmd160"===t?new s:i(t)}}).call(e,n(5).Buffer)},function(t,e,n){var e=t.exports=function(t){var n=e[t];if(!n)throw new Error(t+" is not supported (we accept pull requests)");return new n},r=n(5).Buffer,i=n(46)(r);e.sha1=n(47)(r,i),e.sha256=n(48)(r,i),e.sha512=n(49)(r,i)},function(t,e){t.exports=function(t){function e(e,n){this._block=new t(e),this._finalSize=n,this._blockSize=e,this._len=0,this._s=0}return e.prototype.init=function(){this._s=0,this._len=0},e.prototype.update=function(e,n){"string"==typeof e&&(n=n||"utf8",e=new t(e,n));for(var r=this._len+=e.length,i=this._s=this._s||0,o=0,s=this._block;i=8*this._finalSize&&(this._update(this._block),this._block.fill(0)),this._block.writeInt32BE(e,this._blockSize-4);var n=this._update(this._block)||this._hash();return t?n.toString(t):n},e.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e}},function(t,e,n){var r=n(16).inherits;t.exports=function(t,e){function n(){return p.length?p.pop().init():this instanceof n?(this._w=d,e.call(this,64,56),this._h=null,void this.init()):new n}function i(t,e,n,r){return t<20?e&n|~e&r:t<40?e^n^r:t<60?e&n|e&r|n&r:e^n^r}function o(t){return t<20?1518500249:t<40?1859775393:t<60?-1894007588:-899497514}function s(t,e){return t+e|0}function a(t,e){return t<>>32-e}var u=0,f=4,c=8,h=12,l=16,d=new("undefined"==typeof Int32Array?Array:Int32Array)(80),p=[];return r(n,e),n.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,e.prototype.init.call(this),this},n.prototype._POOL=p,n.prototype._update=function(t){var e,n,r,u,f,c,h,l,d,p;e=c=this._a,n=h=this._b,r=l=this._c,u=d=this._d,f=p=this._e;for(var _=this._w,v=0;v<80;v++){var g=_[v]=v<16?t.readInt32BE(4*v):a(_[v-3]^_[v-8]^_[v-14]^_[v-16],1),y=s(s(a(e,5),i(v,n,r,u)),s(s(f,g),o(v)));f=u,u=r,r=a(n,30),n=e,e=y}this._a=s(e,c),this._b=s(n,h),this._c=s(r,l),this._d=s(u,d),this._e=s(f,p)},n.prototype._hash=function(){p.length<100&&p.push(this);var e=new t(20);return e.writeInt32BE(0|this._a,u),e.writeInt32BE(0|this._b,f),e.writeInt32BE(0|this._c,c),e.writeInt32BE(0|this._d,h),e.writeInt32BE(0|this._e,l),e},n}},function(t,e,n){var r=n(16).inherits;t.exports=function(t,e){function n(){this.init(),this._w=d,e.call(this,64,56)}function i(t,e){return t>>>e|t<<32-e}function o(t,e){return t>>>e}function s(t,e,n){return t&e^~t&n}function a(t,e,n){return t&e^t&n^e&n}function u(t){return i(t,2)^i(t,13)^i(t,22)}function f(t){return i(t,6)^i(t,11)^i(t,25)}function c(t){return i(t,7)^i(t,18)^o(t,3)}function h(t){return i(t,17)^i(t,19)^o(t,10)}var l=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],d=new Array(64);return r(n,e),n.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this._len=this._s=0,this},n.prototype._update=function(t){var e,n,r,i,o,d,p,_,v,g,y=this._w;e=0|this._a,n=0|this._b,r=0|this._c,i=0|this._d,o=0|this._e,d=0|this._f,p=0|this._g,_=0|this._h;for(var m=0;m<64;m++){var w=y[m]=m<16?t.readInt32BE(4*m):h(y[m-2])+y[m-7]+c(y[m-15])+y[m-16];v=_+f(o)+s(o,d,p)+l[m]+w,g=u(e)+a(e,n,r),_=p,p=d,d=o,o=i+v,i=r,r=n,n=e,e=v+g}this._a=e+this._a|0,this._b=n+this._b|0,this._c=r+this._c|0,this._d=i+this._d|0,this._e=o+this._e|0,this._f=d+this._f|0,this._g=p+this._g|0,this._h=_+this._h|0},n.prototype._hash=function(){var e=new t(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},n}},function(t,e,n){var r=n(16).inherits;t.exports=function(t,e){function n(){this.init(),this._w=u,e.call(this,128,112)}function i(t,e,n){return t>>>n|e<<32-n}function o(t,e,n){return t&e^~t&n}function s(t,e,n){return t&e^t&n^e&n}var a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],u=new Array(160);return r(n,e),n.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this._al=-205731576,this._bl=-2067093701,this._cl=-23791573,this._dl=1595750129,this._el=-1377402159,this._fl=725511199,this._gl=-79577749,this._hl=327033209,this._len=this._s=0,this},n.prototype._update=function(t){var e,n,r,u,f,c,h,l,d,p,_,v,g,y,m,w,b=this._w;e=0|this._a,n=0|this._b,r=0|this._c,u=0|this._d,f=0|this._e,c=0|this._f,h=0|this._g,l=0|this._h,d=0|this._al,p=0|this._bl,_=0|this._cl,v=0|this._dl,g=0|this._el,y=0|this._fl,m=0|this._gl,w=0|this._hl;for(var E=0;E<80;E++){var k,x,S=2*E;if(E<16)k=b[S]=t.readInt32BE(4*S),x=b[S+1]=t.readInt32BE(4*S+4);else{var A=b[S-30],T=b[S-30+1],R=i(A,T,1)^i(A,T,8)^A>>>7,L=i(T,A,1)^i(T,A,8)^i(T,A,7);A=b[S-4],T=b[S-4+1];var O=i(A,T,19)^i(T,A,29)^A>>>6,I=i(T,A,19)^i(A,T,29)^i(T,A,6),C=b[S-14],N=b[S-14+1],M=b[S-32],B=b[S-32+1];x=L+N,k=R+C+(x>>>0>>0?1:0),x+=I,k=k+O+(x>>>0>>0?1:0),x+=B,k=k+M+(x>>>0>>0?1:0),b[S]=k,b[S+1]=x}var D=s(e,n,r),P=s(d,p,_),j=i(e,d,28)^i(d,e,2)^i(d,e,7),U=i(d,e,28)^i(e,d,2)^i(e,d,7),z=i(f,g,14)^i(f,g,18)^i(g,f,9),F=i(g,f,14)^i(g,f,18)^i(f,g,9),H=a[S],q=a[S+1],Z=o(f,c,h),W=o(g,y,m),V=w+F,G=l+z+(V>>>0>>0?1:0);V+=W,G=G+Z+(V>>>0>>0?1:0),V+=q,G=G+H+(V>>>0>>0?1:0),V+=x,G=G+k+(V>>>0>>0?1:0);var Y=U+P,$=j+D+(Y>>>0>>0?1:0);l=h,w=m,h=c,m=y,c=f,y=g,g=v+V|0,f=u+G+(g>>>0>>0?1:0)|0,u=r,v=_,r=n,_=p,n=e,p=d,d=V+Y|0,e=G+$+(d>>>0>>0?1:0)|0}this._al=this._al+d|0,this._bl=this._bl+p|0,this._cl=this._cl+_|0,this._dl=this._dl+v|0,this._el=this._el+g|0,this._fl=this._fl+y|0,this._gl=this._gl+m|0,this._hl=this._hl+w|0,this._a=this._a+e+(this._al>>>0>>0?1:0)|0,this._b=this._b+n+(this._bl>>>0

>>0?1:0)|0,this._c=this._c+r+(this._cl>>>0<_>>>0?1:0)|0,this._d=this._d+u+(this._dl>>>0>>0?1:0)|0,this._e=this._e+f+(this._el>>>0>>0?1:0)|0,this._f=this._f+c+(this._fl>>>0>>0?1:0)|0,this._g=this._g+h+(this._gl>>>0>>0?1:0)|0,this._h=this._h+l+(this._hl>>>0>>0?1:0)|0},n.prototype._hash=function(){function e(t,e,r){n.writeInt32BE(t,r),n.writeInt32BE(e,r+4)}var n=new t(64);return e(this._a,this._al,0),e(this._b,this._bl,8),e(this._c,this._cl,16),e(this._d,this._dl,24),e(this._e,this._el,32),e(this._f,this._fl,40),e(this._g,this._gl,48),e(this._h,this._hl,56),n},n}},function(t,e,n){function r(t,e){t[e>>5]|=128<>>9<<4)+14]=e;for(var n=1732584193,r=-271733879,i=-1732584194,c=271733878,h=0;h>16)+(e>>16)+(n>>16);return r<<16|65535&n}function c(t,e){return t<>>32-e}var h=n(51);t.exports=function(t){return h.hash(t,r,16)}},function(t,e,n){(function(e){function n(t,n){if(t.length%o!==0){var r=t.length+(o-t.length%o);t=e.concat([t,s],r)}for(var i=[],a=n?t.readInt32BE:t.readInt32LE,u=0;u>>32-e}function u(t){var n=[1732584193,4023233417,2562383102,271733878,3285377520];"string"==typeof t&&(t=new e(t,"utf8"));var r=_(t),i=8*t.length,o=8*t.length;r[i>>>5]|=128<<24-i%32,r[(i+64>>>9<<4)+14]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);for(var s=0;s>>24)|4278255360&(a<<24|a>>>8)}var u=v(n);return new e(u)}t.exports=u;/** @preserve - (c) 2012 by Cédric Mesnil. All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - - 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. - */ -var f=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],c=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],h=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],l=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],d=[0,1518500249,1859775393,2400959708,2840853838],p=[1352829926,1548603684,1836072691,2053994217,0],_=function(t){for(var e=[],n=0,r=0;n>>5]|=t[n]<<24-r%32;return e},v=function(t){for(var e=[],n=0;n<32*t.length;n+=8)e.push(t[n>>>5]>>>24-n%32&255);return e},g=function(t,e,u){for(var _=0;_<16;_++){var v=u+_,g=e[v];e[v]=16711935&(g<<8|g>>>24)|4278255360&(g<<24|g>>>8)}var y,m,w,b,E,k,x,S,A,T;k=y=t[0],x=m=t[1],S=w=t[2],A=b=t[3],T=E=t[4];for(var R,_=0;_<80;_+=1)R=y+e[u+f[_]]|0,R+=_<16?n(m,w,b)+d[0]:_<32?r(m,w,b)+d[1]:_<48?i(m,w,b)+d[2]:_<64?o(m,w,b)+d[3]:s(m,w,b)+d[4],R|=0,R=a(R,h[_]),R=R+E|0,y=E,E=b,b=a(w,10),w=m,m=R,R=k+e[u+c[_]]|0,R+=_<16?s(x,S,A)+p[0]:_<32?o(x,S,A)+p[1]:_<48?i(x,S,A)+p[2]:_<64?r(x,S,A)+p[3]:n(x,S,A)+p[4],R|=0,R=a(R,l[_]),R=R+T|0,k=T,T=A,A=a(S,10),S=x,x=R;R=t[1]+w+A|0,t[1]=t[2]+b+T|0,t[2]=t[3]+E+k|0,t[3]=t[4]+y+x|0,t[4]=t[0]+m+S|0,t[0]=R}}).call(e,n(5).Buffer)},function(t,e,n){(function(e){function r(t,n){if(!(this instanceof r))return new r(t,n);this._opad=u,this._alg=t;var s="sha512"===t?128:64;n=this._key=e.isBuffer(n)?n:new e(n),n.length>s?n=i(t).update(n).digest():n.length(Math.pow(2,32)-1)*a))throw new TypeError("keylen exceeds maximum length");p.copy(f,0,0,a);for(var _=1;_0)throw r.length>1?new Error("options "+r.slice(0,r.length-1).join(", ")+" and "+r[r.length-1]+" must be defined"):new Error("option "+r[0]+" must be defined")}return Object.keys(t).forEach(function(n){n in e&&(e[n]=t[n])}),this},this.copy=function(e){var r={};return Object.keys(t).forEach(function(t){e.indexOf(t)!==-1&&(r[t]=n[t])}),r},this.read=function(t,e){if("function"==typeof e){var n=this;i.readFile(t,function(t,r){if(t)return e(t);var i=JSON.parse(r);n.merge(i),e()})}else{var r=JSON.parse(i.readFileSync(t));this.merge(r)}return this},this.isDefined=function(t){return"undefined"!=typeof n[t]},this.isDefinedAndNonNull=function(t){return"undefined"!=typeof n[t]&&null!==n[t]},Object.freeze(n),Object.freeze(this)}/*! - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -var i=n(58);t.exports=r},function(t,e){},function(t,e,n){(function(e){function r(t,e){if(this instanceof r==!1)throw new TypeError("Classes can't be function-called");u.EventEmitter.call(this),this._socket=t,this.extensions=e||{},this.firstFragment=!0,this.compress=!1,this.messageHandlers=[],this.processing=!1}function i(t,e){this[e]=(65280&t)>>8,this[e+1]=255&t}function o(t,e){this[e]=(4278190080&t)>>24,this[e+1]=(16711680&t)>>16,this[e+2]=(65280&t)>>8,this[e+3]=255&t}function s(t){for(var n=new Uint8Array(t.buffer||t),r=t.byteLength||t.length,i=t.byteOffset||0,o=new e(r),s=0;s - * MIT Licensed - */ -var u=n(20),f=n(16),c=(u.EventEmitter,n(60)),h=n(61).BufferUtil,l=n(63);f.inherits(r,u.EventEmitter),r.prototype.close=function(t,n,r,o){if("undefined"!=typeof t&&("number"!=typeof t||!c.isValidErrorCode(t)))throw new Error("first argument must be a valid error code number");t=t||1e3;var s=new e(2+(n?e.byteLength(n):0));i.call(s,t,0),s.length>2&&s.write(n,2);var a=this;this.messageHandlers.push(function(t){a.frameAndSend(8,s,!0,r),t(),"function"==typeof o&&o()}),this.flush()},r.prototype.ping=function(t,e){var n=e&&e.mask,r=this;this.messageHandlers.push(function(e){r.frameAndSend(9,t||"",!0,n),e()}),this.flush()},r.prototype.pong=function(t,e){var n=e&&e.mask,r=this;this.messageHandlers.push(function(e){r.frameAndSend(10,t||"",!0,n),e()}),this.flush()},r.prototype.send=function(t,e,n){var r=!e||e.fin!==!1,i=e&&e.mask,o=e&&e.compress,s=e&&e.binary?2:1;this.firstFragment===!1?(s=0,o=!1):(this.firstFragment=!1,this.compress=o),r&&(this.firstFragment=!0);var a=this.compress,u=this;this.messageHandlers.push(function(e){u.applyExtensions(t,r,a,function(t,a){return t?void("function"==typeof n?n(t):u.emit("error",t)):(u.frameAndSend(s,a,r,i,o,n),void e())})}),this.flush()},r.prototype.frameAndSend=function(t,n,r,u,f,c){var l=!1;if(n){e.isBuffer(n)||(l=!0,!n||"undefined"==typeof n.byteLength&&"undefined"==typeof n.buffer?("number"==typeof n&&(n=n.toString()),n=new e(n)):n=s(n));var d=n.length,p=u?6:2,_=d;d>=65536?(p+=8,_=127):d>125&&(p+=2,_=126);var v=d<32768||u&&!l,g=v?d+p:p,y=new e(g);switch(y[0]=r?128|t:t,f&&(y[0]|=64),_){case 126:i.call(y,d,2);break;case 127:o.call(y,0,2),o.call(y,d,6)}if(u){y[1]=128|_;var m=a();if(y[p-4]=m[0],y[p-3]=m[1],y[p-2]=m[2],y[p-1]=m[3],v){h.mask(n,m,y,p,d);try{this._socket.write(y,"binary",c)}catch(t){"function"==typeof c?c(t):this.emit("error",t)}}else{h.mask(n,m,n,0,d);try{this._socket.write(y,"binary"),this._socket.write(n,"binary",c)}catch(t){"function"==typeof c?c(t):this.emit("error",t)}}}else if(y[1]=_,v){n.copy(y,p);try{this._socket.write(y,"binary",c)}catch(t){"function"==typeof c?c(t):this.emit("error",t)}}else try{this._socket.write(y,"binary"),this._socket.write(n,"binary",c)}catch(t){"function"==typeof c?c(t):this.emit("error",t)}}else try{this._socket.write(new e([t|(r?128:0),0|(u?128:0)].concat(u?[0,0,0,0]:[])),"binary",c)}catch(t){"function"==typeof c?c(t):this.emit("error",t)}},r.prototype.flush=function(){if(!this.processing){var t=this.messageHandlers.shift();if(t){this.processing=!0;var e=this;t(function(){e.processing=!1,e.flush()})}}},r.prototype.applyExtensions=function(t,e,n,r){n&&t?((t.buffer||t)instanceof ArrayBuffer&&(t=s(t)),this.extensions[l.extensionName].compress(t,e,r)):r(null,t)},t.exports=r}).call(e,n(5).Buffer)},function(t,e){/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -t.exports={isValidErrorCode:function(t){return t>=1e3&&t<=1011&&1004!=t&&1005!=t&&1006!=t||t>=3e3&&t<=4999},1e3:"normal",1001:"going away",1002:"protocol error",1003:"unsupported data",1004:"reserved",1005:"reserved for extensions",1006:"reserved for extensions",1007:"inconsistent or invalid data",1008:"policy violation",1009:"message too big",1010:"extension handshake missing",1011:"an unexpected condition prevented the request from being fulfilled"}},function(t,e,n){"use strict";/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -try{t.exports=n(!function(){var t=new Error('Cannot find module "bufferutil"');throw t.code="MODULE_NOT_FOUND",t}())}catch(e){t.exports=n(62)}},function(t,e){/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -e.BufferUtil={merge:function(t,e){for(var n=0,r=0,i=e.length;rt.server_max_window_bits)&&("number"!=typeof this._options.clientMaxWindowBits||t.client_max_window_bits))return(this._options.serverNoContextTakeover||t.server_no_context_takeover)&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.clientNoContextTakeover!==!1&&t.client_no_context_takeover&&(e.client_no_context_takeover=!0),"number"==typeof this._options.serverMaxWindowBits?e.server_max_window_bits=this._options.serverMaxWindowBits:"number"==typeof t.server_max_window_bits&&(e.server_max_window_bits=t.server_max_window_bits),"number"==typeof this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits!==!1&&"number"==typeof t.client_max_window_bits&&(e.client_max_window_bits=t.client_max_window_bits),!0},this);if(!n)throw new Error("Doesn't support the offered configuration");return e},r.prototype.acceptAsClient=function(t){var e=t[0];if(null!=this._options.clientNoContextTakeover&&this._options.clientNoContextTakeover===!1&&e.client_no_context_takeover)throw new Error('Invalid value for "client_no_context_takeover"');if(null!=this._options.clientMaxWindowBits){if(this._options.clientMaxWindowBits===!1&&e.client_max_window_bits)throw new Error('Invalid value for "client_max_window_bits"');if("number"==typeof this._options.clientMaxWindowBits&&(!e.client_max_window_bits||e.client_max_window_bits>this._options.clientMaxWindowBits))throw new Error('Invalid value for "client_max_window_bits"')}return e},r.prototype.normalizeParams=function(t){return t.map(function(t){return Object.keys(t).forEach(function(e){var n=t[e];if(n.length>1)throw new Error("Multiple extension parameters for "+e);switch(n=n[0],e){case"server_no_context_takeover":case"client_no_context_takeover":if(n!==!0)throw new Error("invalid extension parameter value for "+e+" ("+n+")");t[e]=!0;break;case"server_max_window_bits":case"client_max_window_bits":if("string"==typeof n&&(n=parseInt(n,10),!~o.indexOf(n)))throw new Error("invalid extension parameter value for "+e+" ("+n+")");if(!this._isServer&&n===!0)throw new Error("Missing extension parameter value for "+e);t[e]=n;break;default:throw new Error("Not defined extension parameter ("+e+")")}},this),t},this)},r.prototype.decompress=function(t,n,r){function o(t){u(),r(t)}function a(t){if(void 0!==h._maxPayload&&null!==h._maxPayload&&h._maxPayload>0&&(d+=t.length,d>h._maxPayload)){l=[],u();var e={type:1009};return void r(e)}l.push(t)}function u(){h._inflate&&(h._inflate.removeListener("error",o),h._inflate.removeListener("data",a),h._inflate.writeInProgress=!1,(n&&h.params[f+"_no_context_takeover"]||h._inflate.pendingClose)&&(h._inflate.close&&h._inflate.close(),h._inflate=null))}var f=this._isServer?"client":"server";if(!this._inflate){var c=this.params[f+"_max_window_bits"];this._inflate=i.createInflateRaw({windowBits:"number"==typeof c?c:s})}this._inflate.writeInProgress=!0;var h=this,l=[],d=0;this._inflate.on("error",o).on("data",a),this._inflate.write(t),n&&this._inflate.write(new e([0,0,255,255])),this._inflate.flush(function(){u(),r(null,e.concat(l))})},r.prototype.compress=function(t,n,r){function o(t){f(),r(t)}function u(t){d.push(t)}function f(){l._deflate&&(l._deflate.removeListener("error",o),l._deflate.removeListener("data",u),l._deflate.writeInProgress=!1,(n&&l.params[c+"_no_context_takeover"]||l._deflate.pendingClose)&&(l._deflate.close&&l._deflate.close(),l._deflate=null))}var c=this._isServer?"server":"client";if(!this._deflate){var h=this.params[c+"_max_window_bits"];this._deflate=i.createDeflateRaw({flush:i.Z_SYNC_FLUSH,windowBits:"number"==typeof h?h:s,memLevel:this._options.memLevel||a})}this._deflate.writeInProgress=!0;var l=this,d=[];this._deflate.on("error",o).on("data",u),this._deflate.write(t),this._deflate.flush(function(){f();var t=e.concat(d);n&&(t=t.slice(0,t.length-4)),r(null,t)})},t.exports=r}).call(e,n(5).Buffer)},function(t,e,n){(function(t,r){function i(e,n,r){function i(){for(var t;null!==(t=e.read());)a.push(t),u+=t.length;e.once("readable",i)}function o(t){e.removeListener("end",s),e.removeListener("readable",i),r(t)}function s(){var n=t.concat(a,u);a=[],r(null,n),e.close()}var a=[],u=0;e.on("error",o),e.on("end",s),e.end(n),i()}function o(e,n){if("string"==typeof n&&(n=new t(n)),!t.isBuffer(n))throw new TypeError("Not a string or buffer");var r=_.Z_FINISH;return e._processChunk(n,r)}function s(t){return this instanceof s?void d.call(this,t,_.DEFLATE):new s(t)}function a(t){return this instanceof a?void d.call(this,t,_.INFLATE):new a(t)}function u(t){return this instanceof u?void d.call(this,t,_.GZIP):new u(t)}function f(t){return this instanceof f?void d.call(this,t,_.GUNZIP):new f(t)}function c(t){return this instanceof c?void d.call(this,t,_.DEFLATERAW):new c(t)}function h(t){return this instanceof h?void d.call(this,t,_.INFLATERAW):new h(t)}function l(t){return this instanceof l?void d.call(this,t,_.UNZIP):new l(t)}function d(n,r){if(this._opts=n=n||{},this._chunkSize=n.chunkSize||e.Z_DEFAULT_CHUNK,p.call(this,n),n.flush&&n.flush!==_.Z_NO_FLUSH&&n.flush!==_.Z_PARTIAL_FLUSH&&n.flush!==_.Z_SYNC_FLUSH&&n.flush!==_.Z_FULL_FLUSH&&n.flush!==_.Z_FINISH&&n.flush!==_.Z_BLOCK)throw new Error("Invalid flush flag: "+n.flush);if(this._flushFlag=n.flush||_.Z_NO_FLUSH,n.chunkSize&&(n.chunkSizee.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+n.chunkSize);if(n.windowBits&&(n.windowBitse.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+n.windowBits);if(n.level&&(n.levele.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+n.level);if(n.memLevel&&(n.memLevele.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+n.memLevel);if(n.strategy&&n.strategy!=e.Z_FILTERED&&n.strategy!=e.Z_HUFFMAN_ONLY&&n.strategy!=e.Z_RLE&&n.strategy!=e.Z_FIXED&&n.strategy!=e.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+n.strategy);if(n.dictionary&&!t.isBuffer(n.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new _.Zlib(r);var i=this;this._hadError=!1,this._binding.onerror=function(t,n){i._binding=null,i._hadError=!0;var r=new Error(t);r.errno=n,r.code=e.codes[n],i.emit("error",r)};var o=e.Z_DEFAULT_COMPRESSION;"number"==typeof n.level&&(o=n.level);var s=e.Z_DEFAULT_STRATEGY;"number"==typeof n.strategy&&(s=n.strategy),this._binding.init(n.windowBits||e.Z_DEFAULT_WINDOWBITS,o,n.memLevel||e.Z_DEFAULT_MEMLEVEL,s,n.dictionary),this._buffer=new t(this._chunkSize),this._offset=0,this._closed=!1,this._level=o,this._strategy=s,this.once("end",this.close)}var p=n(65),_=n(72),v=n(16),g=n(84).ok;_.Z_MIN_WINDOWBITS=8,_.Z_MAX_WINDOWBITS=15,_.Z_DEFAULT_WINDOWBITS=15,_.Z_MIN_CHUNK=64,_.Z_MAX_CHUNK=1/0,_.Z_DEFAULT_CHUNK=16384,_.Z_MIN_MEMLEVEL=1,_.Z_MAX_MEMLEVEL=9,_.Z_DEFAULT_MEMLEVEL=8,_.Z_MIN_LEVEL=-1,_.Z_MAX_LEVEL=9,_.Z_DEFAULT_LEVEL=_.Z_DEFAULT_COMPRESSION,Object.keys(_).forEach(function(t){t.match(/^Z/)&&(e[t]=_[t])}),e.codes={Z_OK:_.Z_OK,Z_STREAM_END:_.Z_STREAM_END,Z_NEED_DICT:_.Z_NEED_DICT,Z_ERRNO:_.Z_ERRNO,Z_STREAM_ERROR:_.Z_STREAM_ERROR,Z_DATA_ERROR:_.Z_DATA_ERROR,Z_MEM_ERROR:_.Z_MEM_ERROR,Z_BUF_ERROR:_.Z_BUF_ERROR,Z_VERSION_ERROR:_.Z_VERSION_ERROR},Object.keys(e.codes).forEach(function(t){e.codes[e.codes[t]]=t}),e.Deflate=s,e.Inflate=a,e.Gzip=u,e.Gunzip=f,e.DeflateRaw=c,e.InflateRaw=h,e.Unzip=l,e.createDeflate=function(t){return new s(t)},e.createInflate=function(t){return new a(t)},e.createDeflateRaw=function(t){return new c(t)},e.createInflateRaw=function(t){return new h(t)},e.createGzip=function(t){return new u(t)},e.createGunzip=function(t){return new f(t)},e.createUnzip=function(t){return new l(t)},e.deflate=function(t,e,n){return"function"==typeof e&&(n=e,e={}),i(new s(e),t,n)},e.deflateSync=function(t,e){return o(new s(e),t)},e.gzip=function(t,e,n){return"function"==typeof e&&(n=e,e={}),i(new u(e),t,n)},e.gzipSync=function(t,e){return o(new u(e),t)},e.deflateRaw=function(t,e,n){return"function"==typeof e&&(n=e,e={}),i(new c(e),t,n)},e.deflateRawSync=function(t,e){return o(new c(e),t)},e.unzip=function(t,e,n){return"function"==typeof e&&(n=e,e={}),i(new l(e),t,n)},e.unzipSync=function(t,e){return o(new l(e),t)},e.inflate=function(t,e,n){return"function"==typeof e&&(n=e,e={}),i(new a(e),t,n)},e.inflateSync=function(t,e){return o(new a(e),t)},e.gunzip=function(t,e,n){return"function"==typeof e&&(n=e,e={}),i(new f(e),t,n)},e.gunzipSync=function(t,e){return o(new f(e),t)},e.inflateRaw=function(t,e,n){return"function"==typeof e&&(n=e,e={}),i(new h(e),t,n)},e.inflateRawSync=function(t,e){return o(new h(e),t)},v.inherits(d,p),d.prototype.params=function(t,n,i){if(te.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+t);if(n!=e.Z_FILTERED&&n!=e.Z_HUFFMAN_ONLY&&n!=e.Z_RLE&&n!=e.Z_FIXED&&n!=e.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+n);if(this._level!==t||this._strategy!==n){var o=this;this.flush(_.Z_SYNC_FLUSH,function(){o._binding.params(t,n),o._hadError||(o._level=t,o._strategy=n,i&&i())})}else r.nextTick(i)},d.prototype.reset=function(){return this._binding.reset()},d.prototype._flush=function(e){this._transform(new t(0),"",e)},d.prototype.flush=function(e,n){var i=this._writableState;if(("function"==typeof e||void 0===e&&!n)&&(n=e,e=_.Z_FULL_FLUSH),i.ended)n&&r.nextTick(n);else if(i.ending)n&&this.once("end",n);else if(i.needDrain){var o=this;this.once("drain",function(){o.flush(n)})}else this._flushFlag=e,this.write(new t(0),"",n)},d.prototype.close=function(t){if(t&&r.nextTick(t),!this._closed){this._closed=!0,this._binding.close();var e=this;r.nextTick(function(){e.emit("close")})}},d.prototype._transform=function(e,n,r){var i,o=this._writableState,s=o.ending||o.ended,a=s&&(!e||o.length===e.length);if(null===!e&&!t.isBuffer(e))return r(new Error("invalid input"));a?i=_.Z_FINISH:(i=this._flushFlag,e.length>=o.length&&(this._flushFlag=this._opts.flush||_.Z_NO_FLUSH));this._processChunk(e,i,r)},d.prototype._processChunk=function(e,n,r){function i(c,d){if(!u._hadError){var p=s-d;if(g(p>=0,"have should not go down"),p>0){var _=u._buffer.slice(u._offset,u._offset+p);u._offset+=p,f?u.push(_):(h.push(_),l+=_.length)}if((0===d||u._offset>=u._chunkSize)&&(s=u._chunkSize,u._offset=0,u._buffer=new t(u._chunkSize)),0===d){if(a+=o-c,o=c,!f)return!0;var v=u._binding.write(n,e,a,o,u._buffer,u._offset,u._chunkSize);return v.callback=i,void(v.buffer=e)}return!!f&&void r()}}var o=e&&e.length,s=this._chunkSize-this._offset,a=0,u=this,f="function"==typeof r;if(!f){var c,h=[],l=0;this.on("error",function(t){c=t});do var d=this._binding.writeSync(n,e,a,o,this._buffer,this._offset,s);while(!this._hadError&&i(d[0],d[1]));if(this._hadError)throw c;var p=t.concat(h,l);return this.close(),p}var _=this._binding.write(n,e,a,o,this._buffer,this._offset,s);_.buffer=e,_.callback=i},v.inherits(s,d),v.inherits(a,d),v.inherits(u,d),v.inherits(f,d),v.inherits(c,d),v.inherits(h,d),v.inherits(l,d)}).call(e,n(5).Buffer,n(9))},function(t,e,n){t.exports=n(66)},function(t,e,n){function r(t,e){this.afterTransform=function(t,n){return i(e,t,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function i(t,e,n){var r=t._transformState;r.transforming=!1;var i=r.writecb;if(!i)return t.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,u.isNullOrUndefined(n)||t.push(n),i&&i(e);var o=t._readableState;o.reading=!1,(o.needReadable||o.length0)if(e.ended&&!i){var a=new Error("stream.push() after EOF");t.emit("error",a)}else if(e.endEmitted&&i){var a=new Error("stream.unshift() after end event");t.emit("error",a)}else!e.decoder||i||r||(n=e.decoder.write(n)),i||(e.reading=!1),e.flowing&&0===e.length&&!e.sync?(t.emit("data",n),t.read(0)):(e.length+=e.objectMode?1:n.length,i?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&h(t)),d(t,e);else i||(e.reading=!1);return s(e)}function s(t){return!t.ended&&(t.needReadable||t.length=O)t=O;else{t--;for(var e=1;e<32;e<<=1)t|=t>>e;t++}return t}function u(t,e){return 0===e.length&&e.ended?0:e.objectMode?0===t?0:1:isNaN(t)||T.isNull(t)?e.flowing&&e.buffer.length?e.buffer[0].length:e.length:t<=0?0:(t>e.highWaterMark&&(e.highWaterMark=a(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function f(t,e){var n=null;return T.isBuffer(e)||T.isString(e)||T.isNullOrUndefined(e)||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function c(t,e){if(e.decoder&&!e.ended){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,h(t)}function h(t){var n=t._readableState;n.needReadable=!1,n.emittedReadable||(L("emitReadable",n.flowing),n.emittedReadable=!0,n.sync?e.nextTick(function(){l(t)}):l(t))}function l(t){L("emit readable"),t.emit("readable"),y(t)}function d(t,n){n.readingMore||(n.readingMore=!0,e.nextTick(function(){p(t,n)}))}function p(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=i)n=o?r.join(""):x.concat(r,i),r.length=0;else if(t0)throw new Error("endReadable called on non-empty stream");n.endEmitted||(n.ended=!0,e.nextTick(function(){n.endEmitted||0!==n.length||(n.endEmitted=!0,t.readable=!1,t.emit("end"))}))}function b(t,e){for(var n=0,r=t.length;n0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return L("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?w(this):h(this),null;if(t=u(t,e),0===t&&e.ended)return 0===e.length&&w(this),null;var r=e.needReadable;L("need readable",r),(0===e.length||e.length-t0?m(t,e):null,T.isNull(i)&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),n!==t&&e.ended&&0===e.length&&w(this),T.isNull(i)||this.emit("data",i),i},i.prototype._read=function(t){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(t,n){function r(t){L("onunpipe"),t===h&&o()}function i(){L("onend"),t.end()}function o(){L("cleanup"),t.removeListener("close",u),t.removeListener("finish",f),t.removeListener("drain",v),t.removeListener("error",a),t.removeListener("unpipe",r),h.removeListener("end",i),h.removeListener("end",o),h.removeListener("data",s),!l.awaitDrain||t._writableState&&!t._writableState.needDrain||v()}function s(e){L("ondata");var n=t.write(e);!1===n&&(L("false write response, pause",h._readableState.awaitDrain),h._readableState.awaitDrain++,h.pause())}function a(e){L("onerror",e),c(),t.removeListener("error",a),0===S.listenerCount(t,"error")&&t.emit("error",e)}function u(){t.removeListener("finish",f),c()}function f(){L("onfinish"),t.removeListener("close",u),c()}function c(){L("unpipe"),h.unpipe(t)}var h=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=t;break;case 1:l.pipes=[l.pipes,t];break;default:l.pipes.push(t)}l.pipesCount+=1,L("pipe count=%d opts=%j",l.pipesCount,n);var d=(!n||n.end!==!1)&&t!==e.stdout&&t!==e.stderr,p=d?i:o;l.endEmitted?e.nextTick(p):h.once("end",p),t.on("unpipe",r);var v=_(h);return t.on("drain",v),h.on("data",s),t._events&&t._events.error?k(t._events.error)?t._events.error.unshift(a):t._events.error=[a,t._events.error]:t.on("error",a),t.once("close",u),t.once("finish",f),t.emit("pipe",h),l.flowing||(L("pipe resume"),h.resume()),t},i.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var n=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i1){for(var n=[],r=0;re.UNZIP)throw new TypeError("Bad argument");this.mode=t,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function o(t,e){for(var n=0;n4?9:0)}function o(t){for(var e=t.length;--e>=0;)t[e]=0}function s(t){var e=t.state,n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(O.arraySet(t.output,e.pending_buf,e.pending_out,n,t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))}function a(t,e){I._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,s(t.strm)}function u(t,e){t.pending_buf[t.pending++]=e}function f(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function c(t,e,n,r){var i=t.avail_in;return i>r&&(i=r),0===i?0:(t.avail_in-=i,O.arraySet(e,t.input,t.next_in,i,n),1===t.state.wrap?t.adler=C(t.adler,e,i,n):2===t.state.wrap&&(t.adler=N(t.adler,e,i,n)),t.next_in+=i,t.total_in+=i,i)}function h(t,e){var n,r,i=t.max_chain_length,o=t.strstart,s=t.prev_length,a=t.nice_match,u=t.strstart>t.w_size-ht?t.strstart-(t.w_size-ht):0,f=t.window,c=t.w_mask,h=t.prev,l=t.strstart+ct,d=f[o+s-1],p=f[o+s];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do if(n=e,f[n+s]===p&&f[n+s-1]===d&&f[n]===f[o]&&f[++n]===f[o+1]){o+=2,n++;do;while(f[++o]===f[++n]&&f[++o]===f[++n]&&f[++o]===f[++n]&&f[++o]===f[++n]&&f[++o]===f[++n]&&f[++o]===f[++n]&&f[++o]===f[++n]&&f[++o]===f[++n]&&os){if(t.match_start=e,s=r,r>=a)break;d=f[o+s-1],p=f[o+s]}}while((e=h[e&c])>u&&0!==--i);return s<=t.lookahead?s:t.lookahead}function l(t){var e,n,r,i,o,s=t.w_size;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=s+(s-ht)){O.arraySet(t.window,t.window,s,s,0),t.match_start-=s,t.strstart-=s,t.block_start-=s,n=t.hash_size,e=n;do r=t.head[--e],t.head[e]=r>=s?r-s:0;while(--n);n=s,e=n;do r=t.prev[--e],t.prev[e]=r>=s?r-s:0;while(--n);i+=s}if(0===t.strm.avail_in)break;if(n=c(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.lookahead+t.insert>=ft)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=(t.ins_h<t.pending_buf_size-5&&(n=t.pending_buf_size-5);;){if(t.lookahead<=1){if(l(t),0===t.lookahead&&e===B)return wt;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var r=t.block_start+n;if((0===t.strstart||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,a(t,!1),0===t.strm.avail_out))return wt;if(t.strstart-t.block_start>=t.w_size-ht&&(a(t,!1),0===t.strm.avail_out))return wt}return t.insert=0,e===j?(a(t,!0),0===t.strm.avail_out?Et:kt):t.strstart>t.block_start&&(a(t,!1),0===t.strm.avail_out)?wt:wt}function p(t,e){for(var n,r;;){if(t.lookahead=ft&&(t.ins_h=(t.ins_h<=ft)if(r=I._tr_tally(t,t.strstart-t.match_start,t.match_length-ft),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=ft){t.match_length--;do t.strstart++,t.ins_h=(t.ins_h<=ft&&(t.ins_h=(t.ins_h<4096)&&(t.match_length=ft-1)),t.prev_length>=ft&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-ft,r=I._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-ft),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=i&&(t.ins_h=(t.ins_h<=ft&&t.strstart>0&&(i=t.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){o=t.strstart+ct;do;while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&it.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=ft?(n=I._tr_tally(t,1,t.match_length-ft),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=I._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(a(t,!1),0===t.strm.avail_out))return wt}return t.insert=0,e===j?(a(t,!0),0===t.strm.avail_out?Et:kt):t.last_lit&&(a(t,!1),0===t.strm.avail_out)?wt:bt}function g(t,e){for(var n;;){if(0===t.lookahead&&(l(t),0===t.lookahead)){if(e===B)return wt;break}if(t.match_length=0,n=I._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(a(t,!1),0===t.strm.avail_out))return wt}return t.insert=0,e===j?(a(t,!0),0===t.strm.avail_out?Et:kt):t.last_lit&&(a(t,!1),0===t.strm.avail_out)?wt:bt}function y(t,e,n,r,i){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=r,this.func=i}function m(t){t.window_size=2*t.w_size,o(t.head),t.max_lazy_match=L[t.level].max_lazy,t.good_match=L[t.level].good_length,t.nice_match=L[t.level].nice_length,t.max_chain_length=L[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=ft-1,t.match_available=0,t.ins_h=0}function w(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=J,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new O.Buf16(2*at),this.dyn_dtree=new O.Buf16(2*(2*ot+1)),this.bl_tree=new O.Buf16(2*(2*st+1)),o(this.dyn_ltree),o(this.dyn_dtree),o(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new O.Buf16(ut+1),this.heap=new O.Buf16(2*it+1),o(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new O.Buf16(2*it+1),o(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function b(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=X,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?dt:yt,t.adler=2===e.wrap?0:1,e.last_flush=B,I._tr_init(e),z):r(t,H)}function E(t){var e=b(t);return e===z&&m(t.state),e}function k(t,e){return t&&t.state?2!==t.state.wrap?H:(t.state.gzhead=e,z):H}function x(t,e,n,i,o,s){if(!t)return H;var a=1;if(e===W&&(e=6),i<0?(a=0,i=-i):i>15&&(a=2,i-=16),o<1||o>Q||n!==J||i<8||i>15||e<0||e>9||s<0||s>$)return r(t,H);8===i&&(i=9);var u=new w;return t.state=u,u.strm=t,u.wrap=a,u.gzhead=null,u.w_bits=i,u.w_size=1<U||e<0)return t?r(t,H):H;if(a=t.state,!t.output||!t.input&&0!==t.avail_in||a.status===mt&&e!==j)return r(t,0===t.avail_out?Z:H);if(a.strm=t,n=a.last_flush,a.last_flush=e,a.status===dt)if(2===a.wrap)t.adler=0,u(a,31),u(a,139),u(a,8),a.gzhead?(u(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),u(a,255&a.gzhead.time),u(a,a.gzhead.time>>8&255),u(a,a.gzhead.time>>16&255),u(a,a.gzhead.time>>24&255),u(a,9===a.level?2:a.strategy>=G||a.level<2?4:0),u(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(u(a,255&a.gzhead.extra.length),u(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(t.adler=N(t.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=pt):(u(a,0),u(a,0),u(a,0),u(a,0),u(a,0),u(a,9===a.level?2:a.strategy>=G||a.level<2?4:0),u(a,xt),a.status=yt);else{var l=J+(a.w_bits-8<<4)<<8,d=-1;d=a.strategy>=G||a.level<2?0:a.level<6?1:6===a.level?2:3,l|=d<<6,0!==a.strstart&&(l|=lt),l+=31-l%31,a.status=yt,f(a,l),0!==a.strstart&&(f(a,t.adler>>>16),f(a,65535&t.adler)),t.adler=1}if(a.status===pt)if(a.gzhead.extra){for(c=a.pending;a.gzindex<(65535&a.gzhead.extra.length)&&(a.pending!==a.pending_buf_size||(a.gzhead.hcrc&&a.pending>c&&(t.adler=N(t.adler,a.pending_buf,a.pending-c,c)),s(t),c=a.pending,a.pending!==a.pending_buf_size));)u(a,255&a.gzhead.extra[a.gzindex]),a.gzindex++;a.gzhead.hcrc&&a.pending>c&&(t.adler=N(t.adler,a.pending_buf,a.pending-c,c)),a.gzindex===a.gzhead.extra.length&&(a.gzindex=0,a.status=_t)}else a.status=_t;if(a.status===_t)if(a.gzhead.name){c=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>c&&(t.adler=N(t.adler,a.pending_buf,a.pending-c,c)),s(t),c=a.pending,a.pending===a.pending_buf_size)){h=1;break}h=a.gzindexc&&(t.adler=N(t.adler,a.pending_buf,a.pending-c,c)),0===h&&(a.gzindex=0,a.status=vt)}else a.status=vt;if(a.status===vt)if(a.gzhead.comment){c=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>c&&(t.adler=N(t.adler,a.pending_buf,a.pending-c,c)),s(t),c=a.pending,a.pending===a.pending_buf_size)){h=1;break}h=a.gzindexc&&(t.adler=N(t.adler,a.pending_buf,a.pending-c,c)),0===h&&(a.status=gt)}else a.status=gt;if(a.status===gt&&(a.gzhead.hcrc?(a.pending+2>a.pending_buf_size&&s(t),a.pending+2<=a.pending_buf_size&&(u(a,255&t.adler),u(a,t.adler>>8&255),t.adler=0,a.status=yt)):a.status=yt),0!==a.pending){if(s(t),0===t.avail_out)return a.last_flush=-1,z}else if(0===t.avail_in&&i(e)<=i(n)&&e!==j)return r(t,Z);if(a.status===mt&&0!==t.avail_in)return r(t,Z);if(0!==t.avail_in||0!==a.lookahead||e!==B&&a.status!==mt){var p=a.strategy===G?g(a,e):a.strategy===Y?v(a,e):L[a.level].func(a,e);if(p!==Et&&p!==kt||(a.status=mt),p===wt||p===Et)return 0===t.avail_out&&(a.last_flush=-1),z;if(p===bt&&(e===D?I._tr_align(a):e!==U&&(I._tr_stored_block(a,0,0,!1),e===P&&(o(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),s(t),0===t.avail_out))return a.last_flush=-1,z}return e!==j?z:a.wrap<=0?F:(2===a.wrap?(u(a,255&t.adler),u(a,t.adler>>8&255),u(a,t.adler>>16&255),u(a,t.adler>>24&255),u(a,255&t.total_in),u(a,t.total_in>>8&255),u(a,t.total_in>>16&255),u(a,t.total_in>>24&255)):(f(a,t.adler>>>16),f(a,65535&t.adler)),s(t),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?z:F)}function T(t){var e;return t&&t.state?(e=t.state.status,e!==dt&&e!==pt&&e!==_t&&e!==vt&&e!==gt&&e!==yt&&e!==mt?r(t,H):(t.state=null,e===yt?r(t,q):z)):H}function R(t,e){var n,r,i,s,a,u,f,c,h=e.length;if(!t||!t.state)return H;if(n=t.state,s=n.wrap,2===s||1===s&&n.status!==dt||n.lookahead)return H;for(1===s&&(t.adler=C(t.adler,e,h,0)),n.wrap=0,h>=n.w_size&&(0===s&&(o(n.head),n.strstart=0,n.block_start=0,n.insert=0),c=new O.Buf8(n.w_size),O.arraySet(c,e,h-n.w_size,n.w_size,0),e=c,h=n.w_size),a=t.avail_in,u=t.next_in,f=t.input,t.avail_in=h,t.next_in=0,t.input=e,l(n);n.lookahead>=ft;){r=n.strstart,i=n.lookahead-(ft-1);do n.ins_h=(n.ins_h<=0;)t[e]=0}function i(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=t&&t.length}function o(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function s(t){return t<256?ut[t]:ut[256+(t>>>7)]}function a(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function u(t,e,n){t.bi_valid>$-n?(t.bi_buf|=e<>$-t.bi_valid,t.bi_valid+=n-$):(t.bi_buf|=e<>>=1,n<<=1;while(--e>0);return n>>>1}function h(t){16===t.bi_valid?(a(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}function l(t,e){var n,r,i,o,s,a,u=e.dyn_tree,f=e.max_code,c=e.stat_desc.static_tree,h=e.stat_desc.has_stree,l=e.stat_desc.extra_bits,d=e.stat_desc.extra_base,p=e.stat_desc.max_length,_=0;for(o=0;o<=Y;o++)t.bl_count[o]=0;for(u[2*t.heap[t.heap_max]+1]=0,n=t.heap_max+1;np&&(o=p,_++),u[2*r+1]=o,r>f||(t.bl_count[o]++,s=0,r>=d&&(s=l[r-d]),a=u[2*r],t.opt_len+=a*(o+s),h&&(t.static_len+=a*(c[2*r+1]+s)));if(0!==_){do{for(o=p-1;0===t.bl_count[o];)o--;t.bl_count[o]--,t.bl_count[o+1]+=2,t.bl_count[p]--,_-=2}while(_>0);for(o=p;0!==o;o--)for(r=t.bl_count[o];0!==r;)i=t.heap[--n],i>f||(u[2*i+1]!==o&&(t.opt_len+=(o-u[2*i+1])*u[2*i],u[2*i+1]=o),r--)}}function d(t,e,n){var r,i,o=new Array(Y+1),s=0;for(r=1;r<=Y;r++)o[r]=s=s+n[r-1]<<1;for(i=0;i<=e;i++){var a=t[2*i+1];0!==a&&(t[2*i]=c(o[a]++,a))}}function p(){var t,e,n,r,o,s=new Array(Y+1);for(n=0,r=0;r>=7;r8?a(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function g(t,e,n,r){v(t),r&&(a(t,n),a(t,~n)),C.arraySet(t.pending_buf,t.window,e,n,t.pending),t.pending+=n}function y(t,e,n,r){var i=2*e,o=2*n;return t[i]>1;n>=1;n--)m(t,o,n);i=u;do n=t.heap[1],t.heap[1]=t.heap[t.heap_len--],m(t,o,1),r=t.heap[1],t.heap[--t.heap_max]=n,t.heap[--t.heap_max]=r,o[2*i]=o[2*n]+o[2*r],t.depth[i]=(t.depth[n]>=t.depth[r]?t.depth[n]:t.depth[r])+1,o[2*n+1]=o[2*r+1]=i,t.heap[1]=i++,m(t,o,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],l(t,e),d(o,f,t.bl_count)}function E(t,e,n){var r,i,o=-1,s=e[1],a=0,u=7,f=4;for(0===s&&(u=138,f=3),e[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=e[2*(r+1)+1],++a=3&&0===t.bl_tree[2*it[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}function S(t,e,n,r){var i;for(u(t,e-257,5),u(t,n-1,5),u(t,r-4,4),i=0;i>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return M;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return B;for(e=32;e0?(t.strm.data_type===D&&(t.strm.data_type=A(t)),b(t,t.l_desc),b(t,t.d_desc),s=x(t),i=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=i&&(i=o)):i=o=n+5,n+4<=i&&e!==-1?R(t,e,n,r):t.strategy===N||o===i?(u(t,(j<<1)+(r?1:0),3),w(t,st,at)):(u(t,(U<<1)+(r?1:0),3),S(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),w(t,t.dyn_ltree,t.dyn_dtree)),_(t),r&&v(t)}function I(t,e,n){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&n,t.last_lit++,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(ft[n]+q+1)]++,t.dyn_dtree[2*s(e)]++),t.last_lit===t.lit_bufsize-1}var C=n(76),N=4,M=0,B=1,D=2,P=0,j=1,U=2,z=3,F=258,H=29,q=256,Z=q+1+H,W=30,V=19,G=2*Z+1,Y=15,$=16,K=7,X=256,J=16,Q=17,tt=18,et=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],nt=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],rt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],it=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],ot=512,st=new Array(2*(Z+2));r(st);var at=new Array(2*W);r(at);var ut=new Array(ot);r(ut);var ft=new Array(F-z+1);r(ft);var ct=new Array(H);r(ct);var ht=new Array(W);r(ht);var lt,dt,pt,_t=!1;e._tr_init=T,e._tr_stored_block=R,e._tr_flush_block=O,e._tr_tally=I,e._tr_align=L},function(t,e){"use strict";function n(t,e,n,r){for(var i=65535&t|0,o=t>>>16&65535|0,s=0;0!==n;){s=n>2e3?2e3:n,n-=s;do i=i+e[r++]|0,o=o+i|0;while(--s);i%=65521,o%=65521}return i|o<<16|0}t.exports=n},function(t,e){"use strict";function n(){for(var t,e=[],n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e}function r(t,e,n,r){var o=i,s=r+n;t^=-1;for(var a=r;a>>8^o[255&(t^e[a])];return t^-1}var i=n();t.exports=r},function(t,e,n){"use strict";function r(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function i(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new y.Buf16(320),this.work=new y.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function o(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=P,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new y.Buf32(_t),e.distcode=e.distdyn=new y.Buf32(vt),e.sane=1,e.back=-1,L):C}function s(t){var e;return t&&t.state?(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,o(t)):C}function a(t,e){var n,r;return t&&t.state?(r=t.state,e<0?(n=0,e=-e):(n=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15)?C:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,s(t))):C}function u(t,e){var n,r;return t?(r=new i,t.state=r,r.window=null,n=a(t,e),n!==L&&(t.state=null),n):C}function f(t){return u(t,yt)}function c(t){if(mt){var e;for(v=new y.Buf32(512),g=new y.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(E(x,t.lens,0,288,v,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;E(S,t.lens,0,32,g,0,t.work,{bits:5}),mt=!1}t.lencode=v,t.lenbits=9,t.distcode=g,t.distbits=5}function h(t,e,n,r){var i,o=t.state;return null===o.window&&(o.wsize=1<=o.wsize?(y.arraySet(o.window,e,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),y.arraySet(o.window,e,n-r,i,o.wnext),r-=i,r?(y.arraySet(o.window,e,n-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,n.check=w(n.check,Tt,2,0),l=0,d=0,n.mode=j;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",n.mode=lt;break}if((15&l)!==D){t.msg="unknown compression method",n.mode=lt;break}if(l>>>=4,d-=4,Et=(15&l)+8,0===n.wbits)n.wbits=Et;else if(Et>n.wbits){t.msg="invalid window size",n.mode=lt;break}n.dmax=1<>8&1),512&n.flags&&(Tt[0]=255&l,Tt[1]=l>>>8&255,n.check=w(n.check,Tt,2,0)),l=0,d=0,n.mode=U;case U:for(;d<32;){if(0===u)break t;u--,l+=i[s++]<>>8&255,Tt[2]=l>>>16&255,Tt[3]=l>>>24&255,n.check=w(n.check,Tt,4,0)),l=0,d=0,n.mode=z;case z:for(;d<16;){if(0===u)break t;u--,l+=i[s++]<>8),512&n.flags&&(Tt[0]=255&l,Tt[1]=l>>>8&255,n.check=w(n.check,Tt,2,0)),l=0,d=0,n.mode=F;case F:if(1024&n.flags){for(;d<16;){if(0===u)break t;u--,l+=i[s++]<>>8&255,n.check=w(n.check,Tt,2,0)),l=0,d=0}else n.head&&(n.head.extra=null);n.mode=H;case H:if(1024&n.flags&&(v=n.length,v>u&&(v=u),v&&(n.head&&(Et=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),y.arraySet(n.head.extra,i,s,v,Et)),512&n.flags&&(n.check=w(n.check,i,v,s)),u-=v,s+=v,n.length-=v),n.length))break t;n.length=0,n.mode=q;case q:if(2048&n.flags){if(0===u)break t;v=0;do Et=i[s+v++],n.head&&Et&&n.length<65536&&(n.head.name+=String.fromCharCode(Et));while(Et&&v>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=Y;break;case V:for(;d<32;){if(0===u)break t;u--,l+=i[s++]<>>=7&d,d-=7&d,n.mode=ft;break}for(;d<3;){if(0===u)break t;u--,l+=i[s++]<>>=1,d-=1,3&l){case 0:n.mode=K;break;case 1:if(c(n),n.mode=nt,e===R){l>>>=2,d-=2;break t}break;case 2:n.mode=Q;break;case 3:t.msg="invalid block type",n.mode=lt}l>>>=2,d-=2;break;case K:for(l>>>=7&d,d-=7&d;d<32;){if(0===u)break t;u--,l+=i[s++]<>>16^65535)){t.msg="invalid stored block lengths",n.mode=lt;break}if(n.length=65535&l,l=0,d=0,n.mode=X,e===R)break t;case X:n.mode=J;case J:if(v=n.length){if(v>u&&(v=u),v>f&&(v=f),0===v)break t;y.arraySet(o,i,s,v,a),u-=v,s+=v,f-=v,a+=v,n.length-=v;break}n.mode=Y;break;case Q:for(;d<14;){if(0===u)break t;u--,l+=i[s++]<>>=5,d-=5,n.ndist=(31&l)+1,l>>>=5,d-=5,n.ncode=(15&l)+4,l>>>=4,d-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=lt;break}n.have=0,n.mode=tt;case tt:for(;n.have>>=3,d-=3}for(;n.have<19;)n.lens[Rt[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,xt={bits:n.lenbits},kt=E(k,n.lens,0,19,n.lencode,0,n.work,xt),n.lenbits=xt.bits,kt){t.msg="invalid code lengths set",n.mode=lt;break}n.have=0,n.mode=et;case et:for(;n.have>>24,gt=At>>>16&255,yt=65535&At,!(vt<=d);){if(0===u)break t;u--,l+=i[s++]<>>=vt,d-=vt,n.lens[n.have++]=yt;else{if(16===yt){for(St=vt+2;d>>=vt,d-=vt,0===n.have){t.msg="invalid bit length repeat",n.mode=lt;break}Et=n.lens[n.have-1],v=3+(3&l),l>>>=2,d-=2}else if(17===yt){for(St=vt+3;d>>=vt,d-=vt,Et=0,v=3+(7&l),l>>>=3,d-=3}else{for(St=vt+7;d>>=vt,d-=vt,Et=0,v=11+(127&l),l>>>=7,d-=7}if(n.have+v>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=lt;break}for(;v--;)n.lens[n.have++]=Et}}if(n.mode===lt)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=lt;break}if(n.lenbits=9,xt={bits:n.lenbits},kt=E(x,n.lens,0,n.nlen,n.lencode,0,n.work,xt),n.lenbits=xt.bits,kt){t.msg="invalid literal/lengths set",n.mode=lt;break}if(n.distbits=6,n.distcode=n.distdyn,xt={bits:n.distbits},kt=E(S,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,xt),n.distbits=xt.bits,kt){t.msg="invalid distances set",n.mode=lt;break}if(n.mode=nt,e===R)break t;case nt:n.mode=rt;case rt:if(u>=6&&f>=258){t.next_out=a,t.avail_out=f,t.next_in=s,t.avail_in=u,n.hold=l,n.bits=d,b(t,_),a=t.next_out,o=t.output,f=t.avail_out,s=t.next_in,i=t.input,u=t.avail_in,l=n.hold,d=n.bits,n.mode===Y&&(n.back=-1);break}for(n.back=0;At=n.lencode[l&(1<>>24,gt=At>>>16&255,yt=65535&At,!(vt<=d);){if(0===u)break t;u--,l+=i[s++]<>mt)],vt=At>>>24,gt=At>>>16&255,yt=65535&At,!(mt+vt<=d);){if(0===u)break t;u--,l+=i[s++]<>>=mt,d-=mt,n.back+=mt}if(l>>>=vt,d-=vt,n.back+=vt,n.length=yt,0===gt){n.mode=ut;break}if(32>){n.back=-1,n.mode=Y;break}if(64>){t.msg="invalid literal/length code",n.mode=lt;break}n.extra=15>,n.mode=it;case it:if(n.extra){for(St=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=ot;case ot:for(;At=n.distcode[l&(1<>>24,gt=At>>>16&255,yt=65535&At,!(vt<=d);){if(0===u)break t;u--,l+=i[s++]<>mt)], -vt=At>>>24,gt=At>>>16&255,yt=65535&At,!(mt+vt<=d);){if(0===u)break t;u--,l+=i[s++]<>>=mt,d-=mt,n.back+=mt}if(l>>>=vt,d-=vt,n.back+=vt,64>){t.msg="invalid distance code",n.mode=lt;break}n.offset=yt,n.extra=15>,n.mode=st;case st:if(n.extra){for(St=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=lt;break}n.mode=at;case at:if(0===f)break t;if(v=_-f,n.offset>v){if(v=n.offset-v,v>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=lt;break}v>n.wnext?(v-=n.wnext,g=n.wsize-v):g=n.wnext-v,v>n.length&&(v=n.length),_t=n.window}else _t=o,g=a-n.offset,v=n.length;v>f&&(v=f),f-=v,n.length-=v;do o[a++]=_t[g++];while(--v);0===n.length&&(n.mode=rt);break;case ut:if(0===f)break t;o[a++]=n.length,f--,n.mode=rt;break;case ft:if(n.wrap){for(;d<32;){if(0===u)break t;u--,l|=i[s++]<>>24,_>>>=E,v-=E,E=b>>>16&255,0===E)R[a++]=65535&b;else{if(!(16&E)){if(0===(64&E)){b=g[(65535&b)+(_&(1<>>=E,v-=E),v<15&&(_+=T[o++]<>>24,_>>>=E,v-=E,E=b>>>16&255,!(16&E)){if(0===(64&E)){b=y[(65535&b)+(_&(1<c){t.msg="invalid distance too far back",i.mode=n;break t}if(_>>>=E,v-=E,E=a-u,x>E){if(E=x-E,E>l&&i.sane){t.msg="invalid distance too far back",i.mode=n;break t}if(S=0,A=p,0===d){if(S+=h-E,E2;)R[a++]=A[S++],R[a++]=A[S++],R[a++]=A[S++],k-=3;k&&(R[a++]=A[S++],k>1&&(R[a++]=A[S++]))}else{S=a-x;do R[a++]=R[S++],R[a++]=R[S++],R[a++]=R[S++],k-=3;while(k>2);k&&(R[a++]=R[S++],k>1&&(R[a++]=R[S++]))}break}}break}}while(o>3,o-=k,v-=k<<3,_&=(1<=1&&0===F[C];C--);if(N>C&&(N=C),0===C)return _[v++]=20971520,_[v++]=20971520,y.bits=1,0;for(I=1;I0&&(t===a||1!==C))return-1;for(H[1]=0,L=1;Lo||t===f&&P>s)return 1;for(var W=0;;){W++,S=L-B,g[O]x?(A=q[Z+g[O]],T=U[z+g[O]]):(A=96,T=0),m=1<>B)+w]=S<<24|A<<16|T|0;while(0!==w);for(m=1<>=1;if(0!==m?(j&=m-1,j+=m):j=0,O++,0===--F[L]){if(L===C)break;L=e[n+g[O]]}if(L>N&&(j&E)!==b){for(0===B&&(B=N),k+=I,M=L-B,D=1<o||t===f&&P>s)return 1;b=j&E,_[b]=N<<24|M<<16|k-v|0}}return 0!==j&&(_[k+j]=L-B<<24|64<<16|0),y.bits=N,0}},function(t,e){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},function(t,e,n){(function(e){"use strict";/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -function r(t,e){if(t===e)return 0;for(var n=t.length,r=e.length,i=0,o=Math.min(n,r);i=0;a--)if(u[a]!==f[a])return!1;for(a=u.length-1;a>=0;a--)if(s=u[a],!d(t[s],e[s],n,r))return!1;return!0}function v(t,e,n){d(t,e,!0)&&h(t,e,n,"notDeepStrictEqual",v)}function g(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&e.call({},t)===!0}function y(t){var e;try{t()}catch(t){e=t}return e}function m(t,e,n,r){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof n&&(r=n,n=null),i=y(e),r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),t&&!i&&h(i,n,"Missing expected exception"+r);var o="string"==typeof r,s=!t&&w.isError(i),a=!t&&i&&!n;if((s&&o&&g(i,n)||a)&&h(i,n,"Got unwanted exception"+r),t&&i&&n&&!g(i,n)||!t&&i)throw i}var w=n(16),b=Object.prototype.hasOwnProperty,E=Array.prototype.slice,k=function(){return"foo"===function(){}.name}(),x=t.exports=l,S=/\s*function\s+([^\(\s]*)\s*/;x.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=c(this),this.generatedMessage=!0);var e=t.stackStartFunction||h;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var n=new Error;if(n.stack){var r=n.stack,i=a(e),o=r.indexOf("\n"+i);if(o>=0){var s=r.indexOf("\n",o+1);r=r.substring(s+1)}this.stack=r}}},w.inherits(x.AssertionError,Error),x.fail=h,x.ok=l,x.equal=function(t,e,n){t!=e&&h(t,e,n,"==",x.equal)},x.notEqual=function(t,e,n){t==e&&h(t,e,n,"!=",x.notEqual)},x.deepEqual=function(t,e,n){d(t,e,!1)||h(t,e,n,"deepEqual",x.deepEqual)},x.deepStrictEqual=function(t,e,n){d(t,e,!0)||h(t,e,n,"deepStrictEqual",x.deepStrictEqual)},x.notDeepEqual=function(t,e,n){d(t,e,!1)&&h(t,e,n,"notDeepEqual",x.notDeepEqual)},x.notDeepStrictEqual=v,x.strictEqual=function(t,e,n){t!==e&&h(t,e,n,"===",x.strictEqual)},x.notStrictEqual=function(t,e,n){t===e&&h(t,e,n,"!==",x.notStrictEqual)},x.throws=function(t,e,n){m(!0,t,e,n)},x.doesNotThrow=function(t,e,n){m(!1,t,e,n)},x.ifError=function(t){if(t)throw t};var A=Object.keys||function(t){var e=[];for(var n in t)b.call(t,n)&&e.push(n);return e}}).call(e,function(){return this}())},function(t,e,n){(function(e){function r(t,n){if(this instanceof r==!1)throw new TypeError("Classes can't be function-called");"number"==typeof t&&(n=t,t={});var i=-1;this.fragmentedBufferPool=new c(1024,function(t,e){return t.used+e},function(t){return i=i>=0?Math.ceil((i+t.used)/2):t.used});var o=-1;this.unfragmentedBufferPool=new c(1024,function(t,e){return t.used+e},function(t){return o=o>=0?Math.ceil((o+t.used)/2):t.used}),this.extensions=t||{},this.maxPayload=n||0,this.currentPayloadLength=0,this.state={activeFragmentedOperation:null,lastFragment:!1,masked:!1,opcode:0,fragmentedOperation:!1},this.overflow=[],this.headerBuffer=new e(10),this.expectOffset=0,this.expectBuffer=null,this.expectHandler=null,this.currentMessage=[],this.currentMessageLength=0,this.messageHandlers=[],this.expectHeader(2,this.processPacket),this.dead=!1,this.processing=!1,this.onerror=function(){},this.ontext=function(){},this.onbinary=function(){},this.onclose=function(){},this.onping=function(){},this.onpong=function(){}}function i(t){return(this[t]<<8)+this[t+1]}function o(t){return(this[t]<<24)+(this[t+1]<<16)+(this[t+2]<<8)+this[t+3]}function s(t,e,n,r){switch(t){default:e.copy(n,r,0,t);break;case 16:n[r+15]=e[15];case 15:n[r+14]=e[14];case 14:n[r+13]=e[13];case 13:n[r+12]=e[12];case 12:n[r+11]=e[11];case 11:n[r+10]=e[10];case 10:n[r+9]=e[9];case 9:n[r+8]=e[8];case 8:n[r+7]=e[7];case 7:n[r+6]=e[6];case 6:n[r+5]=e[5];case 5:n[r+4]=e[4];case 4:n[r+3]=e[3];case 3:n[r+2]=e[2];case 2:n[r+1]=e[1];case 1:n[r]=e[0]}}function a(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -var u=(n(16),n(86).Validation),f=n(60),c=n(88),h=n(61).BufferUtil,l=n(63);t.exports=r,r.prototype.add=function(t){if(!this.dead){var e=t.length;if(0!=e){if(null==this.expectBuffer)return void this.overflow.push(t);var n=Math.min(e,this.expectBuffer.length-this.expectOffset);for(s(n,t,this.expectBuffer,this.expectOffset),this.expectOffset+=n,n0&&this.overflow.length>0;){var r=this.overflow.pop();n0&&this.overflow.length>0;){var r=this.overflow.pop();n=8&&e)return void this.error("control frames cannot have the Per-message Compressed bits",1002);this.state.compressed=e,this.state.opcode=n,this.state.lastFragment===!1?(this.state.fragmentedOperation=!0,this.state.activeFragmentedOperation=n):this.state.fragmentedOperation=!1}var r=d[this.state.opcode];"undefined"==typeof r?this.error("no handler for opcode "+this.state.opcode,1002):r.start.call(this,t)},r.prototype.endPacket=function(){this.dead||(this.state.fragmentedOperation?this.state.lastFragment&&this.fragmentedBufferPool.reset(!0):this.unfragmentedBufferPool.reset(!0),this.expectOffset=0,this.expectBuffer=null,this.expectHandler=null,this.state.lastFragment&&this.state.opcode===this.state.activeFragmentedOperation&&(this.state.activeFragmentedOperation=null),this.currentPayloadLength=0,this.state.lastFragment=!1,this.state.opcode=null!=this.state.activeFragmentedOperation?this.state.activeFragmentedOperation:0,this.state.masked=!1,this.expectHeader(2,this.processPacket))},r.prototype.reset=function(){this.dead||(this.state={activeFragmentedOperation:null,lastFragment:!1,masked:!1,opcode:0,fragmentedOperation:!1},this.fragmentedBufferPool.reset(!0),this.unfragmentedBufferPool.reset(!0),this.expectOffset=0,this.expectBuffer=null,this.expectHandler=null,this.overflow=[],this.currentMessage=[],this.currentMessageLength=0,this.messageHandlers=[],this.currentPayloadLength=0)},r.prototype.unmask=function(t,e,n){return null!=t&&null!=e&&h.unmask(e,t),n?e:null!=e?e.toString("utf8"):""},r.prototype.error=function(t,e){if(!this.dead)return this.reset(),"string"==typeof t?this.onerror(new Error(t),e):t.constructor==Error?this.onerror(t,e):this.onerror(new Error("An error occured"),e),this},r.prototype.flush=function(){if(!this.processing&&!this.dead){var t=this.messageHandlers.shift();if(t){this.processing=!0;var e=this;t(function(){e.processing=!1,e.flush()})}}},r.prototype.applyExtensions=function(t,e,n,r){var i=this;n?this.extensions[l.extensionName].decompress(t,e,function(t,e){if(!i.dead)return t?void r(new Error("invalid compressed data")):void r(null,e)}):r(null,t)},r.prototype.maxPayloadExceeded=function(t){if(void 0===this.maxPayload||null===this.maxPayload||this.maxPayload<1)return!1;var e=this.currentPayloadLength+t;return e0&&r.currentMessageLength+i.length0&&r.currentMessageLength+i.length1?i.call(e,0):1e3;if(!f.isValidErrorCode(t))return void n.error("invalid error code",1002);var o="";if(e&&e.length>2){var s=e.slice(2);if(!u.isValidUTF8(s))return void n.error("invalid utf8 sequence",1007);o=s.toString("utf8")}n.onclose(t,o,{masked:r.masked}),n.reset()}),this.flush()}},9:{start:function(t){var e=this;if(0==e.state.lastFragment)return void e.error("fragmented ping is not supported",1002);var n=127&t[1];n<126?d[9].getData.call(e,n):e.error("control frames cannot have more than 125 bytes of data",1002)},getData:function(t){var e=this;e.state.masked?e.expectHeader(4,function(n){var r=n;e.expectData(t,function(t){d[9].finish.call(e,r,t)})}):e.expectData(t,function(t){d[9].finish.call(e,null,t)})},finish:function(t,e){var n=this;e=this.unmask(t,e,!0);var r=a(this.state);this.messageHandlers.push(function(t){n.onping(e,{masked:r.masked,binary:!0}),t()}),this.flush(),this.endPacket()}},10:{start:function(t){var e=this;if(0==e.state.lastFragment)return void e.error("fragmented pong is not supported",1002);var n=127&t[1];n<126?d[10].getData.call(e,n):e.error("control frames cannot have more than 125 bytes of data",1002)},getData:function(t){var e=this;this.state.masked?this.expectHeader(4,function(n){var r=n;e.expectData(t,function(t){d[10].finish.call(e,r,t)})}):this.expectData(t,function(t){d[10].finish.call(e,null,t)})},finish:function(t,e){var n=this;e=n.unmask(t,e,!0);var r=a(this.state);this.messageHandlers.push(function(t){n.onpong(e,{masked:r.masked,binary:!0}),t()}),this.flush(),this.endPacket()}}}}).call(e,n(5).Buffer)},function(t,e,n){"use strict";/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -try{t.exports=n(!function(){var t=new Error('Cannot find module "utf-8-validate"');throw t.code="MODULE_NOT_FOUND",t}())}catch(e){t.exports=n(87)}},function(t,e){/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -e.Validation={isValidUTF8:function(t){return!0}}},function(t,e,n){(function(e){function r(t,n,i){if(this instanceof r==!1)throw new TypeError("Classes can't be function-called");"function"==typeof t?(i=n,n=t,t=0):"undefined"==typeof t&&(t=0),this._growStrategy=(n||function(t,e){return t.used+e}).bind(null,this),this._shrinkStrategy=(i||function(e){return t}).bind(null,this),this._buffer=t?new e(t):null,this._offset=0,this._used=0,this._changeFactor=0,this.__defineGetter__("size",function(){return null==this._buffer?0:this._buffer.length}),this.__defineGetter__("used",function(){return this._used})}/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -n(16);r.prototype.get=function(t){if(null==this._buffer||this._offset+t>this._buffer.length){var n=new e(this._growStrategy(t));this._buffer=n,this._offset=0}this._used+=t;var r=this._buffer.slice(this._offset,this._offset+t);return this._offset+=t,r},r.prototype.reset=function(t){var n=this._shrinkStrategy();n - * MIT Licensed - */ -var i=n(20),o=n(16);i.EventEmitter;t.exports=r,o.inherits(r,i.EventEmitter),r.prototype.send=function(t,n,r){if(!this.isClosed){var i="string"==typeof t,o=i?e.byteLength(t):t.length,s=o>127?2:1,a=0==this.continuationFrame,u=!n||!("undefined"!=typeof n.fin&&!n.fin),f=new e((a?n&&n.binary?1+s:1:0)+o+(!u||n&&n.binary?0:1)),c=a?1:0;a&&(n&&n.binary?(f.write("€","binary"),s>1&&f.write(String.fromCharCode(128+o/128),c++,"binary"),f.write(String.fromCharCode(127&o),c++,"binary")):f.write("\0","binary")),i?f.write(t,c,"utf8"):t.copy(f,c,0),u?(n&&n.binary||f.write("ÿ",c+o,"binary"),this.continuationFrame=!1):this.continuationFrame=!0;try{this.socket.write(f,"binary",r)}catch(t){this.error(t.toString())}}},r.prototype.close=function(t,n,r,i){if(!this.isClosed){this.isClosed=!0;try{this.continuationFrame&&this.socket.write(new e([255],"binary")),this.socket.write(new e([255,0]),"binary",i)}catch(t){this.error(t.toString())}}},r.prototype.ping=function(t,e){},r.prototype.pong=function(t,e){},r.prototype.error=function(t){return this.emit("error",t),this}}).call(e,n(5).Buffer)},function(t,e,n){(function(e){function r(){if(this instanceof r==!1)throw new TypeError("Classes can't be function-called");this.state=o,this.buffers=[],this.messageEnd=-1,this.spanLength=0,this.dead=!1,this.onerror=function(){},this.ontext=function(){},this.onbinary=function(){},this.onclose=function(){},this.onping=function(){},this.onpong=function(){}}function i(t,e){for(var n=0,r=t.length;n - * MIT Licensed - */ -var o=(n(16),0),s=1,a=2,u=3;t.exports=r,r.prototype.add=function(t){function e(){if(n.state===o){if(2==t.length&&255==t[0]&&0==t[1])return n.reset(),void n.onclose();if(128===t[0])n.messageEnd=0,n.state=a,t=t.slice(1);else{if(0!==t[0])return void n.error("payload must start with 0x00 byte",!0);t=t.slice(1),n.state=s}}if(n.state===a){for(var e=0;e0&&(t=t.slice(e))}if(n.state===u){var r=n.messageEnd-n.spanLength;return t.length>=r?(n.buffers.push(t),n.spanLength+=r,n.messageEnd=r,n.parse()):(n.buffers.push(t),void(n.spanLength+=t.length))}return n.buffers.push(t),(n.messageEnd=i(t,255))!=-1?(n.spanLength+=n.messageEnd,n.parse()):void(n.spanLength+=t.length)}if(!this.dead)for(var n=this;t;)t=e()},r.prototype.cleanup=function(){this.dead=!0,this.state=o,this.buffers=[]},r.prototype.parse=function(){for(var t=new e(this.spanLength),n=0,r=0,i=this.buffers.length;r0&&a.copy(t,n,0,this.messageEnd),this.state!==s&&--this.messageEnd;var u=null;return this.messageEnd>24&255,e>>16&255,e>>8&255,255&e)))}),_.update(r.toString("binary")),n.setTimeout(0),n.setNoDelay(!0);try{var v=new e(_.digest("binary"),"binary"),g=new e(f.length+v.length);f.copy(g,0),v.copy(g,f.length),n.write(g,"binary",function(e){if(!e){var r=new d([t,n,s],{protocolVersion:"hixie-76",protocol:l});u.options.clientTracking&&(u.clients.push(r),r.on("close",function(){var t=u.clients.indexOf(r);t!=-1&&u.clients.splice(t,1)})),n.removeListener("error",o),i(r)}})}catch(t){try{n.destroy()}catch(t){}return}},g=8;if(r&&r.length>=g){var y=r.slice(0,g),m=r.length>g?r.slice(g):null;v.call(u,y,m,p())}else{var y=new e(g);r.copy(y,0);var w=r.length,m=null,b=function(t){var r=Math.min(t.length,g-w);0!==r&&(t.copy(y,w,0,r),w+=r,w==g&&(n.removeListener("data",b),r - * MIT Licensed - */ -var u=n(16),f=n(20),c=n(19),h=n(41),l=n(57),d=n(4),p=n(91),_=n(63),v=(n(58),n(10));u.inherits(r,f.EventEmitter),r.prototype.close=function(t){var e=null;try{for(var n=0,r=this.clients.length;n=300)&&(r=new Error(e.statusText||"Unsuccessful HTTP response"),r.original=t,r.response=e,r.status=e.status)}catch(t){r=t}r?n.callback(r,e):n.callback(null,e)})}function d(t,e){var n=y("DELETE",t);return e&&n.end(e),n}var p;"undefined"!=typeof window?p=window:"undefined"!=typeof self?p=self:(console.warn("Using browser-only version of superagent in non-browser environment"),p=this);var _=n(95),v=n(96),g=n(97),y=t.exports=n(98).bind(null,l);y.getXHR=function(){if(!(!p.XMLHttpRequest||p.location&&"file:"==p.location.protocol&&p.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}throw Error("Browser-only verison of superagent could not find XHR")};var m="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};y.serializeObject=i,y.parseString=s,y.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":i,"application/json":JSON.stringify},y.parse={"application/x-www-form-urlencoded":s,"application/json":JSON.parse},h.prototype.get=function(t){return this.header[t.toLowerCase()]},h.prototype._setHeaderProperties=function(t){var e=this.header["content-type"]||"";this.type=f(e);var n=c(e);for(var r in n)this[r]=n[r]},h.prototype._parseBody=function(t){var e=y.parse[this.type];return!e&&u(this.type)&&(e=y.parse["application/json"]),e&&t&&(t.length||t instanceof Object)?e(t):null},h.prototype._setStatusProperties=function(t){1223===t&&(t=204);var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},h.prototype.toError=function(){var t=this.req,e=t.method,n=t.url,r="cannot "+e+" "+n+" ("+this.status+")",i=new Error(r);return i.status=this.status,i.method=e,i.url=n,i},y.Response=h,_(l.prototype);for(var w in v)l.prototype[w]=v[w];l.prototype.type=function(t){return this.set("Content-Type",y.types[t]||t),this},l.prototype.responseType=function(t){return this._responseType=t,this},l.prototype.accept=function(t){return this.set("Accept",y.types[t]||t),this},l.prototype.auth=function(t,e,n){switch(n||(n={type:"basic"}),n.type){case"basic":var r=btoa(t+":"+e);this.set("Authorization","Basic "+r);break;case"auto":this.username=t,this.password=e}return this},l.prototype.query=function(t){return"string"!=typeof t&&(t=i(t)),t&&this._query.push(t),this},l.prototype.attach=function(t,e,n){return this._getFormData().append(t,e,n||e.name),this},l.prototype._getFormData=function(){return this._formData||(this._formData=new p.FormData),this._formData},l.prototype.callback=function(t,e){var n=this._callback;this.clearTimeout(),n(t,e)},l.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},l.prototype._timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},l.prototype._appendQueryString=function(){var t=this._query.join("&");t&&(this.url+=~this.url.indexOf("?")?"&"+t:"?"+t)},l.prototype.end=function(t){var e=this,n=this.xhr=y.getXHR(),i=this._timeout,o=this._formData||this._data;this._callback=t||r,n.onreadystatechange=function(){if(4==n.readyState){var t;try{t=n.status}catch(e){t=0}if(0==t){if(e.timedout)return e._timeoutError();if(e._aborted)return;return e.crossDomainError()}e.emit("end")}};var s=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{n.onprogress=s.bind(null,"download"),n.upload&&(n.upload.onprogress=s.bind(null,"upload"))}catch(t){}if(i&&!this._timer&&(this._timer=setTimeout(function(){e.timedout=!0,e.abort()},i)),this._appendQueryString(),this.username&&this.password?n.open(this.method,this.url,!0,this.username,this.password):n.open(this.method,this.url,!0),this._withCredentials&&(n.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof o&&!this._isHost(o)){var a=this._header["content-type"],f=this._serializer||y.serialize[a?a.split(";")[0]:""];!f&&u(a)&&(f=y.serialize["application/json"]),f&&(o=f(o))}for(var c in this.header)null!=this.header[c]&&n.setRequestHeader(c,this.header[c]);return this._responseType&&(n.responseType=this._responseType),this.emit("request",this),n.send("undefined"!=typeof o?o:null),this},y.Request=l,y.get=function(t,e,n){var r=y("GET",t);return"function"==typeof e&&(n=e,e=null),e&&r.query(e),n&&r.end(n),r},y.head=function(t,e,n){var r=y("HEAD",t);return"function"==typeof e&&(n=e,e=null),e&&r.send(e),n&&r.end(n),r},y.options=function(t,e,n){var r=y("OPTIONS",t);return"function"==typeof e&&(n=e,e=null),e&&r.send(e),n&&r.end(n),r},y.del=d,y.delete=d,y.patch=function(t,e,n){var r=y("PATCH",t);return"function"==typeof e&&(n=e,e=null),e&&r.send(e),n&&r.end(n),r},y.post=function(t,e,n){var r=y("POST",t);return"function"==typeof e&&(n=e,e=null),e&&r.send(e),n&&r.end(n),r},y.put=function(t,e,n){var r=y("PUT",t);return"function"==typeof e&&(n=e,e=null),e&&r.send(e),n&&r.end(n),r}},function(t,e,n){function r(t){if(t)return i(t)}function i(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},r.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var r,i=0;i-1}function p(t,e,n){for(var r=-1,i=null==t?0:t.length;++r-1;);return n}function U(t,e){for(var n=t.length;n--&&x(e,t[n],0)>-1;);return n}function z(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}function F(t){return"\\"+nr[t]}function H(t,e){return null==t?it:t[e]}function q(t){return Gn.test(t)}function Z(t){return Yn.test(t)}function W(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}function V(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function G(t,e){return function(n){return t(e(n))}}function Y(t,e){for(var n=-1,r=t.length,i=0,o=[];++n>>1,Ft=[["ary",xt],["bind",gt],["bindKey",yt],["curry",wt],["curryRight",bt],["flip",At],["partial",Et],["partialRight",kt],["rearg",St]],Ht="[object Arguments]",qt="[object Array]",Zt="[object AsyncFunction]",Wt="[object Boolean]",Vt="[object Date]",Gt="[object DOMException]",Yt="[object Error]",$t="[object Function]",Kt="[object GeneratorFunction]",Xt="[object Map]",Jt="[object Number]",Qt="[object Null]",te="[object Object]",ee="[object Promise]",ne="[object Proxy]",re="[object RegExp]",ie="[object Set]",oe="[object String]",se="[object Symbol]",ae="[object Undefined]",ue="[object WeakMap]",fe="[object WeakSet]",ce="[object ArrayBuffer]",he="[object DataView]",le="[object Float32Array]",de="[object Float64Array]",pe="[object Int8Array]",_e="[object Int16Array]",ve="[object Int32Array]",ge="[object Uint8Array]",ye="[object Uint8ClampedArray]",me="[object Uint16Array]",we="[object Uint32Array]",be=/\b__p \+= '';/g,Ee=/\b(__p \+=) '' \+/g,ke=/(__e\(.*?\)|\b__t\)) \+\n'';/g,xe=/&(?:amp|lt|gt|quot|#39);/g,Se=/[&<>"']/g,Ae=RegExp(xe.source),Te=RegExp(Se.source),Re=/<%-([\s\S]+?)%>/g,Le=/<%([\s\S]+?)%>/g,Oe=/<%=([\s\S]+?)%>/g,Ie=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ce=/^\w*$/,Ne=/^\./,Me=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Be=/[\\^$.*+?()[\]{}|]/g,De=RegExp(Be.source),Pe=/^\s+|\s+$/g,je=/^\s+/,Ue=/\s+$/,ze=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Fe=/\{\n\/\* \[wrapped with (.+)\] \*/,He=/,? & /,qe=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ze=/\\(\\)?/g,We=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ve=/\w*$/,Ge=/^[-+]0x[0-9a-f]+$/i,Ye=/^0b[01]+$/i,$e=/^\[object .+?Constructor\]$/,Ke=/^0o[0-7]+$/i,Xe=/^(?:0|[1-9]\d*)$/,Je=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Qe=/($^)/,tn=/['\n\r\u2028\u2029\\]/g,en="\\ud800-\\udfff",nn="\\u0300-\\u036f",rn="\\ufe20-\\ufe2f",on="\\u20d0-\\u20ff",sn=nn+rn+on,an="\\u2700-\\u27bf",un="a-z\\xdf-\\xf6\\xf8-\\xff",fn="\\xac\\xb1\\xd7\\xf7",cn="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",hn="\\u2000-\\u206f",ln=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",dn="A-Z\\xc0-\\xd6\\xd8-\\xde",pn="\\ufe0e\\ufe0f",_n=fn+cn+hn+ln,vn="['’]",gn="["+en+"]",yn="["+_n+"]",mn="["+sn+"]",wn="\\d+",bn="["+an+"]",En="["+un+"]",kn="[^"+en+_n+wn+an+un+dn+"]",xn="\\ud83c[\\udffb-\\udfff]",Sn="(?:"+mn+"|"+xn+")",An="[^"+en+"]",Tn="(?:\\ud83c[\\udde6-\\uddff]){2}",Rn="[\\ud800-\\udbff][\\udc00-\\udfff]",Ln="["+dn+"]",On="\\u200d",In="(?:"+En+"|"+kn+")",Cn="(?:"+Ln+"|"+kn+")",Nn="(?:"+vn+"(?:d|ll|m|re|s|t|ve))?",Mn="(?:"+vn+"(?:D|LL|M|RE|S|T|VE))?",Bn=Sn+"?",Dn="["+pn+"]?",Pn="(?:"+On+"(?:"+[An,Tn,Rn].join("|")+")"+Dn+Bn+")*",jn="\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)",Un="\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)",zn=Dn+Bn+Pn,Fn="(?:"+[bn,Tn,Rn].join("|")+")"+zn,Hn="(?:"+[An+mn+"?",mn,Tn,Rn,gn].join("|")+")",qn=RegExp(vn,"g"),Zn=RegExp(mn,"g"),Wn=RegExp(xn+"(?="+xn+")|"+Hn+zn,"g"),Vn=RegExp([Ln+"?"+En+"+"+Nn+"(?="+[yn,Ln,"$"].join("|")+")",Cn+"+"+Mn+"(?="+[yn,Ln+In,"$"].join("|")+")",Ln+"?"+In+"+"+Nn,Ln+"+"+Mn,Un,jn,wn,Fn].join("|"),"g"),Gn=RegExp("["+On+en+sn+pn+"]"),Yn=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,$n=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Kn=-1,Xn={};Xn[le]=Xn[de]=Xn[pe]=Xn[_e]=Xn[ve]=Xn[ge]=Xn[ye]=Xn[me]=Xn[we]=!0,Xn[Ht]=Xn[qt]=Xn[ce]=Xn[Wt]=Xn[he]=Xn[Vt]=Xn[Yt]=Xn[$t]=Xn[Xt]=Xn[Jt]=Xn[te]=Xn[re]=Xn[ie]=Xn[oe]=Xn[ue]=!1;var Jn={};Jn[Ht]=Jn[qt]=Jn[ce]=Jn[he]=Jn[Wt]=Jn[Vt]=Jn[le]=Jn[de]=Jn[pe]=Jn[_e]=Jn[ve]=Jn[Xt]=Jn[Jt]=Jn[te]=Jn[re]=Jn[ie]=Jn[oe]=Jn[se]=Jn[ge]=Jn[ye]=Jn[me]=Jn[we]=!0,Jn[Yt]=Jn[$t]=Jn[ue]=!1;var Qn={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"},tr={"&":"&","<":"<",">":">",'"':""","'":"'"},er={"&":"&","<":"<",">":">",""":'"',"'":"'"},nr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},rr=parseFloat,ir=parseInt,or="object"==typeof t&&t&&t.Object===Object&&t,sr="object"==typeof self&&self&&self.Object===Object&&self,ar=or||sr||Function("return this")(),ur="object"==typeof e&&e&&!e.nodeType&&e,fr=ur&&"object"==typeof i&&i&&!i.nodeType&&i,cr=fr&&fr.exports===ur,hr=cr&&or.process,lr=function(){try{return hr&&hr.binding&&hr.binding("util")}catch(t){}}(),dr=lr&&lr.isArrayBuffer,pr=lr&&lr.isDate,_r=lr&&lr.isMap,vr=lr&&lr.isRegExp,gr=lr&&lr.isSet,yr=lr&&lr.isTypedArray,mr=R("length"),wr=L(Qn),br=L(tr),Er=L(er),kr=function t(e){function n(t){if(uu(t)&&!wl(t)&&!(t instanceof w)){if(t instanceof i)return t;if(wc.call(t,"__wrapped__"))return os(t)}return new i(t)}function r(){}function i(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=it}function w(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=jt,this.__views__=[]}function L(){var t=new w(this.__wrapped__);return t.__actions__=Fi(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Fi(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Fi(this.__views__),t}function X(){if(this.__filtered__){var t=new w(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function et(){var t=this.__wrapped__.value(),e=this.__dir__,n=wl(t),r=e<0,i=n?t.length:0,o=Ro(0,i,this.__views__),s=o.start,a=o.end,u=a-s,f=r?a:s-1,c=this.__iteratees__,h=c.length,l=0,d=Kc(u,this.__takeCount__);if(!n||i-1}function hn(t,e){var n=this.__data__,r=Mn(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}function ln(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function Fn(t,e,n,r,i,o){var s,a=e<,u=e&dt,c=e&pt;if(n&&(s=i?n(t,r,i,o):n(t)),s!==it)return s;if(!au(t))return t;var h=wl(t);if(h){if(s=Io(t),!a)return Fi(t,s)}else{var l=Oh(t),d=l==$t||l==Kt;if(El(t))return Li(t,a);if(l==te||l==Ht||d&&!i){if(s=u||d?{}:Co(t),!a)return u?Zi(t,Pn(s,t)):qi(t,Dn(s,t))}else{if(!Jn[l])return i?t:{};s=No(t,l,Fn,a)}}o||(o=new bn);var p=o.get(t);if(p)return p;o.set(t,s);var _=c?u?wo:mo:u?Zu:qu,v=h?it:_(t);return f(v||t,function(r,i){v&&(i=r,r=t[i]),Nn(s,i,Fn(r,e,n,i,t,o))}),s}function Hn(t){var e=qu(t);return function(n){return Wn(n,t,e)}}function Wn(t,e,n){var r=n.length;if(null==t)return!r;for(t=hc(t);r--;){var i=n[r],o=e[i],s=t[i];if(s===it&&!(i in t)||!o(s))return!1}return!0}function Vn(t,e,n){if("function"!=typeof t)throw new pc(ut);return Nh(function(){t.apply(it,n)},e)}function Gn(t,e,n,r){var i=-1,o=d,s=!0,a=t.length,u=[],f=e.length;if(!a)return u;n&&(e=_(e,B(n))),r?(o=p,s=!1):e.length>=st&&(o=P,s=!1,e=new yn(e));t:for(;++ii?0:i+n),r=r===it||r>i?i:Su(r),r<0&&(r+=i),r=n>r?0:Au(r);n0&&n(a)?e>1?nr(a,e-1,n,r,i):v(i,a):r||(i[i.length]=a)}return i}function or(t,e){return t&&wh(t,e,qu)}function sr(t,e){return t&&bh(t,e,qu)}function ur(t,e){return l(e,function(e){return iu(t[e])})}function fr(t,e){e=Ti(e,t);for(var n=0,r=e.length;null!=t&&ne}function kr(t,e){return null!=t&&wc.call(t,e)}function Sr(t,e){return null!=t&&e in hc(t)}function Ar(t,e,n){return t>=Kc(e,n)&&t<$c(e,n)}function Tr(t,e,n){for(var r=n?p:d,i=t[0].length,o=t.length,s=o,a=sc(o),u=1/0,f=[];s--;){var c=t[s];s&&e&&(c=_(c,B(e))),u=Kc(c.length,u),a[s]=!n&&(e||i>=120&&c.length>=120)?new yn(s&&c):it}c=t[0];var h=-1,l=a[0];t:for(;++h-1;)a!==t&&Mc.call(a,u,1),Mc.call(t,u,1);return t}function ni(t,e){for(var n=t?e.length:0,r=n-1;n--;){var i=e[n];if(n==r||i!==o){var o=i;Do(i)?Mc.call(t,i,1):mi(t,i)}}return t}function ri(t,e){return t+qc(Qc()*(e-t+1))}function ii(t,e,n,r){for(var i=-1,o=$c(Hc((e-t)/(n||1)),0),s=sc(o);o--;)s[r?o:++i]=t,t+=n;return s}function oi(t,e){var n="";if(!t||e<1||e>Bt)return n;do e%2&&(n+=t),e=qc(e/2),e&&(t+=t);while(e);return n}function si(t,e){return Mh(Ko(t,e,Mf),t+"")}function ai(t){return Rn(nf(t))}function ui(t,e){var n=nf(t);return es(n,zn(e,0,n.length))}function fi(t,e,n,r){if(!au(t))return t;e=Ti(e,t);for(var i=-1,o=e.length,s=o-1,a=t;null!=a&&++ii?0:i+e),n=n>i?i:n,n<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var o=sc(i);++r>>1,s=t[o];null!==s&&!mu(s)&&(n?s<=e:s=st){var f=e?null:Ah(t);if(f)return $(f);s=!1,i=P,u=new yn}else u=e?[]:a;t:for(;++r=r?t:hi(t,e,n)}function Li(t,e){if(e)return t.slice();var n=t.length,r=Oc?Oc(n):new t.constructor(n);return t.copy(r),r}function Oi(t){var e=new t.constructor(t.byteLength);return new Lc(e).set(new Lc(t)),e}function Ii(t,e){var n=e?Oi(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}function Ci(t,e,n){var r=e?n(V(t),lt):V(t);return g(r,o,new t.constructor)}function Ni(t){var e=new t.constructor(t.source,Ve.exec(t));return e.lastIndex=t.lastIndex,e}function Mi(t,e,n){var r=e?n($(t),lt):$(t);return g(r,s,new t.constructor)}function Bi(t){return _h?hc(_h.call(t)):{}}function Di(t,e){var n=e?Oi(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Pi(t,e){if(t!==e){var n=t!==it,r=null===t,i=t===t,o=mu(t),s=e!==it,a=null===e,u=e===e,f=mu(e);if(!a&&!f&&!o&&t>e||o&&s&&u&&!a&&!f||r&&s&&u||!n&&u||!i)return 1;if(!r&&!o&&!f&&t=a)return u;var f=n[r];return u*("desc"==f?-1:1)}}return t.index-e.index}function Ui(t,e,n,r){for(var i=-1,o=t.length,s=n.length,a=-1,u=e.length,f=$c(o-s,0),c=sc(u+f),h=!r;++a1?n[i-1]:it,s=i>2?n[2]:it;for(o=t.length>3&&"function"==typeof o?(i--,o):it,s&&Po(n[0],n[1],s)&&(o=i<3?it:o,i=1),e=hc(e);++r-1?i[o?e[s]:s]:it}}function eo(t){return yo(function(e){var n=e.length,r=n,o=i.prototype.thru;for(t&&e.reverse();r--;){var s=e[r];if("function"!=typeof s)throw new pc(ut);if(o&&!a&&"wrapper"==bo(s))var a=new i([],!0)}for(r=a?r:n;++r=st)return a.plant(r).value();for(var i=0,o=n?e[i].apply(this,t):r;++i1&&y.reverse(),h&&ua))return!1;var f=o.get(t);if(f&&o.get(e))return f==e;var c=-1,h=!0,l=n&vt?new yn:it;for(o.set(t,e),o.set(e,t);++c1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(ze,"{\n/* [wrapped with "+e+"] */\n")}function Bo(t){return wl(t)||ml(t)||!!(Bc&&t&&t[Bc])}function Do(t,e){return e=null==e?Bt:e,!!e&&("number"==typeof t||Xe.test(t))&&t>-1&&t%1==0&&t0){if(++e>=Lt)return arguments[0]}else e=0;return t.apply(it,arguments)}}function es(t,e){var n=-1,r=t.length,i=r-1;for(e=e===it?r:e;++n=this.__values__.length,e=t?it:this.__values__[this.__index__++];return{done:t,value:e}}function oa(){return this}function sa(t){for(var e,n=this;n instanceof r;){var i=os(n);i.__index__=0,i.__values__=it,e?o.__wrapped__=i:e=i;var o=i;n=n.__wrapped__}return o.__wrapped__=t,e}function aa(){var t=this.__wrapped__;if(t instanceof w){var e=t;return this.__actions__.length&&(e=new w(this)),e=e.reverse(),e.__actions__.push({func:ea,args:[Is],thisArg:it}),new i(e,this.__chain__)}return this.thru(Is)}function ua(){return Ei(this.__wrapped__,this.__actions__)}function fa(t,e,n){var r=wl(t)?h:Yn;return n&&Po(t,e,n)&&(e=it),r(t,ko(e,3))}function ca(t,e){var n=wl(t)?l:er;return n(t,ko(e,3))}function ha(t,e){return nr(ga(t,e),1)}function la(t,e){return nr(ga(t,e),Mt)}function da(t,e,n){return n=n===it?1:Su(n),nr(ga(t,e),n)}function pa(t,e){var n=wl(t)?f:yh;return n(t,ko(e,3))}function _a(t,e){var n=wl(t)?c:mh;return n(t,ko(e,3))}function va(t,e,n,r){t=$a(t)?t:nf(t),n=n&&!r?Su(n):0;var i=t.length;return n<0&&(n=$c(i+n,0)),yu(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&x(t,e,n)>-1}function ga(t,e){var n=wl(t)?_:Wr;return n(t,ko(e,3))}function ya(t,e,n,r){return null==t?[]:(wl(e)||(e=null==e?[]:[e]),n=r?it:n,wl(n)||(n=null==n?[]:[n]),Xr(t,e,n))}function ma(t,e,n){var r=wl(t)?g:O,i=arguments.length<3;return r(t,ko(e,4),n,i,yh)}function wa(t,e,n){var r=wl(t)?y:O,i=arguments.length<3;return r(t,ko(e,4),n,i,mh)}function ba(t,e){var n=wl(t)?l:er;return n(t,Ba(ko(e,3)))}function Ea(t){var e=wl(t)?Rn:ai;return e(t)}function ka(t,e,n){e=(n?Po(t,e,n):e===it)?1:Su(e);var r=wl(t)?Ln:ui;return r(t,e)}function xa(t){var e=wl(t)?On:ci;return e(t)}function Sa(t){if(null==t)return 0;if($a(t))return yu(t)?Q(t):t.length;var e=Oh(t);return e==Xt||e==ie?t.size:Hr(t).length}function Aa(t,e,n){var r=wl(t)?m:li;return n&&Po(t,e,n)&&(e=it),r(t,ko(e,3))}function Ta(t,e){if("function"!=typeof e)throw new pc(ut);return t=Su(t),function(){if(--t<1)return e.apply(this,arguments)}}function Ra(t,e,n){return e=n?it:e,e=t&&null==e?t.length:e,po(t,xt,it,it,it,it,e)}function La(t,e){var n;if("function"!=typeof e)throw new pc(ut);return t=Su(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=it),n}}function Oa(t,e,n){e=n?it:e;var r=po(t,wt,it,it,it,it,it,e);return r.placeholder=Oa.placeholder,r}function Ia(t,e,n){e=n?it:e;var r=po(t,bt,it,it,it,it,it,e);return r.placeholder=Ia.placeholder,r}function Ca(t,e,n){function r(e){var n=l,r=d;return l=d=it,y=e,_=t.apply(r,n)}function i(t){return y=t,v=Nh(a,e),m?r(t):_}function o(t){var n=t-g,r=t-y,i=e-n;return w?Kc(i,p-r):i}function s(t){var n=t-g,r=t-y;return g===it||n>=e||n<0||w&&r>=p}function a(){var t=ul();return s(t)?u(t):void(v=Nh(a,o(t)))}function u(t){return v=it,b&&l?r(t):(l=d=it,_)}function f(){v!==it&&Sh(v),y=0,l=g=d=v=it}function c(){return v===it?_:u(ul())}function h(){var t=ul(),n=s(t);if(l=arguments,d=this,g=t,n){if(v===it)return i(g);if(w)return v=Nh(a,e),r(g)}return v===it&&(v=Nh(a,e)),_}var l,d,p,_,v,g,y=0,m=!1,w=!1,b=!0;if("function"!=typeof t)throw new pc(ut);return e=Tu(e)||0,au(n)&&(m=!!n.leading,w="maxWait"in n,p=w?$c(Tu(n.maxWait)||0,e):p,b="trailing"in n?!!n.trailing:b),h.cancel=f,h.flush=c,h}function Na(t){return po(t,At)}function Ma(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new pc(ut);var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=t.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(Ma.Cache||ln),n}function Ba(t){if("function"!=typeof t)throw new pc(ut);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function Da(t){return La(2,t)}function Pa(t,e){if("function"!=typeof t)throw new pc(ut);return e=e===it?e:Su(e),si(t,e)}function ja(t,e){if("function"!=typeof t)throw new pc(ut);return e=e===it?0:$c(Su(e),0),si(function(n){var r=n[e],i=Ri(n,0,e);return r&&v(i,r),a(t,this,i)})}function Ua(t,e,n){var r=!0,i=!0;if("function"!=typeof t)throw new pc(ut);return au(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Ca(t,e,{leading:r,maxWait:e,trailing:i})}function za(t){return Ra(t,1)}function Fa(t,e){return pl(Ai(e),t)}function Ha(){if(!arguments.length)return[];var t=arguments[0];return wl(t)?t:[t]}function qa(t){return Fn(t,pt)}function Za(t,e){return e="function"==typeof e?e:it,Fn(t,pt,e)}function Wa(t){return Fn(t,lt|pt)}function Va(t,e){return e="function"==typeof e?e:it,Fn(t,lt|pt,e)}function Ga(t,e){return null==e||Wn(t,e,qu(e))}function Ya(t,e){return t===e||t!==t&&e!==e}function $a(t){return null!=t&&su(t.length)&&!iu(t)}function Ka(t){return uu(t)&&$a(t)}function Xa(t){return t===!0||t===!1||uu(t)&&lr(t)==Wt}function Ja(t){return uu(t)&&1===t.nodeType&&!vu(t)}function Qa(t){if(null==t)return!0;if($a(t)&&(wl(t)||"string"==typeof t||"function"==typeof t.splice||El(t)||Tl(t)||ml(t)))return!t.length;var e=Oh(t);if(e==Xt||e==ie)return!t.size;if(Ho(t))return!Hr(t).length;for(var n in t)if(wc.call(t,n))return!1;return!0}function tu(t,e){return Nr(t,e)}function eu(t,e,n){n="function"==typeof n?n:it;var r=n?n(t,e):it;return r===it?Nr(t,e,it,n):!!r}function nu(t){if(!uu(t))return!1;var e=lr(t);return e==Yt||e==Gt||"string"==typeof t.message&&"string"==typeof t.name&&!vu(t)}function ru(t){return"number"==typeof t&&Vc(t)}function iu(t){if(!au(t))return!1;var e=lr(t);return e==$t||e==Kt||e==Zt||e==ne}function ou(t){return"number"==typeof t&&t==Su(t)}function su(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Bt}function au(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function uu(t){return null!=t&&"object"==typeof t}function fu(t,e){return t===e||Dr(t,e,So(e))}function cu(t,e,n){return n="function"==typeof n?n:it,Dr(t,e,So(e),n)}function hu(t){return _u(t)&&t!=+t}function lu(t){if(Ih(t))throw new uc(at);return Pr(t)}function du(t){return null===t}function pu(t){return null==t}function _u(t){return"number"==typeof t||uu(t)&&lr(t)==Jt}function vu(t){if(!uu(t)||lr(t)!=te)return!1;var e=Ic(t);if(null===e)return!0;var n=wc.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&mc.call(n)==xc}function gu(t){return ou(t)&&t>=-Bt&&t<=Bt}function yu(t){return"string"==typeof t||!wl(t)&&uu(t)&&lr(t)==oe}function mu(t){return"symbol"==typeof t||uu(t)&&lr(t)==se}function wu(t){return t===it}function bu(t){return uu(t)&&Oh(t)==ue}function Eu(t){return uu(t)&&lr(t)==fe}function ku(t){if(!t)return[];if($a(t))return yu(t)?tt(t):Fi(t);if(Dc&&t[Dc])return W(t[Dc]());var e=Oh(t),n=e==Xt?V:e==ie?$:nf;return n(t)}function xu(t){if(!t)return 0===t?t:0;if(t=Tu(t),t===Mt||t===-Mt){var e=t<0?-1:1;return e*Dt}return t===t?t:0}function Su(t){var e=xu(t),n=e%1;return e===e?n?e-n:e:0}function Au(t){return t?zn(Su(t),0,jt):0}function Tu(t){if("number"==typeof t)return t;if(mu(t))return Pt;if(au(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=au(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Pe,"");var n=Ye.test(t);return n||Ke.test(t)?ir(t.slice(2),n?2:8):Ge.test(t)?Pt:+t}function Ru(t){return Hi(t,Zu(t))}function Lu(t){return zn(Su(t),-Bt,Bt)}function Ou(t){return null==t?"":gi(t)}function Iu(t,e){var n=gh(t);return null==e?n:Dn(n,e)}function Cu(t,e){return E(t,ko(e,3),or)}function Nu(t,e){return E(t,ko(e,3),sr)}function Mu(t,e){return null==t?t:wh(t,ko(e,3),Zu)}function Bu(t,e){return null==t?t:bh(t,ko(e,3),Zu)}function Du(t,e){return t&&or(t,ko(e,3))}function Pu(t,e){return t&&sr(t,ko(e,3))}function ju(t){return null==t?[]:ur(t,qu(t))}function Uu(t){return null==t?[]:ur(t,Zu(t))}function zu(t,e,n){var r=null==t?it:fr(t,e);return r===it?n:r}function Fu(t,e){return null!=t&&Oo(t,e,kr)}function Hu(t,e){return null!=t&&Oo(t,e,Sr)}function qu(t){return $a(t)?Tn(t):Hr(t)}function Zu(t){return $a(t)?Tn(t,!0):qr(t)}function Wu(t,e){var n={};return e=ko(e,3),or(t,function(t,r,i){jn(n,e(t,r,i),t)}),n}function Vu(t,e){var n={};return e=ko(e,3),or(t,function(t,r,i){jn(n,r,e(t,r,i))}),n}function Gu(t,e){return Yu(t,Ba(ko(e)))}function Yu(t,e){if(null==t)return{};var n=_(wo(t),function(t){return[t]});return e=ko(e),Qr(t,n,function(t,n){return e(t,n[0])})}function $u(t,e,n){e=Ti(e,t);var r=-1,i=e.length;for(i||(i=1,t=it);++re){var r=t;t=e,e=r}if(n||t%1||e%1){var i=Qc();return Kc(t+i*(e-t+rr("1e-"+((i+"").length-1))),e)}return ri(t,e)}function uf(t){return Ql(Ou(t).toLowerCase())} -function ff(t){return t=Ou(t),t&&t.replace(Je,wr).replace(Zn,"")}function cf(t,e,n){t=Ou(t),e=gi(e);var r=t.length;n=n===it?r:zn(Su(n),0,r);var i=n;return n-=e.length,n>=0&&t.slice(n,i)==e}function hf(t){return t=Ou(t),t&&Te.test(t)?t.replace(Se,br):t}function lf(t){return t=Ou(t),t&&De.test(t)?t.replace(Be,"\\$&"):t}function df(t,e,n){t=Ou(t),e=Su(e);var r=e?Q(t):0;if(!e||r>=e)return t;var i=(e-r)/2;return so(qc(i),n)+t+so(Hc(i),n)}function pf(t,e,n){t=Ou(t),e=Su(e);var r=e?Q(t):0;return e&&r>>0)?(t=Ou(t),t&&("string"==typeof e||null!=e&&!Sl(e))&&(e=gi(e),!e&&q(t))?Ri(tt(t),0,n):t.split(e,n)):[]}function wf(t,e,n){return t=Ou(t),n=zn(Su(n),0,t.length),e=gi(e),t.slice(n,n+e.length)==e}function bf(t,e,r){var i=n.templateSettings;r&&Po(t,e,r)&&(e=it),t=Ou(t),e=Cl({},e,i,In);var o,s,a=Cl({},e.imports,i.imports,In),u=qu(a),f=D(a,u),c=0,h=e.interpolate||Qe,l="__p += '",d=lc((e.escape||Qe).source+"|"+h.source+"|"+(h===Oe?We:Qe).source+"|"+(e.evaluate||Qe).source+"|$","g"),p="//# sourceURL="+("sourceURL"in e?e.sourceURL:"lodash.templateSources["+ ++Kn+"]")+"\n";t.replace(d,function(e,n,r,i,a,u){return r||(r=i),l+=t.slice(c,u).replace(tn,F),n&&(o=!0,l+="' +\n__e("+n+") +\n'"),a&&(s=!0,l+="';\n"+a+";\n__p += '"),r&&(l+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),c=u+e.length,e}),l+="';\n";var _=e.variable;_||(l="with (obj) {\n"+l+"\n}\n"),l=(s?l.replace(be,""):l).replace(Ee,"$1").replace(ke,"$1;"),l="function("+(_||"obj")+") {\n"+(_?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var v=td(function(){return fc(u,p+"return "+l).apply(it,f)});if(v.source=l,nu(v))throw v;return v}function Ef(t){return Ou(t).toLowerCase()}function kf(t){return Ou(t).toUpperCase()}function xf(t,e,n){if(t=Ou(t),t&&(n||e===it))return t.replace(Pe,"");if(!t||!(e=gi(e)))return t;var r=tt(t),i=tt(e),o=j(r,i),s=U(r,i)+1;return Ri(r,o,s).join("")}function Sf(t,e,n){if(t=Ou(t),t&&(n||e===it))return t.replace(Ue,"");if(!t||!(e=gi(e)))return t;var r=tt(t),i=U(r,tt(e))+1;return Ri(r,0,i).join("")}function Af(t,e,n){if(t=Ou(t),t&&(n||e===it))return t.replace(je,"");if(!t||!(e=gi(e)))return t;var r=tt(t),i=j(r,tt(e));return Ri(r,i).join("")}function Tf(t,e){var n=Tt,r=Rt;if(au(e)){var i="separator"in e?e.separator:i;n="length"in e?Su(e.length):n,r="omission"in e?gi(e.omission):r}t=Ou(t);var o=t.length;if(q(t)){var s=tt(t);o=s.length}if(n>=o)return t;var a=n-Q(r);if(a<1)return r;var u=s?Ri(s,0,a).join(""):t.slice(0,a);if(i===it)return u+r;if(s&&(a+=u.length-a),Sl(i)){if(t.slice(a).search(i)){var f,c=u;for(i.global||(i=lc(i.source,Ou(Ve.exec(i))+"g")),i.lastIndex=0;f=i.exec(c);)var h=f.index;u=u.slice(0,h===it?a:h)}}else if(t.indexOf(gi(i),a)!=a){var l=u.lastIndexOf(i);l>-1&&(u=u.slice(0,l))}return u+r}function Rf(t){return t=Ou(t),t&&Ae.test(t)?t.replace(xe,Er):t}function Lf(t,e,n){return t=Ou(t),e=n?it:e,e===it?Z(t)?rt(t):b(t):t.match(e)||[]}function Of(t){var e=null==t?0:t.length,n=ko();return t=e?_(t,function(t){if("function"!=typeof t[1])throw new pc(ut);return[n(t[0]),t[1]]}):[],si(function(n){for(var r=-1;++rBt)return[];var n=jt,r=Kc(t,jt);e=ko(e),t-=jt;for(var i=N(r,e);++n1?t[e-1]:it;return n="function"==typeof n?(t.pop(),n):it,Ks(t,n)}),Qh=yo(function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,o=function(e){return Un(e,t)};return!(e>1||this.__actions__.length)&&r instanceof w&&Do(n)?(r=r.slice(n,+n+(e?1:0)),r.__actions__.push({func:ea,args:[o],thisArg:it}),new i(r,this.__chain__).thru(function(t){return e&&!t.length&&t.push(it),t})):this.thru(o)}),tl=Wi(function(t,e,n){wc.call(t,n)?++t[n]:jn(t,n,1)}),el=to(ps),nl=to(_s),rl=Wi(function(t,e,n){wc.call(t,n)?t[n].push(e):jn(t,n,[e])}),il=si(function(t,e,n){var r=-1,i="function"==typeof e,o=$a(t)?sc(t.length):[];return yh(t,function(t){o[++r]=i?a(e,t,n):Lr(t,e,n)}),o}),ol=Wi(function(t,e,n){jn(t,n,e)}),sl=Wi(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]}),al=si(function(t,e){if(null==t)return[];var n=e.length;return n>1&&Po(t,e[0],e[1])?e=[]:n>2&&Po(e[0],e[1],e[2])&&(e=[e[0]]),Xr(t,nr(e,1),[])}),ul=zc||function(){return ar.Date.now()},fl=si(function(t,e,n){var r=gt;if(n.length){var i=Y(n,Eo(fl));r|=Et}return po(t,r,e,n,i)}),cl=si(function(t,e,n){var r=gt|yt;if(n.length){var i=Y(n,Eo(cl));r|=Et}return po(e,r,t,n,i)}),hl=si(function(t,e){return Vn(t,1,e)}),ll=si(function(t,e,n){return Vn(t,Tu(e)||0,n)});Ma.Cache=ln;var dl=xh(function(t,e){e=1==e.length&&wl(e[0])?_(e[0],B(ko())):_(nr(e,1),B(ko()));var n=e.length;return si(function(r){for(var i=-1,o=Kc(r.length,n);++i=e}),ml=Or(function(){return arguments}())?Or:function(t){return uu(t)&&wc.call(t,"callee")&&!Nc.call(t,"callee")},wl=sc.isArray,bl=dr?B(dr):Ir,El=Wc||Wf,kl=pr?B(pr):Cr,xl=_r?B(_r):Br,Sl=vr?B(vr):jr,Al=gr?B(gr):Ur,Tl=yr?B(yr):zr,Rl=fo(Zr),Ll=fo(function(t,e){return t<=e}),Ol=Vi(function(t,e){if(Ho(e)||$a(e))return void Hi(e,qu(e),t);for(var n in e)wc.call(e,n)&&Nn(t,n,e[n])}),Il=Vi(function(t,e){Hi(e,Zu(e),t)}),Cl=Vi(function(t,e,n,r){Hi(e,Zu(e),t,r)}),Nl=Vi(function(t,e,n,r){Hi(e,qu(e),t,r)}),Ml=yo(Un),Bl=si(function(t){return t.push(it,In),a(Cl,it,t)}),Dl=si(function(t){return t.push(it,Go),a(Fl,it,t)}),Pl=ro(function(t,e,n){t[e]=n},Cf(Mf)),jl=ro(function(t,e,n){wc.call(t,e)?t[e].push(n):t[e]=[n]},ko),Ul=si(Lr),zl=Vi(function(t,e,n){Yr(t,e,n)}),Fl=Vi(function(t,e,n,r){Yr(t,e,n,r)}),Hl=yo(function(t,e){var n={};if(null==t)return n;var r=!1;e=_(e,function(e){return e=Ti(e,t),r||(r=e.length>1),e}),Hi(t,wo(t),n),r&&(n=Fn(n,lt|dt|pt));for(var i=e.length;i--;)mi(n,e[i]);return n}),ql=yo(function(t,e){return null==t?{}:Jr(t,e)}),Zl=lo(qu),Wl=lo(Zu),Vl=Xi(function(t,e,n){return e=e.toLowerCase(),t+(n?uf(e):e)}),Gl=Xi(function(t,e,n){return t+(n?"-":"")+e.toLowerCase()}),Yl=Xi(function(t,e,n){return t+(n?" ":"")+e.toLowerCase()}),$l=Ki("toLowerCase"),Kl=Xi(function(t,e,n){return t+(n?"_":"")+e.toLowerCase()}),Xl=Xi(function(t,e,n){return t+(n?" ":"")+Ql(e)}),Jl=Xi(function(t,e,n){return t+(n?" ":"")+e.toUpperCase()}),Ql=Ki("toUpperCase"),td=si(function(t,e){try{return a(t,it,e)}catch(t){return nu(t)?t:new uc(t)}}),ed=yo(function(t,e){return f(e,function(e){e=ns(e),jn(t,e,fl(t[e],t))}),t}),nd=eo(),rd=eo(!0),id=si(function(t,e){return function(n){return Lr(n,t,e)}}),od=si(function(t,e){return function(n){return Lr(t,n,e)}}),sd=oo(_),ad=oo(h),ud=oo(m),fd=uo(),cd=uo(!0),hd=io(function(t,e){return t+e},0),ld=ho("ceil"),dd=io(function(t,e){return t/e},1),pd=ho("floor"),_d=io(function(t,e){return t*e},1),vd=ho("round"),gd=io(function(t,e){return t-e},0);return n.after=Ta,n.ary=Ra,n.assign=Ol,n.assignIn=Il,n.assignInWith=Cl,n.assignWith=Nl,n.at=Ml,n.before=La,n.bind=fl,n.bindAll=ed,n.bindKey=cl,n.castArray=Ha,n.chain=Qs,n.chunk=ss,n.compact=as,n.concat=us,n.cond=Of,n.conforms=If,n.constant=Cf,n.countBy=tl,n.create=Iu,n.curry=Oa,n.curryRight=Ia,n.debounce=Ca,n.defaults=Bl,n.defaultsDeep=Dl,n.defer=hl,n.delay=ll,n.difference=Dh,n.differenceBy=Ph,n.differenceWith=jh,n.drop=fs,n.dropRight=cs,n.dropRightWhile=hs,n.dropWhile=ls,n.fill=ds,n.filter=ca,n.flatMap=ha,n.flatMapDeep=la,n.flatMapDepth=da,n.flatten=vs,n.flattenDeep=gs,n.flattenDepth=ys,n.flip=Na,n.flow=nd,n.flowRight=rd,n.fromPairs=ms,n.functions=ju,n.functionsIn=Uu,n.groupBy=rl,n.initial=Es,n.intersection=Uh,n.intersectionBy=zh,n.intersectionWith=Fh,n.invert=Pl,n.invertBy=jl,n.invokeMap=il,n.iteratee=Bf,n.keyBy=ol,n.keys=qu,n.keysIn=Zu,n.map=ga,n.mapKeys=Wu,n.mapValues=Vu,n.matches=Df,n.matchesProperty=Pf,n.memoize=Ma,n.merge=zl,n.mergeWith=Fl,n.method=id,n.methodOf=od,n.mixin=jf,n.negate=Ba,n.nthArg=Ff,n.omit=Hl,n.omitBy=Gu,n.once=Da,n.orderBy=ya,n.over=sd,n.overArgs=dl,n.overEvery=ad,n.overSome=ud,n.partial=pl,n.partialRight=_l,n.partition=sl,n.pick=ql,n.pickBy=Yu,n.property=Hf,n.propertyOf=qf,n.pull=Hh,n.pullAll=Ts,n.pullAllBy=Rs,n.pullAllWith=Ls,n.pullAt=qh,n.range=fd,n.rangeRight=cd,n.rearg=vl,n.reject=ba,n.remove=Os,n.rest=Pa,n.reverse=Is,n.sampleSize=ka,n.set=Ku,n.setWith=Xu,n.shuffle=xa,n.slice=Cs,n.sortBy=al,n.sortedUniq=Us,n.sortedUniqBy=zs,n.split=mf,n.spread=ja,n.tail=Fs,n.take=Hs,n.takeRight=qs,n.takeRightWhile=Zs,n.takeWhile=Ws,n.tap=ta,n.throttle=Ua,n.thru=ea,n.toArray=ku,n.toPairs=Zl,n.toPairsIn=Wl,n.toPath=Kf,n.toPlainObject=Ru,n.transform=Ju,n.unary=za,n.union=Zh,n.unionBy=Wh,n.unionWith=Vh,n.uniq=Vs,n.uniqBy=Gs,n.uniqWith=Ys,n.unset=Qu,n.unzip=$s,n.unzipWith=Ks,n.update=tf,n.updateWith=ef,n.values=nf,n.valuesIn=rf,n.without=Gh,n.words=Lf,n.wrap=Fa,n.xor=Yh,n.xorBy=$h,n.xorWith=Kh,n.zip=Xh,n.zipObject=Xs,n.zipObjectDeep=Js,n.zipWith=Jh,n.entries=Zl,n.entriesIn=Wl,n.extend=Il,n.extendWith=Cl,jf(n,n),n.add=hd,n.attempt=td,n.camelCase=Vl,n.capitalize=uf,n.ceil=ld,n.clamp=of,n.clone=qa,n.cloneDeep=Wa,n.cloneDeepWith=Va,n.cloneWith=Za,n.conformsTo=Ga,n.deburr=ff,n.defaultTo=Nf,n.divide=dd,n.endsWith=cf,n.eq=Ya,n.escape=hf,n.escapeRegExp=lf,n.every=fa,n.find=el,n.findIndex=ps,n.findKey=Cu,n.findLast=nl,n.findLastIndex=_s,n.findLastKey=Nu,n.floor=pd,n.forEach=pa,n.forEachRight=_a,n.forIn=Mu,n.forInRight=Bu,n.forOwn=Du,n.forOwnRight=Pu,n.get=zu,n.gt=gl,n.gte=yl,n.has=Fu,n.hasIn=Hu,n.head=ws,n.identity=Mf,n.includes=va,n.indexOf=bs,n.inRange=sf,n.invoke=Ul,n.isArguments=ml,n.isArray=wl,n.isArrayBuffer=bl,n.isArrayLike=$a,n.isArrayLikeObject=Ka,n.isBoolean=Xa,n.isBuffer=El,n.isDate=kl,n.isElement=Ja,n.isEmpty=Qa,n.isEqual=tu,n.isEqualWith=eu,n.isError=nu,n.isFinite=ru,n.isFunction=iu,n.isInteger=ou,n.isLength=su,n.isMap=xl,n.isMatch=fu,n.isMatchWith=cu,n.isNaN=hu,n.isNative=lu,n.isNil=pu,n.isNull=du,n.isNumber=_u,n.isObject=au,n.isObjectLike=uu,n.isPlainObject=vu,n.isRegExp=Sl,n.isSafeInteger=gu,n.isSet=Al,n.isString=yu,n.isSymbol=mu,n.isTypedArray=Tl,n.isUndefined=wu,n.isWeakMap=bu,n.isWeakSet=Eu,n.join=ks,n.kebabCase=Gl,n.last=xs,n.lastIndexOf=Ss,n.lowerCase=Yl,n.lowerFirst=$l,n.lt=Rl,n.lte=Ll,n.max=Jf,n.maxBy=Qf,n.mean=tc,n.meanBy=ec,n.min=nc,n.minBy=rc,n.stubArray=Zf,n.stubFalse=Wf,n.stubObject=Vf,n.stubString=Gf,n.stubTrue=Yf,n.multiply=_d,n.nth=As,n.noConflict=Uf,n.noop=zf,n.now=ul,n.pad=df,n.padEnd=pf,n.padStart=_f,n.parseInt=vf,n.random=af,n.reduce=ma,n.reduceRight=wa,n.repeat=gf,n.replace=yf,n.result=$u,n.round=vd,n.runInContext=t,n.sample=Ea,n.size=Sa,n.snakeCase=Kl,n.some=Aa,n.sortedIndex=Ns,n.sortedIndexBy=Ms,n.sortedIndexOf=Bs,n.sortedLastIndex=Ds,n.sortedLastIndexBy=Ps,n.sortedLastIndexOf=js,n.startCase=Xl,n.startsWith=wf,n.subtract=gd,n.sum=ic,n.sumBy=oc,n.template=bf,n.times=$f,n.toFinite=xu,n.toInteger=Su,n.toLength=Au,n.toLower=Ef,n.toNumber=Tu,n.toSafeInteger=Lu,n.toString=Ou,n.toUpper=kf,n.trim=xf,n.trimEnd=Sf,n.trimStart=Af,n.truncate=Tf,n.unescape=Rf,n.uniqueId=Xf,n.upperCase=Jl,n.upperFirst=Ql,n.each=pa,n.eachRight=_a,n.first=ws,jf(n,function(){var t={};return or(n,function(e,r){wc.call(n.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),n.VERSION=ot,f(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){n[t].placeholder=n}),f(["drop","take"],function(t,e){w.prototype[t]=function(n){var r=this.__filtered__;if(r&&!e)return new w(this);n=n===it?1:$c(Su(n),0);var i=this.clone();return r?i.__takeCount__=Kc(n,i.__takeCount__):i.__views__.push({size:Kc(n,jt),type:t+(i.__dir__<0?"Right":"")}),i},w.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),f(["filter","map","takeWhile"],function(t,e){var n=e+1,r=n==It||n==Nt;w.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:ko(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}}),f(["head","last"],function(t,e){var n="take"+(e?"Right":"");w.prototype[t]=function(){return this[n](1).value()[0]}}),f(["initial","tail"],function(t,e){var n="drop"+(e?"":"Right");w.prototype[t]=function(){return this.__filtered__?new w(this):this[n](1)}}),w.prototype.compact=function(){return this.filter(Mf)},w.prototype.find=function(t){return this.filter(t).head()},w.prototype.findLast=function(t){return this.reverse().find(t)},w.prototype.invokeMap=si(function(t,e){return"function"==typeof t?new w(this):this.map(function(n){return Lr(n,t,e)})}),w.prototype.reject=function(t){return this.filter(Ba(ko(t)))},w.prototype.slice=function(t,e){t=Su(t);var n=this;return n.__filtered__&&(t>0||e<0)?new w(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==it&&(e=Su(e),n=e<0?n.dropRight(-e):n.take(e-t)),n)},w.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},w.prototype.toArray=function(){return this.take(jt)},or(w.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),o=/^(?:head|last)$/.test(e),s=n[o?"take"+("last"==e?"Right":""):e],a=o||/^find/.test(e);s&&(n.prototype[e]=function(){var e=this.__wrapped__,u=o?[1]:arguments,f=e instanceof w,c=u[0],h=f||wl(e),l=function(t){var e=s.apply(n,v([t],u));return o&&d?e[0]:e};h&&r&&"function"==typeof c&&1!=c.length&&(f=h=!1);var d=this.__chain__,p=!!this.__actions__.length,_=a&&!d,g=f&&!p;if(!a&&h){e=g?e:new w(this);var y=t.apply(e,u);return y.__actions__.push({func:ea,args:[l],thisArg:it}),new i(y,d)}return _&&g?t.apply(this,u):(y=this.thru(l),_?o?y.value()[0]:y.value():y)})}),f(["pop","push","shift","sort","splice","unshift"],function(t){var e=_c[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",i=/^(?:pop|shift)$/.test(t);n.prototype[t]=function(){var t=arguments;if(i&&!this.__chain__){var n=this.value();return e.apply(wl(n)?n:[],t)}return this[r](function(n){return e.apply(wl(n)?n:[],t)})}}),or(w.prototype,function(t,e){var r=n[e];if(r){var i=r.name+"",o=uh[i]||(uh[i]=[]);o.push({name:e,func:r})}}),uh[no(it,yt).name]=[{name:"wrapper",func:it}],w.prototype.clone=L,w.prototype.reverse=X,w.prototype.value=et,n.prototype.at=Qh,n.prototype.chain=na,n.prototype.commit=ra,n.prototype.next=ia,n.prototype.plant=sa,n.prototype.reverse=aa,n.prototype.toJSON=n.prototype.valueOf=n.prototype.value=ua,n.prototype.first=n.prototype.head,Dc&&(n.prototype[Dc]=oa),n},xr=kr();ar._=xr,r=function(){return xr}.call(e,n,e,i),!(r!==it&&(i.exports=r))}).call(this)}).call(e,function(){return this}(),n(12)(t))},function(t,e,n){function r(t,e,n){var r=e&&n||0,i=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){i<16&&(e[r+i++]=f[t])});i<16;)e[r+i++]=0;return e}function i(t,e){var n=e||0,r=u;return r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]}function o(t,e,n){var r=e&&n||0,o=e||[];t=t||{};var s=void 0!==t.clockseq?t.clockseq:d,a=void 0!==t.msecs?t.msecs:(new Date).getTime(),u=void 0!==t.nsecs?t.nsecs:_+1,f=a-p+(u-_)/1e4;if(f<0&&void 0===t.clockseq&&(s=s+1&16383),(f<0||a>p)&&void 0===t.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");p=a,_=u,d=s,a+=122192928e5;var c=(1e4*(268435455&a)+u)%4294967296;o[r++]=c>>>24&255,o[r++]=c>>>16&255,o[r++]=c>>>8&255,o[r++]=255&c;var h=a/4294967296*1e4&268435455;o[r++]=h>>>8&255,o[r++]=255&h,o[r++]=h>>>24&15|16,o[r++]=h>>>16&255,o[r++]=s>>>8|128,o[r++]=255&s;for(var v=t.node||l,g=0;g<6;g++)o[r+g]=v[g];return e?e:i(o)}function s(t,e,n){var r=e&&n||0;"string"==typeof t&&(e="binary"==t?new Array(16):null,t=null),t=t||{};var o=t.random||(t.rng||a)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,e)for(var s=0;s<16;s++)e[r+s]=o[s];return e||i(o)}for(var a=n(101),u=[],f={},c=0;c<256;c++)u[c]=(c+256).toString(16).substr(1),f[u[c]]=c;var h=a(),l=[1|h[0],h[1],h[2],h[3],h[4],h[5]],d=16383&(h[6]<<8|h[7]),p=0,_=0,v=s;v.v1=o,v.v4=s,v.parse=r,v.unparse=i,t.exports=v},function(t,e){(function(e){var n,r=e.crypto||e.msCrypto;if(r&&r.getRandomValues){var i=new Uint8Array(16);n=function(){return r.getRandomValues(i),i}}if(!n){var o=new Array(16);n=function(){for(var t,e=0;e<16;e++)0===(3&e)&&(t=4294967296*Math.random()),o[e]=t>>>((3&e)<<3)&255;return o}}t.exports=n}).call(e,function(){return this}())},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function(){function t(t,e){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new Promise(function(s,a){i.Authorization="Bearer "+n.client.accessToken,o[t.toLowerCase()]("https://"+n.client.hostAndPort+e).set(i).send(r).then(function(t){return s(t.body)},a)})}},{key:"sendMessage",value:function(t,e){return this.makeRequest("post",a.channelMessages(t),{content:e})}},{key:"editMessage",value:function(t,e,n){return this.makeRequest("patch",a.channelMessage(t,e),{content:n})}},{key:"deleteMessage",value:function(t,e){return this.makeRequest("delete",a.channelMessage(t,e))}}]),t}()}]); \ No newline at end of file +!function(t){function n(r){if(e[r])return e[r].exports;var i=e[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var e={};return n.m=t,n.c=e,n.p="",n(0)}([function(t,n,e){"use strict";t.exports={version:e(1).version,Client:e(2),Rest:e(15),Constants:e(5)},"undefined"!=typeof window&&(window.DiscordRPC=t.exports)},function(t,n){t.exports={name:"discord-rpc",version:"1.1.2",description:"A simple RPC client for Discord somewhat stolen from the Discord StreamKit.",main:"src/index.js",repository:{type:"git",url:"git+https://github.com/GusCaplan/discord-rpc.git"},scripts:{"web-dist":"npm install && ./node_modules/parallel-webpack/bin/run.js"},author:"Gus Caplan ",license:"MIT",bugs:{url:"https://github.com/GusCaplan/discord-rpc/issues"},homepage:"https://github.com/GusCaplan/discord-rpc#readme",dependencies:{lodash:"^4.17.2",superagent:"^2.3.0",uuid:"^2.0.3",ws:"^1.1.1"},devDependencies:{"babel-core":"^6.18.2","babel-loader":"^6.2.8","babel-preset-es2015":"^6.18.0",bufferutil:"^1.2.1","ignore-loader":"^0.1.2","json-loader":"^0.5.4","parallel-webpack":"^1.5.0","utf-8-validate":"^1.2.1",webpack:"^1.13.3"},browser:{ws:!1}}},function(t,n,e){"use strict";function r(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function i(t,n,e){return t+":"+(n||e)}var u=function(){function t(t,n){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:this.accessToken,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.connected){this.accessToken=t;var e=6463+n%10;this.hostAndPort=v()+".discordapp.io:"+e,this.socket=new o("wss://"+this.hostAndPort+"/?v=1&client_id="+this.OAUTH2_CLIENT_ID),this.socket.onopen=this._handleOpen.bind(this),this.socket.onclose=this._handleClose.bind(this),this.socket.onmessage=this._handleMessage.bind(this)}}},{key:"disconnect",value:function(t){this.connected&&(this.requestedDisconnect=!0,this.socket.close(),t&&t())}},{key:"reconnect",value:function(){this.connected&&this.socket.close()}},{key:"authenticate",value:function(){var t=this;if(!this.authenticated)return this.accessToken?void this.request("AUTHENTICATE",{access_token:this.accessToken},function(n,e){return n&&n.code===l.INVALID_TOKEN?void t.authorize():(t.authenticated=!0,t.flushQueue(),void t.activeSubscriptions.forEach(function(n){return t.subscribe(n.evt,n.args,n.callback)}))}):void this.authorize()}},{key:"flushQueue",value:function(){var t=this.queue;this.queue=[],t.forEach(function(t){return t()})}},{key:"authorize",value:function(){var t=this;this.authenticated||h.get(this.API_ENDPOINT+"/token").then(function(n){if(!n.ok||!n.body.rpc_token)throw new Error("no rpc token");return t.request("AUTHORIZE",{client_id:t.OAUTH2_CLIENT_ID,scopes:["rpc","rpc.api"],rpc_token:n.body.rpc_token})}).then(function(n){return h.post(t.API_ENDPOINT+"/token").send({code:n.code})}).then(function(n){if(!n.ok)throw new Error("no access token");t.accessToken=n.body.access_token,t.authenticate()}).catch(function(n){setTimeout(t.authorize.bind(t),3e3)})}},{key:"request",value:function(t,n,e,r){var u=this;return"function"==typeof e&&(r=e,e=void 0),new Promise(function(o,a){if(!u.connected||!u.ready||!u.authenticated&&["AUTHORIZE","AUTHENTICATE"].indexOf(t)===-1)return void u.queue.push(function(){return u.request(t,n,e,r)});var s=v();u.evts.once(i(c.DISPATCH,s),function(t,n){r&&r(t,n),t?a(t):o(n)}),u.socket.send(JSON.stringify({cmd:t,args:n,evt:e,nonce:s}))})}},{key:"subscribe",value:function(t,n,e){var r=this;this.request(c.SUBSCRIBE,n,t,function(u){return u?void(e&&e(u)):void(r.activeSubscriptions.find(function(t){return e===t.callback})||(r.activeSubscriptions.push({evt:t,args:n,callback:e}),r.evts.on(i(c.DISPATCH,null,t),function(t){e&&e(null,t)})))})}},{key:"unsubscribe",value:function(t,n,e){var r=this;this.request(c.UNSUBSCRIBE,n,t,function(u){if(u)return void(e&&e(u));p.remove(r.activeSubscriptions,function(e){return t===e.evt&&p.isEqual(n,e.args)});var o=i(c.DISPATCH,null,t);r.evts.listeners(o).forEach(function(t){r.evts.removeListener(o,t)}),e&&e()})}},{key:"_handleOpen",value:function(){this.connected=!0,this.authenticate()}},{key:"_handleClose",value:function(t){var n=this;if(this.connected=!1,this.authenticated=!1,this.ready=!1,console.error("WS Closed:",t),this.requestedDisconnect)return void(this.requestedDisconnect=!1);try{this.socket.close()}catch(t){}setTimeout(function(){return n.connect(null,1006===t.code?++n.connectionTries:0)},250)}},{key:"_handleMessage",value:function(t){var n=null;try{n=JSON.parse(t.data)}catch(t){return void console.error("Payload not JSON:",n)}var e=n,r=e.cmd,u=e.evt,o=e.nonce,a=e.data;if(r===c.AUTHENTICATE){if(u===f.ERROR)return void this.evts.emit("ERROR",a);this.user=a.user,this.application=a.application,this.evts.emit("READY",a)}if(r===c.DISPATCH)return u===f.READY?(this.config=a.config,this.ready=!0,void this.flushQueue()):u===f.ERROR?(console.error("Dispatched Error",a),void this.socket.close()):void this.evts.emit(i(c.DISPATCH,null,u),a);var s=null;u===f.ERROR&&(s=new Error(a.message),s.code=a.code,a=null),this.evts.emit(i(c.DISPATCH,o),s,a)}}]),t}();t.exports=d},function(t,n){},function(t,n){function e(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(t){return"function"==typeof t}function i(t){return"number"==typeof t}function u(t){return"object"==typeof t&&null!==t}function o(t){return void 0===t}t.exports=e,e.EventEmitter=e,e.prototype._events=void 0,e.prototype._maxListeners=void 0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(t){if(!i(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},e.prototype.emit=function(t){var n,e,i,a,s,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||u(this._events.error)&&!this._events.error.length)){if(n=arguments[1],n instanceof Error)throw n;var f=new Error('Uncaught, unspecified "error" event. ('+n+")");throw f.context=n,f}if(e=this._events[t],o(e))return!1;if(r(e))switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),e.apply(this,a)}else if(u(e))for(a=Array.prototype.slice.call(arguments,1),c=e.slice(),i=c.length,s=0;s0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(t,n){function e(){this.removeListener(t,e),i||(i=!0,n.apply(this,arguments))}if(!r(n))throw TypeError("listener must be a function");var i=!1;return e.listener=n,this.on(t,e),this},e.prototype.removeListener=function(t,n){var e,i,o,a;if(!r(n))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(e=this._events[t],o=e.length,i=-1,e===n||r(e.listener)&&e.listener===n)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,n);else if(u(e)){for(a=o;a-- >0;)if(e[a]===n||e[a].listener&&e[a].listener===n){i=a;break}if(i<0)return this;1===e.length?(e.length=0,delete this._events[t]):e.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,n)}return this},e.prototype.removeAllListeners=function(t){var n,e;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(n in this._events)"removeListener"!==n&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events={},this}if(e=this._events[t],r(e))this.removeListener(t,e);else if(e)for(;e.length;)this.removeListener(t,e[e.length-1]);return delete this._events[t],this},e.prototype.listeners=function(t){var n;return n=this._events&&this._events[t]?r(this._events[t])?[this._events[t]]:this._events[t].slice():[]},e.prototype.listenerCount=function(t){if(this._events){var n=this._events[t];if(r(n))return 1;if(n)return n.length}return 0},e.listenerCount=function(t,n){return t.listenerCount(n)}},function(t,n){"use strict";var e=function(t){var n={},e=!0,r=!1,i=void 0;try{for(var u,o=t[Symbol.iterator]();!(e=(u=o.next()).done);e=!0){var a=u.value;n[a]=a}}catch(t){r=!0,i=t}finally{try{!e&&o.return&&o.return()}finally{if(r)throw i}}return n};t.exports.RPCCommands=e(["DISPATCH","AUTHORIZE","AUTHENTICATE","GET_GUILD","GET_GUILDS","GET_CHANNEL","GET_CHANNELS","SUBSCRIBE","UNSUBSCRIBE","SET_LOCAL_VOLUME","SELECT_VOICE_CHANNEL"]),t.exports.RPCEvents=e(["GUILD_STATUS","VOICE_STATE_CREATE","VOICE_STATE_DELETE","VOICE_STATE_UPDATE","SPEAKING_START","SPEAKING_STOP","MESSAGE_CREATE","MESSAGE_UPDATE","MESSAGE_DELETE","READY","ERROR"]),t.exports.RPCErrors={UNKNOWN_ERROR:1e3,INVALID_PAYLOAD:4e3,INVALID_VERSION:4001,INVALID_COMMAND:4002,INVALID_GUILD:4003,INVALID_EVENT:4004,INVALID_CHANNEL:4005,INVALID_PERMISSIONS:4006,INVALID_CLIENTID:4007,INVALID_ORIGIN:4008,INVALID_TOKEN:4009,INVALID_USER:4010,OAUTH2_ERROR:5e3},t.exports.RPCCloseCodes={INVALID_CLIENTID:4e3,INVALID_ORIGIN:4001,RATELIMITED:4002,TOKEN_REVOKED:4003},t.exports.ChannelTypes={DM:1,GROUP_DM:3,GUILD_TEXT:0,GUILD_VOICE:2};var r=t.exports.Endpoints={login:"/auth/login",logout:"/auth/logout",gateway:"/gateway",botGateway:"/gateway/bot",invite:function(t){return"/invite/"+t},inviteLink:function(t){return"https://discord.gg/"+t},CDN:"https://cdn.discordapp.com",user:function(t){return"/users/"+t},userChannels:function(t){return r.user(t)+"/channels"},userProfile:function(t){return r.user(t)+"/profile"},avatar:function(t,n){return"1"===t?n:r.user(t)+"/avatars/"+n+".jpg"},me:"/users/@me",meGuild:function(t){return r.me+"/guilds/"+t},relationships:function(t){return r.user(t)+"/relationships"},note:function(t){return r.me+"/notes/"+t},guilds:"/guilds",guild:function(t){return r.guilds+"/"+t},guildIcon:function(t,n){return r.guild(t)+"/icons/"+n+".jpg"},guildPrune:function(t){return r.guild(t)+"/prune"},guildEmbed:function(t){return r.guild(t)+"/embed"},guildInvites:function(t){return r.guild(t)+"/invites"},guildRoles:function(t){return r.guild(t)+"/roles"},guildRole:function(t,n){return r.guildRoles(t)+"/"+n},guildBans:function(t){return r.guild(t)+"/bans"},guildIntegrations:function(t){return r.guild(t)+"/integrations"},guildMembers:function(t){return r.guild(t)+"/members"},guildMember:function(t,n){return r.guildMembers(t)+"/"+n},guildMemberRole:function(t,n,e){return r.guildMember(t,n)+"/roles/"+e+"}"},stupidInconsistentGuildEndpoint:function(t){return r.guildMember(t,"@me")+"/nick"},guildChannels:function(t){return r.guild(t)+"/channels"},guildEmojis:function(t){return r.guild(t)+"/emojis"},channels:"/channels",channel:function(t){return r.channels+"/"+t},channelMessages:function(t){return r.channel(t)+"/messages"},channelInvites:function(t){return r.channel(t)+"/invites"},channelTyping:function(t){return r.channel(t)+"/typing"},channelPermissions:function(t){return r.channel(t)+"/permissions"},channelMessage:function(t,n){return r.channelMessages(t)+"/"+n},channelWebhooks:function(t){return r.channel(t)+"/webhooks"},messageReactions:function(t,n){return r.channelMessage(t,n)+"/reactions"},messageReaction:function(t,n,e,i){return r.messageReactions(t,n)+"/"+e+(i?"?limit="+i:"")},selfMessageReaction:function(t,n,e,i){return r.messageReaction(t,n,e,i)+"/@me"},userMessageReaction:function(t,n,e,i,u){return r.messageReaction(t,n,e,i)+"/"+u},webhook:function(t,n){return"/webhooks/"+t+(n?"/"+n:"")},myApplication:"/oauth2/applications/@me",getApp:function(t){return"/oauth2/authorize?client_id="+t}}},function(t,n,e){function r(){}function i(t){if(!g(t))return t;var n=[];for(var e in t)u(n,e,t[e]);return n.join("&")}function u(t,n,e){if(null!=e)if(Array.isArray(e))e.forEach(function(e){u(t,n,e)});else if(g(e))for(var r in e)u(t,n+"["+r+"]",e[r]);else t.push(encodeURIComponent(n)+"="+encodeURIComponent(e));else null===e&&t.push(encodeURIComponent(n))}function o(t){for(var n,e,r={},i=t.split("&"),u=0,o=i.length;u=300)&&(r=new Error(n.statusText||"Unsuccessful HTTP response"),r.original=t,r.response=n,r.status=n.status)}catch(t){r=t}r?e.callback(r,n):e.callback(null,n)})}function p(t,n){var e=y("DELETE",t);return n&&e.end(n),e}var v;"undefined"!=typeof window?v=window:"undefined"!=typeof self?v=self:(console.warn("Using browser-only version of superagent in non-browser environment"),v=this);var _=e(7),d=e(8),g=e(9),y=t.exports=e(10).bind(null,h);y.getXHR=function(){if(!(!v.XMLHttpRequest||v.location&&"file:"==v.location.protocol&&v.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}throw Error("Browser-only verison of superagent could not find XHR")};var m="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};y.serializeObject=i,y.parseString=o,y.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":i,"application/json":JSON.stringify},y.parse={"application/x-www-form-urlencoded":o,"application/json":JSON.parse},l.prototype.get=function(t){return this.header[t.toLowerCase()]},l.prototype._setHeaderProperties=function(t){var n=this.header["content-type"]||"";this.type=c(n);var e=f(n);for(var r in e)this[r]=e[r]},l.prototype._parseBody=function(t){var n=y.parse[this.type];return!n&&s(this.type)&&(n=y.parse["application/json"]),n&&t&&(t.length||t instanceof Object)?n(t):null},l.prototype._setStatusProperties=function(t){1223===t&&(t=204);var n=t/100|0;this.status=this.statusCode=t,this.statusType=n,this.info=1==n,this.ok=2==n,this.clientError=4==n,this.serverError=5==n,this.error=(4==n||5==n)&&this.toError(),this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},l.prototype.toError=function(){var t=this.req,n=t.method,e=t.url,r="cannot "+n+" "+e+" ("+this.status+")",i=new Error(r);return i.status=this.status,i.method=n,i.url=e,i},y.Response=l,_(h.prototype);for(var b in d)h.prototype[b]=d[b];h.prototype.type=function(t){return this.set("Content-Type",y.types[t]||t),this},h.prototype.responseType=function(t){return this._responseType=t,this},h.prototype.accept=function(t){return this.set("Accept",y.types[t]||t),this},h.prototype.auth=function(t,n,e){switch(e||(e={type:"basic"}),e.type){case"basic":var r=btoa(t+":"+n);this.set("Authorization","Basic "+r);break;case"auto":this.username=t,this.password=n}return this},h.prototype.query=function(t){return"string"!=typeof t&&(t=i(t)),t&&this._query.push(t),this},h.prototype.attach=function(t,n,e){return this._getFormData().append(t,n,e||n.name),this},h.prototype._getFormData=function(){return this._formData||(this._formData=new v.FormData),this._formData},h.prototype.callback=function(t,n){var e=this._callback;this.clearTimeout(),e(t,n)},h.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},h.prototype._timeoutError=function(){var t=this._timeout,n=new Error("timeout of "+t+"ms exceeded");n.timeout=t,this.callback(n)},h.prototype._appendQueryString=function(){var t=this._query.join("&");t&&(this.url+=~this.url.indexOf("?")?"&"+t:"?"+t)},h.prototype.end=function(t){var n=this,e=this.xhr=y.getXHR(),i=this._timeout,u=this._formData||this._data;this._callback=t||r,e.onreadystatechange=function(){if(4==e.readyState){var t;try{t=e.status}catch(n){t=0}if(0==t){if(n.timedout)return n._timeoutError();if(n._aborted)return;return n.crossDomainError()}n.emit("end")}};var o=function(t,e){e.total>0&&(e.percent=e.loaded/e.total*100),e.direction=t,n.emit("progress",e)};if(this.hasListeners("progress"))try{e.onprogress=o.bind(null,"download"),e.upload&&(e.upload.onprogress=o.bind(null,"upload"))}catch(t){}if(i&&!this._timer&&(this._timer=setTimeout(function(){n.timedout=!0,n.abort()},i)),this._appendQueryString(),this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0),this._withCredentials&&(e.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof u&&!this._isHost(u)){var a=this._header["content-type"],c=this._serializer||y.serialize[a?a.split(";")[0]:""];!c&&s(a)&&(c=y.serialize["application/json"]),c&&(u=c(u))}for(var f in this.header)null!=this.header[f]&&e.setRequestHeader(f,this.header[f]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send("undefined"!=typeof u?u:null),this},y.Request=h,y.get=function(t,n,e){var r=y("GET",t);return"function"==typeof n&&(e=n,n=null),n&&r.query(n),e&&r.end(e),r},y.head=function(t,n,e){var r=y("HEAD",t);return"function"==typeof n&&(e=n,n=null),n&&r.send(n),e&&r.end(e),r},y.options=function(t,n,e){var r=y("OPTIONS",t);return"function"==typeof n&&(e=n,n=null),n&&r.send(n),e&&r.end(e),r},y.del=p,y.delete=p,y.patch=function(t,n,e){var r=y("PATCH",t);return"function"==typeof n&&(e=n,n=null),n&&r.send(n),e&&r.end(e),r},y.post=function(t,n,e){var r=y("POST",t);return"function"==typeof n&&(e=n,n=null),n&&r.send(n),e&&r.end(e),r},y.put=function(t,n,e){var r=y("PUT",t);return"function"==typeof n&&(e=n,n=null),n&&r.send(n),e&&r.end(e),r}},function(t,n,e){function r(t){if(t)return i(t)}function i(t){for(var n in r.prototype)t[n]=r.prototype[n];return t}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,n){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(n),this},r.prototype.once=function(t,n){function e(){this.off(t,e),n.apply(this,arguments)}return e.fn=n,this.on(t,e),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,n){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var e=this._callbacks["$"+t];if(!e)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var r,i=0;i-1}function v(t,n,e){for(var r=-1,i=null==t?0:t.length;++r-1;);return e}function z(t,n){for(var e=t.length;e--&&A(n,t[e],0)>-1;);return e}function q(t,n){for(var e=t.length,r=0;e--;)t[e]===n&&++r;return r}function H(t){return"\\"+er[t]}function B(t,n){return null==t?it:t[n]}function W(t){return Fe.test(t)}function $(t){return Ke.test(t)}function G(t){for(var n,e=[];!(n=t.next()).done;)e.push(n.value);return e}function V(t){var n=-1,e=Array(t.size);return t.forEach(function(t,r){e[++n]=[r,t]}),e}function F(t,n){return function(e){return t(n(e))}}function K(t,n){for(var e=-1,r=t.length,i=0,u=[];++e>>1,Ht=[["ary",At],["bind",gt],["bindKey",yt],["curry",bt],["curryRight",wt],["flip",kt],["partial",Et],["partialRight",xt],["rearg",Tt]],Bt="[object Arguments]",Wt="[object Array]",$t="[object AsyncFunction]",Gt="[object Boolean]",Vt="[object Date]",Ft="[object DOMException]",Kt="[object Error]",Xt="[object Function]",Zt="[object GeneratorFunction]",Jt="[object Map]",Yt="[object Number]",Qt="[object Null]",tn="[object Object]",nn="[object Promise]",en="[object Proxy]",rn="[object RegExp]",un="[object Set]",on="[object String]",an="[object Symbol]",sn="[object Undefined]",cn="[object WeakMap]",fn="[object WeakSet]",ln="[object ArrayBuffer]",hn="[object DataView]",pn="[object Float32Array]",vn="[object Float64Array]",_n="[object Int8Array]",dn="[object Int16Array]",gn="[object Int32Array]",yn="[object Uint8Array]",mn="[object Uint8ClampedArray]",bn="[object Uint16Array]",wn="[object Uint32Array]",En=/\b__p \+= '';/g,xn=/\b(__p \+=) '' \+/g,An=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Tn=/&(?:amp|lt|gt|quot|#39);/g,kn=/[&<>"']/g,In=RegExp(Tn.source),Rn=RegExp(kn.source),Cn=/<%-([\s\S]+?)%>/g,Ln=/<%([\s\S]+?)%>/g,On=/<%=([\s\S]+?)%>/g,jn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Sn=/^\w*$/,Dn=/^\./,Nn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pn=/[\\^$.*+?()[\]{}|]/g,Un=RegExp(Pn.source),Mn=/^\s+|\s+$/g,zn=/^\s+/,qn=/\s+$/,Hn=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Bn=/\{\n\/\* \[wrapped with (.+)\] \*/,Wn=/,? & /,$n=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Gn=/\\(\\)?/g,Vn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Fn=/\w*$/,Kn=/^[-+]0x[0-9a-f]+$/i,Xn=/^0b[01]+$/i,Zn=/^\[object .+?Constructor\]$/,Jn=/^0o[0-7]+$/i,Yn=/^(?:0|[1-9]\d*)$/,Qn=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,te=/($^)/,ne=/['\n\r\u2028\u2029\\]/g,ee="\\ud800-\\udfff",re="\\u0300-\\u036f",ie="\\ufe20-\\ufe2f",ue="\\u20d0-\\u20ff",oe=re+ie+ue,ae="\\u2700-\\u27bf",se="a-z\\xdf-\\xf6\\xf8-\\xff",ce="\\xac\\xb1\\xd7\\xf7",fe="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",le="\\u2000-\\u206f",he=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",pe="A-Z\\xc0-\\xd6\\xd8-\\xde",ve="\\ufe0e\\ufe0f",_e=ce+fe+le+he,de="['’]",ge="["+ee+"]",ye="["+_e+"]",me="["+oe+"]",be="\\d+",we="["+ae+"]",Ee="["+se+"]",xe="[^"+ee+_e+be+ae+se+pe+"]",Ae="\\ud83c[\\udffb-\\udfff]",Te="(?:"+me+"|"+Ae+")",ke="[^"+ee+"]",Ie="(?:\\ud83c[\\udde6-\\uddff]){2}",Re="[\\ud800-\\udbff][\\udc00-\\udfff]",Ce="["+pe+"]",Le="\\u200d",Oe="(?:"+Ee+"|"+xe+")",je="(?:"+Ce+"|"+xe+")",Se="(?:"+de+"(?:d|ll|m|re|s|t|ve))?",De="(?:"+de+"(?:D|LL|M|RE|S|T|VE))?",Ne=Te+"?",Pe="["+ve+"]?",Ue="(?:"+Le+"(?:"+[ke,Ie,Re].join("|")+")"+Pe+Ne+")*",Me="\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)",ze="\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)",qe=Pe+Ne+Ue,He="(?:"+[we,Ie,Re].join("|")+")"+qe,Be="(?:"+[ke+me+"?",me,Ie,Re,ge].join("|")+")",We=RegExp(de,"g"),$e=RegExp(me,"g"),Ge=RegExp(Ae+"(?="+Ae+")|"+Be+qe,"g"),Ve=RegExp([Ce+"?"+Ee+"+"+Se+"(?="+[ye,Ce,"$"].join("|")+")",je+"+"+De+"(?="+[ye,Ce+Oe,"$"].join("|")+")",Ce+"?"+Oe+"+"+Se,Ce+"+"+De,ze,Me,be,He].join("|"),"g"),Fe=RegExp("["+Le+ee+oe+ve+"]"),Ke=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Xe=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Ze=-1,Je={};Je[pn]=Je[vn]=Je[_n]=Je[dn]=Je[gn]=Je[yn]=Je[mn]=Je[bn]=Je[wn]=!0,Je[Bt]=Je[Wt]=Je[ln]=Je[Gt]=Je[hn]=Je[Vt]=Je[Kt]=Je[Xt]=Je[Jt]=Je[Yt]=Je[tn]=Je[rn]=Je[un]=Je[on]=Je[cn]=!1; +var Ye={};Ye[Bt]=Ye[Wt]=Ye[ln]=Ye[hn]=Ye[Gt]=Ye[Vt]=Ye[pn]=Ye[vn]=Ye[_n]=Ye[dn]=Ye[gn]=Ye[Jt]=Ye[Yt]=Ye[tn]=Ye[rn]=Ye[un]=Ye[on]=Ye[an]=Ye[yn]=Ye[mn]=Ye[bn]=Ye[wn]=!0,Ye[Kt]=Ye[Xt]=Ye[cn]=!1;var Qe={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"},tr={"&":"&","<":"<",">":">",'"':""","'":"'"},nr={"&":"&","<":"<",">":">",""":'"',"'":"'"},er={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},rr=parseFloat,ir=parseInt,ur="object"==typeof t&&t&&t.Object===Object&&t,or="object"==typeof self&&self&&self.Object===Object&&self,ar=ur||or||Function("return this")(),sr="object"==typeof n&&n&&!n.nodeType&&n,cr=sr&&"object"==typeof i&&i&&!i.nodeType&&i,fr=cr&&cr.exports===sr,lr=fr&&ur.process,hr=function(){try{return lr&&lr.binding&&lr.binding("util")}catch(t){}}(),pr=hr&&hr.isArrayBuffer,vr=hr&&hr.isDate,_r=hr&&hr.isMap,dr=hr&&hr.isRegExp,gr=hr&&hr.isSet,yr=hr&&hr.isTypedArray,mr=R("length"),br=C(Qe),wr=C(tr),Er=C(nr),xr=function t(n){function e(t){if(ss(t)&&!bh(t)&&!(t instanceof b)){if(t instanceof i)return t;if(bf.call(t,"__wrapped__"))return io(t)}return new i(t)}function r(){}function i(t,n){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=it}function b(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Mt,this.__views__=[]}function C(){var t=new b(this.__wrapped__);return t.__actions__=Hi(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Hi(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Hi(this.__views__),t}function J(){if(this.__filtered__){var t=new b(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function nt(){var t=this.__wrapped__.value(),n=this.__dir__,e=bh(t),r=n<0,i=e?t.length:0,u=Iu(0,i,this.__views__),o=u.start,a=u.end,s=a-o,c=r?a:o-1,f=this.__iteratees__,l=f.length,h=0,p=Zf(s,this.__takeCount__);if(!e||i-1}function le(t,n){var e=this.__data__,r=De(e,t);return r<0?(++this.size,e.push([t,n])):e[r][1]=n,this}function he(t){var n=-1,e=null==t?0:t.length;for(this.clear();++n=n?t:n)),t}function He(t,n,e,r,i,u){var o,a=n&ht,s=n&pt,f=n&vt;if(e&&(o=i?e(t,r,i,u):e(t)),o!==it)return o;if(!as(t))return t;var l=bh(t);if(l){if(o=Lu(t),!a)return Hi(t,o)}else{var h=Ll(t),p=h==Xt||h==Zt;if(Eh(t))return Ci(t,a);if(h==tn||h==Bt||p&&!i){if(o=s||p?{}:Ou(t),!a)return s?$i(t,Ue(o,t)):Wi(t,Pe(o,t))}else{if(!Ye[h])return i?t:{};o=ju(t,h,He,a)}}u||(u=new we);var v=u.get(t);if(v)return v;u.set(t,o);var _=f?s?mu:yu:s?$s:Ws,d=l?it:_(t);return c(d||t,function(r,i){d&&(i=r,r=t[i]),Se(o,i,He(r,n,e,i,t,u))}),o}function Be(t){var n=Ws(t);return function(e){return Ge(e,t,n)}}function Ge(t,n,e){var r=e.length;if(null==t)return!r;for(t=lf(t);r--;){var i=e[r],u=n[i],o=t[i];if(o===it&&!(i in t)||!u(o))return!1}return!0}function Ve(t,n,e){if("function"!=typeof t)throw new vf(st);return Sl(function(){t.apply(it,e)},n)}function Fe(t,n,e,r){var i=-1,u=p,o=!0,a=t.length,s=[],c=n.length;if(!a)return s;e&&(n=_(n,N(e))),r?(u=v,o=!1):n.length>=ot&&(u=U,o=!1,n=new ye(n));t:for(;++ii?0:i+e),r=r===it||r>i?i:Ts(r),r<0&&(r+=i),r=e>r?0:ks(r);e0&&e(a)?n>1?er(a,n-1,e,r,i):d(i,a):r||(i[i.length]=a)}return i}function ur(t,n){return t&&bl(t,n,Ws)}function or(t,n){return t&&wl(t,n,Ws)}function sr(t,n){return h(n,function(n){return is(t[n])})}function cr(t,n){n=Ii(n,t);for(var e=0,r=n.length;null!=t&&en}function xr(t,n){return null!=t&&bf.call(t,n)}function Tr(t,n){return null!=t&&n in lf(t)}function kr(t,n,e){return t>=Zf(n,e)&&t=120&&f.length>=120)?new ye(o&&f):it}f=t[0];var l=-1,h=a[0];t:for(;++l-1;)a!==t&&Df.call(a,s,1),Df.call(t,s,1);return t}function ei(t,n){for(var e=t?n.length:0,r=e-1;e--;){var i=n[e];if(e==r||i!==u){var u=i;Nu(i)?Df.call(t,i,1):mi(t,i)}}return t}function ri(t,n){return t+Wf(Qf()*(n-t+1))}function ii(t,n,e,r){for(var i=-1,u=Xf(Bf((n-t)/(e||1)),0),o=of(u);u--;)o[r?u:++i]=t,t+=e;return o}function ui(t,n){var e="";if(!t||n<1||n>Nt)return e;do n%2&&(e+=t),n=Wf(n/2),n&&(t+=t);while(n);return e}function oi(t,n){return Dl(Xu(t,n,Sc),t+"")}function ai(t){return Re(ec(t))}function si(t,n){var e=ec(t);return to(e,qe(n,0,e.length))}function ci(t,n,e,r){if(!as(t))return t;n=Ii(n,t);for(var i=-1,u=n.length,o=u-1,a=t;null!=a&&++ii?0:i+n),e=e>i?i:e,e<0&&(e+=i),i=n>e?0:e-n>>>0,n>>>=0;for(var u=of(i);++r>>1,o=t[u];null!==o&&!ms(o)&&(e?o<=n:o=ot){var c=n?null:kl(t);if(c)return X(c);o=!1,i=U,s=new ye}else s=n?[]:a;t:for(;++r=r?t:li(t,n,e)}function Ci(t,n){if(n)return t.slice();var e=t.length,r=Lf?Lf(e):new t.constructor(e);return t.copy(r),r}function Li(t){var n=new t.constructor(t.byteLength);return new Cf(n).set(new Cf(t)),n}function Oi(t,n){var e=n?Li(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.byteLength)}function ji(t,n,e){var r=n?e(V(t),ht):V(t);return g(r,u,new t.constructor)}function Si(t){var n=new t.constructor(t.source,Fn.exec(t));return n.lastIndex=t.lastIndex,n}function Di(t,n,e){var r=n?e(X(t),ht):X(t);return g(r,o,new t.constructor)}function Ni(t){return _l?lf(_l.call(t)):{}}function Pi(t,n){var e=n?Li(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)}function Ui(t,n){if(t!==n){var e=t!==it,r=null===t,i=t===t,u=ms(t),o=n!==it,a=null===n,s=n===n,c=ms(n);if(!a&&!c&&!u&&t>n||u&&o&&s&&!a&&!c||r&&o&&s||!e&&s||!i)return 1;if(!r&&!u&&!c&&t=a)return s;var c=e[r];return s*("desc"==c?-1:1)}}return t.index-n.index}function zi(t,n,e,r){for(var i=-1,u=t.length,o=e.length,a=-1,s=n.length,c=Xf(u-o,0),f=of(s+c),l=!r;++a1?e[i-1]:it,o=i>2?e[2]:it;for(u=t.length>3&&"function"==typeof u?(i--,u):it,o&&Pu(e[0],e[1],o)&&(u=i<3?it:u,i=1),n=lf(n);++r-1?i[u?n[o]:o]:it}}function nu(t){return gu(function(n){var e=n.length,r=e,u=i.prototype.thru;for(t&&n.reverse();r--;){var o=n[r];if("function"!=typeof o)throw new vf(st);if(u&&!a&&"wrapper"==bu(o))var a=new i([],!0)}for(r=a?r:e;++r=ot)return a.plant(r).value();for(var i=0,u=e?n[i].apply(this,t):r;++i1&&y.reverse(),l&&sa))return!1;var c=u.get(t);if(c&&u.get(n))return c==n;var f=-1,l=!0,h=e&dt?new ye:it;for(u.set(t,n),u.set(n,t);++f1?"& ":"")+n[r],n=n.join(e>2?", ":" "),t.replace(Hn,"{\n/* [wrapped with "+n+"] */\n")}function Du(t){return bh(t)||mh(t)||!!(Nf&&t&&t[Nf])}function Nu(t,n){return n=null==n?Nt:n,!!n&&("number"==typeof t||Yn.test(t))&&t>-1&&t%1==0&&t0){if(++n>=Ct)return arguments[0]}else n=0;return t.apply(it,arguments)}}function to(t,n){var e=-1,r=t.length,i=r-1;for(n=n===it?r:n;++e=this.__values__.length,n=t?it:this.__values__[this.__index__++];return{done:t,value:n}}function ua(){return this}function oa(t){for(var n,e=this;e instanceof r;){var i=io(e);i.__index__=0,i.__values__=it,n?u.__wrapped__=i:n=i;var u=i;e=e.__wrapped__}return u.__wrapped__=t,n}function aa(){var t=this.__wrapped__;if(t instanceof b){var n=t;return this.__actions__.length&&(n=new b(this)),n=n.reverse(),n.__actions__.push({func:na,args:[Oo],thisArg:it}),new i(n,this.__chain__)}return this.thru(Oo)}function sa(){return Ei(this.__wrapped__,this.__actions__)}function ca(t,n,e){var r=bh(t)?l:Ke;return e&&Pu(t,n,e)&&(n=it),r(t,Eu(n,3))}function fa(t,n){var e=bh(t)?h:nr;return e(t,Eu(n,3))}function la(t,n){return er(ga(t,n),1)}function ha(t,n){return er(ga(t,n),Dt)}function pa(t,n,e){return e=e===it?1:Ts(e),er(ga(t,n),e)}function va(t,n){var e=bh(t)?c:yl;return e(t,Eu(n,3))}function _a(t,n){var e=bh(t)?f:ml;return e(t,Eu(n,3))}function da(t,n,e,r){t=Xa(t)?t:ec(t),e=e&&!r?Ts(e):0;var i=t.length;return e<0&&(e=Xf(i+e,0)),ys(t)?e<=i&&t.indexOf(n,e)>-1:!!i&&A(t,n,e)>-1}function ga(t,n){var e=bh(t)?_:Gr;return e(t,Eu(n,3))}function ya(t,n,e,r){return null==t?[]:(bh(n)||(n=null==n?[]:[n]),e=r?it:e,bh(e)||(e=null==e?[]:[e]),Jr(t,n,e))}function ma(t,n,e){var r=bh(t)?g:L,i=arguments.length<3;return r(t,Eu(n,4),e,i,yl)}function ba(t,n,e){var r=bh(t)?y:L,i=arguments.length<3;return r(t,Eu(n,4),e,i,ml)}function wa(t,n){var e=bh(t)?h:nr;return e(t,Na(Eu(n,3)))}function Ea(t){var n=bh(t)?Re:ai;return n(t)}function xa(t,n,e){n=(e?Pu(t,n,e):n===it)?1:Ts(n);var r=bh(t)?Ce:si;return r(t,n)}function Aa(t){var n=bh(t)?Le:fi;return n(t)}function Ta(t){if(null==t)return 0;if(Xa(t))return ys(t)?Q(t):t.length;var n=Ll(t);return n==Jt||n==un?t.size:Br(t).length}function ka(t,n,e){var r=bh(t)?m:hi;return e&&Pu(t,n,e)&&(n=it),r(t,Eu(n,3))}function Ia(t,n){if("function"!=typeof n)throw new vf(st);return t=Ts(t),function(){if(--t<1)return n.apply(this,arguments)}}function Ra(t,n,e){return n=e?it:n,n=t&&null==n?t.length:n,pu(t,At,it,it,it,it,n)}function Ca(t,n){var e;if("function"!=typeof n)throw new vf(st);return t=Ts(t),function(){return--t>0&&(e=n.apply(this,arguments)),t<=1&&(n=it),e}}function La(t,n,e){n=e?it:n;var r=pu(t,bt,it,it,it,it,it,n);return r.placeholder=La.placeholder,r}function Oa(t,n,e){n=e?it:n;var r=pu(t,wt,it,it,it,it,it,n);return r.placeholder=Oa.placeholder,r}function ja(t,n,e){function r(n){var e=h,r=p;return h=p=it,y=n,_=t.apply(r,e)}function i(t){return y=t,d=Sl(a,n),m?r(t):_}function u(t){var e=t-g,r=t-y,i=n-e;return b?Zf(i,v-r):i}function o(t){var e=t-g,r=t-y;return g===it||e>=n||e<0||b&&r>=v}function a(){var t=sh();return o(t)?s(t):void(d=Sl(a,u(t)))}function s(t){return d=it,w&&h?r(t):(h=p=it,_)}function c(){d!==it&&Tl(d),y=0,h=g=p=d=it}function f(){return d===it?_:s(sh())}function l(){var t=sh(),e=o(t);if(h=arguments,p=this,g=t,e){if(d===it)return i(g);if(b)return d=Sl(a,n),r(g)}return d===it&&(d=Sl(a,n)),_}var h,p,v,_,d,g,y=0,m=!1,b=!1,w=!0;if("function"!=typeof t)throw new vf(st);return n=Is(n)||0,as(e)&&(m=!!e.leading,b="maxWait"in e,v=b?Xf(Is(e.maxWait)||0,n):v,w="trailing"in e?!!e.trailing:w),l.cancel=c,l.flush=f,l}function Sa(t){return pu(t,kt)}function Da(t,n){if("function"!=typeof t||null!=n&&"function"!=typeof n)throw new vf(st);var e=function(){var r=arguments,i=n?n.apply(this,r):r[0],u=e.cache;if(u.has(i))return u.get(i);var o=t.apply(this,r);return e.cache=u.set(i,o)||u,o};return e.cache=new(Da.Cache||he),e}function Na(t){if("function"!=typeof t)throw new vf(st);return function(){var n=arguments;switch(n.length){case 0:return!t.call(this);case 1:return!t.call(this,n[0]);case 2:return!t.call(this,n[0],n[1]);case 3:return!t.call(this,n[0],n[1],n[2])}return!t.apply(this,n)}}function Pa(t){return Ca(2,t)}function Ua(t,n){if("function"!=typeof t)throw new vf(st);return n=n===it?n:Ts(n),oi(t,n)}function Ma(t,n){if("function"!=typeof t)throw new vf(st);return n=n===it?0:Xf(Ts(n),0),oi(function(e){var r=e[n],i=Ri(e,0,n);return r&&d(i,r),a(t,this,i)})}function za(t,n,e){var r=!0,i=!0;if("function"!=typeof t)throw new vf(st);return as(e)&&(r="leading"in e?!!e.leading:r,i="trailing"in e?!!e.trailing:i),ja(t,n,{leading:r,maxWait:n,trailing:i})}function qa(t){return Ra(t,1)}function Ha(t,n){return vh(ki(n),t)}function Ba(){if(!arguments.length)return[];var t=arguments[0];return bh(t)?t:[t]}function Wa(t){return He(t,vt)}function $a(t,n){return n="function"==typeof n?n:it,He(t,vt,n)}function Ga(t){return He(t,ht|vt)}function Va(t,n){return n="function"==typeof n?n:it,He(t,ht|vt,n)}function Fa(t,n){return null==n||Ge(t,n,Ws(n))}function Ka(t,n){return t===n||t!==t&&n!==n}function Xa(t){return null!=t&&os(t.length)&&!is(t)}function Za(t){return ss(t)&&Xa(t)}function Ja(t){return t===!0||t===!1||ss(t)&&hr(t)==Gt}function Ya(t){return ss(t)&&1===t.nodeType&&!ds(t)}function Qa(t){if(null==t)return!0;if(Xa(t)&&(bh(t)||"string"==typeof t||"function"==typeof t.splice||Eh(t)||Ih(t)||mh(t)))return!t.length;var n=Ll(t);if(n==Jt||n==un)return!t.size;if(Hu(t))return!Br(t).length;for(var e in t)if(bf.call(t,e))return!1;return!0}function ts(t,n){return Sr(t,n)}function ns(t,n,e){e="function"==typeof e?e:it;var r=e?e(t,n):it;return r===it?Sr(t,n,it,e):!!r}function es(t){if(!ss(t))return!1;var n=hr(t);return n==Kt||n==Ft||"string"==typeof t.message&&"string"==typeof t.name&&!ds(t)}function rs(t){return"number"==typeof t&&Vf(t)}function is(t){if(!as(t))return!1;var n=hr(t);return n==Xt||n==Zt||n==$t||n==en}function us(t){return"number"==typeof t&&t==Ts(t)}function os(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Nt}function as(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function ss(t){return null!=t&&"object"==typeof t}function cs(t,n){return t===n||Pr(t,n,Au(n))}function fs(t,n,e){return e="function"==typeof e?e:it,Pr(t,n,Au(n),e)}function ls(t){return _s(t)&&t!=+t}function hs(t){if(Ol(t))throw new sf(at);return Ur(t)}function ps(t){return null===t}function vs(t){return null==t}function _s(t){return"number"==typeof t||ss(t)&&hr(t)==Yt}function ds(t){if(!ss(t)||hr(t)!=tn)return!1;var n=Of(t);if(null===n)return!0;var e=bf.call(n,"constructor")&&n.constructor;return"function"==typeof e&&e instanceof e&&mf.call(e)==Af}function gs(t){return us(t)&&t>=-Nt&&t<=Nt}function ys(t){return"string"==typeof t||!bh(t)&&ss(t)&&hr(t)==on}function ms(t){return"symbol"==typeof t||ss(t)&&hr(t)==an}function bs(t){return t===it}function ws(t){return ss(t)&&Ll(t)==cn}function Es(t){return ss(t)&&hr(t)==fn}function xs(t){if(!t)return[];if(Xa(t))return ys(t)?tt(t):Hi(t);if(Pf&&t[Pf])return G(t[Pf]());var n=Ll(t),e=n==Jt?V:n==un?X:ec;return e(t)}function As(t){if(!t)return 0===t?t:0;if(t=Is(t),t===Dt||t===-Dt){var n=t<0?-1:1;return n*Pt}return t===t?t:0}function Ts(t){var n=As(t),e=n%1;return n===n?e?n-e:n:0}function ks(t){return t?qe(Ts(t),0,Mt):0}function Is(t){if("number"==typeof t)return t;if(ms(t))return Ut;if(as(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=as(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Mn,"");var e=Xn.test(t);return e||Jn.test(t)?ir(t.slice(2),e?2:8):Kn.test(t)?Ut:+t}function Rs(t){return Bi(t,$s(t))}function Cs(t){return qe(Ts(t),-Nt,Nt)}function Ls(t){return null==t?"":gi(t)}function Os(t,n){var e=gl(t);return null==n?e:Pe(e,n)}function js(t,n){return E(t,Eu(n,3),ur)}function Ss(t,n){return E(t,Eu(n,3),or)}function Ds(t,n){return null==t?t:bl(t,Eu(n,3),$s)}function Ns(t,n){return null==t?t:wl(t,Eu(n,3),$s)}function Ps(t,n){return t&&ur(t,Eu(n,3))}function Us(t,n){return t&&or(t,Eu(n,3))}function Ms(t){return null==t?[]:sr(t,Ws(t))}function zs(t){return null==t?[]:sr(t,$s(t))}function qs(t,n,e){var r=null==t?it:cr(t,n);return r===it?e:r}function Hs(t,n){return null!=t&&Cu(t,n,xr)}function Bs(t,n){return null!=t&&Cu(t,n,Tr)}function Ws(t){return Xa(t)?Ie(t):Br(t)}function $s(t){return Xa(t)?Ie(t,!0):Wr(t)}function Gs(t,n){var e={};return n=Eu(n,3),ur(t,function(t,r,i){Me(e,n(t,r,i),t)}),e}function Vs(t,n){var e={};return n=Eu(n,3),ur(t,function(t,r,i){Me(e,r,n(t,r,i))}),e}function Fs(t,n){return Ks(t,Na(Eu(n)))}function Ks(t,n){if(null==t)return{};var e=_(mu(t),function(t){return[t]});return n=Eu(n),Qr(t,e,function(t,e){return n(t,e[0])})}function Xs(t,n,e){n=Ii(n,t);var r=-1,i=n.length;for(i||(i=1,t=it);++rn){var r=t;t=n,n=r}if(e||t%1||n%1){var i=Qf();return Zf(t+i*(n-t+rr("1e-"+((i+"").length-1))),n)}return ri(t,n)}function ac(t){return Qh(Ls(t).toLowerCase())}function sc(t){return t=Ls(t),t&&t.replace(Qn,br).replace($e,"")}function cc(t,n,e){t=Ls(t),n=gi(n);var r=t.length;e=e===it?r:qe(Ts(e),0,r);var i=e;return e-=n.length,e>=0&&t.slice(e,i)==n}function fc(t){return t=Ls(t),t&&Rn.test(t)?t.replace(kn,wr):t}function lc(t){return t=Ls(t),t&&Un.test(t)?t.replace(Pn,"\\$&"):t}function hc(t,n,e){t=Ls(t),n=Ts(n);var r=n?Q(t):0;if(!n||r>=n)return t;var i=(n-r)/2;return ou(Wf(i),e)+t+ou(Bf(i),e)}function pc(t,n,e){t=Ls(t),n=Ts(n);var r=n?Q(t):0;return n&&r>>0)?(t=Ls(t),t&&("string"==typeof n||null!=n&&!Th(n))&&(n=gi(n),!n&&W(t))?Ri(tt(t),0,e):t.split(n,e)):[]}function mc(t,n,e){return t=Ls(t),e=qe(Ts(e),0,t.length),n=gi(n),t.slice(e,e+n.length)==n}function bc(t,n,r){var i=e.templateSettings;r&&Pu(t,n,r)&&(n=it),t=Ls(t),n=jh({},n,i,Oe);var u,o,a=jh({},n.imports,i.imports,Oe),s=Ws(a),c=P(a,s),f=0,l=n.interpolate||te,h="__p += '",p=hf((n.escape||te).source+"|"+l.source+"|"+(l===On?Vn:te).source+"|"+(n.evaluate||te).source+"|$","g"),v="//# sourceURL="+("sourceURL"in n?n.sourceURL:"lodash.templateSources["+ ++Ze+"]")+"\n";t.replace(p,function(n,e,r,i,a,s){return r||(r=i),h+=t.slice(f,s).replace(ne,H),e&&(u=!0,h+="' +\n__e("+e+") +\n'"),a&&(o=!0,h+="';\n"+a+";\n__p += '"),r&&(h+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),f=s+n.length,n}),h+="';\n";var _=n.variable;_||(h="with (obj) {\n"+h+"\n}\n"),h=(o?h.replace(En,""):h).replace(xn,"$1").replace(An,"$1;"),h="function("+(_||"obj")+") {\n"+(_?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(u?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var d=tp(function(){return cf(s,v+"return "+h).apply(it,c)});if(d.source=h,es(d))throw d;return d}function wc(t){return Ls(t).toLowerCase()}function Ec(t){return Ls(t).toUpperCase()}function xc(t,n,e){if(t=Ls(t),t&&(e||n===it))return t.replace(Mn,"");if(!t||!(n=gi(n)))return t;var r=tt(t),i=tt(n),u=M(r,i),o=z(r,i)+1;return Ri(r,u,o).join("")}function Ac(t,n,e){if(t=Ls(t),t&&(e||n===it))return t.replace(qn,"");if(!t||!(n=gi(n)))return t;var r=tt(t),i=z(r,tt(n))+1;return Ri(r,0,i).join("")}function Tc(t,n,e){if(t=Ls(t),t&&(e||n===it))return t.replace(zn,"");if(!t||!(n=gi(n)))return t;var r=tt(t),i=M(r,tt(n));return Ri(r,i).join("")}function kc(t,n){var e=It,r=Rt;if(as(n)){var i="separator"in n?n.separator:i;e="length"in n?Ts(n.length):e,r="omission"in n?gi(n.omission):r}t=Ls(t);var u=t.length;if(W(t)){var o=tt(t);u=o.length}if(e>=u)return t;var a=e-Q(r);if(a<1)return r;var s=o?Ri(o,0,a).join(""):t.slice(0,a);if(i===it)return s+r;if(o&&(a+=s.length-a),Th(i)){if(t.slice(a).search(i)){var c,f=s;for(i.global||(i=hf(i.source,Ls(Fn.exec(i))+"g")),i.lastIndex=0;c=i.exec(f);)var l=c.index;s=s.slice(0,l===it?a:l)}}else if(t.indexOf(gi(i),a)!=a){var h=s.lastIndexOf(i);h>-1&&(s=s.slice(0,h))}return s+r}function Ic(t){return t=Ls(t),t&&In.test(t)?t.replace(Tn,Er):t}function Rc(t,n,e){return t=Ls(t),n=e?it:n,n===it?$(t)?rt(t):w(t):t.match(n)||[]}function Cc(t){var n=null==t?0:t.length,e=Eu();return t=n?_(t,function(t){if("function"!=typeof t[1])throw new vf(st);return[e(t[0]),t[1]]}):[],oi(function(e){for(var r=-1;++rNt)return[];var e=Mt,r=Zf(t,Mt);n=Eu(n),t-=Mt;for(var i=S(r,n);++e1?t[n-1]:it;return e="function"==typeof e?(t.pop(),e):it,Zo(t,e)}),Ql=gu(function(t){var n=t.length,e=n?t[0]:0,r=this.__wrapped__,u=function(n){return ze(n,t)};return!(n>1||this.__actions__.length)&&r instanceof b&&Nu(e)?(r=r.slice(e,+e+(n?1:0)),r.__actions__.push({func:na,args:[u],thisArg:it}),new i(r,this.__chain__).thru(function(t){return n&&!t.length&&t.push(it),t})):this.thru(u)}),th=Gi(function(t,n,e){bf.call(t,e)?++t[e]:Me(t,e,1)}),nh=tu(po),eh=tu(vo),rh=Gi(function(t,n,e){bf.call(t,e)?t[e].push(n):Me(t,e,[n])}),ih=oi(function(t,n,e){var r=-1,i="function"==typeof n,u=Xa(t)?of(t.length):[];return yl(t,function(t){u[++r]=i?a(n,t,e):Cr(t,n,e)}),u}),uh=Gi(function(t,n,e){Me(t,e,n)}),oh=Gi(function(t,n,e){t[e?0:1].push(n)},function(){return[[],[]]}),ah=oi(function(t,n){if(null==t)return[];var e=n.length;return e>1&&Pu(t,n[0],n[1])?n=[]:e>2&&Pu(n[0],n[1],n[2])&&(n=[n[0]]),Jr(t,er(n,1),[])}),sh=qf||function(){return ar.Date.now()},ch=oi(function(t,n,e){var r=gt;if(e.length){var i=K(e,wu(ch));r|=Et}return pu(t,r,n,e,i)}),fh=oi(function(t,n,e){var r=gt|yt;if(e.length){var i=K(e,wu(fh));r|=Et}return pu(n,r,t,e,i)}),lh=oi(function(t,n){return Ve(t,1,n)}),hh=oi(function(t,n,e){return Ve(t,Is(n)||0,e)});Da.Cache=he;var ph=Al(function(t,n){n=1==n.length&&bh(n[0])?_(n[0],N(Eu())):_(er(n,1),N(Eu()));var e=n.length;return oi(function(r){for(var i=-1,u=Zf(r.length,e);++i=n}),mh=Lr(function(){return arguments}())?Lr:function(t){return ss(t)&&bf.call(t,"callee")&&!Sf.call(t,"callee")},bh=of.isArray,wh=pr?N(pr):Or,Eh=Gf||$c,xh=vr?N(vr):jr,Ah=_r?N(_r):Nr,Th=dr?N(dr):Mr,kh=gr?N(gr):zr,Ih=yr?N(yr):qr,Rh=cu($r),Ch=cu(function(t,n){return t<=n}),Lh=Vi(function(t,n){if(Hu(n)||Xa(n))return void Bi(n,Ws(n),t);for(var e in n)bf.call(n,e)&&Se(t,e,n[e])}),Oh=Vi(function(t,n){Bi(n,$s(n),t)}),jh=Vi(function(t,n,e,r){Bi(n,$s(n),t,r)}),Sh=Vi(function(t,n,e,r){Bi(n,Ws(n),t,r)}),Dh=gu(ze),Nh=oi(function(t){return t.push(it,Oe),a(jh,it,t)}),Ph=oi(function(t){return t.push(it,Vu),a(Hh,it,t)}),Uh=ru(function(t,n,e){t[n]=e},Oc(Sc)),Mh=ru(function(t,n,e){bf.call(t,n)?t[n].push(e):t[n]=[e]},Eu),zh=oi(Cr),qh=Vi(function(t,n,e){Kr(t,n,e)}),Hh=Vi(function(t,n,e,r){Kr(t,n,e,r)}),Bh=gu(function(t,n){var e={};if(null==t)return e;var r=!1;n=_(n,function(n){return n=Ii(n,t),r||(r=n.length>1),n}),Bi(t,mu(t),e),r&&(e=He(e,ht|pt|vt));for(var i=n.length;i--;)mi(e,n[i]);return e}),Wh=gu(function(t,n){return null==t?{}:Yr(t,n)}),$h=hu(Ws),Gh=hu($s),Vh=Ji(function(t,n,e){return n=n.toLowerCase(),t+(e?ac(n):n)}),Fh=Ji(function(t,n,e){return t+(e?"-":"")+n.toLowerCase()}),Kh=Ji(function(t,n,e){return t+(e?" ":"")+n.toLowerCase()}),Xh=Zi("toLowerCase"),Zh=Ji(function(t,n,e){return t+(e?"_":"")+n.toLowerCase()}),Jh=Ji(function(t,n,e){return t+(e?" ":"")+Qh(n)}),Yh=Ji(function(t,n,e){return t+(e?" ":"")+n.toUpperCase()}),Qh=Zi("toUpperCase"),tp=oi(function(t,n){try{return a(t,it,n)}catch(t){return es(t)?t:new sf(t)}}),np=gu(function(t,n){return c(n,function(n){n=no(n),Me(t,n,ch(t[n],t))}),t}),ep=nu(),rp=nu(!0),ip=oi(function(t,n){return function(e){return Cr(e,t,n)}}),up=oi(function(t,n){return function(e){return Cr(t,e,n)}}),op=uu(_),ap=uu(l),sp=uu(m),cp=su(),fp=su(!0),lp=iu(function(t,n){return t+n},0),hp=lu("ceil"),pp=iu(function(t,n){return t/n},1),vp=lu("floor"),_p=iu(function(t,n){return t*n},1),dp=lu("round"),gp=iu(function(t,n){return t-n},0);return e.after=Ia,e.ary=Ra,e.assign=Lh,e.assignIn=Oh,e.assignInWith=jh,e.assignWith=Sh,e.at=Dh,e.before=Ca,e.bind=ch,e.bindAll=np,e.bindKey=fh,e.castArray=Ba,e.chain=Qo,e.chunk=uo,e.compact=oo,e.concat=ao,e.cond=Cc,e.conforms=Lc,e.constant=Oc,e.countBy=th,e.create=Os,e.curry=La,e.curryRight=Oa,e.debounce=ja,e.defaults=Nh,e.defaultsDeep=Ph,e.defer=lh,e.delay=hh,e.difference=Pl,e.differenceBy=Ul,e.differenceWith=Ml,e.drop=so,e.dropRight=co,e.dropRightWhile=fo,e.dropWhile=lo,e.fill=ho,e.filter=fa,e.flatMap=la,e.flatMapDeep=ha,e.flatMapDepth=pa,e.flatten=_o,e.flattenDeep=go,e.flattenDepth=yo,e.flip=Sa,e.flow=ep,e.flowRight=rp,e.fromPairs=mo,e.functions=Ms,e.functionsIn=zs,e.groupBy=rh,e.initial=Eo,e.intersection=zl,e.intersectionBy=ql,e.intersectionWith=Hl,e.invert=Uh,e.invertBy=Mh,e.invokeMap=ih,e.iteratee=Dc,e.keyBy=uh,e.keys=Ws,e.keysIn=$s,e.map=ga,e.mapKeys=Gs,e.mapValues=Vs,e.matches=Nc,e.matchesProperty=Pc,e.memoize=Da,e.merge=qh,e.mergeWith=Hh,e.method=ip,e.methodOf=up,e.mixin=Uc,e.negate=Na,e.nthArg=qc,e.omit=Bh,e.omitBy=Fs,e.once=Pa,e.orderBy=ya,e.over=op,e.overArgs=ph,e.overEvery=ap,e.overSome=sp,e.partial=vh,e.partialRight=_h,e.partition=oh,e.pick=Wh,e.pickBy=Ks,e.property=Hc,e.propertyOf=Bc,e.pull=Bl,e.pullAll=Io,e.pullAllBy=Ro,e.pullAllWith=Co,e.pullAt=Wl,e.range=cp,e.rangeRight=fp,e.rearg=dh,e.reject=wa,e.remove=Lo,e.rest=Ua,e.reverse=Oo,e.sampleSize=xa,e.set=Zs,e.setWith=Js,e.shuffle=Aa,e.slice=jo,e.sortBy=ah,e.sortedUniq=zo,e.sortedUniqBy=qo,e.split=yc,e.spread=Ma,e.tail=Ho,e.take=Bo,e.takeRight=Wo,e.takeRightWhile=$o,e.takeWhile=Go,e.tap=ta,e.throttle=za,e.thru=na,e.toArray=xs,e.toPairs=$h,e.toPairsIn=Gh,e.toPath=Xc,e.toPlainObject=Rs,e.transform=Ys,e.unary=qa,e.union=$l,e.unionBy=Gl,e.unionWith=Vl,e.uniq=Vo,e.uniqBy=Fo,e.uniqWith=Ko,e.unset=Qs,e.unzip=Xo,e.unzipWith=Zo,e.update=tc,e.updateWith=nc,e.values=ec,e.valuesIn=rc,e.without=Fl,e.words=Rc,e.wrap=Ha,e.xor=Kl,e.xorBy=Xl,e.xorWith=Zl,e.zip=Jl,e.zipObject=Jo,e.zipObjectDeep=Yo,e.zipWith=Yl,e.entries=$h,e.entriesIn=Gh,e.extend=Oh,e.extendWith=jh,Uc(e,e),e.add=lp,e.attempt=tp,e.camelCase=Vh,e.capitalize=ac,e.ceil=hp,e.clamp=ic,e.clone=Wa,e.cloneDeep=Ga,e.cloneDeepWith=Va,e.cloneWith=$a,e.conformsTo=Fa,e.deburr=sc,e.defaultTo=jc,e.divide=pp,e.endsWith=cc,e.eq=Ka,e.escape=fc,e.escapeRegExp=lc,e.every=ca,e.find=nh,e.findIndex=po,e.findKey=js,e.findLast=eh,e.findLastIndex=vo,e.findLastKey=Ss,e.floor=vp,e.forEach=va,e.forEachRight=_a,e.forIn=Ds,e.forInRight=Ns,e.forOwn=Ps,e.forOwnRight=Us,e.get=qs,e.gt=gh,e.gte=yh,e.has=Hs,e.hasIn=Bs,e.head=bo,e.identity=Sc,e.includes=da,e.indexOf=wo,e.inRange=uc,e.invoke=zh,e.isArguments=mh,e.isArray=bh,e.isArrayBuffer=wh,e.isArrayLike=Xa,e.isArrayLikeObject=Za,e.isBoolean=Ja,e.isBuffer=Eh,e.isDate=xh,e.isElement=Ya,e.isEmpty=Qa,e.isEqual=ts,e.isEqualWith=ns,e.isError=es,e.isFinite=rs,e.isFunction=is,e.isInteger=us,e.isLength=os,e.isMap=Ah,e.isMatch=cs,e.isMatchWith=fs,e.isNaN=ls,e.isNative=hs,e.isNil=vs,e.isNull=ps,e.isNumber=_s,e.isObject=as,e.isObjectLike=ss,e.isPlainObject=ds,e.isRegExp=Th,e.isSafeInteger=gs,e.isSet=kh,e.isString=ys,e.isSymbol=ms,e.isTypedArray=Ih,e.isUndefined=bs,e.isWeakMap=ws,e.isWeakSet=Es,e.join=xo,e.kebabCase=Fh,e.last=Ao,e.lastIndexOf=To,e.lowerCase=Kh,e.lowerFirst=Xh,e.lt=Rh,e.lte=Ch,e.max=Jc,e.maxBy=Yc,e.mean=Qc,e.meanBy=tf,e.min=nf,e.minBy=ef,e.stubArray=Wc,e.stubFalse=$c,e.stubObject=Gc,e.stubString=Vc,e.stubTrue=Fc,e.multiply=_p,e.nth=ko,e.noConflict=Mc,e.noop=zc,e.now=sh,e.pad=hc,e.padEnd=pc,e.padStart=vc,e.parseInt=_c,e.random=oc,e.reduce=ma,e.reduceRight=ba,e.repeat=dc,e.replace=gc,e.result=Xs,e.round=dp,e.runInContext=t,e.sample=Ea,e.size=Ta,e.snakeCase=Zh,e.some=ka,e.sortedIndex=So,e.sortedIndexBy=Do,e.sortedIndexOf=No,e.sortedLastIndex=Po,e.sortedLastIndexBy=Uo,e.sortedLastIndexOf=Mo,e.startCase=Jh,e.startsWith=mc,e.subtract=gp,e.sum=rf,e.sumBy=uf,e.template=bc,e.times=Kc,e.toFinite=As,e.toInteger=Ts,e.toLength=ks,e.toLower=wc,e.toNumber=Is,e.toSafeInteger=Cs,e.toString=Ls,e.toUpper=Ec,e.trim=xc,e.trimEnd=Ac,e.trimStart=Tc,e.truncate=kc,e.unescape=Ic,e.uniqueId=Zc,e.upperCase=Yh,e.upperFirst=Qh,e.each=va,e.eachRight=_a,e.first=bo,Uc(e,function(){var t={};return ur(e,function(n,r){bf.call(e.prototype,r)||(t[r]=n)}),t}(),{chain:!1}),e.VERSION=ut,c(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){e[t].placeholder=e}),c(["drop","take"],function(t,n){b.prototype[t]=function(e){var r=this.__filtered__;if(r&&!n)return new b(this);e=e===it?1:Xf(Ts(e),0);var i=this.clone();return r?i.__takeCount__=Zf(e,i.__takeCount__):i.__views__.push({size:Zf(e,Mt),type:t+(i.__dir__<0?"Right":"")}),i},b.prototype[t+"Right"]=function(n){return this.reverse()[t](n).reverse()}}),c(["filter","map","takeWhile"],function(t,n){var e=n+1,r=e==Ot||e==St;b.prototype[t]=function(t){var n=this.clone();return n.__iteratees__.push({iteratee:Eu(t,3),type:e}),n.__filtered__=n.__filtered__||r,n}}),c(["head","last"],function(t,n){var e="take"+(n?"Right":"");b.prototype[t]=function(){return this[e](1).value()[0]}}),c(["initial","tail"],function(t,n){var e="drop"+(n?"":"Right");b.prototype[t]=function(){return this.__filtered__?new b(this):this[e](1)}}),b.prototype.compact=function(){return this.filter(Sc)},b.prototype.find=function(t){return this.filter(t).head()},b.prototype.findLast=function(t){return this.reverse().find(t)},b.prototype.invokeMap=oi(function(t,n){return"function"==typeof t?new b(this):this.map(function(e){return Cr(e,t,n)})}),b.prototype.reject=function(t){return this.filter(Na(Eu(t)))},b.prototype.slice=function(t,n){t=Ts(t);var e=this;return e.__filtered__&&(t>0||n<0)?new b(e):(t<0?e=e.takeRight(-t):t&&(e=e.drop(t)),n!==it&&(n=Ts(n),e=n<0?e.dropRight(-n):e.take(n-t)),e)},b.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},b.prototype.toArray=function(){return this.take(Mt)},ur(b.prototype,function(t,n){var r=/^(?:filter|find|map|reject)|While$/.test(n),u=/^(?:head|last)$/.test(n),o=e[u?"take"+("last"==n?"Right":""):n],a=u||/^find/.test(n);o&&(e.prototype[n]=function(){var n=this.__wrapped__,s=u?[1]:arguments,c=n instanceof b,f=s[0],l=c||bh(n),h=function(t){var n=o.apply(e,d([t],s));return u&&p?n[0]:n};l&&r&&"function"==typeof f&&1!=f.length&&(c=l=!1);var p=this.__chain__,v=!!this.__actions__.length,_=a&&!p,g=c&&!v;if(!a&&l){n=g?n:new b(this);var y=t.apply(n,s);return y.__actions__.push({func:na,args:[h],thisArg:it}),new i(y,p)}return _&&g?t.apply(this,s):(y=this.thru(h),_?u?y.value()[0]:y.value():y)})}),c(["pop","push","shift","sort","splice","unshift"],function(t){var n=_f[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",i=/^(?:pop|shift)$/.test(t);e.prototype[t]=function(){var t=arguments;if(i&&!this.__chain__){var e=this.value();return n.apply(bh(e)?e:[],t)}return this[r](function(e){return n.apply(bh(e)?e:[],t)})}}),ur(b.prototype,function(t,n){var r=e[n];if(r){var i=r.name+"",u=sl[i]||(sl[i]=[]);u.push({name:n,func:r})}}),sl[eu(it,yt).name]=[{name:"wrapper",func:it}],b.prototype.clone=C,b.prototype.reverse=J,b.prototype.value=nt,e.prototype.at=Ql,e.prototype.chain=ea,e.prototype.commit=ra,e.prototype.next=ia,e.prototype.plant=oa,e.prototype.reverse=aa,e.prototype.toJSON=e.prototype.valueOf=e.prototype.value=sa,e.prototype.first=e.prototype.head,Pf&&(e.prototype[Pf]=ua),e},Ar=xr();ar._=Ar,r=function(){return Ar}.call(n,e,n,i),!(r!==it&&(i.exports=r))}).call(this)}).call(n,function(){return this}(),e(12)(t))},function(t,n){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,n,e){function r(t,n,e){var r=n&&e||0,i=0;for(n=n||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){i<16&&(n[r+i++]=c[t])});i<16;)n[r+i++]=0;return n}function i(t,n){var e=n||0,r=s;return r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]}function u(t,n,e){var r=n&&e||0,u=n||[];t=t||{};var o=void 0!==t.clockseq?t.clockseq:p,a=void 0!==t.msecs?t.msecs:(new Date).getTime(),s=void 0!==t.nsecs?t.nsecs:_+1,c=a-v+(s-_)/1e4; +if(c<0&&void 0===t.clockseq&&(o=o+1&16383),(c<0||a>v)&&void 0===t.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");v=a,_=s,p=o,a+=122192928e5;var f=(1e4*(268435455&a)+s)%4294967296;u[r++]=f>>>24&255,u[r++]=f>>>16&255,u[r++]=f>>>8&255,u[r++]=255&f;var l=a/4294967296*1e4&268435455;u[r++]=l>>>8&255,u[r++]=255&l,u[r++]=l>>>24&15|16,u[r++]=l>>>16&255,u[r++]=o>>>8|128,u[r++]=255&o;for(var d=t.node||h,g=0;g<6;g++)u[r+g]=d[g];return n?n:i(u)}function o(t,n,e){var r=n&&e||0;"string"==typeof t&&(n="binary"==t?new Array(16):null,t=null),t=t||{};var u=t.random||(t.rng||a)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,n)for(var o=0;o<16;o++)n[r+o]=u[o];return n||i(u)}for(var a=e(14),s=[],c={},f=0;f<256;f++)s[f]=(f+256).toString(16).substr(1),c[s[f]]=f;var l=a(),h=[1|l[0],l[1],l[2],l[3],l[4],l[5]],p=16383&(l[6]<<8|l[7]),v=0,_=0,d=o;d.v1=u,d.v4=o,d.parse=r,d.unparse=i,t.exports=d},function(t,n){(function(n){var e,r=n.crypto||n.msCrypto;if(r&&r.getRandomValues){var i=new Uint8Array(16);e=function(){return r.getRandomValues(i),i}}if(!e){var u=new Array(16);e=function(){for(var t,n=0;n<16;n++)0===(3&n)&&(t=4294967296*Math.random()),u[n]=t>>>((3&n)<<3)&255;return u}}t.exports=e}).call(n,function(){return this}())},function(t,n,e){"use strict";function r(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var i=function(){function t(t,n){for(var e=0;e2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new Promise(function(o,a){i.Authorization="Bearer "+e.client.accessToken,u[t.toLowerCase()]("https://"+e.client.hostAndPort+n).set(i).send(r).then(function(t){return o(t.body)},a)})}},{key:"sendMessage",value:function(t,n){return this.makeRequest("post",a.channelMessages(t),{content:n})}},{key:"editMessage",value:function(t,n,e){return this.makeRequest("patch",a.channelMessage(t,n),{content:e})}},{key:"deleteMessage",value:function(t,n){return this.makeRequest("delete",a.channelMessage(t,n))}}]),t}()}]); \ No newline at end of file