UNPKG

993 kBJavaScriptView Raw
1// Aliyun OSS SDK for JavaScript v6.6.0
2// Copyright Aliyun.com, Inc. or its affiliates. All Rights Reserved.
3// License at https://github.com/ali-sdk/ali-oss/blob/master/LICENSE
4(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.OSS = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
5'use strict';
6
7var OSS = require('./browser/client');
8OSS.Buffer = require('buffer').Buffer;
9OSS.urllib = require('../shims/xhr');
10OSS.version = require('./browser/version').version;
11
12module.exports = OSS;
13
14},{"../shims/xhr":325,"./browser/client":2,"./browser/version":5,"buffer":60}],2:[function(require,module,exports){
15(function (process,Buffer){
16'use strict';
17
18var _promise = require('babel-runtime/core-js/promise');
19
20var _promise2 = _interopRequireDefault(_promise);
21
22var _regenerator = require('babel-runtime/regenerator');
23
24var _regenerator2 = _interopRequireDefault(_regenerator);
25
26var _assign = require('babel-runtime/core-js/object/assign');
27
28var _assign2 = _interopRequireDefault(_assign);
29
30function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
32var debug = require('debug')('ali-oss');
33var crypto = require('./../../shims/crypto/crypto.js');
34var path = require('path');
35var copy = require('copy-to');
36var mime = require('mime');
37var xml = require('xml2js');
38var AgentKeepalive = require('agentkeepalive');
39var merge = require('merge-descriptors');
40var urlutil = require('url');
41var is = require('is-type-of');
42var platform = require('platform');
43var utility = require('utility');
44var urllib = require('urllib');
45var pkg = require('./version');
46var dateFormat = require('dateformat');
47var bowser = require('bowser');
48var signUtils = require('../common/signUtils');
49var _isIP = require('../common/utils/isIP');
50var _initOptions = require('../common/client/initOptions');
51
52var globalHttpAgent = new AgentKeepalive();
53
54function getHeader(headers, name) {
55 return headers[name] || headers[name.toLowerCase()];
56}
57
58function _unSupportBrowserTip() {
59 var name = platform.name,
60 version = platform.version;
61
62 if (name && name.toLowerCase && name.toLowerCase() === 'ie' && version.split('.')[0] < 10) {
63 // eslint-disable-next-line no-console
64 console.warn('ali-oss does not support the current browser');
65 }
66}
67// check local web protocol,if https secure default set true , if http secure default set false
68function isHttpsWebProtocol() {
69 // for web worker not use window.location.
70 // eslint-disable-next-line no-restricted-globals
71 return location && location.protocol === 'https:';
72}
73
74function Client(options, ctx) {
75 _unSupportBrowserTip();
76 if (!(this instanceof Client)) {
77 return new Client(options, ctx);
78 }
79 if (options && options.inited) {
80 this.options = options;
81 } else {
82 this.options = Client.initOptions(options);
83 }
84
85 this.options.cancelFlag = false; // cancel flag: if true need to be cancelled, default false
86
87 // support custom agent and urllib client
88 if (this.options.urllib) {
89 this.urllib = this.options.urllib;
90 } else {
91 this.urllib = urllib;
92 this.agent = this.options.agent || globalHttpAgent;
93 }
94 this.ctx = ctx;
95 this.userAgent = this._getUserAgent();
96
97 // record the time difference between client and server
98 this.options.amendTimeSkewed = 0;
99}
100
101/**
102 * Expose `Client`
103 */
104
105module.exports = Client;
106
107Client.initOptions = function initOptions(options) {
108 if (!options.stsToken) {
109 console.warn('Please use STS Token for safety, see more details at https://help.aliyun.com/document_detail/32077.html');
110 }
111 var opts = (0, _assign2.default)({
112 secure: isHttpsWebProtocol(),
113 // for browser compatibility disable fetch.
114 useFetch: false
115 }, options);
116
117 return _initOptions(opts);
118};
119
120/**
121 * prototype
122 */
123
124var proto = Client.prototype;
125
126// mount debug on proto
127proto.debug = debug;
128
129/**
130 * Object operations
131 */
132merge(proto, require('./object'));
133/**
134 * Bucket operations
135 */
136merge(proto, require('../common/bucket/getBucketWebsite'));
137merge(proto, require('../common/bucket/putBucketWebsite'));
138merge(proto, require('../common/bucket/deleteBucketWebsite'));
139
140// lifecycle
141merge(proto, require('../common/bucket/getBucketLifecycle'));
142merge(proto, require('../common/bucket/putBucketLifecycle'));
143merge(proto, require('../common/bucket/deleteBucketLifecycle'));
144
145// multipart upload
146merge(proto, require('./managed-upload'));
147/**
148 * Multipart operations
149 */
150merge(proto, require('../common/multipart'));
151
152/**
153 * Common module parallel
154 */
155merge(proto, require('../common/parallel'));
156
157/**
158 * get OSS signature
159 * @param {String} stringToSign
160 * @return {String} the signature
161 */
162proto.signature = function signature(stringToSign) {
163 this.debug('authorization stringToSign: %s', stringToSign, 'info');
164
165 return signUtils.computeSignature(this.options.accessKeySecret, stringToSign);
166};
167
168/**
169 * get author header
170 *
171 * "Authorization: OSS " + Access Key Id + ":" + Signature
172 *
173 * Signature = base64(hmac-sha1(Access Key Secret + "\n"
174 * + VERB + "\n"
175 * + CONTENT-MD5 + "\n"
176 * + CONTENT-TYPE + "\n"
177 * + DATE + "\n"
178 * + CanonicalizedOSSHeaders
179 * + CanonicalizedResource))
180 *
181 * @param {String} method
182 * @param {String} resource
183 * @param {Object} header
184 * @return {String}
185 *
186 * @api private
187 */
188
189proto.authorization = function authorization(method, resource, subres, headers) {
190 var stringToSign = signUtils.buildCanonicalString(method.toUpperCase(), resource, {
191 headers: headers,
192 parameters: subres
193 });
194
195 return signUtils.authorization(this.options.accessKeyId, this.options.accessKeySecret, stringToSign);
196};
197
198/**
199 * create request params
200 * See `request`
201 * @api private
202 */
203
204proto.createRequest = function createRequest(params) {
205 var headers = {
206 'x-oss-date': dateFormat(+new Date() + this.options.amendTimeSkewed, 'UTC:ddd, dd mmm yyyy HH:MM:ss \'GMT\''),
207 'x-oss-user-agent': this.userAgent
208 };
209
210 if (this.options.isRequestPay) {
211 (0, _assign2.default)(headers, { 'x-oss-request-payer': 'requester' });
212 }
213
214 if (this.options.stsToken) {
215 headers['x-oss-security-token'] = this.options.stsToken;
216 }
217
218 copy(params.headers).to(headers);
219
220 if (!getHeader(headers, 'Content-Type')) {
221 if (params.mime === mime.default_type) {
222 params.mime = '';
223 }
224
225 if (params.mime && params.mime.indexOf('/') > 0) {
226 headers['Content-Type'] = params.mime;
227 } else {
228 headers['Content-Type'] = mime.getType(params.mime || path.extname(params.object || '')) || 'application/octet-stream';
229 }
230 }
231
232 if (params.content) {
233 headers['Content-Md5'] = crypto.createHash('md5').update(Buffer.from(params.content, 'utf8')).digest('base64');
234 if (!headers['Content-Length']) {
235 headers['Content-Length'] = params.content.length;
236 }
237 }
238
239 var authResource = this._getResource(params);
240 headers.authorization = this.authorization(params.method, authResource, params.subres, headers);
241
242 var url = this._getReqUrl(params);
243 this.debug('request %s %s, with headers %j, !!stream: %s', params.method, url, headers, !!params.stream, 'info');
244 var timeout = params.timeout || this.options.timeout;
245 var reqParams = {
246 agent: this.agent,
247 method: params.method,
248 content: params.content,
249 stream: params.stream,
250 headers: headers,
251 timeout: timeout,
252 writeStream: params.writeStream,
253 customResponse: params.customResponse,
254 ctx: params.ctx || this.ctx
255 };
256
257 return {
258 url: url,
259 params: reqParams
260 };
261};
262
263/**
264 * request oss server
265 * @param {Object} params
266 * - {String} object
267 * - {String} bucket
268 * - {Object} [headers]
269 * - {Object} [query]
270 * - {Buffer} [content]
271 * - {Stream} [stream]
272 * - {Stream} [writeStream]
273 * - {String} [mime]
274 * - {Boolean} [xmlResponse]
275 * - {Boolean} [customResponse]
276 * - {Number} [timeout]
277 * - {Object} [ctx] request context, default is `this.ctx`
278 *
279 * @api private
280 */
281
282proto.request = function request(params) {
283 var reqParams, result, reqErr, useStream, err, parseData;
284 return _regenerator2.default.async(function request$(_context) {
285 while (1) {
286 switch (_context.prev = _context.next) {
287 case 0:
288 reqParams = this.createRequest(params);
289
290
291 if (!this.options.useFetch) {
292 reqParams.params.mode = 'disable-fetch';
293 }
294 result = void 0;
295 reqErr = void 0;
296 useStream = !!params.stream;
297 _context.prev = 5;
298 _context.next = 8;
299 return _regenerator2.default.awrap(this.urllib.request(reqParams.url, reqParams.params));
300
301 case 8:
302 result = _context.sent;
303
304 this.debug('response %s %s, got %s, headers: %j', params.method, reqParams.url, result.status, result.headers, 'info');
305 _context.next = 15;
306 break;
307
308 case 12:
309 _context.prev = 12;
310 _context.t0 = _context['catch'](5);
311
312 reqErr = _context.t0;
313
314 case 15:
315 err = void 0;
316
317 if (!(result && params.successStatuses && params.successStatuses.indexOf(result.status) === -1)) {
318 _context.next = 28;
319 break;
320 }
321
322 _context.next = 19;
323 return _regenerator2.default.awrap(this.requestError(result));
324
325 case 19:
326 err = _context.sent;
327
328 if (!(err.code === 'RequestTimeTooSkewed' && !useStream)) {
329 _context.next = 25;
330 break;
331 }
332
333 this.options.amendTimeSkewed = +new Date(err.serverTime) - new Date();
334 _context.next = 24;
335 return _regenerator2.default.awrap(this.request(params));
336
337 case 24:
338 return _context.abrupt('return', _context.sent);
339
340 case 25:
341 err.params = params;
342 _context.next = 32;
343 break;
344
345 case 28:
346 if (!reqErr) {
347 _context.next = 32;
348 break;
349 }
350
351 _context.next = 31;
352 return _regenerator2.default.awrap(this.requestError(reqErr));
353
354 case 31:
355 err = _context.sent;
356
357 case 32:
358 if (!err) {
359 _context.next = 34;
360 break;
361 }
362
363 throw err;
364
365 case 34:
366 if (!params.xmlResponse) {
367 _context.next = 39;
368 break;
369 }
370
371 _context.next = 37;
372 return _regenerator2.default.awrap(this.parseXML(result.data));
373
374 case 37:
375 parseData = _context.sent;
376
377 result.data = parseData;
378
379 case 39:
380 return _context.abrupt('return', result);
381
382 case 40:
383 case 'end':
384 return _context.stop();
385 }
386 }
387 }, null, this, [[5, 12]]);
388};
389
390proto._getResource = function _getResource(params) {
391 var resource = '/';
392 if (params.bucket) resource += params.bucket + '/';
393 if (params.object) resource += params.object;
394
395 return resource;
396};
397
398proto._isIP = _isIP;
399
400proto._escape = function _escape(name) {
401 return utility.encodeURIComponent(name).replace(/%2F/g, '/');
402};
403
404proto._getReqUrl = function _getReqUrl(params) {
405 var ep = {};
406 copy(this.options.endpoint).to(ep);
407 var isIP = this._isIP(ep.hostname);
408 var isCname = this.options.cname;
409 if (params.bucket && !isCname && !isIP) {
410 ep.host = params.bucket + '.' + ep.host;
411 }
412
413 var reourcePath = '/';
414 if (params.bucket && isIP) {
415 reourcePath += params.bucket + '/';
416 }
417
418 if (params.object) {
419 // Preserve '/' in result url
420 reourcePath += this._escape(params.object).replace(/\+/g, '%2B');
421 }
422 ep.pathname = reourcePath;
423
424 var query = {};
425 if (params.query) {
426 merge(query, params.query);
427 }
428
429 if (params.subres) {
430 var subresAsQuery = {};
431 if (is.string(params.subres)) {
432 subresAsQuery[params.subres] = '';
433 } else if (is.array(params.subres)) {
434 params.subres.forEach(function (k) {
435 subresAsQuery[k] = '';
436 });
437 } else {
438 subresAsQuery = params.subres;
439 }
440 merge(query, subresAsQuery);
441 }
442
443 ep.query = query;
444
445 return urlutil.format(ep);
446};
447
448/*
449 * Get User-Agent for browser & node.js
450 * @example
451 * aliyun-sdk-nodejs/4.1.2 Node.js 5.3.0 on Darwin 64-bit
452 * aliyun-sdk-js/4.1.2 Safari 9.0 on Apple iPhone(iOS 9.2.1)
453 * aliyun-sdk-js/4.1.2 Chrome 43.0.2357.134 32-bit on Windows Server 2008 R2 / 7 64-bit
454 */
455
456proto._getUserAgent = function _getUserAgent() {
457 var agent = process && process.browser ? 'js' : 'nodejs';
458 var sdk = 'aliyun-sdk-' + agent + '/' + pkg.version;
459 var plat = platform.description;
460 if (!plat && process) {
461 plat = 'Node.js ' + process.version.slice(1) + ' on ' + process.platform + ' ' + process.arch;
462 }
463
464 return this._checkUserAgent(sdk + ' ' + plat);
465};
466
467proto._checkUserAgent = function _checkUserAgent(ua) {
468 var userAgent = ua.replace(/\u03b1/, 'alpha').replace(/\u03b2/, 'beta');
469 return userAgent;
470};
471
472/*
473 * Check Browser And Version
474 * @param {String} [name] browser name: like IE, Chrome, Firefox
475 * @param {String} [version] browser major version: like 10(IE 10.x), 55(Chrome 55.x), 50(Firefox 50.x)
476 * @return {Bool} true or false
477 * @api private
478 */
479
480proto.checkBrowserAndVersion = function checkBrowserAndVersion(name, version) {
481 return bowser.name === name && bowser.version.split('.')[0] === version;
482};
483
484/**
485 * thunkify xml.parseString
486 * @param {String|Buffer} str
487 *
488 * @api private
489 */
490
491proto.parseXML = function parseXMLThunk(str) {
492 return new _promise2.default(function (resolve, reject) {
493 if (Buffer.isBuffer(str)) {
494 str = str.toString();
495 }
496 xml.parseString(str, {
497 explicitRoot: false,
498 explicitArray: false
499 }, function (err, result) {
500 if (err) {
501 reject(err);
502 } else {
503 resolve(result);
504 }
505 });
506 });
507};
508
509/**
510 * generater a request error with request response
511 * @param {Object} result
512 *
513 * @api private
514 */
515
516proto.requestError = function requestError(result) {
517 var err, message, info, msg;
518 return _regenerator2.default.async(function requestError$(_context2) {
519 while (1) {
520 switch (_context2.prev = _context2.next) {
521 case 0:
522 err = null;
523
524 if (!(!result.data || !result.data.length)) {
525 _context2.next = 5;
526 break;
527 }
528
529 if (result.status === -1 || result.status === -2) {
530 // -1 is net error , -2 is timeout
531 err = new Error(result.message);
532 err.name = result.name;
533 err.status = result.status;
534 err.code = result.name;
535 } else {
536 // HEAD not exists resource
537 if (result.status === 404) {
538 err = new Error('Object not exists');
539 err.name = 'NoSuchKeyError';
540 err.status = 404;
541 err.code = 'NoSuchKey';
542 } else if (result.status === 412) {
543 err = new Error('Pre condition failed');
544 err.name = 'PreconditionFailedError';
545 err.status = 412;
546 err.code = 'PreconditionFailed';
547 } else {
548 err = new Error('Unknow error, status: ' + result.status);
549 err.name = 'UnknowError';
550 err.status = result.status;
551 }
552 err.requestId = result.headers['x-oss-request-id'];
553 err.host = '';
554 }
555 _context2.next = 33;
556 break;
557
558 case 5:
559 message = String(result.data);
560
561 this.debug('request response error data: %s', message, 'error');
562
563 info = void 0;
564 _context2.prev = 8;
565 _context2.next = 11;
566 return _regenerator2.default.awrap(this.parseXML(message));
567
568 case 11:
569 _context2.t0 = _context2.sent;
570
571 if (_context2.t0) {
572 _context2.next = 14;
573 break;
574 }
575
576 _context2.t0 = {};
577
578 case 14:
579 info = _context2.t0;
580 _context2.next = 24;
581 break;
582
583 case 17:
584 _context2.prev = 17;
585 _context2.t1 = _context2['catch'](8);
586
587 this.debug(message, 'error');
588 _context2.t1.message += '\nraw xml: ' + message;
589 _context2.t1.status = result.status;
590 _context2.t1.requestId = result.headers['x-oss-request-id'];
591 return _context2.abrupt('return', _context2.t1);
592
593 case 24:
594 msg = info.Message || 'unknow request error, status: ' + result.status;
595
596 if (info.Condition) {
597 msg += ' (condition: ' + info.Condition + ')';
598 }
599 err = new Error(msg);
600 err.name = info.Code ? info.Code + 'Error' : 'UnknowError';
601 err.status = result.status;
602 err.code = info.Code;
603 err.requestId = info.RequestId;
604 err.hostId = info.HostId;
605 err.serverTime = info.ServerTime;
606
607 case 33:
608
609 this.debug('generate error %j', err, 'error');
610 return _context2.abrupt('return', err);
611
612 case 35:
613 case 'end':
614 return _context2.stop();
615 }
616 }
617 }, null, this, [[8, 17]]);
618};
619
620}).call(this,require('_process'),require("buffer").Buffer)
621},{"../common/bucket/deleteBucketLifecycle":6,"../common/bucket/deleteBucketWebsite":7,"../common/bucket/getBucketLifecycle":8,"../common/bucket/getBucketWebsite":9,"../common/bucket/putBucketLifecycle":10,"../common/bucket/putBucketWebsite":11,"../common/client/initOptions":13,"../common/multipart":16,"../common/parallel":21,"../common/signUtils":22,"../common/utils/isIP":30,"./../../shims/crypto/crypto.js":318,"./managed-upload":3,"./object":4,"./version":5,"_process":239,"agentkeepalive":33,"babel-runtime/core-js/object/assign":39,"babel-runtime/core-js/promise":46,"babel-runtime/regenerator":55,"bowser":57,"buffer":60,"copy-to":63,"dateformat":177,"debug":178,"is-type-of":223,"merge-descriptors":227,"mime":323,"path":236,"platform":237,"url":269,"urllib":325,"utility":324,"xml2js":283}],3:[function(require,module,exports){
622(function (Buffer){
623'use strict';
624
625var _from = require('babel-runtime/core-js/array/from');
626
627var _from2 = _interopRequireDefault(_from);
628
629var _promise = require('babel-runtime/core-js/promise');
630
631var _promise2 = _interopRequireDefault(_promise);
632
633var _regenerator = require('babel-runtime/regenerator');
634
635var _regenerator2 = _interopRequireDefault(_regenerator);
636
637function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
638
639// var debug = require('debug')('ali-oss:multipart');
640var is = require('is-type-of');
641var util = require('util');
642var path = require('path');
643var mime = require('mime');
644var copy = require('copy-to');
645
646var proto = exports;
647
648/**
649 * Multipart operations
650 */
651
652/**
653 * Upload a file to OSS using multipart uploads
654 * @param {String} name
655 * @param {String|File} file
656 * @param {Object} options
657 * {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
658 * {String} options.callback.url the OSS sends a callback request to this URL
659 * {String} options.callback.host The host header value for initiating callback requests
660 * {String} options.callback.body The value of the request body when a callback is initiated
661 * {String} options.callback.contentType The Content-Type of the callback requests initiatiated
662 * {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
663 * customValue = {
664 * key1: 'value1',
665 * key2: 'value2'
666 * }
667 */
668proto.multipartUpload = function multipartUpload(name, file, options) {
669 var minPartSize, fileSize, stream, result, ret, initResult, uploadId, partSize, checkpoint;
670 return _regenerator2.default.async(function multipartUpload$(_context) {
671 while (1) {
672 switch (_context.prev = _context.next) {
673 case 0:
674 this.resetCancelFlag();
675 options = options || {};
676
677 if (!(options.checkpoint && options.checkpoint.uploadId)) {
678 _context.next = 6;
679 break;
680 }
681
682 _context.next = 5;
683 return _regenerator2.default.awrap(this._resumeMultipart(options.checkpoint, options));
684
685 case 5:
686 return _context.abrupt('return', _context.sent);
687
688 case 6:
689 minPartSize = 100 * 1024;
690
691
692 if (!options.mime) {
693 if (is.file(file)) {
694 options.mime = mime.getType(path.extname(file.name));
695 } else if (is.blob(file)) {
696 options.mime = file.type;
697 } else {
698 options.mime = mime.getType(path.extname(file));
699 }
700 }
701
702 options.headers = options.headers || {};
703 this._convertMetaToHeaders(options.meta, options.headers);
704
705 _context.next = 12;
706 return _regenerator2.default.awrap(this._getFileSize(file));
707
708 case 12:
709 fileSize = _context.sent;
710
711 if (!(fileSize < minPartSize)) {
712 _context.next = 25;
713 break;
714 }
715
716 stream = this._createStream(file, 0, fileSize);
717
718 options.contentLength = fileSize;
719
720 _context.next = 18;
721 return _regenerator2.default.awrap(this.putStream(name, stream, options));
722
723 case 18:
724 result = _context.sent;
725
726 if (!(options && options.progress)) {
727 _context.next = 22;
728 break;
729 }
730
731 _context.next = 22;
732 return _regenerator2.default.awrap(options.progress(1));
733
734 case 22:
735 ret = {
736 res: result.res,
737 bucket: this.options.bucket,
738 name: name,
739 etag: result.res.headers.etag
740 };
741
742
743 if (options.headers && options.headers['x-oss-callback'] || options.callback) {
744 ret.data = result.data;
745 }
746
747 return _context.abrupt('return', ret);
748
749 case 25:
750 if (!(options.partSize && !(parseInt(options.partSize, 10) === options.partSize))) {
751 _context.next = 27;
752 break;
753 }
754
755 throw new Error('partSize must be int number');
756
757 case 27:
758 if (!(options.partSize && options.partSize < minPartSize)) {
759 _context.next = 29;
760 break;
761 }
762
763 throw new Error('partSize must not be smaller than ' + minPartSize);
764
765 case 29:
766 _context.next = 31;
767 return _regenerator2.default.awrap(this.initMultipartUpload(name, options));
768
769 case 31:
770 initResult = _context.sent;
771 uploadId = initResult.uploadId;
772 partSize = this._getPartSize(fileSize, options.partSize);
773 checkpoint = {
774 file: file,
775 name: name,
776 fileSize: fileSize,
777 partSize: partSize,
778 uploadId: uploadId,
779 doneParts: []
780 };
781
782 if (!(options && options.progress)) {
783 _context.next = 38;
784 break;
785 }
786
787 _context.next = 38;
788 return _regenerator2.default.awrap(options.progress(0, checkpoint, initResult.res));
789
790 case 38:
791 _context.next = 40;
792 return _regenerator2.default.awrap(this._resumeMultipart(checkpoint, options));
793
794 case 40:
795 return _context.abrupt('return', _context.sent);
796
797 case 41:
798 case 'end':
799 return _context.stop();
800 }
801 }
802 }, null, this);
803};
804
805/*
806 * Resume multipart upload from checkpoint. The checkpoint will be
807 * updated after each successful part upload.
808 * @param {Object} checkpoint the checkpoint
809 * @param {Object} options
810 */
811proto._resumeMultipart = function _resumeMultipart(checkpoint, options) {
812 var that, file, fileSize, partSize, uploadId, doneParts, name, internalDoneParts, partOffs, numParts, multipartFinish, uploadPartJob, all, done, todo, defaultParallel, parallel, jobErr;
813 return _regenerator2.default.async(function _resumeMultipart$(_context3) {
814 while (1) {
815 switch (_context3.prev = _context3.next) {
816 case 0:
817 that = this;
818
819 if (!this.isCancel()) {
820 _context3.next = 3;
821 break;
822 }
823
824 throw this._makeCancelEvent();
825
826 case 3:
827 file = checkpoint.file, fileSize = checkpoint.fileSize, partSize = checkpoint.partSize, uploadId = checkpoint.uploadId, doneParts = checkpoint.doneParts, name = checkpoint.name;
828 internalDoneParts = [];
829
830
831 if (doneParts.length > 0) {
832 copy(doneParts).to(internalDoneParts);
833 }
834
835 partOffs = this._divideParts(fileSize, partSize);
836 numParts = partOffs.length;
837 multipartFinish = false;
838
839 uploadPartJob = function uploadPartJob(self, partNo) {
840 var _this = this;
841
842 return new _promise2.default(function _callee(resolve, reject) {
843 var pi, data, result, tempErr;
844 return _regenerator2.default.async(function _callee$(_context2) {
845 while (1) {
846 switch (_context2.prev = _context2.next) {
847 case 0:
848 _context2.prev = 0;
849
850 if (self.isCancel()) {
851 _context2.next = 18;
852 break;
853 }
854
855 pi = partOffs[partNo - 1];
856 data = {
857 stream: self._createStream(file, pi.start, pi.end),
858 size: pi.end - pi.start
859 };
860 _context2.next = 6;
861 return _regenerator2.default.awrap(self._uploadPart(name, uploadId, partNo, data));
862
863 case 6:
864 result = _context2.sent;
865
866 if (!(!self.isCancel() && !multipartFinish)) {
867 _context2.next = 15;
868 break;
869 }
870
871 checkpoint.doneParts.push({
872 number: partNo,
873 etag: result.res.headers.etag
874 });
875
876 if (!options.progress) {
877 _context2.next = 12;
878 break;
879 }
880
881 _context2.next = 12;
882 return _regenerator2.default.awrap(options.progress(doneParts.length / numParts, checkpoint, result.res));
883
884 case 12:
885
886 resolve({
887 number: partNo,
888 etag: result.res.headers.etag
889 });
890 _context2.next = 16;
891 break;
892
893 case 15:
894 resolve();
895
896 case 16:
897 _context2.next = 19;
898 break;
899
900 case 18:
901 resolve();
902
903 case 19:
904 _context2.next = 30;
905 break;
906
907 case 21:
908 _context2.prev = 21;
909 _context2.t0 = _context2['catch'](0);
910 tempErr = new Error();
911
912 tempErr.name = _context2.t0.name;
913 tempErr.message = _context2.t0.message;
914 tempErr.stack = _context2.t0.stack;
915 tempErr.partNum = partNo;
916 copy(_context2.t0).to(tempErr);
917 reject(tempErr);
918
919 case 30:
920 case 'end':
921 return _context2.stop();
922 }
923 }
924 }, null, _this, [[0, 21]]);
925 });
926 };
927
928 all = (0, _from2.default)(new Array(numParts), function (x, i) {
929 return i + 1;
930 });
931 done = internalDoneParts.map(function (p) {
932 return p.number;
933 });
934 todo = all.filter(function (p) {
935 return done.indexOf(p) < 0;
936 });
937 defaultParallel = 5;
938 parallel = options.parallel || defaultParallel;
939
940 // upload in parallel
941
942 _context3.next = 17;
943 return _regenerator2.default.awrap(this._parallel(todo, parallel, function (value) {
944 return new _promise2.default(function (resolve, reject) {
945 uploadPartJob(that, value).then(function (result) {
946 if (result) {
947 internalDoneParts.push(result);
948 }
949 resolve();
950 }).catch(function (err) {
951 reject(err);
952 });
953 });
954 }));
955
956 case 17:
957 jobErr = _context3.sent;
958
959 multipartFinish = true;
960
961 if (!this.isCancel()) {
962 _context3.next = 22;
963 break;
964 }
965
966 uploadPartJob = null;
967 throw this._makeCancelEvent();
968
969 case 22:
970 if (!(jobErr && jobErr.length > 0)) {
971 _context3.next = 25;
972 break;
973 }
974
975 jobErr[0].message = 'Failed to upload some parts with error: ' + jobErr[0].toString() + ' part_num: ' + jobErr[0].partNum;
976 throw jobErr[0];
977
978 case 25:
979 _context3.next = 27;
980 return _regenerator2.default.awrap(this.completeMultipartUpload(name, uploadId, internalDoneParts, options));
981
982 case 27:
983 return _context3.abrupt('return', _context3.sent);
984
985 case 28:
986 case 'end':
987 return _context3.stop();
988 }
989 }
990 }, null, this);
991};
992
993is.file = function file(obj) {
994 return typeof File !== 'undefined' && obj instanceof File;
995};
996
997is.blob = function (blob) {
998 return typeof Blob !== 'undefined' && blob instanceof Blob;
999};
1000
1001/**
1002 * Get file size
1003 */
1004proto._getFileSize = function _getFileSize(file) {
1005 var stat;
1006 return _regenerator2.default.async(function _getFileSize$(_context4) {
1007 while (1) {
1008 switch (_context4.prev = _context4.next) {
1009 case 0:
1010 if (!is.buffer(file)) {
1011 _context4.next = 4;
1012 break;
1013 }
1014
1015 return _context4.abrupt('return', file.length);
1016
1017 case 4:
1018 if (!(is.blob(file) || is.file(file))) {
1019 _context4.next = 6;
1020 break;
1021 }
1022
1023 return _context4.abrupt('return', file.size);
1024
1025 case 6:
1026 if (!is.string(file)) {
1027 _context4.next = 11;
1028 break;
1029 }
1030
1031 _context4.next = 9;
1032 return _regenerator2.default.awrap(this._statFile(file));
1033
1034 case 9:
1035 stat = _context4.sent;
1036 return _context4.abrupt('return', stat.size);
1037
1038 case 11:
1039 throw new Error('_getFileSize requires Buffer/File/String.');
1040
1041 case 12:
1042 case 'end':
1043 return _context4.stop();
1044 }
1045 }
1046 }, null, this);
1047};
1048
1049/*
1050 * Readable stream for Web File
1051 */
1052
1053var _require = require('stream'),
1054 Readable = _require.Readable;
1055
1056function WebFileReadStream(file, options) {
1057 if (!(this instanceof WebFileReadStream)) {
1058 return new WebFileReadStream(file, options);
1059 }
1060
1061 Readable.call(this, options);
1062
1063 this.file = file;
1064 this.reader = new FileReader();
1065 this.start = 0;
1066 this.finish = false;
1067 this.fileBuffer = null;
1068}
1069util.inherits(WebFileReadStream, Readable);
1070
1071WebFileReadStream.prototype.readFileAndPush = function readFileAndPush(size) {
1072 if (this.fileBuffer) {
1073 var pushRet = true;
1074 while (pushRet && this.fileBuffer && this.start < this.fileBuffer.length) {
1075 var start = this.start;
1076
1077 var end = start + size;
1078 end = end > this.fileBuffer.length ? this.fileBuffer.length : end;
1079 this.start = end;
1080 pushRet = this.push(this.fileBuffer.slice(start, end));
1081 }
1082 }
1083};
1084
1085WebFileReadStream.prototype._read = function _read(size) {
1086 if (this.file && this.start >= this.file.size || this.fileBuffer && this.start >= this.fileBuffer.length || this.finish || this.start === 0 && !this.file) {
1087 if (!this.finish) {
1088 this.fileBuffer = null;
1089 this.finish = true;
1090 }
1091 this.push(null);
1092 return;
1093 }
1094
1095 var defaultReadSize = 16 * 1024;
1096 size = size || defaultReadSize;
1097
1098 var that = this;
1099 this.reader.onload = function onload(e) {
1100 that.fileBuffer = Buffer.from(new Uint8Array(e.target.result));
1101 that.file = null;
1102 that.readFileAndPush(size);
1103 };
1104
1105 if (this.start === 0) {
1106 this.reader.readAsArrayBuffer(this.file);
1107 } else {
1108 this.readFileAndPush(size);
1109 }
1110};
1111
1112proto._createStream = function _createStream(file, start, end) {
1113 if (is.blob(file) || is.file(file)) {
1114 return new WebFileReadStream(file.slice(start, end));
1115 }
1116 // else if (is.string(file)) {
1117 // return fs.createReadStream(file, {
1118 // start: start,
1119 // end: end - 1
1120 // });
1121 // }
1122
1123 throw new Error('_createStream requires File/String.');
1124};
1125
1126proto._getPartSize = function _getPartSize(fileSize, partSize) {
1127 var maxNumParts = 10 * 1000;
1128 var defaultPartSize = 1024 * 1024;
1129
1130 if (!partSize) {
1131 return defaultPartSize;
1132 }
1133
1134 return Math.max(Math.ceil(fileSize / maxNumParts), partSize);
1135};
1136
1137proto._divideParts = function _divideParts(fileSize, partSize) {
1138 var numParts = Math.ceil(fileSize / partSize);
1139
1140 var partOffs = [];
1141 for (var i = 0; i < numParts; i++) {
1142 var start = partSize * i;
1143 var end = Math.min(start + partSize, fileSize);
1144
1145 partOffs.push({
1146 start: start,
1147 end: end
1148 });
1149 }
1150
1151 return partOffs;
1152};
1153
1154}).call(this,require("buffer").Buffer)
1155},{"babel-runtime/core-js/array/from":37,"babel-runtime/core-js/promise":46,"babel-runtime/regenerator":55,"buffer":60,"copy-to":63,"is-type-of":223,"mime":323,"path":236,"stream":261,"util":277}],4:[function(require,module,exports){
1156'use strict';
1157
1158var _promise = require('babel-runtime/core-js/promise');
1159
1160var _promise2 = _interopRequireDefault(_promise);
1161
1162var _keys = require('babel-runtime/core-js/object/keys');
1163
1164var _keys2 = _interopRequireDefault(_keys);
1165
1166var _regenerator = require('babel-runtime/regenerator');
1167
1168var _regenerator2 = _interopRequireDefault(_regenerator);
1169
1170function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1171
1172// const debug = require('debug')('ali-oss:object');
1173var utility = require('utility');
1174var fs = require('fs');
1175var is = require('is-type-of');
1176var urlutil = require('url');
1177var copy = require('copy-to');
1178var path = require('path');
1179var mime = require('mime');
1180var callback = require('../common/callback');
1181var signHelper = require('../common/signUtils');
1182var merge = require('merge-descriptors');
1183
1184// var assert = require('assert');
1185
1186
1187var proto = exports;
1188
1189/**
1190 * Object operations
1191 */
1192
1193/**
1194 * append an object from String(file path)/Buffer/ReadableStream
1195 * @param {String} name the object key
1196 * @param {Mixed} file String(file path)/Buffer/ReadableStream
1197 * @param {Object} options
1198 * @return {Object}
1199 */
1200proto.append = function append(name, file, options) {
1201 var result;
1202 return _regenerator2.default.async(function append$(_context) {
1203 while (1) {
1204 switch (_context.prev = _context.next) {
1205 case 0:
1206 options = options || {};
1207 if (options.position === undefined) options.position = '0';
1208 options.subres = {
1209 append: '',
1210 position: options.position
1211 };
1212 options.method = 'POST';
1213
1214 _context.next = 6;
1215 return _regenerator2.default.awrap(this.put(name, file, options));
1216
1217 case 6:
1218 result = _context.sent;
1219
1220 result.nextAppendPosition = result.res.headers['x-oss-next-append-position'];
1221 return _context.abrupt('return', result);
1222
1223 case 9:
1224 case 'end':
1225 return _context.stop();
1226 }
1227 }
1228 }, null, this);
1229};
1230
1231/**
1232 * put an object from String(file path)/Buffer/ReadableStream
1233 * @param {String} name the object key
1234 * @param {Mixed} file String(file path)/Buffer/ReadableStream
1235 * @param {Object} options
1236 * {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
1237 * {String} options.callback.url the OSS sends a callback request to this URL
1238 * {String} options.callback.host The host header value for initiating callback requests
1239 * {String} options.callback.body The value of the request body when a callback is initiated
1240 * {String} options.callback.contentType The Content-Type of the callback requests initiatiated
1241 * {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
1242 * customValue = {
1243 * key1: 'value1',
1244 * key2: 'value2'
1245 * }
1246 * @return {Object}
1247 */
1248proto.put = function put(name, file, options) {
1249 var content, stream, _result, method, params, result, ret;
1250
1251 return _regenerator2.default.async(function put$(_context2) {
1252 while (1) {
1253 switch (_context2.prev = _context2.next) {
1254 case 0:
1255 content = void 0;
1256
1257 options = options || {};
1258 name = this._objectName(name);
1259
1260 if (!is.buffer(file)) {
1261 _context2.next = 7;
1262 break;
1263 }
1264
1265 content = file;
1266 _context2.next = 30;
1267 break;
1268
1269 case 7:
1270 if (!(is.blob(file) || is.file(file))) {
1271 _context2.next = 29;
1272 break;
1273 }
1274
1275 if (!options.mime) {
1276 if (is.file(file)) {
1277 options.mime = mime.getType(path.extname(file.name));
1278 } else {
1279 options.mime = file.type;
1280 }
1281 }
1282
1283 stream = this._createStream(file, 0, file.size);
1284 _context2.next = 12;
1285 return _regenerator2.default.awrap(this._getFileSize(file));
1286
1287 case 12:
1288 options.contentLength = _context2.sent;
1289 _context2.prev = 13;
1290 _context2.next = 16;
1291 return _regenerator2.default.awrap(this.putStream(name, stream, options));
1292
1293 case 16:
1294 _result = _context2.sent;
1295 return _context2.abrupt('return', _result);
1296
1297 case 20:
1298 _context2.prev = 20;
1299 _context2.t0 = _context2['catch'](13);
1300
1301 if (!(_context2.t0.code === 'RequestTimeTooSkewed')) {
1302 _context2.next = 27;
1303 break;
1304 }
1305
1306 this.options.amendTimeSkewed = +new Date(_context2.t0.serverTime) - new Date();
1307 _context2.next = 26;
1308 return _regenerator2.default.awrap(this.put(name, file, options));
1309
1310 case 26:
1311 return _context2.abrupt('return', _context2.sent);
1312
1313 case 27:
1314 _context2.next = 30;
1315 break;
1316
1317 case 29:
1318 throw new TypeError('Must provide Buffer/Blob for put.');
1319
1320 case 30:
1321
1322 options.headers = options.headers || {};
1323 this._convertMetaToHeaders(options.meta, options.headers);
1324
1325 method = options.method || 'PUT';
1326 params = this._objectRequestParams(method, name, options);
1327
1328 callback.encodeCallback(params, options);
1329 params.mime = options.mime;
1330 params.content = content;
1331 params.successStatuses = [200];
1332
1333 _context2.next = 40;
1334 return _regenerator2.default.awrap(this.request(params));
1335
1336 case 40:
1337 result = _context2.sent;
1338 ret = {
1339 name: name,
1340 url: this._objectUrl(name),
1341 res: result.res
1342 };
1343
1344
1345 if (params.headers && params.headers['x-oss-callback']) {
1346 ret.data = JSON.parse(result.data.toString());
1347 }
1348
1349 return _context2.abrupt('return', ret);
1350
1351 case 44:
1352 case 'end':
1353 return _context2.stop();
1354 }
1355 }
1356 }, null, this, [[13, 20]]);
1357};
1358
1359/**
1360 * put an object from ReadableStream. If `options.contentLength` is
1361 * not provided, chunked encoding is used.
1362 * @param {String} name the object key
1363 * @param {Readable} stream the ReadableStream
1364 * @param {Object} options
1365 * @return {Object}
1366 */
1367proto.putStream = function putStream(name, stream, options) {
1368 var method, params, result, ret;
1369 return _regenerator2.default.async(function putStream$(_context3) {
1370 while (1) {
1371 switch (_context3.prev = _context3.next) {
1372 case 0:
1373 options = options || {};
1374 options.headers = options.headers || {};
1375 name = this._objectName(name);
1376 if (options.contentLength) {
1377 options.headers['Content-Length'] = options.contentLength;
1378 } else {
1379 options.headers['Transfer-Encoding'] = 'chunked';
1380 }
1381 this._convertMetaToHeaders(options.meta, options.headers);
1382
1383 method = options.method || 'PUT';
1384 params = this._objectRequestParams(method, name, options);
1385
1386 callback.encodeCallback(params, options);
1387 params.mime = options.mime;
1388 params.stream = stream;
1389 params.successStatuses = [200];
1390
1391 _context3.next = 13;
1392 return _regenerator2.default.awrap(this.request(params));
1393
1394 case 13:
1395 result = _context3.sent;
1396 ret = {
1397 name: name,
1398 url: this._objectUrl(name),
1399 res: result.res
1400 };
1401
1402
1403 if (params.headers && params.headers['x-oss-callback']) {
1404 ret.data = JSON.parse(result.data.toString());
1405 }
1406
1407 return _context3.abrupt('return', ret);
1408
1409 case 17:
1410 case 'end':
1411 return _context3.stop();
1412 }
1413 }
1414 }, null, this);
1415};
1416
1417proto.head = function head(name, options) {
1418 var params, result, data;
1419 return _regenerator2.default.async(function head$(_context4) {
1420 while (1) {
1421 switch (_context4.prev = _context4.next) {
1422 case 0:
1423 params = this._objectRequestParams('HEAD', name, options);
1424
1425 params.successStatuses = [200, 304];
1426
1427 _context4.next = 4;
1428 return _regenerator2.default.awrap(this.request(params));
1429
1430 case 4:
1431 result = _context4.sent;
1432 data = {
1433 meta: null,
1434 res: result.res,
1435 status: result.status
1436 };
1437
1438
1439 if (result.status === 200) {
1440 (0, _keys2.default)(result.headers).forEach(function (k) {
1441 if (k.indexOf('x-oss-meta-') === 0) {
1442 if (!data.meta) {
1443 data.meta = {};
1444 }
1445 data.meta[k.substring(11)] = result.headers[k];
1446 }
1447 });
1448 }
1449 return _context4.abrupt('return', data);
1450
1451 case 8:
1452 case 'end':
1453 return _context4.stop();
1454 }
1455 }
1456 }, null, this);
1457};
1458
1459proto.get = function get(name, file, options) {
1460 var writeStream, needDestroy, result, params;
1461 return _regenerator2.default.async(function get$(_context5) {
1462 while (1) {
1463 switch (_context5.prev = _context5.next) {
1464 case 0:
1465 writeStream = null;
1466 needDestroy = false;
1467
1468
1469 if (is.writableStream(file)) {
1470 writeStream = file;
1471 } else if (is.string(file)) {
1472 writeStream = fs.createWriteStream(file);
1473 needDestroy = true;
1474 } else {
1475 // get(name, options)
1476 options = file;
1477 }
1478
1479 options = options || {};
1480 if (options.process) {
1481 options.subres = options.subres || {};
1482 options.subres['x-oss-process'] = options.process;
1483 }
1484
1485 result = void 0;
1486 _context5.prev = 6;
1487 params = this._objectRequestParams('GET', name, options);
1488
1489 params.writeStream = writeStream;
1490 params.successStatuses = [200, 206, 304];
1491
1492 _context5.next = 12;
1493 return _regenerator2.default.awrap(this.request(params));
1494
1495 case 12:
1496 result = _context5.sent;
1497
1498
1499 if (needDestroy) {
1500 writeStream.destroy();
1501 }
1502 _context5.next = 24;
1503 break;
1504
1505 case 16:
1506 _context5.prev = 16;
1507 _context5.t0 = _context5['catch'](6);
1508
1509 if (!needDestroy) {
1510 _context5.next = 23;
1511 break;
1512 }
1513
1514 writeStream.destroy();
1515 // should delete the exists file before throw error
1516 this.debug('get error: %s, delete the exists file %s', _context5.t0, file, 'error');
1517 _context5.next = 23;
1518 return _regenerator2.default.awrap(this._deleteFileSafe(file));
1519
1520 case 23:
1521 throw _context5.t0;
1522
1523 case 24:
1524 return _context5.abrupt('return', {
1525 res: result.res,
1526 content: result.data
1527 });
1528
1529 case 25:
1530 case 'end':
1531 return _context5.stop();
1532 }
1533 }
1534 }, null, this, [[6, 16]]);
1535};
1536
1537proto.delete = function _delete(name, options) {
1538 var params, result;
1539 return _regenerator2.default.async(function _delete$(_context6) {
1540 while (1) {
1541 switch (_context6.prev = _context6.next) {
1542 case 0:
1543 params = this._objectRequestParams('DELETE', name, options);
1544
1545 params.successStatuses = [204];
1546
1547 _context6.next = 4;
1548 return _regenerator2.default.awrap(this.request(params));
1549
1550 case 4:
1551 result = _context6.sent;
1552 return _context6.abrupt('return', {
1553 res: result.res
1554 });
1555
1556 case 6:
1557 case 'end':
1558 return _context6.stop();
1559 }
1560 }
1561 }, null, this);
1562};
1563
1564proto.deleteMulti = function deleteMulti(names, options) {
1565 var xml, i, params, result, r, deleted;
1566 return _regenerator2.default.async(function deleteMulti$(_context7) {
1567 while (1) {
1568 switch (_context7.prev = _context7.next) {
1569 case 0:
1570 options = options || {};
1571 xml = '<?xml version="1.0" encoding="UTF-8"?>\n<Delete>\n';
1572
1573 if (options.quiet) {
1574 xml += ' <Quiet>true</Quiet>\n';
1575 } else {
1576 xml += ' <Quiet>false</Quiet>\n';
1577 }
1578 for (i = 0; i < names.length; i++) {
1579 xml += ' <Object><Key>' + utility.escape(this._objectName(names[i])) + '</Key></Object>\n';
1580 }
1581 xml += '</Delete>';
1582 this.debug('delete multi objects: %s', xml, 'info');
1583
1584 options.subres = 'delete';
1585 params = this._objectRequestParams('POST', '', options);
1586
1587 params.mime = 'xml';
1588 params.content = xml;
1589 params.xmlResponse = true;
1590 params.successStatuses = [200];
1591 _context7.next = 14;
1592 return _regenerator2.default.awrap(this.request(params));
1593
1594 case 14:
1595 result = _context7.sent;
1596 r = result.data;
1597 deleted = r && r.Deleted || null;
1598
1599 if (deleted) {
1600 if (!Array.isArray(deleted)) {
1601 deleted = [deleted];
1602 }
1603 deleted = deleted.map(function (item) {
1604 return item.Key;
1605 });
1606 }
1607 return _context7.abrupt('return', {
1608 res: result.res,
1609 deleted: deleted
1610 });
1611
1612 case 19:
1613 case 'end':
1614 return _context7.stop();
1615 }
1616 }
1617 }, null, this);
1618};
1619
1620merge(proto, require('../common/object/copyObject'));
1621merge(proto, require('../common/object/getObjectTagging'));
1622merge(proto, require('../common/object/putObjectTagging'));
1623merge(proto, require('../common/object/deleteObjectTagging'));
1624merge(proto, require('../common/image'));
1625
1626proto.putMeta = function putMeta(name, meta, options) {
1627 var copyResult;
1628 return _regenerator2.default.async(function putMeta$(_context8) {
1629 while (1) {
1630 switch (_context8.prev = _context8.next) {
1631 case 0:
1632 _context8.next = 2;
1633 return _regenerator2.default.awrap(this.copy(name, name, {
1634 meta: meta || {},
1635 timeout: options && options.timeout,
1636 ctx: options && options.ctx
1637 }));
1638
1639 case 2:
1640 copyResult = _context8.sent;
1641 return _context8.abrupt('return', copyResult);
1642
1643 case 4:
1644 case 'end':
1645 return _context8.stop();
1646 }
1647 }
1648 }, null, this);
1649};
1650
1651proto.list = function list(query, options) {
1652 var params, result, objects, that, prefixes;
1653 return _regenerator2.default.async(function list$(_context9) {
1654 while (1) {
1655 switch (_context9.prev = _context9.next) {
1656 case 0:
1657 // prefix, marker, max-keys, delimiter
1658
1659 params = this._objectRequestParams('GET', '', options);
1660
1661 params.query = query;
1662 params.xmlResponse = true;
1663 params.successStatuses = [200];
1664
1665 _context9.next = 6;
1666 return _regenerator2.default.awrap(this.request(params));
1667
1668 case 6:
1669 result = _context9.sent;
1670 objects = result.data.Contents;
1671 that = this;
1672
1673 if (objects) {
1674 if (!Array.isArray(objects)) {
1675 objects = [objects];
1676 }
1677 objects = objects.map(function (obj) {
1678 return {
1679 name: obj.Key,
1680 url: that._objectUrl(obj.Key),
1681 lastModified: obj.LastModified,
1682 etag: obj.ETag,
1683 type: obj.Type,
1684 size: Number(obj.Size),
1685 storageClass: obj.StorageClass,
1686 owner: {
1687 id: obj.Owner.ID,
1688 displayName: obj.Owner.DisplayName
1689 }
1690 };
1691 });
1692 }
1693 prefixes = result.data.CommonPrefixes || null;
1694
1695 if (prefixes) {
1696 if (!Array.isArray(prefixes)) {
1697 prefixes = [prefixes];
1698 }
1699 prefixes = prefixes.map(function (item) {
1700 return item.Prefix;
1701 });
1702 }
1703 return _context9.abrupt('return', {
1704 res: result.res,
1705 objects: objects,
1706 prefixes: prefixes,
1707 nextMarker: result.data.NextMarker || null,
1708 isTruncated: result.data.IsTruncated === 'true'
1709 });
1710
1711 case 13:
1712 case 'end':
1713 return _context9.stop();
1714 }
1715 }
1716 }, null, this);
1717};
1718
1719/*
1720 * Set object's ACL
1721 * @param {String} name the object key
1722 * @param {String} acl the object ACL
1723 * @param {Object} options
1724 */
1725proto.putACL = function putACL(name, acl, options) {
1726 var params, result;
1727 return _regenerator2.default.async(function putACL$(_context10) {
1728 while (1) {
1729 switch (_context10.prev = _context10.next) {
1730 case 0:
1731 options = options || {};
1732 options.subres = 'acl';
1733 options.headers = options.headers || {};
1734 options.headers['x-oss-object-acl'] = acl;
1735 name = this._objectName(name);
1736
1737 params = this._objectRequestParams('PUT', name, options);
1738
1739 params.successStatuses = [200];
1740
1741 _context10.next = 9;
1742 return _regenerator2.default.awrap(this.request(params));
1743
1744 case 9:
1745 result = _context10.sent;
1746 return _context10.abrupt('return', {
1747 res: result.res
1748 });
1749
1750 case 11:
1751 case 'end':
1752 return _context10.stop();
1753 }
1754 }
1755 }, null, this);
1756};
1757
1758/*
1759 * Get object's ACL
1760 * @param {String} name the object key
1761 * @param {Object} options
1762 * @return {Object}
1763 */
1764proto.getACL = function getACL(name, options) {
1765 var params, result;
1766 return _regenerator2.default.async(function getACL$(_context11) {
1767 while (1) {
1768 switch (_context11.prev = _context11.next) {
1769 case 0:
1770 options = options || {};
1771 options.subres = 'acl';
1772 name = this._objectName(name);
1773
1774 params = this._objectRequestParams('GET', name, options);
1775
1776 params.successStatuses = [200];
1777 params.xmlResponse = true;
1778
1779 _context11.next = 8;
1780 return _regenerator2.default.awrap(this.request(params));
1781
1782 case 8:
1783 result = _context11.sent;
1784 return _context11.abrupt('return', {
1785 acl: result.data.AccessControlList.Grant,
1786 owner: {
1787 id: result.data.Owner.ID,
1788 displayName: result.data.Owner.DisplayName
1789 },
1790 res: result.res
1791 });
1792
1793 case 10:
1794 case 'end':
1795 return _context11.stop();
1796 }
1797 }
1798 }, null, this);
1799};
1800
1801/**
1802 * Restore Object
1803 * @param {String} name the object key
1804 * @param {Object} options
1805 * @returns {{res}}
1806 */
1807proto.restore = function restore(name, options) {
1808 var params, result;
1809 return _regenerator2.default.async(function restore$(_context12) {
1810 while (1) {
1811 switch (_context12.prev = _context12.next) {
1812 case 0:
1813 options = options || {};
1814 options.subres = 'restore';
1815 params = this._objectRequestParams('POST', name, options);
1816
1817 params.successStatuses = [202];
1818
1819 _context12.next = 6;
1820 return _regenerator2.default.awrap(this.request(params));
1821
1822 case 6:
1823 result = _context12.sent;
1824 return _context12.abrupt('return', {
1825 res: result.res
1826 });
1827
1828 case 8:
1829 case 'end':
1830 return _context12.stop();
1831 }
1832 }
1833 }, null, this);
1834};
1835
1836proto.signatureUrl = function signatureUrl(name, options) {
1837 options = options || {};
1838 name = this._objectName(name);
1839 options.method = options.method || 'GET';
1840 var expires = utility.timestamp() + (options.expires || 1800);
1841 var params = {
1842 bucket: this.options.bucket,
1843 object: name
1844 };
1845
1846 var resource = this._getResource(params);
1847
1848 if (this.options.stsToken) {
1849 options['security-token'] = this.options.stsToken;
1850 }
1851
1852 var signRes = signHelper._signatureForURL(this.options.accessKeySecret, options, resource, expires);
1853
1854 var url = urlutil.parse(this._getReqUrl(params));
1855 url.query = {
1856 OSSAccessKeyId: this.options.accessKeyId,
1857 Expires: expires,
1858 Signature: signRes.Signature
1859 };
1860
1861 copy(signRes.subResource).to(url.query);
1862
1863 return url.format();
1864};
1865
1866/**
1867 * Get Object url by name
1868 * @param {String} name - object name
1869 * @param {String} [baseUrl] - If provide `baseUrl`,
1870 * will use `baseUrl` instead the default `endpoint`.
1871 * @return {String} object url
1872 */
1873proto.getObjectUrl = function getObjectUrl(name, baseUrl) {
1874 if (!baseUrl) {
1875 baseUrl = this.options.endpoint.format();
1876 } else if (baseUrl[baseUrl.length - 1] !== '/') {
1877 baseUrl += '/';
1878 }
1879 return baseUrl + this._escape(this._objectName(name));
1880};
1881
1882proto._objectUrl = function _objectUrl(name) {
1883 return this._getReqUrl({ bucket: this.options.bucket, object: name });
1884};
1885
1886/**
1887 * Get Object url by name
1888 * @param {String} name - object name
1889 * @param {String} [baseUrl] - If provide `baseUrl`, will use `baseUrl` instead the default `endpoint and bucket`.
1890 * @return {String} object url include bucket
1891 */
1892proto.generateObjectUrl = function (name, baseUrl) {
1893 if (!baseUrl) {
1894 baseUrl = this.options.endpoint.format();
1895 var copyUrl = urlutil.parse(baseUrl);
1896 var bucket = this.options.bucket;
1897
1898
1899 copyUrl.hostname = bucket + '.' + copyUrl.hostname;
1900 copyUrl.host = bucket + '.' + copyUrl.host;
1901 baseUrl = copyUrl.format();
1902 } else if (baseUrl[baseUrl.length - 1] !== '/') {
1903 baseUrl += '/';
1904 }
1905 return baseUrl + this._escape(this._objectName(name));
1906};
1907
1908/**
1909 * generator request params
1910 * @return {Object} params
1911 *
1912 * @api private
1913 */
1914
1915proto._objectRequestParams = function _objectRequestParams(method, name, options) {
1916 if (!this.options.bucket) {
1917 throw new Error('Please create a bucket first');
1918 }
1919
1920 options = options || {};
1921 name = this._objectName(name);
1922 var params = {
1923 object: name,
1924 bucket: this.options.bucket,
1925 method: method,
1926 subres: options && options.subres,
1927 timeout: options && options.timeout,
1928 ctx: options && options.ctx
1929 };
1930
1931 if (options.headers) {
1932 params.headers = {};
1933 copy(options.headers).to(params.headers);
1934 }
1935 return params;
1936};
1937
1938proto._objectName = function _objectName(name) {
1939 return name.replace(/^\/+/, '');
1940};
1941
1942proto._statFile = function _statFile(filepath) {
1943 return new _promise2.default(function (resolve, reject) {
1944 fs.stat(filepath, function (err, stats) {
1945 if (err) {
1946 reject(err);
1947 } else {
1948 resolve(stats);
1949 }
1950 });
1951 });
1952};
1953
1954proto._convertMetaToHeaders = function _convertMetaToHeaders(meta, headers) {
1955 if (!meta) {
1956 return;
1957 }
1958
1959 (0, _keys2.default)(meta).forEach(function (k) {
1960 headers['x-oss-meta-' + k] = meta[k];
1961 });
1962};
1963
1964proto._deleteFileSafe = function _deleteFileSafe(filepath) {
1965 var _this = this;
1966
1967 return new _promise2.default(function (resolve) {
1968 fs.exists(filepath, function (exists) {
1969 if (!exists) {
1970 resolve();
1971 } else {
1972 fs.unlink(filepath, function (err) {
1973 if (err) {
1974 _this.debug('unlink %j error: %s', filepath, err, 'error');
1975 }
1976 resolve();
1977 });
1978 }
1979 });
1980 });
1981};
1982
1983},{"../common/callback":12,"../common/image":14,"../common/object/copyObject":17,"../common/object/deleteObjectTagging":18,"../common/object/getObjectTagging":19,"../common/object/putObjectTagging":20,"../common/signUtils":22,"babel-runtime/core-js/object/keys":45,"babel-runtime/core-js/promise":46,"babel-runtime/regenerator":55,"copy-to":63,"fs":58,"is-type-of":223,"merge-descriptors":227,"mime":323,"path":236,"url":269,"utility":324}],5:[function(require,module,exports){
1984"use strict";
1985
1986exports.version = "6.6.0";
1987
1988},{}],6:[function(require,module,exports){
1989'use strict';
1990
1991var _regenerator = require('babel-runtime/regenerator');
1992
1993var _regenerator2 = _interopRequireDefault(_regenerator);
1994
1995function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1996
1997var _checkBucketName = require('../utils/checkBucketName');
1998
1999var proto = exports;
2000
2001proto.deleteBucketLifecycle = function deleteBucketLifecycle(name, options) {
2002 var params, result;
2003 return _regenerator2.default.async(function deleteBucketLifecycle$(_context) {
2004 while (1) {
2005 switch (_context.prev = _context.next) {
2006 case 0:
2007 _checkBucketName(name);
2008 params = this._bucketRequestParams('DELETE', name, 'lifecycle', options);
2009
2010 params.successStatuses = [204];
2011 _context.next = 5;
2012 return _regenerator2.default.awrap(this.request(params));
2013
2014 case 5:
2015 result = _context.sent;
2016 return _context.abrupt('return', {
2017 res: result.res
2018 });
2019
2020 case 7:
2021 case 'end':
2022 return _context.stop();
2023 }
2024 }
2025 }, null, this);
2026};
2027
2028},{"../utils/checkBucketName":23,"babel-runtime/regenerator":55}],7:[function(require,module,exports){
2029'use strict';
2030
2031var _regenerator = require('babel-runtime/regenerator');
2032
2033var _regenerator2 = _interopRequireDefault(_regenerator);
2034
2035function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2036
2037var _checkBucketName = require('../utils/checkBucketName');
2038
2039var proto = exports;
2040
2041proto.deleteBucketWebsite = function deleteBucketWebsite(name, options) {
2042 var params, result;
2043 return _regenerator2.default.async(function deleteBucketWebsite$(_context) {
2044 while (1) {
2045 switch (_context.prev = _context.next) {
2046 case 0:
2047 _checkBucketName(name);
2048 params = this._bucketRequestParams('DELETE', name, 'website', options);
2049
2050 params.successStatuses = [204];
2051 _context.next = 5;
2052 return _regenerator2.default.awrap(this.request(params));
2053
2054 case 5:
2055 result = _context.sent;
2056 return _context.abrupt('return', {
2057 res: result.res
2058 });
2059
2060 case 7:
2061 case 'end':
2062 return _context.stop();
2063 }
2064 }
2065 }, null, this);
2066};
2067
2068},{"../utils/checkBucketName":23,"babel-runtime/regenerator":55}],8:[function(require,module,exports){
2069'use strict';
2070
2071var _regenerator = require('babel-runtime/regenerator');
2072
2073var _regenerator2 = _interopRequireDefault(_regenerator);
2074
2075function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2076
2077var _checkBucketName = require('../utils/checkBucketName');
2078var isArray = require('../utils/isArray');
2079var formatObjKey = require('../utils/formatObjKey');
2080
2081var proto = exports;
2082
2083proto.getBucketLifecycle = function getBucketLifecycle(name, options) {
2084 var params, result, rules;
2085 return _regenerator2.default.async(function getBucketLifecycle$(_context) {
2086 while (1) {
2087 switch (_context.prev = _context.next) {
2088 case 0:
2089 _checkBucketName(name);
2090 params = this._bucketRequestParams('GET', name, 'lifecycle', options);
2091
2092 params.successStatuses = [200];
2093 params.xmlResponse = true;
2094 _context.next = 6;
2095 return _regenerator2.default.awrap(this.request(params));
2096
2097 case 6:
2098 result = _context.sent;
2099 rules = result.data.Rule || null;
2100
2101 if (rules) {
2102 if (!isArray(rules)) {
2103 rules = [rules];
2104 }
2105 rules = rules.map(function (_) {
2106 if (_.ID) {
2107 _.id = _.ID;
2108 delete _.ID;
2109 }
2110 if (_.Tag && !isArray(_.Tag)) {
2111 _.Tag = [_.Tag];
2112 }
2113 return formatObjKey(_, 'firstLowerCase');
2114 });
2115 }
2116 return _context.abrupt('return', {
2117 rules: rules,
2118 res: result.res
2119 });
2120
2121 case 10:
2122 case 'end':
2123 return _context.stop();
2124 }
2125 }
2126 }, null, this);
2127};
2128
2129},{"../utils/checkBucketName":23,"../utils/formatObjKey":27,"../utils/isArray":29,"babel-runtime/regenerator":55}],9:[function(require,module,exports){
2130'use strict';
2131
2132var _regenerator = require('babel-runtime/regenerator');
2133
2134var _regenerator2 = _interopRequireDefault(_regenerator);
2135
2136function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2137
2138var _checkBucketName = require('../utils/checkBucketName');
2139var isObject = require('../utils/isObject');
2140
2141var proto = exports;
2142
2143proto.getBucketWebsite = function getBucketWebsite(name, options) {
2144 var params, result, routingRules;
2145 return _regenerator2.default.async(function getBucketWebsite$(_context) {
2146 while (1) {
2147 switch (_context.prev = _context.next) {
2148 case 0:
2149 _checkBucketName(name);
2150 params = this._bucketRequestParams('GET', name, 'website', options);
2151
2152 params.successStatuses = [200];
2153 params.xmlResponse = true;
2154 _context.next = 6;
2155 return _regenerator2.default.awrap(this.request(params));
2156
2157 case 6:
2158 result = _context.sent;
2159 routingRules = [];
2160
2161 if (result.data.RoutingRules && result.data.RoutingRules.RoutingRule) {
2162 if (isObject(result.data.RoutingRules.RoutingRule)) {
2163 routingRules = [result.data.RoutingRules.RoutingRule];
2164 } else {
2165 routingRules = result.data.RoutingRules.RoutingRule;
2166 }
2167 }
2168 return _context.abrupt('return', {
2169 index: result.data.IndexDocument && result.data.IndexDocument.Suffix || '',
2170 supportSubDir: result.data.IndexDocument && result.data.IndexDocument.SupportSubDir || 'false',
2171 type: result.data.IndexDocument && result.data.IndexDocument.Type,
2172 routingRules: routingRules,
2173 error: result.data.ErrorDocument && result.data.ErrorDocument.Key || null,
2174 res: result.res
2175 });
2176
2177 case 10:
2178 case 'end':
2179 return _context.stop();
2180 }
2181 }
2182 }, null, this);
2183};
2184
2185},{"../utils/checkBucketName":23,"../utils/isObject":31,"babel-runtime/regenerator":55}],10:[function(require,module,exports){
2186'use strict';
2187
2188var _regenerator = require('babel-runtime/regenerator');
2189
2190var _regenerator2 = _interopRequireDefault(_regenerator);
2191
2192function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2193
2194/* eslint-disable no-use-before-define */
2195var _checkBucketName = require('../utils/checkBucketName');
2196var isArray = require('../utils/isArray');
2197var deepCopy = require('../utils/deepCopy');
2198var isObject = require('../utils/isObject');
2199var obj2xml = require('../utils/obj2xml');
2200var checkObjectTag = require('../utils/checkObjectTag');
2201var getStrBytesCount = require('../utils/getStrBytesCount');
2202
2203var proto = exports;
2204
2205proto.putBucketLifecycle = function putBucketLifecycle(name, rules, options) {
2206 var params, Rule, paramXMLObj, paramXML, result;
2207 return _regenerator2.default.async(function putBucketLifecycle$(_context) {
2208 while (1) {
2209 switch (_context.prev = _context.next) {
2210 case 0:
2211 _checkBucketName(name);
2212
2213 if (isArray(rules)) {
2214 _context.next = 3;
2215 break;
2216 }
2217
2218 throw new Error('rules must be Array');
2219
2220 case 3:
2221 params = this._bucketRequestParams('PUT', name, 'lifecycle', options);
2222 Rule = [];
2223 paramXMLObj = {
2224 LifecycleConfiguration: {
2225 Rule: Rule
2226 }
2227 };
2228
2229
2230 rules.forEach(function (_) {
2231 defaultDaysAndDate2Expiration(_); // todo delete, 兼容旧版本
2232 checkRule(_);
2233 if (_.id) {
2234 _.ID = _.id;
2235 delete _.id;
2236 }
2237 Rule.push(_);
2238 });
2239
2240 paramXML = obj2xml(paramXMLObj, {
2241 headers: true,
2242 firstUpperCase: true
2243 });
2244
2245
2246 params.content = paramXML;
2247 params.mime = 'xml';
2248 params.successStatuses = [200];
2249 _context.next = 13;
2250 return _regenerator2.default.awrap(this.request(params));
2251
2252 case 13:
2253 result = _context.sent;
2254 return _context.abrupt('return', {
2255 res: result.res
2256 });
2257
2258 case 15:
2259 case 'end':
2260 return _context.stop();
2261 }
2262 }
2263 }, null, this);
2264};
2265
2266// todo delete, 兼容旧版本
2267function defaultDaysAndDate2Expiration(obj) {
2268 if (obj.days) {
2269 obj.expiration = {
2270 days: obj.days
2271 };
2272 }
2273 if (obj.date) {
2274 obj.expiration = {
2275 createdBeforeDate: obj.date
2276 };
2277 }
2278}
2279
2280function checkDaysAndDate(obj, key) {
2281 var days = obj.days,
2282 createdBeforeDate = obj.createdBeforeDate;
2283
2284 if (!days && !createdBeforeDate) {
2285 throw new Error(key + ' must includes days or createdBeforeDate');
2286 } else if (days && !/^[1-9][0-9]*$/.test(days)) {
2287 throw new Error('days must be a positive integer');
2288 } else if (createdBeforeDate && !/\d{4}-\d{2}-\d{2}T00:00:00.000Z/.test(createdBeforeDate)) {
2289 throw new Error('createdBeforeDate must be date and conform to iso8601 format');
2290 }
2291}
2292
2293function handleCheckTag(tag) {
2294 if (!isArray(tag) && !isObject(tag)) {
2295 throw new Error('tag must be Object or Array');
2296 }
2297 tag = isObject(tag) ? [tag] : tag;
2298 var tagObj = {};
2299 var tagClone = deepCopy(tag);
2300 tagClone.forEach(function (v) {
2301 tagObj[v.key] = v.value;
2302 });
2303
2304 checkObjectTag(tagObj);
2305}
2306
2307function checkRule(rule) {
2308 if (rule.id && getStrBytesCount(rule.id) > 255) throw new Error('ID is composed of 255 bytes at most');
2309
2310 if (rule.prefix === '' || rule.prefix === undefined) throw new Error('Rule must includes prefix');
2311
2312 if (!['Enabled', 'Disabled'].includes(rule.status)) throw new Error('Status must be Enabled or Disabled');
2313
2314 if (rule.transition) {
2315 if (!['IA', 'Archive'].includes(rule.transition.storageClass)) throw new Error('StorageClass must be IA or Archive');
2316 checkDaysAndDate(rule.transition, 'Transition');
2317 }
2318
2319 if (rule.expiration) {
2320 checkDaysAndDate(rule.expiration, 'Expiration');
2321 }
2322
2323 if (rule.abortMultipartUpload) {
2324 checkDaysAndDate(rule.abortMultipartUpload, 'AbortMultipartUpload');
2325 }
2326
2327 if (!rule.expiration && !rule.abortMultipartUpload && !rule.transition) {
2328 throw new Error('Rule must includes expiration or abortMultipartUpload or transition');
2329 }
2330
2331 if (rule.tag) {
2332 if (rule.abortMultipartUpload) {
2333 throw new Error('Tag cannot be used with abortMultipartUpload');
2334 }
2335 handleCheckTag(rule.tag);
2336 }
2337}
2338
2339},{"../utils/checkBucketName":23,"../utils/checkObjectTag":24,"../utils/deepCopy":26,"../utils/getStrBytesCount":28,"../utils/isArray":29,"../utils/isObject":31,"../utils/obj2xml":32,"babel-runtime/regenerator":55}],11:[function(require,module,exports){
2340'use strict';
2341
2342var _regenerator = require('babel-runtime/regenerator');
2343
2344var _regenerator2 = _interopRequireDefault(_regenerator);
2345
2346function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2347
2348var _checkBucketName = require('../utils/checkBucketName');
2349var obj2xml = require('../utils/obj2xml');
2350var isArray = require('../utils/isArray');
2351
2352var proto = exports;
2353proto.putBucketWebsite = function putBucketWebsite(name) {
2354 var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2355 var options = arguments[2];
2356 var params, IndexDocument, WebsiteConfiguration, website, result;
2357 return _regenerator2.default.async(function putBucketWebsite$(_context) {
2358 while (1) {
2359 switch (_context.prev = _context.next) {
2360 case 0:
2361 _checkBucketName(name);
2362 params = this._bucketRequestParams('PUT', name, 'website', options);
2363 IndexDocument = {
2364 Suffix: config.index || 'index.html'
2365 };
2366 WebsiteConfiguration = {
2367 IndexDocument: IndexDocument
2368 };
2369 website = {
2370 WebsiteConfiguration: WebsiteConfiguration
2371 };
2372
2373
2374 if (config.supportSubDir) {
2375 IndexDocument.SupportSubDir = config.supportSubDir;
2376 }
2377
2378 if (config.type) {
2379 IndexDocument.Type = config.type;
2380 }
2381
2382 if (config.error) {
2383 WebsiteConfiguration.ErrorDocument = {
2384 Key: config.error
2385 };
2386 }
2387
2388 if (!(config.routingRules !== undefined)) {
2389 _context.next = 12;
2390 break;
2391 }
2392
2393 if (isArray(config.routingRules)) {
2394 _context.next = 11;
2395 break;
2396 }
2397
2398 throw new Error('RoutingRules must be Array');
2399
2400 case 11:
2401 WebsiteConfiguration.RoutingRules = {
2402 RoutingRule: config.routingRules
2403 };
2404
2405 case 12:
2406
2407 website = obj2xml(website);
2408 params.content = website;
2409 params.mime = 'xml';
2410 params.successStatuses = [200];
2411 _context.next = 18;
2412 return _regenerator2.default.awrap(this.request(params));
2413
2414 case 18:
2415 result = _context.sent;
2416 return _context.abrupt('return', {
2417 res: result.res
2418 });
2419
2420 case 20:
2421 case 'end':
2422 return _context.stop();
2423 }
2424 }
2425 }, null, this);
2426};
2427
2428},{"../utils/checkBucketName":23,"../utils/isArray":29,"../utils/obj2xml":32,"babel-runtime/regenerator":55}],12:[function(require,module,exports){
2429(function (Buffer){
2430'use strict';
2431
2432var _keys = require('babel-runtime/core-js/object/keys');
2433
2434var _keys2 = _interopRequireDefault(_keys);
2435
2436var _stringify = require('babel-runtime/core-js/json/stringify');
2437
2438var _stringify2 = _interopRequireDefault(_stringify);
2439
2440function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2441
2442exports.encodeCallback = function encodeCallback(reqParams, options) {
2443 reqParams.headers = reqParams.headers || {};
2444 if (!Object.prototype.hasOwnProperty.call(reqParams.headers, 'x-oss-callback')) {
2445 if (options.callback) {
2446 var json = {
2447 callbackUrl: encodeURI(options.callback.url),
2448 callbackBody: options.callback.body
2449 };
2450 if (options.callback.host) {
2451 json.callbackHost = options.callback.host;
2452 }
2453 if (options.callback.contentType) {
2454 json.callbackBodyType = options.callback.contentType;
2455 }
2456 var callback = Buffer.from((0, _stringify2.default)(json)).toString('base64');
2457 reqParams.headers['x-oss-callback'] = callback;
2458
2459 if (options.callback.customValue) {
2460 var callbackVar = {};
2461 (0, _keys2.default)(options.callback.customValue).forEach(function (key) {
2462 callbackVar['x:' + key] = options.callback.customValue[key];
2463 });
2464 reqParams.headers['x-oss-callback-var'] = Buffer.from((0, _stringify2.default)(callbackVar)).toString('base64');
2465 }
2466 }
2467 }
2468};
2469
2470}).call(this,require("buffer").Buffer)
2471},{"babel-runtime/core-js/json/stringify":38,"babel-runtime/core-js/object/keys":45,"buffer":60}],13:[function(require,module,exports){
2472'use strict';
2473
2474var _assign = require('babel-runtime/core-js/object/assign');
2475
2476var _assign2 = _interopRequireDefault(_assign);
2477
2478function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2479
2480var ms = require('humanize-ms');
2481var urlutil = require('url');
2482var _checkBucketName = require('../utils/checkBucketName');
2483
2484function setEndpoint(endpoint, secure) {
2485 var url = urlutil.parse(endpoint);
2486
2487 if (!url.protocol) {
2488 url = urlutil.parse('http' + (secure ? 's' : '') + '://' + endpoint);
2489 }
2490
2491 if (url.protocol !== 'http:' && url.protocol !== 'https:') {
2492 throw new Error('Endpoint protocol must be http or https.');
2493 }
2494
2495 return url;
2496}
2497
2498function setRegion(region, internal, secure) {
2499 var protocol = secure ? 'https://' : 'http://';
2500 var suffix = internal ? '-internal.aliyuncs.com' : '.aliyuncs.com';
2501 var prefix = 'vpc100-oss-cn-';
2502 // aliyun VPC region: https://help.aliyun.com/knowledge_detail/38740.html
2503 if (region.substr(0, prefix.length) === prefix) {
2504 suffix = '.aliyuncs.com';
2505 }
2506
2507 return urlutil.parse(protocol + region + suffix);
2508}
2509
2510module.exports = function (options) {
2511 if (!options || !options.accessKeyId || !options.accessKeySecret) {
2512 throw new Error('require accessKeyId, accessKeySecret');
2513 }
2514 if (options.bucket) {
2515 _checkBucketName(options.bucket);
2516 }
2517 var opts = (0, _assign2.default)({
2518 region: 'oss-cn-hangzhou',
2519 internal: false,
2520 secure: false,
2521 timeout: 60000,
2522 bucket: null,
2523 endpoint: null,
2524 cname: false,
2525 isRequestPay: false,
2526 sldEnable: false
2527 }, options);
2528
2529 opts.accessKeyId = opts.accessKeyId.trim();
2530 opts.accessKeySecret = opts.accessKeySecret.trim();
2531
2532 if (opts.timeout) {
2533 opts.timeout = ms(opts.timeout);
2534 }
2535
2536 if (opts.endpoint) {
2537 opts.endpoint = setEndpoint(opts.endpoint, opts.secure);
2538 } else if (opts.region) {
2539 opts.endpoint = setRegion(opts.region, opts.internal, opts.secure);
2540 } else {
2541 throw new Error('require options.endpoint or options.region');
2542 }
2543
2544 opts.inited = true;
2545 return opts;
2546};
2547
2548},{"../utils/checkBucketName":23,"babel-runtime/core-js/object/assign":39,"humanize-ms":214,"url":269}],14:[function(require,module,exports){
2549'use strict';
2550
2551var merge = require('merge-descriptors');
2552
2553var proto = exports;
2554
2555merge(proto, require('./processObjectSave'));
2556
2557},{"./processObjectSave":15,"merge-descriptors":227}],15:[function(require,module,exports){
2558'use strict';
2559
2560var _regenerator = require('babel-runtime/regenerator');
2561
2562var _regenerator2 = _interopRequireDefault(_regenerator);
2563
2564function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2565
2566/* eslint-disable no-use-before-define */
2567var _checkBucketName = require('../utils/checkBucketName');
2568var querystring = require('querystring');
2569
2570var _require = require('js-base64'),
2571 str2Base64 = _require.Base64.encode;
2572
2573var proto = exports;
2574
2575proto.processObjectSave = function processObjectSave(sourceObject, targetObject, process, targetBucket) {
2576 var params, bucketParam, content, result;
2577 return _regenerator2.default.async(function processObjectSave$(_context) {
2578 while (1) {
2579 switch (_context.prev = _context.next) {
2580 case 0:
2581 checkArgs(sourceObject, 'sourceObject');
2582 checkArgs(targetObject, 'targetObject');
2583 checkArgs(process, 'process');
2584 targetObject = this._objectName(targetObject);
2585 if (targetBucket) {
2586 _checkBucketName(targetBucket);
2587 }
2588
2589 params = this._objectRequestParams('POST', sourceObject, {
2590 subres: 'x-oss-process'
2591 });
2592 bucketParam = targetBucket ? ',b_' + str2Base64(targetBucket) : '';
2593
2594 targetObject = str2Base64(targetObject);
2595
2596 content = {
2597 'x-oss-process': process + '|sys/saveas,o_' + targetObject + bucketParam
2598 };
2599
2600 params.content = querystring.stringify(content);
2601
2602 _context.next = 12;
2603 return _regenerator2.default.awrap(this.request(params));
2604
2605 case 12:
2606 result = _context.sent;
2607 return _context.abrupt('return', {
2608 res: result.res,
2609 status: result.res.status
2610 });
2611
2612 case 14:
2613 case 'end':
2614 return _context.stop();
2615 }
2616 }
2617 }, null, this);
2618};
2619
2620function checkArgs(name, key) {
2621 if (!name) {
2622 throw new Error(key + ' is required');
2623 }
2624 if (typeof name !== 'string') {
2625 throw new Error(key + ' must be String');
2626 }
2627}
2628
2629},{"../utils/checkBucketName":23,"babel-runtime/regenerator":55,"js-base64":226,"querystring":243}],16:[function(require,module,exports){
2630'use strict';
2631
2632var _regenerator = require('babel-runtime/regenerator');
2633
2634var _regenerator2 = _interopRequireDefault(_regenerator);
2635
2636function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2637
2638var copy = require('copy-to');
2639var callback = require('./callback');
2640var deepCopy = require('./utils/deepCopy');
2641
2642var proto = exports;
2643
2644/**
2645 * List the on-going multipart uploads
2646 * https://help.aliyun.com/document_detail/31997.html
2647 * @param {Object} options
2648 * @return {Array} the multipart uploads
2649 */
2650proto.listUploads = function listUploads(query, options) {
2651 var opt, params, result, uploads;
2652 return _regenerator2.default.async(function listUploads$(_context) {
2653 while (1) {
2654 switch (_context.prev = _context.next) {
2655 case 0:
2656 options = options || {};
2657 opt = {};
2658
2659 copy(options).to(opt);
2660 opt.subres = 'uploads';
2661 params = this._objectRequestParams('GET', '', opt);
2662
2663 params.query = query;
2664 params.xmlResponse = true;
2665 params.successStatuses = [200];
2666
2667 _context.next = 10;
2668 return _regenerator2.default.awrap(this.request(params));
2669
2670 case 10:
2671 result = _context.sent;
2672 uploads = result.data.Upload || [];
2673
2674 if (!Array.isArray(uploads)) {
2675 uploads = [uploads];
2676 }
2677 uploads = uploads.map(function (up) {
2678 return {
2679 name: up.Key,
2680 uploadId: up.UploadId,
2681 initiated: up.Initiated
2682 };
2683 });
2684
2685 return _context.abrupt('return', {
2686 res: result.res,
2687 uploads: uploads,
2688 bucket: result.data.Bucket,
2689 nextKeyMarker: result.data.NextKeyMarker,
2690 nextUploadIdMarker: result.data.NextUploadIdMarker,
2691 isTruncated: result.data.IsTruncated === 'true'
2692 });
2693
2694 case 15:
2695 case 'end':
2696 return _context.stop();
2697 }
2698 }
2699 }, null, this);
2700};
2701
2702/**
2703 * List the done uploadPart parts
2704 * @param {String} name object name
2705 * @param {String} uploadId multipart upload id
2706 * @param {Object} query
2707 * {Number} query.max-parts The maximum part number in the response of the OSS. Default value: 1000
2708 * {Number} query.part-number-marker Starting position of a specific list.
2709 * {String} query.encoding-type Specify the encoding of the returned content and the encoding type.
2710 * @param {Object} options
2711 * @return {Object} result
2712 */
2713proto.listParts = function listParts(name, uploadId, query, options) {
2714 var opt, params, result;
2715 return _regenerator2.default.async(function listParts$(_context2) {
2716 while (1) {
2717 switch (_context2.prev = _context2.next) {
2718 case 0:
2719 options = options || {};
2720 opt = {};
2721
2722 copy(options).to(opt);
2723 opt.subres = {
2724 uploadId: uploadId
2725 };
2726 params = this._objectRequestParams('GET', name, opt);
2727
2728 params.query = query;
2729 params.xmlResponse = true;
2730 params.successStatuses = [200];
2731
2732 _context2.next = 10;
2733 return _regenerator2.default.awrap(this.request(params));
2734
2735 case 10:
2736 result = _context2.sent;
2737 return _context2.abrupt('return', {
2738 res: result.res,
2739 uploadId: result.data.UploadId,
2740 bucket: result.data.Bucket,
2741 name: result.data.Key,
2742 partNumberMarker: result.data.PartNumberMarker,
2743 nextPartNumberMarker: result.data.NextPartNumberMarker,
2744 maxParts: result.data.MaxParts,
2745 isTruncated: result.data.IsTruncated,
2746 parts: result.data.Part || []
2747 });
2748
2749 case 12:
2750 case 'end':
2751 return _context2.stop();
2752 }
2753 }
2754 }, null, this);
2755};
2756
2757/**
2758 * Abort a multipart upload transaction
2759 * @param {String} name the object name
2760 * @param {String} uploadId the upload id
2761 * @param {Object} options
2762 */
2763proto.abortMultipartUpload = function abortMultipartUpload(name, uploadId, options) {
2764 var opt, params, result;
2765 return _regenerator2.default.async(function abortMultipartUpload$(_context3) {
2766 while (1) {
2767 switch (_context3.prev = _context3.next) {
2768 case 0:
2769 this._stop();
2770 options = options || {};
2771 opt = {};
2772
2773 copy(options).to(opt);
2774 opt.subres = { uploadId: uploadId };
2775 params = this._objectRequestParams('DELETE', name, opt);
2776
2777 params.successStatuses = [204];
2778
2779 _context3.next = 9;
2780 return _regenerator2.default.awrap(this.request(params));
2781
2782 case 9:
2783 result = _context3.sent;
2784 return _context3.abrupt('return', {
2785 res: result.res
2786 });
2787
2788 case 11:
2789 case 'end':
2790 return _context3.stop();
2791 }
2792 }
2793 }, null, this);
2794};
2795
2796/**
2797 * Initiate a multipart upload transaction
2798 * @param {String} name the object name
2799 * @param {Object} options
2800 * @return {String} upload id
2801 */
2802proto.initMultipartUpload = function initMultipartUpload(name, options) {
2803 var opt, params, result;
2804 return _regenerator2.default.async(function initMultipartUpload$(_context4) {
2805 while (1) {
2806 switch (_context4.prev = _context4.next) {
2807 case 0:
2808 options = options || {};
2809 opt = {};
2810
2811 copy(options).to(opt);
2812 opt.headers = opt.headers || {};
2813 this._convertMetaToHeaders(options.meta, opt.headers);
2814
2815 opt.subres = 'uploads';
2816 params = this._objectRequestParams('POST', name, opt);
2817
2818 params.mime = options.mime;
2819 params.xmlResponse = true;
2820 params.successStatuses = [200];
2821
2822 _context4.next = 12;
2823 return _regenerator2.default.awrap(this.request(params));
2824
2825 case 12:
2826 result = _context4.sent;
2827 return _context4.abrupt('return', {
2828 res: result.res,
2829 bucket: result.data.Bucket,
2830 name: result.data.Key,
2831 uploadId: result.data.UploadId
2832 });
2833
2834 case 14:
2835 case 'end':
2836 return _context4.stop();
2837 }
2838 }
2839 }, null, this);
2840};
2841
2842/**
2843 * Upload a part in a multipart upload transaction
2844 * @param {String} name the object name
2845 * @param {String} uploadId the upload id
2846 * @param {Integer} partNo the part number
2847 * @param {File} file upload File, whole File
2848 * @param {Integer} start part start bytes e.g: 102400
2849 * @param {Integer} end part end bytes e.g: 204800
2850 * @param {Object} options
2851 */
2852proto.uploadPart = function uploadPart(name, uploadId, partNo, file, start, end, options) {
2853 var data;
2854 return _regenerator2.default.async(function uploadPart$(_context5) {
2855 while (1) {
2856 switch (_context5.prev = _context5.next) {
2857 case 0:
2858 data = {
2859 stream: this._createStream(file, start, end),
2860 size: end - start
2861 };
2862 _context5.next = 3;
2863 return _regenerator2.default.awrap(this._uploadPart(name, uploadId, partNo, data, options));
2864
2865 case 3:
2866 return _context5.abrupt('return', _context5.sent);
2867
2868 case 4:
2869 case 'end':
2870 return _context5.stop();
2871 }
2872 }
2873 }, null, this);
2874};
2875
2876/**
2877 * Complete a multipart upload transaction
2878 * @param {String} name the object name
2879 * @param {String} uploadId the upload id
2880 * @param {Array} parts the uploaded parts, each in the structure:
2881 * {Integer} number partNo
2882 * {String} etag part etag uploadPartCopy result.res.header.etag
2883 * @param {Object} options
2884 * {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
2885 * {String} options.callback.url the OSS sends a callback request to this URL
2886 * {String} options.callback.host The host header value for initiating callback requests
2887 * {String} options.callback.body The value of the request body when a callback is initiated
2888 * {String} options.callback.contentType The Content-Type of the callback requests initiatiated
2889 * {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
2890 * customValue = {
2891 * key1: 'value1',
2892 * key2: 'value2'
2893 * }
2894 */
2895proto.completeMultipartUpload = function completeMultipartUpload(name, uploadId, parts, options) {
2896 var completeParts, xml, i, p, opt, params, result, ret;
2897 return _regenerator2.default.async(function completeMultipartUpload$(_context6) {
2898 while (1) {
2899 switch (_context6.prev = _context6.next) {
2900 case 0:
2901 completeParts = parts.concat().sort(function (a, b) {
2902 return a.number - b.number;
2903 }).filter(function (item, index, arr) {
2904 return !index || item.number !== arr[index - 1].number;
2905 });
2906 xml = '<?xml version="1.0" encoding="UTF-8"?>\n<CompleteMultipartUpload>\n';
2907
2908 for (i = 0; i < completeParts.length; i++) {
2909 p = completeParts[i];
2910
2911 xml += '<Part>\n';
2912 xml += '<PartNumber>' + p.number + '</PartNumber>\n';
2913 xml += '<ETag>' + p.etag + '</ETag>\n';
2914 xml += '</Part>\n';
2915 }
2916 xml += '</CompleteMultipartUpload>';
2917
2918 options = options || {};
2919 opt = {};
2920
2921 opt = deepCopy(options);
2922 if (opt.headers) delete opt.headers['x-oss-server-side-encryption'];
2923 opt.subres = { uploadId: uploadId };
2924
2925 params = this._objectRequestParams('POST', name, opt);
2926
2927 callback.encodeCallback(params, opt);
2928 params.mime = 'xml';
2929 params.content = xml;
2930
2931 if (!(params.headers && params.headers['x-oss-callback'])) {
2932 params.xmlResponse = true;
2933 }
2934 params.successStatuses = [200];
2935 _context6.next = 17;
2936 return _regenerator2.default.awrap(this.request(params));
2937
2938 case 17:
2939 result = _context6.sent;
2940 ret = {
2941 res: result.res,
2942 bucket: params.bucket,
2943 name: name,
2944 etag: result.res.headers.etag
2945 };
2946
2947
2948 if (params.headers && params.headers['x-oss-callback']) {
2949 ret.data = JSON.parse(result.data.toString());
2950 }
2951
2952 return _context6.abrupt('return', ret);
2953
2954 case 21:
2955 case 'end':
2956 return _context6.stop();
2957 }
2958 }
2959 }, null, this);
2960};
2961
2962/**
2963 * Upload a part in a multipart upload transaction
2964 * @param {String} name the object name
2965 * @param {String} uploadId the upload id
2966 * @param {Integer} partNo the part number
2967 * @param {Object} data the body data
2968 * @param {Object} options
2969 */
2970proto._uploadPart = function _uploadPart(name, uploadId, partNo, data, options) {
2971 var opt, params, result;
2972 return _regenerator2.default.async(function _uploadPart$(_context7) {
2973 while (1) {
2974 switch (_context7.prev = _context7.next) {
2975 case 0:
2976 options = options || {};
2977 opt = {};
2978
2979 copy(options).to(opt);
2980 opt.headers = {
2981 'Content-Length': data.size
2982 };
2983
2984 opt.subres = {
2985 partNumber: partNo,
2986 uploadId: uploadId
2987 };
2988 params = this._objectRequestParams('PUT', name, opt);
2989
2990 params.mime = opt.mime;
2991 params.stream = data.stream;
2992 params.successStatuses = [200];
2993
2994 _context7.next = 11;
2995 return _regenerator2.default.awrap(this.request(params));
2996
2997 case 11:
2998 result = _context7.sent;
2999
3000 if (result.res.headers.etag) {
3001 _context7.next = 14;
3002 break;
3003 }
3004
3005 throw new Error('Please set the etag of expose-headers in OSS \n https://help.aliyun.com/document_detail/32069.html');
3006
3007 case 14:
3008
3009 data.stream = null;
3010 params.stream = null;
3011 return _context7.abrupt('return', {
3012 name: name,
3013 etag: result.res.headers.etag,
3014 res: result.res
3015 });
3016
3017 case 17:
3018 case 'end':
3019 return _context7.stop();
3020 }
3021 }
3022 }, null, this);
3023};
3024
3025},{"./callback":12,"./utils/deepCopy":26,"babel-runtime/regenerator":55,"copy-to":63}],17:[function(require,module,exports){
3026'use strict';
3027
3028var _regenerator = require('babel-runtime/regenerator');
3029
3030var _regenerator2 = _interopRequireDefault(_regenerator);
3031
3032var _keys = require('babel-runtime/core-js/object/keys');
3033
3034var _keys2 = _interopRequireDefault(_keys);
3035
3036var _typeof2 = require('babel-runtime/helpers/typeof');
3037
3038var _typeof3 = _interopRequireDefault(_typeof2);
3039
3040function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3041
3042var _checkBucketName = require('../utils/checkBucketName');
3043
3044var proto = exports;
3045
3046proto.copy = function copy(name, sourceName, bucketName, options) {
3047 var params, result, data;
3048 return _regenerator2.default.async(function copy$(_context) {
3049 while (1) {
3050 switch (_context.prev = _context.next) {
3051 case 0:
3052 if ((typeof bucketName === 'undefined' ? 'undefined' : (0, _typeof3.default)(bucketName)) === 'object') {
3053 options = bucketName; // 兼容旧版本,旧版本第三个参数为options
3054 }
3055 options = options || {};
3056 options.headers = options.headers || {};
3057
3058 (0, _keys2.default)(options.headers).forEach(function (key) {
3059 options.headers['x-oss-copy-source-' + key.toLowerCase()] = options.headers[key];
3060 });
3061 if (options.meta) {
3062 options.headers['x-oss-metadata-directive'] = 'REPLACE';
3063 }
3064 this._convertMetaToHeaders(options.meta, options.headers);
3065
3066 sourceName = this._getSourceName(sourceName, bucketName);
3067
3068 options.headers['x-oss-copy-source'] = sourceName;
3069
3070 params = this._objectRequestParams('PUT', name, options);
3071
3072 params.xmlResponse = true;
3073 params.successStatuses = [200, 304];
3074
3075 _context.next = 13;
3076 return _regenerator2.default.awrap(this.request(params));
3077
3078 case 13:
3079 result = _context.sent;
3080 data = result.data;
3081
3082 if (data) {
3083 data = {
3084 etag: data.ETag,
3085 lastModified: data.LastModified
3086 };
3087 }
3088
3089 return _context.abrupt('return', {
3090 data: data,
3091 res: result.res
3092 });
3093
3094 case 17:
3095 case 'end':
3096 return _context.stop();
3097 }
3098 }
3099 }, null, this);
3100};
3101
3102// todo delete
3103proto._getSourceName = function _getSourceName(sourceName, bucketName) {
3104 if (typeof bucketName === 'string') {
3105 sourceName = this._objectName(sourceName);
3106 } else if (sourceName[0] !== '/') {
3107 bucketName = this.options.bucket;
3108 } else {
3109 bucketName = sourceName.replace(/\/(.+?)(\/.*)/, '$1');
3110 sourceName = sourceName.replace(/(\/.+?\/)(.*)/, '$2');
3111 }
3112
3113 _checkBucketName(bucketName);
3114
3115 sourceName = '/' + bucketName + '/' + encodeURIComponent(sourceName);
3116 return sourceName;
3117};
3118
3119},{"../utils/checkBucketName":23,"babel-runtime/core-js/object/keys":45,"babel-runtime/helpers/typeof":54,"babel-runtime/regenerator":55}],18:[function(require,module,exports){
3120'use strict';
3121
3122var _regenerator = require('babel-runtime/regenerator');
3123
3124var _regenerator2 = _interopRequireDefault(_regenerator);
3125
3126function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3127
3128var proto = exports;
3129/**
3130 * deleteObjectTagging
3131 * @param {String} name - object name
3132 * @param {Object} options
3133 */
3134
3135proto.deleteObjectTagging = function deleteObjectTagging(name) {
3136 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3137 var params, result;
3138 return _regenerator2.default.async(function deleteObjectTagging$(_context) {
3139 while (1) {
3140 switch (_context.prev = _context.next) {
3141 case 0:
3142 options.subres = 'tagging';
3143 name = this._objectName(name);
3144 params = this._objectRequestParams('DELETE', name, options);
3145
3146 params.successStatuses = [204];
3147 _context.next = 6;
3148 return _regenerator2.default.awrap(this.request(params));
3149
3150 case 6:
3151 result = _context.sent;
3152 return _context.abrupt('return', {
3153 status: result.status,
3154 res: result.res
3155 });
3156
3157 case 8:
3158 case 'end':
3159 return _context.stop();
3160 }
3161 }
3162 }, null, this);
3163};
3164
3165},{"babel-runtime/regenerator":55}],19:[function(require,module,exports){
3166'use strict';
3167
3168var _regenerator = require('babel-runtime/regenerator');
3169
3170var _regenerator2 = _interopRequireDefault(_regenerator);
3171
3172function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3173
3174var proto = exports;
3175var isObject = require('../utils/isObject');
3176/**
3177 * getObjectTagging
3178 * @param {String} name - object name
3179 * @param {Object} options
3180 * @return {Object}
3181 */
3182
3183proto.getObjectTagging = function getObjectTagging(name) {
3184 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3185 var params, result, Tagging, Tag, tag;
3186 return _regenerator2.default.async(function getObjectTagging$(_context) {
3187 while (1) {
3188 switch (_context.prev = _context.next) {
3189 case 0:
3190 options.subres = 'tagging';
3191 name = this._objectName(name);
3192 params = this._objectRequestParams('GET', name, options);
3193
3194 params.successStatuses = [200];
3195 _context.next = 6;
3196 return _regenerator2.default.awrap(this.request(params));
3197
3198 case 6:
3199 result = _context.sent;
3200 _context.next = 9;
3201 return _regenerator2.default.awrap(this.parseXML(result.data));
3202
3203 case 9:
3204 Tagging = _context.sent;
3205 Tag = Tagging.TagSet.Tag;
3206
3207 Tag = Tag && isObject(Tag) ? [Tag] : Tag || [];
3208
3209 tag = {};
3210
3211
3212 Tag.forEach(function (item) {
3213 tag[item.Key] = item.Value;
3214 });
3215
3216 return _context.abrupt('return', {
3217 status: result.status,
3218 res: result.res,
3219 tag: tag
3220 });
3221
3222 case 15:
3223 case 'end':
3224 return _context.stop();
3225 }
3226 }
3227 }, null, this);
3228};
3229
3230},{"../utils/isObject":31,"babel-runtime/regenerator":55}],20:[function(require,module,exports){
3231'use strict';
3232
3233var _regenerator = require('babel-runtime/regenerator');
3234
3235var _regenerator2 = _interopRequireDefault(_regenerator);
3236
3237var _keys = require('babel-runtime/core-js/object/keys');
3238
3239var _keys2 = _interopRequireDefault(_keys);
3240
3241function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3242
3243var obj2xml = require('../utils/obj2xml');
3244var checkTag = require('../utils/checkObjectTag');
3245
3246var proto = exports;
3247/**
3248 * putObjectTagging
3249 * @param {Sting} name - object name
3250 * @param {Object} tag - object tag, eg: `{a: "1", b: "2"}`
3251 * @param {Object} options
3252 */
3253
3254proto.putObjectTagging = function putObjectTagging(name, tag) {
3255 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3256 var params, paramXMLObj, result;
3257 return _regenerator2.default.async(function putObjectTagging$(_context) {
3258 while (1) {
3259 switch (_context.prev = _context.next) {
3260 case 0:
3261 checkTag(tag);
3262
3263 options.subres = 'tagging';
3264 name = this._objectName(name);
3265 params = this._objectRequestParams('PUT', name, options);
3266
3267 params.successStatuses = [200];
3268 tag = (0, _keys2.default)(tag).map(function (key) {
3269 return {
3270 Key: key,
3271 Value: tag[key]
3272 };
3273 });
3274
3275 paramXMLObj = {
3276 Tagging: {
3277 TagSet: {
3278 Tag: tag
3279 }
3280 }
3281 };
3282
3283
3284 params.mime = 'xml';
3285 params.content = obj2xml(paramXMLObj);
3286
3287 _context.next = 11;
3288 return _regenerator2.default.awrap(this.request(params));
3289
3290 case 11:
3291 result = _context.sent;
3292 return _context.abrupt('return', {
3293 res: result.res,
3294 status: result.status
3295 });
3296
3297 case 13:
3298 case 'end':
3299 return _context.stop();
3300 }
3301 }
3302 }, null, this);
3303};
3304
3305},{"../utils/checkObjectTag":24,"../utils/obj2xml":32,"babel-runtime/core-js/object/keys":45,"babel-runtime/regenerator":55}],21:[function(require,module,exports){
3306'use strict';
3307
3308var _regenerator = require('babel-runtime/regenerator');
3309
3310var _regenerator2 = _interopRequireDefault(_regenerator);
3311
3312var _promise = require('babel-runtime/core-js/promise');
3313
3314var _promise2 = _interopRequireDefault(_promise);
3315
3316function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3317
3318var proto = exports;
3319
3320proto._parallelNode = function _parallelNode(todo, parallel, fn, sourceData) {
3321 var that, jobErr, jobs, tempBatch, remainder, batch, taskIndex, i;
3322 return _regenerator2.default.async(function _parallelNode$(_context) {
3323 while (1) {
3324 switch (_context.prev = _context.next) {
3325 case 0:
3326 that = this;
3327 // upload in parallel
3328
3329 jobErr = [];
3330 jobs = [];
3331 tempBatch = todo.length / parallel;
3332 remainder = todo.length % parallel;
3333 batch = remainder === 0 ? tempBatch : (todo.length - remainder) / parallel + 1;
3334 taskIndex = 1;
3335 i = 0;
3336
3337 case 8:
3338 if (!(i < todo.length)) {
3339 _context.next = 26;
3340 break;
3341 }
3342
3343 if (!that.isCancel()) {
3344 _context.next = 11;
3345 break;
3346 }
3347
3348 return _context.abrupt('break', 26);
3349
3350 case 11:
3351
3352 if (sourceData) {
3353 jobs.push(fn(that, todo[i], sourceData));
3354 } else {
3355 jobs.push(fn(that, todo[i]));
3356 }
3357
3358 if (!(jobs.length === parallel || taskIndex === batch && i === todo.length - 1)) {
3359 _context.next = 23;
3360 break;
3361 }
3362
3363 _context.prev = 13;
3364
3365 taskIndex += 1;
3366 /* eslint no-await-in-loop: [0] */
3367 _context.next = 17;
3368 return _regenerator2.default.awrap(_promise2.default.all(jobs));
3369
3370 case 17:
3371 _context.next = 22;
3372 break;
3373
3374 case 19:
3375 _context.prev = 19;
3376 _context.t0 = _context['catch'](13);
3377
3378 jobErr.push(_context.t0);
3379
3380 case 22:
3381 jobs = [];
3382
3383 case 23:
3384 i++;
3385 _context.next = 8;
3386 break;
3387
3388 case 26:
3389 return _context.abrupt('return', jobErr);
3390
3391 case 27:
3392 case 'end':
3393 return _context.stop();
3394 }
3395 }
3396 }, null, this, [[13, 19]]);
3397};
3398
3399proto._parallel = function _parallel(todo, parallel, jobPromise) {
3400 var that = this;
3401 return new _promise2.default(function (resolve) {
3402 var _jobErr = [];
3403 if (parallel <= 0 || !todo) {
3404 resolve(_jobErr);
3405 return;
3406 }
3407
3408 function onlyOnce(fn) {
3409 return function () {
3410 if (fn === null) throw new Error('Callback was already called.');
3411 var callFn = fn;
3412 fn = null;
3413
3414 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
3415 args[_key] = arguments[_key];
3416 }
3417
3418 callFn.apply(this, args);
3419 };
3420 }
3421
3422 function createArrayIterator(coll) {
3423 var i = -1;
3424 var len = coll.length;
3425 return function next() {
3426 return ++i < len && !that.isCancel() ? { value: coll[i], key: i } : null;
3427 };
3428 }
3429
3430 var nextElem = createArrayIterator(todo);
3431 var done = false;
3432 var running = 0;
3433 var looping = false;
3434
3435 function iterateeCallback(err, value) {
3436 running -= 1;
3437 if (err) {
3438 done = true;
3439 _jobErr.push(err);
3440 resolve(_jobErr);
3441 } else if (value === {} || done && running <= 0) {
3442 done = true;
3443 resolve(_jobErr);
3444 } else if (!looping) {
3445 /* eslint no-use-before-define: [0] */
3446 if (that.isCancel()) {
3447 resolve(_jobErr);
3448 } else {
3449 replenish();
3450 }
3451 }
3452 }
3453
3454 function iteratee(value, callback) {
3455 jobPromise(value).then(function (result) {
3456 callback(null, result);
3457 }).catch(function (err) {
3458 callback(err);
3459 });
3460 }
3461
3462 function replenish() {
3463 looping = true;
3464 while (running < parallel && !done && !that.isCancel()) {
3465 var elem = nextElem();
3466 if (elem === null || _jobErr.length > 0) {
3467 done = true;
3468 if (running <= 0) {
3469 resolve(_jobErr);
3470 }
3471 return;
3472 }
3473 running += 1;
3474 iteratee(elem.value, onlyOnce(iterateeCallback));
3475 }
3476 looping = false;
3477 }
3478
3479 replenish();
3480 });
3481};
3482
3483/**
3484 * cancel operation, now can use with multipartUpload
3485 * @param {Object} abort
3486 * {String} anort.name object key
3487 * {String} anort.uploadId upload id
3488 * {String} anort.options timeout
3489 */
3490proto.cancel = function cancel(abort) {
3491 this.options.cancelFlag = true;
3492 if (abort) {
3493 this.abortMultipartUpload(abort.name, abort.uploadId, abort.options);
3494 }
3495};
3496
3497proto.isCancel = function isCancel() {
3498 return this.options.cancelFlag;
3499};
3500
3501proto.resetCancelFlag = function resetCancelFlag() {
3502 this.options.cancelFlag = false;
3503};
3504
3505proto._stop = function _stop() {
3506 this.options.cancelFlag = true;
3507};
3508
3509// cancel is not error , so create an object
3510proto._makeCancelEvent = function _makeCancelEvent() {
3511 var cancelEvent = {
3512 status: 0,
3513 name: 'cancel'
3514 };
3515 return cancelEvent;
3516};
3517
3518},{"babel-runtime/core-js/promise":46,"babel-runtime/regenerator":55}],22:[function(require,module,exports){
3519(function (Buffer){
3520'use strict';
3521
3522var _stringify = require('babel-runtime/core-js/json/stringify');
3523
3524var _stringify2 = _interopRequireDefault(_stringify);
3525
3526var _keys = require('babel-runtime/core-js/object/keys');
3527
3528var _keys2 = _interopRequireDefault(_keys);
3529
3530function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3531
3532var crypto = require('./../../shims/crypto/crypto.js');
3533var is = require('is-type-of');
3534
3535/**
3536 *
3537 * @param {String} resourcePath
3538 * @param {Object} parameters
3539 * @return
3540 */
3541exports.buildCanonicalizedResource = function buildCanonicalizedResource(resourcePath, parameters) {
3542 var canonicalizedResource = '' + resourcePath;
3543 var separatorString = '?';
3544
3545 if (is.string(parameters) && parameters.trim() !== '') {
3546 canonicalizedResource += separatorString + parameters;
3547 } else if (is.array(parameters)) {
3548 parameters.sort();
3549 canonicalizedResource += separatorString + parameters.join('&');
3550 } else if (parameters) {
3551 var compareFunc = function compareFunc(entry1, entry2) {
3552 if (entry1[0] > entry2[0]) {
3553 return 1;
3554 } else if (entry1[0] < entry2[0]) {
3555 return -1;
3556 }
3557 return 0;
3558 };
3559 var processFunc = function processFunc(key) {
3560 canonicalizedResource += separatorString + key;
3561 if (parameters[key]) {
3562 canonicalizedResource += '=' + parameters[key];
3563 }
3564 separatorString = '&';
3565 };
3566 (0, _keys2.default)(parameters).sort(compareFunc).forEach(processFunc);
3567 }
3568
3569 return canonicalizedResource;
3570};
3571
3572/**
3573 * @param {String} method
3574 * @param {String} resourcePath
3575 * @param {Object} request
3576 * @param {String} expires
3577 * @return {String} canonicalString
3578 */
3579exports.buildCanonicalString = function canonicalString(method, resourcePath, request, expires) {
3580 request = request || {};
3581 var headers = request.headers || {};
3582 var OSS_PREFIX = 'x-oss-';
3583 var ossHeaders = [];
3584 var headersToSign = {};
3585
3586 var signContent = [method.toUpperCase(), headers['Content-Md5'] || '', headers['Content-Type'] || headers['Content-Type'.toLowerCase()], expires || headers['x-oss-date']];
3587
3588 (0, _keys2.default)(headers).forEach(function (key) {
3589 var lowerKey = key.toLowerCase();
3590 if (lowerKey.indexOf(OSS_PREFIX) === 0) {
3591 headersToSign[lowerKey] = String(headers[key]).trim();
3592 }
3593 });
3594
3595 (0, _keys2.default)(headersToSign).sort().forEach(function (key) {
3596 ossHeaders.push(key + ':' + headersToSign[key]);
3597 });
3598
3599 signContent = signContent.concat(ossHeaders);
3600
3601 signContent.push(this.buildCanonicalizedResource(resourcePath, request.parameters));
3602
3603 return signContent.join('\n');
3604};
3605
3606/**
3607 * @param {String} accessKeySecret
3608 * @param {String} canonicalString
3609 */
3610exports.computeSignature = function computeSignature(accessKeySecret, canonicalString) {
3611 var signature = crypto.createHmac('sha1', accessKeySecret);
3612 return signature.update(Buffer.from(canonicalString, 'utf8')).digest('base64');
3613};
3614
3615/**
3616 * @param {String} accessKeyId
3617 * @param {String} accessKeySecret
3618 * @param {String} canonicalString
3619 */
3620exports.authorization = function authorization(accessKeyId, accessKeySecret, canonicalString) {
3621 return 'OSS ' + accessKeyId + ':' + this.computeSignature(accessKeySecret, canonicalString);
3622};
3623
3624/**
3625 *
3626 * @param {String} accessKeySecret
3627 * @param {Object} options
3628 * @param {String} resource
3629 * @param {Number} expires
3630 */
3631exports._signatureForURL = function _signatureForURL(accessKeySecret, options, resource, expires) {
3632 var headers = {};
3633 var subResource = {};
3634
3635 if (options.process) {
3636 var processKeyword = 'x-oss-process';
3637 subResource[processKeyword] = options.process;
3638 }
3639
3640 if (options.trafficLimit) {
3641 var trafficLimitKey = 'x-oss-traffic-limit';
3642 subResource[trafficLimitKey] = options.trafficLimit;
3643 }
3644
3645 if (options.response) {
3646 (0, _keys2.default)(options.response).forEach(function (k) {
3647 var key = 'response-' + k.toLowerCase();
3648 subResource[key] = options.response[k];
3649 });
3650 }
3651
3652 (0, _keys2.default)(options).forEach(function (key) {
3653 var lowerKey = key.toLowerCase();
3654 var value = options[key];
3655 if (lowerKey.indexOf('x-oss-') === 0) {
3656 headers[lowerKey] = value;
3657 } else if (lowerKey.indexOf('content-md5') === 0) {
3658 headers[key] = value;
3659 } else if (lowerKey.indexOf('content-type') === 0) {
3660 headers[key] = value;
3661 } else if (lowerKey !== 'expires' && lowerKey !== 'response' && lowerKey !== 'process' && lowerKey !== 'method' && lowerKey !== 'trafficlimit') {
3662 subResource[lowerKey] = value;
3663 }
3664 });
3665
3666 if (Object.prototype.hasOwnProperty.call(options, 'security-token')) {
3667 subResource['security-token'] = options['security-token'];
3668 }
3669
3670 if (Object.prototype.hasOwnProperty.call(options, 'callback')) {
3671 var json = {
3672 callbackUrl: encodeURI(options.callback.url),
3673 callbackBody: options.callback.body
3674 };
3675 if (options.callback.host) {
3676 json.callbackHost = options.callback.host;
3677 }
3678 if (options.callback.contentType) {
3679 json.callbackBodyType = options.callback.contentType;
3680 }
3681 subResource.callback = Buffer.from((0, _stringify2.default)(json)).toString('base64');
3682
3683 if (options.callback.customValue) {
3684 var callbackVar = {};
3685 (0, _keys2.default)(options.callback.customValue).forEach(function (key) {
3686 callbackVar['x:' + key] = options.callback.customValue[key];
3687 });
3688 subResource['callback-var'] = Buffer.from((0, _stringify2.default)(callbackVar)).toString('base64');
3689 }
3690 }
3691
3692 var canonicalString = this.buildCanonicalString(options.method, resource, {
3693 headers: headers,
3694 parameters: subResource
3695 }, expires.toString());
3696
3697 return {
3698 Signature: this.computeSignature(accessKeySecret, canonicalString),
3699 subResource: subResource
3700 };
3701};
3702
3703}).call(this,require("buffer").Buffer)
3704},{"./../../shims/crypto/crypto.js":318,"babel-runtime/core-js/json/stringify":38,"babel-runtime/core-js/object/keys":45,"buffer":60,"is-type-of":223}],23:[function(require,module,exports){
3705'use strict';
3706
3707/**
3708 * check Bucket Name
3709 */
3710
3711module.exports = function (name, createBucket) {
3712 var bucketRegex = createBucket ? /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/ : /^[a-z0-9_][a-z0-9-_]{1,61}[a-z0-9_]$/;
3713 if (!bucketRegex.test(name)) {
3714 throw new Error('The bucket must be conform to the specifications');
3715 }
3716};
3717
3718},{}],24:[function(require,module,exports){
3719'use strict';
3720
3721var _entries = require('babel-runtime/core-js/object/entries');
3722
3723var _entries2 = _interopRequireDefault(_entries);
3724
3725function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3726
3727var checkValid = require('./checkValid');
3728var isObject = require('./isObject');
3729
3730var commonRules = [{
3731 validator: function validator(value) {
3732 if (typeof value !== 'string') {
3733 throw new Error('the key and value of the tag must be String');
3734 }
3735 }
3736}, {
3737 pattern: /^[a-zA-Z0-9 +-=._:/]+$/,
3738 msg: 'tag can contain letters, numbers, spaces, and the following symbols: plus sign (+), hyphen (-), equal sign (=), period (.), underscore (_), colon (:), and forward slash (/)'
3739}];
3740
3741var rules = {
3742 key: [].concat(commonRules, [{
3743 pattern: /^.{1,128}$/,
3744 msg: 'tag key can be a maximum of 128 bytes in length'
3745 }]),
3746 value: [].concat(commonRules, [{
3747 pattern: /^.{0,256}$/,
3748 msg: 'tag value can be a maximum of 256 bytes in length'
3749 }])
3750};
3751
3752module.exports = function checkTag(tag) {
3753 if (!isObject(tag)) {
3754 throw new Error('tag must be Object');
3755 }
3756
3757 var entries = (0, _entries2.default)(tag);
3758
3759 if (entries.length > 10) {
3760 throw new Error('maximum of 10 tags for a object');
3761 }
3762
3763 var rulesIndexKey = ['key', 'value'];
3764
3765 entries.forEach(function (keyValue) {
3766 keyValue.forEach(function (item, index) {
3767 checkValid(item, rules[rulesIndexKey[index]]);
3768 });
3769 });
3770};
3771
3772},{"./checkValid":25,"./isObject":31,"babel-runtime/core-js/object/entries":42}],25:[function(require,module,exports){
3773"use strict";
3774
3775module.exports = function checkValid(_value, _rules) {
3776 _rules.forEach(function (rule) {
3777 if (rule.validator) {
3778 rule.validator(_value);
3779 } else if (rule.pattern && !rule.pattern.test(_value)) {
3780 throw new Error(rule.msg);
3781 }
3782 });
3783};
3784
3785},{}],26:[function(require,module,exports){
3786'use strict';
3787
3788var _keys = require('babel-runtime/core-js/object/keys');
3789
3790var _keys2 = _interopRequireDefault(_keys);
3791
3792var _typeof2 = require('babel-runtime/helpers/typeof');
3793
3794var _typeof3 = _interopRequireDefault(_typeof2);
3795
3796function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3797
3798module.exports = function deepCopy(obj) {
3799 var cache = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
3800
3801 if (obj === null || (typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) !== 'object') {
3802 return obj;
3803 }
3804 var hit = cache.filter(function (c) {
3805 return c.original === obj;
3806 })[0];
3807 if (hit) {
3808 return hit.copy;
3809 }
3810 var copy = Array.isArray(obj) ? [] : {};
3811 cache.push({
3812 original: obj,
3813 copy: copy
3814 });
3815
3816 (0, _keys2.default)(obj).forEach(function (key) {
3817 copy[key] = deepCopy(obj[key], cache);
3818 });
3819
3820 return copy;
3821};
3822
3823},{"babel-runtime/core-js/object/keys":45,"babel-runtime/helpers/typeof":54}],27:[function(require,module,exports){
3824'use strict';
3825
3826var _keys = require('babel-runtime/core-js/object/keys');
3827
3828var _keys2 = _interopRequireDefault(_keys);
3829
3830var _typeof2 = require('babel-runtime/helpers/typeof');
3831
3832var _typeof3 = _interopRequireDefault(_typeof2);
3833
3834function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3835
3836/* eslint-disable no-use-before-define */
3837module.exports = function formatObjKey(obj, type) {
3838 if (obj === null || (typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) !== 'object') {
3839 return obj;
3840 }
3841
3842 var o = void 0;
3843 if (Array.isArray(obj)) {
3844 o = [];
3845 for (var i = 0; i < obj.length; i++) {
3846 o.push(formatObjKey(obj[i], type));
3847 }
3848 } else {
3849 o = {};
3850 (0, _keys2.default)(obj).forEach(function (key) {
3851 o[handelFormat(key, type)] = formatObjKey(obj[key], type);
3852 });
3853 }
3854 return o;
3855};
3856
3857function handelFormat(key, type) {
3858 if (type === 'firstUpperCase') {
3859 key = key.replace(/^./, function (_) {
3860 return _.toUpperCase();
3861 });
3862 } else if (type === 'firstLowerCase') {
3863 key = key.replace(/^./, function (_) {
3864 return _.toLowerCase();
3865 });
3866 }
3867 return key;
3868}
3869
3870},{"babel-runtime/core-js/object/keys":45,"babel-runtime/helpers/typeof":54}],28:[function(require,module,exports){
3871"use strict";
3872
3873module.exports = function getStrBytesCount(str) {
3874 var bytesCount = 0;
3875 for (var i = 0; i < str.length; i++) {
3876 var c = str.charAt(i);
3877 if (/^[\u00-\uff]$/.test(c)) {
3878 bytesCount += 1;
3879 } else {
3880 bytesCount += 2;
3881 }
3882 }
3883 return bytesCount;
3884};
3885
3886},{}],29:[function(require,module,exports){
3887'use strict';
3888
3889module.exports = function isArray(obj) {
3890 return Object.prototype.toString.call(obj) === '[object Array]';
3891};
3892
3893},{}],30:[function(require,module,exports){
3894"use strict";
3895
3896// it provide commont methods for node and browser , we will add more solutions later in this file
3897/**
3898 * Judge isIP include ipv4 or ipv6
3899 * @param {String} options
3900 * @return {Array} the multipart uploads
3901 */
3902module.exports = function (host) {
3903 var ipv4Regex = /^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$/;
3904 var ipv6Regex = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
3905 var isIP = ipv4Regex.test(host) || ipv6Regex.test(host);
3906 return isIP;
3907};
3908
3909},{}],31:[function(require,module,exports){
3910'use strict';
3911
3912module.exports = function isObject(obj) {
3913 return Object.prototype.toString.call(obj) === '[object Object]';
3914};
3915
3916},{}],32:[function(require,module,exports){
3917'use strict';
3918
3919var _keys = require('babel-runtime/core-js/object/keys');
3920
3921var _keys2 = _interopRequireDefault(_keys);
3922
3923function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3924
3925var formatObjKey = require('./formatObjKey');
3926
3927function type(params) {
3928 return Object.prototype.toString.call(params).replace(/(.*? |])/g, '').toLowerCase();
3929}
3930
3931function obj2xml(obj, options) {
3932 var s = '';
3933 if (options && options.headers) {
3934 s = '<?xml version="1.0" encoding="UTF-8"?>\n';
3935 }
3936 if (options && options.firstUpperCase) {
3937 obj = formatObjKey(obj, 'firstUpperCase');
3938 }
3939 if (type(obj) === 'object') {
3940 (0, _keys2.default)(obj).forEach(function (key) {
3941 if (type(obj[key]) === 'string' || type(obj[key]) === 'number') {
3942 s += '<' + key + '>' + obj[key] + '</' + key + '>';
3943 } else if (type(obj[key]) === 'object') {
3944 s += '<' + key + '>' + obj2xml(obj[key]) + '</' + key + '>';
3945 } else if (type(obj[key]) === 'array') {
3946 s += obj[key].map(function (keyChild) {
3947 return '<' + key + '>' + obj2xml(keyChild) + '</' + key + '>';
3948 }).join('');
3949 } else {
3950 s += '<' + key + '>' + obj[key].toString() + '</' + key + '>';
3951 }
3952 });
3953 } else {
3954 s += obj.toString();
3955 }
3956 return s;
3957}
3958
3959module.exports = obj2xml;
3960
3961},{"./formatObjKey":27,"babel-runtime/core-js/object/keys":45}],33:[function(require,module,exports){
3962module.exports = noop;
3963module.exports.HttpsAgent = noop;
3964
3965// Noop function for browser since native api's don't use agents.
3966function noop () {}
3967
3968},{}],34:[function(require,module,exports){
3969module.exports = require('./register')().Promise
3970
3971},{"./register":36}],35:[function(require,module,exports){
3972"use strict"
3973 // global key for user preferred registration
3974var REGISTRATION_KEY = '@@any-promise/REGISTRATION',
3975 // Prior registration (preferred or detected)
3976 registered = null
3977
3978/**
3979 * Registers the given implementation. An implementation must
3980 * be registered prior to any call to `require("any-promise")`,
3981 * typically on application load.
3982 *
3983 * If called with no arguments, will return registration in
3984 * following priority:
3985 *
3986 * For Node.js:
3987 *
3988 * 1. Previous registration
3989 * 2. global.Promise if node.js version >= 0.12
3990 * 3. Auto detected promise based on first sucessful require of
3991 * known promise libraries. Note this is a last resort, as the
3992 * loaded library is non-deterministic. node.js >= 0.12 will
3993 * always use global.Promise over this priority list.
3994 * 4. Throws error.
3995 *
3996 * For Browser:
3997 *
3998 * 1. Previous registration
3999 * 2. window.Promise
4000 * 3. Throws error.
4001 *
4002 * Options:
4003 *
4004 * Promise: Desired Promise constructor
4005 * global: Boolean - Should the registration be cached in a global variable to
4006 * allow cross dependency/bundle registration? (default true)
4007 */
4008module.exports = function(root, loadImplementation){
4009 return function register(implementation, opts){
4010 implementation = implementation || null
4011 opts = opts || {}
4012 // global registration unless explicitly {global: false} in options (default true)
4013 var registerGlobal = opts.global !== false;
4014
4015 // load any previous global registration
4016 if(registered === null && registerGlobal){
4017 registered = root[REGISTRATION_KEY] || null
4018 }
4019
4020 if(registered !== null
4021 && implementation !== null
4022 && registered.implementation !== implementation){
4023 // Throw error if attempting to redefine implementation
4024 throw new Error('any-promise already defined as "'+registered.implementation+
4025 '". You can only register an implementation before the first '+
4026 ' call to require("any-promise") and an implementation cannot be changed')
4027 }
4028
4029 if(registered === null){
4030 // use provided implementation
4031 if(implementation !== null && typeof opts.Promise !== 'undefined'){
4032 registered = {
4033 Promise: opts.Promise,
4034 implementation: implementation
4035 }
4036 } else {
4037 // require implementation if implementation is specified but not provided
4038 registered = loadImplementation(implementation)
4039 }
4040
4041 if(registerGlobal){
4042 // register preference globally in case multiple installations
4043 root[REGISTRATION_KEY] = registered
4044 }
4045 }
4046
4047 return registered
4048 }
4049}
4050
4051},{}],36:[function(require,module,exports){
4052"use strict";
4053module.exports = require('./loader')(window, loadImplementation)
4054
4055/**
4056 * Browser specific loadImplementation. Always uses `window.Promise`
4057 *
4058 * To register a custom implementation, must register with `Promise` option.
4059 */
4060function loadImplementation(){
4061 if(typeof window.Promise === 'undefined'){
4062 throw new Error("any-promise browser requires a polyfill or explicit registration"+
4063 " e.g: require('any-promise/register/bluebird')")
4064 }
4065 return {
4066 Promise: window.Promise,
4067 implementation: 'window.Promise'
4068 }
4069}
4070
4071},{"./loader":35}],37:[function(require,module,exports){
4072module.exports = { "default": require("core-js/library/fn/array/from"), __esModule: true };
4073},{"core-js/library/fn/array/from":64}],38:[function(require,module,exports){
4074module.exports = { "default": require("core-js/library/fn/json/stringify"), __esModule: true };
4075},{"core-js/library/fn/json/stringify":65}],39:[function(require,module,exports){
4076module.exports = { "default": require("core-js/library/fn/object/assign"), __esModule: true };
4077},{"core-js/library/fn/object/assign":66}],40:[function(require,module,exports){
4078module.exports = { "default": require("core-js/library/fn/object/create"), __esModule: true };
4079},{"core-js/library/fn/object/create":67}],41:[function(require,module,exports){
4080module.exports = { "default": require("core-js/library/fn/object/define-property"), __esModule: true };
4081},{"core-js/library/fn/object/define-property":68}],42:[function(require,module,exports){
4082module.exports = { "default": require("core-js/library/fn/object/entries"), __esModule: true };
4083},{"core-js/library/fn/object/entries":69}],43:[function(require,module,exports){
4084module.exports = { "default": require("core-js/library/fn/object/get-own-property-names"), __esModule: true };
4085},{"core-js/library/fn/object/get-own-property-names":70}],44:[function(require,module,exports){
4086module.exports = { "default": require("core-js/library/fn/object/get-prototype-of"), __esModule: true };
4087},{"core-js/library/fn/object/get-prototype-of":71}],45:[function(require,module,exports){
4088module.exports = { "default": require("core-js/library/fn/object/keys"), __esModule: true };
4089},{"core-js/library/fn/object/keys":72}],46:[function(require,module,exports){
4090module.exports = { "default": require("core-js/library/fn/promise"), __esModule: true };
4091},{"core-js/library/fn/promise":73}],47:[function(require,module,exports){
4092module.exports = { "default": require("core-js/library/fn/set-immediate"), __esModule: true };
4093},{"core-js/library/fn/set-immediate":74}],48:[function(require,module,exports){
4094module.exports = { "default": require("core-js/library/fn/string/from-code-point"), __esModule: true };
4095},{"core-js/library/fn/string/from-code-point":75}],49:[function(require,module,exports){
4096module.exports = { "default": require("core-js/library/fn/symbol"), __esModule: true };
4097},{"core-js/library/fn/symbol":77}],50:[function(require,module,exports){
4098module.exports = { "default": require("core-js/library/fn/symbol/has-instance"), __esModule: true };
4099},{"core-js/library/fn/symbol/has-instance":76}],51:[function(require,module,exports){
4100module.exports = { "default": require("core-js/library/fn/symbol/iterator"), __esModule: true };
4101},{"core-js/library/fn/symbol/iterator":78}],52:[function(require,module,exports){
4102"use strict";
4103
4104exports.__esModule = true;
4105
4106exports.default = function (instance, Constructor) {
4107 if (!(instance instanceof Constructor)) {
4108 throw new TypeError("Cannot call a class as a function");
4109 }
4110};
4111},{}],53:[function(require,module,exports){
4112"use strict";
4113
4114exports.__esModule = true;
4115
4116var _defineProperty = require("../core-js/object/define-property");
4117
4118var _defineProperty2 = _interopRequireDefault(_defineProperty);
4119
4120function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4121
4122exports.default = function () {
4123 function defineProperties(target, props) {
4124 for (var i = 0; i < props.length; i++) {
4125 var descriptor = props[i];
4126 descriptor.enumerable = descriptor.enumerable || false;
4127 descriptor.configurable = true;
4128 if ("value" in descriptor) descriptor.writable = true;
4129 (0, _defineProperty2.default)(target, descriptor.key, descriptor);
4130 }
4131 }
4132
4133 return function (Constructor, protoProps, staticProps) {
4134 if (protoProps) defineProperties(Constructor.prototype, protoProps);
4135 if (staticProps) defineProperties(Constructor, staticProps);
4136 return Constructor;
4137 };
4138}();
4139},{"../core-js/object/define-property":41}],54:[function(require,module,exports){
4140"use strict";
4141
4142exports.__esModule = true;
4143
4144var _iterator = require("../core-js/symbol/iterator");
4145
4146var _iterator2 = _interopRequireDefault(_iterator);
4147
4148var _symbol = require("../core-js/symbol");
4149
4150var _symbol2 = _interopRequireDefault(_symbol);
4151
4152var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
4153
4154function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4155
4156exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
4157 return typeof obj === "undefined" ? "undefined" : _typeof(obj);
4158} : function (obj) {
4159 return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
4160};
4161},{"../core-js/symbol":49,"../core-js/symbol/iterator":51}],55:[function(require,module,exports){
4162module.exports = require("regenerator-runtime");
4163
4164},{"regenerator-runtime":257}],56:[function(require,module,exports){
4165'use strict'
4166
4167exports.byteLength = byteLength
4168exports.toByteArray = toByteArray
4169exports.fromByteArray = fromByteArray
4170
4171var lookup = []
4172var revLookup = []
4173var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
4174
4175var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
4176for (var i = 0, len = code.length; i < len; ++i) {
4177 lookup[i] = code[i]
4178 revLookup[code.charCodeAt(i)] = i
4179}
4180
4181// Support decoding URL-safe base64 strings, as Node.js does.
4182// See: https://en.wikipedia.org/wiki/Base64#URL_applications
4183revLookup['-'.charCodeAt(0)] = 62
4184revLookup['_'.charCodeAt(0)] = 63
4185
4186function getLens (b64) {
4187 var len = b64.length
4188
4189 if (len % 4 > 0) {
4190 throw new Error('Invalid string. Length must be a multiple of 4')
4191 }
4192
4193 // Trim off extra bytes after placeholder bytes are found
4194 // See: https://github.com/beatgammit/base64-js/issues/42
4195 var validLen = b64.indexOf('=')
4196 if (validLen === -1) validLen = len
4197
4198 var placeHoldersLen = validLen === len
4199 ? 0
4200 : 4 - (validLen % 4)
4201
4202 return [validLen, placeHoldersLen]
4203}
4204
4205// base64 is 4/3 + up to two characters of the original data
4206function byteLength (b64) {
4207 var lens = getLens(b64)
4208 var validLen = lens[0]
4209 var placeHoldersLen = lens[1]
4210 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
4211}
4212
4213function _byteLength (b64, validLen, placeHoldersLen) {
4214 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
4215}
4216
4217function toByteArray (b64) {
4218 var tmp
4219 var lens = getLens(b64)
4220 var validLen = lens[0]
4221 var placeHoldersLen = lens[1]
4222
4223 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
4224
4225 var curByte = 0
4226
4227 // if there are placeholders, only get up to the last complete 4 chars
4228 var len = placeHoldersLen > 0
4229 ? validLen - 4
4230 : validLen
4231
4232 for (var i = 0; i < len; i += 4) {
4233 tmp =
4234 (revLookup[b64.charCodeAt(i)] << 18) |
4235 (revLookup[b64.charCodeAt(i + 1)] << 12) |
4236 (revLookup[b64.charCodeAt(i + 2)] << 6) |
4237 revLookup[b64.charCodeAt(i + 3)]
4238 arr[curByte++] = (tmp >> 16) & 0xFF
4239 arr[curByte++] = (tmp >> 8) & 0xFF
4240 arr[curByte++] = tmp & 0xFF
4241 }
4242
4243 if (placeHoldersLen === 2) {
4244 tmp =
4245 (revLookup[b64.charCodeAt(i)] << 2) |
4246 (revLookup[b64.charCodeAt(i + 1)] >> 4)
4247 arr[curByte++] = tmp & 0xFF
4248 }
4249
4250 if (placeHoldersLen === 1) {
4251 tmp =
4252 (revLookup[b64.charCodeAt(i)] << 10) |
4253 (revLookup[b64.charCodeAt(i + 1)] << 4) |
4254 (revLookup[b64.charCodeAt(i + 2)] >> 2)
4255 arr[curByte++] = (tmp >> 8) & 0xFF
4256 arr[curByte++] = tmp & 0xFF
4257 }
4258
4259 return arr
4260}
4261
4262function tripletToBase64 (num) {
4263 return lookup[num >> 18 & 0x3F] +
4264 lookup[num >> 12 & 0x3F] +
4265 lookup[num >> 6 & 0x3F] +
4266 lookup[num & 0x3F]
4267}
4268
4269function encodeChunk (uint8, start, end) {
4270 var tmp
4271 var output = []
4272 for (var i = start; i < end; i += 3) {
4273 tmp =
4274 ((uint8[i] << 16) & 0xFF0000) +
4275 ((uint8[i + 1] << 8) & 0xFF00) +
4276 (uint8[i + 2] & 0xFF)
4277 output.push(tripletToBase64(tmp))
4278 }
4279 return output.join('')
4280}
4281
4282function fromByteArray (uint8) {
4283 var tmp
4284 var len = uint8.length
4285 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
4286 var parts = []
4287 var maxChunkLength = 16383 // must be multiple of 3
4288
4289 // go through the array every three bytes, we'll deal with trailing stuff later
4290 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
4291 parts.push(encodeChunk(
4292 uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
4293 ))
4294 }
4295
4296 // pad the end with zeros, but make sure to not forget the extra bytes
4297 if (extraBytes === 1) {
4298 tmp = uint8[len - 1]
4299 parts.push(
4300 lookup[tmp >> 2] +
4301 lookup[(tmp << 4) & 0x3F] +
4302 '=='
4303 )
4304 } else if (extraBytes === 2) {
4305 tmp = (uint8[len - 2] << 8) + uint8[len - 1]
4306 parts.push(
4307 lookup[tmp >> 10] +
4308 lookup[(tmp >> 4) & 0x3F] +
4309 lookup[(tmp << 2) & 0x3F] +
4310 '='
4311 )
4312 }
4313
4314 return parts.join('')
4315}
4316
4317},{}],57:[function(require,module,exports){
4318/*!
4319 * Bowser - a browser detector
4320 * https://github.com/ded/bowser
4321 * MIT License | (c) Dustin Diaz 2015
4322 */
4323
4324!function (root, name, definition) {
4325 if (typeof module != 'undefined' && module.exports) module.exports = definition()
4326 else if (typeof define == 'function' && define.amd) define(name, definition)
4327 else root[name] = definition()
4328}(this, 'bowser', function () {
4329 /**
4330 * See useragents.js for examples of navigator.userAgent
4331 */
4332
4333 var t = true
4334
4335 function detect(ua) {
4336
4337 function getFirstMatch(regex) {
4338 var match = ua.match(regex);
4339 return (match && match.length > 1 && match[1]) || '';
4340 }
4341
4342 function getSecondMatch(regex) {
4343 var match = ua.match(regex);
4344 return (match && match.length > 1 && match[2]) || '';
4345 }
4346
4347 var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
4348 , likeAndroid = /like android/i.test(ua)
4349 , android = !likeAndroid && /android/i.test(ua)
4350 , nexusMobile = /nexus\s*[0-6]\s*/i.test(ua)
4351 , nexusTablet = !nexusMobile && /nexus\s*[0-9]+/i.test(ua)
4352 , chromeos = /CrOS/.test(ua)
4353 , silk = /silk/i.test(ua)
4354 , sailfish = /sailfish/i.test(ua)
4355 , tizen = /tizen/i.test(ua)
4356 , webos = /(web|hpw)(o|0)s/i.test(ua)
4357 , windowsphone = /windows phone/i.test(ua)
4358 , samsungBrowser = /SamsungBrowser/i.test(ua)
4359 , windows = !windowsphone && /windows/i.test(ua)
4360 , mac = !iosdevice && !silk && /macintosh/i.test(ua)
4361 , linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua)
4362 , edgeVersion = getSecondMatch(/edg([ea]|ios)\/(\d+(\.\d+)?)/i)
4363 , versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i)
4364 , tablet = /tablet/i.test(ua) && !/tablet pc/i.test(ua)
4365 , mobile = !tablet && /[^-]mobi/i.test(ua)
4366 , xbox = /xbox/i.test(ua)
4367 , result
4368
4369 if (/opera/i.test(ua)) {
4370 // an old Opera
4371 result = {
4372 name: 'Opera'
4373 , opera: t
4374 , version: versionIdentifier || getFirstMatch(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)
4375 }
4376 } else if (/opr\/|opios/i.test(ua)) {
4377 // a new Opera
4378 result = {
4379 name: 'Opera'
4380 , opera: t
4381 , version: getFirstMatch(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i) || versionIdentifier
4382 }
4383 }
4384 else if (/SamsungBrowser/i.test(ua)) {
4385 result = {
4386 name: 'Samsung Internet for Android'
4387 , samsungBrowser: t
4388 , version: versionIdentifier || getFirstMatch(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)
4389 }
4390 }
4391 else if (/Whale/i.test(ua)) {
4392 result = {
4393 name: 'NAVER Whale browser'
4394 , whale: t
4395 , version: getFirstMatch(/(?:whale)[\s\/](\d+(?:\.\d+)+)/i)
4396 }
4397 }
4398 else if (/MZBrowser/i.test(ua)) {
4399 result = {
4400 name: 'MZ Browser'
4401 , mzbrowser: t
4402 , version: getFirstMatch(/(?:MZBrowser)[\s\/](\d+(?:\.\d+)+)/i)
4403 }
4404 }
4405 else if (/coast/i.test(ua)) {
4406 result = {
4407 name: 'Opera Coast'
4408 , coast: t
4409 , version: versionIdentifier || getFirstMatch(/(?:coast)[\s\/](\d+(\.\d+)?)/i)
4410 }
4411 }
4412 else if (/focus/i.test(ua)) {
4413 result = {
4414 name: 'Focus'
4415 , focus: t
4416 , version: getFirstMatch(/(?:focus)[\s\/](\d+(?:\.\d+)+)/i)
4417 }
4418 }
4419 else if (/yabrowser/i.test(ua)) {
4420 result = {
4421 name: 'Yandex Browser'
4422 , yandexbrowser: t
4423 , version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)
4424 }
4425 }
4426 else if (/ucbrowser/i.test(ua)) {
4427 result = {
4428 name: 'UC Browser'
4429 , ucbrowser: t
4430 , version: getFirstMatch(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)
4431 }
4432 }
4433 else if (/mxios/i.test(ua)) {
4434 result = {
4435 name: 'Maxthon'
4436 , maxthon: t
4437 , version: getFirstMatch(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)
4438 }
4439 }
4440 else if (/epiphany/i.test(ua)) {
4441 result = {
4442 name: 'Epiphany'
4443 , epiphany: t
4444 , version: getFirstMatch(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)
4445 }
4446 }
4447 else if (/puffin/i.test(ua)) {
4448 result = {
4449 name: 'Puffin'
4450 , puffin: t
4451 , version: getFirstMatch(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)
4452 }
4453 }
4454 else if (/sleipnir/i.test(ua)) {
4455 result = {
4456 name: 'Sleipnir'
4457 , sleipnir: t
4458 , version: getFirstMatch(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)
4459 }
4460 }
4461 else if (/k-meleon/i.test(ua)) {
4462 result = {
4463 name: 'K-Meleon'
4464 , kMeleon: t
4465 , version: getFirstMatch(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)
4466 }
4467 }
4468 else if (windowsphone) {
4469 result = {
4470 name: 'Windows Phone'
4471 , osname: 'Windows Phone'
4472 , windowsphone: t
4473 }
4474 if (edgeVersion) {
4475 result.msedge = t
4476 result.version = edgeVersion
4477 }
4478 else {
4479 result.msie = t
4480 result.version = getFirstMatch(/iemobile\/(\d+(\.\d+)?)/i)
4481 }
4482 }
4483 else if (/msie|trident/i.test(ua)) {
4484 result = {
4485 name: 'Internet Explorer'
4486 , msie: t
4487 , version: getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i)
4488 }
4489 } else if (chromeos) {
4490 result = {
4491 name: 'Chrome'
4492 , osname: 'Chrome OS'
4493 , chromeos: t
4494 , chromeBook: t
4495 , chrome: t
4496 , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
4497 }
4498 } else if (/edg([ea]|ios)/i.test(ua)) {
4499 result = {
4500 name: 'Microsoft Edge'
4501 , msedge: t
4502 , version: edgeVersion
4503 }
4504 }
4505 else if (/vivaldi/i.test(ua)) {
4506 result = {
4507 name: 'Vivaldi'
4508 , vivaldi: t
4509 , version: getFirstMatch(/vivaldi\/(\d+(\.\d+)?)/i) || versionIdentifier
4510 }
4511 }
4512 else if (sailfish) {
4513 result = {
4514 name: 'Sailfish'
4515 , osname: 'Sailfish OS'
4516 , sailfish: t
4517 , version: getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i)
4518 }
4519 }
4520 else if (/seamonkey\//i.test(ua)) {
4521 result = {
4522 name: 'SeaMonkey'
4523 , seamonkey: t
4524 , version: getFirstMatch(/seamonkey\/(\d+(\.\d+)?)/i)
4525 }
4526 }
4527 else if (/firefox|iceweasel|fxios/i.test(ua)) {
4528 result = {
4529 name: 'Firefox'
4530 , firefox: t
4531 , version: getFirstMatch(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)
4532 }
4533 if (/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) {
4534 result.firefoxos = t
4535 result.osname = 'Firefox OS'
4536 }
4537 }
4538 else if (silk) {
4539 result = {
4540 name: 'Amazon Silk'
4541 , silk: t
4542 , version : getFirstMatch(/silk\/(\d+(\.\d+)?)/i)
4543 }
4544 }
4545 else if (/phantom/i.test(ua)) {
4546 result = {
4547 name: 'PhantomJS'
4548 , phantom: t
4549 , version: getFirstMatch(/phantomjs\/(\d+(\.\d+)?)/i)
4550 }
4551 }
4552 else if (/slimerjs/i.test(ua)) {
4553 result = {
4554 name: 'SlimerJS'
4555 , slimer: t
4556 , version: getFirstMatch(/slimerjs\/(\d+(\.\d+)?)/i)
4557 }
4558 }
4559 else if (/blackberry|\bbb\d+/i.test(ua) || /rim\stablet/i.test(ua)) {
4560 result = {
4561 name: 'BlackBerry'
4562 , osname: 'BlackBerry OS'
4563 , blackberry: t
4564 , version: versionIdentifier || getFirstMatch(/blackberry[\d]+\/(\d+(\.\d+)?)/i)
4565 }
4566 }
4567 else if (webos) {
4568 result = {
4569 name: 'WebOS'
4570 , osname: 'WebOS'
4571 , webos: t
4572 , version: versionIdentifier || getFirstMatch(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)
4573 };
4574 /touchpad\//i.test(ua) && (result.touchpad = t)
4575 }
4576 else if (/bada/i.test(ua)) {
4577 result = {
4578 name: 'Bada'
4579 , osname: 'Bada'
4580 , bada: t
4581 , version: getFirstMatch(/dolfin\/(\d+(\.\d+)?)/i)
4582 };
4583 }
4584 else if (tizen) {
4585 result = {
4586 name: 'Tizen'
4587 , osname: 'Tizen'
4588 , tizen: t
4589 , version: getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i) || versionIdentifier
4590 };
4591 }
4592 else if (/qupzilla/i.test(ua)) {
4593 result = {
4594 name: 'QupZilla'
4595 , qupzilla: t
4596 , version: getFirstMatch(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i) || versionIdentifier
4597 }
4598 }
4599 else if (/chromium/i.test(ua)) {
4600 result = {
4601 name: 'Chromium'
4602 , chromium: t
4603 , version: getFirstMatch(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i) || versionIdentifier
4604 }
4605 }
4606 else if (/chrome|crios|crmo/i.test(ua)) {
4607 result = {
4608 name: 'Chrome'
4609 , chrome: t
4610 , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
4611 }
4612 }
4613 else if (android) {
4614 result = {
4615 name: 'Android'
4616 , version: versionIdentifier
4617 }
4618 }
4619 else if (/safari|applewebkit/i.test(ua)) {
4620 result = {
4621 name: 'Safari'
4622 , safari: t
4623 }
4624 if (versionIdentifier) {
4625 result.version = versionIdentifier
4626 }
4627 }
4628 else if (iosdevice) {
4629 result = {
4630 name : iosdevice == 'iphone' ? 'iPhone' : iosdevice == 'ipad' ? 'iPad' : 'iPod'
4631 }
4632 // WTF: version is not part of user agent in web apps
4633 if (versionIdentifier) {
4634 result.version = versionIdentifier
4635 }
4636 }
4637 else if(/googlebot/i.test(ua)) {
4638 result = {
4639 name: 'Googlebot'
4640 , googlebot: t
4641 , version: getFirstMatch(/googlebot\/(\d+(\.\d+))/i) || versionIdentifier
4642 }
4643 }
4644 else {
4645 result = {
4646 name: getFirstMatch(/^(.*)\/(.*) /),
4647 version: getSecondMatch(/^(.*)\/(.*) /)
4648 };
4649 }
4650
4651 // set webkit or gecko flag for browsers based on these engines
4652 if (!result.msedge && /(apple)?webkit/i.test(ua)) {
4653 if (/(apple)?webkit\/537\.36/i.test(ua)) {
4654 result.name = result.name || "Blink"
4655 result.blink = t
4656 } else {
4657 result.name = result.name || "Webkit"
4658 result.webkit = t
4659 }
4660 if (!result.version && versionIdentifier) {
4661 result.version = versionIdentifier
4662 }
4663 } else if (!result.opera && /gecko\//i.test(ua)) {
4664 result.name = result.name || "Gecko"
4665 result.gecko = t
4666 result.version = result.version || getFirstMatch(/gecko\/(\d+(\.\d+)?)/i)
4667 }
4668
4669 // set OS flags for platforms that have multiple browsers
4670 if (!result.windowsphone && (android || result.silk)) {
4671 result.android = t
4672 result.osname = 'Android'
4673 } else if (!result.windowsphone && iosdevice) {
4674 result[iosdevice] = t
4675 result.ios = t
4676 result.osname = 'iOS'
4677 } else if (mac) {
4678 result.mac = t
4679 result.osname = 'macOS'
4680 } else if (xbox) {
4681 result.xbox = t
4682 result.osname = 'Xbox'
4683 } else if (windows) {
4684 result.windows = t
4685 result.osname = 'Windows'
4686 } else if (linux) {
4687 result.linux = t
4688 result.osname = 'Linux'
4689 }
4690
4691 function getWindowsVersion (s) {
4692 switch (s) {
4693 case 'NT': return 'NT'
4694 case 'XP': return 'XP'
4695 case 'NT 5.0': return '2000'
4696 case 'NT 5.1': return 'XP'
4697 case 'NT 5.2': return '2003'
4698 case 'NT 6.0': return 'Vista'
4699 case 'NT 6.1': return '7'
4700 case 'NT 6.2': return '8'
4701 case 'NT 6.3': return '8.1'
4702 case 'NT 10.0': return '10'
4703 default: return undefined
4704 }
4705 }
4706
4707 // OS version extraction
4708 var osVersion = '';
4709 if (result.windows) {
4710 osVersion = getWindowsVersion(getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i))
4711 } else if (result.windowsphone) {
4712 osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i);
4713 } else if (result.mac) {
4714 osVersion = getFirstMatch(/Mac OS X (\d+([_\.\s]\d+)*)/i);
4715 osVersion = osVersion.replace(/[_\s]/g, '.');
4716 } else if (iosdevice) {
4717 osVersion = getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i);
4718 osVersion = osVersion.replace(/[_\s]/g, '.');
4719 } else if (android) {
4720 osVersion = getFirstMatch(/android[ \/-](\d+(\.\d+)*)/i);
4721 } else if (result.webos) {
4722 osVersion = getFirstMatch(/(?:web|hpw)os\/(\d+(\.\d+)*)/i);
4723 } else if (result.blackberry) {
4724 osVersion = getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i);
4725 } else if (result.bada) {
4726 osVersion = getFirstMatch(/bada\/(\d+(\.\d+)*)/i);
4727 } else if (result.tizen) {
4728 osVersion = getFirstMatch(/tizen[\/\s](\d+(\.\d+)*)/i);
4729 }
4730 if (osVersion) {
4731 result.osversion = osVersion;
4732 }
4733
4734 // device type extraction
4735 var osMajorVersion = !result.windows && osVersion.split('.')[0];
4736 if (
4737 tablet
4738 || nexusTablet
4739 || iosdevice == 'ipad'
4740 || (android && (osMajorVersion == 3 || (osMajorVersion >= 4 && !mobile)))
4741 || result.silk
4742 ) {
4743 result.tablet = t
4744 } else if (
4745 mobile
4746 || iosdevice == 'iphone'
4747 || iosdevice == 'ipod'
4748 || android
4749 || nexusMobile
4750 || result.blackberry
4751 || result.webos
4752 || result.bada
4753 ) {
4754 result.mobile = t
4755 }
4756
4757 // Graded Browser Support
4758 // http://developer.yahoo.com/yui/articles/gbs
4759 if (result.msedge ||
4760 (result.msie && result.version >= 10) ||
4761 (result.yandexbrowser && result.version >= 15) ||
4762 (result.vivaldi && result.version >= 1.0) ||
4763 (result.chrome && result.version >= 20) ||
4764 (result.samsungBrowser && result.version >= 4) ||
4765 (result.whale && compareVersions([result.version, '1.0']) === 1) ||
4766 (result.mzbrowser && compareVersions([result.version, '6.0']) === 1) ||
4767 (result.focus && compareVersions([result.version, '1.0']) === 1) ||
4768 (result.firefox && result.version >= 20.0) ||
4769 (result.safari && result.version >= 6) ||
4770 (result.opera && result.version >= 10.0) ||
4771 (result.ios && result.osversion && result.osversion.split(".")[0] >= 6) ||
4772 (result.blackberry && result.version >= 10.1)
4773 || (result.chromium && result.version >= 20)
4774 ) {
4775 result.a = t;
4776 }
4777 else if ((result.msie && result.version < 10) ||
4778 (result.chrome && result.version < 20) ||
4779 (result.firefox && result.version < 20.0) ||
4780 (result.safari && result.version < 6) ||
4781 (result.opera && result.version < 10.0) ||
4782 (result.ios && result.osversion && result.osversion.split(".")[0] < 6)
4783 || (result.chromium && result.version < 20)
4784 ) {
4785 result.c = t
4786 } else result.x = t
4787
4788 return result
4789 }
4790
4791 var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent || '' : '')
4792
4793 bowser.test = function (browserList) {
4794 for (var i = 0; i < browserList.length; ++i) {
4795 var browserItem = browserList[i];
4796 if (typeof browserItem=== 'string') {
4797 if (browserItem in bowser) {
4798 return true;
4799 }
4800 }
4801 }
4802 return false;
4803 }
4804
4805 /**
4806 * Get version precisions count
4807 *
4808 * @example
4809 * getVersionPrecision("1.10.3") // 3
4810 *
4811 * @param {string} version
4812 * @return {number}
4813 */
4814 function getVersionPrecision(version) {
4815 return version.split(".").length;
4816 }
4817
4818 /**
4819 * Array::map polyfill
4820 *
4821 * @param {Array} arr
4822 * @param {Function} iterator
4823 * @return {Array}
4824 */
4825 function map(arr, iterator) {
4826 var result = [], i;
4827 if (Array.prototype.map) {
4828 return Array.prototype.map.call(arr, iterator);
4829 }
4830 for (i = 0; i < arr.length; i++) {
4831 result.push(iterator(arr[i]));
4832 }
4833 return result;
4834 }
4835
4836 /**
4837 * Calculate browser version weight
4838 *
4839 * @example
4840 * compareVersions(['1.10.2.1', '1.8.2.1.90']) // 1
4841 * compareVersions(['1.010.2.1', '1.09.2.1.90']); // 1
4842 * compareVersions(['1.10.2.1', '1.10.2.1']); // 0
4843 * compareVersions(['1.10.2.1', '1.0800.2']); // -1
4844 *
4845 * @param {Array<String>} versions versions to compare
4846 * @return {Number} comparison result
4847 */
4848 function compareVersions(versions) {
4849 // 1) get common precision for both versions, for example for "10.0" and "9" it should be 2
4850 var precision = Math.max(getVersionPrecision(versions[0]), getVersionPrecision(versions[1]));
4851 var chunks = map(versions, function (version) {
4852 var delta = precision - getVersionPrecision(version);
4853
4854 // 2) "9" -> "9.0" (for precision = 2)
4855 version = version + new Array(delta + 1).join(".0");
4856
4857 // 3) "9.0" -> ["000000000"", "000000009"]
4858 return map(version.split("."), function (chunk) {
4859 return new Array(20 - chunk.length).join("0") + chunk;
4860 }).reverse();
4861 });
4862
4863 // iterate in reverse order by reversed chunks array
4864 while (--precision >= 0) {
4865 // 4) compare: "000000009" > "000000010" = false (but "9" > "10" = true)
4866 if (chunks[0][precision] > chunks[1][precision]) {
4867 return 1;
4868 }
4869 else if (chunks[0][precision] === chunks[1][precision]) {
4870 if (precision === 0) {
4871 // all version chunks are same
4872 return 0;
4873 }
4874 }
4875 else {
4876 return -1;
4877 }
4878 }
4879 }
4880
4881 /**
4882 * Check if browser is unsupported
4883 *
4884 * @example
4885 * bowser.isUnsupportedBrowser({
4886 * msie: "10",
4887 * firefox: "23",
4888 * chrome: "29",
4889 * safari: "5.1",
4890 * opera: "16",
4891 * phantom: "534"
4892 * });
4893 *
4894 * @param {Object} minVersions map of minimal version to browser
4895 * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
4896 * @param {String} [ua] user agent string
4897 * @return {Boolean}
4898 */
4899 function isUnsupportedBrowser(minVersions, strictMode, ua) {
4900 var _bowser = bowser;
4901
4902 // make strictMode param optional with ua param usage
4903 if (typeof strictMode === 'string') {
4904 ua = strictMode;
4905 strictMode = void(0);
4906 }
4907
4908 if (strictMode === void(0)) {
4909 strictMode = false;
4910 }
4911 if (ua) {
4912 _bowser = detect(ua);
4913 }
4914
4915 var version = "" + _bowser.version;
4916 for (var browser in minVersions) {
4917 if (minVersions.hasOwnProperty(browser)) {
4918 if (_bowser[browser]) {
4919 if (typeof minVersions[browser] !== 'string') {
4920 throw new Error('Browser version in the minVersion map should be a string: ' + browser + ': ' + String(minVersions));
4921 }
4922
4923 // browser version and min supported version.
4924 return compareVersions([version, minVersions[browser]]) < 0;
4925 }
4926 }
4927 }
4928
4929 return strictMode; // not found
4930 }
4931
4932 /**
4933 * Check if browser is supported
4934 *
4935 * @param {Object} minVersions map of minimal version to browser
4936 * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
4937 * @param {String} [ua] user agent string
4938 * @return {Boolean}
4939 */
4940 function check(minVersions, strictMode, ua) {
4941 return !isUnsupportedBrowser(minVersions, strictMode, ua);
4942 }
4943
4944 bowser.isUnsupportedBrowser = isUnsupportedBrowser;
4945 bowser.compareVersions = compareVersions;
4946 bowser.check = check;
4947
4948 /*
4949 * Set our detect method to the main bowser object so we can
4950 * reuse it to test other user agents.
4951 * This is needed to implement future tests.
4952 */
4953 bowser._detect = detect;
4954
4955 /*
4956 * Set our detect public method to the main bowser object
4957 * This is needed to implement bowser in server side
4958 */
4959 bowser.detect = detect;
4960 return bowser
4961});
4962
4963},{}],58:[function(require,module,exports){
4964
4965},{}],59:[function(require,module,exports){
4966// Copyright Joyent, Inc. and other Node contributors.
4967//
4968// Permission is hereby granted, free of charge, to any person obtaining a
4969// copy of this software and associated documentation files (the
4970// "Software"), to deal in the Software without restriction, including
4971// without limitation the rights to use, copy, modify, merge, publish,
4972// distribute, sublicense, and/or sell copies of the Software, and to permit
4973// persons to whom the Software is furnished to do so, subject to the
4974// following conditions:
4975//
4976// The above copyright notice and this permission notice shall be included
4977// in all copies or substantial portions of the Software.
4978//
4979// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
4980// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4981// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
4982// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
4983// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
4984// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
4985// USE OR OTHER DEALINGS IN THE SOFTWARE.
4986
4987var Buffer = require('buffer').Buffer;
4988
4989var isBufferEncoding = Buffer.isEncoding
4990 || function(encoding) {
4991 switch (encoding && encoding.toLowerCase()) {
4992 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;
4993 default: return false;
4994 }
4995 }
4996
4997
4998function assertEncoding(encoding) {
4999 if (encoding && !isBufferEncoding(encoding)) {
5000 throw new Error('Unknown encoding: ' + encoding);
5001 }
5002}
5003
5004// StringDecoder provides an interface for efficiently splitting a series of
5005// buffers into a series of JS strings without breaking apart multi-byte
5006// characters. CESU-8 is handled as part of the UTF-8 encoding.
5007//
5008// @TODO Handling all encodings inside a single object makes it very difficult
5009// to reason about this code, so it should be split up in the future.
5010// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
5011// points as used by CESU-8.
5012var StringDecoder = exports.StringDecoder = function(encoding) {
5013 this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
5014 assertEncoding(encoding);
5015 switch (this.encoding) {
5016 case 'utf8':
5017 // CESU-8 represents each of Surrogate Pair by 3-bytes
5018 this.surrogateSize = 3;
5019 break;
5020 case 'ucs2':
5021 case 'utf16le':
5022 // UTF-16 represents each of Surrogate Pair by 2-bytes
5023 this.surrogateSize = 2;
5024 this.detectIncompleteChar = utf16DetectIncompleteChar;
5025 break;
5026 case 'base64':
5027 // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
5028 this.surrogateSize = 3;
5029 this.detectIncompleteChar = base64DetectIncompleteChar;
5030 break;
5031 default:
5032 this.write = passThroughWrite;
5033 return;
5034 }
5035
5036 // Enough space to store all bytes of a single character. UTF-8 needs 4
5037 // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
5038 this.charBuffer = new Buffer(6);
5039 // Number of bytes received for the current incomplete multi-byte character.
5040 this.charReceived = 0;
5041 // Number of bytes expected for the current incomplete multi-byte character.
5042 this.charLength = 0;
5043};
5044
5045
5046// write decodes the given buffer and returns it as JS string that is
5047// guaranteed to not contain any partial multi-byte characters. Any partial
5048// character found at the end of the buffer is buffered up, and will be
5049// returned when calling write again with the remaining bytes.
5050//
5051// Note: Converting a Buffer containing an orphan surrogate to a String
5052// currently works, but converting a String to a Buffer (via `new Buffer`, or
5053// Buffer#write) will replace incomplete surrogates with the unicode
5054// replacement character. See https://codereview.chromium.org/121173009/ .
5055StringDecoder.prototype.write = function(buffer) {
5056 var charStr = '';
5057 // if our last write ended with an incomplete multibyte character
5058 while (this.charLength) {
5059 // determine how many remaining bytes this buffer has to offer for this char
5060 var available = (buffer.length >= this.charLength - this.charReceived) ?
5061 this.charLength - this.charReceived :
5062 buffer.length;
5063
5064 // add the new bytes to the char buffer
5065 buffer.copy(this.charBuffer, this.charReceived, 0, available);
5066 this.charReceived += available;
5067
5068 if (this.charReceived < this.charLength) {
5069 // still not enough chars in this buffer? wait for more ...
5070 return '';
5071 }
5072
5073 // remove bytes belonging to the current character from the buffer
5074 buffer = buffer.slice(available, buffer.length);
5075
5076 // get the character that was split
5077 charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
5078
5079 // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
5080 var charCode = charStr.charCodeAt(charStr.length - 1);
5081 if (charCode >= 0xD800 && charCode <= 0xDBFF) {
5082 this.charLength += this.surrogateSize;
5083 charStr = '';
5084 continue;
5085 }
5086 this.charReceived = this.charLength = 0;
5087
5088 // if there are no more bytes in this buffer, just emit our char
5089 if (buffer.length === 0) {
5090 return charStr;
5091 }
5092 break;
5093 }
5094
5095 // determine and set charLength / charReceived
5096 this.detectIncompleteChar(buffer);
5097
5098 var end = buffer.length;
5099 if (this.charLength) {
5100 // buffer the incomplete character bytes we got
5101 buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
5102 end -= this.charReceived;
5103 }
5104
5105 charStr += buffer.toString(this.encoding, 0, end);
5106
5107 var end = charStr.length - 1;
5108 var charCode = charStr.charCodeAt(end);
5109 // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
5110 if (charCode >= 0xD800 && charCode <= 0xDBFF) {
5111 var size = this.surrogateSize;
5112 this.charLength += size;
5113 this.charReceived += size;
5114 this.charBuffer.copy(this.charBuffer, size, 0, size);
5115 buffer.copy(this.charBuffer, 0, 0, size);
5116 return charStr.substring(0, end);
5117 }
5118
5119 // or just emit the charStr
5120 return charStr;
5121};
5122
5123// detectIncompleteChar determines if there is an incomplete UTF-8 character at
5124// the end of the given buffer. If so, it sets this.charLength to the byte
5125// length that character, and sets this.charReceived to the number of bytes
5126// that are available for this character.
5127StringDecoder.prototype.detectIncompleteChar = function(buffer) {
5128 // determine how many bytes we have to check at the end of this buffer
5129 var i = (buffer.length >= 3) ? 3 : buffer.length;
5130
5131 // Figure out if one of the last i bytes of our buffer announces an
5132 // incomplete char.
5133 for (; i > 0; i--) {
5134 var c = buffer[buffer.length - i];
5135
5136 // See http://en.wikipedia.org/wiki/UTF-8#Description
5137
5138 // 110XXXXX
5139 if (i == 1 && c >> 5 == 0x06) {
5140 this.charLength = 2;
5141 break;
5142 }
5143
5144 // 1110XXXX
5145 if (i <= 2 && c >> 4 == 0x0E) {
5146 this.charLength = 3;
5147 break;
5148 }
5149
5150 // 11110XXX
5151 if (i <= 3 && c >> 3 == 0x1E) {
5152 this.charLength = 4;
5153 break;
5154 }
5155 }
5156 this.charReceived = i;
5157};
5158
5159StringDecoder.prototype.end = function(buffer) {
5160 var res = '';
5161 if (buffer && buffer.length)
5162 res = this.write(buffer);
5163
5164 if (this.charReceived) {
5165 var cr = this.charReceived;
5166 var buf = this.charBuffer;
5167 var enc = this.encoding;
5168 res += buf.slice(0, cr).toString(enc);
5169 }
5170
5171 return res;
5172};
5173
5174function passThroughWrite(buffer) {
5175 return buffer.toString(this.encoding);
5176}
5177
5178function utf16DetectIncompleteChar(buffer) {
5179 this.charReceived = buffer.length % 2;
5180 this.charLength = this.charReceived ? 2 : 0;
5181}
5182
5183function base64DetectIncompleteChar(buffer) {
5184 this.charReceived = buffer.length % 3;
5185 this.charLength = this.charReceived ? 3 : 0;
5186}
5187
5188},{"buffer":60}],60:[function(require,module,exports){
5189(function (global){
5190/*!
5191 * The buffer module from node.js, for the browser.
5192 *
5193 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
5194 * @license MIT
5195 */
5196/* eslint-disable no-proto */
5197
5198'use strict'
5199
5200var base64 = require('base64-js')
5201var ieee754 = require('ieee754')
5202var isArray = require('isarray')
5203
5204exports.Buffer = Buffer
5205exports.SlowBuffer = SlowBuffer
5206exports.INSPECT_MAX_BYTES = 50
5207
5208/**
5209 * If `Buffer.TYPED_ARRAY_SUPPORT`:
5210 * === true Use Uint8Array implementation (fastest)
5211 * === false Use Object implementation (most compatible, even IE6)
5212 *
5213 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
5214 * Opera 11.6+, iOS 4.2+.
5215 *
5216 * Due to various browser bugs, sometimes the Object implementation will be used even
5217 * when the browser supports typed arrays.
5218 *
5219 * Note:
5220 *
5221 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
5222 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
5223 *
5224 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
5225 *
5226 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
5227 * incorrect length in some situations.
5228
5229 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
5230 * get the Object implementation, which is slower but behaves correctly.
5231 */
5232Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
5233 ? global.TYPED_ARRAY_SUPPORT
5234 : typedArraySupport()
5235
5236/*
5237 * Export kMaxLength after typed array support is determined.
5238 */
5239exports.kMaxLength = kMaxLength()
5240
5241function typedArraySupport () {
5242 try {
5243 var arr = new Uint8Array(1)
5244 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
5245 return arr.foo() === 42 && // typed array instances can be augmented
5246 typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
5247 arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
5248 } catch (e) {
5249 return false
5250 }
5251}
5252
5253function kMaxLength () {
5254 return Buffer.TYPED_ARRAY_SUPPORT
5255 ? 0x7fffffff
5256 : 0x3fffffff
5257}
5258
5259function createBuffer (that, length) {
5260 if (kMaxLength() < length) {
5261 throw new RangeError('Invalid typed array length')
5262 }
5263 if (Buffer.TYPED_ARRAY_SUPPORT) {
5264 // Return an augmented `Uint8Array` instance, for best performance
5265 that = new Uint8Array(length)
5266 that.__proto__ = Buffer.prototype
5267 } else {
5268 // Fallback: Return an object instance of the Buffer class
5269 if (that === null) {
5270 that = new Buffer(length)
5271 }
5272 that.length = length
5273 }
5274
5275 return that
5276}
5277
5278/**
5279 * The Buffer constructor returns instances of `Uint8Array` that have their
5280 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
5281 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
5282 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
5283 * returns a single octet.
5284 *
5285 * The `Uint8Array` prototype remains unmodified.
5286 */
5287
5288function Buffer (arg, encodingOrOffset, length) {
5289 if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
5290 return new Buffer(arg, encodingOrOffset, length)
5291 }
5292
5293 // Common case.
5294 if (typeof arg === 'number') {
5295 if (typeof encodingOrOffset === 'string') {
5296 throw new Error(
5297 'If encoding is specified then the first argument must be a string'
5298 )
5299 }
5300 return allocUnsafe(this, arg)
5301 }
5302 return from(this, arg, encodingOrOffset, length)
5303}
5304
5305Buffer.poolSize = 8192 // not used by this implementation
5306
5307// TODO: Legacy, not needed anymore. Remove in next major version.
5308Buffer._augment = function (arr) {
5309 arr.__proto__ = Buffer.prototype
5310 return arr
5311}
5312
5313function from (that, value, encodingOrOffset, length) {
5314 if (typeof value === 'number') {
5315 throw new TypeError('"value" argument must not be a number')
5316 }
5317
5318 if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
5319 return fromArrayBuffer(that, value, encodingOrOffset, length)
5320 }
5321
5322 if (typeof value === 'string') {
5323 return fromString(that, value, encodingOrOffset)
5324 }
5325
5326 return fromObject(that, value)
5327}
5328
5329/**
5330 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
5331 * if value is a number.
5332 * Buffer.from(str[, encoding])
5333 * Buffer.from(array)
5334 * Buffer.from(buffer)
5335 * Buffer.from(arrayBuffer[, byteOffset[, length]])
5336 **/
5337Buffer.from = function (value, encodingOrOffset, length) {
5338 return from(null, value, encodingOrOffset, length)
5339}
5340
5341if (Buffer.TYPED_ARRAY_SUPPORT) {
5342 Buffer.prototype.__proto__ = Uint8Array.prototype
5343 Buffer.__proto__ = Uint8Array
5344 if (typeof Symbol !== 'undefined' && Symbol.species &&
5345 Buffer[Symbol.species] === Buffer) {
5346 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
5347 Object.defineProperty(Buffer, Symbol.species, {
5348 value: null,
5349 configurable: true
5350 })
5351 }
5352}
5353
5354function assertSize (size) {
5355 if (typeof size !== 'number') {
5356 throw new TypeError('"size" argument must be a number')
5357 } else if (size < 0) {
5358 throw new RangeError('"size" argument must not be negative')
5359 }
5360}
5361
5362function alloc (that, size, fill, encoding) {
5363 assertSize(size)
5364 if (size <= 0) {
5365 return createBuffer(that, size)
5366 }
5367 if (fill !== undefined) {
5368 // Only pay attention to encoding if it's a string. This
5369 // prevents accidentally sending in a number that would
5370 // be interpretted as a start offset.
5371 return typeof encoding === 'string'
5372 ? createBuffer(that, size).fill(fill, encoding)
5373 : createBuffer(that, size).fill(fill)
5374 }
5375 return createBuffer(that, size)
5376}
5377
5378/**
5379 * Creates a new filled Buffer instance.
5380 * alloc(size[, fill[, encoding]])
5381 **/
5382Buffer.alloc = function (size, fill, encoding) {
5383 return alloc(null, size, fill, encoding)
5384}
5385
5386function allocUnsafe (that, size) {
5387 assertSize(size)
5388 that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
5389 if (!Buffer.TYPED_ARRAY_SUPPORT) {
5390 for (var i = 0; i < size; ++i) {
5391 that[i] = 0
5392 }
5393 }
5394 return that
5395}
5396
5397/**
5398 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
5399 * */
5400Buffer.allocUnsafe = function (size) {
5401 return allocUnsafe(null, size)
5402}
5403/**
5404 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
5405 */
5406Buffer.allocUnsafeSlow = function (size) {
5407 return allocUnsafe(null, size)
5408}
5409
5410function fromString (that, string, encoding) {
5411 if (typeof encoding !== 'string' || encoding === '') {
5412 encoding = 'utf8'
5413 }
5414
5415 if (!Buffer.isEncoding(encoding)) {
5416 throw new TypeError('"encoding" must be a valid string encoding')
5417 }
5418
5419 var length = byteLength(string, encoding) | 0
5420 that = createBuffer(that, length)
5421
5422 var actual = that.write(string, encoding)
5423
5424 if (actual !== length) {
5425 // Writing a hex string, for example, that contains invalid characters will
5426 // cause everything after the first invalid character to be ignored. (e.g.
5427 // 'abxxcd' will be treated as 'ab')
5428 that = that.slice(0, actual)
5429 }
5430
5431 return that
5432}
5433
5434function fromArrayLike (that, array) {
5435 var length = array.length < 0 ? 0 : checked(array.length) | 0
5436 that = createBuffer(that, length)
5437 for (var i = 0; i < length; i += 1) {
5438 that[i] = array[i] & 255
5439 }
5440 return that
5441}
5442
5443function fromArrayBuffer (that, array, byteOffset, length) {
5444 array.byteLength // this throws if `array` is not a valid ArrayBuffer
5445
5446 if (byteOffset < 0 || array.byteLength < byteOffset) {
5447 throw new RangeError('\'offset\' is out of bounds')
5448 }
5449
5450 if (array.byteLength < byteOffset + (length || 0)) {
5451 throw new RangeError('\'length\' is out of bounds')
5452 }
5453
5454 if (byteOffset === undefined && length === undefined) {
5455 array = new Uint8Array(array)
5456 } else if (length === undefined) {
5457 array = new Uint8Array(array, byteOffset)
5458 } else {
5459 array = new Uint8Array(array, byteOffset, length)
5460 }
5461
5462 if (Buffer.TYPED_ARRAY_SUPPORT) {
5463 // Return an augmented `Uint8Array` instance, for best performance
5464 that = array
5465 that.__proto__ = Buffer.prototype
5466 } else {
5467 // Fallback: Return an object instance of the Buffer class
5468 that = fromArrayLike(that, array)
5469 }
5470 return that
5471}
5472
5473function fromObject (that, obj) {
5474 if (Buffer.isBuffer(obj)) {
5475 var len = checked(obj.length) | 0
5476 that = createBuffer(that, len)
5477
5478 if (that.length === 0) {
5479 return that
5480 }
5481
5482 obj.copy(that, 0, 0, len)
5483 return that
5484 }
5485
5486 if (obj) {
5487 if ((typeof ArrayBuffer !== 'undefined' &&
5488 obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
5489 if (typeof obj.length !== 'number' || isnan(obj.length)) {
5490 return createBuffer(that, 0)
5491 }
5492 return fromArrayLike(that, obj)
5493 }
5494
5495 if (obj.type === 'Buffer' && isArray(obj.data)) {
5496 return fromArrayLike(that, obj.data)
5497 }
5498 }
5499
5500 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
5501}
5502
5503function checked (length) {
5504 // Note: cannot use `length < kMaxLength()` here because that fails when
5505 // length is NaN (which is otherwise coerced to zero.)
5506 if (length >= kMaxLength()) {
5507 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
5508 'size: 0x' + kMaxLength().toString(16) + ' bytes')
5509 }
5510 return length | 0
5511}
5512
5513function SlowBuffer (length) {
5514 if (+length != length) { // eslint-disable-line eqeqeq
5515 length = 0
5516 }
5517 return Buffer.alloc(+length)
5518}
5519
5520Buffer.isBuffer = function isBuffer (b) {
5521 return !!(b != null && b._isBuffer)
5522}
5523
5524Buffer.compare = function compare (a, b) {
5525 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
5526 throw new TypeError('Arguments must be Buffers')
5527 }
5528
5529 if (a === b) return 0
5530
5531 var x = a.length
5532 var y = b.length
5533
5534 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
5535 if (a[i] !== b[i]) {
5536 x = a[i]
5537 y = b[i]
5538 break
5539 }
5540 }
5541
5542 if (x < y) return -1
5543 if (y < x) return 1
5544 return 0
5545}
5546
5547Buffer.isEncoding = function isEncoding (encoding) {
5548 switch (String(encoding).toLowerCase()) {
5549 case 'hex':
5550 case 'utf8':
5551 case 'utf-8':
5552 case 'ascii':
5553 case 'latin1':
5554 case 'binary':
5555 case 'base64':
5556 case 'ucs2':
5557 case 'ucs-2':
5558 case 'utf16le':
5559 case 'utf-16le':
5560 return true
5561 default:
5562 return false
5563 }
5564}
5565
5566Buffer.concat = function concat (list, length) {
5567 if (!isArray(list)) {
5568 throw new TypeError('"list" argument must be an Array of Buffers')
5569 }
5570
5571 if (list.length === 0) {
5572 return Buffer.alloc(0)
5573 }
5574
5575 var i
5576 if (length === undefined) {
5577 length = 0
5578 for (i = 0; i < list.length; ++i) {
5579 length += list[i].length
5580 }
5581 }
5582
5583 var buffer = Buffer.allocUnsafe(length)
5584 var pos = 0
5585 for (i = 0; i < list.length; ++i) {
5586 var buf = list[i]
5587 if (!Buffer.isBuffer(buf)) {
5588 throw new TypeError('"list" argument must be an Array of Buffers')
5589 }
5590 buf.copy(buffer, pos)
5591 pos += buf.length
5592 }
5593 return buffer
5594}
5595
5596function byteLength (string, encoding) {
5597 if (Buffer.isBuffer(string)) {
5598 return string.length
5599 }
5600 if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
5601 (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
5602 return string.byteLength
5603 }
5604 if (typeof string !== 'string') {
5605 string = '' + string
5606 }
5607
5608 var len = string.length
5609 if (len === 0) return 0
5610
5611 // Use a for loop to avoid recursion
5612 var loweredCase = false
5613 for (;;) {
5614 switch (encoding) {
5615 case 'ascii':
5616 case 'latin1':
5617 case 'binary':
5618 return len
5619 case 'utf8':
5620 case 'utf-8':
5621 case undefined:
5622 return utf8ToBytes(string).length
5623 case 'ucs2':
5624 case 'ucs-2':
5625 case 'utf16le':
5626 case 'utf-16le':
5627 return len * 2
5628 case 'hex':
5629 return len >>> 1
5630 case 'base64':
5631 return base64ToBytes(string).length
5632 default:
5633 if (loweredCase) return utf8ToBytes(string).length // assume utf8
5634 encoding = ('' + encoding).toLowerCase()
5635 loweredCase = true
5636 }
5637 }
5638}
5639Buffer.byteLength = byteLength
5640
5641function slowToString (encoding, start, end) {
5642 var loweredCase = false
5643
5644 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
5645 // property of a typed array.
5646
5647 // This behaves neither like String nor Uint8Array in that we set start/end
5648 // to their upper/lower bounds if the value passed is out of range.
5649 // undefined is handled specially as per ECMA-262 6th Edition,
5650 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
5651 if (start === undefined || start < 0) {
5652 start = 0
5653 }
5654 // Return early if start > this.length. Done here to prevent potential uint32
5655 // coercion fail below.
5656 if (start > this.length) {
5657 return ''
5658 }
5659
5660 if (end === undefined || end > this.length) {
5661 end = this.length
5662 }
5663
5664 if (end <= 0) {
5665 return ''
5666 }
5667
5668 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
5669 end >>>= 0
5670 start >>>= 0
5671
5672 if (end <= start) {
5673 return ''
5674 }
5675
5676 if (!encoding) encoding = 'utf8'
5677
5678 while (true) {
5679 switch (encoding) {
5680 case 'hex':
5681 return hexSlice(this, start, end)
5682
5683 case 'utf8':
5684 case 'utf-8':
5685 return utf8Slice(this, start, end)
5686
5687 case 'ascii':
5688 return asciiSlice(this, start, end)
5689
5690 case 'latin1':
5691 case 'binary':
5692 return latin1Slice(this, start, end)
5693
5694 case 'base64':
5695 return base64Slice(this, start, end)
5696
5697 case 'ucs2':
5698 case 'ucs-2':
5699 case 'utf16le':
5700 case 'utf-16le':
5701 return utf16leSlice(this, start, end)
5702
5703 default:
5704 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
5705 encoding = (encoding + '').toLowerCase()
5706 loweredCase = true
5707 }
5708 }
5709}
5710
5711// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
5712// Buffer instances.
5713Buffer.prototype._isBuffer = true
5714
5715function swap (b, n, m) {
5716 var i = b[n]
5717 b[n] = b[m]
5718 b[m] = i
5719}
5720
5721Buffer.prototype.swap16 = function swap16 () {
5722 var len = this.length
5723 if (len % 2 !== 0) {
5724 throw new RangeError('Buffer size must be a multiple of 16-bits')
5725 }
5726 for (var i = 0; i < len; i += 2) {
5727 swap(this, i, i + 1)
5728 }
5729 return this
5730}
5731
5732Buffer.prototype.swap32 = function swap32 () {
5733 var len = this.length
5734 if (len % 4 !== 0) {
5735 throw new RangeError('Buffer size must be a multiple of 32-bits')
5736 }
5737 for (var i = 0; i < len; i += 4) {
5738 swap(this, i, i + 3)
5739 swap(this, i + 1, i + 2)
5740 }
5741 return this
5742}
5743
5744Buffer.prototype.swap64 = function swap64 () {
5745 var len = this.length
5746 if (len % 8 !== 0) {
5747 throw new RangeError('Buffer size must be a multiple of 64-bits')
5748 }
5749 for (var i = 0; i < len; i += 8) {
5750 swap(this, i, i + 7)
5751 swap(this, i + 1, i + 6)
5752 swap(this, i + 2, i + 5)
5753 swap(this, i + 3, i + 4)
5754 }
5755 return this
5756}
5757
5758Buffer.prototype.toString = function toString () {
5759 var length = this.length | 0
5760 if (length === 0) return ''
5761 if (arguments.length === 0) return utf8Slice(this, 0, length)
5762 return slowToString.apply(this, arguments)
5763}
5764
5765Buffer.prototype.equals = function equals (b) {
5766 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
5767 if (this === b) return true
5768 return Buffer.compare(this, b) === 0
5769}
5770
5771Buffer.prototype.inspect = function inspect () {
5772 var str = ''
5773 var max = exports.INSPECT_MAX_BYTES
5774 if (this.length > 0) {
5775 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
5776 if (this.length > max) str += ' ... '
5777 }
5778 return '<Buffer ' + str + '>'
5779}
5780
5781Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
5782 if (!Buffer.isBuffer(target)) {
5783 throw new TypeError('Argument must be a Buffer')
5784 }
5785
5786 if (start === undefined) {
5787 start = 0
5788 }
5789 if (end === undefined) {
5790 end = target ? target.length : 0
5791 }
5792 if (thisStart === undefined) {
5793 thisStart = 0
5794 }
5795 if (thisEnd === undefined) {
5796 thisEnd = this.length
5797 }
5798
5799 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
5800 throw new RangeError('out of range index')
5801 }
5802
5803 if (thisStart >= thisEnd && start >= end) {
5804 return 0
5805 }
5806 if (thisStart >= thisEnd) {
5807 return -1
5808 }
5809 if (start >= end) {
5810 return 1
5811 }
5812
5813 start >>>= 0
5814 end >>>= 0
5815 thisStart >>>= 0
5816 thisEnd >>>= 0
5817
5818 if (this === target) return 0
5819
5820 var x = thisEnd - thisStart
5821 var y = end - start
5822 var len = Math.min(x, y)
5823
5824 var thisCopy = this.slice(thisStart, thisEnd)
5825 var targetCopy = target.slice(start, end)
5826
5827 for (var i = 0; i < len; ++i) {
5828 if (thisCopy[i] !== targetCopy[i]) {
5829 x = thisCopy[i]
5830 y = targetCopy[i]
5831 break
5832 }
5833 }
5834
5835 if (x < y) return -1
5836 if (y < x) return 1
5837 return 0
5838}
5839
5840// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
5841// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
5842//
5843// Arguments:
5844// - buffer - a Buffer to search
5845// - val - a string, Buffer, or number
5846// - byteOffset - an index into `buffer`; will be clamped to an int32
5847// - encoding - an optional encoding, relevant is val is a string
5848// - dir - true for indexOf, false for lastIndexOf
5849function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
5850 // Empty buffer means no match
5851 if (buffer.length === 0) return -1
5852
5853 // Normalize byteOffset
5854 if (typeof byteOffset === 'string') {
5855 encoding = byteOffset
5856 byteOffset = 0
5857 } else if (byteOffset > 0x7fffffff) {
5858 byteOffset = 0x7fffffff
5859 } else if (byteOffset < -0x80000000) {
5860 byteOffset = -0x80000000
5861 }
5862 byteOffset = +byteOffset // Coerce to Number.
5863 if (isNaN(byteOffset)) {
5864 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
5865 byteOffset = dir ? 0 : (buffer.length - 1)
5866 }
5867
5868 // Normalize byteOffset: negative offsets start from the end of the buffer
5869 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
5870 if (byteOffset >= buffer.length) {
5871 if (dir) return -1
5872 else byteOffset = buffer.length - 1
5873 } else if (byteOffset < 0) {
5874 if (dir) byteOffset = 0
5875 else return -1
5876 }
5877
5878 // Normalize val
5879 if (typeof val === 'string') {
5880 val = Buffer.from(val, encoding)
5881 }
5882
5883 // Finally, search either indexOf (if dir is true) or lastIndexOf
5884 if (Buffer.isBuffer(val)) {
5885 // Special case: looking for empty string/buffer always fails
5886 if (val.length === 0) {
5887 return -1
5888 }
5889 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
5890 } else if (typeof val === 'number') {
5891 val = val & 0xFF // Search for a byte value [0-255]
5892 if (Buffer.TYPED_ARRAY_SUPPORT &&
5893 typeof Uint8Array.prototype.indexOf === 'function') {
5894 if (dir) {
5895 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
5896 } else {
5897 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
5898 }
5899 }
5900 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
5901 }
5902
5903 throw new TypeError('val must be string, number or Buffer')
5904}
5905
5906function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
5907 var indexSize = 1
5908 var arrLength = arr.length
5909 var valLength = val.length
5910
5911 if (encoding !== undefined) {
5912 encoding = String(encoding).toLowerCase()
5913 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
5914 encoding === 'utf16le' || encoding === 'utf-16le') {
5915 if (arr.length < 2 || val.length < 2) {
5916 return -1
5917 }
5918 indexSize = 2
5919 arrLength /= 2
5920 valLength /= 2
5921 byteOffset /= 2
5922 }
5923 }
5924
5925 function read (buf, i) {
5926 if (indexSize === 1) {
5927 return buf[i]
5928 } else {
5929 return buf.readUInt16BE(i * indexSize)
5930 }
5931 }
5932
5933 var i
5934 if (dir) {
5935 var foundIndex = -1
5936 for (i = byteOffset; i < arrLength; i++) {
5937 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
5938 if (foundIndex === -1) foundIndex = i
5939 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
5940 } else {
5941 if (foundIndex !== -1) i -= i - foundIndex
5942 foundIndex = -1
5943 }
5944 }
5945 } else {
5946 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
5947 for (i = byteOffset; i >= 0; i--) {
5948 var found = true
5949 for (var j = 0; j < valLength; j++) {
5950 if (read(arr, i + j) !== read(val, j)) {
5951 found = false
5952 break
5953 }
5954 }
5955 if (found) return i
5956 }
5957 }
5958
5959 return -1
5960}
5961
5962Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
5963 return this.indexOf(val, byteOffset, encoding) !== -1
5964}
5965
5966Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
5967 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
5968}
5969
5970Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
5971 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
5972}
5973
5974function hexWrite (buf, string, offset, length) {
5975 offset = Number(offset) || 0
5976 var remaining = buf.length - offset
5977 if (!length) {
5978 length = remaining
5979 } else {
5980 length = Number(length)
5981 if (length > remaining) {
5982 length = remaining
5983 }
5984 }
5985
5986 // must be an even number of digits
5987 var strLen = string.length
5988 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
5989
5990 if (length > strLen / 2) {
5991 length = strLen / 2
5992 }
5993 for (var i = 0; i < length; ++i) {
5994 var parsed = parseInt(string.substr(i * 2, 2), 16)
5995 if (isNaN(parsed)) return i
5996 buf[offset + i] = parsed
5997 }
5998 return i
5999}
6000
6001function utf8Write (buf, string, offset, length) {
6002 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
6003}
6004
6005function asciiWrite (buf, string, offset, length) {
6006 return blitBuffer(asciiToBytes(string), buf, offset, length)
6007}
6008
6009function latin1Write (buf, string, offset, length) {
6010 return asciiWrite(buf, string, offset, length)
6011}
6012
6013function base64Write (buf, string, offset, length) {
6014 return blitBuffer(base64ToBytes(string), buf, offset, length)
6015}
6016
6017function ucs2Write (buf, string, offset, length) {
6018 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
6019}
6020
6021Buffer.prototype.write = function write (string, offset, length, encoding) {
6022 // Buffer#write(string)
6023 if (offset === undefined) {
6024 encoding = 'utf8'
6025 length = this.length
6026 offset = 0
6027 // Buffer#write(string, encoding)
6028 } else if (length === undefined && typeof offset === 'string') {
6029 encoding = offset
6030 length = this.length
6031 offset = 0
6032 // Buffer#write(string, offset[, length][, encoding])
6033 } else if (isFinite(offset)) {
6034 offset = offset | 0
6035 if (isFinite(length)) {
6036 length = length | 0
6037 if (encoding === undefined) encoding = 'utf8'
6038 } else {
6039 encoding = length
6040 length = undefined
6041 }
6042 // legacy write(string, encoding, offset, length) - remove in v0.13
6043 } else {
6044 throw new Error(
6045 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
6046 )
6047 }
6048
6049 var remaining = this.length - offset
6050 if (length === undefined || length > remaining) length = remaining
6051
6052 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
6053 throw new RangeError('Attempt to write outside buffer bounds')
6054 }
6055
6056 if (!encoding) encoding = 'utf8'
6057
6058 var loweredCase = false
6059 for (;;) {
6060 switch (encoding) {
6061 case 'hex':
6062 return hexWrite(this, string, offset, length)
6063
6064 case 'utf8':
6065 case 'utf-8':
6066 return utf8Write(this, string, offset, length)
6067
6068 case 'ascii':
6069 return asciiWrite(this, string, offset, length)
6070
6071 case 'latin1':
6072 case 'binary':
6073 return latin1Write(this, string, offset, length)
6074
6075 case 'base64':
6076 // Warning: maxLength not taken into account in base64Write
6077 return base64Write(this, string, offset, length)
6078
6079 case 'ucs2':
6080 case 'ucs-2':
6081 case 'utf16le':
6082 case 'utf-16le':
6083 return ucs2Write(this, string, offset, length)
6084
6085 default:
6086 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
6087 encoding = ('' + encoding).toLowerCase()
6088 loweredCase = true
6089 }
6090 }
6091}
6092
6093Buffer.prototype.toJSON = function toJSON () {
6094 return {
6095 type: 'Buffer',
6096 data: Array.prototype.slice.call(this._arr || this, 0)
6097 }
6098}
6099
6100function base64Slice (buf, start, end) {
6101 if (start === 0 && end === buf.length) {
6102 return base64.fromByteArray(buf)
6103 } else {
6104 return base64.fromByteArray(buf.slice(start, end))
6105 }
6106}
6107
6108function utf8Slice (buf, start, end) {
6109 end = Math.min(buf.length, end)
6110 var res = []
6111
6112 var i = start
6113 while (i < end) {
6114 var firstByte = buf[i]
6115 var codePoint = null
6116 var bytesPerSequence = (firstByte > 0xEF) ? 4
6117 : (firstByte > 0xDF) ? 3
6118 : (firstByte > 0xBF) ? 2
6119 : 1
6120
6121 if (i + bytesPerSequence <= end) {
6122 var secondByte, thirdByte, fourthByte, tempCodePoint
6123
6124 switch (bytesPerSequence) {
6125 case 1:
6126 if (firstByte < 0x80) {
6127 codePoint = firstByte
6128 }
6129 break
6130 case 2:
6131 secondByte = buf[i + 1]
6132 if ((secondByte & 0xC0) === 0x80) {
6133 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
6134 if (tempCodePoint > 0x7F) {
6135 codePoint = tempCodePoint
6136 }
6137 }
6138 break
6139 case 3:
6140 secondByte = buf[i + 1]
6141 thirdByte = buf[i + 2]
6142 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
6143 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
6144 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
6145 codePoint = tempCodePoint
6146 }
6147 }
6148 break
6149 case 4:
6150 secondByte = buf[i + 1]
6151 thirdByte = buf[i + 2]
6152 fourthByte = buf[i + 3]
6153 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
6154 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
6155 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
6156 codePoint = tempCodePoint
6157 }
6158 }
6159 }
6160 }
6161
6162 if (codePoint === null) {
6163 // we did not generate a valid codePoint so insert a
6164 // replacement char (U+FFFD) and advance only 1 byte
6165 codePoint = 0xFFFD
6166 bytesPerSequence = 1
6167 } else if (codePoint > 0xFFFF) {
6168 // encode to utf16 (surrogate pair dance)
6169 codePoint -= 0x10000
6170 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
6171 codePoint = 0xDC00 | codePoint & 0x3FF
6172 }
6173
6174 res.push(codePoint)
6175 i += bytesPerSequence
6176 }
6177
6178 return decodeCodePointsArray(res)
6179}
6180
6181// Based on http://stackoverflow.com/a/22747272/680742, the browser with
6182// the lowest limit is Chrome, with 0x10000 args.
6183// We go 1 magnitude less, for safety
6184var MAX_ARGUMENTS_LENGTH = 0x1000
6185
6186function decodeCodePointsArray (codePoints) {
6187 var len = codePoints.length
6188 if (len <= MAX_ARGUMENTS_LENGTH) {
6189 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
6190 }
6191
6192 // Decode in chunks to avoid "call stack size exceeded".
6193 var res = ''
6194 var i = 0
6195 while (i < len) {
6196 res += String.fromCharCode.apply(
6197 String,
6198 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
6199 )
6200 }
6201 return res
6202}
6203
6204function asciiSlice (buf, start, end) {
6205 var ret = ''
6206 end = Math.min(buf.length, end)
6207
6208 for (var i = start; i < end; ++i) {
6209 ret += String.fromCharCode(buf[i] & 0x7F)
6210 }
6211 return ret
6212}
6213
6214function latin1Slice (buf, start, end) {
6215 var ret = ''
6216 end = Math.min(buf.length, end)
6217
6218 for (var i = start; i < end; ++i) {
6219 ret += String.fromCharCode(buf[i])
6220 }
6221 return ret
6222}
6223
6224function hexSlice (buf, start, end) {
6225 var len = buf.length
6226
6227 if (!start || start < 0) start = 0
6228 if (!end || end < 0 || end > len) end = len
6229
6230 var out = ''
6231 for (var i = start; i < end; ++i) {
6232 out += toHex(buf[i])
6233 }
6234 return out
6235}
6236
6237function utf16leSlice (buf, start, end) {
6238 var bytes = buf.slice(start, end)
6239 var res = ''
6240 for (var i = 0; i < bytes.length; i += 2) {
6241 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
6242 }
6243 return res
6244}
6245
6246Buffer.prototype.slice = function slice (start, end) {
6247 var len = this.length
6248 start = ~~start
6249 end = end === undefined ? len : ~~end
6250
6251 if (start < 0) {
6252 start += len
6253 if (start < 0) start = 0
6254 } else if (start > len) {
6255 start = len
6256 }
6257
6258 if (end < 0) {
6259 end += len
6260 if (end < 0) end = 0
6261 } else if (end > len) {
6262 end = len
6263 }
6264
6265 if (end < start) end = start
6266
6267 var newBuf
6268 if (Buffer.TYPED_ARRAY_SUPPORT) {
6269 newBuf = this.subarray(start, end)
6270 newBuf.__proto__ = Buffer.prototype
6271 } else {
6272 var sliceLen = end - start
6273 newBuf = new Buffer(sliceLen, undefined)
6274 for (var i = 0; i < sliceLen; ++i) {
6275 newBuf[i] = this[i + start]
6276 }
6277 }
6278
6279 return newBuf
6280}
6281
6282/*
6283 * Need to make sure that buffer isn't trying to write out of bounds.
6284 */
6285function checkOffset (offset, ext, length) {
6286 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
6287 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
6288}
6289
6290Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
6291 offset = offset | 0
6292 byteLength = byteLength | 0
6293 if (!noAssert) checkOffset(offset, byteLength, this.length)
6294
6295 var val = this[offset]
6296 var mul = 1
6297 var i = 0
6298 while (++i < byteLength && (mul *= 0x100)) {
6299 val += this[offset + i] * mul
6300 }
6301
6302 return val
6303}
6304
6305Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
6306 offset = offset | 0
6307 byteLength = byteLength | 0
6308 if (!noAssert) {
6309 checkOffset(offset, byteLength, this.length)
6310 }
6311
6312 var val = this[offset + --byteLength]
6313 var mul = 1
6314 while (byteLength > 0 && (mul *= 0x100)) {
6315 val += this[offset + --byteLength] * mul
6316 }
6317
6318 return val
6319}
6320
6321Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
6322 if (!noAssert) checkOffset(offset, 1, this.length)
6323 return this[offset]
6324}
6325
6326Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
6327 if (!noAssert) checkOffset(offset, 2, this.length)
6328 return this[offset] | (this[offset + 1] << 8)
6329}
6330
6331Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
6332 if (!noAssert) checkOffset(offset, 2, this.length)
6333 return (this[offset] << 8) | this[offset + 1]
6334}
6335
6336Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
6337 if (!noAssert) checkOffset(offset, 4, this.length)
6338
6339 return ((this[offset]) |
6340 (this[offset + 1] << 8) |
6341 (this[offset + 2] << 16)) +
6342 (this[offset + 3] * 0x1000000)
6343}
6344
6345Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
6346 if (!noAssert) checkOffset(offset, 4, this.length)
6347
6348 return (this[offset] * 0x1000000) +
6349 ((this[offset + 1] << 16) |
6350 (this[offset + 2] << 8) |
6351 this[offset + 3])
6352}
6353
6354Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
6355 offset = offset | 0
6356 byteLength = byteLength | 0
6357 if (!noAssert) checkOffset(offset, byteLength, this.length)
6358
6359 var val = this[offset]
6360 var mul = 1
6361 var i = 0
6362 while (++i < byteLength && (mul *= 0x100)) {
6363 val += this[offset + i] * mul
6364 }
6365 mul *= 0x80
6366
6367 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
6368
6369 return val
6370}
6371
6372Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
6373 offset = offset | 0
6374 byteLength = byteLength | 0
6375 if (!noAssert) checkOffset(offset, byteLength, this.length)
6376
6377 var i = byteLength
6378 var mul = 1
6379 var val = this[offset + --i]
6380 while (i > 0 && (mul *= 0x100)) {
6381 val += this[offset + --i] * mul
6382 }
6383 mul *= 0x80
6384
6385 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
6386
6387 return val
6388}
6389
6390Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
6391 if (!noAssert) checkOffset(offset, 1, this.length)
6392 if (!(this[offset] & 0x80)) return (this[offset])
6393 return ((0xff - this[offset] + 1) * -1)
6394}
6395
6396Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
6397 if (!noAssert) checkOffset(offset, 2, this.length)
6398 var val = this[offset] | (this[offset + 1] << 8)
6399 return (val & 0x8000) ? val | 0xFFFF0000 : val
6400}
6401
6402Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
6403 if (!noAssert) checkOffset(offset, 2, this.length)
6404 var val = this[offset + 1] | (this[offset] << 8)
6405 return (val & 0x8000) ? val | 0xFFFF0000 : val
6406}
6407
6408Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
6409 if (!noAssert) checkOffset(offset, 4, this.length)
6410
6411 return (this[offset]) |
6412 (this[offset + 1] << 8) |
6413 (this[offset + 2] << 16) |
6414 (this[offset + 3] << 24)
6415}
6416
6417Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
6418 if (!noAssert) checkOffset(offset, 4, this.length)
6419
6420 return (this[offset] << 24) |
6421 (this[offset + 1] << 16) |
6422 (this[offset + 2] << 8) |
6423 (this[offset + 3])
6424}
6425
6426Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
6427 if (!noAssert) checkOffset(offset, 4, this.length)
6428 return ieee754.read(this, offset, true, 23, 4)
6429}
6430
6431Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
6432 if (!noAssert) checkOffset(offset, 4, this.length)
6433 return ieee754.read(this, offset, false, 23, 4)
6434}
6435
6436Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
6437 if (!noAssert) checkOffset(offset, 8, this.length)
6438 return ieee754.read(this, offset, true, 52, 8)
6439}
6440
6441Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
6442 if (!noAssert) checkOffset(offset, 8, this.length)
6443 return ieee754.read(this, offset, false, 52, 8)
6444}
6445
6446function checkInt (buf, value, offset, ext, max, min) {
6447 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
6448 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
6449 if (offset + ext > buf.length) throw new RangeError('Index out of range')
6450}
6451
6452Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
6453 value = +value
6454 offset = offset | 0
6455 byteLength = byteLength | 0
6456 if (!noAssert) {
6457 var maxBytes = Math.pow(2, 8 * byteLength) - 1
6458 checkInt(this, value, offset, byteLength, maxBytes, 0)
6459 }
6460
6461 var mul = 1
6462 var i = 0
6463 this[offset] = value & 0xFF
6464 while (++i < byteLength && (mul *= 0x100)) {
6465 this[offset + i] = (value / mul) & 0xFF
6466 }
6467
6468 return offset + byteLength
6469}
6470
6471Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
6472 value = +value
6473 offset = offset | 0
6474 byteLength = byteLength | 0
6475 if (!noAssert) {
6476 var maxBytes = Math.pow(2, 8 * byteLength) - 1
6477 checkInt(this, value, offset, byteLength, maxBytes, 0)
6478 }
6479
6480 var i = byteLength - 1
6481 var mul = 1
6482 this[offset + i] = value & 0xFF
6483 while (--i >= 0 && (mul *= 0x100)) {
6484 this[offset + i] = (value / mul) & 0xFF
6485 }
6486
6487 return offset + byteLength
6488}
6489
6490Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
6491 value = +value
6492 offset = offset | 0
6493 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
6494 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
6495 this[offset] = (value & 0xff)
6496 return offset + 1
6497}
6498
6499function objectWriteUInt16 (buf, value, offset, littleEndian) {
6500 if (value < 0) value = 0xffff + value + 1
6501 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
6502 buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
6503 (littleEndian ? i : 1 - i) * 8
6504 }
6505}
6506
6507Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
6508 value = +value
6509 offset = offset | 0
6510 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
6511 if (Buffer.TYPED_ARRAY_SUPPORT) {
6512 this[offset] = (value & 0xff)
6513 this[offset + 1] = (value >>> 8)
6514 } else {
6515 objectWriteUInt16(this, value, offset, true)
6516 }
6517 return offset + 2
6518}
6519
6520Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
6521 value = +value
6522 offset = offset | 0
6523 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
6524 if (Buffer.TYPED_ARRAY_SUPPORT) {
6525 this[offset] = (value >>> 8)
6526 this[offset + 1] = (value & 0xff)
6527 } else {
6528 objectWriteUInt16(this, value, offset, false)
6529 }
6530 return offset + 2
6531}
6532
6533function objectWriteUInt32 (buf, value, offset, littleEndian) {
6534 if (value < 0) value = 0xffffffff + value + 1
6535 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
6536 buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
6537 }
6538}
6539
6540Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
6541 value = +value
6542 offset = offset | 0
6543 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
6544 if (Buffer.TYPED_ARRAY_SUPPORT) {
6545 this[offset + 3] = (value >>> 24)
6546 this[offset + 2] = (value >>> 16)
6547 this[offset + 1] = (value >>> 8)
6548 this[offset] = (value & 0xff)
6549 } else {
6550 objectWriteUInt32(this, value, offset, true)
6551 }
6552 return offset + 4
6553}
6554
6555Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
6556 value = +value
6557 offset = offset | 0
6558 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
6559 if (Buffer.TYPED_ARRAY_SUPPORT) {
6560 this[offset] = (value >>> 24)
6561 this[offset + 1] = (value >>> 16)
6562 this[offset + 2] = (value >>> 8)
6563 this[offset + 3] = (value & 0xff)
6564 } else {
6565 objectWriteUInt32(this, value, offset, false)
6566 }
6567 return offset + 4
6568}
6569
6570Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
6571 value = +value
6572 offset = offset | 0
6573 if (!noAssert) {
6574 var limit = Math.pow(2, 8 * byteLength - 1)
6575
6576 checkInt(this, value, offset, byteLength, limit - 1, -limit)
6577 }
6578
6579 var i = 0
6580 var mul = 1
6581 var sub = 0
6582 this[offset] = value & 0xFF
6583 while (++i < byteLength && (mul *= 0x100)) {
6584 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
6585 sub = 1
6586 }
6587 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
6588 }
6589
6590 return offset + byteLength
6591}
6592
6593Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
6594 value = +value
6595 offset = offset | 0
6596 if (!noAssert) {
6597 var limit = Math.pow(2, 8 * byteLength - 1)
6598
6599 checkInt(this, value, offset, byteLength, limit - 1, -limit)
6600 }
6601
6602 var i = byteLength - 1
6603 var mul = 1
6604 var sub = 0
6605 this[offset + i] = value & 0xFF
6606 while (--i >= 0 && (mul *= 0x100)) {
6607 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
6608 sub = 1
6609 }
6610 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
6611 }
6612
6613 return offset + byteLength
6614}
6615
6616Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
6617 value = +value
6618 offset = offset | 0
6619 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
6620 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
6621 if (value < 0) value = 0xff + value + 1
6622 this[offset] = (value & 0xff)
6623 return offset + 1
6624}
6625
6626Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
6627 value = +value
6628 offset = offset | 0
6629 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
6630 if (Buffer.TYPED_ARRAY_SUPPORT) {
6631 this[offset] = (value & 0xff)
6632 this[offset + 1] = (value >>> 8)
6633 } else {
6634 objectWriteUInt16(this, value, offset, true)
6635 }
6636 return offset + 2
6637}
6638
6639Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
6640 value = +value
6641 offset = offset | 0
6642 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
6643 if (Buffer.TYPED_ARRAY_SUPPORT) {
6644 this[offset] = (value >>> 8)
6645 this[offset + 1] = (value & 0xff)
6646 } else {
6647 objectWriteUInt16(this, value, offset, false)
6648 }
6649 return offset + 2
6650}
6651
6652Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
6653 value = +value
6654 offset = offset | 0
6655 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
6656 if (Buffer.TYPED_ARRAY_SUPPORT) {
6657 this[offset] = (value & 0xff)
6658 this[offset + 1] = (value >>> 8)
6659 this[offset + 2] = (value >>> 16)
6660 this[offset + 3] = (value >>> 24)
6661 } else {
6662 objectWriteUInt32(this, value, offset, true)
6663 }
6664 return offset + 4
6665}
6666
6667Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
6668 value = +value
6669 offset = offset | 0
6670 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
6671 if (value < 0) value = 0xffffffff + value + 1
6672 if (Buffer.TYPED_ARRAY_SUPPORT) {
6673 this[offset] = (value >>> 24)
6674 this[offset + 1] = (value >>> 16)
6675 this[offset + 2] = (value >>> 8)
6676 this[offset + 3] = (value & 0xff)
6677 } else {
6678 objectWriteUInt32(this, value, offset, false)
6679 }
6680 return offset + 4
6681}
6682
6683function checkIEEE754 (buf, value, offset, ext, max, min) {
6684 if (offset + ext > buf.length) throw new RangeError('Index out of range')
6685 if (offset < 0) throw new RangeError('Index out of range')
6686}
6687
6688function writeFloat (buf, value, offset, littleEndian, noAssert) {
6689 if (!noAssert) {
6690 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
6691 }
6692 ieee754.write(buf, value, offset, littleEndian, 23, 4)
6693 return offset + 4
6694}
6695
6696Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
6697 return writeFloat(this, value, offset, true, noAssert)
6698}
6699
6700Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
6701 return writeFloat(this, value, offset, false, noAssert)
6702}
6703
6704function writeDouble (buf, value, offset, littleEndian, noAssert) {
6705 if (!noAssert) {
6706 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
6707 }
6708 ieee754.write(buf, value, offset, littleEndian, 52, 8)
6709 return offset + 8
6710}
6711
6712Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
6713 return writeDouble(this, value, offset, true, noAssert)
6714}
6715
6716Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
6717 return writeDouble(this, value, offset, false, noAssert)
6718}
6719
6720// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
6721Buffer.prototype.copy = function copy (target, targetStart, start, end) {
6722 if (!start) start = 0
6723 if (!end && end !== 0) end = this.length
6724 if (targetStart >= target.length) targetStart = target.length
6725 if (!targetStart) targetStart = 0
6726 if (end > 0 && end < start) end = start
6727
6728 // Copy 0 bytes; we're done
6729 if (end === start) return 0
6730 if (target.length === 0 || this.length === 0) return 0
6731
6732 // Fatal error conditions
6733 if (targetStart < 0) {
6734 throw new RangeError('targetStart out of bounds')
6735 }
6736 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
6737 if (end < 0) throw new RangeError('sourceEnd out of bounds')
6738
6739 // Are we oob?
6740 if (end > this.length) end = this.length
6741 if (target.length - targetStart < end - start) {
6742 end = target.length - targetStart + start
6743 }
6744
6745 var len = end - start
6746 var i
6747
6748 if (this === target && start < targetStart && targetStart < end) {
6749 // descending copy from end
6750 for (i = len - 1; i >= 0; --i) {
6751 target[i + targetStart] = this[i + start]
6752 }
6753 } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
6754 // ascending copy from start
6755 for (i = 0; i < len; ++i) {
6756 target[i + targetStart] = this[i + start]
6757 }
6758 } else {
6759 Uint8Array.prototype.set.call(
6760 target,
6761 this.subarray(start, start + len),
6762 targetStart
6763 )
6764 }
6765
6766 return len
6767}
6768
6769// Usage:
6770// buffer.fill(number[, offset[, end]])
6771// buffer.fill(buffer[, offset[, end]])
6772// buffer.fill(string[, offset[, end]][, encoding])
6773Buffer.prototype.fill = function fill (val, start, end, encoding) {
6774 // Handle string cases:
6775 if (typeof val === 'string') {
6776 if (typeof start === 'string') {
6777 encoding = start
6778 start = 0
6779 end = this.length
6780 } else if (typeof end === 'string') {
6781 encoding = end
6782 end = this.length
6783 }
6784 if (val.length === 1) {
6785 var code = val.charCodeAt(0)
6786 if (code < 256) {
6787 val = code
6788 }
6789 }
6790 if (encoding !== undefined && typeof encoding !== 'string') {
6791 throw new TypeError('encoding must be a string')
6792 }
6793 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
6794 throw new TypeError('Unknown encoding: ' + encoding)
6795 }
6796 } else if (typeof val === 'number') {
6797 val = val & 255
6798 }
6799
6800 // Invalid ranges are not set to a default, so can range check early.
6801 if (start < 0 || this.length < start || this.length < end) {
6802 throw new RangeError('Out of range index')
6803 }
6804
6805 if (end <= start) {
6806 return this
6807 }
6808
6809 start = start >>> 0
6810 end = end === undefined ? this.length : end >>> 0
6811
6812 if (!val) val = 0
6813
6814 var i
6815 if (typeof val === 'number') {
6816 for (i = start; i < end; ++i) {
6817 this[i] = val
6818 }
6819 } else {
6820 var bytes = Buffer.isBuffer(val)
6821 ? val
6822 : utf8ToBytes(new Buffer(val, encoding).toString())
6823 var len = bytes.length
6824 for (i = 0; i < end - start; ++i) {
6825 this[i + start] = bytes[i % len]
6826 }
6827 }
6828
6829 return this
6830}
6831
6832// HELPER FUNCTIONS
6833// ================
6834
6835var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
6836
6837function base64clean (str) {
6838 // Node strips out invalid characters like \n and \t from the string, base64-js does not
6839 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
6840 // Node converts strings with length < 2 to ''
6841 if (str.length < 2) return ''
6842 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
6843 while (str.length % 4 !== 0) {
6844 str = str + '='
6845 }
6846 return str
6847}
6848
6849function stringtrim (str) {
6850 if (str.trim) return str.trim()
6851 return str.replace(/^\s+|\s+$/g, '')
6852}
6853
6854function toHex (n) {
6855 if (n < 16) return '0' + n.toString(16)
6856 return n.toString(16)
6857}
6858
6859function utf8ToBytes (string, units) {
6860 units = units || Infinity
6861 var codePoint
6862 var length = string.length
6863 var leadSurrogate = null
6864 var bytes = []
6865
6866 for (var i = 0; i < length; ++i) {
6867 codePoint = string.charCodeAt(i)
6868
6869 // is surrogate component
6870 if (codePoint > 0xD7FF && codePoint < 0xE000) {
6871 // last char was a lead
6872 if (!leadSurrogate) {
6873 // no lead yet
6874 if (codePoint > 0xDBFF) {
6875 // unexpected trail
6876 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
6877 continue
6878 } else if (i + 1 === length) {
6879 // unpaired lead
6880 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
6881 continue
6882 }
6883
6884 // valid lead
6885 leadSurrogate = codePoint
6886
6887 continue
6888 }
6889
6890 // 2 leads in a row
6891 if (codePoint < 0xDC00) {
6892 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
6893 leadSurrogate = codePoint
6894 continue
6895 }
6896
6897 // valid surrogate pair
6898 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
6899 } else if (leadSurrogate) {
6900 // valid bmp char, but last char was a lead
6901 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
6902 }
6903
6904 leadSurrogate = null
6905
6906 // encode utf8
6907 if (codePoint < 0x80) {
6908 if ((units -= 1) < 0) break
6909 bytes.push(codePoint)
6910 } else if (codePoint < 0x800) {
6911 if ((units -= 2) < 0) break
6912 bytes.push(
6913 codePoint >> 0x6 | 0xC0,
6914 codePoint & 0x3F | 0x80
6915 )
6916 } else if (codePoint < 0x10000) {
6917 if ((units -= 3) < 0) break
6918 bytes.push(
6919 codePoint >> 0xC | 0xE0,
6920 codePoint >> 0x6 & 0x3F | 0x80,
6921 codePoint & 0x3F | 0x80
6922 )
6923 } else if (codePoint < 0x110000) {
6924 if ((units -= 4) < 0) break
6925 bytes.push(
6926 codePoint >> 0x12 | 0xF0,
6927 codePoint >> 0xC & 0x3F | 0x80,
6928 codePoint >> 0x6 & 0x3F | 0x80,
6929 codePoint & 0x3F | 0x80
6930 )
6931 } else {
6932 throw new Error('Invalid code point')
6933 }
6934 }
6935
6936 return bytes
6937}
6938
6939function asciiToBytes (str) {
6940 var byteArray = []
6941 for (var i = 0; i < str.length; ++i) {
6942 // Node's code seems to be doing this and not & 0x7F..
6943 byteArray.push(str.charCodeAt(i) & 0xFF)
6944 }
6945 return byteArray
6946}
6947
6948function utf16leToBytes (str, units) {
6949 var c, hi, lo
6950 var byteArray = []
6951 for (var i = 0; i < str.length; ++i) {
6952 if ((units -= 2) < 0) break
6953
6954 c = str.charCodeAt(i)
6955 hi = c >> 8
6956 lo = c % 256
6957 byteArray.push(lo)
6958 byteArray.push(hi)
6959 }
6960
6961 return byteArray
6962}
6963
6964function base64ToBytes (str) {
6965 return base64.toByteArray(base64clean(str))
6966}
6967
6968function blitBuffer (src, dst, offset, length) {
6969 for (var i = 0; i < length; ++i) {
6970 if ((i + offset >= dst.length) || (i >= src.length)) break
6971 dst[i + offset] = src[i]
6972 }
6973 return i
6974}
6975
6976function isnan (val) {
6977 return val !== val // eslint-disable-line no-self-compare
6978}
6979
6980}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
6981},{"base64-js":56,"ieee754":215,"isarray":224}],61:[function(require,module,exports){
6982module.exports = {
6983 "100": "Continue",
6984 "101": "Switching Protocols",
6985 "102": "Processing",
6986 "200": "OK",
6987 "201": "Created",
6988 "202": "Accepted",
6989 "203": "Non-Authoritative Information",
6990 "204": "No Content",
6991 "205": "Reset Content",
6992 "206": "Partial Content",
6993 "207": "Multi-Status",
6994 "208": "Already Reported",
6995 "226": "IM Used",
6996 "300": "Multiple Choices",
6997 "301": "Moved Permanently",
6998 "302": "Found",
6999 "303": "See Other",
7000 "304": "Not Modified",
7001 "305": "Use Proxy",
7002 "307": "Temporary Redirect",
7003 "308": "Permanent Redirect",
7004 "400": "Bad Request",
7005 "401": "Unauthorized",
7006 "402": "Payment Required",
7007 "403": "Forbidden",
7008 "404": "Not Found",
7009 "405": "Method Not Allowed",
7010 "406": "Not Acceptable",
7011 "407": "Proxy Authentication Required",
7012 "408": "Request Timeout",
7013 "409": "Conflict",
7014 "410": "Gone",
7015 "411": "Length Required",
7016 "412": "Precondition Failed",
7017 "413": "Payload Too Large",
7018 "414": "URI Too Long",
7019 "415": "Unsupported Media Type",
7020 "416": "Range Not Satisfiable",
7021 "417": "Expectation Failed",
7022 "418": "I'm a teapot",
7023 "421": "Misdirected Request",
7024 "422": "Unprocessable Entity",
7025 "423": "Locked",
7026 "424": "Failed Dependency",
7027 "425": "Unordered Collection",
7028 "426": "Upgrade Required",
7029 "428": "Precondition Required",
7030 "429": "Too Many Requests",
7031 "431": "Request Header Fields Too Large",
7032 "451": "Unavailable For Legal Reasons",
7033 "500": "Internal Server Error",
7034 "501": "Not Implemented",
7035 "502": "Bad Gateway",
7036 "503": "Service Unavailable",
7037 "504": "Gateway Timeout",
7038 "505": "HTTP Version Not Supported",
7039 "506": "Variant Also Negotiates",
7040 "507": "Insufficient Storage",
7041 "508": "Loop Detected",
7042 "509": "Bandwidth Limit Exceeded",
7043 "510": "Not Extended",
7044 "511": "Network Authentication Required"
7045}
7046
7047},{}],62:[function(require,module,exports){
7048module.exports={
7049 "O_RDONLY": 0,
7050 "O_WRONLY": 1,
7051 "O_RDWR": 2,
7052 "S_IFMT": 61440,
7053 "S_IFREG": 32768,
7054 "S_IFDIR": 16384,
7055 "S_IFCHR": 8192,
7056 "S_IFBLK": 24576,
7057 "S_IFIFO": 4096,
7058 "S_IFLNK": 40960,
7059 "S_IFSOCK": 49152,
7060 "O_CREAT": 512,
7061 "O_EXCL": 2048,
7062 "O_NOCTTY": 131072,
7063 "O_TRUNC": 1024,
7064 "O_APPEND": 8,
7065 "O_DIRECTORY": 1048576,
7066 "O_NOFOLLOW": 256,
7067 "O_SYNC": 128,
7068 "O_SYMLINK": 2097152,
7069 "O_NONBLOCK": 4,
7070 "S_IRWXU": 448,
7071 "S_IRUSR": 256,
7072 "S_IWUSR": 128,
7073 "S_IXUSR": 64,
7074 "S_IRWXG": 56,
7075 "S_IRGRP": 32,
7076 "S_IWGRP": 16,
7077 "S_IXGRP": 8,
7078 "S_IRWXO": 7,
7079 "S_IROTH": 4,
7080 "S_IWOTH": 2,
7081 "S_IXOTH": 1,
7082 "E2BIG": 7,
7083 "EACCES": 13,
7084 "EADDRINUSE": 48,
7085 "EADDRNOTAVAIL": 49,
7086 "EAFNOSUPPORT": 47,
7087 "EAGAIN": 35,
7088 "EALREADY": 37,
7089 "EBADF": 9,
7090 "EBADMSG": 94,
7091 "EBUSY": 16,
7092 "ECANCELED": 89,
7093 "ECHILD": 10,
7094 "ECONNABORTED": 53,
7095 "ECONNREFUSED": 61,
7096 "ECONNRESET": 54,
7097 "EDEADLK": 11,
7098 "EDESTADDRREQ": 39,
7099 "EDOM": 33,
7100 "EDQUOT": 69,
7101 "EEXIST": 17,
7102 "EFAULT": 14,
7103 "EFBIG": 27,
7104 "EHOSTUNREACH": 65,
7105 "EIDRM": 90,
7106 "EILSEQ": 92,
7107 "EINPROGRESS": 36,
7108 "EINTR": 4,
7109 "EINVAL": 22,
7110 "EIO": 5,
7111 "EISCONN": 56,
7112 "EISDIR": 21,
7113 "ELOOP": 62,
7114 "EMFILE": 24,
7115 "EMLINK": 31,
7116 "EMSGSIZE": 40,
7117 "EMULTIHOP": 95,
7118 "ENAMETOOLONG": 63,
7119 "ENETDOWN": 50,
7120 "ENETRESET": 52,
7121 "ENETUNREACH": 51,
7122 "ENFILE": 23,
7123 "ENOBUFS": 55,
7124 "ENODATA": 96,
7125 "ENODEV": 19,
7126 "ENOENT": 2,
7127 "ENOEXEC": 8,
7128 "ENOLCK": 77,
7129 "ENOLINK": 97,
7130 "ENOMEM": 12,
7131 "ENOMSG": 91,
7132 "ENOPROTOOPT": 42,
7133 "ENOSPC": 28,
7134 "ENOSR": 98,
7135 "ENOSTR": 99,
7136 "ENOSYS": 78,
7137 "ENOTCONN": 57,
7138 "ENOTDIR": 20,
7139 "ENOTEMPTY": 66,
7140 "ENOTSOCK": 38,
7141 "ENOTSUP": 45,
7142 "ENOTTY": 25,
7143 "ENXIO": 6,
7144 "EOPNOTSUPP": 102,
7145 "EOVERFLOW": 84,
7146 "EPERM": 1,
7147 "EPIPE": 32,
7148 "EPROTO": 100,
7149 "EPROTONOSUPPORT": 43,
7150 "EPROTOTYPE": 41,
7151 "ERANGE": 34,
7152 "EROFS": 30,
7153 "ESPIPE": 29,
7154 "ESRCH": 3,
7155 "ESTALE": 70,
7156 "ETIME": 101,
7157 "ETIMEDOUT": 60,
7158 "ETXTBSY": 26,
7159 "EWOULDBLOCK": 35,
7160 "EXDEV": 18,
7161 "SIGHUP": 1,
7162 "SIGINT": 2,
7163 "SIGQUIT": 3,
7164 "SIGILL": 4,
7165 "SIGTRAP": 5,
7166 "SIGABRT": 6,
7167 "SIGIOT": 6,
7168 "SIGBUS": 10,
7169 "SIGFPE": 8,
7170 "SIGKILL": 9,
7171 "SIGUSR1": 30,
7172 "SIGSEGV": 11,
7173 "SIGUSR2": 31,
7174 "SIGPIPE": 13,
7175 "SIGALRM": 14,
7176 "SIGTERM": 15,
7177 "SIGCHLD": 20,
7178 "SIGCONT": 19,
7179 "SIGSTOP": 17,
7180 "SIGTSTP": 18,
7181 "SIGTTIN": 21,
7182 "SIGTTOU": 22,
7183 "SIGURG": 16,
7184 "SIGXCPU": 24,
7185 "SIGXFSZ": 25,
7186 "SIGVTALRM": 26,
7187 "SIGPROF": 27,
7188 "SIGWINCH": 28,
7189 "SIGIO": 23,
7190 "SIGSYS": 12,
7191 "SSL_OP_ALL": 2147486719,
7192 "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": 262144,
7193 "SSL_OP_CIPHER_SERVER_PREFERENCE": 4194304,
7194 "SSL_OP_CISCO_ANYCONNECT": 32768,
7195 "SSL_OP_COOKIE_EXCHANGE": 8192,
7196 "SSL_OP_CRYPTOPRO_TLSEXT_BUG": 2147483648,
7197 "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS": 2048,
7198 "SSL_OP_EPHEMERAL_RSA": 0,
7199 "SSL_OP_LEGACY_SERVER_CONNECT": 4,
7200 "SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER": 32,
7201 "SSL_OP_MICROSOFT_SESS_ID_BUG": 1,
7202 "SSL_OP_MSIE_SSLV2_RSA_PADDING": 0,
7203 "SSL_OP_NETSCAPE_CA_DN_BUG": 536870912,
7204 "SSL_OP_NETSCAPE_CHALLENGE_BUG": 2,
7205 "SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG": 1073741824,
7206 "SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG": 8,
7207 "SSL_OP_NO_COMPRESSION": 131072,
7208 "SSL_OP_NO_QUERY_MTU": 4096,
7209 "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION": 65536,
7210 "SSL_OP_NO_SSLv2": 16777216,
7211 "SSL_OP_NO_SSLv3": 33554432,
7212 "SSL_OP_NO_TICKET": 16384,
7213 "SSL_OP_NO_TLSv1": 67108864,
7214 "SSL_OP_NO_TLSv1_1": 268435456,
7215 "SSL_OP_NO_TLSv1_2": 134217728,
7216 "SSL_OP_PKCS1_CHECK_1": 0,
7217 "SSL_OP_PKCS1_CHECK_2": 0,
7218 "SSL_OP_SINGLE_DH_USE": 1048576,
7219 "SSL_OP_SINGLE_ECDH_USE": 524288,
7220 "SSL_OP_SSLEAY_080_CLIENT_DH_BUG": 128,
7221 "SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG": 0,
7222 "SSL_OP_TLS_BLOCK_PADDING_BUG": 512,
7223 "SSL_OP_TLS_D5_BUG": 256,
7224 "SSL_OP_TLS_ROLLBACK_BUG": 8388608,
7225 "ENGINE_METHOD_DSA": 2,
7226 "ENGINE_METHOD_DH": 4,
7227 "ENGINE_METHOD_RAND": 8,
7228 "ENGINE_METHOD_ECDH": 16,
7229 "ENGINE_METHOD_ECDSA": 32,
7230 "ENGINE_METHOD_CIPHERS": 64,
7231 "ENGINE_METHOD_DIGESTS": 128,
7232 "ENGINE_METHOD_STORE": 256,
7233 "ENGINE_METHOD_PKEY_METHS": 512,
7234 "ENGINE_METHOD_PKEY_ASN1_METHS": 1024,
7235 "ENGINE_METHOD_ALL": 65535,
7236 "ENGINE_METHOD_NONE": 0,
7237 "DH_CHECK_P_NOT_SAFE_PRIME": 2,
7238 "DH_CHECK_P_NOT_PRIME": 1,
7239 "DH_UNABLE_TO_CHECK_GENERATOR": 4,
7240 "DH_NOT_SUITABLE_GENERATOR": 8,
7241 "NPN_ENABLED": 1,
7242 "RSA_PKCS1_PADDING": 1,
7243 "RSA_SSLV23_PADDING": 2,
7244 "RSA_NO_PADDING": 3,
7245 "RSA_PKCS1_OAEP_PADDING": 4,
7246 "RSA_X931_PADDING": 5,
7247 "RSA_PKCS1_PSS_PADDING": 6,
7248 "POINT_CONVERSION_COMPRESSED": 2,
7249 "POINT_CONVERSION_UNCOMPRESSED": 4,
7250 "POINT_CONVERSION_HYBRID": 6,
7251 "F_OK": 0,
7252 "R_OK": 4,
7253 "W_OK": 2,
7254 "X_OK": 1,
7255 "UV_UDP_REUSEADDR": 4
7256}
7257
7258},{}],63:[function(require,module,exports){
7259/*!
7260 * copy-to - index.js
7261 * Copyright(c) 2014 dead_horse <dead_horse@qq.com>
7262 * MIT Licensed
7263 */
7264
7265'use strict';
7266
7267/**
7268 * slice() reference.
7269 */
7270
7271var slice = Array.prototype.slice;
7272
7273/**
7274 * Expose copy
7275 *
7276 * ```
7277 * copy({foo: 'nar', hello: 'copy'}).to({hello: 'world'});
7278 * copy({foo: 'nar', hello: 'copy'}).toCover({hello: 'world'});
7279 * ```
7280 *
7281 * @param {Object} src
7282 * @return {Copy}
7283 */
7284
7285module.exports = Copy;
7286
7287
7288/**
7289 * Copy
7290 * @param {Object} src
7291 * @param {Boolean} withAccess
7292 */
7293
7294function Copy(src, withAccess) {
7295 if (!(this instanceof Copy)) return new Copy(src, withAccess);
7296 this.src = src;
7297 this._withAccess = withAccess;
7298}
7299
7300/**
7301 * copy properties include getter and setter
7302 * @param {[type]} val [description]
7303 * @return {[type]} [description]
7304 */
7305
7306Copy.prototype.withAccess = function (w) {
7307 this._withAccess = w !== false;
7308 return this;
7309};
7310
7311/**
7312 * pick keys in src
7313 *
7314 * @api: public
7315 */
7316
7317Copy.prototype.pick = function(keys) {
7318 if (!Array.isArray(keys)) {
7319 keys = slice.call(arguments);
7320 }
7321 if (keys.length) {
7322 this.keys = keys;
7323 }
7324 return this;
7325};
7326
7327/**
7328 * copy src to target,
7329 * do not cover any property target has
7330 * @param {Object} to
7331 *
7332 * @api: public
7333 */
7334
7335Copy.prototype.to = function(to) {
7336 to = to || {};
7337
7338 if (!this.src) return to;
7339 var keys = this.keys || Object.keys(this.src);
7340
7341 if (!this._withAccess) {
7342 for (var i = 0; i < keys.length; i++) {
7343 key = keys[i];
7344 if (to[key] !== undefined) continue;
7345 to[key] = this.src[key];
7346 }
7347 return to;
7348 }
7349
7350 for (var i = 0; i < keys.length; i++) {
7351 var key = keys[i];
7352 if (!notDefined(to, key)) continue;
7353 var getter = this.src.__lookupGetter__(key);
7354 var setter = this.src.__lookupSetter__(key);
7355 if (getter) to.__defineGetter__(key, getter);
7356 if (setter) to.__defineSetter__(key, setter);
7357
7358 if (!getter && !setter) {
7359 to[key] = this.src[key];
7360 }
7361 }
7362 return to;
7363};
7364
7365/**
7366 * copy src to target,
7367 * override any property target has
7368 * @param {Object} to
7369 *
7370 * @api: public
7371 */
7372
7373Copy.prototype.toCover = function(to) {
7374 var keys = this.keys || Object.keys(this.src);
7375
7376 for (var i = 0; i < keys.length; i++) {
7377 var key = keys[i];
7378 delete to[key];
7379 var getter = this.src.__lookupGetter__(key);
7380 var setter = this.src.__lookupSetter__(key);
7381 if (getter) to.__defineGetter__(key, getter);
7382 if (setter) to.__defineSetter__(key, setter);
7383
7384 if (!getter && !setter) {
7385 to[key] = this.src[key];
7386 }
7387 }
7388};
7389
7390Copy.prototype.override = Copy.prototype.toCover;
7391
7392/**
7393 * append another object to src
7394 * @param {Obj} obj
7395 * @return {Copy}
7396 */
7397
7398Copy.prototype.and = function (obj) {
7399 var src = {};
7400 this.to(src);
7401 this.src = obj;
7402 this.to(src);
7403 this.src = src;
7404
7405 return this;
7406};
7407
7408/**
7409 * check obj[key] if not defiend
7410 * @param {Object} obj
7411 * @param {String} key
7412 * @return {Boolean}
7413 */
7414
7415function notDefined(obj, key) {
7416 return obj[key] === undefined
7417 && obj.__lookupGetter__(key) === undefined
7418 && obj.__lookupSetter__(key) === undefined;
7419}
7420
7421},{}],64:[function(require,module,exports){
7422require('../../modules/es6.string.iterator');
7423require('../../modules/es6.array.from');
7424module.exports = require('../../modules/_core').Array.from;
7425
7426},{"../../modules/_core":86,"../../modules/es6.array.from":155,"../../modules/es6.string.iterator":167}],65:[function(require,module,exports){
7427var core = require('../../modules/_core');
7428var $JSON = core.JSON || (core.JSON = { stringify: JSON.stringify });
7429module.exports = function stringify(it) { // eslint-disable-line no-unused-vars
7430 return $JSON.stringify.apply($JSON, arguments);
7431};
7432
7433},{"../../modules/_core":86}],66:[function(require,module,exports){
7434require('../../modules/es6.object.assign');
7435module.exports = require('../../modules/_core').Object.assign;
7436
7437},{"../../modules/_core":86,"../../modules/es6.object.assign":158}],67:[function(require,module,exports){
7438require('../../modules/es6.object.create');
7439var $Object = require('../../modules/_core').Object;
7440module.exports = function create(P, D) {
7441 return $Object.create(P, D);
7442};
7443
7444},{"../../modules/_core":86,"../../modules/es6.object.create":159}],68:[function(require,module,exports){
7445require('../../modules/es6.object.define-property');
7446var $Object = require('../../modules/_core').Object;
7447module.exports = function defineProperty(it, key, desc) {
7448 return $Object.defineProperty(it, key, desc);
7449};
7450
7451},{"../../modules/_core":86,"../../modules/es6.object.define-property":160}],69:[function(require,module,exports){
7452require('../../modules/es7.object.entries');
7453module.exports = require('../../modules/_core').Object.entries;
7454
7455},{"../../modules/_core":86,"../../modules/es7.object.entries":169}],70:[function(require,module,exports){
7456require('../../modules/es6.object.get-own-property-names');
7457var $Object = require('../../modules/_core').Object;
7458module.exports = function getOwnPropertyNames(it) {
7459 return $Object.getOwnPropertyNames(it);
7460};
7461
7462},{"../../modules/_core":86,"../../modules/es6.object.get-own-property-names":161}],71:[function(require,module,exports){
7463require('../../modules/es6.object.get-prototype-of');
7464module.exports = require('../../modules/_core').Object.getPrototypeOf;
7465
7466},{"../../modules/_core":86,"../../modules/es6.object.get-prototype-of":162}],72:[function(require,module,exports){
7467require('../../modules/es6.object.keys');
7468module.exports = require('../../modules/_core').Object.keys;
7469
7470},{"../../modules/_core":86,"../../modules/es6.object.keys":163}],73:[function(require,module,exports){
7471require('../modules/es6.object.to-string');
7472require('../modules/es6.string.iterator');
7473require('../modules/web.dom.iterable');
7474require('../modules/es6.promise');
7475require('../modules/es7.promise.finally');
7476require('../modules/es7.promise.try');
7477module.exports = require('../modules/_core').Promise;
7478
7479},{"../modules/_core":86,"../modules/es6.object.to-string":164,"../modules/es6.promise":165,"../modules/es6.string.iterator":167,"../modules/es7.promise.finally":170,"../modules/es7.promise.try":171,"../modules/web.dom.iterable":174}],74:[function(require,module,exports){
7480require('../modules/web.immediate');
7481module.exports = require('../modules/_core').setImmediate;
7482
7483},{"../modules/_core":86,"../modules/web.immediate":175}],75:[function(require,module,exports){
7484require('../../modules/es6.string.from-code-point');
7485module.exports = require('../../modules/_core').String.fromCodePoint;
7486
7487},{"../../modules/_core":86,"../../modules/es6.string.from-code-point":166}],76:[function(require,module,exports){
7488require('../../modules/es6.function.has-instance');
7489module.exports = require('../../modules/_wks-ext').f('hasInstance');
7490
7491},{"../../modules/_wks-ext":152,"../../modules/es6.function.has-instance":157}],77:[function(require,module,exports){
7492require('../../modules/es6.symbol');
7493require('../../modules/es6.object.to-string');
7494require('../../modules/es7.symbol.async-iterator');
7495require('../../modules/es7.symbol.observable');
7496module.exports = require('../../modules/_core').Symbol;
7497
7498},{"../../modules/_core":86,"../../modules/es6.object.to-string":164,"../../modules/es6.symbol":168,"../../modules/es7.symbol.async-iterator":172,"../../modules/es7.symbol.observable":173}],78:[function(require,module,exports){
7499require('../../modules/es6.string.iterator');
7500require('../../modules/web.dom.iterable');
7501module.exports = require('../../modules/_wks-ext').f('iterator');
7502
7503},{"../../modules/_wks-ext":152,"../../modules/es6.string.iterator":167,"../../modules/web.dom.iterable":174}],79:[function(require,module,exports){
7504module.exports = function (it) {
7505 if (typeof it != 'function') throw TypeError(it + ' is not a function!');
7506 return it;
7507};
7508
7509},{}],80:[function(require,module,exports){
7510module.exports = function () { /* empty */ };
7511
7512},{}],81:[function(require,module,exports){
7513module.exports = function (it, Constructor, name, forbiddenField) {
7514 if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
7515 throw TypeError(name + ': incorrect invocation!');
7516 } return it;
7517};
7518
7519},{}],82:[function(require,module,exports){
7520var isObject = require('./_is-object');
7521module.exports = function (it) {
7522 if (!isObject(it)) throw TypeError(it + ' is not an object!');
7523 return it;
7524};
7525
7526},{"./_is-object":106}],83:[function(require,module,exports){
7527// false -> Array#indexOf
7528// true -> Array#includes
7529var toIObject = require('./_to-iobject');
7530var toLength = require('./_to-length');
7531var toAbsoluteIndex = require('./_to-absolute-index');
7532module.exports = function (IS_INCLUDES) {
7533 return function ($this, el, fromIndex) {
7534 var O = toIObject($this);
7535 var length = toLength(O.length);
7536 var index = toAbsoluteIndex(fromIndex, length);
7537 var value;
7538 // Array#includes uses SameValueZero equality algorithm
7539 // eslint-disable-next-line no-self-compare
7540 if (IS_INCLUDES && el != el) while (length > index) {
7541 value = O[index++];
7542 // eslint-disable-next-line no-self-compare
7543 if (value != value) return true;
7544 // Array#indexOf ignores holes, Array#includes - not
7545 } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
7546 if (O[index] === el) return IS_INCLUDES || index || 0;
7547 } return !IS_INCLUDES && -1;
7548 };
7549};
7550
7551},{"./_to-absolute-index":143,"./_to-iobject":145,"./_to-length":146}],84:[function(require,module,exports){
7552// getting tag from 19.1.3.6 Object.prototype.toString()
7553var cof = require('./_cof');
7554var TAG = require('./_wks')('toStringTag');
7555// ES3 wrong here
7556var ARG = cof(function () { return arguments; }()) == 'Arguments';
7557
7558// fallback for IE11 Script Access Denied error
7559var tryGet = function (it, key) {
7560 try {
7561 return it[key];
7562 } catch (e) { /* empty */ }
7563};
7564
7565module.exports = function (it) {
7566 var O, T, B;
7567 return it === undefined ? 'Undefined' : it === null ? 'Null'
7568 // @@toStringTag case
7569 : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
7570 // builtinTag case
7571 : ARG ? cof(O)
7572 // ES3 arguments fallback
7573 : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
7574};
7575
7576},{"./_cof":85,"./_wks":153}],85:[function(require,module,exports){
7577var toString = {}.toString;
7578
7579module.exports = function (it) {
7580 return toString.call(it).slice(8, -1);
7581};
7582
7583},{}],86:[function(require,module,exports){
7584var core = module.exports = { version: '2.5.7' };
7585if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
7586
7587},{}],87:[function(require,module,exports){
7588'use strict';
7589var $defineProperty = require('./_object-dp');
7590var createDesc = require('./_property-desc');
7591
7592module.exports = function (object, index, value) {
7593 if (index in object) $defineProperty.f(object, index, createDesc(0, value));
7594 else object[index] = value;
7595};
7596
7597},{"./_object-dp":119,"./_property-desc":133}],88:[function(require,module,exports){
7598// optional / simple context binding
7599var aFunction = require('./_a-function');
7600module.exports = function (fn, that, length) {
7601 aFunction(fn);
7602 if (that === undefined) return fn;
7603 switch (length) {
7604 case 1: return function (a) {
7605 return fn.call(that, a);
7606 };
7607 case 2: return function (a, b) {
7608 return fn.call(that, a, b);
7609 };
7610 case 3: return function (a, b, c) {
7611 return fn.call(that, a, b, c);
7612 };
7613 }
7614 return function (/* ...args */) {
7615 return fn.apply(that, arguments);
7616 };
7617};
7618
7619},{"./_a-function":79}],89:[function(require,module,exports){
7620// 7.2.1 RequireObjectCoercible(argument)
7621module.exports = function (it) {
7622 if (it == undefined) throw TypeError("Can't call method on " + it);
7623 return it;
7624};
7625
7626},{}],90:[function(require,module,exports){
7627// Thank's IE8 for his funny defineProperty
7628module.exports = !require('./_fails')(function () {
7629 return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
7630});
7631
7632},{"./_fails":95}],91:[function(require,module,exports){
7633var isObject = require('./_is-object');
7634var document = require('./_global').document;
7635// typeof document.createElement is 'object' in old IE
7636var is = isObject(document) && isObject(document.createElement);
7637module.exports = function (it) {
7638 return is ? document.createElement(it) : {};
7639};
7640
7641},{"./_global":97,"./_is-object":106}],92:[function(require,module,exports){
7642// IE 8- don't enum bug keys
7643module.exports = (
7644 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
7645).split(',');
7646
7647},{}],93:[function(require,module,exports){
7648// all enumerable object keys, includes symbols
7649var getKeys = require('./_object-keys');
7650var gOPS = require('./_object-gops');
7651var pIE = require('./_object-pie');
7652module.exports = function (it) {
7653 var result = getKeys(it);
7654 var getSymbols = gOPS.f;
7655 if (getSymbols) {
7656 var symbols = getSymbols(it);
7657 var isEnum = pIE.f;
7658 var i = 0;
7659 var key;
7660 while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
7661 } return result;
7662};
7663
7664},{"./_object-gops":124,"./_object-keys":127,"./_object-pie":128}],94:[function(require,module,exports){
7665var global = require('./_global');
7666var core = require('./_core');
7667var ctx = require('./_ctx');
7668var hide = require('./_hide');
7669var has = require('./_has');
7670var PROTOTYPE = 'prototype';
7671
7672var $export = function (type, name, source) {
7673 var IS_FORCED = type & $export.F;
7674 var IS_GLOBAL = type & $export.G;
7675 var IS_STATIC = type & $export.S;
7676 var IS_PROTO = type & $export.P;
7677 var IS_BIND = type & $export.B;
7678 var IS_WRAP = type & $export.W;
7679 var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
7680 var expProto = exports[PROTOTYPE];
7681 var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];
7682 var key, own, out;
7683 if (IS_GLOBAL) source = name;
7684 for (key in source) {
7685 // contains in native
7686 own = !IS_FORCED && target && target[key] !== undefined;
7687 if (own && has(exports, key)) continue;
7688 // export native or passed
7689 out = own ? target[key] : source[key];
7690 // prevent global pollution for namespaces
7691 exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
7692 // bind timers to global for call from export context
7693 : IS_BIND && own ? ctx(out, global)
7694 // wrap global constructors for prevent change them in library
7695 : IS_WRAP && target[key] == out ? (function (C) {
7696 var F = function (a, b, c) {
7697 if (this instanceof C) {
7698 switch (arguments.length) {
7699 case 0: return new C();
7700 case 1: return new C(a);
7701 case 2: return new C(a, b);
7702 } return new C(a, b, c);
7703 } return C.apply(this, arguments);
7704 };
7705 F[PROTOTYPE] = C[PROTOTYPE];
7706 return F;
7707 // make static versions for prototype methods
7708 })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
7709 // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
7710 if (IS_PROTO) {
7711 (exports.virtual || (exports.virtual = {}))[key] = out;
7712 // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
7713 if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);
7714 }
7715 }
7716};
7717// type bitmap
7718$export.F = 1; // forced
7719$export.G = 2; // global
7720$export.S = 4; // static
7721$export.P = 8; // proto
7722$export.B = 16; // bind
7723$export.W = 32; // wrap
7724$export.U = 64; // safe
7725$export.R = 128; // real proto method for `library`
7726module.exports = $export;
7727
7728},{"./_core":86,"./_ctx":88,"./_global":97,"./_has":98,"./_hide":99}],95:[function(require,module,exports){
7729module.exports = function (exec) {
7730 try {
7731 return !!exec();
7732 } catch (e) {
7733 return true;
7734 }
7735};
7736
7737},{}],96:[function(require,module,exports){
7738var ctx = require('./_ctx');
7739var call = require('./_iter-call');
7740var isArrayIter = require('./_is-array-iter');
7741var anObject = require('./_an-object');
7742var toLength = require('./_to-length');
7743var getIterFn = require('./core.get-iterator-method');
7744var BREAK = {};
7745var RETURN = {};
7746var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
7747 var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
7748 var f = ctx(fn, that, entries ? 2 : 1);
7749 var index = 0;
7750 var length, step, iterator, result;
7751 if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
7752 // fast case for arrays with default iterator
7753 if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
7754 result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
7755 if (result === BREAK || result === RETURN) return result;
7756 } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
7757 result = call(iterator, f, step.value, entries);
7758 if (result === BREAK || result === RETURN) return result;
7759 }
7760};
7761exports.BREAK = BREAK;
7762exports.RETURN = RETURN;
7763
7764},{"./_an-object":82,"./_ctx":88,"./_is-array-iter":104,"./_iter-call":107,"./_to-length":146,"./core.get-iterator-method":154}],97:[function(require,module,exports){
7765// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
7766var global = module.exports = typeof window != 'undefined' && window.Math == Math
7767 ? window : typeof self != 'undefined' && self.Math == Math ? self
7768 // eslint-disable-next-line no-new-func
7769 : Function('return this')();
7770if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
7771
7772},{}],98:[function(require,module,exports){
7773var hasOwnProperty = {}.hasOwnProperty;
7774module.exports = function (it, key) {
7775 return hasOwnProperty.call(it, key);
7776};
7777
7778},{}],99:[function(require,module,exports){
7779var dP = require('./_object-dp');
7780var createDesc = require('./_property-desc');
7781module.exports = require('./_descriptors') ? function (object, key, value) {
7782 return dP.f(object, key, createDesc(1, value));
7783} : function (object, key, value) {
7784 object[key] = value;
7785 return object;
7786};
7787
7788},{"./_descriptors":90,"./_object-dp":119,"./_property-desc":133}],100:[function(require,module,exports){
7789var document = require('./_global').document;
7790module.exports = document && document.documentElement;
7791
7792},{"./_global":97}],101:[function(require,module,exports){
7793module.exports = !require('./_descriptors') && !require('./_fails')(function () {
7794 return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;
7795});
7796
7797},{"./_descriptors":90,"./_dom-create":91,"./_fails":95}],102:[function(require,module,exports){
7798// fast apply, http://jsperf.lnkit.com/fast-apply/5
7799module.exports = function (fn, args, that) {
7800 var un = that === undefined;
7801 switch (args.length) {
7802 case 0: return un ? fn()
7803 : fn.call(that);
7804 case 1: return un ? fn(args[0])
7805 : fn.call(that, args[0]);
7806 case 2: return un ? fn(args[0], args[1])
7807 : fn.call(that, args[0], args[1]);
7808 case 3: return un ? fn(args[0], args[1], args[2])
7809 : fn.call(that, args[0], args[1], args[2]);
7810 case 4: return un ? fn(args[0], args[1], args[2], args[3])
7811 : fn.call(that, args[0], args[1], args[2], args[3]);
7812 } return fn.apply(that, args);
7813};
7814
7815},{}],103:[function(require,module,exports){
7816// fallback for non-array-like ES3 and non-enumerable old V8 strings
7817var cof = require('./_cof');
7818// eslint-disable-next-line no-prototype-builtins
7819module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
7820 return cof(it) == 'String' ? it.split('') : Object(it);
7821};
7822
7823},{"./_cof":85}],104:[function(require,module,exports){
7824// check on default Array iterator
7825var Iterators = require('./_iterators');
7826var ITERATOR = require('./_wks')('iterator');
7827var ArrayProto = Array.prototype;
7828
7829module.exports = function (it) {
7830 return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
7831};
7832
7833},{"./_iterators":112,"./_wks":153}],105:[function(require,module,exports){
7834// 7.2.2 IsArray(argument)
7835var cof = require('./_cof');
7836module.exports = Array.isArray || function isArray(arg) {
7837 return cof(arg) == 'Array';
7838};
7839
7840},{"./_cof":85}],106:[function(require,module,exports){
7841module.exports = function (it) {
7842 return typeof it === 'object' ? it !== null : typeof it === 'function';
7843};
7844
7845},{}],107:[function(require,module,exports){
7846// call something on iterator step with safe closing on error
7847var anObject = require('./_an-object');
7848module.exports = function (iterator, fn, value, entries) {
7849 try {
7850 return entries ? fn(anObject(value)[0], value[1]) : fn(value);
7851 // 7.4.6 IteratorClose(iterator, completion)
7852 } catch (e) {
7853 var ret = iterator['return'];
7854 if (ret !== undefined) anObject(ret.call(iterator));
7855 throw e;
7856 }
7857};
7858
7859},{"./_an-object":82}],108:[function(require,module,exports){
7860'use strict';
7861var create = require('./_object-create');
7862var descriptor = require('./_property-desc');
7863var setToStringTag = require('./_set-to-string-tag');
7864var IteratorPrototype = {};
7865
7866// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
7867require('./_hide')(IteratorPrototype, require('./_wks')('iterator'), function () { return this; });
7868
7869module.exports = function (Constructor, NAME, next) {
7870 Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
7871 setToStringTag(Constructor, NAME + ' Iterator');
7872};
7873
7874},{"./_hide":99,"./_object-create":118,"./_property-desc":133,"./_set-to-string-tag":137,"./_wks":153}],109:[function(require,module,exports){
7875'use strict';
7876var LIBRARY = require('./_library');
7877var $export = require('./_export');
7878var redefine = require('./_redefine');
7879var hide = require('./_hide');
7880var Iterators = require('./_iterators');
7881var $iterCreate = require('./_iter-create');
7882var setToStringTag = require('./_set-to-string-tag');
7883var getPrototypeOf = require('./_object-gpo');
7884var ITERATOR = require('./_wks')('iterator');
7885var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
7886var FF_ITERATOR = '@@iterator';
7887var KEYS = 'keys';
7888var VALUES = 'values';
7889
7890var returnThis = function () { return this; };
7891
7892module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
7893 $iterCreate(Constructor, NAME, next);
7894 var getMethod = function (kind) {
7895 if (!BUGGY && kind in proto) return proto[kind];
7896 switch (kind) {
7897 case KEYS: return function keys() { return new Constructor(this, kind); };
7898 case VALUES: return function values() { return new Constructor(this, kind); };
7899 } return function entries() { return new Constructor(this, kind); };
7900 };
7901 var TAG = NAME + ' Iterator';
7902 var DEF_VALUES = DEFAULT == VALUES;
7903 var VALUES_BUG = false;
7904 var proto = Base.prototype;
7905 var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
7906 var $default = $native || getMethod(DEFAULT);
7907 var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
7908 var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
7909 var methods, key, IteratorPrototype;
7910 // Fix native
7911 if ($anyNative) {
7912 IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
7913 if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
7914 // Set @@toStringTag to native iterators
7915 setToStringTag(IteratorPrototype, TAG, true);
7916 // fix for some old engines
7917 if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
7918 }
7919 }
7920 // fix Array#{values, @@iterator}.name in V8 / FF
7921 if (DEF_VALUES && $native && $native.name !== VALUES) {
7922 VALUES_BUG = true;
7923 $default = function values() { return $native.call(this); };
7924 }
7925 // Define iterator
7926 if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
7927 hide(proto, ITERATOR, $default);
7928 }
7929 // Plug for library
7930 Iterators[NAME] = $default;
7931 Iterators[TAG] = returnThis;
7932 if (DEFAULT) {
7933 methods = {
7934 values: DEF_VALUES ? $default : getMethod(VALUES),
7935 keys: IS_SET ? $default : getMethod(KEYS),
7936 entries: $entries
7937 };
7938 if (FORCED) for (key in methods) {
7939 if (!(key in proto)) redefine(proto, key, methods[key]);
7940 } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
7941 }
7942 return methods;
7943};
7944
7945},{"./_export":94,"./_hide":99,"./_iter-create":108,"./_iterators":112,"./_library":113,"./_object-gpo":125,"./_redefine":135,"./_set-to-string-tag":137,"./_wks":153}],110:[function(require,module,exports){
7946var ITERATOR = require('./_wks')('iterator');
7947var SAFE_CLOSING = false;
7948
7949try {
7950 var riter = [7][ITERATOR]();
7951 riter['return'] = function () { SAFE_CLOSING = true; };
7952 // eslint-disable-next-line no-throw-literal
7953 Array.from(riter, function () { throw 2; });
7954} catch (e) { /* empty */ }
7955
7956module.exports = function (exec, skipClosing) {
7957 if (!skipClosing && !SAFE_CLOSING) return false;
7958 var safe = false;
7959 try {
7960 var arr = [7];
7961 var iter = arr[ITERATOR]();
7962 iter.next = function () { return { done: safe = true }; };
7963 arr[ITERATOR] = function () { return iter; };
7964 exec(arr);
7965 } catch (e) { /* empty */ }
7966 return safe;
7967};
7968
7969},{"./_wks":153}],111:[function(require,module,exports){
7970module.exports = function (done, value) {
7971 return { value: value, done: !!done };
7972};
7973
7974},{}],112:[function(require,module,exports){
7975module.exports = {};
7976
7977},{}],113:[function(require,module,exports){
7978module.exports = true;
7979
7980},{}],114:[function(require,module,exports){
7981var META = require('./_uid')('meta');
7982var isObject = require('./_is-object');
7983var has = require('./_has');
7984var setDesc = require('./_object-dp').f;
7985var id = 0;
7986var isExtensible = Object.isExtensible || function () {
7987 return true;
7988};
7989var FREEZE = !require('./_fails')(function () {
7990 return isExtensible(Object.preventExtensions({}));
7991});
7992var setMeta = function (it) {
7993 setDesc(it, META, { value: {
7994 i: 'O' + ++id, // object ID
7995 w: {} // weak collections IDs
7996 } });
7997};
7998var fastKey = function (it, create) {
7999 // return primitive with prefix
8000 if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
8001 if (!has(it, META)) {
8002 // can't set metadata to uncaught frozen object
8003 if (!isExtensible(it)) return 'F';
8004 // not necessary to add metadata
8005 if (!create) return 'E';
8006 // add missing metadata
8007 setMeta(it);
8008 // return object ID
8009 } return it[META].i;
8010};
8011var getWeak = function (it, create) {
8012 if (!has(it, META)) {
8013 // can't set metadata to uncaught frozen object
8014 if (!isExtensible(it)) return true;
8015 // not necessary to add metadata
8016 if (!create) return false;
8017 // add missing metadata
8018 setMeta(it);
8019 // return hash weak collections IDs
8020 } return it[META].w;
8021};
8022// add metadata on freeze-family methods calling
8023var onFreeze = function (it) {
8024 if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
8025 return it;
8026};
8027var meta = module.exports = {
8028 KEY: META,
8029 NEED: false,
8030 fastKey: fastKey,
8031 getWeak: getWeak,
8032 onFreeze: onFreeze
8033};
8034
8035},{"./_fails":95,"./_has":98,"./_is-object":106,"./_object-dp":119,"./_uid":149}],115:[function(require,module,exports){
8036var global = require('./_global');
8037var macrotask = require('./_task').set;
8038var Observer = global.MutationObserver || global.WebKitMutationObserver;
8039var process = global.process;
8040var Promise = global.Promise;
8041var isNode = require('./_cof')(process) == 'process';
8042
8043module.exports = function () {
8044 var head, last, notify;
8045
8046 var flush = function () {
8047 var parent, fn;
8048 if (isNode && (parent = process.domain)) parent.exit();
8049 while (head) {
8050 fn = head.fn;
8051 head = head.next;
8052 try {
8053 fn();
8054 } catch (e) {
8055 if (head) notify();
8056 else last = undefined;
8057 throw e;
8058 }
8059 } last = undefined;
8060 if (parent) parent.enter();
8061 };
8062
8063 // Node.js
8064 if (isNode) {
8065 notify = function () {
8066 process.nextTick(flush);
8067 };
8068 // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
8069 } else if (Observer && !(global.navigator && global.navigator.standalone)) {
8070 var toggle = true;
8071 var node = document.createTextNode('');
8072 new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
8073 notify = function () {
8074 node.data = toggle = !toggle;
8075 };
8076 // environments with maybe non-completely correct, but existent Promise
8077 } else if (Promise && Promise.resolve) {
8078 // Promise.resolve without an argument throws an error in LG WebOS 2
8079 var promise = Promise.resolve(undefined);
8080 notify = function () {
8081 promise.then(flush);
8082 };
8083 // for other environments - macrotask based on:
8084 // - setImmediate
8085 // - MessageChannel
8086 // - window.postMessag
8087 // - onreadystatechange
8088 // - setTimeout
8089 } else {
8090 notify = function () {
8091 // strange IE + webpack dev server bug - use .call(global)
8092 macrotask.call(global, flush);
8093 };
8094 }
8095
8096 return function (fn) {
8097 var task = { fn: fn, next: undefined };
8098 if (last) last.next = task;
8099 if (!head) {
8100 head = task;
8101 notify();
8102 } last = task;
8103 };
8104};
8105
8106},{"./_cof":85,"./_global":97,"./_task":142}],116:[function(require,module,exports){
8107'use strict';
8108// 25.4.1.5 NewPromiseCapability(C)
8109var aFunction = require('./_a-function');
8110
8111function PromiseCapability(C) {
8112 var resolve, reject;
8113 this.promise = new C(function ($$resolve, $$reject) {
8114 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
8115 resolve = $$resolve;
8116 reject = $$reject;
8117 });
8118 this.resolve = aFunction(resolve);
8119 this.reject = aFunction(reject);
8120}
8121
8122module.exports.f = function (C) {
8123 return new PromiseCapability(C);
8124};
8125
8126},{"./_a-function":79}],117:[function(require,module,exports){
8127'use strict';
8128// 19.1.2.1 Object.assign(target, source, ...)
8129var getKeys = require('./_object-keys');
8130var gOPS = require('./_object-gops');
8131var pIE = require('./_object-pie');
8132var toObject = require('./_to-object');
8133var IObject = require('./_iobject');
8134var $assign = Object.assign;
8135
8136// should work with symbols and should have deterministic property order (V8 bug)
8137module.exports = !$assign || require('./_fails')(function () {
8138 var A = {};
8139 var B = {};
8140 // eslint-disable-next-line no-undef
8141 var S = Symbol();
8142 var K = 'abcdefghijklmnopqrst';
8143 A[S] = 7;
8144 K.split('').forEach(function (k) { B[k] = k; });
8145 return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
8146}) ? function assign(target, source) { // eslint-disable-line no-unused-vars
8147 var T = toObject(target);
8148 var aLen = arguments.length;
8149 var index = 1;
8150 var getSymbols = gOPS.f;
8151 var isEnum = pIE.f;
8152 while (aLen > index) {
8153 var S = IObject(arguments[index++]);
8154 var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
8155 var length = keys.length;
8156 var j = 0;
8157 var key;
8158 while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
8159 } return T;
8160} : $assign;
8161
8162},{"./_fails":95,"./_iobject":103,"./_object-gops":124,"./_object-keys":127,"./_object-pie":128,"./_to-object":147}],118:[function(require,module,exports){
8163// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
8164var anObject = require('./_an-object');
8165var dPs = require('./_object-dps');
8166var enumBugKeys = require('./_enum-bug-keys');
8167var IE_PROTO = require('./_shared-key')('IE_PROTO');
8168var Empty = function () { /* empty */ };
8169var PROTOTYPE = 'prototype';
8170
8171// Create object with fake `null` prototype: use iframe Object with cleared prototype
8172var createDict = function () {
8173 // Thrash, waste and sodomy: IE GC bug
8174 var iframe = require('./_dom-create')('iframe');
8175 var i = enumBugKeys.length;
8176 var lt = '<';
8177 var gt = '>';
8178 var iframeDocument;
8179 iframe.style.display = 'none';
8180 require('./_html').appendChild(iframe);
8181 iframe.src = 'javascript:'; // eslint-disable-line no-script-url
8182 // createDict = iframe.contentWindow.Object;
8183 // html.removeChild(iframe);
8184 iframeDocument = iframe.contentWindow.document;
8185 iframeDocument.open();
8186 iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
8187 iframeDocument.close();
8188 createDict = iframeDocument.F;
8189 while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
8190 return createDict();
8191};
8192
8193module.exports = Object.create || function create(O, Properties) {
8194 var result;
8195 if (O !== null) {
8196 Empty[PROTOTYPE] = anObject(O);
8197 result = new Empty();
8198 Empty[PROTOTYPE] = null;
8199 // add "__proto__" for Object.getPrototypeOf polyfill
8200 result[IE_PROTO] = O;
8201 } else result = createDict();
8202 return Properties === undefined ? result : dPs(result, Properties);
8203};
8204
8205},{"./_an-object":82,"./_dom-create":91,"./_enum-bug-keys":92,"./_html":100,"./_object-dps":120,"./_shared-key":138}],119:[function(require,module,exports){
8206var anObject = require('./_an-object');
8207var IE8_DOM_DEFINE = require('./_ie8-dom-define');
8208var toPrimitive = require('./_to-primitive');
8209var dP = Object.defineProperty;
8210
8211exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
8212 anObject(O);
8213 P = toPrimitive(P, true);
8214 anObject(Attributes);
8215 if (IE8_DOM_DEFINE) try {
8216 return dP(O, P, Attributes);
8217 } catch (e) { /* empty */ }
8218 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
8219 if ('value' in Attributes) O[P] = Attributes.value;
8220 return O;
8221};
8222
8223},{"./_an-object":82,"./_descriptors":90,"./_ie8-dom-define":101,"./_to-primitive":148}],120:[function(require,module,exports){
8224var dP = require('./_object-dp');
8225var anObject = require('./_an-object');
8226var getKeys = require('./_object-keys');
8227
8228module.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {
8229 anObject(O);
8230 var keys = getKeys(Properties);
8231 var length = keys.length;
8232 var i = 0;
8233 var P;
8234 while (length > i) dP.f(O, P = keys[i++], Properties[P]);
8235 return O;
8236};
8237
8238},{"./_an-object":82,"./_descriptors":90,"./_object-dp":119,"./_object-keys":127}],121:[function(require,module,exports){
8239var pIE = require('./_object-pie');
8240var createDesc = require('./_property-desc');
8241var toIObject = require('./_to-iobject');
8242var toPrimitive = require('./_to-primitive');
8243var has = require('./_has');
8244var IE8_DOM_DEFINE = require('./_ie8-dom-define');
8245var gOPD = Object.getOwnPropertyDescriptor;
8246
8247exports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor(O, P) {
8248 O = toIObject(O);
8249 P = toPrimitive(P, true);
8250 if (IE8_DOM_DEFINE) try {
8251 return gOPD(O, P);
8252 } catch (e) { /* empty */ }
8253 if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
8254};
8255
8256},{"./_descriptors":90,"./_has":98,"./_ie8-dom-define":101,"./_object-pie":128,"./_property-desc":133,"./_to-iobject":145,"./_to-primitive":148}],122:[function(require,module,exports){
8257// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
8258var toIObject = require('./_to-iobject');
8259var gOPN = require('./_object-gopn').f;
8260var toString = {}.toString;
8261
8262var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
8263 ? Object.getOwnPropertyNames(window) : [];
8264
8265var getWindowNames = function (it) {
8266 try {
8267 return gOPN(it);
8268 } catch (e) {
8269 return windowNames.slice();
8270 }
8271};
8272
8273module.exports.f = function getOwnPropertyNames(it) {
8274 return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
8275};
8276
8277},{"./_object-gopn":123,"./_to-iobject":145}],123:[function(require,module,exports){
8278// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
8279var $keys = require('./_object-keys-internal');
8280var hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype');
8281
8282exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
8283 return $keys(O, hiddenKeys);
8284};
8285
8286},{"./_enum-bug-keys":92,"./_object-keys-internal":126}],124:[function(require,module,exports){
8287exports.f = Object.getOwnPropertySymbols;
8288
8289},{}],125:[function(require,module,exports){
8290// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
8291var has = require('./_has');
8292var toObject = require('./_to-object');
8293var IE_PROTO = require('./_shared-key')('IE_PROTO');
8294var ObjectProto = Object.prototype;
8295
8296module.exports = Object.getPrototypeOf || function (O) {
8297 O = toObject(O);
8298 if (has(O, IE_PROTO)) return O[IE_PROTO];
8299 if (typeof O.constructor == 'function' && O instanceof O.constructor) {
8300 return O.constructor.prototype;
8301 } return O instanceof Object ? ObjectProto : null;
8302};
8303
8304},{"./_has":98,"./_shared-key":138,"./_to-object":147}],126:[function(require,module,exports){
8305var has = require('./_has');
8306var toIObject = require('./_to-iobject');
8307var arrayIndexOf = require('./_array-includes')(false);
8308var IE_PROTO = require('./_shared-key')('IE_PROTO');
8309
8310module.exports = function (object, names) {
8311 var O = toIObject(object);
8312 var i = 0;
8313 var result = [];
8314 var key;
8315 for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
8316 // Don't enum bug & hidden keys
8317 while (names.length > i) if (has(O, key = names[i++])) {
8318 ~arrayIndexOf(result, key) || result.push(key);
8319 }
8320 return result;
8321};
8322
8323},{"./_array-includes":83,"./_has":98,"./_shared-key":138,"./_to-iobject":145}],127:[function(require,module,exports){
8324// 19.1.2.14 / 15.2.3.14 Object.keys(O)
8325var $keys = require('./_object-keys-internal');
8326var enumBugKeys = require('./_enum-bug-keys');
8327
8328module.exports = Object.keys || function keys(O) {
8329 return $keys(O, enumBugKeys);
8330};
8331
8332},{"./_enum-bug-keys":92,"./_object-keys-internal":126}],128:[function(require,module,exports){
8333exports.f = {}.propertyIsEnumerable;
8334
8335},{}],129:[function(require,module,exports){
8336// most Object methods by ES6 should accept primitives
8337var $export = require('./_export');
8338var core = require('./_core');
8339var fails = require('./_fails');
8340module.exports = function (KEY, exec) {
8341 var fn = (core.Object || {})[KEY] || Object[KEY];
8342 var exp = {};
8343 exp[KEY] = exec(fn);
8344 $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
8345};
8346
8347},{"./_core":86,"./_export":94,"./_fails":95}],130:[function(require,module,exports){
8348var getKeys = require('./_object-keys');
8349var toIObject = require('./_to-iobject');
8350var isEnum = require('./_object-pie').f;
8351module.exports = function (isEntries) {
8352 return function (it) {
8353 var O = toIObject(it);
8354 var keys = getKeys(O);
8355 var length = keys.length;
8356 var i = 0;
8357 var result = [];
8358 var key;
8359 while (length > i) if (isEnum.call(O, key = keys[i++])) {
8360 result.push(isEntries ? [key, O[key]] : O[key]);
8361 } return result;
8362 };
8363};
8364
8365},{"./_object-keys":127,"./_object-pie":128,"./_to-iobject":145}],131:[function(require,module,exports){
8366module.exports = function (exec) {
8367 try {
8368 return { e: false, v: exec() };
8369 } catch (e) {
8370 return { e: true, v: e };
8371 }
8372};
8373
8374},{}],132:[function(require,module,exports){
8375var anObject = require('./_an-object');
8376var isObject = require('./_is-object');
8377var newPromiseCapability = require('./_new-promise-capability');
8378
8379module.exports = function (C, x) {
8380 anObject(C);
8381 if (isObject(x) && x.constructor === C) return x;
8382 var promiseCapability = newPromiseCapability.f(C);
8383 var resolve = promiseCapability.resolve;
8384 resolve(x);
8385 return promiseCapability.promise;
8386};
8387
8388},{"./_an-object":82,"./_is-object":106,"./_new-promise-capability":116}],133:[function(require,module,exports){
8389module.exports = function (bitmap, value) {
8390 return {
8391 enumerable: !(bitmap & 1),
8392 configurable: !(bitmap & 2),
8393 writable: !(bitmap & 4),
8394 value: value
8395 };
8396};
8397
8398},{}],134:[function(require,module,exports){
8399var hide = require('./_hide');
8400module.exports = function (target, src, safe) {
8401 for (var key in src) {
8402 if (safe && target[key]) target[key] = src[key];
8403 else hide(target, key, src[key]);
8404 } return target;
8405};
8406
8407},{"./_hide":99}],135:[function(require,module,exports){
8408module.exports = require('./_hide');
8409
8410},{"./_hide":99}],136:[function(require,module,exports){
8411'use strict';
8412var global = require('./_global');
8413var core = require('./_core');
8414var dP = require('./_object-dp');
8415var DESCRIPTORS = require('./_descriptors');
8416var SPECIES = require('./_wks')('species');
8417
8418module.exports = function (KEY) {
8419 var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY];
8420 if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
8421 configurable: true,
8422 get: function () { return this; }
8423 });
8424};
8425
8426},{"./_core":86,"./_descriptors":90,"./_global":97,"./_object-dp":119,"./_wks":153}],137:[function(require,module,exports){
8427var def = require('./_object-dp').f;
8428var has = require('./_has');
8429var TAG = require('./_wks')('toStringTag');
8430
8431module.exports = function (it, tag, stat) {
8432 if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
8433};
8434
8435},{"./_has":98,"./_object-dp":119,"./_wks":153}],138:[function(require,module,exports){
8436var shared = require('./_shared')('keys');
8437var uid = require('./_uid');
8438module.exports = function (key) {
8439 return shared[key] || (shared[key] = uid(key));
8440};
8441
8442},{"./_shared":139,"./_uid":149}],139:[function(require,module,exports){
8443var core = require('./_core');
8444var global = require('./_global');
8445var SHARED = '__core-js_shared__';
8446var store = global[SHARED] || (global[SHARED] = {});
8447
8448(module.exports = function (key, value) {
8449 return store[key] || (store[key] = value !== undefined ? value : {});
8450})('versions', []).push({
8451 version: core.version,
8452 mode: require('./_library') ? 'pure' : 'global',
8453 copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
8454});
8455
8456},{"./_core":86,"./_global":97,"./_library":113}],140:[function(require,module,exports){
8457// 7.3.20 SpeciesConstructor(O, defaultConstructor)
8458var anObject = require('./_an-object');
8459var aFunction = require('./_a-function');
8460var SPECIES = require('./_wks')('species');
8461module.exports = function (O, D) {
8462 var C = anObject(O).constructor;
8463 var S;
8464 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
8465};
8466
8467},{"./_a-function":79,"./_an-object":82,"./_wks":153}],141:[function(require,module,exports){
8468var toInteger = require('./_to-integer');
8469var defined = require('./_defined');
8470// true -> String#at
8471// false -> String#codePointAt
8472module.exports = function (TO_STRING) {
8473 return function (that, pos) {
8474 var s = String(defined(that));
8475 var i = toInteger(pos);
8476 var l = s.length;
8477 var a, b;
8478 if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
8479 a = s.charCodeAt(i);
8480 return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
8481 ? TO_STRING ? s.charAt(i) : a
8482 : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
8483 };
8484};
8485
8486},{"./_defined":89,"./_to-integer":144}],142:[function(require,module,exports){
8487var ctx = require('./_ctx');
8488var invoke = require('./_invoke');
8489var html = require('./_html');
8490var cel = require('./_dom-create');
8491var global = require('./_global');
8492var process = global.process;
8493var setTask = global.setImmediate;
8494var clearTask = global.clearImmediate;
8495var MessageChannel = global.MessageChannel;
8496var Dispatch = global.Dispatch;
8497var counter = 0;
8498var queue = {};
8499var ONREADYSTATECHANGE = 'onreadystatechange';
8500var defer, channel, port;
8501var run = function () {
8502 var id = +this;
8503 // eslint-disable-next-line no-prototype-builtins
8504 if (queue.hasOwnProperty(id)) {
8505 var fn = queue[id];
8506 delete queue[id];
8507 fn();
8508 }
8509};
8510var listener = function (event) {
8511 run.call(event.data);
8512};
8513// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
8514if (!setTask || !clearTask) {
8515 setTask = function setImmediate(fn) {
8516 var args = [];
8517 var i = 1;
8518 while (arguments.length > i) args.push(arguments[i++]);
8519 queue[++counter] = function () {
8520 // eslint-disable-next-line no-new-func
8521 invoke(typeof fn == 'function' ? fn : Function(fn), args);
8522 };
8523 defer(counter);
8524 return counter;
8525 };
8526 clearTask = function clearImmediate(id) {
8527 delete queue[id];
8528 };
8529 // Node.js 0.8-
8530 if (require('./_cof')(process) == 'process') {
8531 defer = function (id) {
8532 process.nextTick(ctx(run, id, 1));
8533 };
8534 // Sphere (JS game engine) Dispatch API
8535 } else if (Dispatch && Dispatch.now) {
8536 defer = function (id) {
8537 Dispatch.now(ctx(run, id, 1));
8538 };
8539 // Browsers with MessageChannel, includes WebWorkers
8540 } else if (MessageChannel) {
8541 channel = new MessageChannel();
8542 port = channel.port2;
8543 channel.port1.onmessage = listener;
8544 defer = ctx(port.postMessage, port, 1);
8545 // Browsers with postMessage, skip WebWorkers
8546 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
8547 } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
8548 defer = function (id) {
8549 global.postMessage(id + '', '*');
8550 };
8551 global.addEventListener('message', listener, false);
8552 // IE8-
8553 } else if (ONREADYSTATECHANGE in cel('script')) {
8554 defer = function (id) {
8555 html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
8556 html.removeChild(this);
8557 run.call(id);
8558 };
8559 };
8560 // Rest old browsers
8561 } else {
8562 defer = function (id) {
8563 setTimeout(ctx(run, id, 1), 0);
8564 };
8565 }
8566}
8567module.exports = {
8568 set: setTask,
8569 clear: clearTask
8570};
8571
8572},{"./_cof":85,"./_ctx":88,"./_dom-create":91,"./_global":97,"./_html":100,"./_invoke":102}],143:[function(require,module,exports){
8573var toInteger = require('./_to-integer');
8574var max = Math.max;
8575var min = Math.min;
8576module.exports = function (index, length) {
8577 index = toInteger(index);
8578 return index < 0 ? max(index + length, 0) : min(index, length);
8579};
8580
8581},{"./_to-integer":144}],144:[function(require,module,exports){
8582// 7.1.4 ToInteger
8583var ceil = Math.ceil;
8584var floor = Math.floor;
8585module.exports = function (it) {
8586 return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
8587};
8588
8589},{}],145:[function(require,module,exports){
8590// to indexed object, toObject with fallback for non-array-like ES3 strings
8591var IObject = require('./_iobject');
8592var defined = require('./_defined');
8593module.exports = function (it) {
8594 return IObject(defined(it));
8595};
8596
8597},{"./_defined":89,"./_iobject":103}],146:[function(require,module,exports){
8598// 7.1.15 ToLength
8599var toInteger = require('./_to-integer');
8600var min = Math.min;
8601module.exports = function (it) {
8602 return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
8603};
8604
8605},{"./_to-integer":144}],147:[function(require,module,exports){
8606// 7.1.13 ToObject(argument)
8607var defined = require('./_defined');
8608module.exports = function (it) {
8609 return Object(defined(it));
8610};
8611
8612},{"./_defined":89}],148:[function(require,module,exports){
8613// 7.1.1 ToPrimitive(input [, PreferredType])
8614var isObject = require('./_is-object');
8615// instead of the ES6 spec version, we didn't implement @@toPrimitive case
8616// and the second argument - flag - preferred type is a string
8617module.exports = function (it, S) {
8618 if (!isObject(it)) return it;
8619 var fn, val;
8620 if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
8621 if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
8622 if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
8623 throw TypeError("Can't convert object to primitive value");
8624};
8625
8626},{"./_is-object":106}],149:[function(require,module,exports){
8627var id = 0;
8628var px = Math.random();
8629module.exports = function (key) {
8630 return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
8631};
8632
8633},{}],150:[function(require,module,exports){
8634var global = require('./_global');
8635var navigator = global.navigator;
8636
8637module.exports = navigator && navigator.userAgent || '';
8638
8639},{"./_global":97}],151:[function(require,module,exports){
8640var global = require('./_global');
8641var core = require('./_core');
8642var LIBRARY = require('./_library');
8643var wksExt = require('./_wks-ext');
8644var defineProperty = require('./_object-dp').f;
8645module.exports = function (name) {
8646 var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
8647 if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
8648};
8649
8650},{"./_core":86,"./_global":97,"./_library":113,"./_object-dp":119,"./_wks-ext":152}],152:[function(require,module,exports){
8651exports.f = require('./_wks');
8652
8653},{"./_wks":153}],153:[function(require,module,exports){
8654var store = require('./_shared')('wks');
8655var uid = require('./_uid');
8656var Symbol = require('./_global').Symbol;
8657var USE_SYMBOL = typeof Symbol == 'function';
8658
8659var $exports = module.exports = function (name) {
8660 return store[name] || (store[name] =
8661 USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
8662};
8663
8664$exports.store = store;
8665
8666},{"./_global":97,"./_shared":139,"./_uid":149}],154:[function(require,module,exports){
8667var classof = require('./_classof');
8668var ITERATOR = require('./_wks')('iterator');
8669var Iterators = require('./_iterators');
8670module.exports = require('./_core').getIteratorMethod = function (it) {
8671 if (it != undefined) return it[ITERATOR]
8672 || it['@@iterator']
8673 || Iterators[classof(it)];
8674};
8675
8676},{"./_classof":84,"./_core":86,"./_iterators":112,"./_wks":153}],155:[function(require,module,exports){
8677'use strict';
8678var ctx = require('./_ctx');
8679var $export = require('./_export');
8680var toObject = require('./_to-object');
8681var call = require('./_iter-call');
8682var isArrayIter = require('./_is-array-iter');
8683var toLength = require('./_to-length');
8684var createProperty = require('./_create-property');
8685var getIterFn = require('./core.get-iterator-method');
8686
8687$export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Array.from(iter); }), 'Array', {
8688 // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
8689 from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
8690 var O = toObject(arrayLike);
8691 var C = typeof this == 'function' ? this : Array;
8692 var aLen = arguments.length;
8693 var mapfn = aLen > 1 ? arguments[1] : undefined;
8694 var mapping = mapfn !== undefined;
8695 var index = 0;
8696 var iterFn = getIterFn(O);
8697 var length, result, step, iterator;
8698 if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
8699 // if object isn't iterable or it's array with default iterator - use simple case
8700 if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
8701 for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
8702 createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
8703 }
8704 } else {
8705 length = toLength(O.length);
8706 for (result = new C(length); length > index; index++) {
8707 createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
8708 }
8709 }
8710 result.length = index;
8711 return result;
8712 }
8713});
8714
8715},{"./_create-property":87,"./_ctx":88,"./_export":94,"./_is-array-iter":104,"./_iter-call":107,"./_iter-detect":110,"./_to-length":146,"./_to-object":147,"./core.get-iterator-method":154}],156:[function(require,module,exports){
8716'use strict';
8717var addToUnscopables = require('./_add-to-unscopables');
8718var step = require('./_iter-step');
8719var Iterators = require('./_iterators');
8720var toIObject = require('./_to-iobject');
8721
8722// 22.1.3.4 Array.prototype.entries()
8723// 22.1.3.13 Array.prototype.keys()
8724// 22.1.3.29 Array.prototype.values()
8725// 22.1.3.30 Array.prototype[@@iterator]()
8726module.exports = require('./_iter-define')(Array, 'Array', function (iterated, kind) {
8727 this._t = toIObject(iterated); // target
8728 this._i = 0; // next index
8729 this._k = kind; // kind
8730// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
8731}, function () {
8732 var O = this._t;
8733 var kind = this._k;
8734 var index = this._i++;
8735 if (!O || index >= O.length) {
8736 this._t = undefined;
8737 return step(1);
8738 }
8739 if (kind == 'keys') return step(0, index);
8740 if (kind == 'values') return step(0, O[index]);
8741 return step(0, [index, O[index]]);
8742}, 'values');
8743
8744// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
8745Iterators.Arguments = Iterators.Array;
8746
8747addToUnscopables('keys');
8748addToUnscopables('values');
8749addToUnscopables('entries');
8750
8751},{"./_add-to-unscopables":80,"./_iter-define":109,"./_iter-step":111,"./_iterators":112,"./_to-iobject":145}],157:[function(require,module,exports){
8752'use strict';
8753var isObject = require('./_is-object');
8754var getPrototypeOf = require('./_object-gpo');
8755var HAS_INSTANCE = require('./_wks')('hasInstance');
8756var FunctionProto = Function.prototype;
8757// 19.2.3.6 Function.prototype[@@hasInstance](V)
8758if (!(HAS_INSTANCE in FunctionProto)) require('./_object-dp').f(FunctionProto, HAS_INSTANCE, { value: function (O) {
8759 if (typeof this != 'function' || !isObject(O)) return false;
8760 if (!isObject(this.prototype)) return O instanceof this;
8761 // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
8762 while (O = getPrototypeOf(O)) if (this.prototype === O) return true;
8763 return false;
8764} });
8765
8766},{"./_is-object":106,"./_object-dp":119,"./_object-gpo":125,"./_wks":153}],158:[function(require,module,exports){
8767// 19.1.3.1 Object.assign(target, source)
8768var $export = require('./_export');
8769
8770$export($export.S + $export.F, 'Object', { assign: require('./_object-assign') });
8771
8772},{"./_export":94,"./_object-assign":117}],159:[function(require,module,exports){
8773var $export = require('./_export');
8774// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
8775$export($export.S, 'Object', { create: require('./_object-create') });
8776
8777},{"./_export":94,"./_object-create":118}],160:[function(require,module,exports){
8778var $export = require('./_export');
8779// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
8780$export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f });
8781
8782},{"./_descriptors":90,"./_export":94,"./_object-dp":119}],161:[function(require,module,exports){
8783// 19.1.2.7 Object.getOwnPropertyNames(O)
8784require('./_object-sap')('getOwnPropertyNames', function () {
8785 return require('./_object-gopn-ext').f;
8786});
8787
8788},{"./_object-gopn-ext":122,"./_object-sap":129}],162:[function(require,module,exports){
8789// 19.1.2.9 Object.getPrototypeOf(O)
8790var toObject = require('./_to-object');
8791var $getPrototypeOf = require('./_object-gpo');
8792
8793require('./_object-sap')('getPrototypeOf', function () {
8794 return function getPrototypeOf(it) {
8795 return $getPrototypeOf(toObject(it));
8796 };
8797});
8798
8799},{"./_object-gpo":125,"./_object-sap":129,"./_to-object":147}],163:[function(require,module,exports){
8800// 19.1.2.14 Object.keys(O)
8801var toObject = require('./_to-object');
8802var $keys = require('./_object-keys');
8803
8804require('./_object-sap')('keys', function () {
8805 return function keys(it) {
8806 return $keys(toObject(it));
8807 };
8808});
8809
8810},{"./_object-keys":127,"./_object-sap":129,"./_to-object":147}],164:[function(require,module,exports){
8811arguments[4][58][0].apply(exports,arguments)
8812},{"dup":58}],165:[function(require,module,exports){
8813'use strict';
8814var LIBRARY = require('./_library');
8815var global = require('./_global');
8816var ctx = require('./_ctx');
8817var classof = require('./_classof');
8818var $export = require('./_export');
8819var isObject = require('./_is-object');
8820var aFunction = require('./_a-function');
8821var anInstance = require('./_an-instance');
8822var forOf = require('./_for-of');
8823var speciesConstructor = require('./_species-constructor');
8824var task = require('./_task').set;
8825var microtask = require('./_microtask')();
8826var newPromiseCapabilityModule = require('./_new-promise-capability');
8827var perform = require('./_perform');
8828var userAgent = require('./_user-agent');
8829var promiseResolve = require('./_promise-resolve');
8830var PROMISE = 'Promise';
8831var TypeError = global.TypeError;
8832var process = global.process;
8833var versions = process && process.versions;
8834var v8 = versions && versions.v8 || '';
8835var $Promise = global[PROMISE];
8836var isNode = classof(process) == 'process';
8837var empty = function () { /* empty */ };
8838var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
8839var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
8840
8841var USE_NATIVE = !!function () {
8842 try {
8843 // correct subclassing with @@species support
8844 var promise = $Promise.resolve(1);
8845 var FakePromise = (promise.constructor = {})[require('./_wks')('species')] = function (exec) {
8846 exec(empty, empty);
8847 };
8848 // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
8849 return (isNode || typeof PromiseRejectionEvent == 'function')
8850 && promise.then(empty) instanceof FakePromise
8851 // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
8852 // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
8853 // we can't detect it synchronously, so just check versions
8854 && v8.indexOf('6.6') !== 0
8855 && userAgent.indexOf('Chrome/66') === -1;
8856 } catch (e) { /* empty */ }
8857}();
8858
8859// helpers
8860var isThenable = function (it) {
8861 var then;
8862 return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
8863};
8864var notify = function (promise, isReject) {
8865 if (promise._n) return;
8866 promise._n = true;
8867 var chain = promise._c;
8868 microtask(function () {
8869 var value = promise._v;
8870 var ok = promise._s == 1;
8871 var i = 0;
8872 var run = function (reaction) {
8873 var handler = ok ? reaction.ok : reaction.fail;
8874 var resolve = reaction.resolve;
8875 var reject = reaction.reject;
8876 var domain = reaction.domain;
8877 var result, then, exited;
8878 try {
8879 if (handler) {
8880 if (!ok) {
8881 if (promise._h == 2) onHandleUnhandled(promise);
8882 promise._h = 1;
8883 }
8884 if (handler === true) result = value;
8885 else {
8886 if (domain) domain.enter();
8887 result = handler(value); // may throw
8888 if (domain) {
8889 domain.exit();
8890 exited = true;
8891 }
8892 }
8893 if (result === reaction.promise) {
8894 reject(TypeError('Promise-chain cycle'));
8895 } else if (then = isThenable(result)) {
8896 then.call(result, resolve, reject);
8897 } else resolve(result);
8898 } else reject(value);
8899 } catch (e) {
8900 if (domain && !exited) domain.exit();
8901 reject(e);
8902 }
8903 };
8904 while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
8905 promise._c = [];
8906 promise._n = false;
8907 if (isReject && !promise._h) onUnhandled(promise);
8908 });
8909};
8910var onUnhandled = function (promise) {
8911 task.call(global, function () {
8912 var value = promise._v;
8913 var unhandled = isUnhandled(promise);
8914 var result, handler, console;
8915 if (unhandled) {
8916 result = perform(function () {
8917 if (isNode) {
8918 process.emit('unhandledRejection', value, promise);
8919 } else if (handler = global.onunhandledrejection) {
8920 handler({ promise: promise, reason: value });
8921 } else if ((console = global.console) && console.error) {
8922 console.error('Unhandled promise rejection', value);
8923 }
8924 });
8925 // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
8926 promise._h = isNode || isUnhandled(promise) ? 2 : 1;
8927 } promise._a = undefined;
8928 if (unhandled && result.e) throw result.v;
8929 });
8930};
8931var isUnhandled = function (promise) {
8932 return promise._h !== 1 && (promise._a || promise._c).length === 0;
8933};
8934var onHandleUnhandled = function (promise) {
8935 task.call(global, function () {
8936 var handler;
8937 if (isNode) {
8938 process.emit('rejectionHandled', promise);
8939 } else if (handler = global.onrejectionhandled) {
8940 handler({ promise: promise, reason: promise._v });
8941 }
8942 });
8943};
8944var $reject = function (value) {
8945 var promise = this;
8946 if (promise._d) return;
8947 promise._d = true;
8948 promise = promise._w || promise; // unwrap
8949 promise._v = value;
8950 promise._s = 2;
8951 if (!promise._a) promise._a = promise._c.slice();
8952 notify(promise, true);
8953};
8954var $resolve = function (value) {
8955 var promise = this;
8956 var then;
8957 if (promise._d) return;
8958 promise._d = true;
8959 promise = promise._w || promise; // unwrap
8960 try {
8961 if (promise === value) throw TypeError("Promise can't be resolved itself");
8962 if (then = isThenable(value)) {
8963 microtask(function () {
8964 var wrapper = { _w: promise, _d: false }; // wrap
8965 try {
8966 then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
8967 } catch (e) {
8968 $reject.call(wrapper, e);
8969 }
8970 });
8971 } else {
8972 promise._v = value;
8973 promise._s = 1;
8974 notify(promise, false);
8975 }
8976 } catch (e) {
8977 $reject.call({ _w: promise, _d: false }, e); // wrap
8978 }
8979};
8980
8981// constructor polyfill
8982if (!USE_NATIVE) {
8983 // 25.4.3.1 Promise(executor)
8984 $Promise = function Promise(executor) {
8985 anInstance(this, $Promise, PROMISE, '_h');
8986 aFunction(executor);
8987 Internal.call(this);
8988 try {
8989 executor(ctx($resolve, this, 1), ctx($reject, this, 1));
8990 } catch (err) {
8991 $reject.call(this, err);
8992 }
8993 };
8994 // eslint-disable-next-line no-unused-vars
8995 Internal = function Promise(executor) {
8996 this._c = []; // <- awaiting reactions
8997 this._a = undefined; // <- checked in isUnhandled reactions
8998 this._s = 0; // <- state
8999 this._d = false; // <- done
9000 this._v = undefined; // <- value
9001 this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
9002 this._n = false; // <- notify
9003 };
9004 Internal.prototype = require('./_redefine-all')($Promise.prototype, {
9005 // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
9006 then: function then(onFulfilled, onRejected) {
9007 var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
9008 reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
9009 reaction.fail = typeof onRejected == 'function' && onRejected;
9010 reaction.domain = isNode ? process.domain : undefined;
9011 this._c.push(reaction);
9012 if (this._a) this._a.push(reaction);
9013 if (this._s) notify(this, false);
9014 return reaction.promise;
9015 },
9016 // 25.4.5.1 Promise.prototype.catch(onRejected)
9017 'catch': function (onRejected) {
9018 return this.then(undefined, onRejected);
9019 }
9020 });
9021 OwnPromiseCapability = function () {
9022 var promise = new Internal();
9023 this.promise = promise;
9024 this.resolve = ctx($resolve, promise, 1);
9025 this.reject = ctx($reject, promise, 1);
9026 };
9027 newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
9028 return C === $Promise || C === Wrapper
9029 ? new OwnPromiseCapability(C)
9030 : newGenericPromiseCapability(C);
9031 };
9032}
9033
9034$export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
9035require('./_set-to-string-tag')($Promise, PROMISE);
9036require('./_set-species')(PROMISE);
9037Wrapper = require('./_core')[PROMISE];
9038
9039// statics
9040$export($export.S + $export.F * !USE_NATIVE, PROMISE, {
9041 // 25.4.4.5 Promise.reject(r)
9042 reject: function reject(r) {
9043 var capability = newPromiseCapability(this);
9044 var $$reject = capability.reject;
9045 $$reject(r);
9046 return capability.promise;
9047 }
9048});
9049$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
9050 // 25.4.4.6 Promise.resolve(x)
9051 resolve: function resolve(x) {
9052 return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
9053 }
9054});
9055$export($export.S + $export.F * !(USE_NATIVE && require('./_iter-detect')(function (iter) {
9056 $Promise.all(iter)['catch'](empty);
9057})), PROMISE, {
9058 // 25.4.4.1 Promise.all(iterable)
9059 all: function all(iterable) {
9060 var C = this;
9061 var capability = newPromiseCapability(C);
9062 var resolve = capability.resolve;
9063 var reject = capability.reject;
9064 var result = perform(function () {
9065 var values = [];
9066 var index = 0;
9067 var remaining = 1;
9068 forOf(iterable, false, function (promise) {
9069 var $index = index++;
9070 var alreadyCalled = false;
9071 values.push(undefined);
9072 remaining++;
9073 C.resolve(promise).then(function (value) {
9074 if (alreadyCalled) return;
9075 alreadyCalled = true;
9076 values[$index] = value;
9077 --remaining || resolve(values);
9078 }, reject);
9079 });
9080 --remaining || resolve(values);
9081 });
9082 if (result.e) reject(result.v);
9083 return capability.promise;
9084 },
9085 // 25.4.4.4 Promise.race(iterable)
9086 race: function race(iterable) {
9087 var C = this;
9088 var capability = newPromiseCapability(C);
9089 var reject = capability.reject;
9090 var result = perform(function () {
9091 forOf(iterable, false, function (promise) {
9092 C.resolve(promise).then(capability.resolve, reject);
9093 });
9094 });
9095 if (result.e) reject(result.v);
9096 return capability.promise;
9097 }
9098});
9099
9100},{"./_a-function":79,"./_an-instance":81,"./_classof":84,"./_core":86,"./_ctx":88,"./_export":94,"./_for-of":96,"./_global":97,"./_is-object":106,"./_iter-detect":110,"./_library":113,"./_microtask":115,"./_new-promise-capability":116,"./_perform":131,"./_promise-resolve":132,"./_redefine-all":134,"./_set-species":136,"./_set-to-string-tag":137,"./_species-constructor":140,"./_task":142,"./_user-agent":150,"./_wks":153}],166:[function(require,module,exports){
9101var $export = require('./_export');
9102var toAbsoluteIndex = require('./_to-absolute-index');
9103var fromCharCode = String.fromCharCode;
9104var $fromCodePoint = String.fromCodePoint;
9105
9106// length should be 1, old FF problem
9107$export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
9108 // 21.1.2.2 String.fromCodePoint(...codePoints)
9109 fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars
9110 var res = [];
9111 var aLen = arguments.length;
9112 var i = 0;
9113 var code;
9114 while (aLen > i) {
9115 code = +arguments[i++];
9116 if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
9117 res.push(code < 0x10000
9118 ? fromCharCode(code)
9119 : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
9120 );
9121 } return res.join('');
9122 }
9123});
9124
9125},{"./_export":94,"./_to-absolute-index":143}],167:[function(require,module,exports){
9126'use strict';
9127var $at = require('./_string-at')(true);
9128
9129// 21.1.3.27 String.prototype[@@iterator]()
9130require('./_iter-define')(String, 'String', function (iterated) {
9131 this._t = String(iterated); // target
9132 this._i = 0; // next index
9133// 21.1.5.2.1 %StringIteratorPrototype%.next()
9134}, function () {
9135 var O = this._t;
9136 var index = this._i;
9137 var point;
9138 if (index >= O.length) return { value: undefined, done: true };
9139 point = $at(O, index);
9140 this._i += point.length;
9141 return { value: point, done: false };
9142});
9143
9144},{"./_iter-define":109,"./_string-at":141}],168:[function(require,module,exports){
9145'use strict';
9146// ECMAScript 6 symbols shim
9147var global = require('./_global');
9148var has = require('./_has');
9149var DESCRIPTORS = require('./_descriptors');
9150var $export = require('./_export');
9151var redefine = require('./_redefine');
9152var META = require('./_meta').KEY;
9153var $fails = require('./_fails');
9154var shared = require('./_shared');
9155var setToStringTag = require('./_set-to-string-tag');
9156var uid = require('./_uid');
9157var wks = require('./_wks');
9158var wksExt = require('./_wks-ext');
9159var wksDefine = require('./_wks-define');
9160var enumKeys = require('./_enum-keys');
9161var isArray = require('./_is-array');
9162var anObject = require('./_an-object');
9163var isObject = require('./_is-object');
9164var toIObject = require('./_to-iobject');
9165var toPrimitive = require('./_to-primitive');
9166var createDesc = require('./_property-desc');
9167var _create = require('./_object-create');
9168var gOPNExt = require('./_object-gopn-ext');
9169var $GOPD = require('./_object-gopd');
9170var $DP = require('./_object-dp');
9171var $keys = require('./_object-keys');
9172var gOPD = $GOPD.f;
9173var dP = $DP.f;
9174var gOPN = gOPNExt.f;
9175var $Symbol = global.Symbol;
9176var $JSON = global.JSON;
9177var _stringify = $JSON && $JSON.stringify;
9178var PROTOTYPE = 'prototype';
9179var HIDDEN = wks('_hidden');
9180var TO_PRIMITIVE = wks('toPrimitive');
9181var isEnum = {}.propertyIsEnumerable;
9182var SymbolRegistry = shared('symbol-registry');
9183var AllSymbols = shared('symbols');
9184var OPSymbols = shared('op-symbols');
9185var ObjectProto = Object[PROTOTYPE];
9186var USE_NATIVE = typeof $Symbol == 'function';
9187var QObject = global.QObject;
9188// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
9189var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
9190
9191// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
9192var setSymbolDesc = DESCRIPTORS && $fails(function () {
9193 return _create(dP({}, 'a', {
9194 get: function () { return dP(this, 'a', { value: 7 }).a; }
9195 })).a != 7;
9196}) ? function (it, key, D) {
9197 var protoDesc = gOPD(ObjectProto, key);
9198 if (protoDesc) delete ObjectProto[key];
9199 dP(it, key, D);
9200 if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
9201} : dP;
9202
9203var wrap = function (tag) {
9204 var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
9205 sym._k = tag;
9206 return sym;
9207};
9208
9209var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
9210 return typeof it == 'symbol';
9211} : function (it) {
9212 return it instanceof $Symbol;
9213};
9214
9215var $defineProperty = function defineProperty(it, key, D) {
9216 if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
9217 anObject(it);
9218 key = toPrimitive(key, true);
9219 anObject(D);
9220 if (has(AllSymbols, key)) {
9221 if (!D.enumerable) {
9222 if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
9223 it[HIDDEN][key] = true;
9224 } else {
9225 if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
9226 D = _create(D, { enumerable: createDesc(0, false) });
9227 } return setSymbolDesc(it, key, D);
9228 } return dP(it, key, D);
9229};
9230var $defineProperties = function defineProperties(it, P) {
9231 anObject(it);
9232 var keys = enumKeys(P = toIObject(P));
9233 var i = 0;
9234 var l = keys.length;
9235 var key;
9236 while (l > i) $defineProperty(it, key = keys[i++], P[key]);
9237 return it;
9238};
9239var $create = function create(it, P) {
9240 return P === undefined ? _create(it) : $defineProperties(_create(it), P);
9241};
9242var $propertyIsEnumerable = function propertyIsEnumerable(key) {
9243 var E = isEnum.call(this, key = toPrimitive(key, true));
9244 if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
9245 return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
9246};
9247var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
9248 it = toIObject(it);
9249 key = toPrimitive(key, true);
9250 if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
9251 var D = gOPD(it, key);
9252 if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
9253 return D;
9254};
9255var $getOwnPropertyNames = function getOwnPropertyNames(it) {
9256 var names = gOPN(toIObject(it));
9257 var result = [];
9258 var i = 0;
9259 var key;
9260 while (names.length > i) {
9261 if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
9262 } return result;
9263};
9264var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
9265 var IS_OP = it === ObjectProto;
9266 var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
9267 var result = [];
9268 var i = 0;
9269 var key;
9270 while (names.length > i) {
9271 if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
9272 } return result;
9273};
9274
9275// 19.4.1.1 Symbol([description])
9276if (!USE_NATIVE) {
9277 $Symbol = function Symbol() {
9278 if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
9279 var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
9280 var $set = function (value) {
9281 if (this === ObjectProto) $set.call(OPSymbols, value);
9282 if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
9283 setSymbolDesc(this, tag, createDesc(1, value));
9284 };
9285 if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });
9286 return wrap(tag);
9287 };
9288 redefine($Symbol[PROTOTYPE], 'toString', function toString() {
9289 return this._k;
9290 });
9291
9292 $GOPD.f = $getOwnPropertyDescriptor;
9293 $DP.f = $defineProperty;
9294 require('./_object-gopn').f = gOPNExt.f = $getOwnPropertyNames;
9295 require('./_object-pie').f = $propertyIsEnumerable;
9296 require('./_object-gops').f = $getOwnPropertySymbols;
9297
9298 if (DESCRIPTORS && !require('./_library')) {
9299 redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
9300 }
9301
9302 wksExt.f = function (name) {
9303 return wrap(wks(name));
9304 };
9305}
9306
9307$export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
9308
9309for (var es6Symbols = (
9310 // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
9311 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
9312).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
9313
9314for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
9315
9316$export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
9317 // 19.4.2.1 Symbol.for(key)
9318 'for': function (key) {
9319 return has(SymbolRegistry, key += '')
9320 ? SymbolRegistry[key]
9321 : SymbolRegistry[key] = $Symbol(key);
9322 },
9323 // 19.4.2.5 Symbol.keyFor(sym)
9324 keyFor: function keyFor(sym) {
9325 if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
9326 for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
9327 },
9328 useSetter: function () { setter = true; },
9329 useSimple: function () { setter = false; }
9330});
9331
9332$export($export.S + $export.F * !USE_NATIVE, 'Object', {
9333 // 19.1.2.2 Object.create(O [, Properties])
9334 create: $create,
9335 // 19.1.2.4 Object.defineProperty(O, P, Attributes)
9336 defineProperty: $defineProperty,
9337 // 19.1.2.3 Object.defineProperties(O, Properties)
9338 defineProperties: $defineProperties,
9339 // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
9340 getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
9341 // 19.1.2.7 Object.getOwnPropertyNames(O)
9342 getOwnPropertyNames: $getOwnPropertyNames,
9343 // 19.1.2.8 Object.getOwnPropertySymbols(O)
9344 getOwnPropertySymbols: $getOwnPropertySymbols
9345});
9346
9347// 24.3.2 JSON.stringify(value [, replacer [, space]])
9348$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
9349 var S = $Symbol();
9350 // MS Edge converts symbol values to JSON as {}
9351 // WebKit converts symbol values to JSON as null
9352 // V8 throws on boxed symbols
9353 return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
9354})), 'JSON', {
9355 stringify: function stringify(it) {
9356 var args = [it];
9357 var i = 1;
9358 var replacer, $replacer;
9359 while (arguments.length > i) args.push(arguments[i++]);
9360 $replacer = replacer = args[1];
9361 if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
9362 if (!isArray(replacer)) replacer = function (key, value) {
9363 if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
9364 if (!isSymbol(value)) return value;
9365 };
9366 args[1] = replacer;
9367 return _stringify.apply($JSON, args);
9368 }
9369});
9370
9371// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
9372$Symbol[PROTOTYPE][TO_PRIMITIVE] || require('./_hide')($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
9373// 19.4.3.5 Symbol.prototype[@@toStringTag]
9374setToStringTag($Symbol, 'Symbol');
9375// 20.2.1.9 Math[@@toStringTag]
9376setToStringTag(Math, 'Math', true);
9377// 24.3.3 JSON[@@toStringTag]
9378setToStringTag(global.JSON, 'JSON', true);
9379
9380},{"./_an-object":82,"./_descriptors":90,"./_enum-keys":93,"./_export":94,"./_fails":95,"./_global":97,"./_has":98,"./_hide":99,"./_is-array":105,"./_is-object":106,"./_library":113,"./_meta":114,"./_object-create":118,"./_object-dp":119,"./_object-gopd":121,"./_object-gopn":123,"./_object-gopn-ext":122,"./_object-gops":124,"./_object-keys":127,"./_object-pie":128,"./_property-desc":133,"./_redefine":135,"./_set-to-string-tag":137,"./_shared":139,"./_to-iobject":145,"./_to-primitive":148,"./_uid":149,"./_wks":153,"./_wks-define":151,"./_wks-ext":152}],169:[function(require,module,exports){
9381// https://github.com/tc39/proposal-object-values-entries
9382var $export = require('./_export');
9383var $entries = require('./_object-to-array')(true);
9384
9385$export($export.S, 'Object', {
9386 entries: function entries(it) {
9387 return $entries(it);
9388 }
9389});
9390
9391},{"./_export":94,"./_object-to-array":130}],170:[function(require,module,exports){
9392// https://github.com/tc39/proposal-promise-finally
9393'use strict';
9394var $export = require('./_export');
9395var core = require('./_core');
9396var global = require('./_global');
9397var speciesConstructor = require('./_species-constructor');
9398var promiseResolve = require('./_promise-resolve');
9399
9400$export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) {
9401 var C = speciesConstructor(this, core.Promise || global.Promise);
9402 var isFunction = typeof onFinally == 'function';
9403 return this.then(
9404 isFunction ? function (x) {
9405 return promiseResolve(C, onFinally()).then(function () { return x; });
9406 } : onFinally,
9407 isFunction ? function (e) {
9408 return promiseResolve(C, onFinally()).then(function () { throw e; });
9409 } : onFinally
9410 );
9411} });
9412
9413},{"./_core":86,"./_export":94,"./_global":97,"./_promise-resolve":132,"./_species-constructor":140}],171:[function(require,module,exports){
9414'use strict';
9415// https://github.com/tc39/proposal-promise-try
9416var $export = require('./_export');
9417var newPromiseCapability = require('./_new-promise-capability');
9418var perform = require('./_perform');
9419
9420$export($export.S, 'Promise', { 'try': function (callbackfn) {
9421 var promiseCapability = newPromiseCapability.f(this);
9422 var result = perform(callbackfn);
9423 (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
9424 return promiseCapability.promise;
9425} });
9426
9427},{"./_export":94,"./_new-promise-capability":116,"./_perform":131}],172:[function(require,module,exports){
9428require('./_wks-define')('asyncIterator');
9429
9430},{"./_wks-define":151}],173:[function(require,module,exports){
9431require('./_wks-define')('observable');
9432
9433},{"./_wks-define":151}],174:[function(require,module,exports){
9434require('./es6.array.iterator');
9435var global = require('./_global');
9436var hide = require('./_hide');
9437var Iterators = require('./_iterators');
9438var TO_STRING_TAG = require('./_wks')('toStringTag');
9439
9440var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
9441 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
9442 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
9443 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
9444 'TextTrackList,TouchList').split(',');
9445
9446for (var i = 0; i < DOMIterables.length; i++) {
9447 var NAME = DOMIterables[i];
9448 var Collection = global[NAME];
9449 var proto = Collection && Collection.prototype;
9450 if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
9451 Iterators[NAME] = Iterators.Array;
9452}
9453
9454},{"./_global":97,"./_hide":99,"./_iterators":112,"./_wks":153,"./es6.array.iterator":156}],175:[function(require,module,exports){
9455var $export = require('./_export');
9456var $task = require('./_task');
9457$export($export.G + $export.B, {
9458 setImmediate: $task.set,
9459 clearImmediate: $task.clear
9460});
9461
9462},{"./_export":94,"./_task":142}],176:[function(require,module,exports){
9463(function (Buffer){
9464'use strict';
9465
9466var _typeof2 = require('babel-runtime/helpers/typeof');
9467
9468var _typeof3 = _interopRequireDefault(_typeof2);
9469
9470function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9471
9472// Copyright Joyent, Inc. and other Node contributors.
9473//
9474// Permission is hereby granted, free of charge, to any person obtaining a
9475// copy of this software and associated documentation files (the
9476// "Software"), to deal in the Software without restriction, including
9477// without limitation the rights to use, copy, modify, merge, publish,
9478// distribute, sublicense, and/or sell copies of the Software, and to permit
9479// persons to whom the Software is furnished to do so, subject to the
9480// following conditions:
9481//
9482// The above copyright notice and this permission notice shall be included
9483// in all copies or substantial portions of the Software.
9484//
9485// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9486// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9487// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
9488// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
9489// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
9490// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
9491// USE OR OTHER DEALINGS IN THE SOFTWARE.
9492
9493// NOTE: These type checking functions intentionally don't use `instanceof`
9494// because it is fragile and can be easily faked with `Object.create()`.
9495
9496function isArray(arg) {
9497 if (Array.isArray) {
9498 return Array.isArray(arg);
9499 }
9500 return objectToString(arg) === '[object Array]';
9501}
9502exports.isArray = isArray;
9503
9504function isBoolean(arg) {
9505 return typeof arg === 'boolean';
9506}
9507exports.isBoolean = isBoolean;
9508
9509function isNull(arg) {
9510 return arg === null;
9511}
9512exports.isNull = isNull;
9513
9514function isNullOrUndefined(arg) {
9515 return arg == null;
9516}
9517exports.isNullOrUndefined = isNullOrUndefined;
9518
9519function isNumber(arg) {
9520 return typeof arg === 'number';
9521}
9522exports.isNumber = isNumber;
9523
9524function isString(arg) {
9525 return typeof arg === 'string';
9526}
9527exports.isString = isString;
9528
9529function isSymbol(arg) {
9530 return (typeof arg === 'undefined' ? 'undefined' : (0, _typeof3.default)(arg)) === 'symbol';
9531}
9532exports.isSymbol = isSymbol;
9533
9534function isUndefined(arg) {
9535 return arg === void 0;
9536}
9537exports.isUndefined = isUndefined;
9538
9539function isRegExp(re) {
9540 return objectToString(re) === '[object RegExp]';
9541}
9542exports.isRegExp = isRegExp;
9543
9544function isObject(arg) {
9545 return (typeof arg === 'undefined' ? 'undefined' : (0, _typeof3.default)(arg)) === 'object' && arg !== null;
9546}
9547exports.isObject = isObject;
9548
9549function isDate(d) {
9550 return objectToString(d) === '[object Date]';
9551}
9552exports.isDate = isDate;
9553
9554function isError(e) {
9555 return objectToString(e) === '[object Error]' || e instanceof Error;
9556}
9557exports.isError = isError;
9558
9559function isFunction(arg) {
9560 return typeof arg === 'function';
9561}
9562exports.isFunction = isFunction;
9563
9564function isPrimitive(arg) {
9565 return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || (typeof arg === 'undefined' ? 'undefined' : (0, _typeof3.default)(arg)) === 'symbol' || // ES6 symbol
9566 typeof arg === 'undefined';
9567}
9568exports.isPrimitive = isPrimitive;
9569
9570exports.isBuffer = Buffer.isBuffer;
9571
9572function objectToString(o) {
9573 return Object.prototype.toString.call(o);
9574}
9575
9576}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
9577},{"../../is-buffer/index.js":217,"babel-runtime/helpers/typeof":54}],177:[function(require,module,exports){
9578'use strict';
9579
9580var _typeof2 = require('babel-runtime/helpers/typeof');
9581
9582var _typeof3 = _interopRequireDefault(_typeof2);
9583
9584function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9585
9586/*
9587 * Date Format 1.2.3
9588 * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
9589 * MIT license
9590 *
9591 * Includes enhancements by Scott Trenda <scott.trenda.net>
9592 * and Kris Kowal <cixar.com/~kris.kowal/>
9593 *
9594 * Accepts a date, a mask, or a date and a mask.
9595 * Returns a formatted version of the given date.
9596 * The date defaults to the current date/time.
9597 * The mask defaults to dateFormat.masks.default.
9598 */
9599
9600(function (global) {
9601 'use strict';
9602
9603 var dateFormat = function () {
9604 var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZWN]|'[^']*'|'[^']*'/g;
9605 var timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;
9606 var timezoneClip = /[^-+\dA-Z]/g;
9607
9608 // Regexes and supporting functions are cached through closure
9609 return function (date, mask, utc, gmt) {
9610
9611 // You can't provide utc if you skip other args (use the 'UTC:' mask prefix)
9612 if (arguments.length === 1 && kindOf(date) === 'string' && !/\d/.test(date)) {
9613 mask = date;
9614 date = undefined;
9615 }
9616
9617 date = date || new Date();
9618
9619 if (!(date instanceof Date)) {
9620 date = new Date(date);
9621 }
9622
9623 if (isNaN(date)) {
9624 throw TypeError('Invalid date');
9625 }
9626
9627 mask = String(dateFormat.masks[mask] || mask || dateFormat.masks['default']);
9628
9629 // Allow setting the utc/gmt argument via the mask
9630 var maskSlice = mask.slice(0, 4);
9631 if (maskSlice === 'UTC:' || maskSlice === 'GMT:') {
9632 mask = mask.slice(4);
9633 utc = true;
9634 if (maskSlice === 'GMT:') {
9635 gmt = true;
9636 }
9637 }
9638
9639 var _ = utc ? 'getUTC' : 'get';
9640 var d = date[_ + 'Date']();
9641 var D = date[_ + 'Day']();
9642 var m = date[_ + 'Month']();
9643 var y = date[_ + 'FullYear']();
9644 var H = date[_ + 'Hours']();
9645 var M = date[_ + 'Minutes']();
9646 var s = date[_ + 'Seconds']();
9647 var L = date[_ + 'Milliseconds']();
9648 var o = utc ? 0 : date.getTimezoneOffset();
9649 var W = getWeek(date);
9650 var N = getDayOfWeek(date);
9651 var flags = {
9652 d: d,
9653 dd: pad(d),
9654 ddd: dateFormat.i18n.dayNames[D],
9655 dddd: dateFormat.i18n.dayNames[D + 7],
9656 m: m + 1,
9657 mm: pad(m + 1),
9658 mmm: dateFormat.i18n.monthNames[m],
9659 mmmm: dateFormat.i18n.monthNames[m + 12],
9660 yy: String(y).slice(2),
9661 yyyy: y,
9662 h: H % 12 || 12,
9663 hh: pad(H % 12 || 12),
9664 H: H,
9665 HH: pad(H),
9666 M: M,
9667 MM: pad(M),
9668 s: s,
9669 ss: pad(s),
9670 l: pad(L, 3),
9671 L: pad(Math.round(L / 10)),
9672 t: H < 12 ? 'a' : 'p',
9673 tt: H < 12 ? 'am' : 'pm',
9674 T: H < 12 ? 'A' : 'P',
9675 TT: H < 12 ? 'AM' : 'PM',
9676 Z: gmt ? 'GMT' : utc ? 'UTC' : (String(date).match(timezone) || ['']).pop().replace(timezoneClip, ''),
9677 o: (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
9678 S: ['th', 'st', 'nd', 'rd'][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10],
9679 W: W,
9680 N: N
9681 };
9682
9683 return mask.replace(token, function (match) {
9684 if (match in flags) {
9685 return flags[match];
9686 }
9687 return match.slice(1, match.length - 1);
9688 });
9689 };
9690 }();
9691
9692 dateFormat.masks = {
9693 'default': 'ddd mmm dd yyyy HH:MM:ss',
9694 'shortDate': 'm/d/yy',
9695 'mediumDate': 'mmm d, yyyy',
9696 'longDate': 'mmmm d, yyyy',
9697 'fullDate': 'dddd, mmmm d, yyyy',
9698 'shortTime': 'h:MM TT',
9699 'mediumTime': 'h:MM:ss TT',
9700 'longTime': 'h:MM:ss TT Z',
9701 'isoDate': 'yyyy-mm-dd',
9702 'isoTime': 'HH:MM:ss',
9703 'isoDateTime': 'yyyy-mm-dd\'T\'HH:MM:sso',
9704 'isoUtcDateTime': 'UTC:yyyy-mm-dd\'T\'HH:MM:ss\'Z\'',
9705 'expiresHeaderFormat': 'ddd, dd mmm yyyy HH:MM:ss Z'
9706 };
9707
9708 // Internationalization strings
9709 dateFormat.i18n = {
9710 dayNames: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
9711 monthNames: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
9712 };
9713
9714 function pad(val, len) {
9715 val = String(val);
9716 len = len || 2;
9717 while (val.length < len) {
9718 val = '0' + val;
9719 }
9720 return val;
9721 }
9722
9723 /**
9724 * Get the ISO 8601 week number
9725 * Based on comments from
9726 * http://techblog.procurios.nl/k/n618/news/view/33796/14863/Calculate-ISO-8601-week-and-year-in-javascript.html
9727 *
9728 * @param {Object} `date`
9729 * @return {Number}
9730 */
9731 function getWeek(date) {
9732 // Remove time components of date
9733 var targetThursday = new Date(date.getFullYear(), date.getMonth(), date.getDate());
9734
9735 // Change date to Thursday same week
9736 targetThursday.setDate(targetThursday.getDate() - (targetThursday.getDay() + 6) % 7 + 3);
9737
9738 // Take January 4th as it is always in week 1 (see ISO 8601)
9739 var firstThursday = new Date(targetThursday.getFullYear(), 0, 4);
9740
9741 // Change date to Thursday same week
9742 firstThursday.setDate(firstThursday.getDate() - (firstThursday.getDay() + 6) % 7 + 3);
9743
9744 // Check if daylight-saving-time-switch occurred and correct for it
9745 var ds = targetThursday.getTimezoneOffset() - firstThursday.getTimezoneOffset();
9746 targetThursday.setHours(targetThursday.getHours() - ds);
9747
9748 // Number of weeks between target Thursday and first Thursday
9749 var weekDiff = (targetThursday - firstThursday) / (86400000 * 7);
9750 return 1 + Math.floor(weekDiff);
9751 }
9752
9753 /**
9754 * Get ISO-8601 numeric representation of the day of the week
9755 * 1 (for Monday) through 7 (for Sunday)
9756 *
9757 * @param {Object} `date`
9758 * @return {Number}
9759 */
9760 function getDayOfWeek(date) {
9761 var dow = date.getDay();
9762 if (dow === 0) {
9763 dow = 7;
9764 }
9765 return dow;
9766 }
9767
9768 /**
9769 * kind-of shortcut
9770 * @param {*} val
9771 * @return {String}
9772 */
9773 function kindOf(val) {
9774 if (val === null) {
9775 return 'null';
9776 }
9777
9778 if (val === undefined) {
9779 return 'undefined';
9780 }
9781
9782 if ((typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val)) !== 'object') {
9783 return typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val);
9784 }
9785
9786 if (Array.isArray(val)) {
9787 return 'array';
9788 }
9789
9790 return {}.toString.call(val).slice(8, -1).toLowerCase();
9791 };
9792
9793 if (typeof define === 'function' && define.amd) {
9794 define(function () {
9795 return dateFormat;
9796 });
9797 } else if ((typeof exports === 'undefined' ? 'undefined' : (0, _typeof3.default)(exports)) === 'object') {
9798 module.exports = dateFormat;
9799 } else {
9800 global.dateFormat = dateFormat;
9801 }
9802})(undefined);
9803
9804},{"babel-runtime/helpers/typeof":54}],178:[function(require,module,exports){
9805(function (process){
9806/**
9807 * This is the web browser implementation of `debug()`.
9808 *
9809 * Expose `debug()` as the module.
9810 */
9811
9812exports = module.exports = require('./debug');
9813exports.log = log;
9814exports.formatArgs = formatArgs;
9815exports.save = save;
9816exports.load = load;
9817exports.useColors = useColors;
9818exports.storage = 'undefined' != typeof chrome
9819 && 'undefined' != typeof chrome.storage
9820 ? chrome.storage.local
9821 : localstorage();
9822
9823/**
9824 * Colors.
9825 */
9826
9827exports.colors = [
9828 'lightseagreen',
9829 'forestgreen',
9830 'goldenrod',
9831 'dodgerblue',
9832 'darkorchid',
9833 'crimson'
9834];
9835
9836/**
9837 * Currently only WebKit-based Web Inspectors, Firefox >= v31,
9838 * and the Firebug extension (any Firefox version) are known
9839 * to support "%c" CSS customizations.
9840 *
9841 * TODO: add a `localStorage` variable to explicitly enable/disable colors
9842 */
9843
9844function useColors() {
9845 // NB: In an Electron preload script, document will be defined but not fully
9846 // initialized. Since we know we're in Chrome, we'll just detect this case
9847 // explicitly
9848 if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
9849 return true;
9850 }
9851
9852 // is webkit? http://stackoverflow.com/a/16459606/376773
9853 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
9854 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
9855 // is firebug? http://stackoverflow.com/a/398120/376773
9856 (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
9857 // is firefox >= v31?
9858 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
9859 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
9860 // double check webkit in userAgent just in case we are in a worker
9861 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
9862}
9863
9864/**
9865 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
9866 */
9867
9868exports.formatters.j = function(v) {
9869 try {
9870 return JSON.stringify(v);
9871 } catch (err) {
9872 return '[UnexpectedJSONParseError]: ' + err.message;
9873 }
9874};
9875
9876
9877/**
9878 * Colorize log arguments if enabled.
9879 *
9880 * @api public
9881 */
9882
9883function formatArgs(args) {
9884 var useColors = this.useColors;
9885
9886 args[0] = (useColors ? '%c' : '')
9887 + this.namespace
9888 + (useColors ? ' %c' : ' ')
9889 + args[0]
9890 + (useColors ? '%c ' : ' ')
9891 + '+' + exports.humanize(this.diff);
9892
9893 if (!useColors) return;
9894
9895 var c = 'color: ' + this.color;
9896 args.splice(1, 0, c, 'color: inherit')
9897
9898 // the final "%c" is somewhat tricky, because there could be other
9899 // arguments passed either before or after the %c, so we need to
9900 // figure out the correct index to insert the CSS into
9901 var index = 0;
9902 var lastC = 0;
9903 args[0].replace(/%[a-zA-Z%]/g, function(match) {
9904 if ('%%' === match) return;
9905 index++;
9906 if ('%c' === match) {
9907 // we only are interested in the *last* %c
9908 // (the user may have provided their own)
9909 lastC = index;
9910 }
9911 });
9912
9913 args.splice(lastC, 0, c);
9914}
9915
9916/**
9917 * Invokes `console.log()` when available.
9918 * No-op when `console.log` is not a "function".
9919 *
9920 * @api public
9921 */
9922
9923function log() {
9924 // this hackery is required for IE8/9, where
9925 // the `console.log` function doesn't have 'apply'
9926 return 'object' === typeof console
9927 && console.log
9928 && Function.prototype.apply.call(console.log, console, arguments);
9929}
9930
9931/**
9932 * Save `namespaces`.
9933 *
9934 * @param {String} namespaces
9935 * @api private
9936 */
9937
9938function save(namespaces) {
9939 try {
9940 if (null == namespaces) {
9941 exports.storage.removeItem('debug');
9942 } else {
9943 exports.storage.debug = namespaces;
9944 }
9945 } catch(e) {}
9946}
9947
9948/**
9949 * Load `namespaces`.
9950 *
9951 * @return {String} returns the previously persisted debug modes
9952 * @api private
9953 */
9954
9955function load() {
9956 var r;
9957 try {
9958 r = exports.storage.debug;
9959 } catch(e) {}
9960
9961 // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
9962 if (!r && typeof process !== 'undefined' && 'env' in process) {
9963 r = process.env.DEBUG;
9964 }
9965
9966 return r;
9967}
9968
9969/**
9970 * Enable namespaces listed in `localStorage.debug` initially.
9971 */
9972
9973exports.enable(load());
9974
9975/**
9976 * Localstorage attempts to return the localstorage.
9977 *
9978 * This is necessary because safari throws
9979 * when a user disables cookies/localstorage
9980 * and you attempt to access it.
9981 *
9982 * @return {LocalStorage}
9983 * @api private
9984 */
9985
9986function localstorage() {
9987 try {
9988 return window.localStorage;
9989 } catch (e) {}
9990}
9991
9992}).call(this,require('_process'))
9993},{"./debug":179,"_process":239}],179:[function(require,module,exports){
9994
9995/**
9996 * This is the common logic for both the Node.js and web browser
9997 * implementations of `debug()`.
9998 *
9999 * Expose `debug()` as the module.
10000 */
10001
10002exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
10003exports.coerce = coerce;
10004exports.disable = disable;
10005exports.enable = enable;
10006exports.enabled = enabled;
10007exports.humanize = require('ms');
10008
10009/**
10010 * The currently active debug mode names, and names to skip.
10011 */
10012
10013exports.names = [];
10014exports.skips = [];
10015
10016/**
10017 * Map of special "%n" handling functions, for the debug "format" argument.
10018 *
10019 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
10020 */
10021
10022exports.formatters = {};
10023
10024/**
10025 * Previous log timestamp.
10026 */
10027
10028var prevTime;
10029
10030/**
10031 * Select a color.
10032 * @param {String} namespace
10033 * @return {Number}
10034 * @api private
10035 */
10036
10037function selectColor(namespace) {
10038 var hash = 0, i;
10039
10040 for (i in namespace) {
10041 hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
10042 hash |= 0; // Convert to 32bit integer
10043 }
10044
10045 return exports.colors[Math.abs(hash) % exports.colors.length];
10046}
10047
10048/**
10049 * Create a debugger with the given `namespace`.
10050 *
10051 * @param {String} namespace
10052 * @return {Function}
10053 * @api public
10054 */
10055
10056function createDebug(namespace) {
10057
10058 function debug() {
10059 // disabled?
10060 if (!debug.enabled) return;
10061
10062 var self = debug;
10063
10064 // set `diff` timestamp
10065 var curr = +new Date();
10066 var ms = curr - (prevTime || curr);
10067 self.diff = ms;
10068 self.prev = prevTime;
10069 self.curr = curr;
10070 prevTime = curr;
10071
10072 // turn the `arguments` into a proper Array
10073 var args = new Array(arguments.length);
10074 for (var i = 0; i < args.length; i++) {
10075 args[i] = arguments[i];
10076 }
10077
10078 args[0] = exports.coerce(args[0]);
10079
10080 if ('string' !== typeof args[0]) {
10081 // anything else let's inspect with %O
10082 args.unshift('%O');
10083 }
10084
10085 // apply any `formatters` transformations
10086 var index = 0;
10087 args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
10088 // if we encounter an escaped % then don't increase the array index
10089 if (match === '%%') return match;
10090 index++;
10091 var formatter = exports.formatters[format];
10092 if ('function' === typeof formatter) {
10093 var val = args[index];
10094 match = formatter.call(self, val);
10095
10096 // now we need to remove `args[index]` since it's inlined in the `format`
10097 args.splice(index, 1);
10098 index--;
10099 }
10100 return match;
10101 });
10102
10103 // apply env-specific formatting (colors, etc.)
10104 exports.formatArgs.call(self, args);
10105
10106 var logFn = debug.log || exports.log || console.log.bind(console);
10107 logFn.apply(self, args);
10108 }
10109
10110 debug.namespace = namespace;
10111 debug.enabled = exports.enabled(namespace);
10112 debug.useColors = exports.useColors();
10113 debug.color = selectColor(namespace);
10114
10115 // env-specific initialization logic for debug instances
10116 if ('function' === typeof exports.init) {
10117 exports.init(debug);
10118 }
10119
10120 return debug;
10121}
10122
10123/**
10124 * Enables a debug mode by namespaces. This can include modes
10125 * separated by a colon and wildcards.
10126 *
10127 * @param {String} namespaces
10128 * @api public
10129 */
10130
10131function enable(namespaces) {
10132 exports.save(namespaces);
10133
10134 exports.names = [];
10135 exports.skips = [];
10136
10137 var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
10138 var len = split.length;
10139
10140 for (var i = 0; i < len; i++) {
10141 if (!split[i]) continue; // ignore empty strings
10142 namespaces = split[i].replace(/\*/g, '.*?');
10143 if (namespaces[0] === '-') {
10144 exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
10145 } else {
10146 exports.names.push(new RegExp('^' + namespaces + '$'));
10147 }
10148 }
10149}
10150
10151/**
10152 * Disable debug output.
10153 *
10154 * @api public
10155 */
10156
10157function disable() {
10158 exports.enable('');
10159}
10160
10161/**
10162 * Returns true if the given mode name is enabled, false otherwise.
10163 *
10164 * @param {String} name
10165 * @return {Boolean}
10166 * @api public
10167 */
10168
10169function enabled(name) {
10170 var i, len;
10171 for (i = 0, len = exports.skips.length; i < len; i++) {
10172 if (exports.skips[i].test(name)) {
10173 return false;
10174 }
10175 }
10176 for (i = 0, len = exports.names.length; i < len; i++) {
10177 if (exports.names[i].test(name)) {
10178 return true;
10179 }
10180 }
10181 return false;
10182}
10183
10184/**
10185 * Coerce `val`.
10186 *
10187 * @param {Mixed} val
10188 * @return {Mixed}
10189 * @api private
10190 */
10191
10192function coerce(val) {
10193 if (val instanceof Error) return val.stack || val.message;
10194 return val;
10195}
10196
10197},{"ms":228}],180:[function(require,module,exports){
10198'use strict';
10199
10200var keys = require('object-keys');
10201var foreach = require('foreach');
10202var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
10203
10204var toStr = Object.prototype.toString;
10205
10206var isFunction = function (fn) {
10207 return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
10208};
10209
10210var arePropertyDescriptorsSupported = function () {
10211 var obj = {};
10212 try {
10213 Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
10214 /* eslint-disable no-unused-vars, no-restricted-syntax */
10215 for (var _ in obj) { return false; }
10216 /* eslint-enable no-unused-vars, no-restricted-syntax */
10217 return obj.x === obj;
10218 } catch (e) { /* this is IE 8. */
10219 return false;
10220 }
10221};
10222var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();
10223
10224var defineProperty = function (object, name, value, predicate) {
10225 if (name in object && (!isFunction(predicate) || !predicate())) {
10226 return;
10227 }
10228 if (supportsDescriptors) {
10229 Object.defineProperty(object, name, {
10230 configurable: true,
10231 enumerable: false,
10232 value: value,
10233 writable: true
10234 });
10235 } else {
10236 object[name] = value;
10237 }
10238};
10239
10240var defineProperties = function (object, map) {
10241 var predicates = arguments.length > 2 ? arguments[2] : {};
10242 var props = keys(map);
10243 if (hasSymbols) {
10244 props = props.concat(Object.getOwnPropertySymbols(map));
10245 }
10246 foreach(props, function (name) {
10247 defineProperty(object, name, map[name], predicates[name]);
10248 });
10249};
10250
10251defineProperties.supportsDescriptors = !!supportsDescriptors;
10252
10253module.exports = defineProperties;
10254
10255},{"foreach":207,"object-keys":230}],181:[function(require,module,exports){
10256'use strict';
10257
10258/* globals
10259 Atomics,
10260 SharedArrayBuffer,
10261*/
10262
10263var undefined; // eslint-disable-line no-shadow-restricted-names
10264
10265var ThrowTypeError = Object.getOwnPropertyDescriptor
10266 ? (function () { return Object.getOwnPropertyDescriptor(arguments, 'callee').get; }())
10267 : function () { throw new TypeError(); };
10268
10269var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
10270
10271var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
10272
10273var generator; // = function * () {};
10274var generatorFunction = generator ? getProto(generator) : undefined;
10275var asyncFn; // async function() {};
10276var asyncFunction = asyncFn ? asyncFn.constructor : undefined;
10277var asyncGen; // async function * () {};
10278var asyncGenFunction = asyncGen ? getProto(asyncGen) : undefined;
10279var asyncGenIterator = asyncGen ? asyncGen() : undefined;
10280
10281var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
10282
10283var INTRINSICS = {
10284 '$ %Array%': Array,
10285 '$ %ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
10286 '$ %ArrayBufferPrototype%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer.prototype,
10287 '$ %ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
10288 '$ %ArrayPrototype%': Array.prototype,
10289 '$ %ArrayProto_entries%': Array.prototype.entries,
10290 '$ %ArrayProto_forEach%': Array.prototype.forEach,
10291 '$ %ArrayProto_keys%': Array.prototype.keys,
10292 '$ %ArrayProto_values%': Array.prototype.values,
10293 '$ %AsyncFromSyncIteratorPrototype%': undefined,
10294 '$ %AsyncFunction%': asyncFunction,
10295 '$ %AsyncFunctionPrototype%': asyncFunction ? asyncFunction.prototype : undefined,
10296 '$ %AsyncGenerator%': asyncGen ? getProto(asyncGenIterator) : undefined,
10297 '$ %AsyncGeneratorFunction%': asyncGenFunction,
10298 '$ %AsyncGeneratorPrototype%': asyncGenFunction ? asyncGenFunction.prototype : undefined,
10299 '$ %AsyncIteratorPrototype%': asyncGenIterator && hasSymbols && Symbol.asyncIterator ? asyncGenIterator[Symbol.asyncIterator]() : undefined,
10300 '$ %Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
10301 '$ %Boolean%': Boolean,
10302 '$ %BooleanPrototype%': Boolean.prototype,
10303 '$ %DataView%': typeof DataView === 'undefined' ? undefined : DataView,
10304 '$ %DataViewPrototype%': typeof DataView === 'undefined' ? undefined : DataView.prototype,
10305 '$ %Date%': Date,
10306 '$ %DatePrototype%': Date.prototype,
10307 '$ %decodeURI%': decodeURI,
10308 '$ %decodeURIComponent%': decodeURIComponent,
10309 '$ %encodeURI%': encodeURI,
10310 '$ %encodeURIComponent%': encodeURIComponent,
10311 '$ %Error%': Error,
10312 '$ %ErrorPrototype%': Error.prototype,
10313 '$ %eval%': eval, // eslint-disable-line no-eval
10314 '$ %EvalError%': EvalError,
10315 '$ %EvalErrorPrototype%': EvalError.prototype,
10316 '$ %Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
10317 '$ %Float32ArrayPrototype%': typeof Float32Array === 'undefined' ? undefined : Float32Array.prototype,
10318 '$ %Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
10319 '$ %Float64ArrayPrototype%': typeof Float64Array === 'undefined' ? undefined : Float64Array.prototype,
10320 '$ %Function%': Function,
10321 '$ %FunctionPrototype%': Function.prototype,
10322 '$ %Generator%': generator ? getProto(generator()) : undefined,
10323 '$ %GeneratorFunction%': generatorFunction,
10324 '$ %GeneratorPrototype%': generatorFunction ? generatorFunction.prototype : undefined,
10325 '$ %Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
10326 '$ %Int8ArrayPrototype%': typeof Int8Array === 'undefined' ? undefined : Int8Array.prototype,
10327 '$ %Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
10328 '$ %Int16ArrayPrototype%': typeof Int16Array === 'undefined' ? undefined : Int8Array.prototype,
10329 '$ %Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
10330 '$ %Int32ArrayPrototype%': typeof Int32Array === 'undefined' ? undefined : Int32Array.prototype,
10331 '$ %isFinite%': isFinite,
10332 '$ %isNaN%': isNaN,
10333 '$ %IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
10334 '$ %JSON%': JSON,
10335 '$ %JSONParse%': JSON.parse,
10336 '$ %Map%': typeof Map === 'undefined' ? undefined : Map,
10337 '$ %MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
10338 '$ %MapPrototype%': typeof Map === 'undefined' ? undefined : Map.prototype,
10339 '$ %Math%': Math,
10340 '$ %Number%': Number,
10341 '$ %NumberPrototype%': Number.prototype,
10342 '$ %Object%': Object,
10343 '$ %ObjectPrototype%': Object.prototype,
10344 '$ %ObjProto_toString%': Object.prototype.toString,
10345 '$ %ObjProto_valueOf%': Object.prototype.valueOf,
10346 '$ %parseFloat%': parseFloat,
10347 '$ %parseInt%': parseInt,
10348 '$ %Promise%': typeof Promise === 'undefined' ? undefined : Promise,
10349 '$ %PromisePrototype%': typeof Promise === 'undefined' ? undefined : Promise.prototype,
10350 '$ %PromiseProto_then%': typeof Promise === 'undefined' ? undefined : Promise.prototype.then,
10351 '$ %Promise_all%': typeof Promise === 'undefined' ? undefined : Promise.all,
10352 '$ %Promise_reject%': typeof Promise === 'undefined' ? undefined : Promise.reject,
10353 '$ %Promise_resolve%': typeof Promise === 'undefined' ? undefined : Promise.resolve,
10354 '$ %Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
10355 '$ %RangeError%': RangeError,
10356 '$ %RangeErrorPrototype%': RangeError.prototype,
10357 '$ %ReferenceError%': ReferenceError,
10358 '$ %ReferenceErrorPrototype%': ReferenceError.prototype,
10359 '$ %Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
10360 '$ %RegExp%': RegExp,
10361 '$ %RegExpPrototype%': RegExp.prototype,
10362 '$ %Set%': typeof Set === 'undefined' ? undefined : Set,
10363 '$ %SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
10364 '$ %SetPrototype%': typeof Set === 'undefined' ? undefined : Set.prototype,
10365 '$ %SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
10366 '$ %SharedArrayBufferPrototype%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer.prototype,
10367 '$ %String%': String,
10368 '$ %StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
10369 '$ %StringPrototype%': String.prototype,
10370 '$ %Symbol%': hasSymbols ? Symbol : undefined,
10371 '$ %SymbolPrototype%': hasSymbols ? Symbol.prototype : undefined,
10372 '$ %SyntaxError%': SyntaxError,
10373 '$ %SyntaxErrorPrototype%': SyntaxError.prototype,
10374 '$ %ThrowTypeError%': ThrowTypeError,
10375 '$ %TypedArray%': TypedArray,
10376 '$ %TypedArrayPrototype%': TypedArray ? TypedArray.prototype : undefined,
10377 '$ %TypeError%': TypeError,
10378 '$ %TypeErrorPrototype%': TypeError.prototype,
10379 '$ %Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
10380 '$ %Uint8ArrayPrototype%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array.prototype,
10381 '$ %Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
10382 '$ %Uint8ClampedArrayPrototype%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray.prototype,
10383 '$ %Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
10384 '$ %Uint16ArrayPrototype%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array.prototype,
10385 '$ %Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
10386 '$ %Uint32ArrayPrototype%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array.prototype,
10387 '$ %URIError%': URIError,
10388 '$ %URIErrorPrototype%': URIError.prototype,
10389 '$ %WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
10390 '$ %WeakMapPrototype%': typeof WeakMap === 'undefined' ? undefined : WeakMap.prototype,
10391 '$ %WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet,
10392 '$ %WeakSetPrototype%': typeof WeakSet === 'undefined' ? undefined : WeakSet.prototype
10393};
10394
10395module.exports = function GetIntrinsic(name, allowMissing) {
10396 if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
10397 throw new TypeError('"allowMissing" argument must be a boolean');
10398 }
10399
10400 var key = '$ ' + name;
10401 if (!(key in INTRINSICS)) {
10402 throw new SyntaxError('intrinsic ' + name + ' does not exist!');
10403 }
10404
10405 // istanbul ignore if // hopefully this is impossible to test :-)
10406 if (typeof INTRINSICS[key] === 'undefined' && !allowMissing) {
10407 throw new TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
10408 }
10409 return INTRINSICS[key];
10410};
10411
10412},{}],182:[function(require,module,exports){
10413'use strict';
10414
10415var has = require('has');
10416var toPrimitive = require('es-to-primitive/es6');
10417var keys = require('object-keys');
10418var inspect = require('object-inspect');
10419
10420var GetIntrinsic = require('./GetIntrinsic');
10421
10422var $TypeError = GetIntrinsic('%TypeError%');
10423var $RangeError = GetIntrinsic('%RangeError%');
10424var $SyntaxError = GetIntrinsic('%SyntaxError%');
10425var $Array = GetIntrinsic('%Array%');
10426var $ArrayPrototype = $Array.prototype;
10427var $String = GetIntrinsic('%String%');
10428var $Object = GetIntrinsic('%Object%');
10429var $Number = GetIntrinsic('%Number%');
10430var $Symbol = GetIntrinsic('%Symbol%', true);
10431var $RegExp = GetIntrinsic('%RegExp%');
10432var $Promise = GetIntrinsic('%Promise%', true);
10433var $preventExtensions = $Object.preventExtensions;
10434
10435var hasSymbols = require('has-symbols')();
10436
10437var assertRecord = require('./helpers/assertRecord');
10438var $isNaN = require('./helpers/isNaN');
10439var $isFinite = require('./helpers/isFinite');
10440var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1;
10441var MAX_SAFE_INTEGER = $Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
10442
10443var assign = require('./helpers/assign');
10444var sign = require('./helpers/sign');
10445var mod = require('./helpers/mod');
10446var isPrimitive = require('./helpers/isPrimitive');
10447var forEach = require('./helpers/forEach');
10448var every = require('./helpers/every');
10449var isSamePropertyDescriptor = require('./helpers/isSamePropertyDescriptor');
10450var isPropertyDescriptor = require('./helpers/isPropertyDescriptor');
10451var parseInteger = parseInt;
10452var callBind = require('./helpers/callBind');
10453var $PromiseThen = $Promise ? callBind(GetIntrinsic('%PromiseProto_then%')) : null;
10454var arraySlice = callBind($Array.prototype.slice);
10455var strSlice = callBind($String.prototype.slice);
10456var isBinary = callBind($RegExp.prototype.test, /^0b[01]+$/i);
10457var isOctal = callBind($RegExp.prototype.test, /^0o[0-7]+$/i);
10458var isDigit = callBind($RegExp.prototype.test, /^[0-9]$/);
10459var regexExec = callBind($RegExp.prototype.exec);
10460var nonWS = ['\u0085', '\u200b', '\ufffe'].join('');
10461var nonWSregex = new $RegExp('[' + nonWS + ']', 'g');
10462var hasNonWS = callBind($RegExp.prototype.test, nonWSregex);
10463var invalidHexLiteral = /^[-+]0x[0-9a-f]+$/i;
10464var isInvalidHexLiteral = callBind($RegExp.prototype.test, invalidHexLiteral);
10465var $charCodeAt = callBind($String.prototype.charCodeAt);
10466var $isEnumerable = callBind($Object.prototype.propertyIsEnumerable);
10467
10468var toStr = callBind($Object.prototype.toString);
10469
10470var $NumberValueOf = callBind(GetIntrinsic('%NumberPrototype%').valueOf);
10471var $BooleanValueOf = callBind(GetIntrinsic('%BooleanPrototype%').valueOf);
10472var $StringValueOf = callBind(GetIntrinsic('%StringPrototype%').valueOf);
10473var $DateValueOf = callBind(GetIntrinsic('%DatePrototype%').valueOf);
10474var $SymbolToString = hasSymbols && callBind(GetIntrinsic('%SymbolPrototype%').toString);
10475
10476var $floor = Math.floor;
10477var $abs = Math.abs;
10478
10479var $ObjectCreate = $Object.create;
10480var $gOPD = $Object.getOwnPropertyDescriptor;
10481var $gOPN = $Object.getOwnPropertyNames;
10482var $gOPS = $Object.getOwnPropertySymbols;
10483var $isExtensible = $Object.isExtensible;
10484var $defineProperty = $Object.defineProperty;
10485var $setProto = Object.setPrototypeOf || (
10486 // eslint-disable-next-line no-proto, no-negated-condition
10487 [].__proto__ !== Array.prototype
10488 ? null
10489 : function (O, proto) {
10490 O.__proto__ = proto; // eslint-disable-line no-proto
10491 return O;
10492 }
10493);
10494
10495var DefineOwnProperty = function DefineOwnProperty(ES, O, P, desc) {
10496 if (!$defineProperty) {
10497 if (!ES.IsDataDescriptor(desc)) {
10498 // ES3 does not support getters/setters
10499 return false;
10500 }
10501 if (!desc['[[Configurable]]'] || !desc['[[Writable]]']) {
10502 return false;
10503 }
10504
10505 // fallback for ES3
10506 if (P in O && $isEnumerable(O, P) !== !!desc['[[Enumerable]]']) {
10507 // a non-enumerable existing property
10508 return false;
10509 }
10510
10511 // property does not exist at all, or exists but is enumerable
10512 var V = desc['[[Value]]'];
10513 O[P] = V; // will use [[Define]]
10514 return ES.SameValue(O[P], V);
10515 }
10516 $defineProperty(O, P, ES.FromPropertyDescriptor(desc));
10517 return true;
10518};
10519
10520// whitespace from: https://es5.github.io/#x15.5.4.20
10521// implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324
10522var ws = [
10523 '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003',
10524 '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028',
10525 '\u2029\uFEFF'
10526].join('');
10527var trimRegex = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
10528var $replace = callBind($String.prototype.replace);
10529var trim = function (value) {
10530 return $replace(value, trimRegex, '');
10531};
10532
10533var ES5 = require('./es5');
10534
10535var hasRegExpMatcher = require('is-regex');
10536
10537// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-abstract-operations
10538var ES6 = assign(assign({}, ES5), {
10539
10540 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args
10541 Call: function Call(F, V) {
10542 var args = arguments.length > 2 ? arguments[2] : [];
10543 if (!this.IsCallable(F)) {
10544 throw new $TypeError(inspect(F) + ' is not a function');
10545 }
10546 return F.apply(V, args);
10547 },
10548
10549 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toprimitive
10550 ToPrimitive: toPrimitive,
10551
10552 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toboolean
10553 // ToBoolean: ES5.ToBoolean,
10554
10555 // https://ecma-international.org/ecma-262/6.0/#sec-tonumber
10556 ToNumber: function ToNumber(argument) {
10557 var value = isPrimitive(argument) ? argument : toPrimitive(argument, $Number);
10558 if (typeof value === 'symbol') {
10559 throw new $TypeError('Cannot convert a Symbol value to a number');
10560 }
10561 if (typeof value === 'string') {
10562 if (isBinary(value)) {
10563 return this.ToNumber(parseInteger(strSlice(value, 2), 2));
10564 } else if (isOctal(value)) {
10565 return this.ToNumber(parseInteger(strSlice(value, 2), 8));
10566 } else if (hasNonWS(value) || isInvalidHexLiteral(value)) {
10567 return NaN;
10568 } else {
10569 var trimmed = trim(value);
10570 if (trimmed !== value) {
10571 return this.ToNumber(trimmed);
10572 }
10573 }
10574 }
10575 return $Number(value);
10576 },
10577
10578 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tointeger
10579 // ToInteger: ES5.ToNumber,
10580
10581 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint32
10582 // ToInt32: ES5.ToInt32,
10583
10584 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint32
10585 // ToUint32: ES5.ToUint32,
10586
10587 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint16
10588 ToInt16: function ToInt16(argument) {
10589 var int16bit = this.ToUint16(argument);
10590 return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit;
10591 },
10592
10593 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint16
10594 // ToUint16: ES5.ToUint16,
10595
10596 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint8
10597 ToInt8: function ToInt8(argument) {
10598 var int8bit = this.ToUint8(argument);
10599 return int8bit >= 0x80 ? int8bit - 0x100 : int8bit;
10600 },
10601
10602 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8
10603 ToUint8: function ToUint8(argument) {
10604 var number = this.ToNumber(argument);
10605 if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
10606 var posInt = sign(number) * $floor($abs(number));
10607 return mod(posInt, 0x100);
10608 },
10609
10610 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8clamp
10611 ToUint8Clamp: function ToUint8Clamp(argument) {
10612 var number = this.ToNumber(argument);
10613 if ($isNaN(number) || number <= 0) { return 0; }
10614 if (number >= 0xFF) { return 0xFF; }
10615 var f = $floor(argument);
10616 if (f + 0.5 < number) { return f + 1; }
10617 if (number < f + 0.5) { return f; }
10618 if (f % 2 !== 0) { return f + 1; }
10619 return f;
10620 },
10621
10622 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tostring
10623 ToString: function ToString(argument) {
10624 if (typeof argument === 'symbol') {
10625 throw new $TypeError('Cannot convert a Symbol value to a string');
10626 }
10627 return $String(argument);
10628 },
10629
10630 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toobject
10631 ToObject: function ToObject(value) {
10632 this.RequireObjectCoercible(value);
10633 return $Object(value);
10634 },
10635
10636 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-topropertykey
10637 ToPropertyKey: function ToPropertyKey(argument) {
10638 var key = this.ToPrimitive(argument, $String);
10639 return typeof key === 'symbol' ? key : this.ToString(key);
10640 },
10641
10642 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
10643 ToLength: function ToLength(argument) {
10644 var len = this.ToInteger(argument);
10645 if (len <= 0) { return 0; } // includes converting -0 to +0
10646 if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; }
10647 return len;
10648 },
10649
10650 // https://ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring
10651 CanonicalNumericIndexString: function CanonicalNumericIndexString(argument) {
10652 if (toStr(argument) !== '[object String]') {
10653 throw new $TypeError('must be a string');
10654 }
10655 if (argument === '-0') { return -0; }
10656 var n = this.ToNumber(argument);
10657 if (this.SameValue(this.ToString(n), argument)) { return n; }
10658 return void 0;
10659 },
10660
10661 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-requireobjectcoercible
10662 RequireObjectCoercible: ES5.CheckObjectCoercible,
10663
10664 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray
10665 IsArray: $Array.isArray || function IsArray(argument) {
10666 return toStr(argument) === '[object Array]';
10667 },
10668
10669 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-iscallable
10670 // IsCallable: ES5.IsCallable,
10671
10672 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor
10673 IsConstructor: function IsConstructor(argument) {
10674 return typeof argument === 'function' && !!argument.prototype; // unfortunately there's no way to truly check this without try/catch `new argument`
10675 },
10676
10677 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isextensible-o
10678 IsExtensible: $preventExtensions
10679 ? function IsExtensible(obj) {
10680 if (isPrimitive(obj)) {
10681 return false;
10682 }
10683 return $isExtensible(obj);
10684 }
10685 : function isExtensible(obj) { return true; }, // eslint-disable-line no-unused-vars
10686
10687 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isinteger
10688 IsInteger: function IsInteger(argument) {
10689 if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) {
10690 return false;
10691 }
10692 var abs = $abs(argument);
10693 return $floor(abs) === abs;
10694 },
10695
10696 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ispropertykey
10697 IsPropertyKey: function IsPropertyKey(argument) {
10698 return typeof argument === 'string' || typeof argument === 'symbol';
10699 },
10700
10701 // https://ecma-international.org/ecma-262/6.0/#sec-isregexp
10702 IsRegExp: function IsRegExp(argument) {
10703 if (!argument || typeof argument !== 'object') {
10704 return false;
10705 }
10706 if (hasSymbols) {
10707 var isRegExp = argument[$Symbol.match];
10708 if (typeof isRegExp !== 'undefined') {
10709 return ES5.ToBoolean(isRegExp);
10710 }
10711 }
10712 return hasRegExpMatcher(argument);
10713 },
10714
10715 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevalue
10716 // SameValue: ES5.SameValue,
10717
10718 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero
10719 SameValueZero: function SameValueZero(x, y) {
10720 return (x === y) || ($isNaN(x) && $isNaN(y));
10721 },
10722
10723 /**
10724 * 7.3.2 GetV (V, P)
10725 * 1. Assert: IsPropertyKey(P) is true.
10726 * 2. Let O be ToObject(V).
10727 * 3. ReturnIfAbrupt(O).
10728 * 4. Return O.[[Get]](P, V).
10729 */
10730 GetV: function GetV(V, P) {
10731 // 7.3.2.1
10732 if (!this.IsPropertyKey(P)) {
10733 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
10734 }
10735
10736 // 7.3.2.2-3
10737 var O = this.ToObject(V);
10738
10739 // 7.3.2.4
10740 return O[P];
10741 },
10742
10743 /**
10744 * 7.3.9 - https://ecma-international.org/ecma-262/6.0/#sec-getmethod
10745 * 1. Assert: IsPropertyKey(P) is true.
10746 * 2. Let func be GetV(O, P).
10747 * 3. ReturnIfAbrupt(func).
10748 * 4. If func is either undefined or null, return undefined.
10749 * 5. If IsCallable(func) is false, throw a TypeError exception.
10750 * 6. Return func.
10751 */
10752 GetMethod: function GetMethod(O, P) {
10753 // 7.3.9.1
10754 if (!this.IsPropertyKey(P)) {
10755 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
10756 }
10757
10758 // 7.3.9.2
10759 var func = this.GetV(O, P);
10760
10761 // 7.3.9.4
10762 if (func == null) {
10763 return void 0;
10764 }
10765
10766 // 7.3.9.5
10767 if (!this.IsCallable(func)) {
10768 throw new $TypeError(P + 'is not a function');
10769 }
10770
10771 // 7.3.9.6
10772 return func;
10773 },
10774
10775 /**
10776 * 7.3.1 Get (O, P) - https://ecma-international.org/ecma-262/6.0/#sec-get-o-p
10777 * 1. Assert: Type(O) is Object.
10778 * 2. Assert: IsPropertyKey(P) is true.
10779 * 3. Return O.[[Get]](P, O).
10780 */
10781 Get: function Get(O, P) {
10782 // 7.3.1.1
10783 if (this.Type(O) !== 'Object') {
10784 throw new $TypeError('Assertion failed: Type(O) is not Object');
10785 }
10786 // 7.3.1.2
10787 if (!this.IsPropertyKey(P)) {
10788 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P));
10789 }
10790 // 7.3.1.3
10791 return O[P];
10792 },
10793
10794 Type: function Type(x) {
10795 if (typeof x === 'symbol') {
10796 return 'Symbol';
10797 }
10798 return ES5.Type(x);
10799 },
10800
10801 // https://ecma-international.org/ecma-262/6.0/#sec-speciesconstructor
10802 SpeciesConstructor: function SpeciesConstructor(O, defaultConstructor) {
10803 if (this.Type(O) !== 'Object') {
10804 throw new $TypeError('Assertion failed: Type(O) is not Object');
10805 }
10806 var C = O.constructor;
10807 if (typeof C === 'undefined') {
10808 return defaultConstructor;
10809 }
10810 if (this.Type(C) !== 'Object') {
10811 throw new $TypeError('O.constructor is not an Object');
10812 }
10813 var S = hasSymbols && $Symbol.species ? C[$Symbol.species] : void 0;
10814 if (S == null) {
10815 return defaultConstructor;
10816 }
10817 if (this.IsConstructor(S)) {
10818 return S;
10819 }
10820 throw new $TypeError('no constructor found');
10821 },
10822
10823 // https://www.ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor
10824 FromPropertyDescriptor: function FromPropertyDescriptor(Desc) {
10825 if (typeof Desc === 'undefined') {
10826 return Desc;
10827 }
10828
10829 assertRecord(this, 'Property Descriptor', 'Desc', Desc);
10830
10831 var obj = {};
10832 if ('[[Value]]' in Desc) {
10833 obj.value = Desc['[[Value]]'];
10834 }
10835 if ('[[Writable]]' in Desc) {
10836 obj.writable = Desc['[[Writable]]'];
10837 }
10838 if ('[[Get]]' in Desc) {
10839 obj.get = Desc['[[Get]]'];
10840 }
10841 if ('[[Set]]' in Desc) {
10842 obj.set = Desc['[[Set]]'];
10843 }
10844 if ('[[Enumerable]]' in Desc) {
10845 obj.enumerable = Desc['[[Enumerable]]'];
10846 }
10847 if ('[[Configurable]]' in Desc) {
10848 obj.configurable = Desc['[[Configurable]]'];
10849 }
10850 return obj;
10851 },
10852
10853 // https://ecma-international.org/ecma-262/6.0/#sec-completepropertydescriptor
10854 CompletePropertyDescriptor: function CompletePropertyDescriptor(Desc) {
10855 assertRecord(this, 'Property Descriptor', 'Desc', Desc);
10856
10857 if (this.IsGenericDescriptor(Desc) || this.IsDataDescriptor(Desc)) {
10858 if (!has(Desc, '[[Value]]')) {
10859 Desc['[[Value]]'] = void 0;
10860 }
10861 if (!has(Desc, '[[Writable]]')) {
10862 Desc['[[Writable]]'] = false;
10863 }
10864 } else {
10865 if (!has(Desc, '[[Get]]')) {
10866 Desc['[[Get]]'] = void 0;
10867 }
10868 if (!has(Desc, '[[Set]]')) {
10869 Desc['[[Set]]'] = void 0;
10870 }
10871 }
10872 if (!has(Desc, '[[Enumerable]]')) {
10873 Desc['[[Enumerable]]'] = false;
10874 }
10875 if (!has(Desc, '[[Configurable]]')) {
10876 Desc['[[Configurable]]'] = false;
10877 }
10878 return Desc;
10879 },
10880
10881 // https://ecma-international.org/ecma-262/6.0/#sec-set-o-p-v-throw
10882 Set: function Set(O, P, V, Throw) {
10883 if (this.Type(O) !== 'Object') {
10884 throw new $TypeError('O must be an Object');
10885 }
10886 if (!this.IsPropertyKey(P)) {
10887 throw new $TypeError('P must be a Property Key');
10888 }
10889 if (this.Type(Throw) !== 'Boolean') {
10890 throw new $TypeError('Throw must be a Boolean');
10891 }
10892 if (Throw) {
10893 O[P] = V;
10894 return true;
10895 } else {
10896 try {
10897 O[P] = V;
10898 } catch (e) {
10899 return false;
10900 }
10901 }
10902 },
10903
10904 // https://ecma-international.org/ecma-262/6.0/#sec-hasownproperty
10905 HasOwnProperty: function HasOwnProperty(O, P) {
10906 if (this.Type(O) !== 'Object') {
10907 throw new $TypeError('O must be an Object');
10908 }
10909 if (!this.IsPropertyKey(P)) {
10910 throw new $TypeError('P must be a Property Key');
10911 }
10912 return has(O, P);
10913 },
10914
10915 // https://ecma-international.org/ecma-262/6.0/#sec-hasproperty
10916 HasProperty: function HasProperty(O, P) {
10917 if (this.Type(O) !== 'Object') {
10918 throw new $TypeError('O must be an Object');
10919 }
10920 if (!this.IsPropertyKey(P)) {
10921 throw new $TypeError('P must be a Property Key');
10922 }
10923 return P in O;
10924 },
10925
10926 // https://ecma-international.org/ecma-262/6.0/#sec-isconcatspreadable
10927 IsConcatSpreadable: function IsConcatSpreadable(O) {
10928 if (this.Type(O) !== 'Object') {
10929 return false;
10930 }
10931 if (hasSymbols && typeof $Symbol.isConcatSpreadable === 'symbol') {
10932 var spreadable = this.Get(O, Symbol.isConcatSpreadable);
10933 if (typeof spreadable !== 'undefined') {
10934 return this.ToBoolean(spreadable);
10935 }
10936 }
10937 return this.IsArray(O);
10938 },
10939
10940 // https://ecma-international.org/ecma-262/6.0/#sec-invoke
10941 Invoke: function Invoke(O, P) {
10942 if (!this.IsPropertyKey(P)) {
10943 throw new $TypeError('P must be a Property Key');
10944 }
10945 var argumentsList = arraySlice(arguments, 2);
10946 var func = this.GetV(O, P);
10947 return this.Call(func, O, argumentsList);
10948 },
10949
10950 // https://ecma-international.org/ecma-262/6.0/#sec-getiterator
10951 GetIterator: function GetIterator(obj, method) {
10952 var actualMethod = method;
10953 if (arguments.length < 2) {
10954 if (!hasSymbols) {
10955 throw new SyntaxError('GetIterator depends on native Symbol support when `method` is not passed');
10956 }
10957 actualMethod = this.GetMethod(obj, $Symbol.iterator);
10958 }
10959 var iterator = this.Call(actualMethod, obj);
10960 if (this.Type(iterator) !== 'Object') {
10961 throw new $TypeError('iterator must return an object');
10962 }
10963
10964 return iterator;
10965 },
10966
10967 // https://ecma-international.org/ecma-262/6.0/#sec-iteratornext
10968 IteratorNext: function IteratorNext(iterator, value) {
10969 var result = this.Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]);
10970 if (this.Type(result) !== 'Object') {
10971 throw new $TypeError('iterator next must return an object');
10972 }
10973 return result;
10974 },
10975
10976 // https://ecma-international.org/ecma-262/6.0/#sec-iteratorcomplete
10977 IteratorComplete: function IteratorComplete(iterResult) {
10978 if (this.Type(iterResult) !== 'Object') {
10979 throw new $TypeError('Assertion failed: Type(iterResult) is not Object');
10980 }
10981 return this.ToBoolean(this.Get(iterResult, 'done'));
10982 },
10983
10984 // https://ecma-international.org/ecma-262/6.0/#sec-iteratorvalue
10985 IteratorValue: function IteratorValue(iterResult) {
10986 if (this.Type(iterResult) !== 'Object') {
10987 throw new $TypeError('Assertion failed: Type(iterResult) is not Object');
10988 }
10989 return this.Get(iterResult, 'value');
10990 },
10991
10992 // https://ecma-international.org/ecma-262/6.0/#sec-iteratorstep
10993 IteratorStep: function IteratorStep(iterator) {
10994 var result = this.IteratorNext(iterator);
10995 var done = this.IteratorComplete(result);
10996 return done === true ? false : result;
10997 },
10998
10999 // https://ecma-international.org/ecma-262/6.0/#sec-iteratorclose
11000 IteratorClose: function IteratorClose(iterator, completion) {
11001 if (this.Type(iterator) !== 'Object') {
11002 throw new $TypeError('Assertion failed: Type(iterator) is not Object');
11003 }
11004 if (!this.IsCallable(completion)) {
11005 throw new $TypeError('Assertion failed: completion is not a thunk for a Completion Record');
11006 }
11007 var completionThunk = completion;
11008
11009 var iteratorReturn = this.GetMethod(iterator, 'return');
11010
11011 if (typeof iteratorReturn === 'undefined') {
11012 return completionThunk();
11013 }
11014
11015 var completionRecord;
11016 try {
11017 var innerResult = this.Call(iteratorReturn, iterator, []);
11018 } catch (e) {
11019 // if we hit here, then "e" is the innerResult completion that needs re-throwing
11020
11021 // if the completion is of type "throw", this will throw.
11022 completionRecord = completionThunk();
11023 completionThunk = null; // ensure it's not called twice.
11024
11025 // if not, then return the innerResult completion
11026 throw e;
11027 }
11028 completionRecord = completionThunk(); // if innerResult worked, then throw if the completion does
11029 completionThunk = null; // ensure it's not called twice.
11030
11031 if (this.Type(innerResult) !== 'Object') {
11032 throw new $TypeError('iterator .return must return an object');
11033 }
11034
11035 return completionRecord;
11036 },
11037
11038 // https://ecma-international.org/ecma-262/6.0/#sec-createiterresultobject
11039 CreateIterResultObject: function CreateIterResultObject(value, done) {
11040 if (this.Type(done) !== 'Boolean') {
11041 throw new $TypeError('Assertion failed: Type(done) is not Boolean');
11042 }
11043 return {
11044 value: value,
11045 done: done
11046 };
11047 },
11048
11049 // https://ecma-international.org/ecma-262/6.0/#sec-regexpexec
11050 RegExpExec: function RegExpExec(R, S) {
11051 if (this.Type(R) !== 'Object') {
11052 throw new $TypeError('R must be an Object');
11053 }
11054 if (this.Type(S) !== 'String') {
11055 throw new $TypeError('S must be a String');
11056 }
11057 var exec = this.Get(R, 'exec');
11058 if (this.IsCallable(exec)) {
11059 var result = this.Call(exec, R, [S]);
11060 if (result === null || this.Type(result) === 'Object') {
11061 return result;
11062 }
11063 throw new $TypeError('"exec" method must return `null` or an Object');
11064 }
11065 return regexExec(R, S);
11066 },
11067
11068 // https://ecma-international.org/ecma-262/6.0/#sec-arrayspeciescreate
11069 ArraySpeciesCreate: function ArraySpeciesCreate(originalArray, length) {
11070 if (!this.IsInteger(length) || length < 0) {
11071 throw new $TypeError('Assertion failed: length must be an integer >= 0');
11072 }
11073 var len = length === 0 ? 0 : length;
11074 var C;
11075 var isArray = this.IsArray(originalArray);
11076 if (isArray) {
11077 C = this.Get(originalArray, 'constructor');
11078 // TODO: figure out how to make a cross-realm normal Array, a same-realm Array
11079 // if (this.IsConstructor(C)) {
11080 // if C is another realm's Array, C = undefined
11081 // Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(Array))) === null ?
11082 // }
11083 if (this.Type(C) === 'Object' && hasSymbols && $Symbol.species) {
11084 C = this.Get(C, $Symbol.species);
11085 if (C === null) {
11086 C = void 0;
11087 }
11088 }
11089 }
11090 if (typeof C === 'undefined') {
11091 return $Array(len);
11092 }
11093 if (!this.IsConstructor(C)) {
11094 throw new $TypeError('C must be a constructor');
11095 }
11096 return new C(len); // this.Construct(C, len);
11097 },
11098
11099 CreateDataProperty: function CreateDataProperty(O, P, V) {
11100 if (this.Type(O) !== 'Object') {
11101 throw new $TypeError('Assertion failed: Type(O) is not Object');
11102 }
11103 if (!this.IsPropertyKey(P)) {
11104 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
11105 }
11106 var oldDesc = $gOPD(O, P);
11107 var extensible = oldDesc || this.IsExtensible(O);
11108 var immutable = oldDesc && (!oldDesc.writable || !oldDesc.configurable);
11109 if (immutable || !extensible) {
11110 return false;
11111 }
11112 return DefineOwnProperty(this, O, P, {
11113 '[[Configurable]]': true,
11114 '[[Enumerable]]': true,
11115 '[[Value]]': V,
11116 '[[Writable]]': true
11117 });
11118 },
11119
11120 // https://ecma-international.org/ecma-262/6.0/#sec-createdatapropertyorthrow
11121 CreateDataPropertyOrThrow: function CreateDataPropertyOrThrow(O, P, V) {
11122 if (this.Type(O) !== 'Object') {
11123 throw new $TypeError('Assertion failed: Type(O) is not Object');
11124 }
11125 if (!this.IsPropertyKey(P)) {
11126 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
11127 }
11128 var success = this.CreateDataProperty(O, P, V);
11129 if (!success) {
11130 throw new $TypeError('unable to create data property');
11131 }
11132 return success;
11133 },
11134
11135 // https://www.ecma-international.org/ecma-262/6.0/#sec-objectcreate
11136 ObjectCreate: function ObjectCreate(proto, internalSlotsList) {
11137 if (proto !== null && this.Type(proto) !== 'Object') {
11138 throw new $TypeError('Assertion failed: proto must be null or an object');
11139 }
11140 var slots = arguments.length < 2 ? [] : internalSlotsList;
11141 if (slots.length > 0) {
11142 throw new $SyntaxError('es-abstract does not yet support internal slots');
11143 }
11144
11145 if (proto === null && !$ObjectCreate) {
11146 throw new $SyntaxError('native Object.create support is required to create null objects');
11147 }
11148
11149 return $ObjectCreate(proto);
11150 },
11151
11152 // https://ecma-international.org/ecma-262/6.0/#sec-advancestringindex
11153 AdvanceStringIndex: function AdvanceStringIndex(S, index, unicode) {
11154 if (this.Type(S) !== 'String') {
11155 throw new $TypeError('S must be a String');
11156 }
11157 if (!this.IsInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) {
11158 throw new $TypeError('Assertion failed: length must be an integer >= 0 and <= 2**53');
11159 }
11160 if (this.Type(unicode) !== 'Boolean') {
11161 throw new $TypeError('Assertion failed: unicode must be a Boolean');
11162 }
11163 if (!unicode) {
11164 return index + 1;
11165 }
11166 var length = S.length;
11167 if ((index + 1) >= length) {
11168 return index + 1;
11169 }
11170
11171 var first = $charCodeAt(S, index);
11172 if (first < 0xD800 || first > 0xDBFF) {
11173 return index + 1;
11174 }
11175
11176 var second = $charCodeAt(S, index + 1);
11177 if (second < 0xDC00 || second > 0xDFFF) {
11178 return index + 1;
11179 }
11180
11181 return index + 2;
11182 },
11183
11184 // https://www.ecma-international.org/ecma-262/6.0/#sec-createmethodproperty
11185 CreateMethodProperty: function CreateMethodProperty(O, P, V) {
11186 if (this.Type(O) !== 'Object') {
11187 throw new $TypeError('Assertion failed: Type(O) is not Object');
11188 }
11189
11190 if (!this.IsPropertyKey(P)) {
11191 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
11192 }
11193
11194 var newDesc = {
11195 '[[Configurable]]': true,
11196 '[[Enumerable]]': false,
11197 '[[Value]]': V,
11198 '[[Writable]]': true
11199 };
11200 return DefineOwnProperty(this, O, P, newDesc);
11201 },
11202
11203 // https://www.ecma-international.org/ecma-262/6.0/#sec-definepropertyorthrow
11204 DefinePropertyOrThrow: function DefinePropertyOrThrow(O, P, desc) {
11205 if (this.Type(O) !== 'Object') {
11206 throw new $TypeError('Assertion failed: Type(O) is not Object');
11207 }
11208
11209 if (!this.IsPropertyKey(P)) {
11210 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
11211 }
11212
11213 var Desc = isPropertyDescriptor(this, desc) ? desc : this.ToPropertyDescriptor(desc);
11214 if (!isPropertyDescriptor(this, Desc)) {
11215 throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor');
11216 }
11217
11218 return DefineOwnProperty(this, O, P, Desc);
11219 },
11220
11221 // https://www.ecma-international.org/ecma-262/6.0/#sec-deletepropertyorthrow
11222 DeletePropertyOrThrow: function DeletePropertyOrThrow(O, P) {
11223 if (this.Type(O) !== 'Object') {
11224 throw new $TypeError('Assertion failed: Type(O) is not Object');
11225 }
11226
11227 if (!this.IsPropertyKey(P)) {
11228 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
11229 }
11230
11231 var success = delete O[P];
11232 if (!success) {
11233 throw new TypeError('Attempt to delete property failed.');
11234 }
11235 return success;
11236 },
11237
11238 // https://www.ecma-international.org/ecma-262/6.0/#sec-enumerableownnames
11239 EnumerableOwnNames: function EnumerableOwnNames(O) {
11240 if (this.Type(O) !== 'Object') {
11241 throw new $TypeError('Assertion failed: Type(O) is not Object');
11242 }
11243
11244 return keys(O);
11245 },
11246
11247 // https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-number-prototype-object
11248 thisNumberValue: function thisNumberValue(value) {
11249 if (this.Type(value) === 'Number') {
11250 return value;
11251 }
11252
11253 return $NumberValueOf(value);
11254 },
11255
11256 // https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-boolean-prototype-object
11257 thisBooleanValue: function thisBooleanValue(value) {
11258 if (this.Type(value) === 'Boolean') {
11259 return value;
11260 }
11261
11262 return $BooleanValueOf(value);
11263 },
11264
11265 // https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-string-prototype-object
11266 thisStringValue: function thisStringValue(value) {
11267 if (this.Type(value) === 'String') {
11268 return value;
11269 }
11270
11271 return $StringValueOf(value);
11272 },
11273
11274 // https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-date-prototype-object
11275 thisTimeValue: function thisTimeValue(value) {
11276 return $DateValueOf(value);
11277 },
11278
11279 // https://www.ecma-international.org/ecma-262/6.0/#sec-setintegritylevel
11280 SetIntegrityLevel: function SetIntegrityLevel(O, level) {
11281 if (this.Type(O) !== 'Object') {
11282 throw new $TypeError('Assertion failed: Type(O) is not Object');
11283 }
11284 if (level !== 'sealed' && level !== 'frozen') {
11285 throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`');
11286 }
11287 if (!$preventExtensions) {
11288 throw new $SyntaxError('SetIntegrityLevel requires native `Object.preventExtensions` support');
11289 }
11290 var status = $preventExtensions(O);
11291 if (!status) {
11292 return false;
11293 }
11294 if (!$gOPN) {
11295 throw new $SyntaxError('SetIntegrityLevel requires native `Object.getOwnPropertyNames` support');
11296 }
11297 var theKeys = $gOPN(O);
11298 var ES = this;
11299 if (level === 'sealed') {
11300 forEach(theKeys, function (k) {
11301 ES.DefinePropertyOrThrow(O, k, { configurable: false });
11302 });
11303 } else if (level === 'frozen') {
11304 forEach(theKeys, function (k) {
11305 var currentDesc = $gOPD(O, k);
11306 if (typeof currentDesc !== 'undefined') {
11307 var desc;
11308 if (ES.IsAccessorDescriptor(ES.ToPropertyDescriptor(currentDesc))) {
11309 desc = { configurable: false };
11310 } else {
11311 desc = { configurable: false, writable: false };
11312 }
11313 ES.DefinePropertyOrThrow(O, k, desc);
11314 }
11315 });
11316 }
11317 return true;
11318 },
11319
11320 // https://www.ecma-international.org/ecma-262/6.0/#sec-testintegritylevel
11321 TestIntegrityLevel: function TestIntegrityLevel(O, level) {
11322 if (this.Type(O) !== 'Object') {
11323 throw new $TypeError('Assertion failed: Type(O) is not Object');
11324 }
11325 if (level !== 'sealed' && level !== 'frozen') {
11326 throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`');
11327 }
11328 var status = this.IsExtensible(O);
11329 if (status) {
11330 return false;
11331 }
11332 var theKeys = $gOPN(O);
11333 var ES = this;
11334 return theKeys.length === 0 || every(theKeys, function (k) {
11335 var currentDesc = $gOPD(O, k);
11336 if (typeof currentDesc !== 'undefined') {
11337 if (currentDesc.configurable) {
11338 return false;
11339 }
11340 if (level === 'frozen' && ES.IsDataDescriptor(ES.ToPropertyDescriptor(currentDesc)) && currentDesc.writable) {
11341 return false;
11342 }
11343 }
11344 return true;
11345 });
11346 },
11347
11348 // https://www.ecma-international.org/ecma-262/6.0/#sec-ordinaryhasinstance
11349 OrdinaryHasInstance: function OrdinaryHasInstance(C, O) {
11350 if (this.IsCallable(C) === false) {
11351 return false;
11352 }
11353 if (this.Type(O) !== 'Object') {
11354 return false;
11355 }
11356 var P = this.Get(C, 'prototype');
11357 if (this.Type(P) !== 'Object') {
11358 throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.');
11359 }
11360 return O instanceof C;
11361 },
11362
11363 // https://www.ecma-international.org/ecma-262/6.0/#sec-ordinaryhasproperty
11364 OrdinaryHasProperty: function OrdinaryHasProperty(O, P) {
11365 if (this.Type(O) !== 'Object') {
11366 throw new $TypeError('Assertion failed: Type(O) is not Object');
11367 }
11368 if (!this.IsPropertyKey(P)) {
11369 throw new $TypeError('Assertion failed: P must be a Property Key');
11370 }
11371 return P in O;
11372 },
11373
11374 // https://www.ecma-international.org/ecma-262/6.0/#sec-instanceofoperator
11375 InstanceofOperator: function InstanceofOperator(O, C) {
11376 if (this.Type(O) !== 'Object') {
11377 throw new $TypeError('Assertion failed: Type(O) is not Object');
11378 }
11379 var instOfHandler = hasSymbols && $Symbol.hasInstance ? this.GetMethod(C, $Symbol.hasInstance) : void 0;
11380 if (typeof instOfHandler !== 'undefined') {
11381 return this.ToBoolean(this.Call(instOfHandler, C, [O]));
11382 }
11383 if (!this.IsCallable(C)) {
11384 throw new $TypeError('`C` is not Callable');
11385 }
11386 return this.OrdinaryHasInstance(C, O);
11387 },
11388
11389 // https://www.ecma-international.org/ecma-262/6.0/#sec-ispromise
11390 IsPromise: function IsPromise(x) {
11391 if (this.Type(x) !== 'Object') {
11392 return false;
11393 }
11394 if (!$Promise) { // Promises are not supported
11395 return false;
11396 }
11397 try {
11398 $PromiseThen(x); // throws if not a promise
11399 } catch (e) {
11400 return false;
11401 }
11402 return true;
11403 },
11404
11405 // https://www.ecma-international.org/ecma-262/6.0/#sec-abstract-equality-comparison
11406 'Abstract Equality Comparison': function AbstractEqualityComparison(x, y) {
11407 var xType = this.Type(x);
11408 var yType = this.Type(y);
11409 if (xType === yType) {
11410 return x === y; // ES6+ specified this shortcut anyways.
11411 }
11412 if (x == null && y == null) {
11413 return true;
11414 }
11415 if (xType === 'Number' && yType === 'String') {
11416 return this['Abstract Equality Comparison'](x, this.ToNumber(y));
11417 }
11418 if (xType === 'String' && yType === 'Number') {
11419 return this['Abstract Equality Comparison'](this.ToNumber(x), y);
11420 }
11421 if (xType === 'Boolean') {
11422 return this['Abstract Equality Comparison'](this.ToNumber(x), y);
11423 }
11424 if (yType === 'Boolean') {
11425 return this['Abstract Equality Comparison'](x, this.ToNumber(y));
11426 }
11427 if ((xType === 'String' || xType === 'Number' || xType === 'Symbol') && yType === 'Object') {
11428 return this['Abstract Equality Comparison'](x, this.ToPrimitive(y));
11429 }
11430 if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'Symbol')) {
11431 return this['Abstract Equality Comparison'](this.ToPrimitive(x), y);
11432 }
11433 return false;
11434 },
11435
11436 // eslint-disable-next-line max-lines-per-function, max-statements, id-length, max-params
11437 ValidateAndApplyPropertyDescriptor: function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) {
11438 // this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic.
11439 var oType = this.Type(O);
11440 if (oType !== 'Undefined' && oType !== 'Object') {
11441 throw new $TypeError('Assertion failed: O must be undefined or an Object');
11442 }
11443 if (this.Type(extensible) !== 'Boolean') {
11444 throw new $TypeError('Assertion failed: extensible must be a Boolean');
11445 }
11446 if (!isPropertyDescriptor(this, Desc)) {
11447 throw new $TypeError('Assertion failed: Desc must be a Property Descriptor');
11448 }
11449 if (this.Type(current) !== 'Undefined' && !isPropertyDescriptor(this, current)) {
11450 throw new $TypeError('Assertion failed: current must be a Property Descriptor, or undefined');
11451 }
11452 if (oType !== 'Undefined' && !this.IsPropertyKey(P)) {
11453 throw new $TypeError('Assertion failed: if O is not undefined, P must be a Property Key');
11454 }
11455 if (this.Type(current) === 'Undefined') {
11456 if (!extensible) {
11457 return false;
11458 }
11459 if (this.IsGenericDescriptor(Desc) || this.IsDataDescriptor(Desc)) {
11460 if (oType !== 'Undefined') {
11461 DefineOwnProperty(this, O, P, {
11462 '[[Configurable]]': Desc['[[Configurable]]'],
11463 '[[Enumerable]]': Desc['[[Enumerable]]'],
11464 '[[Value]]': Desc['[[Value]]'],
11465 '[[Writable]]': Desc['[[Writable]]']
11466 });
11467 }
11468 } else {
11469 if (!this.IsAccessorDescriptor(Desc)) {
11470 throw new $TypeError('Assertion failed: Desc is not an accessor descriptor');
11471 }
11472 if (oType !== 'Undefined') {
11473 return DefineOwnProperty(this, O, P, Desc);
11474 }
11475 }
11476 return true;
11477 }
11478 if (this.IsGenericDescriptor(Desc) && !('[[Configurable]]' in Desc) && !('[[Enumerable]]' in Desc)) {
11479 return true;
11480 }
11481 if (isSamePropertyDescriptor(this, Desc, current)) {
11482 return true; // removed by ES2017, but should still be correct
11483 }
11484 // "if every field in Desc is absent, return true" can't really match the assertion that it's a Property Descriptor
11485 if (!current['[[Configurable]]']) {
11486 if (Desc['[[Configurable]]']) {
11487 return false;
11488 }
11489 if ('[[Enumerable]]' in Desc && !Desc['[[Enumerable]]'] === !!current['[[Enumerable]]']) {
11490 return false;
11491 }
11492 }
11493 if (this.IsGenericDescriptor(Desc)) {
11494 // no further validation is required.
11495 } else if (this.IsDataDescriptor(current) !== this.IsDataDescriptor(Desc)) {
11496 if (!current['[[Configurable]]']) {
11497 return false;
11498 }
11499 if (this.IsDataDescriptor(current)) {
11500 if (oType !== 'Undefined') {
11501 DefineOwnProperty(this, O, P, {
11502 '[[Configurable]]': current['[[Configurable]]'],
11503 '[[Enumerable]]': current['[[Enumerable]]'],
11504 '[[Get]]': undefined
11505 });
11506 }
11507 } else if (oType !== 'Undefined') {
11508 DefineOwnProperty(this, O, P, {
11509 '[[Configurable]]': current['[[Configurable]]'],
11510 '[[Enumerable]]': current['[[Enumerable]]'],
11511 '[[Value]]': undefined
11512 });
11513 }
11514 } else if (this.IsDataDescriptor(current) && this.IsDataDescriptor(Desc)) {
11515 if (!current['[[Configurable]]'] && !current['[[Writable]]']) {
11516 if ('[[Writable]]' in Desc && Desc['[[Writable]]']) {
11517 return false;
11518 }
11519 if ('[[Value]]' in Desc && !this.SameValue(Desc['[[Value]]'], current['[[Value]]'])) {
11520 return false;
11521 }
11522 return true;
11523 }
11524 } else if (this.IsAccessorDescriptor(current) && this.IsAccessorDescriptor(Desc)) {
11525 if (!current['[[Configurable]]']) {
11526 if ('[[Set]]' in Desc && !this.SameValue(Desc['[[Set]]'], current['[[Set]]'])) {
11527 return false;
11528 }
11529 if ('[[Get]]' in Desc && !this.SameValue(Desc['[[Get]]'], current['[[Get]]'])) {
11530 return false;
11531 }
11532 return true;
11533 }
11534 } else {
11535 throw new $TypeError('Assertion failed: current and Desc are not both data, both accessors, or one accessor and one data.');
11536 }
11537 if (oType !== 'Undefined') {
11538 return DefineOwnProperty(this, O, P, Desc);
11539 }
11540 return true;
11541 },
11542
11543 // https://www.ecma-international.org/ecma-262/6.0/#sec-ordinarydefineownproperty
11544 OrdinaryDefineOwnProperty: function OrdinaryDefineOwnProperty(O, P, Desc) {
11545 if (this.Type(O) !== 'Object') {
11546 throw new $TypeError('Assertion failed: O must be an Object');
11547 }
11548 if (!this.IsPropertyKey(P)) {
11549 throw new $TypeError('Assertion failed: P must be a Property Key');
11550 }
11551 if (!isPropertyDescriptor(this, Desc)) {
11552 throw new $TypeError('Assertion failed: Desc must be a Property Descriptor');
11553 }
11554 var desc = $gOPD(O, P);
11555 var current = desc && this.ToPropertyDescriptor(desc);
11556 var extensible = this.IsExtensible(O);
11557 return this.ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current);
11558 },
11559
11560 // https://www.ecma-international.org/ecma-262/6.0/#sec-ordinarygetownproperty
11561 OrdinaryGetOwnProperty: function OrdinaryGetOwnProperty(O, P) {
11562 if (this.Type(O) !== 'Object') {
11563 throw new $TypeError('Assertion failed: O must be an Object');
11564 }
11565 if (!this.IsPropertyKey(P)) {
11566 throw new $TypeError('Assertion failed: P must be a Property Key');
11567 }
11568 if (!has(O, P)) {
11569 return void 0;
11570 }
11571 if (!$gOPD) {
11572 // ES3 fallback
11573 var arrayLength = this.IsArray(O) && P === 'length';
11574 var regexLastIndex = this.IsRegExp(O) && P === 'lastIndex';
11575 return {
11576 '[[Configurable]]': !(arrayLength || regexLastIndex),
11577 '[[Enumerable]]': $isEnumerable(O, P),
11578 '[[Value]]': O[P],
11579 '[[Writable]]': true
11580 };
11581 }
11582 return this.ToPropertyDescriptor($gOPD(O, P));
11583 },
11584
11585 // https://www.ecma-international.org/ecma-262/6.0/#sec-arraycreate
11586 ArrayCreate: function ArrayCreate(length) {
11587 if (!this.IsInteger(length) || length < 0) {
11588 throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0');
11589 }
11590 if (length > MAX_ARRAY_LENGTH) {
11591 throw new $RangeError('length is greater than (2**32 - 1)');
11592 }
11593 var proto = arguments.length > 1 ? arguments[1] : $ArrayPrototype;
11594 var A = []; // steps 5 - 7, and 9
11595 if (proto !== $ArrayPrototype) { // step 8
11596 if (!$setProto) {
11597 throw new $SyntaxError('ArrayCreate: a `proto` argument that is not `Array.prototype` is not supported in an environment that does not support setting the [[Prototype]]');
11598 }
11599 $setProto(A, proto);
11600 }
11601 if (length !== 0) { // bypasses the need for step 2
11602 A.length = length;
11603 }
11604 /* step 10, the above as a shortcut for the below
11605 this.OrdinaryDefineOwnProperty(A, 'length', {
11606 '[[Configurable]]': false,
11607 '[[Enumerable]]': false,
11608 '[[Value]]': length,
11609 '[[Writable]]': true
11610 });
11611 */
11612 return A;
11613 },
11614
11615 // eslint-disable-next-line max-statements, max-lines-per-function
11616 ArraySetLength: function ArraySetLength(A, Desc) {
11617 if (!this.IsArray(A)) {
11618 throw new $TypeError('Assertion failed: A must be an Array');
11619 }
11620 if (!isPropertyDescriptor(this, Desc)) {
11621 throw new $TypeError('Assertion failed: Desc must be a Property Descriptor');
11622 }
11623 if (!('[[Value]]' in Desc)) {
11624 return this.OrdinaryDefineOwnProperty(A, 'length', Desc);
11625 }
11626 var newLenDesc = assign({}, Desc);
11627 var newLen = this.ToUint32(Desc['[[Value]]']);
11628 var numberLen = this.ToNumber(Desc['[[Value]]']);
11629 if (newLen !== numberLen) {
11630 throw new $RangeError('Invalid array length');
11631 }
11632 newLenDesc['[[Value]]'] = newLen;
11633 var oldLenDesc = this.OrdinaryGetOwnProperty(A, 'length');
11634 if (!this.IsDataDescriptor(oldLenDesc)) {
11635 throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`');
11636 }
11637 var oldLen = oldLenDesc['[[Value]]'];
11638 if (newLen >= oldLen) {
11639 return this.OrdinaryDefineOwnProperty(A, 'length', newLenDesc);
11640 }
11641 if (!oldLenDesc['[[Writable]]']) {
11642 return false;
11643 }
11644 var newWritable;
11645 if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) {
11646 newWritable = true;
11647 } else {
11648 newWritable = false;
11649 newLenDesc['[[Writable]]'] = true;
11650 }
11651 var succeeded = this.OrdinaryDefineOwnProperty(A, 'length', newLenDesc);
11652 if (!succeeded) {
11653 return false;
11654 }
11655 while (newLen < oldLen) {
11656 oldLen -= 1;
11657 var deleteSucceeded = delete A[this.ToString(oldLen)];
11658 if (!deleteSucceeded) {
11659 newLenDesc['[[Value]]'] = oldLen + 1;
11660 if (!newWritable) {
11661 newLenDesc['[[Writable]]'] = false;
11662 this.OrdinaryDefineOwnProperty(A, 'length', newLenDesc);
11663 return false;
11664 }
11665 }
11666 }
11667 if (!newWritable) {
11668 return this.OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false });
11669 }
11670 return true;
11671 },
11672
11673 // https://www.ecma-international.org/ecma-262/6.0/#sec-createhtml
11674 CreateHTML: function CreateHTML(string, tag, attribute, value) {
11675 if (this.Type(tag) !== 'String' || this.Type(attribute) !== 'String') {
11676 throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings');
11677 }
11678 var str = this.RequireObjectCoercible(string);
11679 var S = this.ToString(str);
11680 var p1 = '<' + tag;
11681 if (attribute !== '') {
11682 var V = this.ToString(value);
11683 var escapedV = $replace(V, /\x22/g, '&quot;');
11684 p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22';
11685 }
11686 return p1 + '>' + S + '</' + tag + '>';
11687 },
11688
11689 // https://www.ecma-international.org/ecma-262/6.0/#sec-getownpropertykeys
11690 GetOwnPropertyKeys: function GetOwnPropertyKeys(O, Type) {
11691 if (this.Type(O) !== 'Object') {
11692 throw new $TypeError('Assertion failed: Type(O) is not Object');
11693 }
11694 if (Type === 'Symbol') {
11695 return hasSymbols && $gOPS ? $gOPS(O) : [];
11696 }
11697 if (Type === 'String') {
11698 if (!$gOPN) {
11699 return keys(O);
11700 }
11701 return $gOPN(O);
11702 }
11703 throw new $TypeError('Assertion failed: `Type` must be `"String"` or `"Symbol"`');
11704 },
11705
11706 // https://www.ecma-international.org/ecma-262/6.0/#sec-symboldescriptivestring
11707 SymbolDescriptiveString: function SymbolDescriptiveString(sym) {
11708 if (this.Type(sym) !== 'Symbol') {
11709 throw new $TypeError('Assertion failed: `sym` must be a Symbol');
11710 }
11711 return $SymbolToString(sym);
11712 },
11713
11714 // https://www.ecma-international.org/ecma-262/6.0/#sec-getsubstitution
11715 // eslint-disable-next-line max-statements, max-params, max-lines-per-function
11716 GetSubstitution: function GetSubstitution(matched, str, position, captures, replacement) {
11717 if (this.Type(matched) !== 'String') {
11718 throw new $TypeError('Assertion failed: `matched` must be a String');
11719 }
11720 var matchLength = matched.length;
11721
11722 if (this.Type(str) !== 'String') {
11723 throw new $TypeError('Assertion failed: `str` must be a String');
11724 }
11725 var stringLength = str.length;
11726
11727 if (!this.IsInteger(position) || position < 0 || position > stringLength) {
11728 throw new $TypeError('Assertion failed: `position` must be a nonnegative integer, and less than or equal to the length of `string`, got ' + inspect(position));
11729 }
11730
11731 var ES = this;
11732 var isStringOrHole = function (capture, index, arr) { return ES.Type(capture) === 'String' || !(index in arr); };
11733 if (!this.IsArray(captures) || !every(captures, isStringOrHole)) {
11734 throw new $TypeError('Assertion failed: `captures` must be a List of Strings, got ' + inspect(captures));
11735 }
11736
11737 if (this.Type(replacement) !== 'String') {
11738 throw new $TypeError('Assertion failed: `replacement` must be a String');
11739 }
11740
11741 var tailPos = position + matchLength;
11742 var m = captures.length;
11743
11744 var result = '';
11745 for (var i = 0; i < replacement.length; i += 1) {
11746 // if this is a $, and it's not the end of the replacement
11747 var current = replacement[i];
11748 var isLast = (i + 1) >= replacement.length;
11749 var nextIsLast = (i + 2) >= replacement.length;
11750 if (current === '$' && !isLast) {
11751 var next = replacement[i + 1];
11752 if (next === '$') {
11753 result += '$';
11754 i += 1;
11755 } else if (next === '&') {
11756 result += matched;
11757 i += 1;
11758 } else if (next === '`') {
11759 result += position === 0 ? '' : strSlice(str, 0, position - 1);
11760 i += 1;
11761 } else if (next === "'") {
11762 result += tailPos >= stringLength ? '' : strSlice(str, tailPos);
11763 i += 1;
11764 } else {
11765 var nextNext = nextIsLast ? null : replacement[i + 2];
11766 if (isDigit(next) && next !== '0' && (nextIsLast || !isDigit(nextNext))) {
11767 // $1 through $9, and not followed by a digit
11768 var n = parseInteger(next, 10);
11769 // if (n > m, impl-defined)
11770 result += (n <= m && this.Type(captures[n - 1]) === 'Undefined') ? '' : captures[n - 1];
11771 i += 1;
11772 } else if (isDigit(next) && (nextIsLast || isDigit(nextNext))) {
11773 // $00 through $99
11774 var nn = next + nextNext;
11775 var nnI = parseInteger(nn, 10) - 1;
11776 // if nn === '00' or nn > m, impl-defined
11777 result += (nn <= m && this.Type(captures[nnI]) === 'Undefined') ? '' : captures[nnI];
11778 i += 2;
11779 } else {
11780 result += '$';
11781 }
11782 }
11783 } else {
11784 // the final $, or else not a $
11785 result += replacement[i];
11786 }
11787 }
11788 return result;
11789 }
11790});
11791
11792delete ES6.CheckObjectCoercible; // renamed in ES6 to RequireObjectCoercible
11793
11794module.exports = ES6;
11795
11796},{"./GetIntrinsic":181,"./es5":184,"./helpers/assertRecord":186,"./helpers/assign":187,"./helpers/callBind":188,"./helpers/every":189,"./helpers/forEach":190,"./helpers/isFinite":191,"./helpers/isNaN":192,"./helpers/isPrimitive":193,"./helpers/isPropertyDescriptor":194,"./helpers/isSamePropertyDescriptor":195,"./helpers/mod":196,"./helpers/sign":197,"es-to-primitive/es6":203,"has":212,"has-symbols":210,"is-regex":221,"object-inspect":229,"object-keys":199}],183:[function(require,module,exports){
11797'use strict';
11798
11799var GetIntrinsic = require('./GetIntrinsic');
11800
11801var $Array = GetIntrinsic('%Array%');
11802
11803var hasSymbols = require('has-symbols')();
11804
11805var ES2015 = require('./es2015');
11806var assign = require('./helpers/assign');
11807var callBind = require('./helpers/callBind');
11808
11809var $arrayPush = callBind($Array.prototype.push);
11810var $arraySlice = callBind($Array.prototype.slice);
11811var $arrayJoin = callBind($Array.prototype.join);
11812
11813var ES2016 = assign(assign({}, ES2015), {
11814 // https://www.ecma-international.org/ecma-262/7.0/#sec-samevaluenonnumber
11815 SameValueNonNumber: function SameValueNonNumber(x, y) {
11816 if (typeof x === 'number' || typeof x !== typeof y) {
11817 throw new TypeError('SameValueNonNumber requires two non-number values of the same type.');
11818 }
11819 return this.SameValue(x, y);
11820 },
11821
11822 // https://www.ecma-international.org/ecma-262/7.0/#sec-iterabletoarraylike
11823 IterableToArrayLike: function IterableToArrayLike(items) {
11824 var usingIterator;
11825 if (hasSymbols) {
11826 usingIterator = this.GetMethod(items, Symbol.iterator);
11827 } else if (this.IsArray(items)) {
11828 usingIterator = function () {
11829 var i = -1;
11830 var arr = this; // eslint-disable-line no-invalid-this
11831 return {
11832 next: function () {
11833 i += 1;
11834 return {
11835 done: i >= arr.length,
11836 value: arr[i]
11837 };
11838 }
11839 };
11840 };
11841 } else if (this.Type(items) === 'String') {
11842 var ES = this;
11843 usingIterator = function () {
11844 var i = 0;
11845 return {
11846 next: function () {
11847 var nextIndex = ES.AdvanceStringIndex(items, i, true);
11848 var value = $arrayJoin($arraySlice(items, i, nextIndex), '');
11849 i = nextIndex;
11850 return {
11851 done: nextIndex > items.length,
11852 value: value
11853 };
11854 }
11855 };
11856 };
11857 }
11858 if (typeof usingIterator !== 'undefined') {
11859 var iterator = this.GetIterator(items, usingIterator);
11860 var values = [];
11861 var next = true;
11862 while (next) {
11863 next = this.IteratorStep(iterator);
11864 if (next) {
11865 var nextValue = this.IteratorValue(next);
11866 $arrayPush(values, nextValue);
11867 }
11868 }
11869 return values;
11870 }
11871
11872 return this.ToObject(items);
11873 }
11874});
11875
11876module.exports = ES2016;
11877
11878},{"./GetIntrinsic":181,"./es2015":182,"./helpers/assign":187,"./helpers/callBind":188,"has-symbols":210}],184:[function(require,module,exports){
11879'use strict';
11880
11881var GetIntrinsic = require('./GetIntrinsic');
11882
11883var $Object = GetIntrinsic('%Object%');
11884var $TypeError = GetIntrinsic('%TypeError%');
11885var $String = GetIntrinsic('%String%');
11886var $Number = GetIntrinsic('%Number%');
11887
11888var assertRecord = require('./helpers/assertRecord');
11889var isPropertyDescriptor = require('./helpers/isPropertyDescriptor');
11890var $isNaN = require('./helpers/isNaN');
11891var $isFinite = require('./helpers/isFinite');
11892
11893var sign = require('./helpers/sign');
11894var mod = require('./helpers/mod');
11895
11896var IsCallable = require('is-callable');
11897var toPrimitive = require('es-to-primitive/es5');
11898
11899var has = require('has');
11900
11901var callBind = require('./helpers/callBind');
11902var strSlice = callBind($String.prototype.slice);
11903
11904var isPrefixOf = function isPrefixOf(prefix, string) {
11905 if (prefix === string) {
11906 return true;
11907 }
11908 if (prefix.length > string.length) {
11909 return false;
11910 }
11911 return strSlice(string, 0, prefix.length) === prefix;
11912};
11913
11914// https://es5.github.io/#x9
11915var ES5 = {
11916 ToPrimitive: toPrimitive,
11917
11918 ToBoolean: function ToBoolean(value) {
11919 return !!value;
11920 },
11921 ToNumber: function ToNumber(value) {
11922 return +value; // eslint-disable-line no-implicit-coercion
11923 },
11924 ToInteger: function ToInteger(value) {
11925 var number = this.ToNumber(value);
11926 if ($isNaN(number)) { return 0; }
11927 if (number === 0 || !$isFinite(number)) { return number; }
11928 return sign(number) * Math.floor(Math.abs(number));
11929 },
11930 ToInt32: function ToInt32(x) {
11931 return this.ToNumber(x) >> 0;
11932 },
11933 ToUint32: function ToUint32(x) {
11934 return this.ToNumber(x) >>> 0;
11935 },
11936 ToUint16: function ToUint16(value) {
11937 var number = this.ToNumber(value);
11938 if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
11939 var posInt = sign(number) * Math.floor(Math.abs(number));
11940 return mod(posInt, 0x10000);
11941 },
11942 ToString: function ToString(value) {
11943 return $String(value);
11944 },
11945 ToObject: function ToObject(value) {
11946 this.CheckObjectCoercible(value);
11947 return $Object(value);
11948 },
11949 CheckObjectCoercible: function CheckObjectCoercible(value, optMessage) {
11950 /* jshint eqnull:true */
11951 if (value == null) {
11952 throw new $TypeError(optMessage || 'Cannot call method on ' + value);
11953 }
11954 return value;
11955 },
11956 IsCallable: IsCallable,
11957 SameValue: function SameValue(x, y) {
11958 if (x === y) { // 0 === -0, but they are not identical.
11959 if (x === 0) { return 1 / x === 1 / y; }
11960 return true;
11961 }
11962 return $isNaN(x) && $isNaN(y);
11963 },
11964
11965 // https://www.ecma-international.org/ecma-262/5.1/#sec-8
11966 Type: function Type(x) {
11967 if (x === null) {
11968 return 'Null';
11969 }
11970 if (typeof x === 'undefined') {
11971 return 'Undefined';
11972 }
11973 if (typeof x === 'function' || typeof x === 'object') {
11974 return 'Object';
11975 }
11976 if (typeof x === 'number') {
11977 return 'Number';
11978 }
11979 if (typeof x === 'boolean') {
11980 return 'Boolean';
11981 }
11982 if (typeof x === 'string') {
11983 return 'String';
11984 }
11985 },
11986
11987 // https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type
11988 IsPropertyDescriptor: function IsPropertyDescriptor(Desc) {
11989 return isPropertyDescriptor(this, Desc);
11990 },
11991
11992 // https://ecma-international.org/ecma-262/5.1/#sec-8.10.1
11993 IsAccessorDescriptor: function IsAccessorDescriptor(Desc) {
11994 if (typeof Desc === 'undefined') {
11995 return false;
11996 }
11997
11998 assertRecord(this, 'Property Descriptor', 'Desc', Desc);
11999
12000 if (!has(Desc, '[[Get]]') && !has(Desc, '[[Set]]')) {
12001 return false;
12002 }
12003
12004 return true;
12005 },
12006
12007 // https://ecma-international.org/ecma-262/5.1/#sec-8.10.2
12008 IsDataDescriptor: function IsDataDescriptor(Desc) {
12009 if (typeof Desc === 'undefined') {
12010 return false;
12011 }
12012
12013 assertRecord(this, 'Property Descriptor', 'Desc', Desc);
12014
12015 if (!has(Desc, '[[Value]]') && !has(Desc, '[[Writable]]')) {
12016 return false;
12017 }
12018
12019 return true;
12020 },
12021
12022 // https://ecma-international.org/ecma-262/5.1/#sec-8.10.3
12023 IsGenericDescriptor: function IsGenericDescriptor(Desc) {
12024 if (typeof Desc === 'undefined') {
12025 return false;
12026 }
12027
12028 assertRecord(this, 'Property Descriptor', 'Desc', Desc);
12029
12030 if (!this.IsAccessorDescriptor(Desc) && !this.IsDataDescriptor(Desc)) {
12031 return true;
12032 }
12033
12034 return false;
12035 },
12036
12037 // https://ecma-international.org/ecma-262/5.1/#sec-8.10.4
12038 FromPropertyDescriptor: function FromPropertyDescriptor(Desc) {
12039 if (typeof Desc === 'undefined') {
12040 return Desc;
12041 }
12042
12043 assertRecord(this, 'Property Descriptor', 'Desc', Desc);
12044
12045 if (this.IsDataDescriptor(Desc)) {
12046 return {
12047 value: Desc['[[Value]]'],
12048 writable: !!Desc['[[Writable]]'],
12049 enumerable: !!Desc['[[Enumerable]]'],
12050 configurable: !!Desc['[[Configurable]]']
12051 };
12052 } else if (this.IsAccessorDescriptor(Desc)) {
12053 return {
12054 get: Desc['[[Get]]'],
12055 set: Desc['[[Set]]'],
12056 enumerable: !!Desc['[[Enumerable]]'],
12057 configurable: !!Desc['[[Configurable]]']
12058 };
12059 } else {
12060 throw new $TypeError('FromPropertyDescriptor must be called with a fully populated Property Descriptor');
12061 }
12062 },
12063
12064 // https://ecma-international.org/ecma-262/5.1/#sec-8.10.5
12065 ToPropertyDescriptor: function ToPropertyDescriptor(Obj) {
12066 if (this.Type(Obj) !== 'Object') {
12067 throw new $TypeError('ToPropertyDescriptor requires an object');
12068 }
12069
12070 var desc = {};
12071 if (has(Obj, 'enumerable')) {
12072 desc['[[Enumerable]]'] = this.ToBoolean(Obj.enumerable);
12073 }
12074 if (has(Obj, 'configurable')) {
12075 desc['[[Configurable]]'] = this.ToBoolean(Obj.configurable);
12076 }
12077 if (has(Obj, 'value')) {
12078 desc['[[Value]]'] = Obj.value;
12079 }
12080 if (has(Obj, 'writable')) {
12081 desc['[[Writable]]'] = this.ToBoolean(Obj.writable);
12082 }
12083 if (has(Obj, 'get')) {
12084 var getter = Obj.get;
12085 if (typeof getter !== 'undefined' && !this.IsCallable(getter)) {
12086 throw new TypeError('getter must be a function');
12087 }
12088 desc['[[Get]]'] = getter;
12089 }
12090 if (has(Obj, 'set')) {
12091 var setter = Obj.set;
12092 if (typeof setter !== 'undefined' && !this.IsCallable(setter)) {
12093 throw new $TypeError('setter must be a function');
12094 }
12095 desc['[[Set]]'] = setter;
12096 }
12097
12098 if ((has(desc, '[[Get]]') || has(desc, '[[Set]]')) && (has(desc, '[[Value]]') || has(desc, '[[Writable]]'))) {
12099 throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute');
12100 }
12101 return desc;
12102 },
12103
12104 // https://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3
12105 'Abstract Equality Comparison': function AbstractEqualityComparison(x, y) {
12106 var xType = this.Type(x);
12107 var yType = this.Type(y);
12108 if (xType === yType) {
12109 return x === y; // ES6+ specified this shortcut anyways.
12110 }
12111 if (x == null && y == null) {
12112 return true;
12113 }
12114 if (xType === 'Number' && yType === 'String') {
12115 return this['Abstract Equality Comparison'](x, this.ToNumber(y));
12116 }
12117 if (xType === 'String' && yType === 'Number') {
12118 return this['Abstract Equality Comparison'](this.ToNumber(x), y);
12119 }
12120 if (xType === 'Boolean') {
12121 return this['Abstract Equality Comparison'](this.ToNumber(x), y);
12122 }
12123 if (yType === 'Boolean') {
12124 return this['Abstract Equality Comparison'](x, this.ToNumber(y));
12125 }
12126 if ((xType === 'String' || xType === 'Number') && yType === 'Object') {
12127 return this['Abstract Equality Comparison'](x, this.ToPrimitive(y));
12128 }
12129 if (xType === 'Object' && (yType === 'String' || yType === 'Number')) {
12130 return this['Abstract Equality Comparison'](this.ToPrimitive(x), y);
12131 }
12132 return false;
12133 },
12134
12135 // https://www.ecma-international.org/ecma-262/5.1/#sec-11.9.6
12136 'Strict Equality Comparison': function StrictEqualityComparison(x, y) {
12137 var xType = this.Type(x);
12138 var yType = this.Type(y);
12139 if (xType !== yType) {
12140 return false;
12141 }
12142 if (xType === 'Undefined' || xType === 'Null') {
12143 return true;
12144 }
12145 return x === y; // shortcut for steps 4-7
12146 },
12147
12148 // https://www.ecma-international.org/ecma-262/5.1/#sec-11.8.5
12149 // eslint-disable-next-line max-statements
12150 'Abstract Relational Comparison': function AbstractRelationalComparison(x, y, LeftFirst) {
12151 if (this.Type(LeftFirst) !== 'Boolean') {
12152 throw new $TypeError('Assertion failed: LeftFirst argument must be a Boolean');
12153 }
12154 var px;
12155 var py;
12156 if (LeftFirst) {
12157 px = this.ToPrimitive(x, $Number);
12158 py = this.ToPrimitive(y, $Number);
12159 } else {
12160 py = this.ToPrimitive(y, $Number);
12161 px = this.ToPrimitive(x, $Number);
12162 }
12163 var bothStrings = this.Type(px) === 'String' && this.Type(py) === 'String';
12164 if (!bothStrings) {
12165 var nx = this.ToNumber(px);
12166 var ny = this.ToNumber(py);
12167 if ($isNaN(nx) || $isNaN(ny)) {
12168 return undefined;
12169 }
12170 if ($isFinite(nx) && $isFinite(ny) && nx === ny) {
12171 return false;
12172 }
12173 if (nx === 0 && ny === 0) {
12174 return false;
12175 }
12176 if (nx === Infinity) {
12177 return false;
12178 }
12179 if (ny === Infinity) {
12180 return true;
12181 }
12182 if (ny === -Infinity) {
12183 return false;
12184 }
12185 if (nx === -Infinity) {
12186 return true;
12187 }
12188 return nx < ny; // by now, these are both nonzero, finite, and not equal
12189 }
12190 if (isPrefixOf(py, px)) {
12191 return false;
12192 }
12193 if (isPrefixOf(px, py)) {
12194 return true;
12195 }
12196 return px < py; // both strings, neither a prefix of the other. shortcut for steps c-f
12197 }
12198};
12199
12200module.exports = ES5;
12201
12202},{"./GetIntrinsic":181,"./helpers/assertRecord":186,"./helpers/callBind":188,"./helpers/isFinite":191,"./helpers/isNaN":192,"./helpers/isPropertyDescriptor":194,"./helpers/mod":196,"./helpers/sign":197,"es-to-primitive/es5":202,"has":212,"is-callable":218}],185:[function(require,module,exports){
12203'use strict';
12204
12205module.exports = require('./es2016');
12206
12207},{"./es2016":183}],186:[function(require,module,exports){
12208'use strict';
12209
12210var GetIntrinsic = require('../GetIntrinsic');
12211
12212var $TypeError = GetIntrinsic('%TypeError%');
12213var $SyntaxError = GetIntrinsic('%SyntaxError%');
12214
12215var has = require('has');
12216
12217var predicates = {
12218 // https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type
12219 'Property Descriptor': function isPropertyDescriptor(ES, Desc) {
12220 if (ES.Type(Desc) !== 'Object') {
12221 return false;
12222 }
12223 var allowed = {
12224 '[[Configurable]]': true,
12225 '[[Enumerable]]': true,
12226 '[[Get]]': true,
12227 '[[Set]]': true,
12228 '[[Value]]': true,
12229 '[[Writable]]': true
12230 };
12231
12232 for (var key in Desc) { // eslint-disable-line
12233 if (has(Desc, key) && !allowed[key]) {
12234 return false;
12235 }
12236 }
12237
12238 var isData = has(Desc, '[[Value]]');
12239 var IsAccessor = has(Desc, '[[Get]]') || has(Desc, '[[Set]]');
12240 if (isData && IsAccessor) {
12241 throw new $TypeError('Property Descriptors may not be both accessor and data descriptors');
12242 }
12243 return true;
12244 }
12245};
12246
12247module.exports = function assertRecord(ES, recordType, argumentName, value) {
12248 var predicate = predicates[recordType];
12249 if (typeof predicate !== 'function') {
12250 throw new $SyntaxError('unknown record type: ' + recordType);
12251 }
12252 if (!predicate(ES, value)) {
12253 throw new $TypeError(argumentName + ' must be a ' + recordType);
12254 }
12255};
12256
12257},{"../GetIntrinsic":181,"has":212}],187:[function(require,module,exports){
12258'use strict';
12259
12260var GetIntrinsic = require('../GetIntrinsic');
12261
12262var has = require('has');
12263
12264var $assign = GetIntrinsic('%Object%').assign;
12265
12266module.exports = function assign(target, source) {
12267 if ($assign) {
12268 return $assign(target, source);
12269 }
12270
12271 // eslint-disable-next-line no-restricted-syntax
12272 for (var key in source) {
12273 if (has(source, key)) {
12274 target[key] = source[key];
12275 }
12276 }
12277 return target;
12278};
12279
12280},{"../GetIntrinsic":181,"has":212}],188:[function(require,module,exports){
12281'use strict';
12282
12283var bind = require('function-bind');
12284
12285var GetIntrinsic = require('../GetIntrinsic');
12286
12287var $Function = GetIntrinsic('%Function%');
12288var $apply = $Function.apply;
12289var $call = $Function.call;
12290
12291module.exports = function callBind() {
12292 return bind.apply($call, arguments);
12293};
12294
12295module.exports.apply = function applyBind() {
12296 return bind.apply($apply, arguments);
12297};
12298
12299},{"../GetIntrinsic":181,"function-bind":209}],189:[function(require,module,exports){
12300'use strict';
12301
12302module.exports = function every(array, predicate) {
12303 for (var i = 0; i < array.length; i += 1) {
12304 if (!predicate(array[i], i, array)) {
12305 return false;
12306 }
12307 }
12308 return true;
12309};
12310
12311},{}],190:[function(require,module,exports){
12312'use strict';
12313
12314module.exports = function forEach(array, callback) {
12315 for (var i = 0; i < array.length; i += 1) {
12316 callback(array[i], i, array); // eslint-disable-line callback-return
12317 }
12318};
12319
12320},{}],191:[function(require,module,exports){
12321'use strict';
12322
12323var $isNaN = Number.isNaN || function (a) { return a !== a; };
12324
12325module.exports = Number.isFinite || function (x) { return typeof x === 'number' && !$isNaN(x) && x !== Infinity && x !== -Infinity; };
12326
12327},{}],192:[function(require,module,exports){
12328'use strict';
12329
12330module.exports = Number.isNaN || function isNaN(a) {
12331 return a !== a;
12332};
12333
12334},{}],193:[function(require,module,exports){
12335'use strict';
12336
12337module.exports = function isPrimitive(value) {
12338 return value === null || (typeof value !== 'function' && typeof value !== 'object');
12339};
12340
12341},{}],194:[function(require,module,exports){
12342'use strict';
12343
12344var GetIntrinsic = require('../GetIntrinsic');
12345
12346var has = require('has');
12347var $TypeError = GetIntrinsic('%TypeError%');
12348
12349module.exports = function IsPropertyDescriptor(ES, Desc) {
12350 if (ES.Type(Desc) !== 'Object') {
12351 return false;
12352 }
12353 var allowed = {
12354 '[[Configurable]]': true,
12355 '[[Enumerable]]': true,
12356 '[[Get]]': true,
12357 '[[Set]]': true,
12358 '[[Value]]': true,
12359 '[[Writable]]': true
12360 };
12361
12362 for (var key in Desc) { // eslint-disable-line
12363 if (has(Desc, key) && !allowed[key]) {
12364 return false;
12365 }
12366 }
12367
12368 if (ES.IsDataDescriptor(Desc) && ES.IsAccessorDescriptor(Desc)) {
12369 throw new $TypeError('Property Descriptors may not be both accessor and data descriptors');
12370 }
12371 return true;
12372};
12373
12374},{"../GetIntrinsic":181,"has":212}],195:[function(require,module,exports){
12375'use strict';
12376
12377var every = require('./every');
12378
12379module.exports = function isSamePropertyDescriptor(ES, D1, D2) {
12380 var fields = [
12381 '[[Configurable]]',
12382 '[[Enumerable]]',
12383 '[[Get]]',
12384 '[[Set]]',
12385 '[[Value]]',
12386 '[[Writable]]'
12387 ];
12388 return every(fields, function (field) {
12389 if ((field in D1) !== (field in D2)) {
12390 return false;
12391 }
12392 return ES.SameValue(D1[field], D2[field]);
12393 });
12394};
12395
12396},{"./every":189}],196:[function(require,module,exports){
12397'use strict';
12398
12399module.exports = function mod(number, modulo) {
12400 var remain = number % modulo;
12401 return Math.floor(remain >= 0 ? remain : remain + modulo);
12402};
12403
12404},{}],197:[function(require,module,exports){
12405'use strict';
12406
12407module.exports = function sign(number) {
12408 return number >= 0 ? 1 : -1;
12409};
12410
12411},{}],198:[function(require,module,exports){
12412'use strict';
12413
12414var keysShim;
12415if (!Object.keys) {
12416 // modified from https://github.com/es-shims/es5-shim
12417 var has = Object.prototype.hasOwnProperty;
12418 var toStr = Object.prototype.toString;
12419 var isArgs = require('./isArguments'); // eslint-disable-line global-require
12420 var isEnumerable = Object.prototype.propertyIsEnumerable;
12421 var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
12422 var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
12423 var dontEnums = [
12424 'toString',
12425 'toLocaleString',
12426 'valueOf',
12427 'hasOwnProperty',
12428 'isPrototypeOf',
12429 'propertyIsEnumerable',
12430 'constructor'
12431 ];
12432 var equalsConstructorPrototype = function (o) {
12433 var ctor = o.constructor;
12434 return ctor && ctor.prototype === o;
12435 };
12436 var excludedKeys = {
12437 $applicationCache: true,
12438 $console: true,
12439 $external: true,
12440 $frame: true,
12441 $frameElement: true,
12442 $frames: true,
12443 $innerHeight: true,
12444 $innerWidth: true,
12445 $onmozfullscreenchange: true,
12446 $onmozfullscreenerror: true,
12447 $outerHeight: true,
12448 $outerWidth: true,
12449 $pageXOffset: true,
12450 $pageYOffset: true,
12451 $parent: true,
12452 $scrollLeft: true,
12453 $scrollTop: true,
12454 $scrollX: true,
12455 $scrollY: true,
12456 $self: true,
12457 $webkitIndexedDB: true,
12458 $webkitStorageInfo: true,
12459 $window: true
12460 };
12461 var hasAutomationEqualityBug = (function () {
12462 /* global window */
12463 if (typeof window === 'undefined') { return false; }
12464 for (var k in window) {
12465 try {
12466 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
12467 try {
12468 equalsConstructorPrototype(window[k]);
12469 } catch (e) {
12470 return true;
12471 }
12472 }
12473 } catch (e) {
12474 return true;
12475 }
12476 }
12477 return false;
12478 }());
12479 var equalsConstructorPrototypeIfNotBuggy = function (o) {
12480 /* global window */
12481 if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
12482 return equalsConstructorPrototype(o);
12483 }
12484 try {
12485 return equalsConstructorPrototype(o);
12486 } catch (e) {
12487 return false;
12488 }
12489 };
12490
12491 keysShim = function keys(object) {
12492 var isObject = object !== null && typeof object === 'object';
12493 var isFunction = toStr.call(object) === '[object Function]';
12494 var isArguments = isArgs(object);
12495 var isString = isObject && toStr.call(object) === '[object String]';
12496 var theKeys = [];
12497
12498 if (!isObject && !isFunction && !isArguments) {
12499 throw new TypeError('Object.keys called on a non-object');
12500 }
12501
12502 var skipProto = hasProtoEnumBug && isFunction;
12503 if (isString && object.length > 0 && !has.call(object, 0)) {
12504 for (var i = 0; i < object.length; ++i) {
12505 theKeys.push(String(i));
12506 }
12507 }
12508
12509 if (isArguments && object.length > 0) {
12510 for (var j = 0; j < object.length; ++j) {
12511 theKeys.push(String(j));
12512 }
12513 } else {
12514 for (var name in object) {
12515 if (!(skipProto && name === 'prototype') && has.call(object, name)) {
12516 theKeys.push(String(name));
12517 }
12518 }
12519 }
12520
12521 if (hasDontEnumBug) {
12522 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
12523
12524 for (var k = 0; k < dontEnums.length; ++k) {
12525 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
12526 theKeys.push(dontEnums[k]);
12527 }
12528 }
12529 }
12530 return theKeys;
12531 };
12532}
12533module.exports = keysShim;
12534
12535},{"./isArguments":200}],199:[function(require,module,exports){
12536'use strict';
12537
12538var slice = Array.prototype.slice;
12539var isArgs = require('./isArguments');
12540
12541var origKeys = Object.keys;
12542var keysShim = origKeys ? function keys(o) { return origKeys(o); } : require('./implementation');
12543
12544var originalKeys = Object.keys;
12545
12546keysShim.shim = function shimObjectKeys() {
12547 if (Object.keys) {
12548 var keysWorksWithArguments = (function () {
12549 // Safari 5.0 bug
12550 var args = Object.keys(arguments);
12551 return args && args.length === arguments.length;
12552 }(1, 2));
12553 if (!keysWorksWithArguments) {
12554 Object.keys = function keys(object) { // eslint-disable-line func-name-matching
12555 if (isArgs(object)) {
12556 return originalKeys(slice.call(object));
12557 }
12558 return originalKeys(object);
12559 };
12560 }
12561 } else {
12562 Object.keys = keysShim;
12563 }
12564 return Object.keys || keysShim;
12565};
12566
12567module.exports = keysShim;
12568
12569},{"./implementation":198,"./isArguments":200}],200:[function(require,module,exports){
12570'use strict';
12571
12572var toStr = Object.prototype.toString;
12573
12574module.exports = function isArguments(value) {
12575 var str = toStr.call(value);
12576 var isArgs = str === '[object Arguments]';
12577 if (!isArgs) {
12578 isArgs = str !== '[object Array]' &&
12579 value !== null &&
12580 typeof value === 'object' &&
12581 typeof value.length === 'number' &&
12582 value.length >= 0 &&
12583 toStr.call(value.callee) === '[object Function]';
12584 }
12585 return isArgs;
12586};
12587
12588},{}],201:[function(require,module,exports){
12589'use strict';
12590
12591var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
12592
12593var isPrimitive = require('./helpers/isPrimitive');
12594var isCallable = require('is-callable');
12595var isDate = require('is-date-object');
12596var isSymbol = require('is-symbol');
12597
12598var ordinaryToPrimitive = function OrdinaryToPrimitive(O, hint) {
12599 if (typeof O === 'undefined' || O === null) {
12600 throw new TypeError('Cannot call method on ' + O);
12601 }
12602 if (typeof hint !== 'string' || (hint !== 'number' && hint !== 'string')) {
12603 throw new TypeError('hint must be "string" or "number"');
12604 }
12605 var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
12606 var method, result, i;
12607 for (i = 0; i < methodNames.length; ++i) {
12608 method = O[methodNames[i]];
12609 if (isCallable(method)) {
12610 result = method.call(O);
12611 if (isPrimitive(result)) {
12612 return result;
12613 }
12614 }
12615 }
12616 throw new TypeError('No default value');
12617};
12618
12619var GetMethod = function GetMethod(O, P) {
12620 var func = O[P];
12621 if (func !== null && typeof func !== 'undefined') {
12622 if (!isCallable(func)) {
12623 throw new TypeError(func + ' returned for property ' + P + ' of object ' + O + ' is not a function');
12624 }
12625 return func;
12626 }
12627 return void 0;
12628};
12629
12630// http://www.ecma-international.org/ecma-262/6.0/#sec-toprimitive
12631module.exports = function ToPrimitive(input) {
12632 if (isPrimitive(input)) {
12633 return input;
12634 }
12635 var hint = 'default';
12636 if (arguments.length > 1) {
12637 if (arguments[1] === String) {
12638 hint = 'string';
12639 } else if (arguments[1] === Number) {
12640 hint = 'number';
12641 }
12642 }
12643
12644 var exoticToPrim;
12645 if (hasSymbols) {
12646 if (Symbol.toPrimitive) {
12647 exoticToPrim = GetMethod(input, Symbol.toPrimitive);
12648 } else if (isSymbol(input)) {
12649 exoticToPrim = Symbol.prototype.valueOf;
12650 }
12651 }
12652 if (typeof exoticToPrim !== 'undefined') {
12653 var result = exoticToPrim.call(input, hint);
12654 if (isPrimitive(result)) {
12655 return result;
12656 }
12657 throw new TypeError('unable to convert exotic object to primitive');
12658 }
12659 if (hint === 'default' && (isDate(input) || isSymbol(input))) {
12660 hint = 'string';
12661 }
12662 return ordinaryToPrimitive(input, hint === 'default' ? 'number' : hint);
12663};
12664
12665},{"./helpers/isPrimitive":204,"is-callable":218,"is-date-object":220,"is-symbol":222}],202:[function(require,module,exports){
12666'use strict';
12667
12668var toStr = Object.prototype.toString;
12669
12670var isPrimitive = require('./helpers/isPrimitive');
12671
12672var isCallable = require('is-callable');
12673
12674// http://ecma-international.org/ecma-262/5.1/#sec-8.12.8
12675var ES5internalSlots = {
12676 '[[DefaultValue]]': function (O) {
12677 var actualHint;
12678 if (arguments.length > 1) {
12679 actualHint = arguments[1];
12680 } else {
12681 actualHint = toStr.call(O) === '[object Date]' ? String : Number;
12682 }
12683
12684 if (actualHint === String || actualHint === Number) {
12685 var methods = actualHint === String ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
12686 var value, i;
12687 for (i = 0; i < methods.length; ++i) {
12688 if (isCallable(O[methods[i]])) {
12689 value = O[methods[i]]();
12690 if (isPrimitive(value)) {
12691 return value;
12692 }
12693 }
12694 }
12695 throw new TypeError('No default value');
12696 }
12697 throw new TypeError('invalid [[DefaultValue]] hint supplied');
12698 }
12699};
12700
12701// http://ecma-international.org/ecma-262/5.1/#sec-9.1
12702module.exports = function ToPrimitive(input) {
12703 if (isPrimitive(input)) {
12704 return input;
12705 }
12706 if (arguments.length > 1) {
12707 return ES5internalSlots['[[DefaultValue]]'](input, arguments[1]);
12708 }
12709 return ES5internalSlots['[[DefaultValue]]'](input);
12710};
12711
12712},{"./helpers/isPrimitive":204,"is-callable":218}],203:[function(require,module,exports){
12713'use strict';
12714
12715module.exports = require('./es2015');
12716
12717},{"./es2015":201}],204:[function(require,module,exports){
12718module.exports = function isPrimitive(value) {
12719 return value === null || (typeof value !== 'function' && typeof value !== 'object');
12720};
12721
12722},{}],205:[function(require,module,exports){
12723/*!
12724 * escape-html
12725 * Copyright(c) 2012-2013 TJ Holowaychuk
12726 * Copyright(c) 2015 Andreas Lubbe
12727 * Copyright(c) 2015 Tiancheng "Timothy" Gu
12728 * MIT Licensed
12729 */
12730
12731'use strict';
12732
12733/**
12734 * Module variables.
12735 * @private
12736 */
12737
12738var matchHtmlRegExp = /["'&<>]/;
12739
12740/**
12741 * Module exports.
12742 * @public
12743 */
12744
12745module.exports = escapeHtml;
12746
12747/**
12748 * Escape special characters in the given string of html.
12749 *
12750 * @param {string} string The string to escape for inserting into HTML
12751 * @return {string}
12752 * @public
12753 */
12754
12755function escapeHtml(string) {
12756 var str = '' + string;
12757 var match = matchHtmlRegExp.exec(str);
12758
12759 if (!match) {
12760 return str;
12761 }
12762
12763 var escape;
12764 var html = '';
12765 var index = 0;
12766 var lastIndex = 0;
12767
12768 for (index = match.index; index < str.length; index++) {
12769 switch (str.charCodeAt(index)) {
12770 case 34: // "
12771 escape = '&quot;';
12772 break;
12773 case 38: // &
12774 escape = '&amp;';
12775 break;
12776 case 39: // '
12777 escape = '&#39;';
12778 break;
12779 case 60: // <
12780 escape = '&lt;';
12781 break;
12782 case 62: // >
12783 escape = '&gt;';
12784 break;
12785 default:
12786 continue;
12787 }
12788
12789 if (lastIndex !== index) {
12790 html += str.substring(lastIndex, index);
12791 }
12792
12793 lastIndex = index + 1;
12794 html += escape;
12795 }
12796
12797 return lastIndex !== index
12798 ? html + str.substring(lastIndex, index)
12799 : html;
12800}
12801
12802},{}],206:[function(require,module,exports){
12803// Copyright Joyent, Inc. and other Node contributors.
12804//
12805// Permission is hereby granted, free of charge, to any person obtaining a
12806// copy of this software and associated documentation files (the
12807// "Software"), to deal in the Software without restriction, including
12808// without limitation the rights to use, copy, modify, merge, publish,
12809// distribute, sublicense, and/or sell copies of the Software, and to permit
12810// persons to whom the Software is furnished to do so, subject to the
12811// following conditions:
12812//
12813// The above copyright notice and this permission notice shall be included
12814// in all copies or substantial portions of the Software.
12815//
12816// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12817// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12818// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
12819// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
12820// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
12821// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
12822// USE OR OTHER DEALINGS IN THE SOFTWARE.
12823
12824function EventEmitter() {
12825 this._events = this._events || {};
12826 this._maxListeners = this._maxListeners || undefined;
12827}
12828module.exports = EventEmitter;
12829
12830// Backwards-compat with node 0.10.x
12831EventEmitter.EventEmitter = EventEmitter;
12832
12833EventEmitter.prototype._events = undefined;
12834EventEmitter.prototype._maxListeners = undefined;
12835
12836// By default EventEmitters will print a warning if more than 10 listeners are
12837// added to it. This is a useful default which helps finding memory leaks.
12838EventEmitter.defaultMaxListeners = 10;
12839
12840// Obviously not all Emitters should be limited to 10. This function allows
12841// that to be increased. Set to zero for unlimited.
12842EventEmitter.prototype.setMaxListeners = function(n) {
12843 if (!isNumber(n) || n < 0 || isNaN(n))
12844 throw TypeError('n must be a positive number');
12845 this._maxListeners = n;
12846 return this;
12847};
12848
12849EventEmitter.prototype.emit = function(type) {
12850 var er, handler, len, args, i, listeners;
12851
12852 if (!this._events)
12853 this._events = {};
12854
12855 // If there is no 'error' event listener then throw.
12856 if (type === 'error') {
12857 if (!this._events.error ||
12858 (isObject(this._events.error) && !this._events.error.length)) {
12859 er = arguments[1];
12860 if (er instanceof Error) {
12861 throw er; // Unhandled 'error' event
12862 } else {
12863 // At least give some kind of context to the user
12864 var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
12865 err.context = er;
12866 throw err;
12867 }
12868 }
12869 }
12870
12871 handler = this._events[type];
12872
12873 if (isUndefined(handler))
12874 return false;
12875
12876 if (isFunction(handler)) {
12877 switch (arguments.length) {
12878 // fast cases
12879 case 1:
12880 handler.call(this);
12881 break;
12882 case 2:
12883 handler.call(this, arguments[1]);
12884 break;
12885 case 3:
12886 handler.call(this, arguments[1], arguments[2]);
12887 break;
12888 // slower
12889 default:
12890 args = Array.prototype.slice.call(arguments, 1);
12891 handler.apply(this, args);
12892 }
12893 } else if (isObject(handler)) {
12894 args = Array.prototype.slice.call(arguments, 1);
12895 listeners = handler.slice();
12896 len = listeners.length;
12897 for (i = 0; i < len; i++)
12898 listeners[i].apply(this, args);
12899 }
12900
12901 return true;
12902};
12903
12904EventEmitter.prototype.addListener = function(type, listener) {
12905 var m;
12906
12907 if (!isFunction(listener))
12908 throw TypeError('listener must be a function');
12909
12910 if (!this._events)
12911 this._events = {};
12912
12913 // To avoid recursion in the case that type === "newListener"! Before
12914 // adding it to the listeners, first emit "newListener".
12915 if (this._events.newListener)
12916 this.emit('newListener', type,
12917 isFunction(listener.listener) ?
12918 listener.listener : listener);
12919
12920 if (!this._events[type])
12921 // Optimize the case of one listener. Don't need the extra array object.
12922 this._events[type] = listener;
12923 else if (isObject(this._events[type]))
12924 // If we've already got an array, just append.
12925 this._events[type].push(listener);
12926 else
12927 // Adding the second element, need to change to array.
12928 this._events[type] = [this._events[type], listener];
12929
12930 // Check for listener leak
12931 if (isObject(this._events[type]) && !this._events[type].warned) {
12932 if (!isUndefined(this._maxListeners)) {
12933 m = this._maxListeners;
12934 } else {
12935 m = EventEmitter.defaultMaxListeners;
12936 }
12937
12938 if (m && m > 0 && this._events[type].length > m) {
12939 this._events[type].warned = true;
12940 console.error('(node) warning: possible EventEmitter memory ' +
12941 'leak detected. %d listeners added. ' +
12942 'Use emitter.setMaxListeners() to increase limit.',
12943 this._events[type].length);
12944 if (typeof console.trace === 'function') {
12945 // not supported in IE 10
12946 console.trace();
12947 }
12948 }
12949 }
12950
12951 return this;
12952};
12953
12954EventEmitter.prototype.on = EventEmitter.prototype.addListener;
12955
12956EventEmitter.prototype.once = function(type, listener) {
12957 if (!isFunction(listener))
12958 throw TypeError('listener must be a function');
12959
12960 var fired = false;
12961
12962 function g() {
12963 this.removeListener(type, g);
12964
12965 if (!fired) {
12966 fired = true;
12967 listener.apply(this, arguments);
12968 }
12969 }
12970
12971 g.listener = listener;
12972 this.on(type, g);
12973
12974 return this;
12975};
12976
12977// emits a 'removeListener' event iff the listener was removed
12978EventEmitter.prototype.removeListener = function(type, listener) {
12979 var list, position, length, i;
12980
12981 if (!isFunction(listener))
12982 throw TypeError('listener must be a function');
12983
12984 if (!this._events || !this._events[type])
12985 return this;
12986
12987 list = this._events[type];
12988 length = list.length;
12989 position = -1;
12990
12991 if (list === listener ||
12992 (isFunction(list.listener) && list.listener === listener)) {
12993 delete this._events[type];
12994 if (this._events.removeListener)
12995 this.emit('removeListener', type, listener);
12996
12997 } else if (isObject(list)) {
12998 for (i = length; i-- > 0;) {
12999 if (list[i] === listener ||
13000 (list[i].listener && list[i].listener === listener)) {
13001 position = i;
13002 break;
13003 }
13004 }
13005
13006 if (position < 0)
13007 return this;
13008
13009 if (list.length === 1) {
13010 list.length = 0;
13011 delete this._events[type];
13012 } else {
13013 list.splice(position, 1);
13014 }
13015
13016 if (this._events.removeListener)
13017 this.emit('removeListener', type, listener);
13018 }
13019
13020 return this;
13021};
13022
13023EventEmitter.prototype.removeAllListeners = function(type) {
13024 var key, listeners;
13025
13026 if (!this._events)
13027 return this;
13028
13029 // not listening for removeListener, no need to emit
13030 if (!this._events.removeListener) {
13031 if (arguments.length === 0)
13032 this._events = {};
13033 else if (this._events[type])
13034 delete this._events[type];
13035 return this;
13036 }
13037
13038 // emit removeListener for all listeners on all events
13039 if (arguments.length === 0) {
13040 for (key in this._events) {
13041 if (key === 'removeListener') continue;
13042 this.removeAllListeners(key);
13043 }
13044 this.removeAllListeners('removeListener');
13045 this._events = {};
13046 return this;
13047 }
13048
13049 listeners = this._events[type];
13050
13051 if (isFunction(listeners)) {
13052 this.removeListener(type, listeners);
13053 } else if (listeners) {
13054 // LIFO order
13055 while (listeners.length)
13056 this.removeListener(type, listeners[listeners.length - 1]);
13057 }
13058 delete this._events[type];
13059
13060 return this;
13061};
13062
13063EventEmitter.prototype.listeners = function(type) {
13064 var ret;
13065 if (!this._events || !this._events[type])
13066 ret = [];
13067 else if (isFunction(this._events[type]))
13068 ret = [this._events[type]];
13069 else
13070 ret = this._events[type].slice();
13071 return ret;
13072};
13073
13074EventEmitter.prototype.listenerCount = function(type) {
13075 if (this._events) {
13076 var evlistener = this._events[type];
13077
13078 if (isFunction(evlistener))
13079 return 1;
13080 else if (evlistener)
13081 return evlistener.length;
13082 }
13083 return 0;
13084};
13085
13086EventEmitter.listenerCount = function(emitter, type) {
13087 return emitter.listenerCount(type);
13088};
13089
13090function isFunction(arg) {
13091 return typeof arg === 'function';
13092}
13093
13094function isNumber(arg) {
13095 return typeof arg === 'number';
13096}
13097
13098function isObject(arg) {
13099 return typeof arg === 'object' && arg !== null;
13100}
13101
13102function isUndefined(arg) {
13103 return arg === void 0;
13104}
13105
13106},{}],207:[function(require,module,exports){
13107
13108var hasOwn = Object.prototype.hasOwnProperty;
13109var toString = Object.prototype.toString;
13110
13111module.exports = function forEach (obj, fn, ctx) {
13112 if (toString.call(fn) !== '[object Function]') {
13113 throw new TypeError('iterator must be a function');
13114 }
13115 var l = obj.length;
13116 if (l === +l) {
13117 for (var i = 0; i < l; i++) {
13118 fn.call(ctx, obj[i], i, obj);
13119 }
13120 } else {
13121 for (var k in obj) {
13122 if (hasOwn.call(obj, k)) {
13123 fn.call(ctx, obj[k], k, obj);
13124 }
13125 }
13126 }
13127};
13128
13129
13130},{}],208:[function(require,module,exports){
13131'use strict';
13132
13133/* eslint no-invalid-this: 1 */
13134
13135var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
13136var slice = Array.prototype.slice;
13137var toStr = Object.prototype.toString;
13138var funcType = '[object Function]';
13139
13140module.exports = function bind(that) {
13141 var target = this;
13142 if (typeof target !== 'function' || toStr.call(target) !== funcType) {
13143 throw new TypeError(ERROR_MESSAGE + target);
13144 }
13145 var args = slice.call(arguments, 1);
13146
13147 var bound;
13148 var binder = function () {
13149 if (this instanceof bound) {
13150 var result = target.apply(
13151 this,
13152 args.concat(slice.call(arguments))
13153 );
13154 if (Object(result) === result) {
13155 return result;
13156 }
13157 return this;
13158 } else {
13159 return target.apply(
13160 that,
13161 args.concat(slice.call(arguments))
13162 );
13163 }
13164 };
13165
13166 var boundLength = Math.max(0, target.length - args.length);
13167 var boundArgs = [];
13168 for (var i = 0; i < boundLength; i++) {
13169 boundArgs.push('$' + i);
13170 }
13171
13172 bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
13173
13174 if (target.prototype) {
13175 var Empty = function Empty() {};
13176 Empty.prototype = target.prototype;
13177 bound.prototype = new Empty();
13178 Empty.prototype = null;
13179 }
13180
13181 return bound;
13182};
13183
13184},{}],209:[function(require,module,exports){
13185'use strict';
13186
13187var implementation = require('./implementation');
13188
13189module.exports = Function.prototype.bind || implementation;
13190
13191},{"./implementation":208}],210:[function(require,module,exports){
13192(function (global){
13193'use strict';
13194
13195var origSymbol = global.Symbol;
13196var hasSymbolSham = require('./shams');
13197
13198module.exports = function hasNativeSymbols() {
13199 if (typeof origSymbol !== 'function') { return false; }
13200 if (typeof Symbol !== 'function') { return false; }
13201 if (typeof origSymbol('foo') !== 'symbol') { return false; }
13202 if (typeof Symbol('bar') !== 'symbol') { return false; }
13203
13204 return hasSymbolSham();
13205};
13206
13207}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
13208},{"./shams":211}],211:[function(require,module,exports){
13209'use strict';
13210
13211/* eslint complexity: [2, 17], max-statements: [2, 33] */
13212module.exports = function hasSymbols() {
13213 if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
13214 if (typeof Symbol.iterator === 'symbol') { return true; }
13215
13216 var obj = {};
13217 var sym = Symbol('test');
13218 var symObj = Object(sym);
13219 if (typeof sym === 'string') { return false; }
13220
13221 if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
13222 if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
13223
13224 // temp disabled per https://github.com/ljharb/object.assign/issues/17
13225 // if (sym instanceof Symbol) { return false; }
13226 // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
13227 // if (!(symObj instanceof Symbol)) { return false; }
13228
13229 // if (typeof Symbol.prototype.toString !== 'function') { return false; }
13230 // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
13231
13232 var symVal = 42;
13233 obj[sym] = symVal;
13234 for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
13235 if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
13236
13237 if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
13238
13239 var syms = Object.getOwnPropertySymbols(obj);
13240 if (syms.length !== 1 || syms[0] !== sym) { return false; }
13241
13242 if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
13243
13244 if (typeof Object.getOwnPropertyDescriptor === 'function') {
13245 var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
13246 if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
13247 }
13248
13249 return true;
13250};
13251
13252},{}],212:[function(require,module,exports){
13253'use strict';
13254
13255var bind = require('function-bind');
13256
13257module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
13258
13259},{"function-bind":209}],213:[function(require,module,exports){
13260var http = require('http');
13261
13262var https = module.exports;
13263
13264for (var key in http) {
13265 if (http.hasOwnProperty(key)) https[key] = http[key];
13266};
13267
13268https.request = function (params, cb) {
13269 if (!params) params = {};
13270 params.scheme = 'https';
13271 params.protocol = 'https:';
13272 return http.request.call(this, params, cb);
13273}
13274
13275},{"http":262}],214:[function(require,module,exports){
13276/*!
13277 * humanize-ms - index.js
13278 * Copyright(c) 2014 dead_horse <dead_horse@qq.com>
13279 * MIT Licensed
13280 */
13281
13282'use strict';
13283
13284/**
13285 * Module dependencies.
13286 */
13287
13288var util = require('util');
13289var ms = require('ms');
13290
13291module.exports = function (t) {
13292 if (typeof t === 'number') return t;
13293 var r = ms(t);
13294 if (r === undefined) {
13295 var err = new Error(util.format('humanize-ms(%j) result undefined', t));
13296 console.warn(err.stack);
13297 }
13298 return r;
13299};
13300
13301},{"ms":228,"util":277}],215:[function(require,module,exports){
13302exports.read = function (buffer, offset, isLE, mLen, nBytes) {
13303 var e, m
13304 var eLen = (nBytes * 8) - mLen - 1
13305 var eMax = (1 << eLen) - 1
13306 var eBias = eMax >> 1
13307 var nBits = -7
13308 var i = isLE ? (nBytes - 1) : 0
13309 var d = isLE ? -1 : 1
13310 var s = buffer[offset + i]
13311
13312 i += d
13313
13314 e = s & ((1 << (-nBits)) - 1)
13315 s >>= (-nBits)
13316 nBits += eLen
13317 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13318
13319 m = e & ((1 << (-nBits)) - 1)
13320 e >>= (-nBits)
13321 nBits += mLen
13322 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13323
13324 if (e === 0) {
13325 e = 1 - eBias
13326 } else if (e === eMax) {
13327 return m ? NaN : ((s ? -1 : 1) * Infinity)
13328 } else {
13329 m = m + Math.pow(2, mLen)
13330 e = e - eBias
13331 }
13332 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
13333}
13334
13335exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
13336 var e, m, c
13337 var eLen = (nBytes * 8) - mLen - 1
13338 var eMax = (1 << eLen) - 1
13339 var eBias = eMax >> 1
13340 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
13341 var i = isLE ? 0 : (nBytes - 1)
13342 var d = isLE ? 1 : -1
13343 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
13344
13345 value = Math.abs(value)
13346
13347 if (isNaN(value) || value === Infinity) {
13348 m = isNaN(value) ? 1 : 0
13349 e = eMax
13350 } else {
13351 e = Math.floor(Math.log(value) / Math.LN2)
13352 if (value * (c = Math.pow(2, -e)) < 1) {
13353 e--
13354 c *= 2
13355 }
13356 if (e + eBias >= 1) {
13357 value += rt / c
13358 } else {
13359 value += rt * Math.pow(2, 1 - eBias)
13360 }
13361 if (value * c >= 2) {
13362 e++
13363 c /= 2
13364 }
13365
13366 if (e + eBias >= eMax) {
13367 m = 0
13368 e = eMax
13369 } else if (e + eBias >= 1) {
13370 m = ((value * c) - 1) * Math.pow(2, mLen)
13371 e = e + eBias
13372 } else {
13373 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
13374 e = 0
13375 }
13376 }
13377
13378 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
13379
13380 e = (e << mLen) | m
13381 eLen += mLen
13382 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
13383
13384 buffer[offset + i - d] |= s * 128
13385}
13386
13387},{}],216:[function(require,module,exports){
13388if (typeof Object.create === 'function') {
13389 // implementation from standard node.js 'util' module
13390 module.exports = function inherits(ctor, superCtor) {
13391 ctor.super_ = superCtor
13392 ctor.prototype = Object.create(superCtor.prototype, {
13393 constructor: {
13394 value: ctor,
13395 enumerable: false,
13396 writable: true,
13397 configurable: true
13398 }
13399 });
13400 };
13401} else {
13402 // old school shim for old browsers
13403 module.exports = function inherits(ctor, superCtor) {
13404 ctor.super_ = superCtor
13405 var TempCtor = function () {}
13406 TempCtor.prototype = superCtor.prototype
13407 ctor.prototype = new TempCtor()
13408 ctor.prototype.constructor = ctor
13409 }
13410}
13411
13412},{}],217:[function(require,module,exports){
13413/*!
13414 * Determine if an object is a Buffer
13415 *
13416 * @author Feross Aboukhadijeh <https://feross.org>
13417 * @license MIT
13418 */
13419
13420// The _isBuffer check is for Safari 5-7 support, because it's missing
13421// Object.prototype.constructor. Remove this eventually
13422module.exports = function (obj) {
13423 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
13424}
13425
13426function isBuffer (obj) {
13427 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
13428}
13429
13430// For Node v0.10 support. Remove this eventually.
13431function isSlowBuffer (obj) {
13432 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
13433}
13434
13435},{}],218:[function(require,module,exports){
13436'use strict';
13437
13438var fnToStr = Function.prototype.toString;
13439
13440var constructorRegex = /^\s*class\b/;
13441var isES6ClassFn = function isES6ClassFunction(value) {
13442 try {
13443 var fnStr = fnToStr.call(value);
13444 return constructorRegex.test(fnStr);
13445 } catch (e) {
13446 return false; // not a function
13447 }
13448};
13449
13450var tryFunctionObject = function tryFunctionToStr(value) {
13451 try {
13452 if (isES6ClassFn(value)) { return false; }
13453 fnToStr.call(value);
13454 return true;
13455 } catch (e) {
13456 return false;
13457 }
13458};
13459var toStr = Object.prototype.toString;
13460var fnClass = '[object Function]';
13461var genClass = '[object GeneratorFunction]';
13462var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
13463
13464module.exports = function isCallable(value) {
13465 if (!value) { return false; }
13466 if (typeof value !== 'function' && typeof value !== 'object') { return false; }
13467 if (typeof value === 'function' && !value.prototype) { return true; }
13468 if (hasToStringTag) { return tryFunctionObject(value); }
13469 if (isES6ClassFn(value)) { return false; }
13470 var strClass = toStr.call(value);
13471 return strClass === fnClass || strClass === genClass;
13472};
13473
13474},{}],219:[function(require,module,exports){
13475(function(root) {
13476 var toString = Function.prototype.toString;
13477
13478 function fnBody(fn) {
13479 return toString.call(fn).replace(/^[^{]*{\s*/,'').replace(/\s*}[^}]*$/,'');
13480 }
13481
13482 function isClass(fn) {
13483 return (typeof fn === 'function' &&
13484 (/^class(?:\s|{)/.test(toString.call(fn)) ||
13485 (/^.*classCallCheck\(/.test(fnBody(fn)))) // babel.js
13486 );
13487 }
13488
13489 if (typeof exports !== 'undefined') {
13490 if (typeof module !== 'undefined' && module.exports) {
13491 exports = module.exports = isClass;
13492 }
13493 exports.isClass = isClass;
13494 } else if (typeof define === 'function' && define.amd) {
13495 define([], function() {
13496 return isClass;
13497 });
13498 } else {
13499 root.isClass = isClass;
13500 }
13501
13502})(this);
13503
13504},{}],220:[function(require,module,exports){
13505'use strict';
13506
13507var getDay = Date.prototype.getDay;
13508var tryDateObject = function tryDateObject(value) {
13509 try {
13510 getDay.call(value);
13511 return true;
13512 } catch (e) {
13513 return false;
13514 }
13515};
13516
13517var toStr = Object.prototype.toString;
13518var dateClass = '[object Date]';
13519var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
13520
13521module.exports = function isDateObject(value) {
13522 if (typeof value !== 'object' || value === null) { return false; }
13523 return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
13524};
13525
13526},{}],221:[function(require,module,exports){
13527'use strict';
13528
13529var has = require('has');
13530var regexExec = RegExp.prototype.exec;
13531var gOPD = Object.getOwnPropertyDescriptor;
13532
13533var tryRegexExecCall = function tryRegexExec(value) {
13534 try {
13535 var lastIndex = value.lastIndex;
13536 value.lastIndex = 0;
13537
13538 regexExec.call(value);
13539 return true;
13540 } catch (e) {
13541 return false;
13542 } finally {
13543 value.lastIndex = lastIndex;
13544 }
13545};
13546var toStr = Object.prototype.toString;
13547var regexClass = '[object RegExp]';
13548var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
13549
13550module.exports = function isRegex(value) {
13551 if (!value || typeof value !== 'object') {
13552 return false;
13553 }
13554 if (!hasToStringTag) {
13555 return toStr.call(value) === regexClass;
13556 }
13557
13558 var descriptor = gOPD(value, 'lastIndex');
13559 var hasLastIndexDataProperty = descriptor && has(descriptor, 'value');
13560 if (!hasLastIndexDataProperty) {
13561 return false;
13562 }
13563
13564 return tryRegexExecCall(value);
13565};
13566
13567},{"has":212}],222:[function(require,module,exports){
13568'use strict';
13569
13570var toStr = Object.prototype.toString;
13571var hasSymbols = require('has-symbols')();
13572
13573if (hasSymbols) {
13574 var symToStr = Symbol.prototype.toString;
13575 var symStringRegex = /^Symbol\(.*\)$/;
13576 var isSymbolObject = function isRealSymbolObject(value) {
13577 if (typeof value.valueOf() !== 'symbol') {
13578 return false;
13579 }
13580 return symStringRegex.test(symToStr.call(value));
13581 };
13582
13583 module.exports = function isSymbol(value) {
13584 if (typeof value === 'symbol') {
13585 return true;
13586 }
13587 if (toStr.call(value) !== '[object Symbol]') {
13588 return false;
13589 }
13590 try {
13591 return isSymbolObject(value);
13592 } catch (e) {
13593 return false;
13594 }
13595 };
13596} else {
13597
13598 module.exports = function isSymbol(value) {
13599 // this environment does not support Symbols.
13600 return false && value;
13601 };
13602}
13603
13604},{"has-symbols":210}],223:[function(require,module,exports){
13605'use strict';
13606
13607var utils = require('core-util-is');
13608var isStearm = require('isstream');
13609// wait for https://github.com/miguelmota/is-class/pull/6 merge
13610var isClass = require('is-class-hotfix');
13611
13612/**
13613 * Expose all methods in core-util-is
13614 */
13615
13616Object.keys(utils).map(function (name) {
13617 exports[transform(name)] = utils[name];
13618});
13619
13620/**
13621 * Stream detected by isstream
13622 */
13623
13624exports.stream = isStearm;
13625exports.readableStream = isStearm.isReadable;
13626exports.writableStream = isStearm.isWritable;
13627exports.duplexStream = isStearm.isDuplex;
13628
13629/**
13630 * Class detected by is-class
13631 */
13632 exports.class = isClass;
13633
13634/**
13635 * Extend method
13636 */
13637
13638exports.finite = Number.isFinite;
13639
13640exports.NaN = Number.isNaN
13641
13642exports.generator = function (obj) {
13643 return obj
13644 && 'function' === typeof obj.next
13645 && 'function' === typeof obj.throw;
13646};
13647
13648exports.generatorFunction = function (obj) {
13649 return obj
13650 && obj.constructor
13651 && 'GeneratorFunction' === obj.constructor.name;
13652};
13653
13654exports.asyncFunction = function (obj) {
13655 return obj
13656 && obj.constructor
13657 && 'AsyncFunction' === obj.constructor.name;
13658};
13659
13660exports.promise = function (obj) {
13661 return obj
13662 && 'function' === typeof obj.then;
13663};
13664
13665var MAX_INT_31 = Math.pow(2, 31);
13666
13667exports.int = function (obj) {
13668 return utils.isNumber(obj)
13669 && obj % 1 === 0;
13670};
13671
13672exports.int32 = function (obj) {
13673 return exports.int(obj)
13674 && obj < MAX_INT_31
13675 && obj >= -MAX_INT_31;
13676};
13677
13678exports.long = function (obj) {
13679 return exports.int(obj)
13680 && (obj >= MAX_INT_31 || obj < -MAX_INT_31);
13681};
13682
13683exports.Long = function (obj) {
13684 return exports.object(obj)
13685 && exports.number(obj.high)
13686 && exports.number(obj.low);
13687};
13688
13689exports.double = function (obj) {
13690 return utils.isNumber(obj)
13691 && !isNaN(obj)
13692 && obj % 1 !== 0;
13693};
13694
13695/**
13696 * override core-util-is
13697 */
13698
13699exports.date = function isDate(obj) {
13700 return obj instanceof Date;
13701};
13702
13703exports.regExp = function isRegExp(obj) {
13704 return obj instanceof RegExp;
13705};
13706exports.regexp = exports.regExp;
13707
13708exports.error = function isError(obj) {
13709 return obj instanceof Error;
13710};
13711
13712exports.array = Array.isArray;
13713
13714/**
13715 * transform isNull type to null
13716 * @param {[type]} m [description]
13717 * @return {[type]} [description]
13718 */
13719
13720function transform(m) {
13721 var name = m.slice(2);
13722 name = name[0].toLowerCase() + name.slice(1);
13723 return name;
13724}
13725
13726},{"core-util-is":176,"is-class-hotfix":219,"isstream":225}],224:[function(require,module,exports){
13727var toString = {}.toString;
13728
13729module.exports = Array.isArray || function (arr) {
13730 return toString.call(arr) == '[object Array]';
13731};
13732
13733},{}],225:[function(require,module,exports){
13734var stream = require('stream')
13735
13736
13737function isStream (obj) {
13738 return obj instanceof stream.Stream
13739}
13740
13741
13742function isReadable (obj) {
13743 return isStream(obj) && typeof obj._read == 'function' && typeof obj._readableState == 'object'
13744}
13745
13746
13747function isWritable (obj) {
13748 return isStream(obj) && typeof obj._write == 'function' && typeof obj._writableState == 'object'
13749}
13750
13751
13752function isDuplex (obj) {
13753 return isReadable(obj) && isWritable(obj)
13754}
13755
13756
13757module.exports = isStream
13758module.exports.isReadable = isReadable
13759module.exports.isWritable = isWritable
13760module.exports.isDuplex = isDuplex
13761
13762},{"stream":261}],226:[function(require,module,exports){
13763(function (global){
13764/*
13765 * base64.js
13766 *
13767 * Licensed under the BSD 3-Clause License.
13768 * http://opensource.org/licenses/BSD-3-Clause
13769 *
13770 * References:
13771 * http://en.wikipedia.org/wiki/Base64
13772 */
13773;(function (global, factory) {
13774 typeof exports === 'object' && typeof module !== 'undefined'
13775 ? module.exports = factory(global)
13776 : typeof define === 'function' && define.amd
13777 ? define(factory) : factory(global)
13778}((
13779 typeof self !== 'undefined' ? self
13780 : typeof window !== 'undefined' ? window
13781 : typeof global !== 'undefined' ? global
13782: this
13783), function(global) {
13784 'use strict';
13785 // existing version for noConflict()
13786 global = global || {};
13787 var _Base64 = global.Base64;
13788 var version = "2.5.2";
13789 // if node.js and NOT React Native, we use Buffer
13790 var buffer;
13791 if (typeof module !== 'undefined' && module.exports) {
13792 try {
13793 buffer = eval("require('buffer').Buffer");
13794 } catch (err) {
13795 buffer = undefined;
13796 }
13797 }
13798 // constants
13799 var b64chars
13800 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
13801 var b64tab = function(bin) {
13802 var t = {};
13803 for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
13804 return t;
13805 }(b64chars);
13806 var fromCharCode = String.fromCharCode;
13807 // encoder stuff
13808 var cb_utob = function(c) {
13809 if (c.length < 2) {
13810 var cc = c.charCodeAt(0);
13811 return cc < 0x80 ? c
13812 : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
13813 + fromCharCode(0x80 | (cc & 0x3f)))
13814 : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
13815 + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
13816 + fromCharCode(0x80 | ( cc & 0x3f)));
13817 } else {
13818 var cc = 0x10000
13819 + (c.charCodeAt(0) - 0xD800) * 0x400
13820 + (c.charCodeAt(1) - 0xDC00);
13821 return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
13822 + fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
13823 + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
13824 + fromCharCode(0x80 | ( cc & 0x3f)));
13825 }
13826 };
13827 var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
13828 var utob = function(u) {
13829 return u.replace(re_utob, cb_utob);
13830 };
13831 var cb_encode = function(ccc) {
13832 var padlen = [0, 2, 1][ccc.length % 3],
13833 ord = ccc.charCodeAt(0) << 16
13834 | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
13835 | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),
13836 chars = [
13837 b64chars.charAt( ord >>> 18),
13838 b64chars.charAt((ord >>> 12) & 63),
13839 padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
13840 padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
13841 ];
13842 return chars.join('');
13843 };
13844 var btoa = global.btoa ? function(b) {
13845 return global.btoa(b);
13846 } : function(b) {
13847 return b.replace(/[\s\S]{1,3}/g, cb_encode);
13848 };
13849 var _encode = function(u) {
13850 var isUint8Array = Object.prototype.toString.call(u) === '[object Uint8Array]';
13851 return isUint8Array ? u.toString('base64')
13852 : btoa(utob(String(u)));
13853 }
13854 var encode = function(u, urisafe) {
13855 return !urisafe
13856 ? _encode(u)
13857 : _encode(String(u)).replace(/[+\/]/g, function(m0) {
13858 return m0 == '+' ? '-' : '_';
13859 }).replace(/=/g, '');
13860 };
13861 var encodeURI = function(u) { return encode(u, true) };
13862 // decoder stuff
13863 var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
13864 var cb_btou = function(cccc) {
13865 switch(cccc.length) {
13866 case 4:
13867 var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
13868 | ((0x3f & cccc.charCodeAt(1)) << 12)
13869 | ((0x3f & cccc.charCodeAt(2)) << 6)
13870 | (0x3f & cccc.charCodeAt(3)),
13871 offset = cp - 0x10000;
13872 return (fromCharCode((offset >>> 10) + 0xD800)
13873 + fromCharCode((offset & 0x3FF) + 0xDC00));
13874 case 3:
13875 return fromCharCode(
13876 ((0x0f & cccc.charCodeAt(0)) << 12)
13877 | ((0x3f & cccc.charCodeAt(1)) << 6)
13878 | (0x3f & cccc.charCodeAt(2))
13879 );
13880 default:
13881 return fromCharCode(
13882 ((0x1f & cccc.charCodeAt(0)) << 6)
13883 | (0x3f & cccc.charCodeAt(1))
13884 );
13885 }
13886 };
13887 var btou = function(b) {
13888 return b.replace(re_btou, cb_btou);
13889 };
13890 var cb_decode = function(cccc) {
13891 var len = cccc.length,
13892 padlen = len % 4,
13893 n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
13894 | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)
13895 | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)
13896 | (len > 3 ? b64tab[cccc.charAt(3)] : 0),
13897 chars = [
13898 fromCharCode( n >>> 16),
13899 fromCharCode((n >>> 8) & 0xff),
13900 fromCharCode( n & 0xff)
13901 ];
13902 chars.length -= [0, 0, 2, 1][padlen];
13903 return chars.join('');
13904 };
13905 var _atob = global.atob ? function(a) {
13906 return global.atob(a);
13907 } : function(a){
13908 return a.replace(/\S{1,4}/g, cb_decode);
13909 };
13910 var atob = function(a) {
13911 return _atob(String(a).replace(/[^A-Za-z0-9\+\/]/g, ''));
13912 };
13913 var _decode = buffer ?
13914 buffer.from && Uint8Array && buffer.from !== Uint8Array.from
13915 ? function(a) {
13916 return (a.constructor === buffer.constructor
13917 ? a : buffer.from(a, 'base64')).toString();
13918 }
13919 : function(a) {
13920 return (a.constructor === buffer.constructor
13921 ? a : new buffer(a, 'base64')).toString();
13922 }
13923 : function(a) { return btou(_atob(a)) };
13924 var decode = function(a){
13925 return _decode(
13926 String(a).replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })
13927 .replace(/[^A-Za-z0-9\+\/]/g, '')
13928 );
13929 };
13930 var noConflict = function() {
13931 var Base64 = global.Base64;
13932 global.Base64 = _Base64;
13933 return Base64;
13934 };
13935 // export Base64
13936 global.Base64 = {
13937 VERSION: version,
13938 atob: atob,
13939 btoa: btoa,
13940 fromBase64: decode,
13941 toBase64: encode,
13942 utob: utob,
13943 encode: encode,
13944 encodeURI: encodeURI,
13945 btou: btou,
13946 decode: decode,
13947 noConflict: noConflict,
13948 __buffer__: buffer
13949 };
13950 // if ES5 is available, make Base64.extendString() available
13951 if (typeof Object.defineProperty === 'function') {
13952 var noEnum = function(v){
13953 return {value:v,enumerable:false,writable:true,configurable:true};
13954 };
13955 global.Base64.extendString = function () {
13956 Object.defineProperty(
13957 String.prototype, 'fromBase64', noEnum(function () {
13958 return decode(this)
13959 }));
13960 Object.defineProperty(
13961 String.prototype, 'toBase64', noEnum(function (urisafe) {
13962 return encode(this, urisafe)
13963 }));
13964 Object.defineProperty(
13965 String.prototype, 'toBase64URI', noEnum(function () {
13966 return encode(this, true)
13967 }));
13968 };
13969 }
13970 //
13971 // export Base64 to the namespace
13972 //
13973 if (global['Meteor']) { // Meteor.js
13974 Base64 = global.Base64;
13975 }
13976 // module.exports and AMD are mutually exclusive.
13977 // module.exports has precedence.
13978 if (typeof module !== 'undefined' && module.exports) {
13979 module.exports.Base64 = global.Base64;
13980 }
13981 else if (typeof define === 'function' && define.amd) {
13982 // AMD. Register as an anonymous module.
13983 define([], function(){ return global.Base64 });
13984 }
13985 // that's it!
13986 return {Base64: global.Base64}
13987}));
13988
13989
13990}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
13991},{}],227:[function(require,module,exports){
13992/*!
13993 * merge-descriptors
13994 * Copyright(c) 2014 Jonathan Ong
13995 * Copyright(c) 2015 Douglas Christopher Wilson
13996 * MIT Licensed
13997 */
13998
13999'use strict'
14000
14001/**
14002 * Module exports.
14003 * @public
14004 */
14005
14006module.exports = merge
14007
14008/**
14009 * Module variables.
14010 * @private
14011 */
14012
14013var hasOwnProperty = Object.prototype.hasOwnProperty
14014
14015/**
14016 * Merge the property descriptors of `src` into `dest`
14017 *
14018 * @param {object} dest Object to add descriptors to
14019 * @param {object} src Object to clone descriptors from
14020 * @param {boolean} [redefine=true] Redefine `dest` properties with `src` properties
14021 * @returns {object} Reference to dest
14022 * @public
14023 */
14024
14025function merge(dest, src, redefine) {
14026 if (!dest) {
14027 throw new TypeError('argument dest is required')
14028 }
14029
14030 if (!src) {
14031 throw new TypeError('argument src is required')
14032 }
14033
14034 if (redefine === undefined) {
14035 // Default to true
14036 redefine = true
14037 }
14038
14039 Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) {
14040 if (!redefine && hasOwnProperty.call(dest, name)) {
14041 // Skip desriptor
14042 return
14043 }
14044
14045 // Copy descriptor
14046 var descriptor = Object.getOwnPropertyDescriptor(src, name)
14047 Object.defineProperty(dest, name, descriptor)
14048 })
14049
14050 return dest
14051}
14052
14053},{}],228:[function(require,module,exports){
14054/**
14055 * Helpers.
14056 */
14057
14058var s = 1000;
14059var m = s * 60;
14060var h = m * 60;
14061var d = h * 24;
14062var y = d * 365.25;
14063
14064/**
14065 * Parse or format the given `val`.
14066 *
14067 * Options:
14068 *
14069 * - `long` verbose formatting [false]
14070 *
14071 * @param {String|Number} val
14072 * @param {Object} [options]
14073 * @throws {Error} throw an error if val is not a non-empty string or a number
14074 * @return {String|Number}
14075 * @api public
14076 */
14077
14078module.exports = function(val, options) {
14079 options = options || {};
14080 var type = typeof val;
14081 if (type === 'string' && val.length > 0) {
14082 return parse(val);
14083 } else if (type === 'number' && isNaN(val) === false) {
14084 return options.long ? fmtLong(val) : fmtShort(val);
14085 }
14086 throw new Error(
14087 'val is not a non-empty string or a valid number. val=' +
14088 JSON.stringify(val)
14089 );
14090};
14091
14092/**
14093 * Parse the given `str` and return milliseconds.
14094 *
14095 * @param {String} str
14096 * @return {Number}
14097 * @api private
14098 */
14099
14100function parse(str) {
14101 str = String(str);
14102 if (str.length > 100) {
14103 return;
14104 }
14105 var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
14106 str
14107 );
14108 if (!match) {
14109 return;
14110 }
14111 var n = parseFloat(match[1]);
14112 var type = (match[2] || 'ms').toLowerCase();
14113 switch (type) {
14114 case 'years':
14115 case 'year':
14116 case 'yrs':
14117 case 'yr':
14118 case 'y':
14119 return n * y;
14120 case 'days':
14121 case 'day':
14122 case 'd':
14123 return n * d;
14124 case 'hours':
14125 case 'hour':
14126 case 'hrs':
14127 case 'hr':
14128 case 'h':
14129 return n * h;
14130 case 'minutes':
14131 case 'minute':
14132 case 'mins':
14133 case 'min':
14134 case 'm':
14135 return n * m;
14136 case 'seconds':
14137 case 'second':
14138 case 'secs':
14139 case 'sec':
14140 case 's':
14141 return n * s;
14142 case 'milliseconds':
14143 case 'millisecond':
14144 case 'msecs':
14145 case 'msec':
14146 case 'ms':
14147 return n;
14148 default:
14149 return undefined;
14150 }
14151}
14152
14153/**
14154 * Short format for `ms`.
14155 *
14156 * @param {Number} ms
14157 * @return {String}
14158 * @api private
14159 */
14160
14161function fmtShort(ms) {
14162 if (ms >= d) {
14163 return Math.round(ms / d) + 'd';
14164 }
14165 if (ms >= h) {
14166 return Math.round(ms / h) + 'h';
14167 }
14168 if (ms >= m) {
14169 return Math.round(ms / m) + 'm';
14170 }
14171 if (ms >= s) {
14172 return Math.round(ms / s) + 's';
14173 }
14174 return ms + 'ms';
14175}
14176
14177/**
14178 * Long format for `ms`.
14179 *
14180 * @param {Number} ms
14181 * @return {String}
14182 * @api private
14183 */
14184
14185function fmtLong(ms) {
14186 return plural(ms, d, 'day') ||
14187 plural(ms, h, 'hour') ||
14188 plural(ms, m, 'minute') ||
14189 plural(ms, s, 'second') ||
14190 ms + ' ms';
14191}
14192
14193/**
14194 * Pluralization helper.
14195 */
14196
14197function plural(ms, n, name) {
14198 if (ms < n) {
14199 return;
14200 }
14201 if (ms < n * 1.5) {
14202 return Math.floor(ms / n) + ' ' + name;
14203 }
14204 return Math.ceil(ms / n) + ' ' + name + 's';
14205}
14206
14207},{}],229:[function(require,module,exports){
14208var hasMap = typeof Map === 'function' && Map.prototype;
14209var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
14210var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
14211var mapForEach = hasMap && Map.prototype.forEach;
14212var hasSet = typeof Set === 'function' && Set.prototype;
14213var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
14214var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
14215var setForEach = hasSet && Set.prototype.forEach;
14216var booleanValueOf = Boolean.prototype.valueOf;
14217var objectToString = Object.prototype.toString;
14218var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
14219
14220var inspectCustom = require('./util.inspect').custom;
14221var inspectSymbol = (inspectCustom && isSymbol(inspectCustom)) ? inspectCustom : null;
14222
14223module.exports = function inspect_ (obj, opts, depth, seen) {
14224 if (!opts) opts = {};
14225
14226 if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) {
14227 throw new TypeError('option "quoteStyle" must be "single" or "double"');
14228 }
14229
14230 if (typeof obj === 'undefined') {
14231 return 'undefined';
14232 }
14233 if (obj === null) {
14234 return 'null';
14235 }
14236 if (typeof obj === 'boolean') {
14237 return obj ? 'true' : 'false';
14238 }
14239
14240 if (typeof obj === 'string') {
14241 return inspectString(obj, opts);
14242 }
14243 if (typeof obj === 'number') {
14244 if (obj === 0) {
14245 return Infinity / obj > 0 ? '0' : '-0';
14246 }
14247 return String(obj);
14248 }
14249 if (typeof obj === 'bigint') {
14250 return String(obj) + 'n';
14251 }
14252
14253 var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
14254 if (typeof depth === 'undefined') depth = 0;
14255 if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
14256 return '[Object]';
14257 }
14258
14259 if (typeof seen === 'undefined') seen = [];
14260 else if (indexOf(seen, obj) >= 0) {
14261 return '[Circular]';
14262 }
14263
14264 function inspect (value, from) {
14265 if (from) {
14266 seen = seen.slice();
14267 seen.push(from);
14268 }
14269 return inspect_(value, opts, depth + 1, seen);
14270 }
14271
14272 if (typeof obj === 'function') {
14273 var name = nameOf(obj);
14274 return '[Function' + (name ? ': ' + name : '') + ']';
14275 }
14276 if (isSymbol(obj)) {
14277 var symString = Symbol.prototype.toString.call(obj);
14278 return typeof obj === 'object' ? markBoxed(symString) : symString;
14279 }
14280 if (isElement(obj)) {
14281 var s = '<' + String(obj.nodeName).toLowerCase();
14282 var attrs = obj.attributes || [];
14283 for (var i = 0; i < attrs.length; i++) {
14284 s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
14285 }
14286 s += '>';
14287 if (obj.childNodes && obj.childNodes.length) s += '...';
14288 s += '</' + String(obj.nodeName).toLowerCase() + '>';
14289 return s;
14290 }
14291 if (isArray(obj)) {
14292 if (obj.length === 0) return '[]';
14293 return '[ ' + arrObjKeys(obj, inspect).join(', ') + ' ]';
14294 }
14295 if (isError(obj)) {
14296 var parts = arrObjKeys(obj, inspect);
14297 if (parts.length === 0) return '[' + String(obj) + ']';
14298 return '{ [' + String(obj) + '] ' + parts.join(', ') + ' }';
14299 }
14300 if (typeof obj === 'object') {
14301 if (inspectSymbol && typeof obj[inspectSymbol] === 'function') {
14302 return obj[inspectSymbol]();
14303 } else if (typeof obj.inspect === 'function') {
14304 return obj.inspect();
14305 }
14306 }
14307 if (isMap(obj)) {
14308 var parts = [];
14309 mapForEach.call(obj, function (value, key) {
14310 parts.push(inspect(key, obj) + ' => ' + inspect(value, obj));
14311 });
14312 return collectionOf('Map', mapSize.call(obj), parts);
14313 }
14314 if (isSet(obj)) {
14315 var parts = [];
14316 setForEach.call(obj, function (value ) {
14317 parts.push(inspect(value, obj));
14318 });
14319 return collectionOf('Set', setSize.call(obj), parts);
14320 }
14321 if (isNumber(obj)) {
14322 return markBoxed(inspect(Number(obj)));
14323 }
14324 if (isBigInt(obj)) {
14325 return markBoxed(inspect(bigIntValueOf.call(obj)));
14326 }
14327 if (isBoolean(obj)) {
14328 return markBoxed(booleanValueOf.call(obj));
14329 }
14330 if (isString(obj)) {
14331 return markBoxed(inspect(String(obj)));
14332 }
14333 if (!isDate(obj) && !isRegExp(obj)) {
14334 var xs = arrObjKeys(obj, inspect);
14335 if (xs.length === 0) return '{}';
14336 return '{ ' + xs.join(', ') + ' }';
14337 }
14338 return String(obj);
14339};
14340
14341function wrapQuotes (s, defaultStyle, opts) {
14342 var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
14343 return quoteChar + s + quoteChar;
14344}
14345
14346function quote (s) {
14347 return String(s).replace(/"/g, '&quot;');
14348}
14349
14350function isArray (obj) { return toStr(obj) === '[object Array]'; }
14351function isDate (obj) { return toStr(obj) === '[object Date]'; }
14352function isRegExp (obj) { return toStr(obj) === '[object RegExp]'; }
14353function isError (obj) { return toStr(obj) === '[object Error]'; }
14354function isSymbol (obj) { return toStr(obj) === '[object Symbol]'; }
14355function isString (obj) { return toStr(obj) === '[object String]'; }
14356function isNumber (obj) { return toStr(obj) === '[object Number]'; }
14357function isBigInt (obj) { return toStr(obj) === '[object BigInt]'; }
14358function isBoolean (obj) { return toStr(obj) === '[object Boolean]'; }
14359
14360var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };
14361function has (obj, key) {
14362 return hasOwn.call(obj, key);
14363}
14364
14365function toStr (obj) {
14366 return objectToString.call(obj);
14367}
14368
14369function nameOf (f) {
14370 if (f.name) return f.name;
14371 var m = String(f).match(/^function\s*([\w$]+)/);
14372 if (m) return m[1];
14373}
14374
14375function indexOf (xs, x) {
14376 if (xs.indexOf) return xs.indexOf(x);
14377 for (var i = 0, l = xs.length; i < l; i++) {
14378 if (xs[i] === x) return i;
14379 }
14380 return -1;
14381}
14382
14383function isMap (x) {
14384 if (!mapSize) {
14385 return false;
14386 }
14387 try {
14388 mapSize.call(x);
14389 try {
14390 setSize.call(x);
14391 } catch (s) {
14392 return true;
14393 }
14394 return x instanceof Map; // core-js workaround, pre-v2.5.0
14395 } catch (e) {}
14396 return false;
14397}
14398
14399function isSet (x) {
14400 if (!setSize) {
14401 return false;
14402 }
14403 try {
14404 setSize.call(x);
14405 try {
14406 mapSize.call(x);
14407 } catch (m) {
14408 return true;
14409 }
14410 return x instanceof Set; // core-js workaround, pre-v2.5.0
14411 } catch (e) {}
14412 return false;
14413}
14414
14415function isElement (x) {
14416 if (!x || typeof x !== 'object') return false;
14417 if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
14418 return true;
14419 }
14420 return typeof x.nodeName === 'string'
14421 && typeof x.getAttribute === 'function'
14422 ;
14423}
14424
14425function inspectString (str, opts) {
14426 var s = str.replace(/(['\\])/g, '\\$1').replace(/[\x00-\x1f]/g, lowbyte);
14427 return wrapQuotes(s, 'single', opts);
14428}
14429
14430function lowbyte (c) {
14431 var n = c.charCodeAt(0);
14432 var x = { 8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r' }[n];
14433 if (x) return '\\' + x;
14434 return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16);
14435}
14436
14437function markBoxed (str) {
14438 return 'Object(' + str + ')';
14439}
14440
14441function collectionOf (type, size, entries) {
14442 return type + ' (' + size + ') {' + entries.join(', ') + '}';
14443}
14444
14445function arrObjKeys (obj, inspect) {
14446 var isArr = isArray(obj);
14447 var xs = [];
14448 if (isArr) {
14449 xs.length = obj.length;
14450 for (var i = 0; i < obj.length; i++) {
14451 xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
14452 }
14453 }
14454 for (var key in obj) {
14455 if (!has(obj, key)) continue;
14456 if (isArr && String(Number(key)) === key && key < obj.length) continue;
14457 if (/[^\w$]/.test(key)) {
14458 xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
14459 } else {
14460 xs.push(key + ': ' + inspect(obj[key], obj));
14461 }
14462 }
14463 return xs;
14464}
14465
14466},{"./util.inspect":58}],230:[function(require,module,exports){
14467'use strict';
14468
14469// modified from https://github.com/es-shims/es5-shim
14470var has = Object.prototype.hasOwnProperty;
14471var toStr = Object.prototype.toString;
14472var slice = Array.prototype.slice;
14473var isArgs = require('./isArguments');
14474var isEnumerable = Object.prototype.propertyIsEnumerable;
14475var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
14476var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
14477var dontEnums = [
14478 'toString',
14479 'toLocaleString',
14480 'valueOf',
14481 'hasOwnProperty',
14482 'isPrototypeOf',
14483 'propertyIsEnumerable',
14484 'constructor'
14485];
14486var equalsConstructorPrototype = function (o) {
14487 var ctor = o.constructor;
14488 return ctor && ctor.prototype === o;
14489};
14490var excludedKeys = {
14491 $applicationCache: true,
14492 $console: true,
14493 $external: true,
14494 $frame: true,
14495 $frameElement: true,
14496 $frames: true,
14497 $innerHeight: true,
14498 $innerWidth: true,
14499 $outerHeight: true,
14500 $outerWidth: true,
14501 $pageXOffset: true,
14502 $pageYOffset: true,
14503 $parent: true,
14504 $scrollLeft: true,
14505 $scrollTop: true,
14506 $scrollX: true,
14507 $scrollY: true,
14508 $self: true,
14509 $webkitIndexedDB: true,
14510 $webkitStorageInfo: true,
14511 $window: true
14512};
14513var hasAutomationEqualityBug = (function () {
14514 /* global window */
14515 if (typeof window === 'undefined') { return false; }
14516 for (var k in window) {
14517 try {
14518 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
14519 try {
14520 equalsConstructorPrototype(window[k]);
14521 } catch (e) {
14522 return true;
14523 }
14524 }
14525 } catch (e) {
14526 return true;
14527 }
14528 }
14529 return false;
14530}());
14531var equalsConstructorPrototypeIfNotBuggy = function (o) {
14532 /* global window */
14533 if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
14534 return equalsConstructorPrototype(o);
14535 }
14536 try {
14537 return equalsConstructorPrototype(o);
14538 } catch (e) {
14539 return false;
14540 }
14541};
14542
14543var keysShim = function keys(object) {
14544 var isObject = object !== null && typeof object === 'object';
14545 var isFunction = toStr.call(object) === '[object Function]';
14546 var isArguments = isArgs(object);
14547 var isString = isObject && toStr.call(object) === '[object String]';
14548 var theKeys = [];
14549
14550 if (!isObject && !isFunction && !isArguments) {
14551 throw new TypeError('Object.keys called on a non-object');
14552 }
14553
14554 var skipProto = hasProtoEnumBug && isFunction;
14555 if (isString && object.length > 0 && !has.call(object, 0)) {
14556 for (var i = 0; i < object.length; ++i) {
14557 theKeys.push(String(i));
14558 }
14559 }
14560
14561 if (isArguments && object.length > 0) {
14562 for (var j = 0; j < object.length; ++j) {
14563 theKeys.push(String(j));
14564 }
14565 } else {
14566 for (var name in object) {
14567 if (!(skipProto && name === 'prototype') && has.call(object, name)) {
14568 theKeys.push(String(name));
14569 }
14570 }
14571 }
14572
14573 if (hasDontEnumBug) {
14574 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
14575
14576 for (var k = 0; k < dontEnums.length; ++k) {
14577 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
14578 theKeys.push(dontEnums[k]);
14579 }
14580 }
14581 }
14582 return theKeys;
14583};
14584
14585keysShim.shim = function shimObjectKeys() {
14586 if (Object.keys) {
14587 var keysWorksWithArguments = (function () {
14588 // Safari 5.0 bug
14589 return (Object.keys(arguments) || '').length === 2;
14590 }(1, 2));
14591 if (!keysWorksWithArguments) {
14592 var originalKeys = Object.keys;
14593 Object.keys = function keys(object) { // eslint-disable-line func-name-matching
14594 if (isArgs(object)) {
14595 return originalKeys(slice.call(object));
14596 } else {
14597 return originalKeys(object);
14598 }
14599 };
14600 }
14601 } else {
14602 Object.keys = keysShim;
14603 }
14604 return Object.keys || keysShim;
14605};
14606
14607module.exports = keysShim;
14608
14609},{"./isArguments":231}],231:[function(require,module,exports){
14610arguments[4][200][0].apply(exports,arguments)
14611},{"dup":200}],232:[function(require,module,exports){
14612'use strict';
14613
14614var ES = require('es-abstract/es7');
14615
14616var defineProperty = Object.defineProperty;
14617var getDescriptor = Object.getOwnPropertyDescriptor;
14618var getOwnNames = Object.getOwnPropertyNames;
14619var getSymbols = Object.getOwnPropertySymbols;
14620var concat = Function.call.bind(Array.prototype.concat);
14621var reduce = Function.call.bind(Array.prototype.reduce);
14622var getAll = getSymbols ? function (obj) {
14623 return concat(getOwnNames(obj), getSymbols(obj));
14624} : getOwnNames;
14625
14626var isES5 = ES.IsCallable(getDescriptor) && ES.IsCallable(getOwnNames);
14627
14628var safePut = function put(obj, prop, val) { // eslint-disable-line max-params
14629 if (defineProperty && prop in obj) {
14630 defineProperty(obj, prop, {
14631 configurable: true,
14632 enumerable: true,
14633 value: val,
14634 writable: true
14635 });
14636 } else {
14637 obj[prop] = val;
14638 }
14639};
14640
14641module.exports = function getOwnPropertyDescriptors(value) {
14642 ES.RequireObjectCoercible(value);
14643 if (!isES5) {
14644 throw new TypeError('getOwnPropertyDescriptors requires Object.getOwnPropertyDescriptor');
14645 }
14646
14647 var O = ES.ToObject(value);
14648 return reduce(getAll(O), function (acc, key) {
14649 var descriptor = getDescriptor(O, key);
14650 if (typeof descriptor !== 'undefined') {
14651 safePut(acc, key, descriptor);
14652 }
14653 return acc;
14654 }, {});
14655};
14656
14657},{"es-abstract/es7":185}],233:[function(require,module,exports){
14658'use strict';
14659
14660var define = require('define-properties');
14661
14662var implementation = require('./implementation');
14663var getPolyfill = require('./polyfill');
14664var shim = require('./shim');
14665
14666define(implementation, {
14667 getPolyfill: getPolyfill,
14668 implementation: implementation,
14669 shim: shim
14670});
14671
14672module.exports = implementation;
14673
14674},{"./implementation":232,"./polyfill":234,"./shim":235,"define-properties":180}],234:[function(require,module,exports){
14675'use strict';
14676
14677var implementation = require('./implementation');
14678
14679module.exports = function getPolyfill() {
14680 return typeof Object.getOwnPropertyDescriptors === 'function' ? Object.getOwnPropertyDescriptors : implementation;
14681};
14682
14683},{"./implementation":232}],235:[function(require,module,exports){
14684'use strict';
14685
14686var getPolyfill = require('./polyfill');
14687var define = require('define-properties');
14688
14689module.exports = function shimGetOwnPropertyDescriptors() {
14690 var polyfill = getPolyfill();
14691 define(
14692 Object,
14693 { getOwnPropertyDescriptors: polyfill },
14694 { getOwnPropertyDescriptors: function () { return Object.getOwnPropertyDescriptors !== polyfill; } }
14695 );
14696 return polyfill;
14697};
14698
14699},{"./polyfill":234,"define-properties":180}],236:[function(require,module,exports){
14700(function (process){
14701// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
14702// backported and transplited with Babel, with backwards-compat fixes
14703
14704// Copyright Joyent, Inc. and other Node contributors.
14705//
14706// Permission is hereby granted, free of charge, to any person obtaining a
14707// copy of this software and associated documentation files (the
14708// "Software"), to deal in the Software without restriction, including
14709// without limitation the rights to use, copy, modify, merge, publish,
14710// distribute, sublicense, and/or sell copies of the Software, and to permit
14711// persons to whom the Software is furnished to do so, subject to the
14712// following conditions:
14713//
14714// The above copyright notice and this permission notice shall be included
14715// in all copies or substantial portions of the Software.
14716//
14717// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14718// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14719// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
14720// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
14721// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14722// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
14723// USE OR OTHER DEALINGS IN THE SOFTWARE.
14724
14725// resolves . and .. elements in a path array with directory names there
14726// must be no slashes, empty elements, or device names (c:\) in the array
14727// (so also no leading and trailing slashes - it does not distinguish
14728// relative and absolute paths)
14729function normalizeArray(parts, allowAboveRoot) {
14730 // if the path tries to go above the root, `up` ends up > 0
14731 var up = 0;
14732 for (var i = parts.length - 1; i >= 0; i--) {
14733 var last = parts[i];
14734 if (last === '.') {
14735 parts.splice(i, 1);
14736 } else if (last === '..') {
14737 parts.splice(i, 1);
14738 up++;
14739 } else if (up) {
14740 parts.splice(i, 1);
14741 up--;
14742 }
14743 }
14744
14745 // if the path is allowed to go above the root, restore leading ..s
14746 if (allowAboveRoot) {
14747 for (; up--; up) {
14748 parts.unshift('..');
14749 }
14750 }
14751
14752 return parts;
14753}
14754
14755// path.resolve([from ...], to)
14756// posix version
14757exports.resolve = function() {
14758 var resolvedPath = '',
14759 resolvedAbsolute = false;
14760
14761 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
14762 var path = (i >= 0) ? arguments[i] : process.cwd();
14763
14764 // Skip empty and invalid entries
14765 if (typeof path !== 'string') {
14766 throw new TypeError('Arguments to path.resolve must be strings');
14767 } else if (!path) {
14768 continue;
14769 }
14770
14771 resolvedPath = path + '/' + resolvedPath;
14772 resolvedAbsolute = path.charAt(0) === '/';
14773 }
14774
14775 // At this point the path should be resolved to a full absolute path, but
14776 // handle relative paths to be safe (might happen when process.cwd() fails)
14777
14778 // Normalize the path
14779 resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
14780 return !!p;
14781 }), !resolvedAbsolute).join('/');
14782
14783 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
14784};
14785
14786// path.normalize(path)
14787// posix version
14788exports.normalize = function(path) {
14789 var isAbsolute = exports.isAbsolute(path),
14790 trailingSlash = substr(path, -1) === '/';
14791
14792 // Normalize the path
14793 path = normalizeArray(filter(path.split('/'), function(p) {
14794 return !!p;
14795 }), !isAbsolute).join('/');
14796
14797 if (!path && !isAbsolute) {
14798 path = '.';
14799 }
14800 if (path && trailingSlash) {
14801 path += '/';
14802 }
14803
14804 return (isAbsolute ? '/' : '') + path;
14805};
14806
14807// posix version
14808exports.isAbsolute = function(path) {
14809 return path.charAt(0) === '/';
14810};
14811
14812// posix version
14813exports.join = function() {
14814 var paths = Array.prototype.slice.call(arguments, 0);
14815 return exports.normalize(filter(paths, function(p, index) {
14816 if (typeof p !== 'string') {
14817 throw new TypeError('Arguments to path.join must be strings');
14818 }
14819 return p;
14820 }).join('/'));
14821};
14822
14823
14824// path.relative(from, to)
14825// posix version
14826exports.relative = function(from, to) {
14827 from = exports.resolve(from).substr(1);
14828 to = exports.resolve(to).substr(1);
14829
14830 function trim(arr) {
14831 var start = 0;
14832 for (; start < arr.length; start++) {
14833 if (arr[start] !== '') break;
14834 }
14835
14836 var end = arr.length - 1;
14837 for (; end >= 0; end--) {
14838 if (arr[end] !== '') break;
14839 }
14840
14841 if (start > end) return [];
14842 return arr.slice(start, end - start + 1);
14843 }
14844
14845 var fromParts = trim(from.split('/'));
14846 var toParts = trim(to.split('/'));
14847
14848 var length = Math.min(fromParts.length, toParts.length);
14849 var samePartsLength = length;
14850 for (var i = 0; i < length; i++) {
14851 if (fromParts[i] !== toParts[i]) {
14852 samePartsLength = i;
14853 break;
14854 }
14855 }
14856
14857 var outputParts = [];
14858 for (var i = samePartsLength; i < fromParts.length; i++) {
14859 outputParts.push('..');
14860 }
14861
14862 outputParts = outputParts.concat(toParts.slice(samePartsLength));
14863
14864 return outputParts.join('/');
14865};
14866
14867exports.sep = '/';
14868exports.delimiter = ':';
14869
14870exports.dirname = function (path) {
14871 if (typeof path !== 'string') path = path + '';
14872 if (path.length === 0) return '.';
14873 var code = path.charCodeAt(0);
14874 var hasRoot = code === 47 /*/*/;
14875 var end = -1;
14876 var matchedSlash = true;
14877 for (var i = path.length - 1; i >= 1; --i) {
14878 code = path.charCodeAt(i);
14879 if (code === 47 /*/*/) {
14880 if (!matchedSlash) {
14881 end = i;
14882 break;
14883 }
14884 } else {
14885 // We saw the first non-path separator
14886 matchedSlash = false;
14887 }
14888 }
14889
14890 if (end === -1) return hasRoot ? '/' : '.';
14891 if (hasRoot && end === 1) {
14892 // return '//';
14893 // Backwards-compat fix:
14894 return '/';
14895 }
14896 return path.slice(0, end);
14897};
14898
14899function basename(path) {
14900 if (typeof path !== 'string') path = path + '';
14901
14902 var start = 0;
14903 var end = -1;
14904 var matchedSlash = true;
14905 var i;
14906
14907 for (i = path.length - 1; i >= 0; --i) {
14908 if (path.charCodeAt(i) === 47 /*/*/) {
14909 // If we reached a path separator that was not part of a set of path
14910 // separators at the end of the string, stop now
14911 if (!matchedSlash) {
14912 start = i + 1;
14913 break;
14914 }
14915 } else if (end === -1) {
14916 // We saw the first non-path separator, mark this as the end of our
14917 // path component
14918 matchedSlash = false;
14919 end = i + 1;
14920 }
14921 }
14922
14923 if (end === -1) return '';
14924 return path.slice(start, end);
14925}
14926
14927// Uses a mixed approach for backwards-compatibility, as ext behavior changed
14928// in new Node.js versions, so only basename() above is backported here
14929exports.basename = function (path, ext) {
14930 var f = basename(path);
14931 if (ext && f.substr(-1 * ext.length) === ext) {
14932 f = f.substr(0, f.length - ext.length);
14933 }
14934 return f;
14935};
14936
14937exports.extname = function (path) {
14938 if (typeof path !== 'string') path = path + '';
14939 var startDot = -1;
14940 var startPart = 0;
14941 var end = -1;
14942 var matchedSlash = true;
14943 // Track the state of characters (if any) we see before our first dot and
14944 // after any path separator we find
14945 var preDotState = 0;
14946 for (var i = path.length - 1; i >= 0; --i) {
14947 var code = path.charCodeAt(i);
14948 if (code === 47 /*/*/) {
14949 // If we reached a path separator that was not part of a set of path
14950 // separators at the end of the string, stop now
14951 if (!matchedSlash) {
14952 startPart = i + 1;
14953 break;
14954 }
14955 continue;
14956 }
14957 if (end === -1) {
14958 // We saw the first non-path separator, mark this as the end of our
14959 // extension
14960 matchedSlash = false;
14961 end = i + 1;
14962 }
14963 if (code === 46 /*.*/) {
14964 // If this is our first dot, mark it as the start of our extension
14965 if (startDot === -1)
14966 startDot = i;
14967 else if (preDotState !== 1)
14968 preDotState = 1;
14969 } else if (startDot !== -1) {
14970 // We saw a non-dot and non-path separator before our dot, so we should
14971 // have a good chance at having a non-empty extension
14972 preDotState = -1;
14973 }
14974 }
14975
14976 if (startDot === -1 || end === -1 ||
14977 // We saw a non-dot character immediately before the dot
14978 preDotState === 0 ||
14979 // The (right-most) trimmed path component is exactly '..'
14980 preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
14981 return '';
14982 }
14983 return path.slice(startDot, end);
14984};
14985
14986function filter (xs, f) {
14987 if (xs.filter) return xs.filter(f);
14988 var res = [];
14989 for (var i = 0; i < xs.length; i++) {
14990 if (f(xs[i], i, xs)) res.push(xs[i]);
14991 }
14992 return res;
14993}
14994
14995// String.prototype.substr - negative index don't work in IE8
14996var substr = 'ab'.substr(-1) === 'b'
14997 ? function (str, start, len) { return str.substr(start, len) }
14998 : function (str, start, len) {
14999 if (start < 0) start = str.length + start;
15000 return str.substr(start, len);
15001 }
15002;
15003
15004}).call(this,require('_process'))
15005},{"_process":239}],237:[function(require,module,exports){
15006(function (global){
15007/*!
15008 * Platform.js <https://mths.be/platform>
15009 * Copyright 2014-2018 Benjamin Tan <https://bnjmnt4n.now.sh/>
15010 * Copyright 2011-2013 John-David Dalton <http://allyoucanleet.com/>
15011 * Available under MIT license <https://mths.be/mit>
15012 */
15013;(function() {
15014 'use strict';
15015
15016 /** Used to determine if values are of the language type `Object`. */
15017 var objectTypes = {
15018 'function': true,
15019 'object': true
15020 };
15021
15022 /** Used as a reference to the global object. */
15023 var root = (objectTypes[typeof window] && window) || this;
15024
15025 /** Backup possible global object. */
15026 var oldRoot = root;
15027
15028 /** Detect free variable `exports`. */
15029 var freeExports = objectTypes[typeof exports] && exports;
15030
15031 /** Detect free variable `module`. */
15032 var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
15033
15034 /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */
15035 var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
15036 if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
15037 root = freeGlobal;
15038 }
15039
15040 /**
15041 * Used as the maximum length of an array-like object.
15042 * See the [ES6 spec](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
15043 * for more details.
15044 */
15045 var maxSafeInteger = Math.pow(2, 53) - 1;
15046
15047 /** Regular expression to detect Opera. */
15048 var reOpera = /\bOpera/;
15049
15050 /** Possible global object. */
15051 var thisBinding = this;
15052
15053 /** Used for native method references. */
15054 var objectProto = Object.prototype;
15055
15056 /** Used to check for own properties of an object. */
15057 var hasOwnProperty = objectProto.hasOwnProperty;
15058
15059 /** Used to resolve the internal `[[Class]]` of values. */
15060 var toString = objectProto.toString;
15061
15062 /*--------------------------------------------------------------------------*/
15063
15064 /**
15065 * Capitalizes a string value.
15066 *
15067 * @private
15068 * @param {string} string The string to capitalize.
15069 * @returns {string} The capitalized string.
15070 */
15071 function capitalize(string) {
15072 string = String(string);
15073 return string.charAt(0).toUpperCase() + string.slice(1);
15074 }
15075
15076 /**
15077 * A utility function to clean up the OS name.
15078 *
15079 * @private
15080 * @param {string} os The OS name to clean up.
15081 * @param {string} [pattern] A `RegExp` pattern matching the OS name.
15082 * @param {string} [label] A label for the OS.
15083 */
15084 function cleanupOS(os, pattern, label) {
15085 // Platform tokens are defined at:
15086 // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
15087 // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
15088 var data = {
15089 '10.0': '10',
15090 '6.4': '10 Technical Preview',
15091 '6.3': '8.1',
15092 '6.2': '8',
15093 '6.1': 'Server 2008 R2 / 7',
15094 '6.0': 'Server 2008 / Vista',
15095 '5.2': 'Server 2003 / XP 64-bit',
15096 '5.1': 'XP',
15097 '5.01': '2000 SP1',
15098 '5.0': '2000',
15099 '4.0': 'NT',
15100 '4.90': 'ME'
15101 };
15102 // Detect Windows version from platform tokens.
15103 if (pattern && label && /^Win/i.test(os) && !/^Windows Phone /i.test(os) &&
15104 (data = data[/[\d.]+$/.exec(os)])) {
15105 os = 'Windows ' + data;
15106 }
15107 // Correct character case and cleanup string.
15108 os = String(os);
15109
15110 if (pattern && label) {
15111 os = os.replace(RegExp(pattern, 'i'), label);
15112 }
15113
15114 os = format(
15115 os.replace(/ ce$/i, ' CE')
15116 .replace(/\bhpw/i, 'web')
15117 .replace(/\bMacintosh\b/, 'Mac OS')
15118 .replace(/_PowerPC\b/i, ' OS')
15119 .replace(/\b(OS X) [^ \d]+/i, '$1')
15120 .replace(/\bMac (OS X)\b/, '$1')
15121 .replace(/\/(\d)/, ' $1')
15122 .replace(/_/g, '.')
15123 .replace(/(?: BePC|[ .]*fc[ \d.]+)$/i, '')
15124 .replace(/\bx86\.64\b/gi, 'x86_64')
15125 .replace(/\b(Windows Phone) OS\b/, '$1')
15126 .replace(/\b(Chrome OS \w+) [\d.]+\b/, '$1')
15127 .split(' on ')[0]
15128 );
15129
15130 return os;
15131 }
15132
15133 /**
15134 * An iteration utility for arrays and objects.
15135 *
15136 * @private
15137 * @param {Array|Object} object The object to iterate over.
15138 * @param {Function} callback The function called per iteration.
15139 */
15140 function each(object, callback) {
15141 var index = -1,
15142 length = object ? object.length : 0;
15143
15144 if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) {
15145 while (++index < length) {
15146 callback(object[index], index, object);
15147 }
15148 } else {
15149 forOwn(object, callback);
15150 }
15151 }
15152
15153 /**
15154 * Trim and conditionally capitalize string values.
15155 *
15156 * @private
15157 * @param {string} string The string to format.
15158 * @returns {string} The formatted string.
15159 */
15160 function format(string) {
15161 string = trim(string);
15162 return /^(?:webOS|i(?:OS|P))/.test(string)
15163 ? string
15164 : capitalize(string);
15165 }
15166
15167 /**
15168 * Iterates over an object's own properties, executing the `callback` for each.
15169 *
15170 * @private
15171 * @param {Object} object The object to iterate over.
15172 * @param {Function} callback The function executed per own property.
15173 */
15174 function forOwn(object, callback) {
15175 for (var key in object) {
15176 if (hasOwnProperty.call(object, key)) {
15177 callback(object[key], key, object);
15178 }
15179 }
15180 }
15181
15182 /**
15183 * Gets the internal `[[Class]]` of a value.
15184 *
15185 * @private
15186 * @param {*} value The value.
15187 * @returns {string} The `[[Class]]`.
15188 */
15189 function getClassOf(value) {
15190 return value == null
15191 ? capitalize(value)
15192 : toString.call(value).slice(8, -1);
15193 }
15194
15195 /**
15196 * Host objects can return type values that are different from their actual
15197 * data type. The objects we are concerned with usually return non-primitive
15198 * types of "object", "function", or "unknown".
15199 *
15200 * @private
15201 * @param {*} object The owner of the property.
15202 * @param {string} property The property to check.
15203 * @returns {boolean} Returns `true` if the property value is a non-primitive, else `false`.
15204 */
15205 function isHostType(object, property) {
15206 var type = object != null ? typeof object[property] : 'number';
15207 return !/^(?:boolean|number|string|undefined)$/.test(type) &&
15208 (type == 'object' ? !!object[property] : true);
15209 }
15210
15211 /**
15212 * Prepares a string for use in a `RegExp` by making hyphens and spaces optional.
15213 *
15214 * @private
15215 * @param {string} string The string to qualify.
15216 * @returns {string} The qualified string.
15217 */
15218 function qualify(string) {
15219 return String(string).replace(/([ -])(?!$)/g, '$1?');
15220 }
15221
15222 /**
15223 * A bare-bones `Array#reduce` like utility function.
15224 *
15225 * @private
15226 * @param {Array} array The array to iterate over.
15227 * @param {Function} callback The function called per iteration.
15228 * @returns {*} The accumulated result.
15229 */
15230 function reduce(array, callback) {
15231 var accumulator = null;
15232 each(array, function(value, index) {
15233 accumulator = callback(accumulator, value, index, array);
15234 });
15235 return accumulator;
15236 }
15237
15238 /**
15239 * Removes leading and trailing whitespace from a string.
15240 *
15241 * @private
15242 * @param {string} string The string to trim.
15243 * @returns {string} The trimmed string.
15244 */
15245 function trim(string) {
15246 return String(string).replace(/^ +| +$/g, '');
15247 }
15248
15249 /*--------------------------------------------------------------------------*/
15250
15251 /**
15252 * Creates a new platform object.
15253 *
15254 * @memberOf platform
15255 * @param {Object|string} [ua=navigator.userAgent] The user agent string or
15256 * context object.
15257 * @returns {Object} A platform object.
15258 */
15259 function parse(ua) {
15260
15261 /** The environment context object. */
15262 var context = root;
15263
15264 /** Used to flag when a custom context is provided. */
15265 var isCustomContext = ua && typeof ua == 'object' && getClassOf(ua) != 'String';
15266
15267 // Juggle arguments.
15268 if (isCustomContext) {
15269 context = ua;
15270 ua = null;
15271 }
15272
15273 /** Browser navigator object. */
15274 var nav = context.navigator || {};
15275
15276 /** Browser user agent string. */
15277 var userAgent = nav.userAgent || '';
15278
15279 ua || (ua = userAgent);
15280
15281 /** Used to flag when `thisBinding` is the [ModuleScope]. */
15282 var isModuleScope = isCustomContext || thisBinding == oldRoot;
15283
15284 /** Used to detect if browser is like Chrome. */
15285 var likeChrome = isCustomContext
15286 ? !!nav.likeChrome
15287 : /\bChrome\b/.test(ua) && !/internal|\n/i.test(toString.toString());
15288
15289 /** Internal `[[Class]]` value shortcuts. */
15290 var objectClass = 'Object',
15291 airRuntimeClass = isCustomContext ? objectClass : 'ScriptBridgingProxyObject',
15292 enviroClass = isCustomContext ? objectClass : 'Environment',
15293 javaClass = (isCustomContext && context.java) ? 'JavaPackage' : getClassOf(context.java),
15294 phantomClass = isCustomContext ? objectClass : 'RuntimeObject';
15295
15296 /** Detect Java environments. */
15297 var java = /\bJava/.test(javaClass) && context.java;
15298
15299 /** Detect Rhino. */
15300 var rhino = java && getClassOf(context.environment) == enviroClass;
15301
15302 /** A character to represent alpha. */
15303 var alpha = java ? 'a' : '\u03b1';
15304
15305 /** A character to represent beta. */
15306 var beta = java ? 'b' : '\u03b2';
15307
15308 /** Browser document object. */
15309 var doc = context.document || {};
15310
15311 /**
15312 * Detect Opera browser (Presto-based).
15313 * http://www.howtocreate.co.uk/operaStuff/operaObject.html
15314 * http://dev.opera.com/articles/view/opera-mini-web-content-authoring-guidelines/#operamini
15315 */
15316 var opera = context.operamini || context.opera;
15317
15318 /** Opera `[[Class]]`. */
15319 var operaClass = reOpera.test(operaClass = (isCustomContext && opera) ? opera['[[Class]]'] : getClassOf(opera))
15320 ? operaClass
15321 : (opera = null);
15322
15323 /*------------------------------------------------------------------------*/
15324
15325 /** Temporary variable used over the script's lifetime. */
15326 var data;
15327
15328 /** The CPU architecture. */
15329 var arch = ua;
15330
15331 /** Platform description array. */
15332 var description = [];
15333
15334 /** Platform alpha/beta indicator. */
15335 var prerelease = null;
15336
15337 /** A flag to indicate that environment features should be used to resolve the platform. */
15338 var useFeatures = ua == userAgent;
15339
15340 /** The browser/environment version. */
15341 var version = useFeatures && opera && typeof opera.version == 'function' && opera.version();
15342
15343 /** A flag to indicate if the OS ends with "/ Version" */
15344 var isSpecialCasedOS;
15345
15346 /* Detectable layout engines (order is important). */
15347 var layout = getLayout([
15348 { 'label': 'EdgeHTML', 'pattern': 'Edge' },
15349 'Trident',
15350 { 'label': 'WebKit', 'pattern': 'AppleWebKit' },
15351 'iCab',
15352 'Presto',
15353 'NetFront',
15354 'Tasman',
15355 'KHTML',
15356 'Gecko'
15357 ]);
15358
15359 /* Detectable browser names (order is important). */
15360 var name = getName([
15361 'Adobe AIR',
15362 'Arora',
15363 'Avant Browser',
15364 'Breach',
15365 'Camino',
15366 'Electron',
15367 'Epiphany',
15368 'Fennec',
15369 'Flock',
15370 'Galeon',
15371 'GreenBrowser',
15372 'iCab',
15373 'Iceweasel',
15374 'K-Meleon',
15375 'Konqueror',
15376 'Lunascape',
15377 'Maxthon',
15378 { 'label': 'Microsoft Edge', 'pattern': 'Edge' },
15379 'Midori',
15380 'Nook Browser',
15381 'PaleMoon',
15382 'PhantomJS',
15383 'Raven',
15384 'Rekonq',
15385 'RockMelt',
15386 { 'label': 'Samsung Internet', 'pattern': 'SamsungBrowser' },
15387 'SeaMonkey',
15388 { 'label': 'Silk', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
15389 'Sleipnir',
15390 'SlimBrowser',
15391 { 'label': 'SRWare Iron', 'pattern': 'Iron' },
15392 'Sunrise',
15393 'Swiftfox',
15394 'Waterfox',
15395 'WebPositive',
15396 'Opera Mini',
15397 { 'label': 'Opera Mini', 'pattern': 'OPiOS' },
15398 'Opera',
15399 { 'label': 'Opera', 'pattern': 'OPR' },
15400 'Chrome',
15401 { 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' },
15402 { 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },
15403 { 'label': 'Firefox for iOS', 'pattern': 'FxiOS' },
15404 { 'label': 'IE', 'pattern': 'IEMobile' },
15405 { 'label': 'IE', 'pattern': 'MSIE' },
15406 'Safari'
15407 ]);
15408
15409 /* Detectable products (order is important). */
15410 var product = getProduct([
15411 { 'label': 'BlackBerry', 'pattern': 'BB10' },
15412 'BlackBerry',
15413 { 'label': 'Galaxy S', 'pattern': 'GT-I9000' },
15414 { 'label': 'Galaxy S2', 'pattern': 'GT-I9100' },
15415 { 'label': 'Galaxy S3', 'pattern': 'GT-I9300' },
15416 { 'label': 'Galaxy S4', 'pattern': 'GT-I9500' },
15417 { 'label': 'Galaxy S5', 'pattern': 'SM-G900' },
15418 { 'label': 'Galaxy S6', 'pattern': 'SM-G920' },
15419 { 'label': 'Galaxy S6 Edge', 'pattern': 'SM-G925' },
15420 { 'label': 'Galaxy S7', 'pattern': 'SM-G930' },
15421 { 'label': 'Galaxy S7 Edge', 'pattern': 'SM-G935' },
15422 'Google TV',
15423 'Lumia',
15424 'iPad',
15425 'iPod',
15426 'iPhone',
15427 'Kindle',
15428 { 'label': 'Kindle Fire', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
15429 'Nexus',
15430 'Nook',
15431 'PlayBook',
15432 'PlayStation Vita',
15433 'PlayStation',
15434 'TouchPad',
15435 'Transformer',
15436 { 'label': 'Wii U', 'pattern': 'WiiU' },
15437 'Wii',
15438 'Xbox One',
15439 { 'label': 'Xbox 360', 'pattern': 'Xbox' },
15440 'Xoom'
15441 ]);
15442
15443 /* Detectable manufacturers. */
15444 var manufacturer = getManufacturer({
15445 'Apple': { 'iPad': 1, 'iPhone': 1, 'iPod': 1 },
15446 'Archos': {},
15447 'Amazon': { 'Kindle': 1, 'Kindle Fire': 1 },
15448 'Asus': { 'Transformer': 1 },
15449 'Barnes & Noble': { 'Nook': 1 },
15450 'BlackBerry': { 'PlayBook': 1 },
15451 'Google': { 'Google TV': 1, 'Nexus': 1 },
15452 'HP': { 'TouchPad': 1 },
15453 'HTC': {},
15454 'LG': {},
15455 'Microsoft': { 'Xbox': 1, 'Xbox One': 1 },
15456 'Motorola': { 'Xoom': 1 },
15457 'Nintendo': { 'Wii U': 1, 'Wii': 1 },
15458 'Nokia': { 'Lumia': 1 },
15459 'Samsung': { 'Galaxy S': 1, 'Galaxy S2': 1, 'Galaxy S3': 1, 'Galaxy S4': 1 },
15460 'Sony': { 'PlayStation': 1, 'PlayStation Vita': 1 }
15461 });
15462
15463 /* Detectable operating systems (order is important). */
15464 var os = getOS([
15465 'Windows Phone',
15466 'Android',
15467 'CentOS',
15468 { 'label': 'Chrome OS', 'pattern': 'CrOS' },
15469 'Debian',
15470 'Fedora',
15471 'FreeBSD',
15472 'Gentoo',
15473 'Haiku',
15474 'Kubuntu',
15475 'Linux Mint',
15476 'OpenBSD',
15477 'Red Hat',
15478 'SuSE',
15479 'Ubuntu',
15480 'Xubuntu',
15481 'Cygwin',
15482 'Symbian OS',
15483 'hpwOS',
15484 'webOS ',
15485 'webOS',
15486 'Tablet OS',
15487 'Tizen',
15488 'Linux',
15489 'Mac OS X',
15490 'Macintosh',
15491 'Mac',
15492 'Windows 98;',
15493 'Windows '
15494 ]);
15495
15496 /*------------------------------------------------------------------------*/
15497
15498 /**
15499 * Picks the layout engine from an array of guesses.
15500 *
15501 * @private
15502 * @param {Array} guesses An array of guesses.
15503 * @returns {null|string} The detected layout engine.
15504 */
15505 function getLayout(guesses) {
15506 return reduce(guesses, function(result, guess) {
15507 return result || RegExp('\\b' + (
15508 guess.pattern || qualify(guess)
15509 ) + '\\b', 'i').exec(ua) && (guess.label || guess);
15510 });
15511 }
15512
15513 /**
15514 * Picks the manufacturer from an array of guesses.
15515 *
15516 * @private
15517 * @param {Array} guesses An object of guesses.
15518 * @returns {null|string} The detected manufacturer.
15519 */
15520 function getManufacturer(guesses) {
15521 return reduce(guesses, function(result, value, key) {
15522 // Lookup the manufacturer by product or scan the UA for the manufacturer.
15523 return result || (
15524 value[product] ||
15525 value[/^[a-z]+(?: +[a-z]+\b)*/i.exec(product)] ||
15526 RegExp('\\b' + qualify(key) + '(?:\\b|\\w*\\d)', 'i').exec(ua)
15527 ) && key;
15528 });
15529 }
15530
15531 /**
15532 * Picks the browser name from an array of guesses.
15533 *
15534 * @private
15535 * @param {Array} guesses An array of guesses.
15536 * @returns {null|string} The detected browser name.
15537 */
15538 function getName(guesses) {
15539 return reduce(guesses, function(result, guess) {
15540 return result || RegExp('\\b' + (
15541 guess.pattern || qualify(guess)
15542 ) + '\\b', 'i').exec(ua) && (guess.label || guess);
15543 });
15544 }
15545
15546 /**
15547 * Picks the OS name from an array of guesses.
15548 *
15549 * @private
15550 * @param {Array} guesses An array of guesses.
15551 * @returns {null|string} The detected OS name.
15552 */
15553 function getOS(guesses) {
15554 return reduce(guesses, function(result, guess) {
15555 var pattern = guess.pattern || qualify(guess);
15556 if (!result && (result =
15557 RegExp('\\b' + pattern + '(?:/[\\d.]+|[ \\w.]*)', 'i').exec(ua)
15558 )) {
15559 result = cleanupOS(result, pattern, guess.label || guess);
15560 }
15561 return result;
15562 });
15563 }
15564
15565 /**
15566 * Picks the product name from an array of guesses.
15567 *
15568 * @private
15569 * @param {Array} guesses An array of guesses.
15570 * @returns {null|string} The detected product name.
15571 */
15572 function getProduct(guesses) {
15573 return reduce(guesses, function(result, guess) {
15574 var pattern = guess.pattern || qualify(guess);
15575 if (!result && (result =
15576 RegExp('\\b' + pattern + ' *\\d+[.\\w_]*', 'i').exec(ua) ||
15577 RegExp('\\b' + pattern + ' *\\w+-[\\w]*', 'i').exec(ua) ||
15578 RegExp('\\b' + pattern + '(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)', 'i').exec(ua)
15579 )) {
15580 // Split by forward slash and append product version if needed.
15581 if ((result = String((guess.label && !RegExp(pattern, 'i').test(guess.label)) ? guess.label : result).split('/'))[1] && !/[\d.]+/.test(result[0])) {
15582 result[0] += ' ' + result[1];
15583 }
15584 // Correct character case and cleanup string.
15585 guess = guess.label || guess;
15586 result = format(result[0]
15587 .replace(RegExp(pattern, 'i'), guess)
15588 .replace(RegExp('; *(?:' + guess + '[_-])?', 'i'), ' ')
15589 .replace(RegExp('(' + guess + ')[-_.]?(\\w)', 'i'), '$1 $2'));
15590 }
15591 return result;
15592 });
15593 }
15594
15595 /**
15596 * Resolves the version using an array of UA patterns.
15597 *
15598 * @private
15599 * @param {Array} patterns An array of UA patterns.
15600 * @returns {null|string} The detected version.
15601 */
15602 function getVersion(patterns) {
15603 return reduce(patterns, function(result, pattern) {
15604 return result || (RegExp(pattern +
15605 '(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null;
15606 });
15607 }
15608
15609 /**
15610 * Returns `platform.description` when the platform object is coerced to a string.
15611 *
15612 * @name toString
15613 * @memberOf platform
15614 * @returns {string} Returns `platform.description` if available, else an empty string.
15615 */
15616 function toStringPlatform() {
15617 return this.description || '';
15618 }
15619
15620 /*------------------------------------------------------------------------*/
15621
15622 // Convert layout to an array so we can add extra details.
15623 layout && (layout = [layout]);
15624
15625 // Detect product names that contain their manufacturer's name.
15626 if (manufacturer && !product) {
15627 product = getProduct([manufacturer]);
15628 }
15629 // Clean up Google TV.
15630 if ((data = /\bGoogle TV\b/.exec(product))) {
15631 product = data[0];
15632 }
15633 // Detect simulators.
15634 if (/\bSimulator\b/i.test(ua)) {
15635 product = (product ? product + ' ' : '') + 'Simulator';
15636 }
15637 // Detect Opera Mini 8+ running in Turbo/Uncompressed mode on iOS.
15638 if (name == 'Opera Mini' && /\bOPiOS\b/.test(ua)) {
15639 description.push('running in Turbo/Uncompressed mode');
15640 }
15641 // Detect IE Mobile 11.
15642 if (name == 'IE' && /\blike iPhone OS\b/.test(ua)) {
15643 data = parse(ua.replace(/like iPhone OS/, ''));
15644 manufacturer = data.manufacturer;
15645 product = data.product;
15646 }
15647 // Detect iOS.
15648 else if (/^iP/.test(product)) {
15649 name || (name = 'Safari');
15650 os = 'iOS' + ((data = / OS ([\d_]+)/i.exec(ua))
15651 ? ' ' + data[1].replace(/_/g, '.')
15652 : '');
15653 }
15654 // Detect Kubuntu.
15655 else if (name == 'Konqueror' && !/buntu/i.test(os)) {
15656 os = 'Kubuntu';
15657 }
15658 // Detect Android browsers.
15659 else if ((manufacturer && manufacturer != 'Google' &&
15660 ((/Chrome/.test(name) && !/\bMobile Safari\b/i.test(ua)) || /\bVita\b/.test(product))) ||
15661 (/\bAndroid\b/.test(os) && /^Chrome/.test(name) && /\bVersion\//i.test(ua))) {
15662 name = 'Android Browser';
15663 os = /\bAndroid\b/.test(os) ? os : 'Android';
15664 }
15665 // Detect Silk desktop/accelerated modes.
15666 else if (name == 'Silk') {
15667 if (!/\bMobi/i.test(ua)) {
15668 os = 'Android';
15669 description.unshift('desktop mode');
15670 }
15671 if (/Accelerated *= *true/i.test(ua)) {
15672 description.unshift('accelerated');
15673 }
15674 }
15675 // Detect PaleMoon identifying as Firefox.
15676 else if (name == 'PaleMoon' && (data = /\bFirefox\/([\d.]+)\b/.exec(ua))) {
15677 description.push('identifying as Firefox ' + data[1]);
15678 }
15679 // Detect Firefox OS and products running Firefox.
15680 else if (name == 'Firefox' && (data = /\b(Mobile|Tablet|TV)\b/i.exec(ua))) {
15681 os || (os = 'Firefox OS');
15682 product || (product = data[1]);
15683 }
15684 // Detect false positives for Firefox/Safari.
15685 else if (!name || (data = !/\bMinefield\b/i.test(ua) && /\b(?:Firefox|Safari)\b/.exec(name))) {
15686 // Escape the `/` for Firefox 1.
15687 if (name && !product && /[\/,]|^[^(]+?\)/.test(ua.slice(ua.indexOf(data + '/') + 8))) {
15688 // Clear name of false positives.
15689 name = null;
15690 }
15691 // Reassign a generic name.
15692 if ((data = product || manufacturer || os) &&
15693 (product || manufacturer || /\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(os))) {
15694 name = /[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(os) ? os : data) + ' Browser';
15695 }
15696 }
15697 // Add Chrome version to description for Electron.
15698 else if (name == 'Electron' && (data = (/\bChrome\/([\d.]+)\b/.exec(ua) || 0)[1])) {
15699 description.push('Chromium ' + data);
15700 }
15701 // Detect non-Opera (Presto-based) versions (order is important).
15702 if (!version) {
15703 version = getVersion([
15704 '(?:Cloud9|CriOS|CrMo|Edge|FxiOS|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$))',
15705 'Version',
15706 qualify(name),
15707 '(?:Firefox|Minefield|NetFront)'
15708 ]);
15709 }
15710 // Detect stubborn layout engines.
15711 if ((data =
15712 layout == 'iCab' && parseFloat(version) > 3 && 'WebKit' ||
15713 /\bOpera\b/.test(name) && (/\bOPR\b/.test(ua) ? 'Blink' : 'Presto') ||
15714 /\b(?:Midori|Nook|Safari)\b/i.test(ua) && !/^(?:Trident|EdgeHTML)$/.test(layout) && 'WebKit' ||
15715 !layout && /\bMSIE\b/i.test(ua) && (os == 'Mac OS' ? 'Tasman' : 'Trident') ||
15716 layout == 'WebKit' && /\bPlayStation\b(?! Vita\b)/i.test(name) && 'NetFront'
15717 )) {
15718 layout = [data];
15719 }
15720 // Detect Windows Phone 7 desktop mode.
15721 if (name == 'IE' && (data = (/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(ua) || 0)[1])) {
15722 name += ' Mobile';
15723 os = 'Windows Phone ' + (/\+$/.test(data) ? data : data + '.x');
15724 description.unshift('desktop mode');
15725 }
15726 // Detect Windows Phone 8.x desktop mode.
15727 else if (/\bWPDesktop\b/i.test(ua)) {
15728 name = 'IE Mobile';
15729 os = 'Windows Phone 8.x';
15730 description.unshift('desktop mode');
15731 version || (version = (/\brv:([\d.]+)/.exec(ua) || 0)[1]);
15732 }
15733 // Detect IE 11 identifying as other browsers.
15734 else if (name != 'IE' && layout == 'Trident' && (data = /\brv:([\d.]+)/.exec(ua))) {
15735 if (name) {
15736 description.push('identifying as ' + name + (version ? ' ' + version : ''));
15737 }
15738 name = 'IE';
15739 version = data[1];
15740 }
15741 // Leverage environment features.
15742 if (useFeatures) {
15743 // Detect server-side environments.
15744 // Rhino has a global function while others have a global object.
15745 if (isHostType(context, 'global')) {
15746 if (java) {
15747 data = java.lang.System;
15748 arch = data.getProperty('os.arch');
15749 os = os || data.getProperty('os.name') + ' ' + data.getProperty('os.version');
15750 }
15751 if (rhino) {
15752 try {
15753 version = context.require('ringo/engine').version.join('.');
15754 name = 'RingoJS';
15755 } catch(e) {
15756 if ((data = context.system) && data.global.system == context.system) {
15757 name = 'Narwhal';
15758 os || (os = data[0].os || null);
15759 }
15760 }
15761 if (!name) {
15762 name = 'Rhino';
15763 }
15764 }
15765 else if (
15766 typeof context.process == 'object' && !context.process.browser &&
15767 (data = context.process)
15768 ) {
15769 if (typeof data.versions == 'object') {
15770 if (typeof data.versions.electron == 'string') {
15771 description.push('Node ' + data.versions.node);
15772 name = 'Electron';
15773 version = data.versions.electron;
15774 } else if (typeof data.versions.nw == 'string') {
15775 description.push('Chromium ' + version, 'Node ' + data.versions.node);
15776 name = 'NW.js';
15777 version = data.versions.nw;
15778 }
15779 }
15780 if (!name) {
15781 name = 'Node.js';
15782 arch = data.arch;
15783 os = data.platform;
15784 version = /[\d.]+/.exec(data.version);
15785 version = version ? version[0] : null;
15786 }
15787 }
15788 }
15789 // Detect Adobe AIR.
15790 else if (getClassOf((data = context.runtime)) == airRuntimeClass) {
15791 name = 'Adobe AIR';
15792 os = data.flash.system.Capabilities.os;
15793 }
15794 // Detect PhantomJS.
15795 else if (getClassOf((data = context.phantom)) == phantomClass) {
15796 name = 'PhantomJS';
15797 version = (data = data.version || null) && (data.major + '.' + data.minor + '.' + data.patch);
15798 }
15799 // Detect IE compatibility modes.
15800 else if (typeof doc.documentMode == 'number' && (data = /\bTrident\/(\d+)/i.exec(ua))) {
15801 // We're in compatibility mode when the Trident version + 4 doesn't
15802 // equal the document mode.
15803 version = [version, doc.documentMode];
15804 if ((data = +data[1] + 4) != version[1]) {
15805 description.push('IE ' + version[1] + ' mode');
15806 layout && (layout[1] = '');
15807 version[1] = data;
15808 }
15809 version = name == 'IE' ? String(version[1].toFixed(1)) : version[0];
15810 }
15811 // Detect IE 11 masking as other browsers.
15812 else if (typeof doc.documentMode == 'number' && /^(?:Chrome|Firefox)\b/.test(name)) {
15813 description.push('masking as ' + name + ' ' + version);
15814 name = 'IE';
15815 version = '11.0';
15816 layout = ['Trident'];
15817 os = 'Windows';
15818 }
15819 os = os && format(os);
15820 }
15821 // Detect prerelease phases.
15822 if (version && (data =
15823 /(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(version) ||
15824 /(?:alpha|beta)(?: ?\d)?/i.exec(ua + ';' + (useFeatures && nav.appMinorVersion)) ||
15825 /\bMinefield\b/i.test(ua) && 'a'
15826 )) {
15827 prerelease = /b/i.test(data) ? 'beta' : 'alpha';
15828 version = version.replace(RegExp(data + '\\+?$'), '') +
15829 (prerelease == 'beta' ? beta : alpha) + (/\d+\+?/.exec(data) || '');
15830 }
15831 // Detect Firefox Mobile.
15832 if (name == 'Fennec' || name == 'Firefox' && /\b(?:Android|Firefox OS)\b/.test(os)) {
15833 name = 'Firefox Mobile';
15834 }
15835 // Obscure Maxthon's unreliable version.
15836 else if (name == 'Maxthon' && version) {
15837 version = version.replace(/\.[\d.]+/, '.x');
15838 }
15839 // Detect Xbox 360 and Xbox One.
15840 else if (/\bXbox\b/i.test(product)) {
15841 if (product == 'Xbox 360') {
15842 os = null;
15843 }
15844 if (product == 'Xbox 360' && /\bIEMobile\b/.test(ua)) {
15845 description.unshift('mobile mode');
15846 }
15847 }
15848 // Add mobile postfix.
15849 else if ((/^(?:Chrome|IE|Opera)$/.test(name) || name && !product && !/Browser|Mobi/.test(name)) &&
15850 (os == 'Windows CE' || /Mobi/i.test(ua))) {
15851 name += ' Mobile';
15852 }
15853 // Detect IE platform preview.
15854 else if (name == 'IE' && useFeatures) {
15855 try {
15856 if (context.external === null) {
15857 description.unshift('platform preview');
15858 }
15859 } catch(e) {
15860 description.unshift('embedded');
15861 }
15862 }
15863 // Detect BlackBerry OS version.
15864 // http://docs.blackberry.com/en/developers/deliverables/18169/HTTP_headers_sent_by_BB_Browser_1234911_11.jsp
15865 else if ((/\bBlackBerry\b/.test(product) || /\bBB10\b/.test(ua)) && (data =
15866 (RegExp(product.replace(/ +/g, ' *') + '/([.\\d]+)', 'i').exec(ua) || 0)[1] ||
15867 version
15868 )) {
15869 data = [data, /BB10/.test(ua)];
15870 os = (data[1] ? (product = null, manufacturer = 'BlackBerry') : 'Device Software') + ' ' + data[0];
15871 version = null;
15872 }
15873 // Detect Opera identifying/masking itself as another browser.
15874 // http://www.opera.com/support/kb/view/843/
15875 else if (this != forOwn && product != 'Wii' && (
15876 (useFeatures && opera) ||
15877 (/Opera/.test(name) && /\b(?:MSIE|Firefox)\b/i.test(ua)) ||
15878 (name == 'Firefox' && /\bOS X (?:\d+\.){2,}/.test(os)) ||
15879 (name == 'IE' && (
15880 (os && !/^Win/.test(os) && version > 5.5) ||
15881 /\bWindows XP\b/.test(os) && version > 8 ||
15882 version == 8 && !/\bTrident\b/.test(ua)
15883 ))
15884 ) && !reOpera.test((data = parse.call(forOwn, ua.replace(reOpera, '') + ';'))) && data.name) {
15885 // When "identifying", the UA contains both Opera and the other browser's name.
15886 data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : '');
15887 if (reOpera.test(name)) {
15888 if (/\bIE\b/.test(data) && os == 'Mac OS') {
15889 os = null;
15890 }
15891 data = 'identify' + data;
15892 }
15893 // When "masking", the UA contains only the other browser's name.
15894 else {
15895 data = 'mask' + data;
15896 if (operaClass) {
15897 name = format(operaClass.replace(/([a-z])([A-Z])/g, '$1 $2'));
15898 } else {
15899 name = 'Opera';
15900 }
15901 if (/\bIE\b/.test(data)) {
15902 os = null;
15903 }
15904 if (!useFeatures) {
15905 version = null;
15906 }
15907 }
15908 layout = ['Presto'];
15909 description.push(data);
15910 }
15911 // Detect WebKit Nightly and approximate Chrome/Safari versions.
15912 if ((data = (/\bAppleWebKit\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
15913 // Correct build number for numeric comparison.
15914 // (e.g. "532.5" becomes "532.05")
15915 data = [parseFloat(data.replace(/\.(\d)$/, '.0$1')), data];
15916 // Nightly builds are postfixed with a "+".
15917 if (name == 'Safari' && data[1].slice(-1) == '+') {
15918 name = 'WebKit Nightly';
15919 prerelease = 'alpha';
15920 version = data[1].slice(0, -1);
15921 }
15922 // Clear incorrect browser versions.
15923 else if (version == data[1] ||
15924 version == (data[2] = (/\bSafari\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
15925 version = null;
15926 }
15927 // Use the full Chrome version when available.
15928 data[1] = (/\bChrome\/([\d.]+)/i.exec(ua) || 0)[1];
15929 // Detect Blink layout engine.
15930 if (data[0] == 537.36 && data[2] == 537.36 && parseFloat(data[1]) >= 28 && layout == 'WebKit') {
15931 layout = ['Blink'];
15932 }
15933 // Detect JavaScriptCore.
15934 // http://stackoverflow.com/questions/6768474/how-can-i-detect-which-javascript-engine-v8-or-jsc-is-used-at-runtime-in-androi
15935 if (!useFeatures || (!likeChrome && !data[1])) {
15936 layout && (layout[1] = 'like Safari');
15937 data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : data < 537 ? 6 : data < 538 ? 7 : data < 601 ? 8 : '8');
15938 } else {
15939 layout && (layout[1] = 'like Chrome');
15940 data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 536.05 ? 18 : data < 536.10 ? 19 : data < 537.01 ? 20 : data < 537.11 ? '21+' : data < 537.13 ? 23 : data < 537.18 ? 24 : data < 537.24 ? 25 : data < 537.36 ? 26 : layout != 'Blink' ? '27' : '28');
15941 }
15942 // Add the postfix of ".x" or "+" for approximate versions.
15943 layout && (layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+'));
15944 // Obscure version for some Safari 1-2 releases.
15945 if (name == 'Safari' && (!version || parseInt(version) > 45)) {
15946 version = data;
15947 }
15948 }
15949 // Detect Opera desktop modes.
15950 if (name == 'Opera' && (data = /\bzbov|zvav$/.exec(os))) {
15951 name += ' ';
15952 description.unshift('desktop mode');
15953 if (data == 'zvav') {
15954 name += 'Mini';
15955 version = null;
15956 } else {
15957 name += 'Mobile';
15958 }
15959 os = os.replace(RegExp(' *' + data + '$'), '');
15960 }
15961 // Detect Chrome desktop mode.
15962 else if (name == 'Safari' && /\bChrome\b/.exec(layout && layout[1])) {
15963 description.unshift('desktop mode');
15964 name = 'Chrome Mobile';
15965 version = null;
15966
15967 if (/\bOS X\b/.test(os)) {
15968 manufacturer = 'Apple';
15969 os = 'iOS 4.3+';
15970 } else {
15971 os = null;
15972 }
15973 }
15974 // Strip incorrect OS versions.
15975 if (version && version.indexOf((data = /[\d.]+$/.exec(os))) == 0 &&
15976 ua.indexOf('/' + data + '-') > -1) {
15977 os = trim(os.replace(data, ''));
15978 }
15979 // Add layout engine.
15980 if (layout && !/\b(?:Avant|Nook)\b/.test(name) && (
15981 /Browser|Lunascape|Maxthon/.test(name) ||
15982 name != 'Safari' && /^iOS/.test(os) && /\bSafari\b/.test(layout[1]) ||
15983 /^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(name) && layout[1])) {
15984 // Don't add layout details to description if they are falsey.
15985 (data = layout[layout.length - 1]) && description.push(data);
15986 }
15987 // Combine contextual information.
15988 if (description.length) {
15989 description = ['(' + description.join('; ') + ')'];
15990 }
15991 // Append manufacturer to description.
15992 if (manufacturer && product && product.indexOf(manufacturer) < 0) {
15993 description.push('on ' + manufacturer);
15994 }
15995 // Append product to description.
15996 if (product) {
15997 description.push((/^on /.test(description[description.length - 1]) ? '' : 'on ') + product);
15998 }
15999 // Parse the OS into an object.
16000 if (os) {
16001 data = / ([\d.+]+)$/.exec(os);
16002 isSpecialCasedOS = data && os.charAt(os.length - data[0].length - 1) == '/';
16003 os = {
16004 'architecture': 32,
16005 'family': (data && !isSpecialCasedOS) ? os.replace(data[0], '') : os,
16006 'version': data ? data[1] : null,
16007 'toString': function() {
16008 var version = this.version;
16009 return this.family + ((version && !isSpecialCasedOS) ? ' ' + version : '') + (this.architecture == 64 ? ' 64-bit' : '');
16010 }
16011 };
16012 }
16013 // Add browser/OS architecture.
16014 if ((data = /\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(arch)) && !/\bi686\b/i.test(arch)) {
16015 if (os) {
16016 os.architecture = 64;
16017 os.family = os.family.replace(RegExp(' *' + data), '');
16018 }
16019 if (
16020 name && (/\bWOW64\b/i.test(ua) ||
16021 (useFeatures && /\w(?:86|32)$/.test(nav.cpuClass || nav.platform) && !/\bWin64; x64\b/i.test(ua)))
16022 ) {
16023 description.unshift('32-bit');
16024 }
16025 }
16026 // Chrome 39 and above on OS X is always 64-bit.
16027 else if (
16028 os && /^OS X/.test(os.family) &&
16029 name == 'Chrome' && parseFloat(version) >= 39
16030 ) {
16031 os.architecture = 64;
16032 }
16033
16034 ua || (ua = null);
16035
16036 /*------------------------------------------------------------------------*/
16037
16038 /**
16039 * The platform object.
16040 *
16041 * @name platform
16042 * @type Object
16043 */
16044 var platform = {};
16045
16046 /**
16047 * The platform description.
16048 *
16049 * @memberOf platform
16050 * @type string|null
16051 */
16052 platform.description = ua;
16053
16054 /**
16055 * The name of the browser's layout engine.
16056 *
16057 * The list of common layout engines include:
16058 * "Blink", "EdgeHTML", "Gecko", "Trident" and "WebKit"
16059 *
16060 * @memberOf platform
16061 * @type string|null
16062 */
16063 platform.layout = layout && layout[0];
16064
16065 /**
16066 * The name of the product's manufacturer.
16067 *
16068 * The list of manufacturers include:
16069 * "Apple", "Archos", "Amazon", "Asus", "Barnes & Noble", "BlackBerry",
16070 * "Google", "HP", "HTC", "LG", "Microsoft", "Motorola", "Nintendo",
16071 * "Nokia", "Samsung" and "Sony"
16072 *
16073 * @memberOf platform
16074 * @type string|null
16075 */
16076 platform.manufacturer = manufacturer;
16077
16078 /**
16079 * The name of the browser/environment.
16080 *
16081 * The list of common browser names include:
16082 * "Chrome", "Electron", "Firefox", "Firefox for iOS", "IE",
16083 * "Microsoft Edge", "PhantomJS", "Safari", "SeaMonkey", "Silk",
16084 * "Opera Mini" and "Opera"
16085 *
16086 * Mobile versions of some browsers have "Mobile" appended to their name:
16087 * eg. "Chrome Mobile", "Firefox Mobile", "IE Mobile" and "Opera Mobile"
16088 *
16089 * @memberOf platform
16090 * @type string|null
16091 */
16092 platform.name = name;
16093
16094 /**
16095 * The alpha/beta release indicator.
16096 *
16097 * @memberOf platform
16098 * @type string|null
16099 */
16100 platform.prerelease = prerelease;
16101
16102 /**
16103 * The name of the product hosting the browser.
16104 *
16105 * The list of common products include:
16106 *
16107 * "BlackBerry", "Galaxy S4", "Lumia", "iPad", "iPod", "iPhone", "Kindle",
16108 * "Kindle Fire", "Nexus", "Nook", "PlayBook", "TouchPad" and "Transformer"
16109 *
16110 * @memberOf platform
16111 * @type string|null
16112 */
16113 platform.product = product;
16114
16115 /**
16116 * The browser's user agent string.
16117 *
16118 * @memberOf platform
16119 * @type string|null
16120 */
16121 platform.ua = ua;
16122
16123 /**
16124 * The browser/environment version.
16125 *
16126 * @memberOf platform
16127 * @type string|null
16128 */
16129 platform.version = name && version;
16130
16131 /**
16132 * The name of the operating system.
16133 *
16134 * @memberOf platform
16135 * @type Object
16136 */
16137 platform.os = os || {
16138
16139 /**
16140 * The CPU architecture the OS is built for.
16141 *
16142 * @memberOf platform.os
16143 * @type number|null
16144 */
16145 'architecture': null,
16146
16147 /**
16148 * The family of the OS.
16149 *
16150 * Common values include:
16151 * "Windows", "Windows Server 2008 R2 / 7", "Windows Server 2008 / Vista",
16152 * "Windows XP", "OS X", "Ubuntu", "Debian", "Fedora", "Red Hat", "SuSE",
16153 * "Android", "iOS" and "Windows Phone"
16154 *
16155 * @memberOf platform.os
16156 * @type string|null
16157 */
16158 'family': null,
16159
16160 /**
16161 * The version of the OS.
16162 *
16163 * @memberOf platform.os
16164 * @type string|null
16165 */
16166 'version': null,
16167
16168 /**
16169 * Returns the OS string.
16170 *
16171 * @memberOf platform.os
16172 * @returns {string} The OS string.
16173 */
16174 'toString': function() { return 'null'; }
16175 };
16176
16177 platform.parse = parse;
16178 platform.toString = toStringPlatform;
16179
16180 if (platform.version) {
16181 description.unshift(version);
16182 }
16183 if (platform.name) {
16184 description.unshift(name);
16185 }
16186 if (os && name && !(os == String(os).split(' ')[0] && (os == name.split(' ')[0] || product))) {
16187 description.push(product ? '(' + os + ')' : 'on ' + os);
16188 }
16189 if (description.length) {
16190 platform.description = description.join(' ');
16191 }
16192 return platform;
16193 }
16194
16195 /*--------------------------------------------------------------------------*/
16196
16197 // Export platform.
16198 var platform = parse();
16199
16200 // Some AMD build optimizers, like r.js, check for condition patterns like the following:
16201 if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
16202 // Expose platform on the global object to prevent errors when platform is
16203 // loaded by a script tag in the presence of an AMD loader.
16204 // See http://requirejs.org/docs/errors.html#mismatch for more details.
16205 root.platform = platform;
16206
16207 // Define as an anonymous module so platform can be aliased through path mapping.
16208 define(function() {
16209 return platform;
16210 });
16211 }
16212 // Check for `exports` after `define` in case a build optimizer adds an `exports` object.
16213 else if (freeExports && freeModule) {
16214 // Export for CommonJS support.
16215 forOwn(platform, function(value, key) {
16216 freeExports[key] = value;
16217 });
16218 }
16219 else {
16220 // Export to the global object.
16221 root.platform = platform;
16222 }
16223}.call(this));
16224
16225}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
16226},{}],238:[function(require,module,exports){
16227(function (process){
16228'use strict';
16229
16230if (!process.version ||
16231 process.version.indexOf('v0.') === 0 ||
16232 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
16233 module.exports = { nextTick: nextTick };
16234} else {
16235 module.exports = process
16236}
16237
16238function nextTick(fn, arg1, arg2, arg3) {
16239 if (typeof fn !== 'function') {
16240 throw new TypeError('"callback" argument must be a function');
16241 }
16242 var len = arguments.length;
16243 var args, i;
16244 switch (len) {
16245 case 0:
16246 case 1:
16247 return process.nextTick(fn);
16248 case 2:
16249 return process.nextTick(function afterTickOne() {
16250 fn.call(null, arg1);
16251 });
16252 case 3:
16253 return process.nextTick(function afterTickTwo() {
16254 fn.call(null, arg1, arg2);
16255 });
16256 case 4:
16257 return process.nextTick(function afterTickThree() {
16258 fn.call(null, arg1, arg2, arg3);
16259 });
16260 default:
16261 args = new Array(len - 1);
16262 i = 0;
16263 while (i < args.length) {
16264 args[i++] = arguments[i];
16265 }
16266 return process.nextTick(function afterTick() {
16267 fn.apply(null, args);
16268 });
16269 }
16270}
16271
16272
16273}).call(this,require('_process'))
16274},{"_process":239}],239:[function(require,module,exports){
16275// shim for using process in browser
16276var process = module.exports = {};
16277
16278// cached from whatever global is present so that test runners that stub it
16279// don't break things. But we need to wrap it in a try catch in case it is
16280// wrapped in strict mode code which doesn't define any globals. It's inside a
16281// function because try/catches deoptimize in certain engines.
16282
16283var cachedSetTimeout;
16284var cachedClearTimeout;
16285
16286function defaultSetTimout() {
16287 throw new Error('setTimeout has not been defined');
16288}
16289function defaultClearTimeout () {
16290 throw new Error('clearTimeout has not been defined');
16291}
16292(function () {
16293 try {
16294 if (typeof setTimeout === 'function') {
16295 cachedSetTimeout = setTimeout;
16296 } else {
16297 cachedSetTimeout = defaultSetTimout;
16298 }
16299 } catch (e) {
16300 cachedSetTimeout = defaultSetTimout;
16301 }
16302 try {
16303 if (typeof clearTimeout === 'function') {
16304 cachedClearTimeout = clearTimeout;
16305 } else {
16306 cachedClearTimeout = defaultClearTimeout;
16307 }
16308 } catch (e) {
16309 cachedClearTimeout = defaultClearTimeout;
16310 }
16311} ())
16312function runTimeout(fun) {
16313 if (cachedSetTimeout === setTimeout) {
16314 //normal enviroments in sane situations
16315 return setTimeout(fun, 0);
16316 }
16317 // if setTimeout wasn't available but was latter defined
16318 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
16319 cachedSetTimeout = setTimeout;
16320 return setTimeout(fun, 0);
16321 }
16322 try {
16323 // when when somebody has screwed with setTimeout but no I.E. maddness
16324 return cachedSetTimeout(fun, 0);
16325 } catch(e){
16326 try {
16327 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
16328 return cachedSetTimeout.call(null, fun, 0);
16329 } catch(e){
16330 // 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
16331 return cachedSetTimeout.call(this, fun, 0);
16332 }
16333 }
16334
16335
16336}
16337function runClearTimeout(marker) {
16338 if (cachedClearTimeout === clearTimeout) {
16339 //normal enviroments in sane situations
16340 return clearTimeout(marker);
16341 }
16342 // if clearTimeout wasn't available but was latter defined
16343 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
16344 cachedClearTimeout = clearTimeout;
16345 return clearTimeout(marker);
16346 }
16347 try {
16348 // when when somebody has screwed with setTimeout but no I.E. maddness
16349 return cachedClearTimeout(marker);
16350 } catch (e){
16351 try {
16352 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
16353 return cachedClearTimeout.call(null, marker);
16354 } catch (e){
16355 // 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.
16356 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
16357 return cachedClearTimeout.call(this, marker);
16358 }
16359 }
16360
16361
16362
16363}
16364var queue = [];
16365var draining = false;
16366var currentQueue;
16367var queueIndex = -1;
16368
16369function cleanUpNextTick() {
16370 if (!draining || !currentQueue) {
16371 return;
16372 }
16373 draining = false;
16374 if (currentQueue.length) {
16375 queue = currentQueue.concat(queue);
16376 } else {
16377 queueIndex = -1;
16378 }
16379 if (queue.length) {
16380 drainQueue();
16381 }
16382}
16383
16384function drainQueue() {
16385 if (draining) {
16386 return;
16387 }
16388 var timeout = runTimeout(cleanUpNextTick);
16389 draining = true;
16390
16391 var len = queue.length;
16392 while(len) {
16393 currentQueue = queue;
16394 queue = [];
16395 while (++queueIndex < len) {
16396 if (currentQueue) {
16397 currentQueue[queueIndex].run();
16398 }
16399 }
16400 queueIndex = -1;
16401 len = queue.length;
16402 }
16403 currentQueue = null;
16404 draining = false;
16405 runClearTimeout(timeout);
16406}
16407
16408process.nextTick = function (fun) {
16409 var args = new Array(arguments.length - 1);
16410 if (arguments.length > 1) {
16411 for (var i = 1; i < arguments.length; i++) {
16412 args[i - 1] = arguments[i];
16413 }
16414 }
16415 queue.push(new Item(fun, args));
16416 if (queue.length === 1 && !draining) {
16417 runTimeout(drainQueue);
16418 }
16419};
16420
16421// v8 likes predictible objects
16422function Item(fun, array) {
16423 this.fun = fun;
16424 this.array = array;
16425}
16426Item.prototype.run = function () {
16427 this.fun.apply(null, this.array);
16428};
16429process.title = 'browser';
16430process.browser = true;
16431process.env = {};
16432process.argv = [];
16433process.version = ''; // empty string to avoid regexp issues
16434process.versions = {};
16435
16436function noop() {}
16437
16438process.on = noop;
16439process.addListener = noop;
16440process.once = noop;
16441process.off = noop;
16442process.removeListener = noop;
16443process.removeAllListeners = noop;
16444process.emit = noop;
16445process.prependListener = noop;
16446process.prependOnceListener = noop;
16447
16448process.listeners = function (name) { return [] }
16449
16450process.binding = function (name) {
16451 throw new Error('process.binding is not supported');
16452};
16453
16454process.cwd = function () { return '/' };
16455process.chdir = function (dir) {
16456 throw new Error('process.chdir is not supported');
16457};
16458process.umask = function() { return 0; };
16459
16460},{}],240:[function(require,module,exports){
16461(function (global){
16462/*! https://mths.be/punycode v1.4.1 by @mathias */
16463;(function(root) {
16464
16465 /** Detect free variables */
16466 var freeExports = typeof exports == 'object' && exports &&
16467 !exports.nodeType && exports;
16468 var freeModule = typeof module == 'object' && module &&
16469 !module.nodeType && module;
16470 var freeGlobal = typeof global == 'object' && global;
16471 if (
16472 freeGlobal.global === freeGlobal ||
16473 freeGlobal.window === freeGlobal ||
16474 freeGlobal.self === freeGlobal
16475 ) {
16476 root = freeGlobal;
16477 }
16478
16479 /**
16480 * The `punycode` object.
16481 * @name punycode
16482 * @type Object
16483 */
16484 var punycode,
16485
16486 /** Highest positive signed 32-bit float value */
16487 maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
16488
16489 /** Bootstring parameters */
16490 base = 36,
16491 tMin = 1,
16492 tMax = 26,
16493 skew = 38,
16494 damp = 700,
16495 initialBias = 72,
16496 initialN = 128, // 0x80
16497 delimiter = '-', // '\x2D'
16498
16499 /** Regular expressions */
16500 regexPunycode = /^xn--/,
16501 regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
16502 regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
16503
16504 /** Error messages */
16505 errors = {
16506 'overflow': 'Overflow: input needs wider integers to process',
16507 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
16508 'invalid-input': 'Invalid input'
16509 },
16510
16511 /** Convenience shortcuts */
16512 baseMinusTMin = base - tMin,
16513 floor = Math.floor,
16514 stringFromCharCode = String.fromCharCode,
16515
16516 /** Temporary variable */
16517 key;
16518
16519 /*--------------------------------------------------------------------------*/
16520
16521 /**
16522 * A generic error utility function.
16523 * @private
16524 * @param {String} type The error type.
16525 * @returns {Error} Throws a `RangeError` with the applicable error message.
16526 */
16527 function error(type) {
16528 throw new RangeError(errors[type]);
16529 }
16530
16531 /**
16532 * A generic `Array#map` utility function.
16533 * @private
16534 * @param {Array} array The array to iterate over.
16535 * @param {Function} callback The function that gets called for every array
16536 * item.
16537 * @returns {Array} A new array of values returned by the callback function.
16538 */
16539 function map(array, fn) {
16540 var length = array.length;
16541 var result = [];
16542 while (length--) {
16543 result[length] = fn(array[length]);
16544 }
16545 return result;
16546 }
16547
16548 /**
16549 * A simple `Array#map`-like wrapper to work with domain name strings or email
16550 * addresses.
16551 * @private
16552 * @param {String} domain The domain name or email address.
16553 * @param {Function} callback The function that gets called for every
16554 * character.
16555 * @returns {Array} A new string of characters returned by the callback
16556 * function.
16557 */
16558 function mapDomain(string, fn) {
16559 var parts = string.split('@');
16560 var result = '';
16561 if (parts.length > 1) {
16562 // In email addresses, only the domain name should be punycoded. Leave
16563 // the local part (i.e. everything up to `@`) intact.
16564 result = parts[0] + '@';
16565 string = parts[1];
16566 }
16567 // Avoid `split(regex)` for IE8 compatibility. See #17.
16568 string = string.replace(regexSeparators, '\x2E');
16569 var labels = string.split('.');
16570 var encoded = map(labels, fn).join('.');
16571 return result + encoded;
16572 }
16573
16574 /**
16575 * Creates an array containing the numeric code points of each Unicode
16576 * character in the string. While JavaScript uses UCS-2 internally,
16577 * this function will convert a pair of surrogate halves (each of which
16578 * UCS-2 exposes as separate characters) into a single code point,
16579 * matching UTF-16.
16580 * @see `punycode.ucs2.encode`
16581 * @see <https://mathiasbynens.be/notes/javascript-encoding>
16582 * @memberOf punycode.ucs2
16583 * @name decode
16584 * @param {String} string The Unicode input string (UCS-2).
16585 * @returns {Array} The new array of code points.
16586 */
16587 function ucs2decode(string) {
16588 var output = [],
16589 counter = 0,
16590 length = string.length,
16591 value,
16592 extra;
16593 while (counter < length) {
16594 value = string.charCodeAt(counter++);
16595 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
16596 // high surrogate, and there is a next character
16597 extra = string.charCodeAt(counter++);
16598 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
16599 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
16600 } else {
16601 // unmatched surrogate; only append this code unit, in case the next
16602 // code unit is the high surrogate of a surrogate pair
16603 output.push(value);
16604 counter--;
16605 }
16606 } else {
16607 output.push(value);
16608 }
16609 }
16610 return output;
16611 }
16612
16613 /**
16614 * Creates a string based on an array of numeric code points.
16615 * @see `punycode.ucs2.decode`
16616 * @memberOf punycode.ucs2
16617 * @name encode
16618 * @param {Array} codePoints The array of numeric code points.
16619 * @returns {String} The new Unicode string (UCS-2).
16620 */
16621 function ucs2encode(array) {
16622 return map(array, function(value) {
16623 var output = '';
16624 if (value > 0xFFFF) {
16625 value -= 0x10000;
16626 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
16627 value = 0xDC00 | value & 0x3FF;
16628 }
16629 output += stringFromCharCode(value);
16630 return output;
16631 }).join('');
16632 }
16633
16634 /**
16635 * Converts a basic code point into a digit/integer.
16636 * @see `digitToBasic()`
16637 * @private
16638 * @param {Number} codePoint The basic numeric code point value.
16639 * @returns {Number} The numeric value of a basic code point (for use in
16640 * representing integers) in the range `0` to `base - 1`, or `base` if
16641 * the code point does not represent a value.
16642 */
16643 function basicToDigit(codePoint) {
16644 if (codePoint - 48 < 10) {
16645 return codePoint - 22;
16646 }
16647 if (codePoint - 65 < 26) {
16648 return codePoint - 65;
16649 }
16650 if (codePoint - 97 < 26) {
16651 return codePoint - 97;
16652 }
16653 return base;
16654 }
16655
16656 /**
16657 * Converts a digit/integer into a basic code point.
16658 * @see `basicToDigit()`
16659 * @private
16660 * @param {Number} digit The numeric value of a basic code point.
16661 * @returns {Number} The basic code point whose value (when used for
16662 * representing integers) is `digit`, which needs to be in the range
16663 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
16664 * used; else, the lowercase form is used. The behavior is undefined
16665 * if `flag` is non-zero and `digit` has no uppercase form.
16666 */
16667 function digitToBasic(digit, flag) {
16668 // 0..25 map to ASCII a..z or A..Z
16669 // 26..35 map to ASCII 0..9
16670 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
16671 }
16672
16673 /**
16674 * Bias adaptation function as per section 3.4 of RFC 3492.
16675 * https://tools.ietf.org/html/rfc3492#section-3.4
16676 * @private
16677 */
16678 function adapt(delta, numPoints, firstTime) {
16679 var k = 0;
16680 delta = firstTime ? floor(delta / damp) : delta >> 1;
16681 delta += floor(delta / numPoints);
16682 for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
16683 delta = floor(delta / baseMinusTMin);
16684 }
16685 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
16686 }
16687
16688 /**
16689 * Converts a Punycode string of ASCII-only symbols to a string of Unicode
16690 * symbols.
16691 * @memberOf punycode
16692 * @param {String} input The Punycode string of ASCII-only symbols.
16693 * @returns {String} The resulting string of Unicode symbols.
16694 */
16695 function decode(input) {
16696 // Don't use UCS-2
16697 var output = [],
16698 inputLength = input.length,
16699 out,
16700 i = 0,
16701 n = initialN,
16702 bias = initialBias,
16703 basic,
16704 j,
16705 index,
16706 oldi,
16707 w,
16708 k,
16709 digit,
16710 t,
16711 /** Cached calculation results */
16712 baseMinusT;
16713
16714 // Handle the basic code points: let `basic` be the number of input code
16715 // points before the last delimiter, or `0` if there is none, then copy
16716 // the first basic code points to the output.
16717
16718 basic = input.lastIndexOf(delimiter);
16719 if (basic < 0) {
16720 basic = 0;
16721 }
16722
16723 for (j = 0; j < basic; ++j) {
16724 // if it's not a basic code point
16725 if (input.charCodeAt(j) >= 0x80) {
16726 error('not-basic');
16727 }
16728 output.push(input.charCodeAt(j));
16729 }
16730
16731 // Main decoding loop: start just after the last delimiter if any basic code
16732 // points were copied; start at the beginning otherwise.
16733
16734 for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
16735
16736 // `index` is the index of the next character to be consumed.
16737 // Decode a generalized variable-length integer into `delta`,
16738 // which gets added to `i`. The overflow checking is easier
16739 // if we increase `i` as we go, then subtract off its starting
16740 // value at the end to obtain `delta`.
16741 for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
16742
16743 if (index >= inputLength) {
16744 error('invalid-input');
16745 }
16746
16747 digit = basicToDigit(input.charCodeAt(index++));
16748
16749 if (digit >= base || digit > floor((maxInt - i) / w)) {
16750 error('overflow');
16751 }
16752
16753 i += digit * w;
16754 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
16755
16756 if (digit < t) {
16757 break;
16758 }
16759
16760 baseMinusT = base - t;
16761 if (w > floor(maxInt / baseMinusT)) {
16762 error('overflow');
16763 }
16764
16765 w *= baseMinusT;
16766
16767 }
16768
16769 out = output.length + 1;
16770 bias = adapt(i - oldi, out, oldi == 0);
16771
16772 // `i` was supposed to wrap around from `out` to `0`,
16773 // incrementing `n` each time, so we'll fix that now:
16774 if (floor(i / out) > maxInt - n) {
16775 error('overflow');
16776 }
16777
16778 n += floor(i / out);
16779 i %= out;
16780
16781 // Insert `n` at position `i` of the output
16782 output.splice(i++, 0, n);
16783
16784 }
16785
16786 return ucs2encode(output);
16787 }
16788
16789 /**
16790 * Converts a string of Unicode symbols (e.g. a domain name label) to a
16791 * Punycode string of ASCII-only symbols.
16792 * @memberOf punycode
16793 * @param {String} input The string of Unicode symbols.
16794 * @returns {String} The resulting Punycode string of ASCII-only symbols.
16795 */
16796 function encode(input) {
16797 var n,
16798 delta,
16799 handledCPCount,
16800 basicLength,
16801 bias,
16802 j,
16803 m,
16804 q,
16805 k,
16806 t,
16807 currentValue,
16808 output = [],
16809 /** `inputLength` will hold the number of code points in `input`. */
16810 inputLength,
16811 /** Cached calculation results */
16812 handledCPCountPlusOne,
16813 baseMinusT,
16814 qMinusT;
16815
16816 // Convert the input in UCS-2 to Unicode
16817 input = ucs2decode(input);
16818
16819 // Cache the length
16820 inputLength = input.length;
16821
16822 // Initialize the state
16823 n = initialN;
16824 delta = 0;
16825 bias = initialBias;
16826
16827 // Handle the basic code points
16828 for (j = 0; j < inputLength; ++j) {
16829 currentValue = input[j];
16830 if (currentValue < 0x80) {
16831 output.push(stringFromCharCode(currentValue));
16832 }
16833 }
16834
16835 handledCPCount = basicLength = output.length;
16836
16837 // `handledCPCount` is the number of code points that have been handled;
16838 // `basicLength` is the number of basic code points.
16839
16840 // Finish the basic string - if it is not empty - with a delimiter
16841 if (basicLength) {
16842 output.push(delimiter);
16843 }
16844
16845 // Main encoding loop:
16846 while (handledCPCount < inputLength) {
16847
16848 // All non-basic code points < n have been handled already. Find the next
16849 // larger one:
16850 for (m = maxInt, j = 0; j < inputLength; ++j) {
16851 currentValue = input[j];
16852 if (currentValue >= n && currentValue < m) {
16853 m = currentValue;
16854 }
16855 }
16856
16857 // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
16858 // but guard against overflow
16859 handledCPCountPlusOne = handledCPCount + 1;
16860 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
16861 error('overflow');
16862 }
16863
16864 delta += (m - n) * handledCPCountPlusOne;
16865 n = m;
16866
16867 for (j = 0; j < inputLength; ++j) {
16868 currentValue = input[j];
16869
16870 if (currentValue < n && ++delta > maxInt) {
16871 error('overflow');
16872 }
16873
16874 if (currentValue == n) {
16875 // Represent delta as a generalized variable-length integer
16876 for (q = delta, k = base; /* no condition */; k += base) {
16877 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
16878 if (q < t) {
16879 break;
16880 }
16881 qMinusT = q - t;
16882 baseMinusT = base - t;
16883 output.push(
16884 stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
16885 );
16886 q = floor(qMinusT / baseMinusT);
16887 }
16888
16889 output.push(stringFromCharCode(digitToBasic(q, 0)));
16890 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
16891 delta = 0;
16892 ++handledCPCount;
16893 }
16894 }
16895
16896 ++delta;
16897 ++n;
16898
16899 }
16900 return output.join('');
16901 }
16902
16903 /**
16904 * Converts a Punycode string representing a domain name or an email address
16905 * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
16906 * it doesn't matter if you call it on a string that has already been
16907 * converted to Unicode.
16908 * @memberOf punycode
16909 * @param {String} input The Punycoded domain name or email address to
16910 * convert to Unicode.
16911 * @returns {String} The Unicode representation of the given Punycode
16912 * string.
16913 */
16914 function toUnicode(input) {
16915 return mapDomain(input, function(string) {
16916 return regexPunycode.test(string)
16917 ? decode(string.slice(4).toLowerCase())
16918 : string;
16919 });
16920 }
16921
16922 /**
16923 * Converts a Unicode string representing a domain name or an email address to
16924 * Punycode. Only the non-ASCII parts of the domain name will be converted,
16925 * i.e. it doesn't matter if you call it with a domain that's already in
16926 * ASCII.
16927 * @memberOf punycode
16928 * @param {String} input The domain name or email address to convert, as a
16929 * Unicode string.
16930 * @returns {String} The Punycode representation of the given domain name or
16931 * email address.
16932 */
16933 function toASCII(input) {
16934 return mapDomain(input, function(string) {
16935 return regexNonASCII.test(string)
16936 ? 'xn--' + encode(string)
16937 : string;
16938 });
16939 }
16940
16941 /*--------------------------------------------------------------------------*/
16942
16943 /** Define the public API */
16944 punycode = {
16945 /**
16946 * A string representing the current Punycode.js version number.
16947 * @memberOf punycode
16948 * @type String
16949 */
16950 'version': '1.4.1',
16951 /**
16952 * An object of methods to convert from JavaScript's internal character
16953 * representation (UCS-2) to Unicode code points, and back.
16954 * @see <https://mathiasbynens.be/notes/javascript-encoding>
16955 * @memberOf punycode
16956 * @type Object
16957 */
16958 'ucs2': {
16959 'decode': ucs2decode,
16960 'encode': ucs2encode
16961 },
16962 'decode': decode,
16963 'encode': encode,
16964 'toASCII': toASCII,
16965 'toUnicode': toUnicode
16966 };
16967
16968 /** Expose `punycode` */
16969 // Some AMD build optimizers, like r.js, check for specific condition patterns
16970 // like the following:
16971 if (
16972 typeof define == 'function' &&
16973 typeof define.amd == 'object' &&
16974 define.amd
16975 ) {
16976 define('punycode', function() {
16977 return punycode;
16978 });
16979 } else if (freeExports && freeModule) {
16980 if (module.exports == freeExports) {
16981 // in Node.js, io.js, or RingoJS v0.8.0+
16982 freeModule.exports = punycode;
16983 } else {
16984 // in Narwhal or RingoJS v0.7.0-
16985 for (key in punycode) {
16986 punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
16987 }
16988 }
16989 } else {
16990 // in Rhino or a web browser
16991 root.punycode = punycode;
16992 }
16993
16994}(this));
16995
16996}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
16997},{}],241:[function(require,module,exports){
16998// Copyright Joyent, Inc. and other Node contributors.
16999//
17000// Permission is hereby granted, free of charge, to any person obtaining a
17001// copy of this software and associated documentation files (the
17002// "Software"), to deal in the Software without restriction, including
17003// without limitation the rights to use, copy, modify, merge, publish,
17004// distribute, sublicense, and/or sell copies of the Software, and to permit
17005// persons to whom the Software is furnished to do so, subject to the
17006// following conditions:
17007//
17008// The above copyright notice and this permission notice shall be included
17009// in all copies or substantial portions of the Software.
17010//
17011// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17012// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17013// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17014// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17015// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17016// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17017// USE OR OTHER DEALINGS IN THE SOFTWARE.
17018
17019'use strict';
17020
17021// If obj.hasOwnProperty has been overridden, then calling
17022// obj.hasOwnProperty(prop) will break.
17023// See: https://github.com/joyent/node/issues/1707
17024function hasOwnProperty(obj, prop) {
17025 return Object.prototype.hasOwnProperty.call(obj, prop);
17026}
17027
17028module.exports = function(qs, sep, eq, options) {
17029 sep = sep || '&';
17030 eq = eq || '=';
17031 var obj = {};
17032
17033 if (typeof qs !== 'string' || qs.length === 0) {
17034 return obj;
17035 }
17036
17037 var regexp = /\+/g;
17038 qs = qs.split(sep);
17039
17040 var maxKeys = 1000;
17041 if (options && typeof options.maxKeys === 'number') {
17042 maxKeys = options.maxKeys;
17043 }
17044
17045 var len = qs.length;
17046 // maxKeys <= 0 means that we should not limit keys count
17047 if (maxKeys > 0 && len > maxKeys) {
17048 len = maxKeys;
17049 }
17050
17051 for (var i = 0; i < len; ++i) {
17052 var x = qs[i].replace(regexp, '%20'),
17053 idx = x.indexOf(eq),
17054 kstr, vstr, k, v;
17055
17056 if (idx >= 0) {
17057 kstr = x.substr(0, idx);
17058 vstr = x.substr(idx + 1);
17059 } else {
17060 kstr = x;
17061 vstr = '';
17062 }
17063
17064 k = decodeURIComponent(kstr);
17065 v = decodeURIComponent(vstr);
17066
17067 if (!hasOwnProperty(obj, k)) {
17068 obj[k] = v;
17069 } else if (isArray(obj[k])) {
17070 obj[k].push(v);
17071 } else {
17072 obj[k] = [obj[k], v];
17073 }
17074 }
17075
17076 return obj;
17077};
17078
17079var isArray = Array.isArray || function (xs) {
17080 return Object.prototype.toString.call(xs) === '[object Array]';
17081};
17082
17083},{}],242:[function(require,module,exports){
17084// Copyright Joyent, Inc. and other Node contributors.
17085//
17086// Permission is hereby granted, free of charge, to any person obtaining a
17087// copy of this software and associated documentation files (the
17088// "Software"), to deal in the Software without restriction, including
17089// without limitation the rights to use, copy, modify, merge, publish,
17090// distribute, sublicense, and/or sell copies of the Software, and to permit
17091// persons to whom the Software is furnished to do so, subject to the
17092// following conditions:
17093//
17094// The above copyright notice and this permission notice shall be included
17095// in all copies or substantial portions of the Software.
17096//
17097// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17098// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17099// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17100// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17101// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17102// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17103// USE OR OTHER DEALINGS IN THE SOFTWARE.
17104
17105'use strict';
17106
17107var stringifyPrimitive = function(v) {
17108 switch (typeof v) {
17109 case 'string':
17110 return v;
17111
17112 case 'boolean':
17113 return v ? 'true' : 'false';
17114
17115 case 'number':
17116 return isFinite(v) ? v : '';
17117
17118 default:
17119 return '';
17120 }
17121};
17122
17123module.exports = function(obj, sep, eq, name) {
17124 sep = sep || '&';
17125 eq = eq || '=';
17126 if (obj === null) {
17127 obj = undefined;
17128 }
17129
17130 if (typeof obj === 'object') {
17131 return map(objectKeys(obj), function(k) {
17132 var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
17133 if (isArray(obj[k])) {
17134 return map(obj[k], function(v) {
17135 return ks + encodeURIComponent(stringifyPrimitive(v));
17136 }).join(sep);
17137 } else {
17138 return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
17139 }
17140 }).join(sep);
17141
17142 }
17143
17144 if (!name) return '';
17145 return encodeURIComponent(stringifyPrimitive(name)) + eq +
17146 encodeURIComponent(stringifyPrimitive(obj));
17147};
17148
17149var isArray = Array.isArray || function (xs) {
17150 return Object.prototype.toString.call(xs) === '[object Array]';
17151};
17152
17153function map (xs, f) {
17154 if (xs.map) return xs.map(f);
17155 var res = [];
17156 for (var i = 0; i < xs.length; i++) {
17157 res.push(f(xs[i], i));
17158 }
17159 return res;
17160}
17161
17162var objectKeys = Object.keys || function (obj) {
17163 var res = [];
17164 for (var key in obj) {
17165 if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
17166 }
17167 return res;
17168};
17169
17170},{}],243:[function(require,module,exports){
17171'use strict';
17172
17173exports.decode = exports.parse = require('./decode');
17174exports.encode = exports.stringify = require('./encode');
17175
17176},{"./decode":241,"./encode":242}],244:[function(require,module,exports){
17177module.exports = require('./lib/_stream_duplex.js');
17178
17179},{"./lib/_stream_duplex.js":245}],245:[function(require,module,exports){
17180// Copyright Joyent, Inc. and other Node contributors.
17181//
17182// Permission is hereby granted, free of charge, to any person obtaining a
17183// copy of this software and associated documentation files (the
17184// "Software"), to deal in the Software without restriction, including
17185// without limitation the rights to use, copy, modify, merge, publish,
17186// distribute, sublicense, and/or sell copies of the Software, and to permit
17187// persons to whom the Software is furnished to do so, subject to the
17188// following conditions:
17189//
17190// The above copyright notice and this permission notice shall be included
17191// in all copies or substantial portions of the Software.
17192//
17193// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17194// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17195// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17196// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17197// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17198// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17199// USE OR OTHER DEALINGS IN THE SOFTWARE.
17200
17201// a duplex stream is just a stream that is both readable and writable.
17202// Since JS doesn't have multiple prototypal inheritance, this class
17203// prototypally inherits from Readable, and then parasitically from
17204// Writable.
17205
17206'use strict';
17207
17208/*<replacement>*/
17209
17210var _keys = require('babel-runtime/core-js/object/keys');
17211
17212var _keys2 = _interopRequireDefault(_keys);
17213
17214function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17215
17216var pna = require('process-nextick-args');
17217/*</replacement>*/
17218
17219/*<replacement>*/
17220var objectKeys = _keys2.default || function (obj) {
17221 var keys = [];
17222 for (var key in obj) {
17223 keys.push(key);
17224 }return keys;
17225};
17226/*</replacement>*/
17227
17228module.exports = Duplex;
17229
17230/*<replacement>*/
17231var util = require('core-util-is');
17232util.inherits = require('inherits');
17233/*</replacement>*/
17234
17235var Readable = require('./_stream_readable');
17236var Writable = require('./_stream_writable');
17237
17238util.inherits(Duplex, Readable);
17239
17240{
17241 // avoid scope creep, the keys array can then be collected
17242 var keys = objectKeys(Writable.prototype);
17243 for (var v = 0; v < keys.length; v++) {
17244 var method = keys[v];
17245 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
17246 }
17247}
17248
17249function Duplex(options) {
17250 if (!(this instanceof Duplex)) return new Duplex(options);
17251
17252 Readable.call(this, options);
17253 Writable.call(this, options);
17254
17255 if (options && options.readable === false) this.readable = false;
17256
17257 if (options && options.writable === false) this.writable = false;
17258
17259 this.allowHalfOpen = true;
17260 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
17261
17262 this.once('end', onend);
17263}
17264
17265Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
17266 // making it explicit this property is not enumerable
17267 // because otherwise some prototype manipulation in
17268 // userland will fail
17269 enumerable: false,
17270 get: function get() {
17271 return this._writableState.highWaterMark;
17272 }
17273});
17274
17275// the no-half-open enforcer
17276function onend() {
17277 // if we allow half-open state, or if the writable side ended,
17278 // then we're ok.
17279 if (this.allowHalfOpen || this._writableState.ended) return;
17280
17281 // no more data can be written.
17282 // But allow more writes to happen in this tick.
17283 pna.nextTick(onEndNT, this);
17284}
17285
17286function onEndNT(self) {
17287 self.end();
17288}
17289
17290Object.defineProperty(Duplex.prototype, 'destroyed', {
17291 get: function get() {
17292 if (this._readableState === undefined || this._writableState === undefined) {
17293 return false;
17294 }
17295 return this._readableState.destroyed && this._writableState.destroyed;
17296 },
17297 set: function set(value) {
17298 // we ignore the value if the stream
17299 // has not been initialized yet
17300 if (this._readableState === undefined || this._writableState === undefined) {
17301 return;
17302 }
17303
17304 // backward compatibility, the user is explicitly
17305 // managing destroyed
17306 this._readableState.destroyed = value;
17307 this._writableState.destroyed = value;
17308 }
17309});
17310
17311Duplex.prototype._destroy = function (err, cb) {
17312 this.push(null);
17313 this.end();
17314
17315 pna.nextTick(cb, err);
17316};
17317
17318},{"./_stream_readable":247,"./_stream_writable":249,"babel-runtime/core-js/object/keys":45,"core-util-is":176,"inherits":216,"process-nextick-args":238}],246:[function(require,module,exports){
17319// Copyright Joyent, Inc. and other Node contributors.
17320//
17321// Permission is hereby granted, free of charge, to any person obtaining a
17322// copy of this software and associated documentation files (the
17323// "Software"), to deal in the Software without restriction, including
17324// without limitation the rights to use, copy, modify, merge, publish,
17325// distribute, sublicense, and/or sell copies of the Software, and to permit
17326// persons to whom the Software is furnished to do so, subject to the
17327// following conditions:
17328//
17329// The above copyright notice and this permission notice shall be included
17330// in all copies or substantial portions of the Software.
17331//
17332// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17333// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17334// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17335// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17336// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17337// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17338// USE OR OTHER DEALINGS IN THE SOFTWARE.
17339
17340// a passthrough stream.
17341// basically just the most minimal sort of Transform stream.
17342// Every written chunk gets output as-is.
17343
17344'use strict';
17345
17346module.exports = PassThrough;
17347
17348var Transform = require('./_stream_transform');
17349
17350/*<replacement>*/
17351var util = require('core-util-is');
17352util.inherits = require('inherits');
17353/*</replacement>*/
17354
17355util.inherits(PassThrough, Transform);
17356
17357function PassThrough(options) {
17358 if (!(this instanceof PassThrough)) return new PassThrough(options);
17359
17360 Transform.call(this, options);
17361}
17362
17363PassThrough.prototype._transform = function (chunk, encoding, cb) {
17364 cb(null, chunk);
17365};
17366
17367},{"./_stream_transform":248,"core-util-is":176,"inherits":216}],247:[function(require,module,exports){
17368(function (process,global){
17369// Copyright Joyent, Inc. and other Node contributors.
17370//
17371// Permission is hereby granted, free of charge, to any person obtaining a
17372// copy of this software and associated documentation files (the
17373// "Software"), to deal in the Software without restriction, including
17374// without limitation the rights to use, copy, modify, merge, publish,
17375// distribute, sublicense, and/or sell copies of the Software, and to permit
17376// persons to whom the Software is furnished to do so, subject to the
17377// following conditions:
17378//
17379// The above copyright notice and this permission notice shall be included
17380// in all copies or substantial portions of the Software.
17381//
17382// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17383// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17384// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17385// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17386// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17387// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17388// USE OR OTHER DEALINGS IN THE SOFTWARE.
17389
17390'use strict';
17391
17392/*<replacement>*/
17393
17394var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
17395
17396var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
17397
17398function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17399
17400var pna = require('process-nextick-args');
17401/*</replacement>*/
17402
17403module.exports = Readable;
17404
17405/*<replacement>*/
17406var isArray = require('isarray');
17407/*</replacement>*/
17408
17409/*<replacement>*/
17410var Duplex;
17411/*</replacement>*/
17412
17413Readable.ReadableState = ReadableState;
17414
17415/*<replacement>*/
17416var EE = require('events').EventEmitter;
17417
17418var EElistenerCount = function EElistenerCount(emitter, type) {
17419 return emitter.listeners(type).length;
17420};
17421/*</replacement>*/
17422
17423/*<replacement>*/
17424var Stream = require('./internal/streams/stream');
17425/*</replacement>*/
17426
17427/*<replacement>*/
17428
17429var Buffer = require('safe-buffer').Buffer;
17430var OurUint8Array = global.Uint8Array || function () {};
17431function _uint8ArrayToBuffer(chunk) {
17432 return Buffer.from(chunk);
17433}
17434function _isUint8Array(obj) {
17435 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
17436}
17437
17438/*</replacement>*/
17439
17440/*<replacement>*/
17441var util = require('core-util-is');
17442util.inherits = require('inherits');
17443/*</replacement>*/
17444
17445/*<replacement>*/
17446var debugUtil = require('util');
17447var debug = void 0;
17448if (debugUtil && debugUtil.debuglog) {
17449 debug = debugUtil.debuglog('stream');
17450} else {
17451 debug = function debug() {};
17452}
17453/*</replacement>*/
17454
17455var BufferList = require('./internal/streams/BufferList');
17456var destroyImpl = require('./internal/streams/destroy');
17457var StringDecoder;
17458
17459util.inherits(Readable, Stream);
17460
17461var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
17462
17463function prependListener(emitter, event, fn) {
17464 // Sadly this is not cacheable as some libraries bundle their own
17465 // event emitter implementation with them.
17466 if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
17467
17468 // This is a hack to make sure that our error handler is attached before any
17469 // userland ones. NEVER DO THIS. This is here only because this code needs
17470 // to continue to work with older versions of Node.js that do not include
17471 // the prependListener() method. The goal is to eventually remove this hack.
17472 if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
17473}
17474
17475function ReadableState(options, stream) {
17476 Duplex = Duplex || require('./_stream_duplex');
17477
17478 options = options || {};
17479
17480 // Duplex streams are both readable and writable, but share
17481 // the same options object.
17482 // However, some cases require setting options to different
17483 // values for the readable and the writable sides of the duplex stream.
17484 // These options can be provided separately as readableXXX and writableXXX.
17485 var isDuplex = stream instanceof Duplex;
17486
17487 // object stream flag. Used to make read(n) ignore n and to
17488 // make all the buffer merging and length checks go away
17489 this.objectMode = !!options.objectMode;
17490
17491 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
17492
17493 // the point at which it stops calling _read() to fill the buffer
17494 // Note: 0 is a valid value, means "don't call _read preemptively ever"
17495 var hwm = options.highWaterMark;
17496 var readableHwm = options.readableHighWaterMark;
17497 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
17498
17499 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
17500
17501 // cast to ints.
17502 this.highWaterMark = Math.floor(this.highWaterMark);
17503
17504 // A linked list is used to store data chunks instead of an array because the
17505 // linked list can remove elements from the beginning faster than
17506 // array.shift()
17507 this.buffer = new BufferList();
17508 this.length = 0;
17509 this.pipes = null;
17510 this.pipesCount = 0;
17511 this.flowing = null;
17512 this.ended = false;
17513 this.endEmitted = false;
17514 this.reading = false;
17515
17516 // a flag to be able to tell if the event 'readable'/'data' is emitted
17517 // immediately, or on a later tick. We set this to true at first, because
17518 // any actions that shouldn't happen until "later" should generally also
17519 // not happen before the first read call.
17520 this.sync = true;
17521
17522 // whenever we return null, then we set a flag to say
17523 // that we're awaiting a 'readable' event emission.
17524 this.needReadable = false;
17525 this.emittedReadable = false;
17526 this.readableListening = false;
17527 this.resumeScheduled = false;
17528
17529 // has it been destroyed
17530 this.destroyed = false;
17531
17532 // Crypto is kind of old and crusty. Historically, its default string
17533 // encoding is 'binary' so we have to make this configurable.
17534 // Everything else in the universe uses 'utf8', though.
17535 this.defaultEncoding = options.defaultEncoding || 'utf8';
17536
17537 // the number of writers that are awaiting a drain event in .pipe()s
17538 this.awaitDrain = 0;
17539
17540 // if true, a maybeReadMore has been scheduled
17541 this.readingMore = false;
17542
17543 this.decoder = null;
17544 this.encoding = null;
17545 if (options.encoding) {
17546 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
17547 this.decoder = new StringDecoder(options.encoding);
17548 this.encoding = options.encoding;
17549 }
17550}
17551
17552function Readable(options) {
17553 Duplex = Duplex || require('./_stream_duplex');
17554
17555 if (!(this instanceof Readable)) return new Readable(options);
17556
17557 this._readableState = new ReadableState(options, this);
17558
17559 // legacy
17560 this.readable = true;
17561
17562 if (options) {
17563 if (typeof options.read === 'function') this._read = options.read;
17564
17565 if (typeof options.destroy === 'function') this._destroy = options.destroy;
17566 }
17567
17568 Stream.call(this);
17569}
17570
17571Object.defineProperty(Readable.prototype, 'destroyed', {
17572 get: function get() {
17573 if (this._readableState === undefined) {
17574 return false;
17575 }
17576 return this._readableState.destroyed;
17577 },
17578 set: function set(value) {
17579 // we ignore the value if the stream
17580 // has not been initialized yet
17581 if (!this._readableState) {
17582 return;
17583 }
17584
17585 // backward compatibility, the user is explicitly
17586 // managing destroyed
17587 this._readableState.destroyed = value;
17588 }
17589});
17590
17591Readable.prototype.destroy = destroyImpl.destroy;
17592Readable.prototype._undestroy = destroyImpl.undestroy;
17593Readable.prototype._destroy = function (err, cb) {
17594 this.push(null);
17595 cb(err);
17596};
17597
17598// Manually shove something into the read() buffer.
17599// This returns true if the highWaterMark has not been hit yet,
17600// similar to how Writable.write() returns true if you should
17601// write() some more.
17602Readable.prototype.push = function (chunk, encoding) {
17603 var state = this._readableState;
17604 var skipChunkCheck;
17605
17606 if (!state.objectMode) {
17607 if (typeof chunk === 'string') {
17608 encoding = encoding || state.defaultEncoding;
17609 if (encoding !== state.encoding) {
17610 chunk = Buffer.from(chunk, encoding);
17611 encoding = '';
17612 }
17613 skipChunkCheck = true;
17614 }
17615 } else {
17616 skipChunkCheck = true;
17617 }
17618
17619 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
17620};
17621
17622// Unshift should *always* be something directly out of read()
17623Readable.prototype.unshift = function (chunk) {
17624 return readableAddChunk(this, chunk, null, true, false);
17625};
17626
17627function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
17628 var state = stream._readableState;
17629 if (chunk === null) {
17630 state.reading = false;
17631 onEofChunk(stream, state);
17632 } else {
17633 var er;
17634 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
17635 if (er) {
17636 stream.emit('error', er);
17637 } else if (state.objectMode || chunk && chunk.length > 0) {
17638 if (typeof chunk !== 'string' && !state.objectMode && (0, _getPrototypeOf2.default)(chunk) !== Buffer.prototype) {
17639 chunk = _uint8ArrayToBuffer(chunk);
17640 }
17641
17642 if (addToFront) {
17643 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
17644 } else if (state.ended) {
17645 stream.emit('error', new Error('stream.push() after EOF'));
17646 } else {
17647 state.reading = false;
17648 if (state.decoder && !encoding) {
17649 chunk = state.decoder.write(chunk);
17650 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
17651 } else {
17652 addChunk(stream, state, chunk, false);
17653 }
17654 }
17655 } else if (!addToFront) {
17656 state.reading = false;
17657 }
17658 }
17659
17660 return needMoreData(state);
17661}
17662
17663function addChunk(stream, state, chunk, addToFront) {
17664 if (state.flowing && state.length === 0 && !state.sync) {
17665 stream.emit('data', chunk);
17666 stream.read(0);
17667 } else {
17668 // update the buffer info.
17669 state.length += state.objectMode ? 1 : chunk.length;
17670 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
17671
17672 if (state.needReadable) emitReadable(stream);
17673 }
17674 maybeReadMore(stream, state);
17675}
17676
17677function chunkInvalid(state, chunk) {
17678 var er;
17679 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
17680 er = new TypeError('Invalid non-string/buffer chunk');
17681 }
17682 return er;
17683}
17684
17685// if it's past the high water mark, we can push in some more.
17686// Also, if we have no data yet, we can stand some
17687// more bytes. This is to work around cases where hwm=0,
17688// such as the repl. Also, if the push() triggered a
17689// readable event, and the user called read(largeNumber) such that
17690// needReadable was set, then we ought to push more, so that another
17691// 'readable' event will be triggered.
17692function needMoreData(state) {
17693 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
17694}
17695
17696Readable.prototype.isPaused = function () {
17697 return this._readableState.flowing === false;
17698};
17699
17700// backwards compatibility.
17701Readable.prototype.setEncoding = function (enc) {
17702 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
17703 this._readableState.decoder = new StringDecoder(enc);
17704 this._readableState.encoding = enc;
17705 return this;
17706};
17707
17708// Don't raise the hwm > 8MB
17709var MAX_HWM = 0x800000;
17710function computeNewHighWaterMark(n) {
17711 if (n >= MAX_HWM) {
17712 n = MAX_HWM;
17713 } else {
17714 // Get the next highest power of 2 to prevent increasing hwm excessively in
17715 // tiny amounts
17716 n--;
17717 n |= n >>> 1;
17718 n |= n >>> 2;
17719 n |= n >>> 4;
17720 n |= n >>> 8;
17721 n |= n >>> 16;
17722 n++;
17723 }
17724 return n;
17725}
17726
17727// This function is designed to be inlinable, so please take care when making
17728// changes to the function body.
17729function howMuchToRead(n, state) {
17730 if (n <= 0 || state.length === 0 && state.ended) return 0;
17731 if (state.objectMode) return 1;
17732 if (n !== n) {
17733 // Only flow one buffer at a time
17734 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
17735 }
17736 // If we're asking for more than the current hwm, then raise the hwm.
17737 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
17738 if (n <= state.length) return n;
17739 // Don't have enough
17740 if (!state.ended) {
17741 state.needReadable = true;
17742 return 0;
17743 }
17744 return state.length;
17745}
17746
17747// you can override either this method, or the async _read(n) below.
17748Readable.prototype.read = function (n) {
17749 debug('read', n);
17750 n = parseInt(n, 10);
17751 var state = this._readableState;
17752 var nOrig = n;
17753
17754 if (n !== 0) state.emittedReadable = false;
17755
17756 // if we're doing read(0) to trigger a readable event, but we
17757 // already have a bunch of data in the buffer, then just trigger
17758 // the 'readable' event and move on.
17759 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
17760 debug('read: emitReadable', state.length, state.ended);
17761 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
17762 return null;
17763 }
17764
17765 n = howMuchToRead(n, state);
17766
17767 // if we've ended, and we're now clear, then finish it up.
17768 if (n === 0 && state.ended) {
17769 if (state.length === 0) endReadable(this);
17770 return null;
17771 }
17772
17773 // All the actual chunk generation logic needs to be
17774 // *below* the call to _read. The reason is that in certain
17775 // synthetic stream cases, such as passthrough streams, _read
17776 // may be a completely synchronous operation which may change
17777 // the state of the read buffer, providing enough data when
17778 // before there was *not* enough.
17779 //
17780 // So, the steps are:
17781 // 1. Figure out what the state of things will be after we do
17782 // a read from the buffer.
17783 //
17784 // 2. If that resulting state will trigger a _read, then call _read.
17785 // Note that this may be asynchronous, or synchronous. Yes, it is
17786 // deeply ugly to write APIs this way, but that still doesn't mean
17787 // that the Readable class should behave improperly, as streams are
17788 // designed to be sync/async agnostic.
17789 // Take note if the _read call is sync or async (ie, if the read call
17790 // has returned yet), so that we know whether or not it's safe to emit
17791 // 'readable' etc.
17792 //
17793 // 3. Actually pull the requested chunks out of the buffer and return.
17794
17795 // if we need a readable event, then we need to do some reading.
17796 var doRead = state.needReadable;
17797 debug('need readable', doRead);
17798
17799 // if we currently have less than the highWaterMark, then also read some
17800 if (state.length === 0 || state.length - n < state.highWaterMark) {
17801 doRead = true;
17802 debug('length less than watermark', doRead);
17803 }
17804
17805 // however, if we've ended, then there's no point, and if we're already
17806 // reading, then it's unnecessary.
17807 if (state.ended || state.reading) {
17808 doRead = false;
17809 debug('reading or ended', doRead);
17810 } else if (doRead) {
17811 debug('do read');
17812 state.reading = true;
17813 state.sync = true;
17814 // if the length is currently zero, then we *need* a readable event.
17815 if (state.length === 0) state.needReadable = true;
17816 // call internal read method
17817 this._read(state.highWaterMark);
17818 state.sync = false;
17819 // If _read pushed data synchronously, then `reading` will be false,
17820 // and we need to re-evaluate how much data we can return to the user.
17821 if (!state.reading) n = howMuchToRead(nOrig, state);
17822 }
17823
17824 var ret;
17825 if (n > 0) ret = fromList(n, state);else ret = null;
17826
17827 if (ret === null) {
17828 state.needReadable = true;
17829 n = 0;
17830 } else {
17831 state.length -= n;
17832 }
17833
17834 if (state.length === 0) {
17835 // If we have nothing in the buffer, then we want to know
17836 // as soon as we *do* get something into the buffer.
17837 if (!state.ended) state.needReadable = true;
17838
17839 // If we tried to read() past the EOF, then emit end on the next tick.
17840 if (nOrig !== n && state.ended) endReadable(this);
17841 }
17842
17843 if (ret !== null) this.emit('data', ret);
17844
17845 return ret;
17846};
17847
17848function onEofChunk(stream, state) {
17849 if (state.ended) return;
17850 if (state.decoder) {
17851 var chunk = state.decoder.end();
17852 if (chunk && chunk.length) {
17853 state.buffer.push(chunk);
17854 state.length += state.objectMode ? 1 : chunk.length;
17855 }
17856 }
17857 state.ended = true;
17858
17859 // emit 'readable' now to make sure it gets picked up.
17860 emitReadable(stream);
17861}
17862
17863// Don't emit readable right away in sync mode, because this can trigger
17864// another read() call => stack overflow. This way, it might trigger
17865// a nextTick recursion warning, but that's not so bad.
17866function emitReadable(stream) {
17867 var state = stream._readableState;
17868 state.needReadable = false;
17869 if (!state.emittedReadable) {
17870 debug('emitReadable', state.flowing);
17871 state.emittedReadable = true;
17872 if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
17873 }
17874}
17875
17876function emitReadable_(stream) {
17877 debug('emit readable');
17878 stream.emit('readable');
17879 flow(stream);
17880}
17881
17882// at this point, the user has presumably seen the 'readable' event,
17883// and called read() to consume some data. that may have triggered
17884// in turn another _read(n) call, in which case reading = true if
17885// it's in progress.
17886// However, if we're not ended, or reading, and the length < hwm,
17887// then go ahead and try to read some more preemptively.
17888function maybeReadMore(stream, state) {
17889 if (!state.readingMore) {
17890 state.readingMore = true;
17891 pna.nextTick(maybeReadMore_, stream, state);
17892 }
17893}
17894
17895function maybeReadMore_(stream, state) {
17896 var len = state.length;
17897 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
17898 debug('maybeReadMore read 0');
17899 stream.read(0);
17900 if (len === state.length)
17901 // didn't get any data, stop spinning.
17902 break;else len = state.length;
17903 }
17904 state.readingMore = false;
17905}
17906
17907// abstract method. to be overridden in specific implementation classes.
17908// call cb(er, data) where data is <= n in length.
17909// for virtual (non-string, non-buffer) streams, "length" is somewhat
17910// arbitrary, and perhaps not very meaningful.
17911Readable.prototype._read = function (n) {
17912 this.emit('error', new Error('_read() is not implemented'));
17913};
17914
17915Readable.prototype.pipe = function (dest, pipeOpts) {
17916 var src = this;
17917 var state = this._readableState;
17918
17919 switch (state.pipesCount) {
17920 case 0:
17921 state.pipes = dest;
17922 break;
17923 case 1:
17924 state.pipes = [state.pipes, dest];
17925 break;
17926 default:
17927 state.pipes.push(dest);
17928 break;
17929 }
17930 state.pipesCount += 1;
17931 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
17932
17933 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
17934
17935 var endFn = doEnd ? onend : unpipe;
17936 if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
17937
17938 dest.on('unpipe', onunpipe);
17939 function onunpipe(readable, unpipeInfo) {
17940 debug('onunpipe');
17941 if (readable === src) {
17942 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
17943 unpipeInfo.hasUnpiped = true;
17944 cleanup();
17945 }
17946 }
17947 }
17948
17949 function onend() {
17950 debug('onend');
17951 dest.end();
17952 }
17953
17954 // when the dest drains, it reduces the awaitDrain counter
17955 // on the source. This would be more elegant with a .once()
17956 // handler in flow(), but adding and removing repeatedly is
17957 // too slow.
17958 var ondrain = pipeOnDrain(src);
17959 dest.on('drain', ondrain);
17960
17961 var cleanedUp = false;
17962 function cleanup() {
17963 debug('cleanup');
17964 // cleanup event handlers once the pipe is broken
17965 dest.removeListener('close', onclose);
17966 dest.removeListener('finish', onfinish);
17967 dest.removeListener('drain', ondrain);
17968 dest.removeListener('error', onerror);
17969 dest.removeListener('unpipe', onunpipe);
17970 src.removeListener('end', onend);
17971 src.removeListener('end', unpipe);
17972 src.removeListener('data', ondata);
17973
17974 cleanedUp = true;
17975
17976 // if the reader is waiting for a drain event from this
17977 // specific writer, then it would cause it to never start
17978 // flowing again.
17979 // So, if this is awaiting a drain, then we just call it now.
17980 // If we don't know, then assume that we are waiting for one.
17981 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
17982 }
17983
17984 // If the user pushes more data while we're writing to dest then we'll end up
17985 // in ondata again. However, we only want to increase awaitDrain once because
17986 // dest will only emit one 'drain' event for the multiple writes.
17987 // => Introduce a guard on increasing awaitDrain.
17988 var increasedAwaitDrain = false;
17989 src.on('data', ondata);
17990 function ondata(chunk) {
17991 debug('ondata');
17992 increasedAwaitDrain = false;
17993 var ret = dest.write(chunk);
17994 if (false === ret && !increasedAwaitDrain) {
17995 // If the user unpiped during `dest.write()`, it is possible
17996 // to get stuck in a permanently paused state if that write
17997 // also returned false.
17998 // => Check whether `dest` is still a piping destination.
17999 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
18000 debug('false write response, pause', src._readableState.awaitDrain);
18001 src._readableState.awaitDrain++;
18002 increasedAwaitDrain = true;
18003 }
18004 src.pause();
18005 }
18006 }
18007
18008 // if the dest has an error, then stop piping into it.
18009 // however, don't suppress the throwing behavior for this.
18010 function onerror(er) {
18011 debug('onerror', er);
18012 unpipe();
18013 dest.removeListener('error', onerror);
18014 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
18015 }
18016
18017 // Make sure our error handler is attached before userland ones.
18018 prependListener(dest, 'error', onerror);
18019
18020 // Both close and finish should trigger unpipe, but only once.
18021 function onclose() {
18022 dest.removeListener('finish', onfinish);
18023 unpipe();
18024 }
18025 dest.once('close', onclose);
18026 function onfinish() {
18027 debug('onfinish');
18028 dest.removeListener('close', onclose);
18029 unpipe();
18030 }
18031 dest.once('finish', onfinish);
18032
18033 function unpipe() {
18034 debug('unpipe');
18035 src.unpipe(dest);
18036 }
18037
18038 // tell the dest that it's being piped to
18039 dest.emit('pipe', src);
18040
18041 // start the flow if it hasn't been started already.
18042 if (!state.flowing) {
18043 debug('pipe resume');
18044 src.resume();
18045 }
18046
18047 return dest;
18048};
18049
18050function pipeOnDrain(src) {
18051 return function () {
18052 var state = src._readableState;
18053 debug('pipeOnDrain', state.awaitDrain);
18054 if (state.awaitDrain) state.awaitDrain--;
18055 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
18056 state.flowing = true;
18057 flow(src);
18058 }
18059 };
18060}
18061
18062Readable.prototype.unpipe = function (dest) {
18063 var state = this._readableState;
18064 var unpipeInfo = { hasUnpiped: false };
18065
18066 // if we're not piping anywhere, then do nothing.
18067 if (state.pipesCount === 0) return this;
18068
18069 // just one destination. most common case.
18070 if (state.pipesCount === 1) {
18071 // passed in one, but it's not the right one.
18072 if (dest && dest !== state.pipes) return this;
18073
18074 if (!dest) dest = state.pipes;
18075
18076 // got a match.
18077 state.pipes = null;
18078 state.pipesCount = 0;
18079 state.flowing = false;
18080 if (dest) dest.emit('unpipe', this, unpipeInfo);
18081 return this;
18082 }
18083
18084 // slow case. multiple pipe destinations.
18085
18086 if (!dest) {
18087 // remove all.
18088 var dests = state.pipes;
18089 var len = state.pipesCount;
18090 state.pipes = null;
18091 state.pipesCount = 0;
18092 state.flowing = false;
18093
18094 for (var i = 0; i < len; i++) {
18095 dests[i].emit('unpipe', this, unpipeInfo);
18096 }return this;
18097 }
18098
18099 // try to find the right one.
18100 var index = indexOf(state.pipes, dest);
18101 if (index === -1) return this;
18102
18103 state.pipes.splice(index, 1);
18104 state.pipesCount -= 1;
18105 if (state.pipesCount === 1) state.pipes = state.pipes[0];
18106
18107 dest.emit('unpipe', this, unpipeInfo);
18108
18109 return this;
18110};
18111
18112// set up data events if they are asked for
18113// Ensure readable listeners eventually get something
18114Readable.prototype.on = function (ev, fn) {
18115 var res = Stream.prototype.on.call(this, ev, fn);
18116
18117 if (ev === 'data') {
18118 // Start flowing on next tick if stream isn't explicitly paused
18119 if (this._readableState.flowing !== false) this.resume();
18120 } else if (ev === 'readable') {
18121 var state = this._readableState;
18122 if (!state.endEmitted && !state.readableListening) {
18123 state.readableListening = state.needReadable = true;
18124 state.emittedReadable = false;
18125 if (!state.reading) {
18126 pna.nextTick(nReadingNextTick, this);
18127 } else if (state.length) {
18128 emitReadable(this);
18129 }
18130 }
18131 }
18132
18133 return res;
18134};
18135Readable.prototype.addListener = Readable.prototype.on;
18136
18137function nReadingNextTick(self) {
18138 debug('readable nexttick read 0');
18139 self.read(0);
18140}
18141
18142// pause() and resume() are remnants of the legacy readable stream API
18143// If the user uses them, then switch into old mode.
18144Readable.prototype.resume = function () {
18145 var state = this._readableState;
18146 if (!state.flowing) {
18147 debug('resume');
18148 state.flowing = true;
18149 resume(this, state);
18150 }
18151 return this;
18152};
18153
18154function resume(stream, state) {
18155 if (!state.resumeScheduled) {
18156 state.resumeScheduled = true;
18157 pna.nextTick(resume_, stream, state);
18158 }
18159}
18160
18161function resume_(stream, state) {
18162 if (!state.reading) {
18163 debug('resume read 0');
18164 stream.read(0);
18165 }
18166
18167 state.resumeScheduled = false;
18168 state.awaitDrain = 0;
18169 stream.emit('resume');
18170 flow(stream);
18171 if (state.flowing && !state.reading) stream.read(0);
18172}
18173
18174Readable.prototype.pause = function () {
18175 debug('call pause flowing=%j', this._readableState.flowing);
18176 if (false !== this._readableState.flowing) {
18177 debug('pause');
18178 this._readableState.flowing = false;
18179 this.emit('pause');
18180 }
18181 return this;
18182};
18183
18184function flow(stream) {
18185 var state = stream._readableState;
18186 debug('flow', state.flowing);
18187 while (state.flowing && stream.read() !== null) {}
18188}
18189
18190// wrap an old-style stream as the async data source.
18191// This is *not* part of the readable stream interface.
18192// It is an ugly unfortunate mess of history.
18193Readable.prototype.wrap = function (stream) {
18194 var _this = this;
18195
18196 var state = this._readableState;
18197 var paused = false;
18198
18199 stream.on('end', function () {
18200 debug('wrapped end');
18201 if (state.decoder && !state.ended) {
18202 var chunk = state.decoder.end();
18203 if (chunk && chunk.length) _this.push(chunk);
18204 }
18205
18206 _this.push(null);
18207 });
18208
18209 stream.on('data', function (chunk) {
18210 debug('wrapped data');
18211 if (state.decoder) chunk = state.decoder.write(chunk);
18212
18213 // don't skip over falsy values in objectMode
18214 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
18215
18216 var ret = _this.push(chunk);
18217 if (!ret) {
18218 paused = true;
18219 stream.pause();
18220 }
18221 });
18222
18223 // proxy all the other methods.
18224 // important when wrapping filters and duplexes.
18225 for (var i in stream) {
18226 if (this[i] === undefined && typeof stream[i] === 'function') {
18227 this[i] = function (method) {
18228 return function () {
18229 return stream[method].apply(stream, arguments);
18230 };
18231 }(i);
18232 }
18233 }
18234
18235 // proxy certain important events.
18236 for (var n = 0; n < kProxyEvents.length; n++) {
18237 stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
18238 }
18239
18240 // when we try to consume some more bytes, simply unpause the
18241 // underlying stream.
18242 this._read = function (n) {
18243 debug('wrapped _read', n);
18244 if (paused) {
18245 paused = false;
18246 stream.resume();
18247 }
18248 };
18249
18250 return this;
18251};
18252
18253Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
18254 // making it explicit this property is not enumerable
18255 // because otherwise some prototype manipulation in
18256 // userland will fail
18257 enumerable: false,
18258 get: function get() {
18259 return this._readableState.highWaterMark;
18260 }
18261});
18262
18263// exposed for testing purposes only.
18264Readable._fromList = fromList;
18265
18266// Pluck off n bytes from an array of buffers.
18267// Length is the combined lengths of all the buffers in the list.
18268// This function is designed to be inlinable, so please take care when making
18269// changes to the function body.
18270function fromList(n, state) {
18271 // nothing buffered
18272 if (state.length === 0) return null;
18273
18274 var ret;
18275 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
18276 // read it all, truncate the list
18277 if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
18278 state.buffer.clear();
18279 } else {
18280 // read part of list
18281 ret = fromListPartial(n, state.buffer, state.decoder);
18282 }
18283
18284 return ret;
18285}
18286
18287// Extracts only enough buffered data to satisfy the amount requested.
18288// This function is designed to be inlinable, so please take care when making
18289// changes to the function body.
18290function fromListPartial(n, list, hasStrings) {
18291 var ret;
18292 if (n < list.head.data.length) {
18293 // slice is the same for buffers and strings
18294 ret = list.head.data.slice(0, n);
18295 list.head.data = list.head.data.slice(n);
18296 } else if (n === list.head.data.length) {
18297 // first chunk is a perfect match
18298 ret = list.shift();
18299 } else {
18300 // result spans more than one buffer
18301 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
18302 }
18303 return ret;
18304}
18305
18306// Copies a specified amount of characters from the list of buffered data
18307// chunks.
18308// This function is designed to be inlinable, so please take care when making
18309// changes to the function body.
18310function copyFromBufferString(n, list) {
18311 var p = list.head;
18312 var c = 1;
18313 var ret = p.data;
18314 n -= ret.length;
18315 while (p = p.next) {
18316 var str = p.data;
18317 var nb = n > str.length ? str.length : n;
18318 if (nb === str.length) ret += str;else ret += str.slice(0, n);
18319 n -= nb;
18320 if (n === 0) {
18321 if (nb === str.length) {
18322 ++c;
18323 if (p.next) list.head = p.next;else list.head = list.tail = null;
18324 } else {
18325 list.head = p;
18326 p.data = str.slice(nb);
18327 }
18328 break;
18329 }
18330 ++c;
18331 }
18332 list.length -= c;
18333 return ret;
18334}
18335
18336// Copies a specified amount of bytes from the list of buffered data chunks.
18337// This function is designed to be inlinable, so please take care when making
18338// changes to the function body.
18339function copyFromBuffer(n, list) {
18340 var ret = Buffer.allocUnsafe(n);
18341 var p = list.head;
18342 var c = 1;
18343 p.data.copy(ret);
18344 n -= p.data.length;
18345 while (p = p.next) {
18346 var buf = p.data;
18347 var nb = n > buf.length ? buf.length : n;
18348 buf.copy(ret, ret.length - n, 0, nb);
18349 n -= nb;
18350 if (n === 0) {
18351 if (nb === buf.length) {
18352 ++c;
18353 if (p.next) list.head = p.next;else list.head = list.tail = null;
18354 } else {
18355 list.head = p;
18356 p.data = buf.slice(nb);
18357 }
18358 break;
18359 }
18360 ++c;
18361 }
18362 list.length -= c;
18363 return ret;
18364}
18365
18366function endReadable(stream) {
18367 var state = stream._readableState;
18368
18369 // If we get here before consuming all the bytes, then that is a
18370 // bug in node. Should never happen.
18371 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
18372
18373 if (!state.endEmitted) {
18374 state.ended = true;
18375 pna.nextTick(endReadableNT, state, stream);
18376 }
18377}
18378
18379function endReadableNT(state, stream) {
18380 // Check that we didn't get one last unshift.
18381 if (!state.endEmitted && state.length === 0) {
18382 state.endEmitted = true;
18383 stream.readable = false;
18384 stream.emit('end');
18385 }
18386}
18387
18388function indexOf(xs, x) {
18389 for (var i = 0, l = xs.length; i < l; i++) {
18390 if (xs[i] === x) return i;
18391 }
18392 return -1;
18393}
18394
18395}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
18396},{"./_stream_duplex":245,"./internal/streams/BufferList":250,"./internal/streams/destroy":251,"./internal/streams/stream":252,"_process":239,"babel-runtime/core-js/object/get-prototype-of":44,"core-util-is":176,"events":206,"inherits":216,"isarray":224,"process-nextick-args":238,"safe-buffer":259,"string_decoder/":266,"util":58}],248:[function(require,module,exports){
18397// Copyright Joyent, Inc. and other Node contributors.
18398//
18399// Permission is hereby granted, free of charge, to any person obtaining a
18400// copy of this software and associated documentation files (the
18401// "Software"), to deal in the Software without restriction, including
18402// without limitation the rights to use, copy, modify, merge, publish,
18403// distribute, sublicense, and/or sell copies of the Software, and to permit
18404// persons to whom the Software is furnished to do so, subject to the
18405// following conditions:
18406//
18407// The above copyright notice and this permission notice shall be included
18408// in all copies or substantial portions of the Software.
18409//
18410// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18411// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18412// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
18413// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18414// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18415// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18416// USE OR OTHER DEALINGS IN THE SOFTWARE.
18417
18418// a transform stream is a readable/writable stream where you do
18419// something with the data. Sometimes it's called a "filter",
18420// but that's not a great name for it, since that implies a thing where
18421// some bits pass through, and others are simply ignored. (That would
18422// be a valid example of a transform, of course.)
18423//
18424// While the output is causally related to the input, it's not a
18425// necessarily symmetric or synchronous transformation. For example,
18426// a zlib stream might take multiple plain-text writes(), and then
18427// emit a single compressed chunk some time in the future.
18428//
18429// Here's how this works:
18430//
18431// The Transform stream has all the aspects of the readable and writable
18432// stream classes. When you write(chunk), that calls _write(chunk,cb)
18433// internally, and returns false if there's a lot of pending writes
18434// buffered up. When you call read(), that calls _read(n) until
18435// there's enough pending readable data buffered up.
18436//
18437// In a transform stream, the written data is placed in a buffer. When
18438// _read(n) is called, it transforms the queued up data, calling the
18439// buffered _write cb's as it consumes chunks. If consuming a single
18440// written chunk would result in multiple output chunks, then the first
18441// outputted bit calls the readcb, and subsequent chunks just go into
18442// the read buffer, and will cause it to emit 'readable' if necessary.
18443//
18444// This way, back-pressure is actually determined by the reading side,
18445// since _read has to be called to start processing a new chunk. However,
18446// a pathological inflate type of transform can cause excessive buffering
18447// here. For example, imagine a stream where every byte of input is
18448// interpreted as an integer from 0-255, and then results in that many
18449// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
18450// 1kb of data being output. In this case, you could write a very small
18451// amount of input, and end up with a very large amount of output. In
18452// such a pathological inflating mechanism, there'd be no way to tell
18453// the system to stop doing the transform. A single 4MB write could
18454// cause the system to run out of memory.
18455//
18456// However, even in such a pathological case, only a single written chunk
18457// would be consumed, and then the rest would wait (un-transformed) until
18458// the results of the previous transformed chunk were consumed.
18459
18460'use strict';
18461
18462module.exports = Transform;
18463
18464var Duplex = require('./_stream_duplex');
18465
18466/*<replacement>*/
18467var util = require('core-util-is');
18468util.inherits = require('inherits');
18469/*</replacement>*/
18470
18471util.inherits(Transform, Duplex);
18472
18473function afterTransform(er, data) {
18474 var ts = this._transformState;
18475 ts.transforming = false;
18476
18477 var cb = ts.writecb;
18478
18479 if (!cb) {
18480 return this.emit('error', new Error('write callback called multiple times'));
18481 }
18482
18483 ts.writechunk = null;
18484 ts.writecb = null;
18485
18486 if (data != null) // single equals check for both `null` and `undefined`
18487 this.push(data);
18488
18489 cb(er);
18490
18491 var rs = this._readableState;
18492 rs.reading = false;
18493 if (rs.needReadable || rs.length < rs.highWaterMark) {
18494 this._read(rs.highWaterMark);
18495 }
18496}
18497
18498function Transform(options) {
18499 if (!(this instanceof Transform)) return new Transform(options);
18500
18501 Duplex.call(this, options);
18502
18503 this._transformState = {
18504 afterTransform: afterTransform.bind(this),
18505 needTransform: false,
18506 transforming: false,
18507 writecb: null,
18508 writechunk: null,
18509 writeencoding: null
18510 };
18511
18512 // start out asking for a readable event once data is transformed.
18513 this._readableState.needReadable = true;
18514
18515 // we have implemented the _read method, and done the other things
18516 // that Readable wants before the first _read call, so unset the
18517 // sync guard flag.
18518 this._readableState.sync = false;
18519
18520 if (options) {
18521 if (typeof options.transform === 'function') this._transform = options.transform;
18522
18523 if (typeof options.flush === 'function') this._flush = options.flush;
18524 }
18525
18526 // When the writable side finishes, then flush out anything remaining.
18527 this.on('prefinish', prefinish);
18528}
18529
18530function prefinish() {
18531 var _this = this;
18532
18533 if (typeof this._flush === 'function') {
18534 this._flush(function (er, data) {
18535 done(_this, er, data);
18536 });
18537 } else {
18538 done(this, null, null);
18539 }
18540}
18541
18542Transform.prototype.push = function (chunk, encoding) {
18543 this._transformState.needTransform = false;
18544 return Duplex.prototype.push.call(this, chunk, encoding);
18545};
18546
18547// This is the part where you do stuff!
18548// override this function in implementation classes.
18549// 'chunk' is an input chunk.
18550//
18551// Call `push(newChunk)` to pass along transformed output
18552// to the readable side. You may call 'push' zero or more times.
18553//
18554// Call `cb(err)` when you are done with this chunk. If you pass
18555// an error, then that'll put the hurt on the whole operation. If you
18556// never call cb(), then you'll never get another chunk.
18557Transform.prototype._transform = function (chunk, encoding, cb) {
18558 throw new Error('_transform() is not implemented');
18559};
18560
18561Transform.prototype._write = function (chunk, encoding, cb) {
18562 var ts = this._transformState;
18563 ts.writecb = cb;
18564 ts.writechunk = chunk;
18565 ts.writeencoding = encoding;
18566 if (!ts.transforming) {
18567 var rs = this._readableState;
18568 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
18569 }
18570};
18571
18572// Doesn't matter what the args are here.
18573// _transform does all the work.
18574// That we got here means that the readable side wants more data.
18575Transform.prototype._read = function (n) {
18576 var ts = this._transformState;
18577
18578 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
18579 ts.transforming = true;
18580 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
18581 } else {
18582 // mark that we need a transform, so that any data that comes in
18583 // will get processed, now that we've asked for it.
18584 ts.needTransform = true;
18585 }
18586};
18587
18588Transform.prototype._destroy = function (err, cb) {
18589 var _this2 = this;
18590
18591 Duplex.prototype._destroy.call(this, err, function (err2) {
18592 cb(err2);
18593 _this2.emit('close');
18594 });
18595};
18596
18597function done(stream, er, data) {
18598 if (er) return stream.emit('error', er);
18599
18600 if (data != null) // single equals check for both `null` and `undefined`
18601 stream.push(data);
18602
18603 // if there's nothing in the write buffer, then that means
18604 // that nothing more will ever be provided
18605 if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
18606
18607 if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
18608
18609 return stream.push(null);
18610}
18611
18612},{"./_stream_duplex":245,"core-util-is":176,"inherits":216}],249:[function(require,module,exports){
18613(function (process,global){
18614// Copyright Joyent, Inc. and other Node contributors.
18615//
18616// Permission is hereby granted, free of charge, to any person obtaining a
18617// copy of this software and associated documentation files (the
18618// "Software"), to deal in the Software without restriction, including
18619// without limitation the rights to use, copy, modify, merge, publish,
18620// distribute, sublicense, and/or sell copies of the Software, and to permit
18621// persons to whom the Software is furnished to do so, subject to the
18622// following conditions:
18623//
18624// The above copyright notice and this permission notice shall be included
18625// in all copies or substantial portions of the Software.
18626//
18627// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18628// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18629// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
18630// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18631// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18632// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18633// USE OR OTHER DEALINGS IN THE SOFTWARE.
18634
18635// A bit simpler than readable streams.
18636// Implement an async ._write(chunk, encoding, cb), and it'll handle all
18637// the drain event emission and buffering.
18638
18639'use strict';
18640
18641/*<replacement>*/
18642
18643var _defineProperty = require('babel-runtime/core-js/object/define-property');
18644
18645var _defineProperty2 = _interopRequireDefault(_defineProperty);
18646
18647var _hasInstance = require('babel-runtime/core-js/symbol/has-instance');
18648
18649var _hasInstance2 = _interopRequireDefault(_hasInstance);
18650
18651var _symbol = require('babel-runtime/core-js/symbol');
18652
18653var _symbol2 = _interopRequireDefault(_symbol);
18654
18655var _setImmediate2 = require('babel-runtime/core-js/set-immediate');
18656
18657var _setImmediate3 = _interopRequireDefault(_setImmediate2);
18658
18659function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18660
18661var pna = require('process-nextick-args');
18662/*</replacement>*/
18663
18664module.exports = Writable;
18665
18666/* <replacement> */
18667function WriteReq(chunk, encoding, cb) {
18668 this.chunk = chunk;
18669 this.encoding = encoding;
18670 this.callback = cb;
18671 this.next = null;
18672}
18673
18674// It seems a linked list but it is not
18675// there will be only 2 of these for each stream
18676function CorkedRequest(state) {
18677 var _this = this;
18678
18679 this.next = null;
18680 this.entry = null;
18681 this.finish = function () {
18682 onCorkedFinish(_this, state);
18683 };
18684}
18685/* </replacement> */
18686
18687/*<replacement>*/
18688var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? _setImmediate3.default : pna.nextTick;
18689/*</replacement>*/
18690
18691/*<replacement>*/
18692var Duplex;
18693/*</replacement>*/
18694
18695Writable.WritableState = WritableState;
18696
18697/*<replacement>*/
18698var util = require('core-util-is');
18699util.inherits = require('inherits');
18700/*</replacement>*/
18701
18702/*<replacement>*/
18703var internalUtil = {
18704 deprecate: require('util-deprecate')
18705};
18706/*</replacement>*/
18707
18708/*<replacement>*/
18709var Stream = require('./internal/streams/stream');
18710/*</replacement>*/
18711
18712/*<replacement>*/
18713
18714var Buffer = require('safe-buffer').Buffer;
18715var OurUint8Array = global.Uint8Array || function () {};
18716function _uint8ArrayToBuffer(chunk) {
18717 return Buffer.from(chunk);
18718}
18719function _isUint8Array(obj) {
18720 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
18721}
18722
18723/*</replacement>*/
18724
18725var destroyImpl = require('./internal/streams/destroy');
18726
18727util.inherits(Writable, Stream);
18728
18729function nop() {}
18730
18731function WritableState(options, stream) {
18732 Duplex = Duplex || require('./_stream_duplex');
18733
18734 options = options || {};
18735
18736 // Duplex streams are both readable and writable, but share
18737 // the same options object.
18738 // However, some cases require setting options to different
18739 // values for the readable and the writable sides of the duplex stream.
18740 // These options can be provided separately as readableXXX and writableXXX.
18741 var isDuplex = stream instanceof Duplex;
18742
18743 // object stream flag to indicate whether or not this stream
18744 // contains buffers or objects.
18745 this.objectMode = !!options.objectMode;
18746
18747 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
18748
18749 // the point at which write() starts returning false
18750 // Note: 0 is a valid value, means that we always return false if
18751 // the entire buffer is not flushed immediately on write()
18752 var hwm = options.highWaterMark;
18753 var writableHwm = options.writableHighWaterMark;
18754 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
18755
18756 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
18757
18758 // cast to ints.
18759 this.highWaterMark = Math.floor(this.highWaterMark);
18760
18761 // if _final has been called
18762 this.finalCalled = false;
18763
18764 // drain event flag.
18765 this.needDrain = false;
18766 // at the start of calling end()
18767 this.ending = false;
18768 // when end() has been called, and returned
18769 this.ended = false;
18770 // when 'finish' is emitted
18771 this.finished = false;
18772
18773 // has it been destroyed
18774 this.destroyed = false;
18775
18776 // should we decode strings into buffers before passing to _write?
18777 // this is here so that some node-core streams can optimize string
18778 // handling at a lower level.
18779 var noDecode = options.decodeStrings === false;
18780 this.decodeStrings = !noDecode;
18781
18782 // Crypto is kind of old and crusty. Historically, its default string
18783 // encoding is 'binary' so we have to make this configurable.
18784 // Everything else in the universe uses 'utf8', though.
18785 this.defaultEncoding = options.defaultEncoding || 'utf8';
18786
18787 // not an actual buffer we keep track of, but a measurement
18788 // of how much we're waiting to get pushed to some underlying
18789 // socket or file.
18790 this.length = 0;
18791
18792 // a flag to see when we're in the middle of a write.
18793 this.writing = false;
18794
18795 // when true all writes will be buffered until .uncork() call
18796 this.corked = 0;
18797
18798 // a flag to be able to tell if the onwrite cb is called immediately,
18799 // or on a later tick. We set this to true at first, because any
18800 // actions that shouldn't happen until "later" should generally also
18801 // not happen before the first write call.
18802 this.sync = true;
18803
18804 // a flag to know if we're processing previously buffered items, which
18805 // may call the _write() callback in the same tick, so that we don't
18806 // end up in an overlapped onwrite situation.
18807 this.bufferProcessing = false;
18808
18809 // the callback that's passed to _write(chunk,cb)
18810 this.onwrite = function (er) {
18811 onwrite(stream, er);
18812 };
18813
18814 // the callback that the user supplies to write(chunk,encoding,cb)
18815 this.writecb = null;
18816
18817 // the amount that is being written when _write is called.
18818 this.writelen = 0;
18819
18820 this.bufferedRequest = null;
18821 this.lastBufferedRequest = null;
18822
18823 // number of pending user-supplied write callbacks
18824 // this must be 0 before 'finish' can be emitted
18825 this.pendingcb = 0;
18826
18827 // emit prefinish if the only thing we're waiting for is _write cbs
18828 // This is relevant for synchronous Transform streams
18829 this.prefinished = false;
18830
18831 // True if the error was already emitted and should not be thrown again
18832 this.errorEmitted = false;
18833
18834 // count buffered requests
18835 this.bufferedRequestCount = 0;
18836
18837 // allocate the first CorkedRequest, there is always
18838 // one allocated and free to use, and we maintain at most two
18839 this.corkedRequestsFree = new CorkedRequest(this);
18840}
18841
18842WritableState.prototype.getBuffer = function getBuffer() {
18843 var current = this.bufferedRequest;
18844 var out = [];
18845 while (current) {
18846 out.push(current);
18847 current = current.next;
18848 }
18849 return out;
18850};
18851
18852(function () {
18853 try {
18854 Object.defineProperty(WritableState.prototype, 'buffer', {
18855 get: internalUtil.deprecate(function () {
18856 return this.getBuffer();
18857 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
18858 });
18859 } catch (_) {}
18860})();
18861
18862// Test _writableState for inheritance to account for Duplex streams,
18863// whose prototype chain only points to Readable.
18864var realHasInstance;
18865if (typeof _symbol2.default === 'function' && _hasInstance2.default && typeof Function.prototype[_hasInstance2.default] === 'function') {
18866 realHasInstance = Function.prototype[_hasInstance2.default];
18867 (0, _defineProperty2.default)(Writable, _hasInstance2.default, {
18868 value: function value(object) {
18869 if (realHasInstance.call(this, object)) return true;
18870 if (this !== Writable) return false;
18871
18872 return object && object._writableState instanceof WritableState;
18873 }
18874 });
18875} else {
18876 realHasInstance = function realHasInstance(object) {
18877 return object instanceof this;
18878 };
18879}
18880
18881function Writable(options) {
18882 Duplex = Duplex || require('./_stream_duplex');
18883
18884 // Writable ctor is applied to Duplexes, too.
18885 // `realHasInstance` is necessary because using plain `instanceof`
18886 // would return false, as no `_writableState` property is attached.
18887
18888 // Trying to use the custom `instanceof` for Writable here will also break the
18889 // Node.js LazyTransform implementation, which has a non-trivial getter for
18890 // `_writableState` that would lead to infinite recursion.
18891 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
18892 return new Writable(options);
18893 }
18894
18895 this._writableState = new WritableState(options, this);
18896
18897 // legacy.
18898 this.writable = true;
18899
18900 if (options) {
18901 if (typeof options.write === 'function') this._write = options.write;
18902
18903 if (typeof options.writev === 'function') this._writev = options.writev;
18904
18905 if (typeof options.destroy === 'function') this._destroy = options.destroy;
18906
18907 if (typeof options.final === 'function') this._final = options.final;
18908 }
18909
18910 Stream.call(this);
18911}
18912
18913// Otherwise people can pipe Writable streams, which is just wrong.
18914Writable.prototype.pipe = function () {
18915 this.emit('error', new Error('Cannot pipe, not readable'));
18916};
18917
18918function writeAfterEnd(stream, cb) {
18919 var er = new Error('write after end');
18920 // TODO: defer error events consistently everywhere, not just the cb
18921 stream.emit('error', er);
18922 pna.nextTick(cb, er);
18923}
18924
18925// Checks that a user-supplied chunk is valid, especially for the particular
18926// mode the stream is in. Currently this means that `null` is never accepted
18927// and undefined/non-string values are only allowed in object mode.
18928function validChunk(stream, state, chunk, cb) {
18929 var valid = true;
18930 var er = false;
18931
18932 if (chunk === null) {
18933 er = new TypeError('May not write null values to stream');
18934 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
18935 er = new TypeError('Invalid non-string/buffer chunk');
18936 }
18937 if (er) {
18938 stream.emit('error', er);
18939 pna.nextTick(cb, er);
18940 valid = false;
18941 }
18942 return valid;
18943}
18944
18945Writable.prototype.write = function (chunk, encoding, cb) {
18946 var state = this._writableState;
18947 var ret = false;
18948 var isBuf = !state.objectMode && _isUint8Array(chunk);
18949
18950 if (isBuf && !Buffer.isBuffer(chunk)) {
18951 chunk = _uint8ArrayToBuffer(chunk);
18952 }
18953
18954 if (typeof encoding === 'function') {
18955 cb = encoding;
18956 encoding = null;
18957 }
18958
18959 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
18960
18961 if (typeof cb !== 'function') cb = nop;
18962
18963 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
18964 state.pendingcb++;
18965 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
18966 }
18967
18968 return ret;
18969};
18970
18971Writable.prototype.cork = function () {
18972 var state = this._writableState;
18973
18974 state.corked++;
18975};
18976
18977Writable.prototype.uncork = function () {
18978 var state = this._writableState;
18979
18980 if (state.corked) {
18981 state.corked--;
18982
18983 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
18984 }
18985};
18986
18987Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
18988 // node::ParseEncoding() requires lower case.
18989 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
18990 if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
18991 this._writableState.defaultEncoding = encoding;
18992 return this;
18993};
18994
18995function decodeChunk(state, chunk, encoding) {
18996 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
18997 chunk = Buffer.from(chunk, encoding);
18998 }
18999 return chunk;
19000}
19001
19002Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
19003 // making it explicit this property is not enumerable
19004 // because otherwise some prototype manipulation in
19005 // userland will fail
19006 enumerable: false,
19007 get: function get() {
19008 return this._writableState.highWaterMark;
19009 }
19010});
19011
19012// if we're already writing something, then just put this
19013// in the queue, and wait our turn. Otherwise, call _write
19014// If we return false, then we need a drain event, so set that flag.
19015function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
19016 if (!isBuf) {
19017 var newChunk = decodeChunk(state, chunk, encoding);
19018 if (chunk !== newChunk) {
19019 isBuf = true;
19020 encoding = 'buffer';
19021 chunk = newChunk;
19022 }
19023 }
19024 var len = state.objectMode ? 1 : chunk.length;
19025
19026 state.length += len;
19027
19028 var ret = state.length < state.highWaterMark;
19029 // we must ensure that previous needDrain will not be reset to false.
19030 if (!ret) state.needDrain = true;
19031
19032 if (state.writing || state.corked) {
19033 var last = state.lastBufferedRequest;
19034 state.lastBufferedRequest = {
19035 chunk: chunk,
19036 encoding: encoding,
19037 isBuf: isBuf,
19038 callback: cb,
19039 next: null
19040 };
19041 if (last) {
19042 last.next = state.lastBufferedRequest;
19043 } else {
19044 state.bufferedRequest = state.lastBufferedRequest;
19045 }
19046 state.bufferedRequestCount += 1;
19047 } else {
19048 doWrite(stream, state, false, len, chunk, encoding, cb);
19049 }
19050
19051 return ret;
19052}
19053
19054function doWrite(stream, state, writev, len, chunk, encoding, cb) {
19055 state.writelen = len;
19056 state.writecb = cb;
19057 state.writing = true;
19058 state.sync = true;
19059 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
19060 state.sync = false;
19061}
19062
19063function onwriteError(stream, state, sync, er, cb) {
19064 --state.pendingcb;
19065
19066 if (sync) {
19067 // defer the callback if we are being called synchronously
19068 // to avoid piling up things on the stack
19069 pna.nextTick(cb, er);
19070 // this can emit finish, and it will always happen
19071 // after error
19072 pna.nextTick(finishMaybe, stream, state);
19073 stream._writableState.errorEmitted = true;
19074 stream.emit('error', er);
19075 } else {
19076 // the caller expect this to happen before if
19077 // it is async
19078 cb(er);
19079 stream._writableState.errorEmitted = true;
19080 stream.emit('error', er);
19081 // this can emit finish, but finish must
19082 // always follow error
19083 finishMaybe(stream, state);
19084 }
19085}
19086
19087function onwriteStateUpdate(state) {
19088 state.writing = false;
19089 state.writecb = null;
19090 state.length -= state.writelen;
19091 state.writelen = 0;
19092}
19093
19094function onwrite(stream, er) {
19095 var state = stream._writableState;
19096 var sync = state.sync;
19097 var cb = state.writecb;
19098
19099 onwriteStateUpdate(state);
19100
19101 if (er) onwriteError(stream, state, sync, er, cb);else {
19102 // Check if we're actually ready to finish, but don't emit yet
19103 var finished = needFinish(state);
19104
19105 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
19106 clearBuffer(stream, state);
19107 }
19108
19109 if (sync) {
19110 /*<replacement>*/
19111 asyncWrite(afterWrite, stream, state, finished, cb);
19112 /*</replacement>*/
19113 } else {
19114 afterWrite(stream, state, finished, cb);
19115 }
19116 }
19117}
19118
19119function afterWrite(stream, state, finished, cb) {
19120 if (!finished) onwriteDrain(stream, state);
19121 state.pendingcb--;
19122 cb();
19123 finishMaybe(stream, state);
19124}
19125
19126// Must force callback to be called on nextTick, so that we don't
19127// emit 'drain' before the write() consumer gets the 'false' return
19128// value, and has a chance to attach a 'drain' listener.
19129function onwriteDrain(stream, state) {
19130 if (state.length === 0 && state.needDrain) {
19131 state.needDrain = false;
19132 stream.emit('drain');
19133 }
19134}
19135
19136// if there's something in the buffer waiting, then process it
19137function clearBuffer(stream, state) {
19138 state.bufferProcessing = true;
19139 var entry = state.bufferedRequest;
19140
19141 if (stream._writev && entry && entry.next) {
19142 // Fast case, write everything using _writev()
19143 var l = state.bufferedRequestCount;
19144 var buffer = new Array(l);
19145 var holder = state.corkedRequestsFree;
19146 holder.entry = entry;
19147
19148 var count = 0;
19149 var allBuffers = true;
19150 while (entry) {
19151 buffer[count] = entry;
19152 if (!entry.isBuf) allBuffers = false;
19153 entry = entry.next;
19154 count += 1;
19155 }
19156 buffer.allBuffers = allBuffers;
19157
19158 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
19159
19160 // doWrite is almost always async, defer these to save a bit of time
19161 // as the hot path ends with doWrite
19162 state.pendingcb++;
19163 state.lastBufferedRequest = null;
19164 if (holder.next) {
19165 state.corkedRequestsFree = holder.next;
19166 holder.next = null;
19167 } else {
19168 state.corkedRequestsFree = new CorkedRequest(state);
19169 }
19170 state.bufferedRequestCount = 0;
19171 } else {
19172 // Slow case, write chunks one-by-one
19173 while (entry) {
19174 var chunk = entry.chunk;
19175 var encoding = entry.encoding;
19176 var cb = entry.callback;
19177 var len = state.objectMode ? 1 : chunk.length;
19178
19179 doWrite(stream, state, false, len, chunk, encoding, cb);
19180 entry = entry.next;
19181 state.bufferedRequestCount--;
19182 // if we didn't call the onwrite immediately, then
19183 // it means that we need to wait until it does.
19184 // also, that means that the chunk and cb are currently
19185 // being processed, so move the buffer counter past them.
19186 if (state.writing) {
19187 break;
19188 }
19189 }
19190
19191 if (entry === null) state.lastBufferedRequest = null;
19192 }
19193
19194 state.bufferedRequest = entry;
19195 state.bufferProcessing = false;
19196}
19197
19198Writable.prototype._write = function (chunk, encoding, cb) {
19199 cb(new Error('_write() is not implemented'));
19200};
19201
19202Writable.prototype._writev = null;
19203
19204Writable.prototype.end = function (chunk, encoding, cb) {
19205 var state = this._writableState;
19206
19207 if (typeof chunk === 'function') {
19208 cb = chunk;
19209 chunk = null;
19210 encoding = null;
19211 } else if (typeof encoding === 'function') {
19212 cb = encoding;
19213 encoding = null;
19214 }
19215
19216 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
19217
19218 // .end() fully uncorks
19219 if (state.corked) {
19220 state.corked = 1;
19221 this.uncork();
19222 }
19223
19224 // ignore unnecessary end() calls.
19225 if (!state.ending && !state.finished) endWritable(this, state, cb);
19226};
19227
19228function needFinish(state) {
19229 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
19230}
19231function callFinal(stream, state) {
19232 stream._final(function (err) {
19233 state.pendingcb--;
19234 if (err) {
19235 stream.emit('error', err);
19236 }
19237 state.prefinished = true;
19238 stream.emit('prefinish');
19239 finishMaybe(stream, state);
19240 });
19241}
19242function prefinish(stream, state) {
19243 if (!state.prefinished && !state.finalCalled) {
19244 if (typeof stream._final === 'function') {
19245 state.pendingcb++;
19246 state.finalCalled = true;
19247 pna.nextTick(callFinal, stream, state);
19248 } else {
19249 state.prefinished = true;
19250 stream.emit('prefinish');
19251 }
19252 }
19253}
19254
19255function finishMaybe(stream, state) {
19256 var need = needFinish(state);
19257 if (need) {
19258 prefinish(stream, state);
19259 if (state.pendingcb === 0) {
19260 state.finished = true;
19261 stream.emit('finish');
19262 }
19263 }
19264 return need;
19265}
19266
19267function endWritable(stream, state, cb) {
19268 state.ending = true;
19269 finishMaybe(stream, state);
19270 if (cb) {
19271 if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
19272 }
19273 state.ended = true;
19274 stream.writable = false;
19275}
19276
19277function onCorkedFinish(corkReq, state, err) {
19278 var entry = corkReq.entry;
19279 corkReq.entry = null;
19280 while (entry) {
19281 var cb = entry.callback;
19282 state.pendingcb--;
19283 cb(err);
19284 entry = entry.next;
19285 }
19286 if (state.corkedRequestsFree) {
19287 state.corkedRequestsFree.next = corkReq;
19288 } else {
19289 state.corkedRequestsFree = corkReq;
19290 }
19291}
19292
19293Object.defineProperty(Writable.prototype, 'destroyed', {
19294 get: function get() {
19295 if (this._writableState === undefined) {
19296 return false;
19297 }
19298 return this._writableState.destroyed;
19299 },
19300 set: function set(value) {
19301 // we ignore the value if the stream
19302 // has not been initialized yet
19303 if (!this._writableState) {
19304 return;
19305 }
19306
19307 // backward compatibility, the user is explicitly
19308 // managing destroyed
19309 this._writableState.destroyed = value;
19310 }
19311});
19312
19313Writable.prototype.destroy = destroyImpl.destroy;
19314Writable.prototype._undestroy = destroyImpl.undestroy;
19315Writable.prototype._destroy = function (err, cb) {
19316 this.end();
19317 cb(err);
19318};
19319
19320}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
19321},{"./_stream_duplex":245,"./internal/streams/destroy":251,"./internal/streams/stream":252,"_process":239,"babel-runtime/core-js/object/define-property":41,"babel-runtime/core-js/set-immediate":47,"babel-runtime/core-js/symbol":49,"babel-runtime/core-js/symbol/has-instance":50,"core-util-is":176,"inherits":216,"process-nextick-args":238,"safe-buffer":259,"util-deprecate":271}],250:[function(require,module,exports){
19322'use strict';
19323
19324function _classCallCheck(instance, Constructor) {
19325 if (!(instance instanceof Constructor)) {
19326 throw new TypeError("Cannot call a class as a function");
19327 }
19328}
19329
19330var Buffer = require('safe-buffer').Buffer;
19331var util = require('util');
19332
19333function copyBuffer(src, target, offset) {
19334 src.copy(target, offset);
19335}
19336
19337module.exports = function () {
19338 function BufferList() {
19339 _classCallCheck(this, BufferList);
19340
19341 this.head = null;
19342 this.tail = null;
19343 this.length = 0;
19344 }
19345
19346 BufferList.prototype.push = function push(v) {
19347 var entry = { data: v, next: null };
19348 if (this.length > 0) this.tail.next = entry;else this.head = entry;
19349 this.tail = entry;
19350 ++this.length;
19351 };
19352
19353 BufferList.prototype.unshift = function unshift(v) {
19354 var entry = { data: v, next: this.head };
19355 if (this.length === 0) this.tail = entry;
19356 this.head = entry;
19357 ++this.length;
19358 };
19359
19360 BufferList.prototype.shift = function shift() {
19361 if (this.length === 0) return;
19362 var ret = this.head.data;
19363 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
19364 --this.length;
19365 return ret;
19366 };
19367
19368 BufferList.prototype.clear = function clear() {
19369 this.head = this.tail = null;
19370 this.length = 0;
19371 };
19372
19373 BufferList.prototype.join = function join(s) {
19374 if (this.length === 0) return '';
19375 var p = this.head;
19376 var ret = '' + p.data;
19377 while (p = p.next) {
19378 ret += s + p.data;
19379 }return ret;
19380 };
19381
19382 BufferList.prototype.concat = function concat(n) {
19383 if (this.length === 0) return Buffer.alloc(0);
19384 if (this.length === 1) return this.head.data;
19385 var ret = Buffer.allocUnsafe(n >>> 0);
19386 var p = this.head;
19387 var i = 0;
19388 while (p) {
19389 copyBuffer(p.data, ret, i);
19390 i += p.data.length;
19391 p = p.next;
19392 }
19393 return ret;
19394 };
19395
19396 return BufferList;
19397}();
19398
19399if (util && util.inspect && util.inspect.custom) {
19400 module.exports.prototype[util.inspect.custom] = function () {
19401 var obj = util.inspect({ length: this.length });
19402 return this.constructor.name + ' ' + obj;
19403 };
19404}
19405
19406},{"safe-buffer":259,"util":58}],251:[function(require,module,exports){
19407'use strict';
19408
19409/*<replacement>*/
19410
19411var pna = require('process-nextick-args');
19412/*</replacement>*/
19413
19414// undocumented cb() API, needed for core, not for public API
19415function destroy(err, cb) {
19416 var _this = this;
19417
19418 var readableDestroyed = this._readableState && this._readableState.destroyed;
19419 var writableDestroyed = this._writableState && this._writableState.destroyed;
19420
19421 if (readableDestroyed || writableDestroyed) {
19422 if (cb) {
19423 cb(err);
19424 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
19425 pna.nextTick(emitErrorNT, this, err);
19426 }
19427 return this;
19428 }
19429
19430 // we set destroyed to true before firing error callbacks in order
19431 // to make it re-entrance safe in case destroy() is called within callbacks
19432
19433 if (this._readableState) {
19434 this._readableState.destroyed = true;
19435 }
19436
19437 // if this is a duplex stream mark the writable part as destroyed as well
19438 if (this._writableState) {
19439 this._writableState.destroyed = true;
19440 }
19441
19442 this._destroy(err || null, function (err) {
19443 if (!cb && err) {
19444 pna.nextTick(emitErrorNT, _this, err);
19445 if (_this._writableState) {
19446 _this._writableState.errorEmitted = true;
19447 }
19448 } else if (cb) {
19449 cb(err);
19450 }
19451 });
19452
19453 return this;
19454}
19455
19456function undestroy() {
19457 if (this._readableState) {
19458 this._readableState.destroyed = false;
19459 this._readableState.reading = false;
19460 this._readableState.ended = false;
19461 this._readableState.endEmitted = false;
19462 }
19463
19464 if (this._writableState) {
19465 this._writableState.destroyed = false;
19466 this._writableState.ended = false;
19467 this._writableState.ending = false;
19468 this._writableState.finished = false;
19469 this._writableState.errorEmitted = false;
19470 }
19471}
19472
19473function emitErrorNT(self, err) {
19474 self.emit('error', err);
19475}
19476
19477module.exports = {
19478 destroy: destroy,
19479 undestroy: undestroy
19480};
19481
19482},{"process-nextick-args":238}],252:[function(require,module,exports){
19483'use strict';
19484
19485module.exports = require('events').EventEmitter;
19486
19487},{"events":206}],253:[function(require,module,exports){
19488module.exports = require('./readable').PassThrough
19489
19490},{"./readable":254}],254:[function(require,module,exports){
19491exports = module.exports = require('./lib/_stream_readable.js');
19492exports.Stream = exports;
19493exports.Readable = exports;
19494exports.Writable = require('./lib/_stream_writable.js');
19495exports.Duplex = require('./lib/_stream_duplex.js');
19496exports.Transform = require('./lib/_stream_transform.js');
19497exports.PassThrough = require('./lib/_stream_passthrough.js');
19498
19499},{"./lib/_stream_duplex.js":245,"./lib/_stream_passthrough.js":246,"./lib/_stream_readable.js":247,"./lib/_stream_transform.js":248,"./lib/_stream_writable.js":249}],255:[function(require,module,exports){
19500module.exports = require('./readable').Transform
19501
19502},{"./readable":254}],256:[function(require,module,exports){
19503module.exports = require('./lib/_stream_writable.js');
19504
19505},{"./lib/_stream_writable.js":249}],257:[function(require,module,exports){
19506/**
19507 * Copyright (c) 2014-present, Facebook, Inc.
19508 *
19509 * This source code is licensed under the MIT license found in the
19510 * LICENSE file in the root directory of this source tree.
19511 */
19512
19513// This method of obtaining a reference to the global object needs to be
19514// kept identical to the way it is obtained in runtime.js
19515var g = (function() { return this })() || Function("return this")();
19516
19517// Use `getOwnPropertyNames` because not all browsers support calling
19518// `hasOwnProperty` on the global `self` object in a worker. See #183.
19519var hadRuntime = g.regeneratorRuntime &&
19520 Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
19521
19522// Save the old regeneratorRuntime in case it needs to be restored later.
19523var oldRuntime = hadRuntime && g.regeneratorRuntime;
19524
19525// Force reevalutation of runtime.js.
19526g.regeneratorRuntime = undefined;
19527
19528module.exports = require("./runtime");
19529
19530if (hadRuntime) {
19531 // Restore the original runtime.
19532 g.regeneratorRuntime = oldRuntime;
19533} else {
19534 // Remove the global property added by runtime.js.
19535 try {
19536 delete g.regeneratorRuntime;
19537 } catch(e) {
19538 g.regeneratorRuntime = undefined;
19539 }
19540}
19541
19542},{"./runtime":258}],258:[function(require,module,exports){
19543/**
19544 * Copyright (c) 2014-present, Facebook, Inc.
19545 *
19546 * This source code is licensed under the MIT license found in the
19547 * LICENSE file in the root directory of this source tree.
19548 */
19549
19550!(function(global) {
19551 "use strict";
19552
19553 var Op = Object.prototype;
19554 var hasOwn = Op.hasOwnProperty;
19555 var undefined; // More compressible than void 0.
19556 var $Symbol = typeof Symbol === "function" ? Symbol : {};
19557 var iteratorSymbol = $Symbol.iterator || "@@iterator";
19558 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
19559 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
19560
19561 var inModule = typeof module === "object";
19562 var runtime = global.regeneratorRuntime;
19563 if (runtime) {
19564 if (inModule) {
19565 // If regeneratorRuntime is defined globally and we're in a module,
19566 // make the exports object identical to regeneratorRuntime.
19567 module.exports = runtime;
19568 }
19569 // Don't bother evaluating the rest of this file if the runtime was
19570 // already defined globally.
19571 return;
19572 }
19573
19574 // Define the runtime globally (as expected by generated code) as either
19575 // module.exports (if we're in a module) or a new, empty object.
19576 runtime = global.regeneratorRuntime = inModule ? module.exports : {};
19577
19578 function wrap(innerFn, outerFn, self, tryLocsList) {
19579 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
19580 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
19581 var generator = Object.create(protoGenerator.prototype);
19582 var context = new Context(tryLocsList || []);
19583
19584 // The ._invoke method unifies the implementations of the .next,
19585 // .throw, and .return methods.
19586 generator._invoke = makeInvokeMethod(innerFn, self, context);
19587
19588 return generator;
19589 }
19590 runtime.wrap = wrap;
19591
19592 // Try/catch helper to minimize deoptimizations. Returns a completion
19593 // record like context.tryEntries[i].completion. This interface could
19594 // have been (and was previously) designed to take a closure to be
19595 // invoked without arguments, but in all the cases we care about we
19596 // already have an existing method we want to call, so there's no need
19597 // to create a new function object. We can even get away with assuming
19598 // the method takes exactly one argument, since that happens to be true
19599 // in every case, so we don't have to touch the arguments object. The
19600 // only additional allocation required is the completion record, which
19601 // has a stable shape and so hopefully should be cheap to allocate.
19602 function tryCatch(fn, obj, arg) {
19603 try {
19604 return { type: "normal", arg: fn.call(obj, arg) };
19605 } catch (err) {
19606 return { type: "throw", arg: err };
19607 }
19608 }
19609
19610 var GenStateSuspendedStart = "suspendedStart";
19611 var GenStateSuspendedYield = "suspendedYield";
19612 var GenStateExecuting = "executing";
19613 var GenStateCompleted = "completed";
19614
19615 // Returning this object from the innerFn has the same effect as
19616 // breaking out of the dispatch switch statement.
19617 var ContinueSentinel = {};
19618
19619 // Dummy constructor functions that we use as the .constructor and
19620 // .constructor.prototype properties for functions that return Generator
19621 // objects. For full spec compliance, you may wish to configure your
19622 // minifier not to mangle the names of these two functions.
19623 function Generator() {}
19624 function GeneratorFunction() {}
19625 function GeneratorFunctionPrototype() {}
19626
19627 // This is a polyfill for %IteratorPrototype% for environments that
19628 // don't natively support it.
19629 var IteratorPrototype = {};
19630 IteratorPrototype[iteratorSymbol] = function () {
19631 return this;
19632 };
19633
19634 var getProto = Object.getPrototypeOf;
19635 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
19636 if (NativeIteratorPrototype &&
19637 NativeIteratorPrototype !== Op &&
19638 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
19639 // This environment has a native %IteratorPrototype%; use it instead
19640 // of the polyfill.
19641 IteratorPrototype = NativeIteratorPrototype;
19642 }
19643
19644 var Gp = GeneratorFunctionPrototype.prototype =
19645 Generator.prototype = Object.create(IteratorPrototype);
19646 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
19647 GeneratorFunctionPrototype.constructor = GeneratorFunction;
19648 GeneratorFunctionPrototype[toStringTagSymbol] =
19649 GeneratorFunction.displayName = "GeneratorFunction";
19650
19651 // Helper for defining the .next, .throw, and .return methods of the
19652 // Iterator interface in terms of a single ._invoke method.
19653 function defineIteratorMethods(prototype) {
19654 ["next", "throw", "return"].forEach(function(method) {
19655 prototype[method] = function(arg) {
19656 return this._invoke(method, arg);
19657 };
19658 });
19659 }
19660
19661 runtime.isGeneratorFunction = function(genFun) {
19662 var ctor = typeof genFun === "function" && genFun.constructor;
19663 return ctor
19664 ? ctor === GeneratorFunction ||
19665 // For the native GeneratorFunction constructor, the best we can
19666 // do is to check its .name property.
19667 (ctor.displayName || ctor.name) === "GeneratorFunction"
19668 : false;
19669 };
19670
19671 runtime.mark = function(genFun) {
19672 if (Object.setPrototypeOf) {
19673 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
19674 } else {
19675 genFun.__proto__ = GeneratorFunctionPrototype;
19676 if (!(toStringTagSymbol in genFun)) {
19677 genFun[toStringTagSymbol] = "GeneratorFunction";
19678 }
19679 }
19680 genFun.prototype = Object.create(Gp);
19681 return genFun;
19682 };
19683
19684 // Within the body of any async function, `await x` is transformed to
19685 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
19686 // `hasOwn.call(value, "__await")` to determine if the yielded value is
19687 // meant to be awaited.
19688 runtime.awrap = function(arg) {
19689 return { __await: arg };
19690 };
19691
19692 function AsyncIterator(generator) {
19693 function invoke(method, arg, resolve, reject) {
19694 var record = tryCatch(generator[method], generator, arg);
19695 if (record.type === "throw") {
19696 reject(record.arg);
19697 } else {
19698 var result = record.arg;
19699 var value = result.value;
19700 if (value &&
19701 typeof value === "object" &&
19702 hasOwn.call(value, "__await")) {
19703 return Promise.resolve(value.__await).then(function(value) {
19704 invoke("next", value, resolve, reject);
19705 }, function(err) {
19706 invoke("throw", err, resolve, reject);
19707 });
19708 }
19709
19710 return Promise.resolve(value).then(function(unwrapped) {
19711 // When a yielded Promise is resolved, its final value becomes
19712 // the .value of the Promise<{value,done}> result for the
19713 // current iteration. If the Promise is rejected, however, the
19714 // result for this iteration will be rejected with the same
19715 // reason. Note that rejections of yielded Promises are not
19716 // thrown back into the generator function, as is the case
19717 // when an awaited Promise is rejected. This difference in
19718 // behavior between yield and await is important, because it
19719 // allows the consumer to decide what to do with the yielded
19720 // rejection (swallow it and continue, manually .throw it back
19721 // into the generator, abandon iteration, whatever). With
19722 // await, by contrast, there is no opportunity to examine the
19723 // rejection reason outside the generator function, so the
19724 // only option is to throw it from the await expression, and
19725 // let the generator function handle the exception.
19726 result.value = unwrapped;
19727 resolve(result);
19728 }, reject);
19729 }
19730 }
19731
19732 var previousPromise;
19733
19734 function enqueue(method, arg) {
19735 function callInvokeWithMethodAndArg() {
19736 return new Promise(function(resolve, reject) {
19737 invoke(method, arg, resolve, reject);
19738 });
19739 }
19740
19741 return previousPromise =
19742 // If enqueue has been called before, then we want to wait until
19743 // all previous Promises have been resolved before calling invoke,
19744 // so that results are always delivered in the correct order. If
19745 // enqueue has not been called before, then it is important to
19746 // call invoke immediately, without waiting on a callback to fire,
19747 // so that the async generator function has the opportunity to do
19748 // any necessary setup in a predictable way. This predictability
19749 // is why the Promise constructor synchronously invokes its
19750 // executor callback, and why async functions synchronously
19751 // execute code before the first await. Since we implement simple
19752 // async functions in terms of async generators, it is especially
19753 // important to get this right, even though it requires care.
19754 previousPromise ? previousPromise.then(
19755 callInvokeWithMethodAndArg,
19756 // Avoid propagating failures to Promises returned by later
19757 // invocations of the iterator.
19758 callInvokeWithMethodAndArg
19759 ) : callInvokeWithMethodAndArg();
19760 }
19761
19762 // Define the unified helper method that is used to implement .next,
19763 // .throw, and .return (see defineIteratorMethods).
19764 this._invoke = enqueue;
19765 }
19766
19767 defineIteratorMethods(AsyncIterator.prototype);
19768 AsyncIterator.prototype[asyncIteratorSymbol] = function () {
19769 return this;
19770 };
19771 runtime.AsyncIterator = AsyncIterator;
19772
19773 // Note that simple async functions are implemented on top of
19774 // AsyncIterator objects; they just return a Promise for the value of
19775 // the final result produced by the iterator.
19776 runtime.async = function(innerFn, outerFn, self, tryLocsList) {
19777 var iter = new AsyncIterator(
19778 wrap(innerFn, outerFn, self, tryLocsList)
19779 );
19780
19781 return runtime.isGeneratorFunction(outerFn)
19782 ? iter // If outerFn is a generator, return the full iterator.
19783 : iter.next().then(function(result) {
19784 return result.done ? result.value : iter.next();
19785 });
19786 };
19787
19788 function makeInvokeMethod(innerFn, self, context) {
19789 var state = GenStateSuspendedStart;
19790
19791 return function invoke(method, arg) {
19792 if (state === GenStateExecuting) {
19793 throw new Error("Generator is already running");
19794 }
19795
19796 if (state === GenStateCompleted) {
19797 if (method === "throw") {
19798 throw arg;
19799 }
19800
19801 // Be forgiving, per 25.3.3.3.3 of the spec:
19802 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
19803 return doneResult();
19804 }
19805
19806 context.method = method;
19807 context.arg = arg;
19808
19809 while (true) {
19810 var delegate = context.delegate;
19811 if (delegate) {
19812 var delegateResult = maybeInvokeDelegate(delegate, context);
19813 if (delegateResult) {
19814 if (delegateResult === ContinueSentinel) continue;
19815 return delegateResult;
19816 }
19817 }
19818
19819 if (context.method === "next") {
19820 // Setting context._sent for legacy support of Babel's
19821 // function.sent implementation.
19822 context.sent = context._sent = context.arg;
19823
19824 } else if (context.method === "throw") {
19825 if (state === GenStateSuspendedStart) {
19826 state = GenStateCompleted;
19827 throw context.arg;
19828 }
19829
19830 context.dispatchException(context.arg);
19831
19832 } else if (context.method === "return") {
19833 context.abrupt("return", context.arg);
19834 }
19835
19836 state = GenStateExecuting;
19837
19838 var record = tryCatch(innerFn, self, context);
19839 if (record.type === "normal") {
19840 // If an exception is thrown from innerFn, we leave state ===
19841 // GenStateExecuting and loop back for another invocation.
19842 state = context.done
19843 ? GenStateCompleted
19844 : GenStateSuspendedYield;
19845
19846 if (record.arg === ContinueSentinel) {
19847 continue;
19848 }
19849
19850 return {
19851 value: record.arg,
19852 done: context.done
19853 };
19854
19855 } else if (record.type === "throw") {
19856 state = GenStateCompleted;
19857 // Dispatch the exception by looping back around to the
19858 // context.dispatchException(context.arg) call above.
19859 context.method = "throw";
19860 context.arg = record.arg;
19861 }
19862 }
19863 };
19864 }
19865
19866 // Call delegate.iterator[context.method](context.arg) and handle the
19867 // result, either by returning a { value, done } result from the
19868 // delegate iterator, or by modifying context.method and context.arg,
19869 // setting context.delegate to null, and returning the ContinueSentinel.
19870 function maybeInvokeDelegate(delegate, context) {
19871 var method = delegate.iterator[context.method];
19872 if (method === undefined) {
19873 // A .throw or .return when the delegate iterator has no .throw
19874 // method always terminates the yield* loop.
19875 context.delegate = null;
19876
19877 if (context.method === "throw") {
19878 if (delegate.iterator.return) {
19879 // If the delegate iterator has a return method, give it a
19880 // chance to clean up.
19881 context.method = "return";
19882 context.arg = undefined;
19883 maybeInvokeDelegate(delegate, context);
19884
19885 if (context.method === "throw") {
19886 // If maybeInvokeDelegate(context) changed context.method from
19887 // "return" to "throw", let that override the TypeError below.
19888 return ContinueSentinel;
19889 }
19890 }
19891
19892 context.method = "throw";
19893 context.arg = new TypeError(
19894 "The iterator does not provide a 'throw' method");
19895 }
19896
19897 return ContinueSentinel;
19898 }
19899
19900 var record = tryCatch(method, delegate.iterator, context.arg);
19901
19902 if (record.type === "throw") {
19903 context.method = "throw";
19904 context.arg = record.arg;
19905 context.delegate = null;
19906 return ContinueSentinel;
19907 }
19908
19909 var info = record.arg;
19910
19911 if (! info) {
19912 context.method = "throw";
19913 context.arg = new TypeError("iterator result is not an object");
19914 context.delegate = null;
19915 return ContinueSentinel;
19916 }
19917
19918 if (info.done) {
19919 // Assign the result of the finished delegate to the temporary
19920 // variable specified by delegate.resultName (see delegateYield).
19921 context[delegate.resultName] = info.value;
19922
19923 // Resume execution at the desired location (see delegateYield).
19924 context.next = delegate.nextLoc;
19925
19926 // If context.method was "throw" but the delegate handled the
19927 // exception, let the outer generator proceed normally. If
19928 // context.method was "next", forget context.arg since it has been
19929 // "consumed" by the delegate iterator. If context.method was
19930 // "return", allow the original .return call to continue in the
19931 // outer generator.
19932 if (context.method !== "return") {
19933 context.method = "next";
19934 context.arg = undefined;
19935 }
19936
19937 } else {
19938 // Re-yield the result returned by the delegate method.
19939 return info;
19940 }
19941
19942 // The delegate iterator is finished, so forget it and continue with
19943 // the outer generator.
19944 context.delegate = null;
19945 return ContinueSentinel;
19946 }
19947
19948 // Define Generator.prototype.{next,throw,return} in terms of the
19949 // unified ._invoke helper method.
19950 defineIteratorMethods(Gp);
19951
19952 Gp[toStringTagSymbol] = "Generator";
19953
19954 // A Generator should always return itself as the iterator object when the
19955 // @@iterator function is called on it. Some browsers' implementations of the
19956 // iterator prototype chain incorrectly implement this, causing the Generator
19957 // object to not be returned from this call. This ensures that doesn't happen.
19958 // See https://github.com/facebook/regenerator/issues/274 for more details.
19959 Gp[iteratorSymbol] = function() {
19960 return this;
19961 };
19962
19963 Gp.toString = function() {
19964 return "[object Generator]";
19965 };
19966
19967 function pushTryEntry(locs) {
19968 var entry = { tryLoc: locs[0] };
19969
19970 if (1 in locs) {
19971 entry.catchLoc = locs[1];
19972 }
19973
19974 if (2 in locs) {
19975 entry.finallyLoc = locs[2];
19976 entry.afterLoc = locs[3];
19977 }
19978
19979 this.tryEntries.push(entry);
19980 }
19981
19982 function resetTryEntry(entry) {
19983 var record = entry.completion || {};
19984 record.type = "normal";
19985 delete record.arg;
19986 entry.completion = record;
19987 }
19988
19989 function Context(tryLocsList) {
19990 // The root entry object (effectively a try statement without a catch
19991 // or a finally block) gives us a place to store values thrown from
19992 // locations where there is no enclosing try statement.
19993 this.tryEntries = [{ tryLoc: "root" }];
19994 tryLocsList.forEach(pushTryEntry, this);
19995 this.reset(true);
19996 }
19997
19998 runtime.keys = function(object) {
19999 var keys = [];
20000 for (var key in object) {
20001 keys.push(key);
20002 }
20003 keys.reverse();
20004
20005 // Rather than returning an object with a next method, we keep
20006 // things simple and return the next function itself.
20007 return function next() {
20008 while (keys.length) {
20009 var key = keys.pop();
20010 if (key in object) {
20011 next.value = key;
20012 next.done = false;
20013 return next;
20014 }
20015 }
20016
20017 // To avoid creating an additional object, we just hang the .value
20018 // and .done properties off the next function object itself. This
20019 // also ensures that the minifier will not anonymize the function.
20020 next.done = true;
20021 return next;
20022 };
20023 };
20024
20025 function values(iterable) {
20026 if (iterable) {
20027 var iteratorMethod = iterable[iteratorSymbol];
20028 if (iteratorMethod) {
20029 return iteratorMethod.call(iterable);
20030 }
20031
20032 if (typeof iterable.next === "function") {
20033 return iterable;
20034 }
20035
20036 if (!isNaN(iterable.length)) {
20037 var i = -1, next = function next() {
20038 while (++i < iterable.length) {
20039 if (hasOwn.call(iterable, i)) {
20040 next.value = iterable[i];
20041 next.done = false;
20042 return next;
20043 }
20044 }
20045
20046 next.value = undefined;
20047 next.done = true;
20048
20049 return next;
20050 };
20051
20052 return next.next = next;
20053 }
20054 }
20055
20056 // Return an iterator with no values.
20057 return { next: doneResult };
20058 }
20059 runtime.values = values;
20060
20061 function doneResult() {
20062 return { value: undefined, done: true };
20063 }
20064
20065 Context.prototype = {
20066 constructor: Context,
20067
20068 reset: function(skipTempReset) {
20069 this.prev = 0;
20070 this.next = 0;
20071 // Resetting context._sent for legacy support of Babel's
20072 // function.sent implementation.
20073 this.sent = this._sent = undefined;
20074 this.done = false;
20075 this.delegate = null;
20076
20077 this.method = "next";
20078 this.arg = undefined;
20079
20080 this.tryEntries.forEach(resetTryEntry);
20081
20082 if (!skipTempReset) {
20083 for (var name in this) {
20084 // Not sure about the optimal order of these conditions:
20085 if (name.charAt(0) === "t" &&
20086 hasOwn.call(this, name) &&
20087 !isNaN(+name.slice(1))) {
20088 this[name] = undefined;
20089 }
20090 }
20091 }
20092 },
20093
20094 stop: function() {
20095 this.done = true;
20096
20097 var rootEntry = this.tryEntries[0];
20098 var rootRecord = rootEntry.completion;
20099 if (rootRecord.type === "throw") {
20100 throw rootRecord.arg;
20101 }
20102
20103 return this.rval;
20104 },
20105
20106 dispatchException: function(exception) {
20107 if (this.done) {
20108 throw exception;
20109 }
20110
20111 var context = this;
20112 function handle(loc, caught) {
20113 record.type = "throw";
20114 record.arg = exception;
20115 context.next = loc;
20116
20117 if (caught) {
20118 // If the dispatched exception was caught by a catch block,
20119 // then let that catch block handle the exception normally.
20120 context.method = "next";
20121 context.arg = undefined;
20122 }
20123
20124 return !! caught;
20125 }
20126
20127 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
20128 var entry = this.tryEntries[i];
20129 var record = entry.completion;
20130
20131 if (entry.tryLoc === "root") {
20132 // Exception thrown outside of any try block that could handle
20133 // it, so set the completion value of the entire function to
20134 // throw the exception.
20135 return handle("end");
20136 }
20137
20138 if (entry.tryLoc <= this.prev) {
20139 var hasCatch = hasOwn.call(entry, "catchLoc");
20140 var hasFinally = hasOwn.call(entry, "finallyLoc");
20141
20142 if (hasCatch && hasFinally) {
20143 if (this.prev < entry.catchLoc) {
20144 return handle(entry.catchLoc, true);
20145 } else if (this.prev < entry.finallyLoc) {
20146 return handle(entry.finallyLoc);
20147 }
20148
20149 } else if (hasCatch) {
20150 if (this.prev < entry.catchLoc) {
20151 return handle(entry.catchLoc, true);
20152 }
20153
20154 } else if (hasFinally) {
20155 if (this.prev < entry.finallyLoc) {
20156 return handle(entry.finallyLoc);
20157 }
20158
20159 } else {
20160 throw new Error("try statement without catch or finally");
20161 }
20162 }
20163 }
20164 },
20165
20166 abrupt: function(type, arg) {
20167 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
20168 var entry = this.tryEntries[i];
20169 if (entry.tryLoc <= this.prev &&
20170 hasOwn.call(entry, "finallyLoc") &&
20171 this.prev < entry.finallyLoc) {
20172 var finallyEntry = entry;
20173 break;
20174 }
20175 }
20176
20177 if (finallyEntry &&
20178 (type === "break" ||
20179 type === "continue") &&
20180 finallyEntry.tryLoc <= arg &&
20181 arg <= finallyEntry.finallyLoc) {
20182 // Ignore the finally entry if control is not jumping to a
20183 // location outside the try/catch block.
20184 finallyEntry = null;
20185 }
20186
20187 var record = finallyEntry ? finallyEntry.completion : {};
20188 record.type = type;
20189 record.arg = arg;
20190
20191 if (finallyEntry) {
20192 this.method = "next";
20193 this.next = finallyEntry.finallyLoc;
20194 return ContinueSentinel;
20195 }
20196
20197 return this.complete(record);
20198 },
20199
20200 complete: function(record, afterLoc) {
20201 if (record.type === "throw") {
20202 throw record.arg;
20203 }
20204
20205 if (record.type === "break" ||
20206 record.type === "continue") {
20207 this.next = record.arg;
20208 } else if (record.type === "return") {
20209 this.rval = this.arg = record.arg;
20210 this.method = "return";
20211 this.next = "end";
20212 } else if (record.type === "normal" && afterLoc) {
20213 this.next = afterLoc;
20214 }
20215
20216 return ContinueSentinel;
20217 },
20218
20219 finish: function(finallyLoc) {
20220 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
20221 var entry = this.tryEntries[i];
20222 if (entry.finallyLoc === finallyLoc) {
20223 this.complete(entry.completion, entry.afterLoc);
20224 resetTryEntry(entry);
20225 return ContinueSentinel;
20226 }
20227 }
20228 },
20229
20230 "catch": function(tryLoc) {
20231 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
20232 var entry = this.tryEntries[i];
20233 if (entry.tryLoc === tryLoc) {
20234 var record = entry.completion;
20235 if (record.type === "throw") {
20236 var thrown = record.arg;
20237 resetTryEntry(entry);
20238 }
20239 return thrown;
20240 }
20241 }
20242
20243 // The context.catch method must only be called with a location
20244 // argument that corresponds to a known catch block.
20245 throw new Error("illegal catch attempt");
20246 },
20247
20248 delegateYield: function(iterable, resultName, nextLoc) {
20249 this.delegate = {
20250 iterator: values(iterable),
20251 resultName: resultName,
20252 nextLoc: nextLoc
20253 };
20254
20255 if (this.method === "next") {
20256 // Deliberately forget the last sent value so that we don't
20257 // accidentally pass it on to the delegate.
20258 this.arg = undefined;
20259 }
20260
20261 return ContinueSentinel;
20262 }
20263 };
20264})(
20265 // In sloppy mode, unbound `this` refers to the global object, fallback to
20266 // Function constructor if we're in global strict mode. That is sadly a form
20267 // of indirect eval which violates Content Security Policy.
20268 (function() { return this })() || Function("return this")()
20269);
20270
20271},{}],259:[function(require,module,exports){
20272/* eslint-disable node/no-deprecated-api */
20273var buffer = require('buffer')
20274var Buffer = buffer.Buffer
20275
20276// alternative to using Object.keys for old browsers
20277function copyProps (src, dst) {
20278 for (var key in src) {
20279 dst[key] = src[key]
20280 }
20281}
20282if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
20283 module.exports = buffer
20284} else {
20285 // Copy properties from require('buffer')
20286 copyProps(buffer, exports)
20287 exports.Buffer = SafeBuffer
20288}
20289
20290function SafeBuffer (arg, encodingOrOffset, length) {
20291 return Buffer(arg, encodingOrOffset, length)
20292}
20293
20294// Copy static methods from Buffer
20295copyProps(Buffer, SafeBuffer)
20296
20297SafeBuffer.from = function (arg, encodingOrOffset, length) {
20298 if (typeof arg === 'number') {
20299 throw new TypeError('Argument must not be a number')
20300 }
20301 return Buffer(arg, encodingOrOffset, length)
20302}
20303
20304SafeBuffer.alloc = function (size, fill, encoding) {
20305 if (typeof size !== 'number') {
20306 throw new TypeError('Argument must be a number')
20307 }
20308 var buf = Buffer(size)
20309 if (fill !== undefined) {
20310 if (typeof encoding === 'string') {
20311 buf.fill(fill, encoding)
20312 } else {
20313 buf.fill(fill)
20314 }
20315 } else {
20316 buf.fill(0)
20317 }
20318 return buf
20319}
20320
20321SafeBuffer.allocUnsafe = function (size) {
20322 if (typeof size !== 'number') {
20323 throw new TypeError('Argument must be a number')
20324 }
20325 return Buffer(size)
20326}
20327
20328SafeBuffer.allocUnsafeSlow = function (size) {
20329 if (typeof size !== 'number') {
20330 throw new TypeError('Argument must be a number')
20331 }
20332 return buffer.SlowBuffer(size)
20333}
20334
20335},{"buffer":60}],260:[function(require,module,exports){
20336(function (Buffer){
20337'use strict';
20338
20339var _fromCodePoint = require('babel-runtime/core-js/string/from-code-point');
20340
20341var _fromCodePoint2 = _interopRequireDefault(_fromCodePoint);
20342
20343var _stringify = require('babel-runtime/core-js/json/stringify');
20344
20345var _stringify2 = _interopRequireDefault(_stringify);
20346
20347var _typeof2 = require('babel-runtime/helpers/typeof');
20348
20349var _typeof3 = _interopRequireDefault(_typeof2);
20350
20351var _defineProperty = require('babel-runtime/core-js/object/define-property');
20352
20353var _defineProperty2 = _interopRequireDefault(_defineProperty);
20354
20355var _keys = require('babel-runtime/core-js/object/keys');
20356
20357var _keys2 = _interopRequireDefault(_keys);
20358
20359var _create = require('babel-runtime/core-js/object/create');
20360
20361var _create2 = _interopRequireDefault(_create);
20362
20363function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20364
20365;(function (sax) {
20366 // wrapper for non-node envs
20367 sax.parser = function (strict, opt) {
20368 return new SAXParser(strict, opt);
20369 };
20370 sax.SAXParser = SAXParser;
20371 sax.SAXStream = SAXStream;
20372 sax.createStream = createStream;
20373
20374 // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
20375 // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
20376 // since that's the earliest that a buffer overrun could occur. This way, checks are
20377 // as rare as required, but as often as necessary to ensure never crossing this bound.
20378 // Furthermore, buffers are only tested at most once per write(), so passing a very
20379 // large string into write() might have undesirable effects, but this is manageable by
20380 // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
20381 // edge case, result in creating at most one complete copy of the string passed in.
20382 // Set to Infinity to have unlimited buffers.
20383 sax.MAX_BUFFER_LENGTH = 64 * 1024;
20384
20385 var buffers = ['comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype', 'procInstName', 'procInstBody', 'entity', 'attribName', 'attribValue', 'cdata', 'script'];
20386
20387 sax.EVENTS = ['text', 'processinginstruction', 'sgmldeclaration', 'doctype', 'comment', 'opentagstart', 'attribute', 'opentag', 'closetag', 'opencdata', 'cdata', 'closecdata', 'error', 'end', 'ready', 'script', 'opennamespace', 'closenamespace'];
20388
20389 function SAXParser(strict, opt) {
20390 if (!(this instanceof SAXParser)) {
20391 return new SAXParser(strict, opt);
20392 }
20393
20394 var parser = this;
20395 clearBuffers(parser);
20396 parser.q = parser.c = '';
20397 parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH;
20398 parser.opt = opt || {};
20399 parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags;
20400 parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase';
20401 parser.tags = [];
20402 parser.closed = parser.closedRoot = parser.sawRoot = false;
20403 parser.tag = parser.error = null;
20404 parser.strict = !!strict;
20405 parser.noscript = !!(strict || parser.opt.noscript);
20406 parser.state = S.BEGIN;
20407 parser.strictEntities = parser.opt.strictEntities;
20408 parser.ENTITIES = parser.strictEntities ? (0, _create2.default)(sax.XML_ENTITIES) : (0, _create2.default)(sax.ENTITIES);
20409 parser.attribList = [];
20410
20411 // namespaces form a prototype chain.
20412 // it always points at the current tag,
20413 // which protos to its parent tag.
20414 if (parser.opt.xmlns) {
20415 parser.ns = (0, _create2.default)(rootNS);
20416 }
20417
20418 // mostly just for error reporting
20419 parser.trackPosition = parser.opt.position !== false;
20420 if (parser.trackPosition) {
20421 parser.position = parser.line = parser.column = 0;
20422 }
20423 emit(parser, 'onready');
20424 }
20425
20426 if (!_create2.default) {
20427 Object.create = function (o) {
20428 function F() {}
20429 F.prototype = o;
20430 var newf = new F();
20431 return newf;
20432 };
20433 }
20434
20435 if (!_keys2.default) {
20436 Object.keys = function (o) {
20437 var a = [];
20438 for (var i in o) {
20439 if (o.hasOwnProperty(i)) a.push(i);
20440 }return a;
20441 };
20442 }
20443
20444 function checkBufferLength(parser) {
20445 var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10);
20446 var maxActual = 0;
20447 for (var i = 0, l = buffers.length; i < l; i++) {
20448 var len = parser[buffers[i]].length;
20449 if (len > maxAllowed) {
20450 // Text/cdata nodes can get big, and since they're buffered,
20451 // we can get here under normal conditions.
20452 // Avoid issues by emitting the text node now,
20453 // so at least it won't get any bigger.
20454 switch (buffers[i]) {
20455 case 'textNode':
20456 closeText(parser);
20457 break;
20458
20459 case 'cdata':
20460 emitNode(parser, 'oncdata', parser.cdata);
20461 parser.cdata = '';
20462 break;
20463
20464 case 'script':
20465 emitNode(parser, 'onscript', parser.script);
20466 parser.script = '';
20467 break;
20468
20469 default:
20470 error(parser, 'Max buffer length exceeded: ' + buffers[i]);
20471 }
20472 }
20473 maxActual = Math.max(maxActual, len);
20474 }
20475 // schedule the next check for the earliest possible buffer overrun.
20476 var m = sax.MAX_BUFFER_LENGTH - maxActual;
20477 parser.bufferCheckPosition = m + parser.position;
20478 }
20479
20480 function clearBuffers(parser) {
20481 for (var i = 0, l = buffers.length; i < l; i++) {
20482 parser[buffers[i]] = '';
20483 }
20484 }
20485
20486 function flushBuffers(parser) {
20487 closeText(parser);
20488 if (parser.cdata !== '') {
20489 emitNode(parser, 'oncdata', parser.cdata);
20490 parser.cdata = '';
20491 }
20492 if (parser.script !== '') {
20493 emitNode(parser, 'onscript', parser.script);
20494 parser.script = '';
20495 }
20496 }
20497
20498 SAXParser.prototype = {
20499 end: function end() {
20500 _end(this);
20501 },
20502 write: write,
20503 resume: function resume() {
20504 this.error = null;return this;
20505 },
20506 close: function close() {
20507 return this.write(null);
20508 },
20509 flush: function flush() {
20510 flushBuffers(this);
20511 }
20512 };
20513
20514 var Stream;
20515 try {
20516 Stream = require('stream').Stream;
20517 } catch (ex) {
20518 Stream = function Stream() {};
20519 }
20520
20521 var streamWraps = sax.EVENTS.filter(function (ev) {
20522 return ev !== 'error' && ev !== 'end';
20523 });
20524
20525 function createStream(strict, opt) {
20526 return new SAXStream(strict, opt);
20527 }
20528
20529 function SAXStream(strict, opt) {
20530 if (!(this instanceof SAXStream)) {
20531 return new SAXStream(strict, opt);
20532 }
20533
20534 Stream.apply(this);
20535
20536 this._parser = new SAXParser(strict, opt);
20537 this.writable = true;
20538 this.readable = true;
20539
20540 var me = this;
20541
20542 this._parser.onend = function () {
20543 me.emit('end');
20544 };
20545
20546 this._parser.onerror = function (er) {
20547 me.emit('error', er);
20548
20549 // if didn't throw, then means error was handled.
20550 // go ahead and clear error, so we can write again.
20551 me._parser.error = null;
20552 };
20553
20554 this._decoder = null;
20555
20556 streamWraps.forEach(function (ev) {
20557 (0, _defineProperty2.default)(me, 'on' + ev, {
20558 get: function get() {
20559 return me._parser['on' + ev];
20560 },
20561 set: function set(h) {
20562 if (!h) {
20563 me.removeAllListeners(ev);
20564 me._parser['on' + ev] = h;
20565 return h;
20566 }
20567 me.on(ev, h);
20568 },
20569 enumerable: true,
20570 configurable: false
20571 });
20572 });
20573 }
20574
20575 SAXStream.prototype = (0, _create2.default)(Stream.prototype, {
20576 constructor: {
20577 value: SAXStream
20578 }
20579 });
20580
20581 SAXStream.prototype.write = function (data) {
20582 if (typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function' && Buffer.isBuffer(data)) {
20583 if (!this._decoder) {
20584 var SD = require('string_decoder').StringDecoder;
20585 this._decoder = new SD('utf8');
20586 }
20587 data = this._decoder.write(data);
20588 }
20589
20590 this._parser.write(data.toString());
20591 this.emit('data', data);
20592 return true;
20593 };
20594
20595 SAXStream.prototype.end = function (chunk) {
20596 if (chunk && chunk.length) {
20597 this.write(chunk);
20598 }
20599 this._parser.end();
20600 return true;
20601 };
20602
20603 SAXStream.prototype.on = function (ev, handler) {
20604 var me = this;
20605 if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {
20606 me._parser['on' + ev] = function () {
20607 var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
20608 args.splice(0, 0, ev);
20609 me.emit.apply(me, args);
20610 };
20611 }
20612
20613 return Stream.prototype.on.call(me, ev, handler);
20614 };
20615
20616 // this really needs to be replaced with character classes.
20617 // XML allows all manner of ridiculous numbers and digits.
20618 var CDATA = '[CDATA[';
20619 var DOCTYPE = 'DOCTYPE';
20620 var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
20621 var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/';
20622 var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE
20623
20624 // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
20625 // This implementation works on strings, a single character at a time
20626 // as such, it cannot ever support astral-plane characters (10000-EFFFF)
20627 // without a significant breaking change to either this parser, or the
20628 // JavaScript language. Implementation of an emoji-capable xml parser
20629 // is left as an exercise for the reader.
20630 };var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
20631
20632 var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
20633
20634 var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
20635 var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
20636
20637 function isWhitespace(c) {
20638 return c === ' ' || c === '\n' || c === '\r' || c === '\t';
20639 }
20640
20641 function isQuote(c) {
20642 return c === '"' || c === '\'';
20643 }
20644
20645 function isAttribEnd(c) {
20646 return c === '>' || isWhitespace(c);
20647 }
20648
20649 function isMatch(regex, c) {
20650 return regex.test(c);
20651 }
20652
20653 function notMatch(regex, c) {
20654 return !isMatch(regex, c);
20655 }
20656
20657 var S = 0;
20658 sax.STATE = {
20659 BEGIN: S++, // leading byte order mark or whitespace
20660 BEGIN_WHITESPACE: S++, // leading whitespace
20661 TEXT: S++, // general stuff
20662 TEXT_ENTITY: S++, // &amp and such.
20663 OPEN_WAKA: S++, // <
20664 SGML_DECL: S++, // <!BLARG
20665 SGML_DECL_QUOTED: S++, // <!BLARG foo "bar
20666 DOCTYPE: S++, // <!DOCTYPE
20667 DOCTYPE_QUOTED: S++, // <!DOCTYPE "//blah
20668 DOCTYPE_DTD: S++, // <!DOCTYPE "//blah" [ ...
20669 DOCTYPE_DTD_QUOTED: S++, // <!DOCTYPE "//blah" [ "foo
20670 COMMENT_STARTING: S++, // <!-
20671 COMMENT: S++, // <!--
20672 COMMENT_ENDING: S++, // <!-- blah -
20673 COMMENT_ENDED: S++, // <!-- blah --
20674 CDATA: S++, // <![CDATA[ something
20675 CDATA_ENDING: S++, // ]
20676 CDATA_ENDING_2: S++, // ]]
20677 PROC_INST: S++, // <?hi
20678 PROC_INST_BODY: S++, // <?hi there
20679 PROC_INST_ENDING: S++, // <?hi "there" ?
20680 OPEN_TAG: S++, // <strong
20681 OPEN_TAG_SLASH: S++, // <strong /
20682 ATTRIB: S++, // <a
20683 ATTRIB_NAME: S++, // <a foo
20684 ATTRIB_NAME_SAW_WHITE: S++, // <a foo _
20685 ATTRIB_VALUE: S++, // <a foo=
20686 ATTRIB_VALUE_QUOTED: S++, // <a foo="bar
20687 ATTRIB_VALUE_CLOSED: S++, // <a foo="bar"
20688 ATTRIB_VALUE_UNQUOTED: S++, // <a foo=bar
20689 ATTRIB_VALUE_ENTITY_Q: S++, // <foo bar="&quot;"
20690 ATTRIB_VALUE_ENTITY_U: S++, // <foo bar=&quot
20691 CLOSE_TAG: S++, // </a
20692 CLOSE_TAG_SAW_WHITE: S++, // </a >
20693 SCRIPT: S++, // <script> ...
20694 SCRIPT_ENDING: S++ // <script> ... <
20695 };
20696
20697 sax.XML_ENTITIES = {
20698 'amp': '&',
20699 'gt': '>',
20700 'lt': '<',
20701 'quot': '"',
20702 'apos': "'"
20703 };
20704
20705 sax.ENTITIES = {
20706 'amp': '&',
20707 'gt': '>',
20708 'lt': '<',
20709 'quot': '"',
20710 'apos': "'",
20711 'AElig': 198,
20712 'Aacute': 193,
20713 'Acirc': 194,
20714 'Agrave': 192,
20715 'Aring': 197,
20716 'Atilde': 195,
20717 'Auml': 196,
20718 'Ccedil': 199,
20719 'ETH': 208,
20720 'Eacute': 201,
20721 'Ecirc': 202,
20722 'Egrave': 200,
20723 'Euml': 203,
20724 'Iacute': 205,
20725 'Icirc': 206,
20726 'Igrave': 204,
20727 'Iuml': 207,
20728 'Ntilde': 209,
20729 'Oacute': 211,
20730 'Ocirc': 212,
20731 'Ograve': 210,
20732 'Oslash': 216,
20733 'Otilde': 213,
20734 'Ouml': 214,
20735 'THORN': 222,
20736 'Uacute': 218,
20737 'Ucirc': 219,
20738 'Ugrave': 217,
20739 'Uuml': 220,
20740 'Yacute': 221,
20741 'aacute': 225,
20742 'acirc': 226,
20743 'aelig': 230,
20744 'agrave': 224,
20745 'aring': 229,
20746 'atilde': 227,
20747 'auml': 228,
20748 'ccedil': 231,
20749 'eacute': 233,
20750 'ecirc': 234,
20751 'egrave': 232,
20752 'eth': 240,
20753 'euml': 235,
20754 'iacute': 237,
20755 'icirc': 238,
20756 'igrave': 236,
20757 'iuml': 239,
20758 'ntilde': 241,
20759 'oacute': 243,
20760 'ocirc': 244,
20761 'ograve': 242,
20762 'oslash': 248,
20763 'otilde': 245,
20764 'ouml': 246,
20765 'szlig': 223,
20766 'thorn': 254,
20767 'uacute': 250,
20768 'ucirc': 251,
20769 'ugrave': 249,
20770 'uuml': 252,
20771 'yacute': 253,
20772 'yuml': 255,
20773 'copy': 169,
20774 'reg': 174,
20775 'nbsp': 160,
20776 'iexcl': 161,
20777 'cent': 162,
20778 'pound': 163,
20779 'curren': 164,
20780 'yen': 165,
20781 'brvbar': 166,
20782 'sect': 167,
20783 'uml': 168,
20784 'ordf': 170,
20785 'laquo': 171,
20786 'not': 172,
20787 'shy': 173,
20788 'macr': 175,
20789 'deg': 176,
20790 'plusmn': 177,
20791 'sup1': 185,
20792 'sup2': 178,
20793 'sup3': 179,
20794 'acute': 180,
20795 'micro': 181,
20796 'para': 182,
20797 'middot': 183,
20798 'cedil': 184,
20799 'ordm': 186,
20800 'raquo': 187,
20801 'frac14': 188,
20802 'frac12': 189,
20803 'frac34': 190,
20804 'iquest': 191,
20805 'times': 215,
20806 'divide': 247,
20807 'OElig': 338,
20808 'oelig': 339,
20809 'Scaron': 352,
20810 'scaron': 353,
20811 'Yuml': 376,
20812 'fnof': 402,
20813 'circ': 710,
20814 'tilde': 732,
20815 'Alpha': 913,
20816 'Beta': 914,
20817 'Gamma': 915,
20818 'Delta': 916,
20819 'Epsilon': 917,
20820 'Zeta': 918,
20821 'Eta': 919,
20822 'Theta': 920,
20823 'Iota': 921,
20824 'Kappa': 922,
20825 'Lambda': 923,
20826 'Mu': 924,
20827 'Nu': 925,
20828 'Xi': 926,
20829 'Omicron': 927,
20830 'Pi': 928,
20831 'Rho': 929,
20832 'Sigma': 931,
20833 'Tau': 932,
20834 'Upsilon': 933,
20835 'Phi': 934,
20836 'Chi': 935,
20837 'Psi': 936,
20838 'Omega': 937,
20839 'alpha': 945,
20840 'beta': 946,
20841 'gamma': 947,
20842 'delta': 948,
20843 'epsilon': 949,
20844 'zeta': 950,
20845 'eta': 951,
20846 'theta': 952,
20847 'iota': 953,
20848 'kappa': 954,
20849 'lambda': 955,
20850 'mu': 956,
20851 'nu': 957,
20852 'xi': 958,
20853 'omicron': 959,
20854 'pi': 960,
20855 'rho': 961,
20856 'sigmaf': 962,
20857 'sigma': 963,
20858 'tau': 964,
20859 'upsilon': 965,
20860 'phi': 966,
20861 'chi': 967,
20862 'psi': 968,
20863 'omega': 969,
20864 'thetasym': 977,
20865 'upsih': 978,
20866 'piv': 982,
20867 'ensp': 8194,
20868 'emsp': 8195,
20869 'thinsp': 8201,
20870 'zwnj': 8204,
20871 'zwj': 8205,
20872 'lrm': 8206,
20873 'rlm': 8207,
20874 'ndash': 8211,
20875 'mdash': 8212,
20876 'lsquo': 8216,
20877 'rsquo': 8217,
20878 'sbquo': 8218,
20879 'ldquo': 8220,
20880 'rdquo': 8221,
20881 'bdquo': 8222,
20882 'dagger': 8224,
20883 'Dagger': 8225,
20884 'bull': 8226,
20885 'hellip': 8230,
20886 'permil': 8240,
20887 'prime': 8242,
20888 'Prime': 8243,
20889 'lsaquo': 8249,
20890 'rsaquo': 8250,
20891 'oline': 8254,
20892 'frasl': 8260,
20893 'euro': 8364,
20894 'image': 8465,
20895 'weierp': 8472,
20896 'real': 8476,
20897 'trade': 8482,
20898 'alefsym': 8501,
20899 'larr': 8592,
20900 'uarr': 8593,
20901 'rarr': 8594,
20902 'darr': 8595,
20903 'harr': 8596,
20904 'crarr': 8629,
20905 'lArr': 8656,
20906 'uArr': 8657,
20907 'rArr': 8658,
20908 'dArr': 8659,
20909 'hArr': 8660,
20910 'forall': 8704,
20911 'part': 8706,
20912 'exist': 8707,
20913 'empty': 8709,
20914 'nabla': 8711,
20915 'isin': 8712,
20916 'notin': 8713,
20917 'ni': 8715,
20918 'prod': 8719,
20919 'sum': 8721,
20920 'minus': 8722,
20921 'lowast': 8727,
20922 'radic': 8730,
20923 'prop': 8733,
20924 'infin': 8734,
20925 'ang': 8736,
20926 'and': 8743,
20927 'or': 8744,
20928 'cap': 8745,
20929 'cup': 8746,
20930 'int': 8747,
20931 'there4': 8756,
20932 'sim': 8764,
20933 'cong': 8773,
20934 'asymp': 8776,
20935 'ne': 8800,
20936 'equiv': 8801,
20937 'le': 8804,
20938 'ge': 8805,
20939 'sub': 8834,
20940 'sup': 8835,
20941 'nsub': 8836,
20942 'sube': 8838,
20943 'supe': 8839,
20944 'oplus': 8853,
20945 'otimes': 8855,
20946 'perp': 8869,
20947 'sdot': 8901,
20948 'lceil': 8968,
20949 'rceil': 8969,
20950 'lfloor': 8970,
20951 'rfloor': 8971,
20952 'lang': 9001,
20953 'rang': 9002,
20954 'loz': 9674,
20955 'spades': 9824,
20956 'clubs': 9827,
20957 'hearts': 9829,
20958 'diams': 9830
20959 };
20960
20961 (0, _keys2.default)(sax.ENTITIES).forEach(function (key) {
20962 var e = sax.ENTITIES[key];
20963 var s = typeof e === 'number' ? String.fromCharCode(e) : e;
20964 sax.ENTITIES[key] = s;
20965 });
20966
20967 for (var s in sax.STATE) {
20968 sax.STATE[sax.STATE[s]] = s;
20969 }
20970
20971 // shorthand
20972 S = sax.STATE;
20973
20974 function emit(parser, event, data) {
20975 parser[event] && parser[event](data);
20976 }
20977
20978 function emitNode(parser, nodeType, data) {
20979 if (parser.textNode) closeText(parser);
20980 emit(parser, nodeType, data);
20981 }
20982
20983 function closeText(parser) {
20984 parser.textNode = textopts(parser.opt, parser.textNode);
20985 if (parser.textNode) emit(parser, 'ontext', parser.textNode);
20986 parser.textNode = '';
20987 }
20988
20989 function textopts(opt, text) {
20990 if (opt.trim) text = text.trim();
20991 if (opt.normalize) text = text.replace(/\s+/g, ' ');
20992 return text;
20993 }
20994
20995 function error(parser, er) {
20996 closeText(parser);
20997 if (parser.trackPosition) {
20998 er += '\nLine: ' + parser.line + '\nColumn: ' + parser.column + '\nChar: ' + parser.c;
20999 }
21000 er = new Error(er);
21001 parser.error = er;
21002 emit(parser, 'onerror', er);
21003 return parser;
21004 }
21005
21006 function _end(parser) {
21007 if (parser.sawRoot && !parser.closedRoot) strictFail(parser, 'Unclosed root tag');
21008 if (parser.state !== S.BEGIN && parser.state !== S.BEGIN_WHITESPACE && parser.state !== S.TEXT) {
21009 error(parser, 'Unexpected end');
21010 }
21011 closeText(parser);
21012 parser.c = '';
21013 parser.closed = true;
21014 emit(parser, 'onend');
21015 SAXParser.call(parser, parser.strict, parser.opt);
21016 return parser;
21017 }
21018
21019 function strictFail(parser, message) {
21020 if ((typeof parser === 'undefined' ? 'undefined' : (0, _typeof3.default)(parser)) !== 'object' || !(parser instanceof SAXParser)) {
21021 throw new Error('bad call to strictFail');
21022 }
21023 if (parser.strict) {
21024 error(parser, message);
21025 }
21026 }
21027
21028 function newTag(parser) {
21029 if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]();
21030 var parent = parser.tags[parser.tags.length - 1] || parser;
21031 var tag = parser.tag = { name: parser.tagName, attributes: {}
21032
21033 // will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
21034 };if (parser.opt.xmlns) {
21035 tag.ns = parent.ns;
21036 }
21037 parser.attribList.length = 0;
21038 emitNode(parser, 'onopentagstart', tag);
21039 }
21040
21041 function qname(name, attribute) {
21042 var i = name.indexOf(':');
21043 var qualName = i < 0 ? ['', name] : name.split(':');
21044 var prefix = qualName[0];
21045 var local = qualName[1];
21046
21047 // <x "xmlns"="http://foo">
21048 if (attribute && name === 'xmlns') {
21049 prefix = 'xmlns';
21050 local = '';
21051 }
21052
21053 return { prefix: prefix, local: local };
21054 }
21055
21056 function attrib(parser) {
21057 if (!parser.strict) {
21058 parser.attribName = parser.attribName[parser.looseCase]();
21059 }
21060
21061 if (parser.attribList.indexOf(parser.attribName) !== -1 || parser.tag.attributes.hasOwnProperty(parser.attribName)) {
21062 parser.attribName = parser.attribValue = '';
21063 return;
21064 }
21065
21066 if (parser.opt.xmlns) {
21067 var qn = qname(parser.attribName, true);
21068 var prefix = qn.prefix;
21069 var local = qn.local;
21070
21071 if (prefix === 'xmlns') {
21072 // namespace binding attribute. push the binding into scope
21073 if (local === 'xml' && parser.attribValue !== XML_NAMESPACE) {
21074 strictFail(parser, 'xml: prefix must be bound to ' + XML_NAMESPACE + '\n' + 'Actual: ' + parser.attribValue);
21075 } else if (local === 'xmlns' && parser.attribValue !== XMLNS_NAMESPACE) {
21076 strictFail(parser, 'xmlns: prefix must be bound to ' + XMLNS_NAMESPACE + '\n' + 'Actual: ' + parser.attribValue);
21077 } else {
21078 var tag = parser.tag;
21079 var parent = parser.tags[parser.tags.length - 1] || parser;
21080 if (tag.ns === parent.ns) {
21081 tag.ns = (0, _create2.default)(parent.ns);
21082 }
21083 tag.ns[local] = parser.attribValue;
21084 }
21085 }
21086
21087 // defer onattribute events until all attributes have been seen
21088 // so any new bindings can take effect. preserve attribute order
21089 // so deferred events can be emitted in document order
21090 parser.attribList.push([parser.attribName, parser.attribValue]);
21091 } else {
21092 // in non-xmlns mode, we can emit the event right away
21093 parser.tag.attributes[parser.attribName] = parser.attribValue;
21094 emitNode(parser, 'onattribute', {
21095 name: parser.attribName,
21096 value: parser.attribValue
21097 });
21098 }
21099
21100 parser.attribName = parser.attribValue = '';
21101 }
21102
21103 function openTag(parser, selfClosing) {
21104 if (parser.opt.xmlns) {
21105 // emit namespace binding events
21106 var tag = parser.tag;
21107
21108 // add namespace info to tag
21109 var qn = qname(parser.tagName);
21110 tag.prefix = qn.prefix;
21111 tag.local = qn.local;
21112 tag.uri = tag.ns[qn.prefix] || '';
21113
21114 if (tag.prefix && !tag.uri) {
21115 strictFail(parser, 'Unbound namespace prefix: ' + (0, _stringify2.default)(parser.tagName));
21116 tag.uri = qn.prefix;
21117 }
21118
21119 var parent = parser.tags[parser.tags.length - 1] || parser;
21120 if (tag.ns && parent.ns !== tag.ns) {
21121 (0, _keys2.default)(tag.ns).forEach(function (p) {
21122 emitNode(parser, 'onopennamespace', {
21123 prefix: p,
21124 uri: tag.ns[p]
21125 });
21126 });
21127 }
21128
21129 // handle deferred onattribute events
21130 // Note: do not apply default ns to attributes:
21131 // http://www.w3.org/TR/REC-xml-names/#defaulting
21132 for (var i = 0, l = parser.attribList.length; i < l; i++) {
21133 var nv = parser.attribList[i];
21134 var name = nv[0];
21135 var value = nv[1];
21136 var qualName = qname(name, true);
21137 var prefix = qualName.prefix;
21138 var local = qualName.local;
21139 var uri = prefix === '' ? '' : tag.ns[prefix] || '';
21140 var a = {
21141 name: name,
21142 value: value,
21143 prefix: prefix,
21144 local: local,
21145 uri: uri
21146
21147 // if there's any attributes with an undefined namespace,
21148 // then fail on them now.
21149 };if (prefix && prefix !== 'xmlns' && !uri) {
21150 strictFail(parser, 'Unbound namespace prefix: ' + (0, _stringify2.default)(prefix));
21151 a.uri = prefix;
21152 }
21153 parser.tag.attributes[name] = a;
21154 emitNode(parser, 'onattribute', a);
21155 }
21156 parser.attribList.length = 0;
21157 }
21158
21159 parser.tag.isSelfClosing = !!selfClosing;
21160
21161 // process the tag
21162 parser.sawRoot = true;
21163 parser.tags.push(parser.tag);
21164 emitNode(parser, 'onopentag', parser.tag);
21165 if (!selfClosing) {
21166 // special case for <script> in non-strict mode.
21167 if (!parser.noscript && parser.tagName.toLowerCase() === 'script') {
21168 parser.state = S.SCRIPT;
21169 } else {
21170 parser.state = S.TEXT;
21171 }
21172 parser.tag = null;
21173 parser.tagName = '';
21174 }
21175 parser.attribName = parser.attribValue = '';
21176 parser.attribList.length = 0;
21177 }
21178
21179 function closeTag(parser) {
21180 if (!parser.tagName) {
21181 strictFail(parser, 'Weird empty close tag.');
21182 parser.textNode += '</>';
21183 parser.state = S.TEXT;
21184 return;
21185 }
21186
21187 if (parser.script) {
21188 if (parser.tagName !== 'script') {
21189 parser.script += '</' + parser.tagName + '>';
21190 parser.tagName = '';
21191 parser.state = S.SCRIPT;
21192 return;
21193 }
21194 emitNode(parser, 'onscript', parser.script);
21195 parser.script = '';
21196 }
21197
21198 // first make sure that the closing tag actually exists.
21199 // <a><b></c></b></a> will close everything, otherwise.
21200 var t = parser.tags.length;
21201 var tagName = parser.tagName;
21202 if (!parser.strict) {
21203 tagName = tagName[parser.looseCase]();
21204 }
21205 var closeTo = tagName;
21206 while (t--) {
21207 var close = parser.tags[t];
21208 if (close.name !== closeTo) {
21209 // fail the first time in strict mode
21210 strictFail(parser, 'Unexpected close tag');
21211 } else {
21212 break;
21213 }
21214 }
21215
21216 // didn't find it. we already failed for strict, so just abort.
21217 if (t < 0) {
21218 strictFail(parser, 'Unmatched closing tag: ' + parser.tagName);
21219 parser.textNode += '</' + parser.tagName + '>';
21220 parser.state = S.TEXT;
21221 return;
21222 }
21223 parser.tagName = tagName;
21224 var s = parser.tags.length;
21225 while (s-- > t) {
21226 var tag = parser.tag = parser.tags.pop();
21227 parser.tagName = parser.tag.name;
21228 emitNode(parser, 'onclosetag', parser.tagName);
21229
21230 var x = {};
21231 for (var i in tag.ns) {
21232 x[i] = tag.ns[i];
21233 }
21234
21235 var parent = parser.tags[parser.tags.length - 1] || parser;
21236 if (parser.opt.xmlns && tag.ns !== parent.ns) {
21237 // remove namespace bindings introduced by tag
21238 (0, _keys2.default)(tag.ns).forEach(function (p) {
21239 var n = tag.ns[p];
21240 emitNode(parser, 'onclosenamespace', { prefix: p, uri: n });
21241 });
21242 }
21243 }
21244 if (t === 0) parser.closedRoot = true;
21245 parser.tagName = parser.attribValue = parser.attribName = '';
21246 parser.attribList.length = 0;
21247 parser.state = S.TEXT;
21248 }
21249
21250 function parseEntity(parser) {
21251 var entity = parser.entity;
21252 var entityLC = entity.toLowerCase();
21253 var num;
21254 var numStr = '';
21255
21256 if (parser.ENTITIES[entity]) {
21257 return parser.ENTITIES[entity];
21258 }
21259 if (parser.ENTITIES[entityLC]) {
21260 return parser.ENTITIES[entityLC];
21261 }
21262 entity = entityLC;
21263 if (entity.charAt(0) === '#') {
21264 if (entity.charAt(1) === 'x') {
21265 entity = entity.slice(2);
21266 num = parseInt(entity, 16);
21267 numStr = num.toString(16);
21268 } else {
21269 entity = entity.slice(1);
21270 num = parseInt(entity, 10);
21271 numStr = num.toString(10);
21272 }
21273 }
21274 entity = entity.replace(/^0+/, '');
21275 if (isNaN(num) || numStr.toLowerCase() !== entity) {
21276 strictFail(parser, 'Invalid character entity');
21277 return '&' + parser.entity + ';';
21278 }
21279
21280 return (0, _fromCodePoint2.default)(num);
21281 }
21282
21283 function beginWhiteSpace(parser, c) {
21284 if (c === '<') {
21285 parser.state = S.OPEN_WAKA;
21286 parser.startTagPosition = parser.position;
21287 } else if (!isWhitespace(c)) {
21288 // have to process this as a text node.
21289 // weird, but happens.
21290 strictFail(parser, 'Non-whitespace before first tag.');
21291 parser.textNode = c;
21292 parser.state = S.TEXT;
21293 }
21294 }
21295
21296 function charAt(chunk, i) {
21297 var result = '';
21298 if (i < chunk.length) {
21299 result = chunk.charAt(i);
21300 }
21301 return result;
21302 }
21303
21304 function write(chunk) {
21305 var parser = this;
21306 if (this.error) {
21307 throw this.error;
21308 }
21309 if (parser.closed) {
21310 return error(parser, 'Cannot write after close. Assign an onready handler.');
21311 }
21312 if (chunk === null) {
21313 return _end(parser);
21314 }
21315 if ((typeof chunk === 'undefined' ? 'undefined' : (0, _typeof3.default)(chunk)) === 'object') {
21316 chunk = chunk.toString();
21317 }
21318 var i = 0;
21319 var c = '';
21320 while (true) {
21321 c = charAt(chunk, i++);
21322 parser.c = c;
21323
21324 if (!c) {
21325 break;
21326 }
21327
21328 if (parser.trackPosition) {
21329 parser.position++;
21330 if (c === '\n') {
21331 parser.line++;
21332 parser.column = 0;
21333 } else {
21334 parser.column++;
21335 }
21336 }
21337
21338 switch (parser.state) {
21339 case S.BEGIN:
21340 parser.state = S.BEGIN_WHITESPACE;
21341 if (c === '\uFEFF') {
21342 continue;
21343 }
21344 beginWhiteSpace(parser, c);
21345 continue;
21346
21347 case S.BEGIN_WHITESPACE:
21348 beginWhiteSpace(parser, c);
21349 continue;
21350
21351 case S.TEXT:
21352 if (parser.sawRoot && !parser.closedRoot) {
21353 var starti = i - 1;
21354 while (c && c !== '<' && c !== '&') {
21355 c = charAt(chunk, i++);
21356 if (c && parser.trackPosition) {
21357 parser.position++;
21358 if (c === '\n') {
21359 parser.line++;
21360 parser.column = 0;
21361 } else {
21362 parser.column++;
21363 }
21364 }
21365 }
21366 parser.textNode += chunk.substring(starti, i - 1);
21367 }
21368 if (c === '<' && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {
21369 parser.state = S.OPEN_WAKA;
21370 parser.startTagPosition = parser.position;
21371 } else {
21372 if (!isWhitespace(c) && (!parser.sawRoot || parser.closedRoot)) {
21373 strictFail(parser, 'Text data outside of root node.');
21374 }
21375 if (c === '&') {
21376 parser.state = S.TEXT_ENTITY;
21377 } else {
21378 parser.textNode += c;
21379 }
21380 }
21381 continue;
21382
21383 case S.SCRIPT:
21384 // only non-strict
21385 if (c === '<') {
21386 parser.state = S.SCRIPT_ENDING;
21387 } else {
21388 parser.script += c;
21389 }
21390 continue;
21391
21392 case S.SCRIPT_ENDING:
21393 if (c === '/') {
21394 parser.state = S.CLOSE_TAG;
21395 } else {
21396 parser.script += '<' + c;
21397 parser.state = S.SCRIPT;
21398 }
21399 continue;
21400
21401 case S.OPEN_WAKA:
21402 // either a /, ?, !, or text is coming next.
21403 if (c === '!') {
21404 parser.state = S.SGML_DECL;
21405 parser.sgmlDecl = '';
21406 } else if (isWhitespace(c)) {
21407 // wait for it...
21408 } else if (isMatch(nameStart, c)) {
21409 parser.state = S.OPEN_TAG;
21410 parser.tagName = c;
21411 } else if (c === '/') {
21412 parser.state = S.CLOSE_TAG;
21413 parser.tagName = '';
21414 } else if (c === '?') {
21415 parser.state = S.PROC_INST;
21416 parser.procInstName = parser.procInstBody = '';
21417 } else {
21418 strictFail(parser, 'Unencoded <');
21419 // if there was some whitespace, then add that in.
21420 if (parser.startTagPosition + 1 < parser.position) {
21421 var pad = parser.position - parser.startTagPosition;
21422 c = new Array(pad).join(' ') + c;
21423 }
21424 parser.textNode += '<' + c;
21425 parser.state = S.TEXT;
21426 }
21427 continue;
21428
21429 case S.SGML_DECL:
21430 if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
21431 emitNode(parser, 'onopencdata');
21432 parser.state = S.CDATA;
21433 parser.sgmlDecl = '';
21434 parser.cdata = '';
21435 } else if (parser.sgmlDecl + c === '--') {
21436 parser.state = S.COMMENT;
21437 parser.comment = '';
21438 parser.sgmlDecl = '';
21439 } else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
21440 parser.state = S.DOCTYPE;
21441 if (parser.doctype || parser.sawRoot) {
21442 strictFail(parser, 'Inappropriately located doctype declaration');
21443 }
21444 parser.doctype = '';
21445 parser.sgmlDecl = '';
21446 } else if (c === '>') {
21447 emitNode(parser, 'onsgmldeclaration', parser.sgmlDecl);
21448 parser.sgmlDecl = '';
21449 parser.state = S.TEXT;
21450 } else if (isQuote(c)) {
21451 parser.state = S.SGML_DECL_QUOTED;
21452 parser.sgmlDecl += c;
21453 } else {
21454 parser.sgmlDecl += c;
21455 }
21456 continue;
21457
21458 case S.SGML_DECL_QUOTED:
21459 if (c === parser.q) {
21460 parser.state = S.SGML_DECL;
21461 parser.q = '';
21462 }
21463 parser.sgmlDecl += c;
21464 continue;
21465
21466 case S.DOCTYPE:
21467 if (c === '>') {
21468 parser.state = S.TEXT;
21469 emitNode(parser, 'ondoctype', parser.doctype);
21470 parser.doctype = true; // just remember that we saw it.
21471 } else {
21472 parser.doctype += c;
21473 if (c === '[') {
21474 parser.state = S.DOCTYPE_DTD;
21475 } else if (isQuote(c)) {
21476 parser.state = S.DOCTYPE_QUOTED;
21477 parser.q = c;
21478 }
21479 }
21480 continue;
21481
21482 case S.DOCTYPE_QUOTED:
21483 parser.doctype += c;
21484 if (c === parser.q) {
21485 parser.q = '';
21486 parser.state = S.DOCTYPE;
21487 }
21488 continue;
21489
21490 case S.DOCTYPE_DTD:
21491 parser.doctype += c;
21492 if (c === ']') {
21493 parser.state = S.DOCTYPE;
21494 } else if (isQuote(c)) {
21495 parser.state = S.DOCTYPE_DTD_QUOTED;
21496 parser.q = c;
21497 }
21498 continue;
21499
21500 case S.DOCTYPE_DTD_QUOTED:
21501 parser.doctype += c;
21502 if (c === parser.q) {
21503 parser.state = S.DOCTYPE_DTD;
21504 parser.q = '';
21505 }
21506 continue;
21507
21508 case S.COMMENT:
21509 if (c === '-') {
21510 parser.state = S.COMMENT_ENDING;
21511 } else {
21512 parser.comment += c;
21513 }
21514 continue;
21515
21516 case S.COMMENT_ENDING:
21517 if (c === '-') {
21518 parser.state = S.COMMENT_ENDED;
21519 parser.comment = textopts(parser.opt, parser.comment);
21520 if (parser.comment) {
21521 emitNode(parser, 'oncomment', parser.comment);
21522 }
21523 parser.comment = '';
21524 } else {
21525 parser.comment += '-' + c;
21526 parser.state = S.COMMENT;
21527 }
21528 continue;
21529
21530 case S.COMMENT_ENDED:
21531 if (c !== '>') {
21532 strictFail(parser, 'Malformed comment');
21533 // allow <!-- blah -- bloo --> in non-strict mode,
21534 // which is a comment of " blah -- bloo "
21535 parser.comment += '--' + c;
21536 parser.state = S.COMMENT;
21537 } else {
21538 parser.state = S.TEXT;
21539 }
21540 continue;
21541
21542 case S.CDATA:
21543 if (c === ']') {
21544 parser.state = S.CDATA_ENDING;
21545 } else {
21546 parser.cdata += c;
21547 }
21548 continue;
21549
21550 case S.CDATA_ENDING:
21551 if (c === ']') {
21552 parser.state = S.CDATA_ENDING_2;
21553 } else {
21554 parser.cdata += ']' + c;
21555 parser.state = S.CDATA;
21556 }
21557 continue;
21558
21559 case S.CDATA_ENDING_2:
21560 if (c === '>') {
21561 if (parser.cdata) {
21562 emitNode(parser, 'oncdata', parser.cdata);
21563 }
21564 emitNode(parser, 'onclosecdata');
21565 parser.cdata = '';
21566 parser.state = S.TEXT;
21567 } else if (c === ']') {
21568 parser.cdata += ']';
21569 } else {
21570 parser.cdata += ']]' + c;
21571 parser.state = S.CDATA;
21572 }
21573 continue;
21574
21575 case S.PROC_INST:
21576 if (c === '?') {
21577 parser.state = S.PROC_INST_ENDING;
21578 } else if (isWhitespace(c)) {
21579 parser.state = S.PROC_INST_BODY;
21580 } else {
21581 parser.procInstName += c;
21582 }
21583 continue;
21584
21585 case S.PROC_INST_BODY:
21586 if (!parser.procInstBody && isWhitespace(c)) {
21587 continue;
21588 } else if (c === '?') {
21589 parser.state = S.PROC_INST_ENDING;
21590 } else {
21591 parser.procInstBody += c;
21592 }
21593 continue;
21594
21595 case S.PROC_INST_ENDING:
21596 if (c === '>') {
21597 emitNode(parser, 'onprocessinginstruction', {
21598 name: parser.procInstName,
21599 body: parser.procInstBody
21600 });
21601 parser.procInstName = parser.procInstBody = '';
21602 parser.state = S.TEXT;
21603 } else {
21604 parser.procInstBody += '?' + c;
21605 parser.state = S.PROC_INST_BODY;
21606 }
21607 continue;
21608
21609 case S.OPEN_TAG:
21610 if (isMatch(nameBody, c)) {
21611 parser.tagName += c;
21612 } else {
21613 newTag(parser);
21614 if (c === '>') {
21615 openTag(parser);
21616 } else if (c === '/') {
21617 parser.state = S.OPEN_TAG_SLASH;
21618 } else {
21619 if (!isWhitespace(c)) {
21620 strictFail(parser, 'Invalid character in tag name');
21621 }
21622 parser.state = S.ATTRIB;
21623 }
21624 }
21625 continue;
21626
21627 case S.OPEN_TAG_SLASH:
21628 if (c === '>') {
21629 openTag(parser, true);
21630 closeTag(parser);
21631 } else {
21632 strictFail(parser, 'Forward-slash in opening tag not followed by >');
21633 parser.state = S.ATTRIB;
21634 }
21635 continue;
21636
21637 case S.ATTRIB:
21638 // haven't read the attribute name yet.
21639 if (isWhitespace(c)) {
21640 continue;
21641 } else if (c === '>') {
21642 openTag(parser);
21643 } else if (c === '/') {
21644 parser.state = S.OPEN_TAG_SLASH;
21645 } else if (isMatch(nameStart, c)) {
21646 parser.attribName = c;
21647 parser.attribValue = '';
21648 parser.state = S.ATTRIB_NAME;
21649 } else {
21650 strictFail(parser, 'Invalid attribute name');
21651 }
21652 continue;
21653
21654 case S.ATTRIB_NAME:
21655 if (c === '=') {
21656 parser.state = S.ATTRIB_VALUE;
21657 } else if (c === '>') {
21658 strictFail(parser, 'Attribute without value');
21659 parser.attribValue = parser.attribName;
21660 attrib(parser);
21661 openTag(parser);
21662 } else if (isWhitespace(c)) {
21663 parser.state = S.ATTRIB_NAME_SAW_WHITE;
21664 } else if (isMatch(nameBody, c)) {
21665 parser.attribName += c;
21666 } else {
21667 strictFail(parser, 'Invalid attribute name');
21668 }
21669 continue;
21670
21671 case S.ATTRIB_NAME_SAW_WHITE:
21672 if (c === '=') {
21673 parser.state = S.ATTRIB_VALUE;
21674 } else if (isWhitespace(c)) {
21675 continue;
21676 } else {
21677 strictFail(parser, 'Attribute without value');
21678 parser.tag.attributes[parser.attribName] = '';
21679 parser.attribValue = '';
21680 emitNode(parser, 'onattribute', {
21681 name: parser.attribName,
21682 value: ''
21683 });
21684 parser.attribName = '';
21685 if (c === '>') {
21686 openTag(parser);
21687 } else if (isMatch(nameStart, c)) {
21688 parser.attribName = c;
21689 parser.state = S.ATTRIB_NAME;
21690 } else {
21691 strictFail(parser, 'Invalid attribute name');
21692 parser.state = S.ATTRIB;
21693 }
21694 }
21695 continue;
21696
21697 case S.ATTRIB_VALUE:
21698 if (isWhitespace(c)) {
21699 continue;
21700 } else if (isQuote(c)) {
21701 parser.q = c;
21702 parser.state = S.ATTRIB_VALUE_QUOTED;
21703 } else {
21704 strictFail(parser, 'Unquoted attribute value');
21705 parser.state = S.ATTRIB_VALUE_UNQUOTED;
21706 parser.attribValue = c;
21707 }
21708 continue;
21709
21710 case S.ATTRIB_VALUE_QUOTED:
21711 if (c !== parser.q) {
21712 if (c === '&') {
21713 parser.state = S.ATTRIB_VALUE_ENTITY_Q;
21714 } else {
21715 parser.attribValue += c;
21716 }
21717 continue;
21718 }
21719 attrib(parser);
21720 parser.q = '';
21721 parser.state = S.ATTRIB_VALUE_CLOSED;
21722 continue;
21723
21724 case S.ATTRIB_VALUE_CLOSED:
21725 if (isWhitespace(c)) {
21726 parser.state = S.ATTRIB;
21727 } else if (c === '>') {
21728 openTag(parser);
21729 } else if (c === '/') {
21730 parser.state = S.OPEN_TAG_SLASH;
21731 } else if (isMatch(nameStart, c)) {
21732 strictFail(parser, 'No whitespace between attributes');
21733 parser.attribName = c;
21734 parser.attribValue = '';
21735 parser.state = S.ATTRIB_NAME;
21736 } else {
21737 strictFail(parser, 'Invalid attribute name');
21738 }
21739 continue;
21740
21741 case S.ATTRIB_VALUE_UNQUOTED:
21742 if (!isAttribEnd(c)) {
21743 if (c === '&') {
21744 parser.state = S.ATTRIB_VALUE_ENTITY_U;
21745 } else {
21746 parser.attribValue += c;
21747 }
21748 continue;
21749 }
21750 attrib(parser);
21751 if (c === '>') {
21752 openTag(parser);
21753 } else {
21754 parser.state = S.ATTRIB;
21755 }
21756 continue;
21757
21758 case S.CLOSE_TAG:
21759 if (!parser.tagName) {
21760 if (isWhitespace(c)) {
21761 continue;
21762 } else if (notMatch(nameStart, c)) {
21763 if (parser.script) {
21764 parser.script += '</' + c;
21765 parser.state = S.SCRIPT;
21766 } else {
21767 strictFail(parser, 'Invalid tagname in closing tag.');
21768 }
21769 } else {
21770 parser.tagName = c;
21771 }
21772 } else if (c === '>') {
21773 closeTag(parser);
21774 } else if (isMatch(nameBody, c)) {
21775 parser.tagName += c;
21776 } else if (parser.script) {
21777 parser.script += '</' + parser.tagName;
21778 parser.tagName = '';
21779 parser.state = S.SCRIPT;
21780 } else {
21781 if (!isWhitespace(c)) {
21782 strictFail(parser, 'Invalid tagname in closing tag');
21783 }
21784 parser.state = S.CLOSE_TAG_SAW_WHITE;
21785 }
21786 continue;
21787
21788 case S.CLOSE_TAG_SAW_WHITE:
21789 if (isWhitespace(c)) {
21790 continue;
21791 }
21792 if (c === '>') {
21793 closeTag(parser);
21794 } else {
21795 strictFail(parser, 'Invalid characters in closing tag');
21796 }
21797 continue;
21798
21799 case S.TEXT_ENTITY:
21800 case S.ATTRIB_VALUE_ENTITY_Q:
21801 case S.ATTRIB_VALUE_ENTITY_U:
21802 var returnState;
21803 var buffer;
21804 switch (parser.state) {
21805 case S.TEXT_ENTITY:
21806 returnState = S.TEXT;
21807 buffer = 'textNode';
21808 break;
21809
21810 case S.ATTRIB_VALUE_ENTITY_Q:
21811 returnState = S.ATTRIB_VALUE_QUOTED;
21812 buffer = 'attribValue';
21813 break;
21814
21815 case S.ATTRIB_VALUE_ENTITY_U:
21816 returnState = S.ATTRIB_VALUE_UNQUOTED;
21817 buffer = 'attribValue';
21818 break;
21819 }
21820
21821 if (c === ';') {
21822 parser[buffer] += parseEntity(parser);
21823 parser.entity = '';
21824 parser.state = returnState;
21825 } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
21826 parser.entity += c;
21827 } else {
21828 strictFail(parser, 'Invalid character in entity name');
21829 parser[buffer] += '&' + parser.entity + c;
21830 parser.entity = '';
21831 parser.state = returnState;
21832 }
21833
21834 continue;
21835
21836 default:
21837 throw new Error(parser, 'Unknown state: ' + parser.state);
21838 }
21839 } // while
21840
21841 if (parser.position >= parser.bufferCheckPosition) {
21842 checkBufferLength(parser);
21843 }
21844 return parser;
21845 }
21846
21847 /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
21848 /* istanbul ignore next */
21849 if (!_fromCodePoint2.default) {
21850 (function () {
21851 var stringFromCharCode = String.fromCharCode;
21852 var floor = Math.floor;
21853 var fromCodePoint = function fromCodePoint() {
21854 var MAX_SIZE = 0x4000;
21855 var codeUnits = [];
21856 var highSurrogate;
21857 var lowSurrogate;
21858 var index = -1;
21859 var length = arguments.length;
21860 if (!length) {
21861 return '';
21862 }
21863 var result = '';
21864 while (++index < length) {
21865 var codePoint = Number(arguments[index]);
21866 if (!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
21867 codePoint < 0 || // not a valid Unicode code point
21868 codePoint > 0x10FFFF || // not a valid Unicode code point
21869 floor(codePoint) !== codePoint // not an integer
21870 ) {
21871 throw RangeError('Invalid code point: ' + codePoint);
21872 }
21873 if (codePoint <= 0xFFFF) {
21874 // BMP code point
21875 codeUnits.push(codePoint);
21876 } else {
21877 // Astral code point; split in surrogate halves
21878 // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
21879 codePoint -= 0x10000;
21880 highSurrogate = (codePoint >> 10) + 0xD800;
21881 lowSurrogate = codePoint % 0x400 + 0xDC00;
21882 codeUnits.push(highSurrogate, lowSurrogate);
21883 }
21884 if (index + 1 === length || codeUnits.length > MAX_SIZE) {
21885 result += stringFromCharCode.apply(null, codeUnits);
21886 codeUnits.length = 0;
21887 }
21888 }
21889 return result;
21890 };
21891 /* istanbul ignore next */
21892 if (_defineProperty2.default) {
21893 Object.defineProperty(String, 'fromCodePoint', {
21894 value: fromCodePoint,
21895 configurable: true,
21896 writable: true
21897 });
21898 } else {
21899 String.fromCodePoint = fromCodePoint;
21900 }
21901 })();
21902 }
21903})(typeof exports === 'undefined' ? undefined.sax = {} : exports);
21904
21905}).call(this,require("buffer").Buffer)
21906},{"babel-runtime/core-js/json/stringify":38,"babel-runtime/core-js/object/create":40,"babel-runtime/core-js/object/define-property":41,"babel-runtime/core-js/object/keys":45,"babel-runtime/core-js/string/from-code-point":48,"babel-runtime/helpers/typeof":54,"buffer":60,"stream":261,"string_decoder":59}],261:[function(require,module,exports){
21907// Copyright Joyent, Inc. and other Node contributors.
21908//
21909// Permission is hereby granted, free of charge, to any person obtaining a
21910// copy of this software and associated documentation files (the
21911// "Software"), to deal in the Software without restriction, including
21912// without limitation the rights to use, copy, modify, merge, publish,
21913// distribute, sublicense, and/or sell copies of the Software, and to permit
21914// persons to whom the Software is furnished to do so, subject to the
21915// following conditions:
21916//
21917// The above copyright notice and this permission notice shall be included
21918// in all copies or substantial portions of the Software.
21919//
21920// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21921// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21922// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
21923// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21924// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21925// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21926// USE OR OTHER DEALINGS IN THE SOFTWARE.
21927
21928module.exports = Stream;
21929
21930var EE = require('events').EventEmitter;
21931var inherits = require('inherits');
21932
21933inherits(Stream, EE);
21934Stream.Readable = require('readable-stream/readable.js');
21935Stream.Writable = require('readable-stream/writable.js');
21936Stream.Duplex = require('readable-stream/duplex.js');
21937Stream.Transform = require('readable-stream/transform.js');
21938Stream.PassThrough = require('readable-stream/passthrough.js');
21939
21940// Backwards-compat with node 0.4.x
21941Stream.Stream = Stream;
21942
21943
21944
21945// old-style streams. Note that the pipe method (the only relevant
21946// part of this class) is overridden in the Readable class.
21947
21948function Stream() {
21949 EE.call(this);
21950}
21951
21952Stream.prototype.pipe = function(dest, options) {
21953 var source = this;
21954
21955 function ondata(chunk) {
21956 if (dest.writable) {
21957 if (false === dest.write(chunk) && source.pause) {
21958 source.pause();
21959 }
21960 }
21961 }
21962
21963 source.on('data', ondata);
21964
21965 function ondrain() {
21966 if (source.readable && source.resume) {
21967 source.resume();
21968 }
21969 }
21970
21971 dest.on('drain', ondrain);
21972
21973 // If the 'end' option is not supplied, dest.end() will be called when
21974 // source gets the 'end' or 'close' events. Only dest.end() once.
21975 if (!dest._isStdio && (!options || options.end !== false)) {
21976 source.on('end', onend);
21977 source.on('close', onclose);
21978 }
21979
21980 var didOnEnd = false;
21981 function onend() {
21982 if (didOnEnd) return;
21983 didOnEnd = true;
21984
21985 dest.end();
21986 }
21987
21988
21989 function onclose() {
21990 if (didOnEnd) return;
21991 didOnEnd = true;
21992
21993 if (typeof dest.destroy === 'function') dest.destroy();
21994 }
21995
21996 // don't leave dangling pipes when there are errors.
21997 function onerror(er) {
21998 cleanup();
21999 if (EE.listenerCount(this, 'error') === 0) {
22000 throw er; // Unhandled stream error in pipe.
22001 }
22002 }
22003
22004 source.on('error', onerror);
22005 dest.on('error', onerror);
22006
22007 // remove all the event listeners that were added.
22008 function cleanup() {
22009 source.removeListener('data', ondata);
22010 dest.removeListener('drain', ondrain);
22011
22012 source.removeListener('end', onend);
22013 source.removeListener('close', onclose);
22014
22015 source.removeListener('error', onerror);
22016 dest.removeListener('error', onerror);
22017
22018 source.removeListener('end', cleanup);
22019 source.removeListener('close', cleanup);
22020
22021 dest.removeListener('close', cleanup);
22022 }
22023
22024 source.on('end', cleanup);
22025 source.on('close', cleanup);
22026
22027 dest.on('close', cleanup);
22028
22029 dest.emit('pipe', source);
22030
22031 // Allow for unix-like usage: A.pipe(B).pipe(C)
22032 return dest;
22033};
22034
22035},{"events":206,"inherits":216,"readable-stream/duplex.js":244,"readable-stream/passthrough.js":253,"readable-stream/readable.js":254,"readable-stream/transform.js":255,"readable-stream/writable.js":256}],262:[function(require,module,exports){
22036(function (global){
22037var ClientRequest = require('./lib/request')
22038var response = require('./lib/response')
22039var extend = require('xtend')
22040var statusCodes = require('builtin-status-codes')
22041var url = require('url')
22042
22043var http = exports
22044
22045http.request = function (opts, cb) {
22046 if (typeof opts === 'string')
22047 opts = url.parse(opts)
22048 else
22049 opts = extend(opts)
22050
22051 // Normally, the page is loaded from http or https, so not specifying a protocol
22052 // will result in a (valid) protocol-relative url. However, this won't work if
22053 // the protocol is something else, like 'file:'
22054 var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
22055
22056 var protocol = opts.protocol || defaultProtocol
22057 var host = opts.hostname || opts.host
22058 var port = opts.port
22059 var path = opts.path || '/'
22060
22061 // Necessary for IPv6 addresses
22062 if (host && host.indexOf(':') !== -1)
22063 host = '[' + host + ']'
22064
22065 // This may be a relative url. The browser should always be able to interpret it correctly.
22066 opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
22067 opts.method = (opts.method || 'GET').toUpperCase()
22068 opts.headers = opts.headers || {}
22069
22070 // Also valid opts.auth, opts.mode
22071
22072 var req = new ClientRequest(opts)
22073 if (cb)
22074 req.on('response', cb)
22075 return req
22076}
22077
22078http.get = function get (opts, cb) {
22079 var req = http.request(opts, cb)
22080 req.end()
22081 return req
22082}
22083
22084http.ClientRequest = ClientRequest
22085http.IncomingMessage = response.IncomingMessage
22086
22087http.Agent = function () {}
22088http.Agent.defaultMaxSockets = 4
22089
22090http.globalAgent = new http.Agent()
22091
22092http.STATUS_CODES = statusCodes
22093
22094http.METHODS = [
22095 'CHECKOUT',
22096 'CONNECT',
22097 'COPY',
22098 'DELETE',
22099 'GET',
22100 'HEAD',
22101 'LOCK',
22102 'M-SEARCH',
22103 'MERGE',
22104 'MKACTIVITY',
22105 'MKCOL',
22106 'MOVE',
22107 'NOTIFY',
22108 'OPTIONS',
22109 'PATCH',
22110 'POST',
22111 'PROPFIND',
22112 'PROPPATCH',
22113 'PURGE',
22114 'PUT',
22115 'REPORT',
22116 'SEARCH',
22117 'SUBSCRIBE',
22118 'TRACE',
22119 'UNLOCK',
22120 'UNSUBSCRIBE'
22121]
22122}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
22123},{"./lib/request":264,"./lib/response":265,"builtin-status-codes":61,"url":269,"xtend":317}],263:[function(require,module,exports){
22124(function (global){
22125'use strict';
22126
22127exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream);
22128
22129exports.writableStream = isFunction(global.WritableStream);
22130
22131exports.abortController = isFunction(global.AbortController);
22132
22133exports.blobConstructor = false;
22134try {
22135 new Blob([new ArrayBuffer(1)]);
22136 exports.blobConstructor = true;
22137} catch (e) {}
22138
22139// The xhr request to example.com may violate some restrictive CSP configurations,
22140// so if we're running in a browser that supports `fetch`, avoid calling getXHR()
22141// and assume support for certain features below.
22142var xhr;
22143function getXHR() {
22144 // Cache the xhr value
22145 if (xhr !== undefined) return xhr;
22146
22147 if (global.XMLHttpRequest) {
22148 xhr = new global.XMLHttpRequest();
22149 // If XDomainRequest is available (ie only, where xhr might not work
22150 // cross domain), use the page location. Otherwise use example.com
22151 // Note: this doesn't actually make an http request.
22152 try {
22153 xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com');
22154 } catch (e) {
22155 xhr = null;
22156 }
22157 } else {
22158 // Service workers don't have XHR
22159 xhr = null;
22160 }
22161 return xhr;
22162}
22163
22164function checkTypeSupport(type) {
22165 var xhr = getXHR();
22166 if (!xhr) return false;
22167 try {
22168 xhr.responseType = type;
22169 return xhr.responseType === type;
22170 } catch (e) {}
22171 return false;
22172}
22173
22174// For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
22175// Safari 7.1 appears to have fixed this bug.
22176var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined';
22177var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice);
22178
22179// If fetch is supported, then arraybuffer will be supported too. Skip calling
22180// checkTypeSupport(), since that calls getXHR().
22181exports.arraybuffer = exports.fetch || haveArrayBuffer && checkTypeSupport('arraybuffer');
22182
22183// These next two tests unavoidably show warnings in Chrome. Since fetch will always
22184// be used if it's available, just return false for these to avoid the warnings.
22185exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream');
22186exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer && checkTypeSupport('moz-chunked-arraybuffer');
22187
22188// If fetch is supported, then overrideMimeType will be supported too. Skip calling
22189// getXHR().
22190exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false);
22191
22192exports.vbArray = isFunction(global.VBArray);
22193
22194function isFunction(value) {
22195 return typeof value === 'function';
22196}
22197
22198xhr = null; // Help gc
22199
22200}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
22201},{}],264:[function(require,module,exports){
22202(function (process,global,Buffer){
22203'use strict';
22204
22205var _keys = require('babel-runtime/core-js/object/keys');
22206
22207var _keys2 = _interopRequireDefault(_keys);
22208
22209function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22210
22211var capability = require('./capability');
22212var inherits = require('inherits');
22213var response = require('./response');
22214var stream = require('readable-stream');
22215var toArrayBuffer = require('to-arraybuffer');
22216
22217var IncomingMessage = response.IncomingMessage;
22218var rStates = response.readyStates;
22219
22220function decideMode(preferBinary, useFetch) {
22221 if (capability.fetch && useFetch) {
22222 return 'fetch';
22223 } else if (capability.mozchunkedarraybuffer) {
22224 return 'moz-chunked-arraybuffer';
22225 } else if (capability.msstream) {
22226 return 'ms-stream';
22227 } else if (capability.arraybuffer && preferBinary) {
22228 return 'arraybuffer';
22229 } else if (capability.vbArray && preferBinary) {
22230 return 'text:vbarray';
22231 } else {
22232 return 'text';
22233 }
22234}
22235
22236var ClientRequest = module.exports = function (opts) {
22237 var self = this;
22238 stream.Writable.call(self);
22239
22240 self._opts = opts;
22241 self._body = [];
22242 self._headers = {};
22243 if (opts.auth) self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'));
22244 (0, _keys2.default)(opts.headers).forEach(function (name) {
22245 self.setHeader(name, opts.headers[name]);
22246 });
22247
22248 var preferBinary;
22249 var useFetch = true;
22250 if (opts.mode === 'disable-fetch' || 'requestTimeout' in opts && !capability.abortController) {
22251 // If the use of XHR should be preferred. Not typically needed.
22252 useFetch = false;
22253 preferBinary = true;
22254 } else if (opts.mode === 'prefer-streaming') {
22255 // If streaming is a high priority but binary compatibility and
22256 // the accuracy of the 'content-type' header aren't
22257 preferBinary = false;
22258 } else if (opts.mode === 'allow-wrong-content-type') {
22259 // If streaming is more important than preserving the 'content-type' header
22260 preferBinary = !capability.overrideMimeType;
22261 } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
22262 // Use binary if text streaming may corrupt data or the content-type header, or for speed
22263 preferBinary = true;
22264 } else {
22265 throw new Error('Invalid value for opts.mode');
22266 }
22267 self._mode = decideMode(preferBinary, useFetch);
22268 self._fetchTimer = null;
22269
22270 self.on('finish', function () {
22271 self._onFinish();
22272 });
22273};
22274
22275inherits(ClientRequest, stream.Writable);
22276
22277ClientRequest.prototype.setHeader = function (name, value) {
22278 var self = this;
22279 var lowerName = name.toLowerCase();
22280 // This check is not necessary, but it prevents warnings from browsers about setting unsafe
22281 // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
22282 // http-browserify did it, so I will too.
22283 if (unsafeHeaders.indexOf(lowerName) !== -1) return;
22284
22285 self._headers[lowerName] = {
22286 name: name,
22287 value: value
22288 };
22289};
22290
22291ClientRequest.prototype.getHeader = function (name) {
22292 var header = this._headers[name.toLowerCase()];
22293 if (header) return header.value;
22294 return null;
22295};
22296
22297ClientRequest.prototype.removeHeader = function (name) {
22298 var self = this;
22299 delete self._headers[name.toLowerCase()];
22300};
22301
22302ClientRequest.prototype._onFinish = function () {
22303 var self = this;
22304
22305 if (self._destroyed) return;
22306 var opts = self._opts;
22307
22308 var headersObj = self._headers;
22309 var body = null;
22310 if (opts.method !== 'GET' && opts.method !== 'HEAD') {
22311 if (capability.arraybuffer) {
22312 body = toArrayBuffer(Buffer.concat(self._body));
22313 } else if (capability.blobConstructor) {
22314 body = new global.Blob(self._body.map(function (buffer) {
22315 return toArrayBuffer(buffer);
22316 }), {
22317 type: (headersObj['content-type'] || {}).value || ''
22318 });
22319 } else {
22320 // get utf8 string
22321 body = Buffer.concat(self._body).toString();
22322 }
22323 }
22324
22325 // create flattened list of headers
22326 var headersList = [];
22327 (0, _keys2.default)(headersObj).forEach(function (keyName) {
22328 var name = headersObj[keyName].name;
22329 var value = headersObj[keyName].value;
22330 if (Array.isArray(value)) {
22331 value.forEach(function (v) {
22332 headersList.push([name, v]);
22333 });
22334 } else {
22335 headersList.push([name, value]);
22336 }
22337 });
22338
22339 if (self._mode === 'fetch') {
22340 var signal = null;
22341 var fetchTimer = null;
22342 if (capability.abortController) {
22343 var controller = new AbortController();
22344 signal = controller.signal;
22345 self._fetchAbortController = controller;
22346
22347 if ('requestTimeout' in opts && opts.requestTimeout !== 0) {
22348 self._fetchTimer = global.setTimeout(function () {
22349 self.emit('requestTimeout');
22350 if (self._fetchAbortController) self._fetchAbortController.abort();
22351 }, opts.requestTimeout);
22352 }
22353 }
22354
22355 global.fetch(self._opts.url, {
22356 method: self._opts.method,
22357 headers: headersList,
22358 body: body || undefined,
22359 mode: 'cors',
22360 credentials: opts.withCredentials ? 'include' : 'same-origin',
22361 signal: signal
22362 }).then(function (response) {
22363 self._fetchResponse = response;
22364 self._connect();
22365 }, function (reason) {
22366 global.clearTimeout(self._fetchTimer);
22367 if (!self._destroyed) self.emit('error', reason);
22368 });
22369 } else {
22370 var xhr = self._xhr = new global.XMLHttpRequest();
22371 try {
22372 xhr.open(self._opts.method, self._opts.url, true);
22373 } catch (err) {
22374 process.nextTick(function () {
22375 self.emit('error', err);
22376 });
22377 return;
22378 }
22379
22380 // Can't set responseType on really old browsers
22381 if ('responseType' in xhr) xhr.responseType = self._mode.split(':')[0];
22382
22383 if ('withCredentials' in xhr) xhr.withCredentials = !!opts.withCredentials;
22384
22385 if (self._mode === 'text' && 'overrideMimeType' in xhr) xhr.overrideMimeType('text/plain; charset=x-user-defined');
22386
22387 if ('requestTimeout' in opts) {
22388 xhr.timeout = opts.requestTimeout;
22389 xhr.ontimeout = function () {
22390 self.emit('requestTimeout');
22391 };
22392 }
22393
22394 headersList.forEach(function (header) {
22395 xhr.setRequestHeader(header[0], header[1]);
22396 });
22397
22398 self._response = null;
22399 xhr.onreadystatechange = function () {
22400 switch (xhr.readyState) {
22401 case rStates.LOADING:
22402 case rStates.DONE:
22403 self._onXHRProgress();
22404 break;
22405 }
22406 };
22407 // Necessary for streaming in Firefox, since xhr.response is ONLY defined
22408 // in onprogress, not in onreadystatechange with xhr.readyState = 3
22409 if (self._mode === 'moz-chunked-arraybuffer') {
22410 xhr.onprogress = function () {
22411 self._onXHRProgress();
22412 };
22413 }
22414
22415 xhr.onerror = function () {
22416 if (self._destroyed) return;
22417 self.emit('error', new Error('XHR error'));
22418 };
22419
22420 try {
22421 xhr.send(body);
22422 } catch (err) {
22423 process.nextTick(function () {
22424 self.emit('error', err);
22425 });
22426 return;
22427 }
22428 }
22429};
22430
22431/**
22432 * Checks if xhr.status is readable and non-zero, indicating no error.
22433 * Even though the spec says it should be available in readyState 3,
22434 * accessing it throws an exception in IE8
22435 */
22436function statusValid(xhr) {
22437 try {
22438 var status = xhr.status;
22439 return status !== null && status !== 0;
22440 } catch (e) {
22441 return false;
22442 }
22443}
22444
22445ClientRequest.prototype._onXHRProgress = function () {
22446 var self = this;
22447
22448 if (!statusValid(self._xhr) || self._destroyed) return;
22449
22450 if (!self._response) self._connect();
22451
22452 self._response._onXHRProgress();
22453};
22454
22455ClientRequest.prototype._connect = function () {
22456 var self = this;
22457
22458 if (self._destroyed) return;
22459
22460 self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._fetchTimer);
22461 self._response.on('error', function (err) {
22462 self.emit('error', err);
22463 });
22464
22465 self.emit('response', self._response);
22466};
22467
22468ClientRequest.prototype._write = function (chunk, encoding, cb) {
22469 var self = this;
22470
22471 self._body.push(chunk);
22472 cb();
22473};
22474
22475ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
22476 var self = this;
22477 self._destroyed = true;
22478 global.clearTimeout(self._fetchTimer);
22479 if (self._response) self._response._destroyed = true;
22480 if (self._xhr) self._xhr.abort();else if (self._fetchAbortController) self._fetchAbortController.abort();
22481};
22482
22483ClientRequest.prototype.end = function (data, encoding, cb) {
22484 var self = this;
22485 if (typeof data === 'function') {
22486 cb = data;
22487 data = undefined;
22488 }
22489
22490 stream.Writable.prototype.end.call(self, data, encoding, cb);
22491};
22492
22493ClientRequest.prototype.flushHeaders = function () {};
22494ClientRequest.prototype.setTimeout = function () {};
22495ClientRequest.prototype.setNoDelay = function () {};
22496ClientRequest.prototype.setSocketKeepAlive = function () {};
22497
22498// Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
22499var unsafeHeaders = ['accept-charset', 'accept-encoding', 'access-control-request-headers', 'access-control-request-method', 'connection', 'content-length', 'cookie', 'cookie2', 'date', 'dnt', 'expect', 'host', 'keep-alive', 'origin', 'referer', 'te', 'trailer', 'transfer-encoding', 'upgrade', 'user-agent', 'via'];
22500
22501}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
22502},{"./capability":263,"./response":265,"_process":239,"babel-runtime/core-js/object/keys":45,"buffer":60,"inherits":216,"readable-stream":254,"to-arraybuffer":268}],265:[function(require,module,exports){
22503(function (process,global,Buffer){
22504'use strict';
22505
22506var _promise = require('babel-runtime/core-js/promise');
22507
22508var _promise2 = _interopRequireDefault(_promise);
22509
22510function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22511
22512var capability = require('./capability');
22513var inherits = require('inherits');
22514var stream = require('readable-stream');
22515
22516var rStates = exports.readyStates = {
22517 UNSENT: 0,
22518 OPENED: 1,
22519 HEADERS_RECEIVED: 2,
22520 LOADING: 3,
22521 DONE: 4
22522};
22523
22524var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, fetchTimer) {
22525 var self = this;
22526 stream.Readable.call(self);
22527
22528 self._mode = mode;
22529 self.headers = {};
22530 self.rawHeaders = [];
22531 self.trailers = {};
22532 self.rawTrailers = [];
22533
22534 // Fake the 'close' event, but only once 'end' fires
22535 self.on('end', function () {
22536 // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
22537 process.nextTick(function () {
22538 self.emit('close');
22539 });
22540 });
22541
22542 if (mode === 'fetch') {
22543 var read = function read() {
22544 reader.read().then(function (result) {
22545 if (self._destroyed) return;
22546 if (result.done) {
22547 global.clearTimeout(fetchTimer);
22548 self.push(null);
22549 return;
22550 }
22551 self.push(new Buffer(result.value));
22552 read();
22553 }).catch(function (err) {
22554 global.clearTimeout(fetchTimer);
22555 if (!self._destroyed) self.emit('error', err);
22556 });
22557 };
22558
22559 self._fetchResponse = response;
22560
22561 self.url = response.url;
22562 self.statusCode = response.status;
22563 self.statusMessage = response.statusText;
22564
22565 response.headers.forEach(function (header, key) {
22566 self.headers[key.toLowerCase()] = header;
22567 self.rawHeaders.push(key, header);
22568 });
22569
22570 if (capability.writableStream) {
22571 var writable = new WritableStream({
22572 write: function write(chunk) {
22573 return new _promise2.default(function (resolve, reject) {
22574 if (self._destroyed) {
22575 reject();
22576 } else if (self.push(new Buffer(chunk))) {
22577 resolve();
22578 } else {
22579 self._resumeFetch = resolve;
22580 }
22581 });
22582 },
22583 close: function close() {
22584 global.clearTimeout(fetchTimer);
22585 if (!self._destroyed) self.push(null);
22586 },
22587 abort: function abort(err) {
22588 if (!self._destroyed) self.emit('error', err);
22589 }
22590 });
22591
22592 try {
22593 response.body.pipeTo(writable).catch(function (err) {
22594 global.clearTimeout(fetchTimer);
22595 if (!self._destroyed) self.emit('error', err);
22596 });
22597 return;
22598 } catch (e) {} // pipeTo method isn't defined. Can't find a better way to feature test this
22599 }
22600 // fallback for when writableStream or pipeTo aren't available
22601 var reader = response.body.getReader();
22602
22603 read();
22604 } else {
22605 self._xhr = xhr;
22606 self._pos = 0;
22607
22608 self.url = xhr.responseURL;
22609 self.statusCode = xhr.status;
22610 self.statusMessage = xhr.statusText;
22611 var headers = xhr.getAllResponseHeaders().split(/\r?\n/);
22612 headers.forEach(function (header) {
22613 var matches = header.match(/^([^:]+):\s*(.*)/);
22614 if (matches) {
22615 var key = matches[1].toLowerCase();
22616 if (key === 'set-cookie') {
22617 if (self.headers[key] === undefined) {
22618 self.headers[key] = [];
22619 }
22620 self.headers[key].push(matches[2]);
22621 } else if (self.headers[key] !== undefined) {
22622 self.headers[key] += ', ' + matches[2];
22623 } else {
22624 self.headers[key] = matches[2];
22625 }
22626 self.rawHeaders.push(matches[1], matches[2]);
22627 }
22628 });
22629
22630 self._charset = 'x-user-defined';
22631 if (!capability.overrideMimeType) {
22632 var mimeType = self.rawHeaders['mime-type'];
22633 if (mimeType) {
22634 var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/);
22635 if (charsetMatch) {
22636 self._charset = charsetMatch[1].toLowerCase();
22637 }
22638 }
22639 if (!self._charset) self._charset = 'utf-8'; // best guess
22640 }
22641 }
22642};
22643
22644inherits(IncomingMessage, stream.Readable);
22645
22646IncomingMessage.prototype._read = function () {
22647 var self = this;
22648
22649 var resolve = self._resumeFetch;
22650 if (resolve) {
22651 self._resumeFetch = null;
22652 resolve();
22653 }
22654};
22655
22656IncomingMessage.prototype._onXHRProgress = function () {
22657 var self = this;
22658
22659 var xhr = self._xhr;
22660
22661 var response = null;
22662 switch (self._mode) {
22663 case 'text:vbarray':
22664 // For IE9
22665 if (xhr.readyState !== rStates.DONE) break;
22666 try {
22667 // This fails in IE8
22668 response = new global.VBArray(xhr.responseBody).toArray();
22669 } catch (e) {}
22670 if (response !== null) {
22671 self.push(new Buffer(response));
22672 break;
22673 }
22674 // Falls through in IE8
22675 case 'text':
22676 try {
22677 // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
22678 response = xhr.responseText;
22679 } catch (e) {
22680 self._mode = 'text:vbarray';
22681 break;
22682 }
22683 if (response.length > self._pos) {
22684 var newData = response.substr(self._pos);
22685 if (self._charset === 'x-user-defined') {
22686 var buffer = new Buffer(newData.length);
22687 for (var i = 0; i < newData.length; i++) {
22688 buffer[i] = newData.charCodeAt(i) & 0xff;
22689 }self.push(buffer);
22690 } else {
22691 self.push(newData, self._charset);
22692 }
22693 self._pos = response.length;
22694 }
22695 break;
22696 case 'arraybuffer':
22697 if (xhr.readyState !== rStates.DONE || !xhr.response) break;
22698 response = xhr.response;
22699 self.push(new Buffer(new Uint8Array(response)));
22700 break;
22701 case 'moz-chunked-arraybuffer':
22702 // take whole
22703 response = xhr.response;
22704 if (xhr.readyState !== rStates.LOADING || !response) break;
22705 self.push(new Buffer(new Uint8Array(response)));
22706 break;
22707 case 'ms-stream':
22708 response = xhr.response;
22709 if (xhr.readyState !== rStates.LOADING) break;
22710 var reader = new global.MSStreamReader();
22711 reader.onprogress = function () {
22712 if (reader.result.byteLength > self._pos) {
22713 self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))));
22714 self._pos = reader.result.byteLength;
22715 }
22716 };
22717 reader.onload = function () {
22718 self.push(null);
22719 };
22720 // reader.onerror = ??? // TODO: this
22721 reader.readAsArrayBuffer(response);
22722 break;
22723 }
22724
22725 // The ms-stream case handles end separately in reader.onload()
22726 if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
22727 self.push(null);
22728 }
22729};
22730
22731}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
22732},{"./capability":263,"_process":239,"babel-runtime/core-js/promise":46,"buffer":60,"inherits":216,"readable-stream":254}],266:[function(require,module,exports){
22733// Copyright Joyent, Inc. and other Node contributors.
22734//
22735// Permission is hereby granted, free of charge, to any person obtaining a
22736// copy of this software and associated documentation files (the
22737// "Software"), to deal in the Software without restriction, including
22738// without limitation the rights to use, copy, modify, merge, publish,
22739// distribute, sublicense, and/or sell copies of the Software, and to permit
22740// persons to whom the Software is furnished to do so, subject to the
22741// following conditions:
22742//
22743// The above copyright notice and this permission notice shall be included
22744// in all copies or substantial portions of the Software.
22745//
22746// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22747// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22748// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22749// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22750// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22751// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22752// USE OR OTHER DEALINGS IN THE SOFTWARE.
22753
22754'use strict';
22755
22756/*<replacement>*/
22757
22758var Buffer = require('safe-buffer').Buffer;
22759/*</replacement>*/
22760
22761var isEncoding = Buffer.isEncoding || function (encoding) {
22762 encoding = '' + encoding;
22763 switch (encoding && encoding.toLowerCase()) {
22764 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':
22765 return true;
22766 default:
22767 return false;
22768 }
22769};
22770
22771function _normalizeEncoding(enc) {
22772 if (!enc) return 'utf8';
22773 var retried;
22774 while (true) {
22775 switch (enc) {
22776 case 'utf8':
22777 case 'utf-8':
22778 return 'utf8';
22779 case 'ucs2':
22780 case 'ucs-2':
22781 case 'utf16le':
22782 case 'utf-16le':
22783 return 'utf16le';
22784 case 'latin1':
22785 case 'binary':
22786 return 'latin1';
22787 case 'base64':
22788 case 'ascii':
22789 case 'hex':
22790 return enc;
22791 default:
22792 if (retried) return; // undefined
22793 enc = ('' + enc).toLowerCase();
22794 retried = true;
22795 }
22796 }
22797};
22798
22799// Do not cache `Buffer.isEncoding` when checking encoding names as some
22800// modules monkey-patch it to support additional encodings
22801function normalizeEncoding(enc) {
22802 var nenc = _normalizeEncoding(enc);
22803 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
22804 return nenc || enc;
22805}
22806
22807// StringDecoder provides an interface for efficiently splitting a series of
22808// buffers into a series of JS strings without breaking apart multi-byte
22809// characters.
22810exports.StringDecoder = StringDecoder;
22811function StringDecoder(encoding) {
22812 this.encoding = normalizeEncoding(encoding);
22813 var nb;
22814 switch (this.encoding) {
22815 case 'utf16le':
22816 this.text = utf16Text;
22817 this.end = utf16End;
22818 nb = 4;
22819 break;
22820 case 'utf8':
22821 this.fillLast = utf8FillLast;
22822 nb = 4;
22823 break;
22824 case 'base64':
22825 this.text = base64Text;
22826 this.end = base64End;
22827 nb = 3;
22828 break;
22829 default:
22830 this.write = simpleWrite;
22831 this.end = simpleEnd;
22832 return;
22833 }
22834 this.lastNeed = 0;
22835 this.lastTotal = 0;
22836 this.lastChar = Buffer.allocUnsafe(nb);
22837}
22838
22839StringDecoder.prototype.write = function (buf) {
22840 if (buf.length === 0) return '';
22841 var r;
22842 var i;
22843 if (this.lastNeed) {
22844 r = this.fillLast(buf);
22845 if (r === undefined) return '';
22846 i = this.lastNeed;
22847 this.lastNeed = 0;
22848 } else {
22849 i = 0;
22850 }
22851 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
22852 return r || '';
22853};
22854
22855StringDecoder.prototype.end = utf8End;
22856
22857// Returns only complete characters in a Buffer
22858StringDecoder.prototype.text = utf8Text;
22859
22860// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
22861StringDecoder.prototype.fillLast = function (buf) {
22862 if (this.lastNeed <= buf.length) {
22863 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
22864 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
22865 }
22866 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
22867 this.lastNeed -= buf.length;
22868};
22869
22870// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
22871// continuation byte. If an invalid byte is detected, -2 is returned.
22872function utf8CheckByte(byte) {
22873 if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
22874 return byte >> 6 === 0x02 ? -1 : -2;
22875}
22876
22877// Checks at most 3 bytes at the end of a Buffer in order to detect an
22878// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
22879// needed to complete the UTF-8 character (if applicable) are returned.
22880function utf8CheckIncomplete(self, buf, i) {
22881 var j = buf.length - 1;
22882 if (j < i) return 0;
22883 var nb = utf8CheckByte(buf[j]);
22884 if (nb >= 0) {
22885 if (nb > 0) self.lastNeed = nb - 1;
22886 return nb;
22887 }
22888 if (--j < i || nb === -2) return 0;
22889 nb = utf8CheckByte(buf[j]);
22890 if (nb >= 0) {
22891 if (nb > 0) self.lastNeed = nb - 2;
22892 return nb;
22893 }
22894 if (--j < i || nb === -2) return 0;
22895 nb = utf8CheckByte(buf[j]);
22896 if (nb >= 0) {
22897 if (nb > 0) {
22898 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
22899 }
22900 return nb;
22901 }
22902 return 0;
22903}
22904
22905// Validates as many continuation bytes for a multi-byte UTF-8 character as
22906// needed or are available. If we see a non-continuation byte where we expect
22907// one, we "replace" the validated continuation bytes we've seen so far with
22908// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
22909// behavior. The continuation byte check is included three times in the case
22910// where all of the continuation bytes for a character exist in the same buffer.
22911// It is also done this way as a slight performance increase instead of using a
22912// loop.
22913function utf8CheckExtraBytes(self, buf, p) {
22914 if ((buf[0] & 0xC0) !== 0x80) {
22915 self.lastNeed = 0;
22916 return '\uFFFD';
22917 }
22918 if (self.lastNeed > 1 && buf.length > 1) {
22919 if ((buf[1] & 0xC0) !== 0x80) {
22920 self.lastNeed = 1;
22921 return '\uFFFD';
22922 }
22923 if (self.lastNeed > 2 && buf.length > 2) {
22924 if ((buf[2] & 0xC0) !== 0x80) {
22925 self.lastNeed = 2;
22926 return '\uFFFD';
22927 }
22928 }
22929 }
22930}
22931
22932// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
22933function utf8FillLast(buf) {
22934 var p = this.lastTotal - this.lastNeed;
22935 var r = utf8CheckExtraBytes(this, buf, p);
22936 if (r !== undefined) return r;
22937 if (this.lastNeed <= buf.length) {
22938 buf.copy(this.lastChar, p, 0, this.lastNeed);
22939 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
22940 }
22941 buf.copy(this.lastChar, p, 0, buf.length);
22942 this.lastNeed -= buf.length;
22943}
22944
22945// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
22946// partial character, the character's bytes are buffered until the required
22947// number of bytes are available.
22948function utf8Text(buf, i) {
22949 var total = utf8CheckIncomplete(this, buf, i);
22950 if (!this.lastNeed) return buf.toString('utf8', i);
22951 this.lastTotal = total;
22952 var end = buf.length - (total - this.lastNeed);
22953 buf.copy(this.lastChar, 0, end);
22954 return buf.toString('utf8', i, end);
22955}
22956
22957// For UTF-8, a replacement character is added when ending on a partial
22958// character.
22959function utf8End(buf) {
22960 var r = buf && buf.length ? this.write(buf) : '';
22961 if (this.lastNeed) return r + '\uFFFD';
22962 return r;
22963}
22964
22965// UTF-16LE typically needs two bytes per character, but even if we have an even
22966// number of bytes available, we need to check if we end on a leading/high
22967// surrogate. In that case, we need to wait for the next two bytes in order to
22968// decode the last character properly.
22969function utf16Text(buf, i) {
22970 if ((buf.length - i) % 2 === 0) {
22971 var r = buf.toString('utf16le', i);
22972 if (r) {
22973 var c = r.charCodeAt(r.length - 1);
22974 if (c >= 0xD800 && c <= 0xDBFF) {
22975 this.lastNeed = 2;
22976 this.lastTotal = 4;
22977 this.lastChar[0] = buf[buf.length - 2];
22978 this.lastChar[1] = buf[buf.length - 1];
22979 return r.slice(0, -1);
22980 }
22981 }
22982 return r;
22983 }
22984 this.lastNeed = 1;
22985 this.lastTotal = 2;
22986 this.lastChar[0] = buf[buf.length - 1];
22987 return buf.toString('utf16le', i, buf.length - 1);
22988}
22989
22990// For UTF-16LE we do not explicitly append special replacement characters if we
22991// end on a partial character, we simply let v8 handle that.
22992function utf16End(buf) {
22993 var r = buf && buf.length ? this.write(buf) : '';
22994 if (this.lastNeed) {
22995 var end = this.lastTotal - this.lastNeed;
22996 return r + this.lastChar.toString('utf16le', 0, end);
22997 }
22998 return r;
22999}
23000
23001function base64Text(buf, i) {
23002 var n = (buf.length - i) % 3;
23003 if (n === 0) return buf.toString('base64', i);
23004 this.lastNeed = 3 - n;
23005 this.lastTotal = 3;
23006 if (n === 1) {
23007 this.lastChar[0] = buf[buf.length - 1];
23008 } else {
23009 this.lastChar[0] = buf[buf.length - 2];
23010 this.lastChar[1] = buf[buf.length - 1];
23011 }
23012 return buf.toString('base64', i, buf.length - n);
23013}
23014
23015function base64End(buf) {
23016 var r = buf && buf.length ? this.write(buf) : '';
23017 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
23018 return r;
23019}
23020
23021// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
23022function simpleWrite(buf) {
23023 return buf.toString(this.encoding);
23024}
23025
23026function simpleEnd(buf) {
23027 return buf && buf.length ? this.write(buf) : '';
23028}
23029
23030},{"safe-buffer":259}],267:[function(require,module,exports){
23031(function (setImmediate,clearImmediate){
23032var nextTick = require('process/browser.js').nextTick;
23033var apply = Function.prototype.apply;
23034var slice = Array.prototype.slice;
23035var immediateIds = {};
23036var nextImmediateId = 0;
23037
23038// DOM APIs, for completeness
23039
23040exports.setTimeout = function() {
23041 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
23042};
23043exports.setInterval = function() {
23044 return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
23045};
23046exports.clearTimeout =
23047exports.clearInterval = function(timeout) { timeout.close(); };
23048
23049function Timeout(id, clearFn) {
23050 this._id = id;
23051 this._clearFn = clearFn;
23052}
23053Timeout.prototype.unref = Timeout.prototype.ref = function() {};
23054Timeout.prototype.close = function() {
23055 this._clearFn.call(window, this._id);
23056};
23057
23058// Does not start the time, just sets up the members needed.
23059exports.enroll = function(item, msecs) {
23060 clearTimeout(item._idleTimeoutId);
23061 item._idleTimeout = msecs;
23062};
23063
23064exports.unenroll = function(item) {
23065 clearTimeout(item._idleTimeoutId);
23066 item._idleTimeout = -1;
23067};
23068
23069exports._unrefActive = exports.active = function(item) {
23070 clearTimeout(item._idleTimeoutId);
23071
23072 var msecs = item._idleTimeout;
23073 if (msecs >= 0) {
23074 item._idleTimeoutId = setTimeout(function onTimeout() {
23075 if (item._onTimeout)
23076 item._onTimeout();
23077 }, msecs);
23078 }
23079};
23080
23081// That's not how node.js implements it but the exposed api is the same.
23082exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
23083 var id = nextImmediateId++;
23084 var args = arguments.length < 2 ? false : slice.call(arguments, 1);
23085
23086 immediateIds[id] = true;
23087
23088 nextTick(function onNextTick() {
23089 if (immediateIds[id]) {
23090 // fn.call() is faster so we optimize for the common use-case
23091 // @see http://jsperf.com/call-apply-segu
23092 if (args) {
23093 fn.apply(null, args);
23094 } else {
23095 fn.call(null);
23096 }
23097 // Prevent ids from leaking
23098 exports.clearImmediate(id);
23099 }
23100 });
23101
23102 return id;
23103};
23104
23105exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
23106 delete immediateIds[id];
23107};
23108}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
23109},{"process/browser.js":239,"timers":267}],268:[function(require,module,exports){
23110var Buffer = require('buffer').Buffer
23111
23112module.exports = function (buf) {
23113 // If the buffer is backed by a Uint8Array, a faster version will work
23114 if (buf instanceof Uint8Array) {
23115 // If the buffer isn't a subarray, return the underlying ArrayBuffer
23116 if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
23117 return buf.buffer
23118 } else if (typeof buf.buffer.slice === 'function') {
23119 // Otherwise we need to get a proper copy
23120 return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
23121 }
23122 }
23123
23124 if (Buffer.isBuffer(buf)) {
23125 // This is the slow version that will work with any Buffer
23126 // implementation (even in old browsers)
23127 var arrayCopy = new Uint8Array(buf.length)
23128 var len = buf.length
23129 for (var i = 0; i < len; i++) {
23130 arrayCopy[i] = buf[i]
23131 }
23132 return arrayCopy.buffer
23133 } else {
23134 throw new Error('Argument must be a Buffer')
23135 }
23136}
23137
23138},{"buffer":60}],269:[function(require,module,exports){
23139// Copyright Joyent, Inc. and other Node contributors.
23140//
23141// Permission is hereby granted, free of charge, to any person obtaining a
23142// copy of this software and associated documentation files (the
23143// "Software"), to deal in the Software without restriction, including
23144// without limitation the rights to use, copy, modify, merge, publish,
23145// distribute, sublicense, and/or sell copies of the Software, and to permit
23146// persons to whom the Software is furnished to do so, subject to the
23147// following conditions:
23148//
23149// The above copyright notice and this permission notice shall be included
23150// in all copies or substantial portions of the Software.
23151//
23152// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23153// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23154// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
23155// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
23156// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23157// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23158// USE OR OTHER DEALINGS IN THE SOFTWARE.
23159
23160'use strict';
23161
23162var punycode = require('punycode');
23163var util = require('./util');
23164
23165exports.parse = urlParse;
23166exports.resolve = urlResolve;
23167exports.resolveObject = urlResolveObject;
23168exports.format = urlFormat;
23169
23170exports.Url = Url;
23171
23172function Url() {
23173 this.protocol = null;
23174 this.slashes = null;
23175 this.auth = null;
23176 this.host = null;
23177 this.port = null;
23178 this.hostname = null;
23179 this.hash = null;
23180 this.search = null;
23181 this.query = null;
23182 this.pathname = null;
23183 this.path = null;
23184 this.href = null;
23185}
23186
23187// Reference: RFC 3986, RFC 1808, RFC 2396
23188
23189// define these here so at least they only have to be
23190// compiled once on the first module load.
23191var protocolPattern = /^([a-z0-9.+-]+:)/i,
23192 portPattern = /:[0-9]*$/,
23193
23194 // Special case for a simple path URL
23195 simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
23196
23197 // RFC 2396: characters reserved for delimiting URLs.
23198 // We actually just auto-escape these.
23199 delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
23200
23201 // RFC 2396: characters not allowed for various reasons.
23202 unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
23203
23204 // Allowed by RFCs, but cause of XSS attacks. Always escape these.
23205 autoEscape = ['\''].concat(unwise),
23206 // Characters that are never ever allowed in a hostname.
23207 // Note that any invalid chars are also handled, but these
23208 // are the ones that are *expected* to be seen, so we fast-path
23209 // them.
23210 nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
23211 hostEndingChars = ['/', '?', '#'],
23212 hostnameMaxLen = 255,
23213 hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
23214 hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
23215 // protocols that can allow "unsafe" and "unwise" chars.
23216 unsafeProtocol = {
23217 'javascript': true,
23218 'javascript:': true
23219 },
23220 // protocols that never have a hostname.
23221 hostlessProtocol = {
23222 'javascript': true,
23223 'javascript:': true
23224 },
23225 // protocols that always contain a // bit.
23226 slashedProtocol = {
23227 'http': true,
23228 'https': true,
23229 'ftp': true,
23230 'gopher': true,
23231 'file': true,
23232 'http:': true,
23233 'https:': true,
23234 'ftp:': true,
23235 'gopher:': true,
23236 'file:': true
23237 },
23238 querystring = require('querystring');
23239
23240function urlParse(url, parseQueryString, slashesDenoteHost) {
23241 if (url && util.isObject(url) && url instanceof Url) return url;
23242
23243 var u = new Url;
23244 u.parse(url, parseQueryString, slashesDenoteHost);
23245 return u;
23246}
23247
23248Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
23249 if (!util.isString(url)) {
23250 throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
23251 }
23252
23253 // Copy chrome, IE, opera backslash-handling behavior.
23254 // Back slashes before the query string get converted to forward slashes
23255 // See: https://code.google.com/p/chromium/issues/detail?id=25916
23256 var queryIndex = url.indexOf('?'),
23257 splitter =
23258 (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
23259 uSplit = url.split(splitter),
23260 slashRegex = /\\/g;
23261 uSplit[0] = uSplit[0].replace(slashRegex, '/');
23262 url = uSplit.join(splitter);
23263
23264 var rest = url;
23265
23266 // trim before proceeding.
23267 // This is to support parse stuff like " http://foo.com \n"
23268 rest = rest.trim();
23269
23270 if (!slashesDenoteHost && url.split('#').length === 1) {
23271 // Try fast path regexp
23272 var simplePath = simplePathPattern.exec(rest);
23273 if (simplePath) {
23274 this.path = rest;
23275 this.href = rest;
23276 this.pathname = simplePath[1];
23277 if (simplePath[2]) {
23278 this.search = simplePath[2];
23279 if (parseQueryString) {
23280 this.query = querystring.parse(this.search.substr(1));
23281 } else {
23282 this.query = this.search.substr(1);
23283 }
23284 } else if (parseQueryString) {
23285 this.search = '';
23286 this.query = {};
23287 }
23288 return this;
23289 }
23290 }
23291
23292 var proto = protocolPattern.exec(rest);
23293 if (proto) {
23294 proto = proto[0];
23295 var lowerProto = proto.toLowerCase();
23296 this.protocol = lowerProto;
23297 rest = rest.substr(proto.length);
23298 }
23299
23300 // figure out if it's got a host
23301 // user@server is *always* interpreted as a hostname, and url
23302 // resolution will treat //foo/bar as host=foo,path=bar because that's
23303 // how the browser resolves relative URLs.
23304 if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
23305 var slashes = rest.substr(0, 2) === '//';
23306 if (slashes && !(proto && hostlessProtocol[proto])) {
23307 rest = rest.substr(2);
23308 this.slashes = true;
23309 }
23310 }
23311
23312 if (!hostlessProtocol[proto] &&
23313 (slashes || (proto && !slashedProtocol[proto]))) {
23314
23315 // there's a hostname.
23316 // the first instance of /, ?, ;, or # ends the host.
23317 //
23318 // If there is an @ in the hostname, then non-host chars *are* allowed
23319 // to the left of the last @ sign, unless some host-ending character
23320 // comes *before* the @-sign.
23321 // URLs are obnoxious.
23322 //
23323 // ex:
23324 // http://a@b@c/ => user:a@b host:c
23325 // http://a@b?@c => user:a host:c path:/?@c
23326
23327 // v0.12 TODO(isaacs): This is not quite how Chrome does things.
23328 // Review our test case against browsers more comprehensively.
23329
23330 // find the first instance of any hostEndingChars
23331 var hostEnd = -1;
23332 for (var i = 0; i < hostEndingChars.length; i++) {
23333 var hec = rest.indexOf(hostEndingChars[i]);
23334 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
23335 hostEnd = hec;
23336 }
23337
23338 // at this point, either we have an explicit point where the
23339 // auth portion cannot go past, or the last @ char is the decider.
23340 var auth, atSign;
23341 if (hostEnd === -1) {
23342 // atSign can be anywhere.
23343 atSign = rest.lastIndexOf('@');
23344 } else {
23345 // atSign must be in auth portion.
23346 // http://a@b/c@d => host:b auth:a path:/c@d
23347 atSign = rest.lastIndexOf('@', hostEnd);
23348 }
23349
23350 // Now we have a portion which is definitely the auth.
23351 // Pull that off.
23352 if (atSign !== -1) {
23353 auth = rest.slice(0, atSign);
23354 rest = rest.slice(atSign + 1);
23355 this.auth = decodeURIComponent(auth);
23356 }
23357
23358 // the host is the remaining to the left of the first non-host char
23359 hostEnd = -1;
23360 for (var i = 0; i < nonHostChars.length; i++) {
23361 var hec = rest.indexOf(nonHostChars[i]);
23362 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
23363 hostEnd = hec;
23364 }
23365 // if we still have not hit it, then the entire thing is a host.
23366 if (hostEnd === -1)
23367 hostEnd = rest.length;
23368
23369 this.host = rest.slice(0, hostEnd);
23370 rest = rest.slice(hostEnd);
23371
23372 // pull out port.
23373 this.parseHost();
23374
23375 // we've indicated that there is a hostname,
23376 // so even if it's empty, it has to be present.
23377 this.hostname = this.hostname || '';
23378
23379 // if hostname begins with [ and ends with ]
23380 // assume that it's an IPv6 address.
23381 var ipv6Hostname = this.hostname[0] === '[' &&
23382 this.hostname[this.hostname.length - 1] === ']';
23383
23384 // validate a little.
23385 if (!ipv6Hostname) {
23386 var hostparts = this.hostname.split(/\./);
23387 for (var i = 0, l = hostparts.length; i < l; i++) {
23388 var part = hostparts[i];
23389 if (!part) continue;
23390 if (!part.match(hostnamePartPattern)) {
23391 var newpart = '';
23392 for (var j = 0, k = part.length; j < k; j++) {
23393 if (part.charCodeAt(j) > 127) {
23394 // we replace non-ASCII char with a temporary placeholder
23395 // we need this to make sure size of hostname is not
23396 // broken by replacing non-ASCII by nothing
23397 newpart += 'x';
23398 } else {
23399 newpart += part[j];
23400 }
23401 }
23402 // we test again with ASCII char only
23403 if (!newpart.match(hostnamePartPattern)) {
23404 var validParts = hostparts.slice(0, i);
23405 var notHost = hostparts.slice(i + 1);
23406 var bit = part.match(hostnamePartStart);
23407 if (bit) {
23408 validParts.push(bit[1]);
23409 notHost.unshift(bit[2]);
23410 }
23411 if (notHost.length) {
23412 rest = '/' + notHost.join('.') + rest;
23413 }
23414 this.hostname = validParts.join('.');
23415 break;
23416 }
23417 }
23418 }
23419 }
23420
23421 if (this.hostname.length > hostnameMaxLen) {
23422 this.hostname = '';
23423 } else {
23424 // hostnames are always lower case.
23425 this.hostname = this.hostname.toLowerCase();
23426 }
23427
23428 if (!ipv6Hostname) {
23429 // IDNA Support: Returns a punycoded representation of "domain".
23430 // It only converts parts of the domain name that
23431 // have non-ASCII characters, i.e. it doesn't matter if
23432 // you call it with a domain that already is ASCII-only.
23433 this.hostname = punycode.toASCII(this.hostname);
23434 }
23435
23436 var p = this.port ? ':' + this.port : '';
23437 var h = this.hostname || '';
23438 this.host = h + p;
23439 this.href += this.host;
23440
23441 // strip [ and ] from the hostname
23442 // the host field still retains them, though
23443 if (ipv6Hostname) {
23444 this.hostname = this.hostname.substr(1, this.hostname.length - 2);
23445 if (rest[0] !== '/') {
23446 rest = '/' + rest;
23447 }
23448 }
23449 }
23450
23451 // now rest is set to the post-host stuff.
23452 // chop off any delim chars.
23453 if (!unsafeProtocol[lowerProto]) {
23454
23455 // First, make 100% sure that any "autoEscape" chars get
23456 // escaped, even if encodeURIComponent doesn't think they
23457 // need to be.
23458 for (var i = 0, l = autoEscape.length; i < l; i++) {
23459 var ae = autoEscape[i];
23460 if (rest.indexOf(ae) === -1)
23461 continue;
23462 var esc = encodeURIComponent(ae);
23463 if (esc === ae) {
23464 esc = escape(ae);
23465 }
23466 rest = rest.split(ae).join(esc);
23467 }
23468 }
23469
23470
23471 // chop off from the tail first.
23472 var hash = rest.indexOf('#');
23473 if (hash !== -1) {
23474 // got a fragment string.
23475 this.hash = rest.substr(hash);
23476 rest = rest.slice(0, hash);
23477 }
23478 var qm = rest.indexOf('?');
23479 if (qm !== -1) {
23480 this.search = rest.substr(qm);
23481 this.query = rest.substr(qm + 1);
23482 if (parseQueryString) {
23483 this.query = querystring.parse(this.query);
23484 }
23485 rest = rest.slice(0, qm);
23486 } else if (parseQueryString) {
23487 // no query string, but parseQueryString still requested
23488 this.search = '';
23489 this.query = {};
23490 }
23491 if (rest) this.pathname = rest;
23492 if (slashedProtocol[lowerProto] &&
23493 this.hostname && !this.pathname) {
23494 this.pathname = '/';
23495 }
23496
23497 //to support http.request
23498 if (this.pathname || this.search) {
23499 var p = this.pathname || '';
23500 var s = this.search || '';
23501 this.path = p + s;
23502 }
23503
23504 // finally, reconstruct the href based on what has been validated.
23505 this.href = this.format();
23506 return this;
23507};
23508
23509// format a parsed object into a url string
23510function urlFormat(obj) {
23511 // ensure it's an object, and not a string url.
23512 // If it's an obj, this is a no-op.
23513 // this way, you can call url_format() on strings
23514 // to clean up potentially wonky urls.
23515 if (util.isString(obj)) obj = urlParse(obj);
23516 if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
23517 return obj.format();
23518}
23519
23520Url.prototype.format = function() {
23521 var auth = this.auth || '';
23522 if (auth) {
23523 auth = encodeURIComponent(auth);
23524 auth = auth.replace(/%3A/i, ':');
23525 auth += '@';
23526 }
23527
23528 var protocol = this.protocol || '',
23529 pathname = this.pathname || '',
23530 hash = this.hash || '',
23531 host = false,
23532 query = '';
23533
23534 if (this.host) {
23535 host = auth + this.host;
23536 } else if (this.hostname) {
23537 host = auth + (this.hostname.indexOf(':') === -1 ?
23538 this.hostname :
23539 '[' + this.hostname + ']');
23540 if (this.port) {
23541 host += ':' + this.port;
23542 }
23543 }
23544
23545 if (this.query &&
23546 util.isObject(this.query) &&
23547 Object.keys(this.query).length) {
23548 query = querystring.stringify(this.query);
23549 }
23550
23551 var search = this.search || (query && ('?' + query)) || '';
23552
23553 if (protocol && protocol.substr(-1) !== ':') protocol += ':';
23554
23555 // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
23556 // unless they had them to begin with.
23557 if (this.slashes ||
23558 (!protocol || slashedProtocol[protocol]) && host !== false) {
23559 host = '//' + (host || '');
23560 if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
23561 } else if (!host) {
23562 host = '';
23563 }
23564
23565 if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
23566 if (search && search.charAt(0) !== '?') search = '?' + search;
23567
23568 pathname = pathname.replace(/[?#]/g, function(match) {
23569 return encodeURIComponent(match);
23570 });
23571 search = search.replace('#', '%23');
23572
23573 return protocol + host + pathname + search + hash;
23574};
23575
23576function urlResolve(source, relative) {
23577 return urlParse(source, false, true).resolve(relative);
23578}
23579
23580Url.prototype.resolve = function(relative) {
23581 return this.resolveObject(urlParse(relative, false, true)).format();
23582};
23583
23584function urlResolveObject(source, relative) {
23585 if (!source) return relative;
23586 return urlParse(source, false, true).resolveObject(relative);
23587}
23588
23589Url.prototype.resolveObject = function(relative) {
23590 if (util.isString(relative)) {
23591 var rel = new Url();
23592 rel.parse(relative, false, true);
23593 relative = rel;
23594 }
23595
23596 var result = new Url();
23597 var tkeys = Object.keys(this);
23598 for (var tk = 0; tk < tkeys.length; tk++) {
23599 var tkey = tkeys[tk];
23600 result[tkey] = this[tkey];
23601 }
23602
23603 // hash is always overridden, no matter what.
23604 // even href="" will remove it.
23605 result.hash = relative.hash;
23606
23607 // if the relative url is empty, then there's nothing left to do here.
23608 if (relative.href === '') {
23609 result.href = result.format();
23610 return result;
23611 }
23612
23613 // hrefs like //foo/bar always cut to the protocol.
23614 if (relative.slashes && !relative.protocol) {
23615 // take everything except the protocol from relative
23616 var rkeys = Object.keys(relative);
23617 for (var rk = 0; rk < rkeys.length; rk++) {
23618 var rkey = rkeys[rk];
23619 if (rkey !== 'protocol')
23620 result[rkey] = relative[rkey];
23621 }
23622
23623 //urlParse appends trailing / to urls like http://www.example.com
23624 if (slashedProtocol[result.protocol] &&
23625 result.hostname && !result.pathname) {
23626 result.path = result.pathname = '/';
23627 }
23628
23629 result.href = result.format();
23630 return result;
23631 }
23632
23633 if (relative.protocol && relative.protocol !== result.protocol) {
23634 // if it's a known url protocol, then changing
23635 // the protocol does weird things
23636 // first, if it's not file:, then we MUST have a host,
23637 // and if there was a path
23638 // to begin with, then we MUST have a path.
23639 // if it is file:, then the host is dropped,
23640 // because that's known to be hostless.
23641 // anything else is assumed to be absolute.
23642 if (!slashedProtocol[relative.protocol]) {
23643 var keys = Object.keys(relative);
23644 for (var v = 0; v < keys.length; v++) {
23645 var k = keys[v];
23646 result[k] = relative[k];
23647 }
23648 result.href = result.format();
23649 return result;
23650 }
23651
23652 result.protocol = relative.protocol;
23653 if (!relative.host && !hostlessProtocol[relative.protocol]) {
23654 var relPath = (relative.pathname || '').split('/');
23655 while (relPath.length && !(relative.host = relPath.shift()));
23656 if (!relative.host) relative.host = '';
23657 if (!relative.hostname) relative.hostname = '';
23658 if (relPath[0] !== '') relPath.unshift('');
23659 if (relPath.length < 2) relPath.unshift('');
23660 result.pathname = relPath.join('/');
23661 } else {
23662 result.pathname = relative.pathname;
23663 }
23664 result.search = relative.search;
23665 result.query = relative.query;
23666 result.host = relative.host || '';
23667 result.auth = relative.auth;
23668 result.hostname = relative.hostname || relative.host;
23669 result.port = relative.port;
23670 // to support http.request
23671 if (result.pathname || result.search) {
23672 var p = result.pathname || '';
23673 var s = result.search || '';
23674 result.path = p + s;
23675 }
23676 result.slashes = result.slashes || relative.slashes;
23677 result.href = result.format();
23678 return result;
23679 }
23680
23681 var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
23682 isRelAbs = (
23683 relative.host ||
23684 relative.pathname && relative.pathname.charAt(0) === '/'
23685 ),
23686 mustEndAbs = (isRelAbs || isSourceAbs ||
23687 (result.host && relative.pathname)),
23688 removeAllDots = mustEndAbs,
23689 srcPath = result.pathname && result.pathname.split('/') || [],
23690 relPath = relative.pathname && relative.pathname.split('/') || [],
23691 psychotic = result.protocol && !slashedProtocol[result.protocol];
23692
23693 // if the url is a non-slashed url, then relative
23694 // links like ../.. should be able
23695 // to crawl up to the hostname, as well. This is strange.
23696 // result.protocol has already been set by now.
23697 // Later on, put the first path part into the host field.
23698 if (psychotic) {
23699 result.hostname = '';
23700 result.port = null;
23701 if (result.host) {
23702 if (srcPath[0] === '') srcPath[0] = result.host;
23703 else srcPath.unshift(result.host);
23704 }
23705 result.host = '';
23706 if (relative.protocol) {
23707 relative.hostname = null;
23708 relative.port = null;
23709 if (relative.host) {
23710 if (relPath[0] === '') relPath[0] = relative.host;
23711 else relPath.unshift(relative.host);
23712 }
23713 relative.host = null;
23714 }
23715 mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
23716 }
23717
23718 if (isRelAbs) {
23719 // it's absolute.
23720 result.host = (relative.host || relative.host === '') ?
23721 relative.host : result.host;
23722 result.hostname = (relative.hostname || relative.hostname === '') ?
23723 relative.hostname : result.hostname;
23724 result.search = relative.search;
23725 result.query = relative.query;
23726 srcPath = relPath;
23727 // fall through to the dot-handling below.
23728 } else if (relPath.length) {
23729 // it's relative
23730 // throw away the existing file, and take the new path instead.
23731 if (!srcPath) srcPath = [];
23732 srcPath.pop();
23733 srcPath = srcPath.concat(relPath);
23734 result.search = relative.search;
23735 result.query = relative.query;
23736 } else if (!util.isNullOrUndefined(relative.search)) {
23737 // just pull out the search.
23738 // like href='?foo'.
23739 // Put this after the other two cases because it simplifies the booleans
23740 if (psychotic) {
23741 result.hostname = result.host = srcPath.shift();
23742 //occationaly the auth can get stuck only in host
23743 //this especially happens in cases like
23744 //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
23745 var authInHost = result.host && result.host.indexOf('@') > 0 ?
23746 result.host.split('@') : false;
23747 if (authInHost) {
23748 result.auth = authInHost.shift();
23749 result.host = result.hostname = authInHost.shift();
23750 }
23751 }
23752 result.search = relative.search;
23753 result.query = relative.query;
23754 //to support http.request
23755 if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
23756 result.path = (result.pathname ? result.pathname : '') +
23757 (result.search ? result.search : '');
23758 }
23759 result.href = result.format();
23760 return result;
23761 }
23762
23763 if (!srcPath.length) {
23764 // no path at all. easy.
23765 // we've already handled the other stuff above.
23766 result.pathname = null;
23767 //to support http.request
23768 if (result.search) {
23769 result.path = '/' + result.search;
23770 } else {
23771 result.path = null;
23772 }
23773 result.href = result.format();
23774 return result;
23775 }
23776
23777 // if a url ENDs in . or .., then it must get a trailing slash.
23778 // however, if it ends in anything else non-slashy,
23779 // then it must NOT get a trailing slash.
23780 var last = srcPath.slice(-1)[0];
23781 var hasTrailingSlash = (
23782 (result.host || relative.host || srcPath.length > 1) &&
23783 (last === '.' || last === '..') || last === '');
23784
23785 // strip single dots, resolve double dots to parent dir
23786 // if the path tries to go above the root, `up` ends up > 0
23787 var up = 0;
23788 for (var i = srcPath.length; i >= 0; i--) {
23789 last = srcPath[i];
23790 if (last === '.') {
23791 srcPath.splice(i, 1);
23792 } else if (last === '..') {
23793 srcPath.splice(i, 1);
23794 up++;
23795 } else if (up) {
23796 srcPath.splice(i, 1);
23797 up--;
23798 }
23799 }
23800
23801 // if the path is allowed to go above the root, restore leading ..s
23802 if (!mustEndAbs && !removeAllDots) {
23803 for (; up--; up) {
23804 srcPath.unshift('..');
23805 }
23806 }
23807
23808 if (mustEndAbs && srcPath[0] !== '' &&
23809 (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
23810 srcPath.unshift('');
23811 }
23812
23813 if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
23814 srcPath.push('');
23815 }
23816
23817 var isAbsolute = srcPath[0] === '' ||
23818 (srcPath[0] && srcPath[0].charAt(0) === '/');
23819
23820 // put the host back
23821 if (psychotic) {
23822 result.hostname = result.host = isAbsolute ? '' :
23823 srcPath.length ? srcPath.shift() : '';
23824 //occationaly the auth can get stuck only in host
23825 //this especially happens in cases like
23826 //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
23827 var authInHost = result.host && result.host.indexOf('@') > 0 ?
23828 result.host.split('@') : false;
23829 if (authInHost) {
23830 result.auth = authInHost.shift();
23831 result.host = result.hostname = authInHost.shift();
23832 }
23833 }
23834
23835 mustEndAbs = mustEndAbs || (result.host && srcPath.length);
23836
23837 if (mustEndAbs && !isAbsolute) {
23838 srcPath.unshift('');
23839 }
23840
23841 if (!srcPath.length) {
23842 result.pathname = null;
23843 result.path = null;
23844 } else {
23845 result.pathname = srcPath.join('/');
23846 }
23847
23848 //to support request.http
23849 if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
23850 result.path = (result.pathname ? result.pathname : '') +
23851 (result.search ? result.search : '');
23852 }
23853 result.auth = relative.auth || result.auth;
23854 result.slashes = result.slashes || relative.slashes;
23855 result.href = result.format();
23856 return result;
23857};
23858
23859Url.prototype.parseHost = function() {
23860 var host = this.host;
23861 var port = portPattern.exec(host);
23862 if (port) {
23863 port = port[0];
23864 if (port !== ':') {
23865 this.port = port.substr(1);
23866 }
23867 host = host.substr(0, host.length - port.length);
23868 }
23869 if (host) this.hostname = host;
23870};
23871
23872},{"./util":270,"punycode":240,"querystring":243}],270:[function(require,module,exports){
23873'use strict';
23874
23875module.exports = {
23876 isString: function(arg) {
23877 return typeof(arg) === 'string';
23878 },
23879 isObject: function(arg) {
23880 return typeof(arg) === 'object' && arg !== null;
23881 },
23882 isNull: function(arg) {
23883 return arg === null;
23884 },
23885 isNullOrUndefined: function(arg) {
23886 return arg == null;
23887 }
23888};
23889
23890},{}],271:[function(require,module,exports){
23891(function (global){
23892
23893/**
23894 * Module exports.
23895 */
23896
23897module.exports = deprecate;
23898
23899/**
23900 * Mark that a method should not be used.
23901 * Returns a modified function which warns once by default.
23902 *
23903 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
23904 *
23905 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
23906 * will throw an Error when invoked.
23907 *
23908 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
23909 * will invoke `console.trace()` instead of `console.error()`.
23910 *
23911 * @param {Function} fn - the function to deprecate
23912 * @param {String} msg - the string to print to the console when `fn` is invoked
23913 * @returns {Function} a new "deprecated" version of `fn`
23914 * @api public
23915 */
23916
23917function deprecate (fn, msg) {
23918 if (config('noDeprecation')) {
23919 return fn;
23920 }
23921
23922 var warned = false;
23923 function deprecated() {
23924 if (!warned) {
23925 if (config('throwDeprecation')) {
23926 throw new Error(msg);
23927 } else if (config('traceDeprecation')) {
23928 console.trace(msg);
23929 } else {
23930 console.warn(msg);
23931 }
23932 warned = true;
23933 }
23934 return fn.apply(this, arguments);
23935 }
23936
23937 return deprecated;
23938}
23939
23940/**
23941 * Checks `localStorage` for boolean values for the given `name`.
23942 *
23943 * @param {String} name
23944 * @returns {Boolean}
23945 * @api private
23946 */
23947
23948function config (name) {
23949 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
23950 try {
23951 if (!global.localStorage) return false;
23952 } catch (_) {
23953 return false;
23954 }
23955 var val = global.localStorage[name];
23956 if (null == val) return false;
23957 return String(val).toLowerCase() === 'true';
23958}
23959
23960}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
23961},{}],272:[function(require,module,exports){
23962'use strict';
23963
23964var isES5 = typeof Object.defineProperty === 'function'
23965 && typeof Object.defineProperties === 'function'
23966 && typeof Object.getPrototypeOf === 'function'
23967 && typeof Object.setPrototypeOf === 'function';
23968
23969if (!isES5) {
23970 throw new TypeError('util.promisify requires a true ES5 environment');
23971}
23972
23973var getOwnPropertyDescriptors = require('object.getownpropertydescriptors');
23974
23975if (typeof Promise !== 'function') {
23976 throw new TypeError('`Promise` must be globally available for util.promisify to work.');
23977}
23978
23979var slice = Function.call.bind(Array.prototype.slice);
23980var concat = Function.call.bind(Array.prototype.concat);
23981var forEach = Function.call.bind(Array.prototype.forEach);
23982
23983var hasSymbols = typeof Symbol === 'function' && typeof Symbol('') === 'symbol';
23984
23985var kCustomPromisifiedSymbol = hasSymbols ? Symbol('util.promisify.custom') : null;
23986var kCustomPromisifyArgsSymbol = hasSymbols ? Symbol('customPromisifyArgs') : null;
23987
23988module.exports = function promisify(orig) {
23989 if (typeof orig !== 'function') {
23990 var error = new TypeError('The "original" argument must be of type function');
23991 error.name = 'TypeError [ERR_INVALID_ARG_TYPE]';
23992 error.code = 'ERR_INVALID_ARG_TYPE';
23993 throw error;
23994 }
23995
23996 if (hasSymbols && orig[kCustomPromisifiedSymbol]) {
23997 var customFunction = orig[kCustomPromisifiedSymbol];
23998 if (typeof customFunction !== 'function') {
23999 throw new TypeError('The [util.promisify.custom] property must be a function');
24000 }
24001 Object.defineProperty(customFunction, kCustomPromisifiedSymbol, {
24002 configurable: true,
24003 enumerable: false,
24004 value: customFunction,
24005 writable: false
24006 });
24007 return customFunction;
24008 }
24009
24010 // Names to create an object from in case the callback receives multiple
24011 // arguments, e.g. ['stdout', 'stderr'] for child_process.exec.
24012 var argumentNames = orig[kCustomPromisifyArgsSymbol];
24013
24014 var promisified = function fn() {
24015 var args = slice(arguments);
24016 var self = this; // eslint-disable-line no-invalid-this
24017 return new Promise(function (resolve, reject) {
24018 orig.apply(self, concat(args, function (err) {
24019 var values = arguments.length > 1 ? slice(arguments, 1) : [];
24020 if (err) {
24021 reject(err);
24022 } else if (typeof argumentNames !== 'undefined' && values.length > 1) {
24023 var obj = {};
24024 forEach(argumentNames, function (name, index) {
24025 obj[name] = values[index];
24026 });
24027 resolve(obj);
24028 } else {
24029 resolve(values[0]);
24030 }
24031 }));
24032 });
24033 };
24034
24035 Object.setPrototypeOf(promisified, Object.getPrototypeOf(orig));
24036
24037 Object.defineProperty(promisified, kCustomPromisifiedSymbol, {
24038 configurable: true,
24039 enumerable: false,
24040 value: promisified,
24041 writable: false
24042 });
24043 return Object.defineProperties(promisified, getOwnPropertyDescriptors(orig));
24044};
24045
24046module.exports.custom = kCustomPromisifiedSymbol;
24047module.exports.customPromisifyArgs = kCustomPromisifyArgsSymbol;
24048
24049},{"object.getownpropertydescriptors":233}],273:[function(require,module,exports){
24050'use strict';
24051
24052var define = require('define-properties');
24053var util = require('util');
24054
24055var implementation = require('./implementation');
24056var getPolyfill = require('./polyfill');
24057var polyfill = getPolyfill();
24058var shim = require('./shim');
24059
24060/* eslint-disable no-unused-vars */
24061var boundPromisify = function promisify(orig) {
24062/* eslint-enable no-unused-vars */
24063 return polyfill.apply(util, arguments);
24064};
24065define(boundPromisify, {
24066 custom: polyfill.custom,
24067 customPromisifyArgs: polyfill.customPromisifyArgs,
24068 getPolyfill: getPolyfill,
24069 implementation: implementation,
24070 shim: shim
24071});
24072
24073module.exports = boundPromisify;
24074
24075},{"./implementation":272,"./polyfill":274,"./shim":275,"define-properties":180,"util":277}],274:[function(require,module,exports){
24076'use strict';
24077
24078var util = require('util');
24079var implementation = require('./implementation');
24080
24081module.exports = function getPolyfill() {
24082 if (typeof util.promisify === 'function') {
24083 return util.promisify;
24084 }
24085 return implementation;
24086};
24087
24088},{"./implementation":272,"util":277}],275:[function(require,module,exports){
24089'use strict';
24090
24091var util = require('util');
24092var getPolyfill = require('./polyfill');
24093
24094module.exports = function shimUtilPromisify() {
24095 var polyfill = getPolyfill();
24096 if (polyfill !== util.promisify) {
24097 util.promisify = polyfill;
24098 Object.defineProperty(util, 'promisify', { value: polyfill });
24099 }
24100 return polyfill;
24101};
24102
24103},{"./polyfill":274,"util":277}],276:[function(require,module,exports){
24104module.exports = function isBuffer(arg) {
24105 return arg && typeof arg === 'object'
24106 && typeof arg.copy === 'function'
24107 && typeof arg.fill === 'function'
24108 && typeof arg.readUInt8 === 'function';
24109}
24110},{}],277:[function(require,module,exports){
24111(function (process,global){
24112// Copyright Joyent, Inc. and other Node contributors.
24113//
24114// Permission is hereby granted, free of charge, to any person obtaining a
24115// copy of this software and associated documentation files (the
24116// "Software"), to deal in the Software without restriction, including
24117// without limitation the rights to use, copy, modify, merge, publish,
24118// distribute, sublicense, and/or sell copies of the Software, and to permit
24119// persons to whom the Software is furnished to do so, subject to the
24120// following conditions:
24121//
24122// The above copyright notice and this permission notice shall be included
24123// in all copies or substantial portions of the Software.
24124//
24125// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24126// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24127// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
24128// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
24129// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24130// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24131// USE OR OTHER DEALINGS IN THE SOFTWARE.
24132
24133var formatRegExp = /%[sdj%]/g;
24134exports.format = function(f) {
24135 if (!isString(f)) {
24136 var objects = [];
24137 for (var i = 0; i < arguments.length; i++) {
24138 objects.push(inspect(arguments[i]));
24139 }
24140 return objects.join(' ');
24141 }
24142
24143 var i = 1;
24144 var args = arguments;
24145 var len = args.length;
24146 var str = String(f).replace(formatRegExp, function(x) {
24147 if (x === '%%') return '%';
24148 if (i >= len) return x;
24149 switch (x) {
24150 case '%s': return String(args[i++]);
24151 case '%d': return Number(args[i++]);
24152 case '%j':
24153 try {
24154 return JSON.stringify(args[i++]);
24155 } catch (_) {
24156 return '[Circular]';
24157 }
24158 default:
24159 return x;
24160 }
24161 });
24162 for (var x = args[i]; i < len; x = args[++i]) {
24163 if (isNull(x) || !isObject(x)) {
24164 str += ' ' + x;
24165 } else {
24166 str += ' ' + inspect(x);
24167 }
24168 }
24169 return str;
24170};
24171
24172
24173// Mark that a method should not be used.
24174// Returns a modified function which warns once by default.
24175// If --no-deprecation is set, then it is a no-op.
24176exports.deprecate = function(fn, msg) {
24177 // Allow for deprecating things in the process of starting up.
24178 if (isUndefined(global.process)) {
24179 return function() {
24180 return exports.deprecate(fn, msg).apply(this, arguments);
24181 };
24182 }
24183
24184 if (process.noDeprecation === true) {
24185 return fn;
24186 }
24187
24188 var warned = false;
24189 function deprecated() {
24190 if (!warned) {
24191 if (process.throwDeprecation) {
24192 throw new Error(msg);
24193 } else if (process.traceDeprecation) {
24194 console.trace(msg);
24195 } else {
24196 console.error(msg);
24197 }
24198 warned = true;
24199 }
24200 return fn.apply(this, arguments);
24201 }
24202
24203 return deprecated;
24204};
24205
24206
24207var debugs = {};
24208var debugEnviron;
24209exports.debuglog = function(set) {
24210 if (isUndefined(debugEnviron))
24211 debugEnviron = process.env.NODE_DEBUG || '';
24212 set = set.toUpperCase();
24213 if (!debugs[set]) {
24214 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
24215 var pid = process.pid;
24216 debugs[set] = function() {
24217 var msg = exports.format.apply(exports, arguments);
24218 console.error('%s %d: %s', set, pid, msg);
24219 };
24220 } else {
24221 debugs[set] = function() {};
24222 }
24223 }
24224 return debugs[set];
24225};
24226
24227
24228/**
24229 * Echos the value of a value. Trys to print the value out
24230 * in the best way possible given the different types.
24231 *
24232 * @param {Object} obj The object to print out.
24233 * @param {Object} opts Optional options object that alters the output.
24234 */
24235/* legacy: obj, showHidden, depth, colors*/
24236function inspect(obj, opts) {
24237 // default options
24238 var ctx = {
24239 seen: [],
24240 stylize: stylizeNoColor
24241 };
24242 // legacy...
24243 if (arguments.length >= 3) ctx.depth = arguments[2];
24244 if (arguments.length >= 4) ctx.colors = arguments[3];
24245 if (isBoolean(opts)) {
24246 // legacy...
24247 ctx.showHidden = opts;
24248 } else if (opts) {
24249 // got an "options" object
24250 exports._extend(ctx, opts);
24251 }
24252 // set default options
24253 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
24254 if (isUndefined(ctx.depth)) ctx.depth = 2;
24255 if (isUndefined(ctx.colors)) ctx.colors = false;
24256 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
24257 if (ctx.colors) ctx.stylize = stylizeWithColor;
24258 return formatValue(ctx, obj, ctx.depth);
24259}
24260exports.inspect = inspect;
24261
24262
24263// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
24264inspect.colors = {
24265 'bold' : [1, 22],
24266 'italic' : [3, 23],
24267 'underline' : [4, 24],
24268 'inverse' : [7, 27],
24269 'white' : [37, 39],
24270 'grey' : [90, 39],
24271 'black' : [30, 39],
24272 'blue' : [34, 39],
24273 'cyan' : [36, 39],
24274 'green' : [32, 39],
24275 'magenta' : [35, 39],
24276 'red' : [31, 39],
24277 'yellow' : [33, 39]
24278};
24279
24280// Don't use 'blue' not visible on cmd.exe
24281inspect.styles = {
24282 'special': 'cyan',
24283 'number': 'yellow',
24284 'boolean': 'yellow',
24285 'undefined': 'grey',
24286 'null': 'bold',
24287 'string': 'green',
24288 'date': 'magenta',
24289 // "name": intentionally not styling
24290 'regexp': 'red'
24291};
24292
24293
24294function stylizeWithColor(str, styleType) {
24295 var style = inspect.styles[styleType];
24296
24297 if (style) {
24298 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
24299 '\u001b[' + inspect.colors[style][1] + 'm';
24300 } else {
24301 return str;
24302 }
24303}
24304
24305
24306function stylizeNoColor(str, styleType) {
24307 return str;
24308}
24309
24310
24311function arrayToHash(array) {
24312 var hash = {};
24313
24314 array.forEach(function(val, idx) {
24315 hash[val] = true;
24316 });
24317
24318 return hash;
24319}
24320
24321
24322function formatValue(ctx, value, recurseTimes) {
24323 // Provide a hook for user-specified inspect functions.
24324 // Check that value is an object with an inspect function on it
24325 if (ctx.customInspect &&
24326 value &&
24327 isFunction(value.inspect) &&
24328 // Filter out the util module, it's inspect function is special
24329 value.inspect !== exports.inspect &&
24330 // Also filter out any prototype objects using the circular check.
24331 !(value.constructor && value.constructor.prototype === value)) {
24332 var ret = value.inspect(recurseTimes, ctx);
24333 if (!isString(ret)) {
24334 ret = formatValue(ctx, ret, recurseTimes);
24335 }
24336 return ret;
24337 }
24338
24339 // Primitive types cannot have properties
24340 var primitive = formatPrimitive(ctx, value);
24341 if (primitive) {
24342 return primitive;
24343 }
24344
24345 // Look up the keys of the object.
24346 var keys = Object.keys(value);
24347 var visibleKeys = arrayToHash(keys);
24348
24349 if (ctx.showHidden) {
24350 keys = Object.getOwnPropertyNames(value);
24351 }
24352
24353 // IE doesn't make error fields non-enumerable
24354 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
24355 if (isError(value)
24356 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
24357 return formatError(value);
24358 }
24359
24360 // Some type of object without properties can be shortcutted.
24361 if (keys.length === 0) {
24362 if (isFunction(value)) {
24363 var name = value.name ? ': ' + value.name : '';
24364 return ctx.stylize('[Function' + name + ']', 'special');
24365 }
24366 if (isRegExp(value)) {
24367 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
24368 }
24369 if (isDate(value)) {
24370 return ctx.stylize(Date.prototype.toString.call(value), 'date');
24371 }
24372 if (isError(value)) {
24373 return formatError(value);
24374 }
24375 }
24376
24377 var base = '', array = false, braces = ['{', '}'];
24378
24379 // Make Array say that they are Array
24380 if (isArray(value)) {
24381 array = true;
24382 braces = ['[', ']'];
24383 }
24384
24385 // Make functions say that they are functions
24386 if (isFunction(value)) {
24387 var n = value.name ? ': ' + value.name : '';
24388 base = ' [Function' + n + ']';
24389 }
24390
24391 // Make RegExps say that they are RegExps
24392 if (isRegExp(value)) {
24393 base = ' ' + RegExp.prototype.toString.call(value);
24394 }
24395
24396 // Make dates with properties first say the date
24397 if (isDate(value)) {
24398 base = ' ' + Date.prototype.toUTCString.call(value);
24399 }
24400
24401 // Make error with message first say the error
24402 if (isError(value)) {
24403 base = ' ' + formatError(value);
24404 }
24405
24406 if (keys.length === 0 && (!array || value.length == 0)) {
24407 return braces[0] + base + braces[1];
24408 }
24409
24410 if (recurseTimes < 0) {
24411 if (isRegExp(value)) {
24412 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
24413 } else {
24414 return ctx.stylize('[Object]', 'special');
24415 }
24416 }
24417
24418 ctx.seen.push(value);
24419
24420 var output;
24421 if (array) {
24422 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
24423 } else {
24424 output = keys.map(function(key) {
24425 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
24426 });
24427 }
24428
24429 ctx.seen.pop();
24430
24431 return reduceToSingleString(output, base, braces);
24432}
24433
24434
24435function formatPrimitive(ctx, value) {
24436 if (isUndefined(value))
24437 return ctx.stylize('undefined', 'undefined');
24438 if (isString(value)) {
24439 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
24440 .replace(/'/g, "\\'")
24441 .replace(/\\"/g, '"') + '\'';
24442 return ctx.stylize(simple, 'string');
24443 }
24444 if (isNumber(value))
24445 return ctx.stylize('' + value, 'number');
24446 if (isBoolean(value))
24447 return ctx.stylize('' + value, 'boolean');
24448 // For some reason typeof null is "object", so special case here.
24449 if (isNull(value))
24450 return ctx.stylize('null', 'null');
24451}
24452
24453
24454function formatError(value) {
24455 return '[' + Error.prototype.toString.call(value) + ']';
24456}
24457
24458
24459function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
24460 var output = [];
24461 for (var i = 0, l = value.length; i < l; ++i) {
24462 if (hasOwnProperty(value, String(i))) {
24463 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
24464 String(i), true));
24465 } else {
24466 output.push('');
24467 }
24468 }
24469 keys.forEach(function(key) {
24470 if (!key.match(/^\d+$/)) {
24471 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
24472 key, true));
24473 }
24474 });
24475 return output;
24476}
24477
24478
24479function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
24480 var name, str, desc;
24481 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
24482 if (desc.get) {
24483 if (desc.set) {
24484 str = ctx.stylize('[Getter/Setter]', 'special');
24485 } else {
24486 str = ctx.stylize('[Getter]', 'special');
24487 }
24488 } else {
24489 if (desc.set) {
24490 str = ctx.stylize('[Setter]', 'special');
24491 }
24492 }
24493 if (!hasOwnProperty(visibleKeys, key)) {
24494 name = '[' + key + ']';
24495 }
24496 if (!str) {
24497 if (ctx.seen.indexOf(desc.value) < 0) {
24498 if (isNull(recurseTimes)) {
24499 str = formatValue(ctx, desc.value, null);
24500 } else {
24501 str = formatValue(ctx, desc.value, recurseTimes - 1);
24502 }
24503 if (str.indexOf('\n') > -1) {
24504 if (array) {
24505 str = str.split('\n').map(function(line) {
24506 return ' ' + line;
24507 }).join('\n').substr(2);
24508 } else {
24509 str = '\n' + str.split('\n').map(function(line) {
24510 return ' ' + line;
24511 }).join('\n');
24512 }
24513 }
24514 } else {
24515 str = ctx.stylize('[Circular]', 'special');
24516 }
24517 }
24518 if (isUndefined(name)) {
24519 if (array && key.match(/^\d+$/)) {
24520 return str;
24521 }
24522 name = JSON.stringify('' + key);
24523 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
24524 name = name.substr(1, name.length - 2);
24525 name = ctx.stylize(name, 'name');
24526 } else {
24527 name = name.replace(/'/g, "\\'")
24528 .replace(/\\"/g, '"')
24529 .replace(/(^"|"$)/g, "'");
24530 name = ctx.stylize(name, 'string');
24531 }
24532 }
24533
24534 return name + ': ' + str;
24535}
24536
24537
24538function reduceToSingleString(output, base, braces) {
24539 var numLinesEst = 0;
24540 var length = output.reduce(function(prev, cur) {
24541 numLinesEst++;
24542 if (cur.indexOf('\n') >= 0) numLinesEst++;
24543 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
24544 }, 0);
24545
24546 if (length > 60) {
24547 return braces[0] +
24548 (base === '' ? '' : base + '\n ') +
24549 ' ' +
24550 output.join(',\n ') +
24551 ' ' +
24552 braces[1];
24553 }
24554
24555 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
24556}
24557
24558
24559// NOTE: These type checking functions intentionally don't use `instanceof`
24560// because it is fragile and can be easily faked with `Object.create()`.
24561function isArray(ar) {
24562 return Array.isArray(ar);
24563}
24564exports.isArray = isArray;
24565
24566function isBoolean(arg) {
24567 return typeof arg === 'boolean';
24568}
24569exports.isBoolean = isBoolean;
24570
24571function isNull(arg) {
24572 return arg === null;
24573}
24574exports.isNull = isNull;
24575
24576function isNullOrUndefined(arg) {
24577 return arg == null;
24578}
24579exports.isNullOrUndefined = isNullOrUndefined;
24580
24581function isNumber(arg) {
24582 return typeof arg === 'number';
24583}
24584exports.isNumber = isNumber;
24585
24586function isString(arg) {
24587 return typeof arg === 'string';
24588}
24589exports.isString = isString;
24590
24591function isSymbol(arg) {
24592 return typeof arg === 'symbol';
24593}
24594exports.isSymbol = isSymbol;
24595
24596function isUndefined(arg) {
24597 return arg === void 0;
24598}
24599exports.isUndefined = isUndefined;
24600
24601function isRegExp(re) {
24602 return isObject(re) && objectToString(re) === '[object RegExp]';
24603}
24604exports.isRegExp = isRegExp;
24605
24606function isObject(arg) {
24607 return typeof arg === 'object' && arg !== null;
24608}
24609exports.isObject = isObject;
24610
24611function isDate(d) {
24612 return isObject(d) && objectToString(d) === '[object Date]';
24613}
24614exports.isDate = isDate;
24615
24616function isError(e) {
24617 return isObject(e) &&
24618 (objectToString(e) === '[object Error]' || e instanceof Error);
24619}
24620exports.isError = isError;
24621
24622function isFunction(arg) {
24623 return typeof arg === 'function';
24624}
24625exports.isFunction = isFunction;
24626
24627function isPrimitive(arg) {
24628 return arg === null ||
24629 typeof arg === 'boolean' ||
24630 typeof arg === 'number' ||
24631 typeof arg === 'string' ||
24632 typeof arg === 'symbol' || // ES6 symbol
24633 typeof arg === 'undefined';
24634}
24635exports.isPrimitive = isPrimitive;
24636
24637exports.isBuffer = require('./support/isBuffer');
24638
24639function objectToString(o) {
24640 return Object.prototype.toString.call(o);
24641}
24642
24643
24644function pad(n) {
24645 return n < 10 ? '0' + n.toString(10) : n.toString(10);
24646}
24647
24648
24649var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
24650 'Oct', 'Nov', 'Dec'];
24651
24652// 26 Feb 16:19:34
24653function timestamp() {
24654 var d = new Date();
24655 var time = [pad(d.getHours()),
24656 pad(d.getMinutes()),
24657 pad(d.getSeconds())].join(':');
24658 return [d.getDate(), months[d.getMonth()], time].join(' ');
24659}
24660
24661
24662// log is just a thin wrapper to console.log that prepends a timestamp
24663exports.log = function() {
24664 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
24665};
24666
24667
24668/**
24669 * Inherit the prototype methods from one constructor into another.
24670 *
24671 * The Function.prototype.inherits from lang.js rewritten as a standalone
24672 * function (not on Function.prototype). NOTE: If this file is to be loaded
24673 * during bootstrapping this function needs to be rewritten using some native
24674 * functions as prototype setup using normal JavaScript does not work as
24675 * expected during bootstrapping (see mirror.js in r114903).
24676 *
24677 * @param {function} ctor Constructor function which needs to inherit the
24678 * prototype.
24679 * @param {function} superCtor Constructor function to inherit prototype from.
24680 */
24681exports.inherits = require('inherits');
24682
24683exports._extend = function(origin, add) {
24684 // Don't do anything if add isn't an object
24685 if (!add || !isObject(add)) return origin;
24686
24687 var keys = Object.keys(add);
24688 var i = keys.length;
24689 while (i--) {
24690 origin[keys[i]] = add[keys[i]];
24691 }
24692 return origin;
24693};
24694
24695function hasOwnProperty(obj, prop) {
24696 return Object.prototype.hasOwnProperty.call(obj, prop);
24697}
24698
24699}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
24700},{"./support/isBuffer":276,"_process":239,"inherits":216}],278:[function(require,module,exports){
24701"use strict";
24702
24703// Generated by CoffeeScript 1.12.7
24704(function () {
24705 "use strict";
24706
24707 exports.stripBOM = function (str) {
24708 if (str[0] === "\uFEFF") {
24709 return str.substring(1);
24710 } else {
24711 return str;
24712 }
24713 };
24714}).call(undefined);
24715
24716},{}],279:[function(require,module,exports){
24717'use strict';
24718
24719var _typeof2 = require('babel-runtime/helpers/typeof');
24720
24721var _typeof3 = _interopRequireDefault(_typeof2);
24722
24723var _keys = require('babel-runtime/core-js/object/keys');
24724
24725var _keys2 = _interopRequireDefault(_keys);
24726
24727function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24728
24729// Generated by CoffeeScript 1.12.7
24730(function () {
24731 "use strict";
24732
24733 var builder,
24734 defaults,
24735 escapeCDATA,
24736 requiresCDATA,
24737 wrapCDATA,
24738 hasProp = {}.hasOwnProperty;
24739
24740 builder = require('xmlbuilder');
24741
24742 defaults = require('./defaults').defaults;
24743
24744 requiresCDATA = function requiresCDATA(entry) {
24745 return typeof entry === "string" && (entry.indexOf('&') >= 0 || entry.indexOf('>') >= 0 || entry.indexOf('<') >= 0);
24746 };
24747
24748 wrapCDATA = function wrapCDATA(entry) {
24749 return "<![CDATA[" + escapeCDATA(entry) + "]]>";
24750 };
24751
24752 escapeCDATA = function escapeCDATA(entry) {
24753 return entry.replace(']]>', ']]]]><![CDATA[>');
24754 };
24755
24756 exports.Builder = function () {
24757 function Builder(opts) {
24758 var key, ref, value;
24759 this.options = {};
24760 ref = defaults["0.2"];
24761 for (key in ref) {
24762 if (!hasProp.call(ref, key)) continue;
24763 value = ref[key];
24764 this.options[key] = value;
24765 }
24766 for (key in opts) {
24767 if (!hasProp.call(opts, key)) continue;
24768 value = opts[key];
24769 this.options[key] = value;
24770 }
24771 }
24772
24773 Builder.prototype.buildObject = function (rootObj) {
24774 var attrkey, charkey, render, rootElement, rootName;
24775 attrkey = this.options.attrkey;
24776 charkey = this.options.charkey;
24777 if ((0, _keys2.default)(rootObj).length === 1 && this.options.rootName === defaults['0.2'].rootName) {
24778 rootName = (0, _keys2.default)(rootObj)[0];
24779 rootObj = rootObj[rootName];
24780 } else {
24781 rootName = this.options.rootName;
24782 }
24783 render = function (_this) {
24784 return function (element, obj) {
24785 var attr, child, entry, index, key, value;
24786 if ((typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) !== 'object') {
24787 if (_this.options.cdata && requiresCDATA(obj)) {
24788 element.raw(wrapCDATA(obj));
24789 } else {
24790 element.txt(obj);
24791 }
24792 } else if (Array.isArray(obj)) {
24793 for (index in obj) {
24794 if (!hasProp.call(obj, index)) continue;
24795 child = obj[index];
24796 for (key in child) {
24797 entry = child[key];
24798 element = render(element.ele(key), entry).up();
24799 }
24800 }
24801 } else {
24802 for (key in obj) {
24803 if (!hasProp.call(obj, key)) continue;
24804 child = obj[key];
24805 if (key === attrkey) {
24806 if ((typeof child === 'undefined' ? 'undefined' : (0, _typeof3.default)(child)) === "object") {
24807 for (attr in child) {
24808 value = child[attr];
24809 element = element.att(attr, value);
24810 }
24811 }
24812 } else if (key === charkey) {
24813 if (_this.options.cdata && requiresCDATA(child)) {
24814 element = element.raw(wrapCDATA(child));
24815 } else {
24816 element = element.txt(child);
24817 }
24818 } else if (Array.isArray(child)) {
24819 for (index in child) {
24820 if (!hasProp.call(child, index)) continue;
24821 entry = child[index];
24822 if (typeof entry === 'string') {
24823 if (_this.options.cdata && requiresCDATA(entry)) {
24824 element = element.ele(key).raw(wrapCDATA(entry)).up();
24825 } else {
24826 element = element.ele(key, entry).up();
24827 }
24828 } else {
24829 element = render(element.ele(key), entry).up();
24830 }
24831 }
24832 } else if ((typeof child === 'undefined' ? 'undefined' : (0, _typeof3.default)(child)) === "object") {
24833 element = render(element.ele(key), child).up();
24834 } else {
24835 if (typeof child === 'string' && _this.options.cdata && requiresCDATA(child)) {
24836 element = element.ele(key).raw(wrapCDATA(child)).up();
24837 } else {
24838 if (child == null) {
24839 child = '';
24840 }
24841 element = element.ele(key, child.toString()).up();
24842 }
24843 }
24844 }
24845 }
24846 return element;
24847 };
24848 }(this);
24849 rootElement = builder.create(rootName, this.options.xmldec, this.options.doctype, {
24850 headless: this.options.headless,
24851 allowSurrogateChars: this.options.allowSurrogateChars
24852 });
24853 return render(rootElement, rootObj).end(this.options.renderOpts);
24854 };
24855
24856 return Builder;
24857 }();
24858}).call(undefined);
24859
24860},{"./defaults":280,"babel-runtime/core-js/object/keys":45,"babel-runtime/helpers/typeof":54,"xmlbuilder":316}],280:[function(require,module,exports){
24861"use strict";
24862
24863// Generated by CoffeeScript 1.12.7
24864(function () {
24865 exports.defaults = {
24866 "0.1": {
24867 explicitCharkey: false,
24868 trim: true,
24869 normalize: true,
24870 normalizeTags: false,
24871 attrkey: "@",
24872 charkey: "#",
24873 explicitArray: false,
24874 ignoreAttrs: false,
24875 mergeAttrs: false,
24876 explicitRoot: false,
24877 validator: null,
24878 xmlns: false,
24879 explicitChildren: false,
24880 childkey: '@@',
24881 charsAsChildren: false,
24882 includeWhiteChars: false,
24883 async: false,
24884 strict: true,
24885 attrNameProcessors: null,
24886 attrValueProcessors: null,
24887 tagNameProcessors: null,
24888 valueProcessors: null,
24889 emptyTag: ''
24890 },
24891 "0.2": {
24892 explicitCharkey: false,
24893 trim: false,
24894 normalize: false,
24895 normalizeTags: false,
24896 attrkey: "$",
24897 charkey: "_",
24898 explicitArray: true,
24899 ignoreAttrs: false,
24900 mergeAttrs: false,
24901 explicitRoot: true,
24902 validator: null,
24903 xmlns: false,
24904 explicitChildren: false,
24905 preserveChildrenOrder: false,
24906 childkey: '$$',
24907 charsAsChildren: false,
24908 includeWhiteChars: false,
24909 async: false,
24910 strict: true,
24911 attrNameProcessors: null,
24912 attrValueProcessors: null,
24913 tagNameProcessors: null,
24914 valueProcessors: null,
24915 rootName: 'root',
24916 xmldec: {
24917 'version': '1.0',
24918 'encoding': 'UTF-8',
24919 'standalone': true
24920 },
24921 doctype: null,
24922 renderOpts: {
24923 'pretty': true,
24924 'indent': ' ',
24925 'newline': '\n'
24926 },
24927 headless: false,
24928 chunkSize: 10000,
24929 emptyTag: '',
24930 cdata: false
24931 }
24932 };
24933}).call(undefined);
24934
24935},{}],281:[function(require,module,exports){
24936'use strict';
24937
24938var _getOwnPropertyNames = require('babel-runtime/core-js/object/get-own-property-names');
24939
24940var _getOwnPropertyNames2 = _interopRequireDefault(_getOwnPropertyNames);
24941
24942var _keys = require('babel-runtime/core-js/object/keys');
24943
24944var _keys2 = _interopRequireDefault(_keys);
24945
24946var _typeof2 = require('babel-runtime/helpers/typeof');
24947
24948var _typeof3 = _interopRequireDefault(_typeof2);
24949
24950function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24951
24952// Generated by CoffeeScript 1.12.7
24953(function () {
24954 "use strict";
24955
24956 var bom,
24957 defaults,
24958 events,
24959 isEmpty,
24960 processItem,
24961 processors,
24962 promisify,
24963 sax,
24964 setImmediate,
24965 bind = function bind(fn, me) {
24966 return function () {
24967 return fn.apply(me, arguments);
24968 };
24969 },
24970 extend = function extend(child, parent) {
24971 for (var key in parent) {
24972 if (hasProp.call(parent, key)) child[key] = parent[key];
24973 }function ctor() {
24974 this.constructor = child;
24975 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
24976 },
24977 hasProp = {}.hasOwnProperty;
24978
24979 sax = require('sax');
24980
24981 events = require('events');
24982
24983 bom = require('./bom');
24984
24985 processors = require('./processors');
24986
24987 setImmediate = require('timers').setImmediate;
24988
24989 defaults = require('./defaults').defaults;
24990
24991 promisify = require('util.promisify');
24992
24993 isEmpty = function isEmpty(thing) {
24994 return (typeof thing === 'undefined' ? 'undefined' : (0, _typeof3.default)(thing)) === "object" && thing != null && (0, _keys2.default)(thing).length === 0;
24995 };
24996
24997 processItem = function processItem(processors, item, key) {
24998 var i, len, process;
24999 for (i = 0, len = processors.length; i < len; i++) {
25000 process = processors[i];
25001 item = process(item, key);
25002 }
25003 return item;
25004 };
25005
25006 exports.Parser = function (superClass) {
25007 extend(Parser, superClass);
25008
25009 function Parser(opts) {
25010 this.parseStringPromise = bind(this.parseStringPromise, this);
25011 this.parseString = bind(this.parseString, this);
25012 this.reset = bind(this.reset, this);
25013 this.assignOrPush = bind(this.assignOrPush, this);
25014 this.processAsync = bind(this.processAsync, this);
25015 var key, ref, value;
25016 if (!(this instanceof exports.Parser)) {
25017 return new exports.Parser(opts);
25018 }
25019 this.options = {};
25020 ref = defaults["0.2"];
25021 for (key in ref) {
25022 if (!hasProp.call(ref, key)) continue;
25023 value = ref[key];
25024 this.options[key] = value;
25025 }
25026 for (key in opts) {
25027 if (!hasProp.call(opts, key)) continue;
25028 value = opts[key];
25029 this.options[key] = value;
25030 }
25031 if (this.options.xmlns) {
25032 this.options.xmlnskey = this.options.attrkey + "ns";
25033 }
25034 if (this.options.normalizeTags) {
25035 if (!this.options.tagNameProcessors) {
25036 this.options.tagNameProcessors = [];
25037 }
25038 this.options.tagNameProcessors.unshift(processors.normalize);
25039 }
25040 this.reset();
25041 }
25042
25043 Parser.prototype.processAsync = function () {
25044 var chunk, err;
25045 try {
25046 if (this.remaining.length <= this.options.chunkSize) {
25047 chunk = this.remaining;
25048 this.remaining = '';
25049 this.saxParser = this.saxParser.write(chunk);
25050 return this.saxParser.close();
25051 } else {
25052 chunk = this.remaining.substr(0, this.options.chunkSize);
25053 this.remaining = this.remaining.substr(this.options.chunkSize, this.remaining.length);
25054 this.saxParser = this.saxParser.write(chunk);
25055 return setImmediate(this.processAsync);
25056 }
25057 } catch (error1) {
25058 err = error1;
25059 if (!this.saxParser.errThrown) {
25060 this.saxParser.errThrown = true;
25061 return this.emit(err);
25062 }
25063 }
25064 };
25065
25066 Parser.prototype.assignOrPush = function (obj, key, newValue) {
25067 if (!(key in obj)) {
25068 if (!this.options.explicitArray) {
25069 return obj[key] = newValue;
25070 } else {
25071 return obj[key] = [newValue];
25072 }
25073 } else {
25074 if (!(obj[key] instanceof Array)) {
25075 obj[key] = [obj[key]];
25076 }
25077 return obj[key].push(newValue);
25078 }
25079 };
25080
25081 Parser.prototype.reset = function () {
25082 var attrkey, charkey, ontext, stack;
25083 this.removeAllListeners();
25084 this.saxParser = sax.parser(this.options.strict, {
25085 trim: false,
25086 normalize: false,
25087 xmlns: this.options.xmlns
25088 });
25089 this.saxParser.errThrown = false;
25090 this.saxParser.onerror = function (_this) {
25091 return function (error) {
25092 _this.saxParser.resume();
25093 if (!_this.saxParser.errThrown) {
25094 _this.saxParser.errThrown = true;
25095 return _this.emit("error", error);
25096 }
25097 };
25098 }(this);
25099 this.saxParser.onend = function (_this) {
25100 return function () {
25101 if (!_this.saxParser.ended) {
25102 _this.saxParser.ended = true;
25103 return _this.emit("end", _this.resultObject);
25104 }
25105 };
25106 }(this);
25107 this.saxParser.ended = false;
25108 this.EXPLICIT_CHARKEY = this.options.explicitCharkey;
25109 this.resultObject = null;
25110 stack = [];
25111 attrkey = this.options.attrkey;
25112 charkey = this.options.charkey;
25113 this.saxParser.onopentag = function (_this) {
25114 return function (node) {
25115 var key, newValue, obj, processedKey, ref;
25116 obj = {};
25117 obj[charkey] = "";
25118 if (!_this.options.ignoreAttrs) {
25119 ref = node.attributes;
25120 for (key in ref) {
25121 if (!hasProp.call(ref, key)) continue;
25122 if (!(attrkey in obj) && !_this.options.mergeAttrs) {
25123 obj[attrkey] = {};
25124 }
25125 newValue = _this.options.attrValueProcessors ? processItem(_this.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key];
25126 processedKey = _this.options.attrNameProcessors ? processItem(_this.options.attrNameProcessors, key) : key;
25127 if (_this.options.mergeAttrs) {
25128 _this.assignOrPush(obj, processedKey, newValue);
25129 } else {
25130 obj[attrkey][processedKey] = newValue;
25131 }
25132 }
25133 }
25134 obj["#name"] = _this.options.tagNameProcessors ? processItem(_this.options.tagNameProcessors, node.name) : node.name;
25135 if (_this.options.xmlns) {
25136 obj[_this.options.xmlnskey] = {
25137 uri: node.uri,
25138 local: node.local
25139 };
25140 }
25141 return stack.push(obj);
25142 };
25143 }(this);
25144 this.saxParser.onclosetag = function (_this) {
25145 return function () {
25146 var cdata, emptyStr, key, node, nodeName, obj, objClone, old, s, xpath;
25147 obj = stack.pop();
25148 nodeName = obj["#name"];
25149 if (!_this.options.explicitChildren || !_this.options.preserveChildrenOrder) {
25150 delete obj["#name"];
25151 }
25152 if (obj.cdata === true) {
25153 cdata = obj.cdata;
25154 delete obj.cdata;
25155 }
25156 s = stack[stack.length - 1];
25157 if (obj[charkey].match(/^\s*$/) && !cdata) {
25158 emptyStr = obj[charkey];
25159 delete obj[charkey];
25160 } else {
25161 if (_this.options.trim) {
25162 obj[charkey] = obj[charkey].trim();
25163 }
25164 if (_this.options.normalize) {
25165 obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim();
25166 }
25167 obj[charkey] = _this.options.valueProcessors ? processItem(_this.options.valueProcessors, obj[charkey], nodeName) : obj[charkey];
25168 if ((0, _keys2.default)(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
25169 obj = obj[charkey];
25170 }
25171 }
25172 if (isEmpty(obj)) {
25173 obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr;
25174 }
25175 if (_this.options.validator != null) {
25176 xpath = "/" + function () {
25177 var i, len, results;
25178 results = [];
25179 for (i = 0, len = stack.length; i < len; i++) {
25180 node = stack[i];
25181 results.push(node["#name"]);
25182 }
25183 return results;
25184 }().concat(nodeName).join("/");
25185 (function () {
25186 var err;
25187 try {
25188 return obj = _this.options.validator(xpath, s && s[nodeName], obj);
25189 } catch (error1) {
25190 err = error1;
25191 return _this.emit("error", err);
25192 }
25193 })();
25194 }
25195 if (_this.options.explicitChildren && !_this.options.mergeAttrs && (typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) === 'object') {
25196 if (!_this.options.preserveChildrenOrder) {
25197 node = {};
25198 if (_this.options.attrkey in obj) {
25199 node[_this.options.attrkey] = obj[_this.options.attrkey];
25200 delete obj[_this.options.attrkey];
25201 }
25202 if (!_this.options.charsAsChildren && _this.options.charkey in obj) {
25203 node[_this.options.charkey] = obj[_this.options.charkey];
25204 delete obj[_this.options.charkey];
25205 }
25206 if ((0, _getOwnPropertyNames2.default)(obj).length > 0) {
25207 node[_this.options.childkey] = obj;
25208 }
25209 obj = node;
25210 } else if (s) {
25211 s[_this.options.childkey] = s[_this.options.childkey] || [];
25212 objClone = {};
25213 for (key in obj) {
25214 if (!hasProp.call(obj, key)) continue;
25215 objClone[key] = obj[key];
25216 }
25217 s[_this.options.childkey].push(objClone);
25218 delete obj["#name"];
25219 if ((0, _keys2.default)(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
25220 obj = obj[charkey];
25221 }
25222 }
25223 }
25224 if (stack.length > 0) {
25225 return _this.assignOrPush(s, nodeName, obj);
25226 } else {
25227 if (_this.options.explicitRoot) {
25228 old = obj;
25229 obj = {};
25230 obj[nodeName] = old;
25231 }
25232 _this.resultObject = obj;
25233 _this.saxParser.ended = true;
25234 return _this.emit("end", _this.resultObject);
25235 }
25236 };
25237 }(this);
25238 ontext = function (_this) {
25239 return function (text) {
25240 var charChild, s;
25241 s = stack[stack.length - 1];
25242 if (s) {
25243 s[charkey] += text;
25244 if (_this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && (_this.options.includeWhiteChars || text.replace(/\\n/g, '').trim() !== '')) {
25245 s[_this.options.childkey] = s[_this.options.childkey] || [];
25246 charChild = {
25247 '#name': '__text__'
25248 };
25249 charChild[charkey] = text;
25250 if (_this.options.normalize) {
25251 charChild[charkey] = charChild[charkey].replace(/\s{2,}/g, " ").trim();
25252 }
25253 s[_this.options.childkey].push(charChild);
25254 }
25255 return s;
25256 }
25257 };
25258 }(this);
25259 this.saxParser.ontext = ontext;
25260 return this.saxParser.oncdata = function (_this) {
25261 return function (text) {
25262 var s;
25263 s = ontext(text);
25264 if (s) {
25265 return s.cdata = true;
25266 }
25267 };
25268 }(this);
25269 };
25270
25271 Parser.prototype.parseString = function (str, cb) {
25272 var err;
25273 if (cb != null && typeof cb === "function") {
25274 this.on("end", function (result) {
25275 this.reset();
25276 return cb(null, result);
25277 });
25278 this.on("error", function (err) {
25279 this.reset();
25280 return cb(err);
25281 });
25282 }
25283 try {
25284 str = str.toString();
25285 if (str.trim() === '') {
25286 this.emit("end", null);
25287 return true;
25288 }
25289 str = bom.stripBOM(str);
25290 if (this.options.async) {
25291 this.remaining = str;
25292 setImmediate(this.processAsync);
25293 return this.saxParser;
25294 }
25295 return this.saxParser.write(str).close();
25296 } catch (error1) {
25297 err = error1;
25298 if (!(this.saxParser.errThrown || this.saxParser.ended)) {
25299 this.emit('error', err);
25300 return this.saxParser.errThrown = true;
25301 } else if (this.saxParser.ended) {
25302 throw err;
25303 }
25304 }
25305 };
25306
25307 Parser.prototype.parseStringPromise = function (str) {
25308 return promisify(this.parseString)(str);
25309 };
25310
25311 return Parser;
25312 }(events);
25313
25314 exports.parseString = function (str, a, b) {
25315 var cb, options, parser;
25316 if (b != null) {
25317 if (typeof b === 'function') {
25318 cb = b;
25319 }
25320 if ((typeof a === 'undefined' ? 'undefined' : (0, _typeof3.default)(a)) === 'object') {
25321 options = a;
25322 }
25323 } else {
25324 if (typeof a === 'function') {
25325 cb = a;
25326 }
25327 options = {};
25328 }
25329 parser = new exports.Parser(options);
25330 return parser.parseString(str, cb);
25331 };
25332
25333 exports.parseStringPromise = function (str, a) {
25334 var options, parser;
25335 if ((typeof a === 'undefined' ? 'undefined' : (0, _typeof3.default)(a)) === 'object') {
25336 options = a;
25337 }
25338 parser = new exports.Parser(options);
25339 return parser.parseStringPromise(str);
25340 };
25341}).call(undefined);
25342
25343},{"./bom":278,"./defaults":280,"./processors":282,"babel-runtime/core-js/object/get-own-property-names":43,"babel-runtime/core-js/object/keys":45,"babel-runtime/helpers/typeof":54,"events":206,"sax":260,"timers":267,"util.promisify":273}],282:[function(require,module,exports){
25344'use strict';
25345
25346// Generated by CoffeeScript 1.12.7
25347(function () {
25348 "use strict";
25349
25350 var prefixMatch;
25351
25352 prefixMatch = new RegExp(/(?!xmlns)^.*:/);
25353
25354 exports.normalize = function (str) {
25355 return str.toLowerCase();
25356 };
25357
25358 exports.firstCharLowerCase = function (str) {
25359 return str.charAt(0).toLowerCase() + str.slice(1);
25360 };
25361
25362 exports.stripPrefix = function (str) {
25363 return str.replace(prefixMatch, '');
25364 };
25365
25366 exports.parseNumbers = function (str) {
25367 if (!isNaN(str)) {
25368 str = str % 1 === 0 ? parseInt(str, 10) : parseFloat(str);
25369 }
25370 return str;
25371 };
25372
25373 exports.parseBooleans = function (str) {
25374 if (/^(?:true|false)$/i.test(str)) {
25375 str = str.toLowerCase() === 'true';
25376 }
25377 return str;
25378 };
25379}).call(undefined);
25380
25381},{}],283:[function(require,module,exports){
25382'use strict';
25383
25384// Generated by CoffeeScript 1.12.7
25385(function () {
25386 "use strict";
25387
25388 var builder,
25389 defaults,
25390 parser,
25391 processors,
25392 extend = function extend(child, parent) {
25393 for (var key in parent) {
25394 if (hasProp.call(parent, key)) child[key] = parent[key];
25395 }function ctor() {
25396 this.constructor = child;
25397 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
25398 },
25399 hasProp = {}.hasOwnProperty;
25400
25401 defaults = require('./defaults');
25402
25403 builder = require('./builder');
25404
25405 parser = require('./parser');
25406
25407 processors = require('./processors');
25408
25409 exports.defaults = defaults.defaults;
25410
25411 exports.processors = processors;
25412
25413 exports.ValidationError = function (superClass) {
25414 extend(ValidationError, superClass);
25415
25416 function ValidationError(message) {
25417 this.message = message;
25418 }
25419
25420 return ValidationError;
25421 }(Error);
25422
25423 exports.Builder = builder.Builder;
25424
25425 exports.Parser = parser.Parser;
25426
25427 exports.parseString = parser.parseString;
25428
25429 exports.parseStringPromise = parser.parseStringPromise;
25430}).call(undefined);
25431
25432},{"./builder":279,"./defaults":280,"./parser":281,"./processors":282}],284:[function(require,module,exports){
25433"use strict";
25434
25435// Generated by CoffeeScript 1.12.7
25436(function () {
25437 module.exports = {
25438 Disconnected: 1,
25439 Preceding: 2,
25440 Following: 4,
25441 Contains: 8,
25442 ContainedBy: 16,
25443 ImplementationSpecific: 32
25444 };
25445}).call(undefined);
25446
25447},{}],285:[function(require,module,exports){
25448"use strict";
25449
25450// Generated by CoffeeScript 1.12.7
25451(function () {
25452 module.exports = {
25453 Element: 1,
25454 Attribute: 2,
25455 Text: 3,
25456 CData: 4,
25457 EntityReference: 5,
25458 EntityDeclaration: 6,
25459 ProcessingInstruction: 7,
25460 Comment: 8,
25461 Document: 9,
25462 DocType: 10,
25463 DocumentFragment: 11,
25464 NotationDeclaration: 12,
25465 Declaration: 201,
25466 Raw: 202,
25467 AttributeDeclaration: 203,
25468 ElementDeclaration: 204,
25469 Dummy: 205
25470 };
25471}).call(undefined);
25472
25473},{}],286:[function(require,module,exports){
25474'use strict';
25475
25476var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
25477
25478var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
25479
25480var _typeof2 = require('babel-runtime/helpers/typeof');
25481
25482var _typeof3 = _interopRequireDefault(_typeof2);
25483
25484var _assign = require('babel-runtime/core-js/object/assign');
25485
25486var _assign2 = _interopRequireDefault(_assign);
25487
25488function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25489
25490// Generated by CoffeeScript 1.12.7
25491(function () {
25492 var assign,
25493 getValue,
25494 isArray,
25495 isEmpty,
25496 isFunction,
25497 isObject,
25498 isPlainObject,
25499 slice = [].slice,
25500 hasProp = {}.hasOwnProperty;
25501
25502 assign = function assign() {
25503 var i, key, len, source, sources, target;
25504 target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
25505 if (isFunction(_assign2.default)) {
25506 _assign2.default.apply(null, arguments);
25507 } else {
25508 for (i = 0, len = sources.length; i < len; i++) {
25509 source = sources[i];
25510 if (source != null) {
25511 for (key in source) {
25512 if (!hasProp.call(source, key)) continue;
25513 target[key] = source[key];
25514 }
25515 }
25516 }
25517 }
25518 return target;
25519 };
25520
25521 isFunction = function isFunction(val) {
25522 return !!val && Object.prototype.toString.call(val) === '[object Function]';
25523 };
25524
25525 isObject = function isObject(val) {
25526 var ref;
25527 return !!val && ((ref = typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val)) === 'function' || ref === 'object');
25528 };
25529
25530 isArray = function isArray(val) {
25531 if (isFunction(Array.isArray)) {
25532 return Array.isArray(val);
25533 } else {
25534 return Object.prototype.toString.call(val) === '[object Array]';
25535 }
25536 };
25537
25538 isEmpty = function isEmpty(val) {
25539 var key;
25540 if (isArray(val)) {
25541 return !val.length;
25542 } else {
25543 for (key in val) {
25544 if (!hasProp.call(val, key)) continue;
25545 return false;
25546 }
25547 return true;
25548 }
25549 };
25550
25551 isPlainObject = function isPlainObject(val) {
25552 var ctor, proto;
25553 return isObject(val) && (proto = (0, _getPrototypeOf2.default)(val)) && (ctor = proto.constructor) && typeof ctor === 'function' && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
25554 };
25555
25556 getValue = function getValue(obj) {
25557 if (isFunction(obj.valueOf)) {
25558 return obj.valueOf();
25559 } else {
25560 return obj;
25561 }
25562 };
25563
25564 module.exports.assign = assign;
25565
25566 module.exports.isFunction = isFunction;
25567
25568 module.exports.isObject = isObject;
25569
25570 module.exports.isArray = isArray;
25571
25572 module.exports.isEmpty = isEmpty;
25573
25574 module.exports.isPlainObject = isPlainObject;
25575
25576 module.exports.getValue = getValue;
25577}).call(undefined);
25578
25579},{"babel-runtime/core-js/object/assign":39,"babel-runtime/core-js/object/get-prototype-of":44,"babel-runtime/helpers/typeof":54}],287:[function(require,module,exports){
25580"use strict";
25581
25582// Generated by CoffeeScript 1.12.7
25583(function () {
25584 module.exports = {
25585 None: 0,
25586 OpenTag: 1,
25587 InsideTag: 2,
25588 CloseTag: 3
25589 };
25590}).call(undefined);
25591
25592},{}],288:[function(require,module,exports){
25593'use strict';
25594
25595var _create = require('babel-runtime/core-js/object/create');
25596
25597var _create2 = _interopRequireDefault(_create);
25598
25599function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25600
25601// Generated by CoffeeScript 1.12.7
25602(function () {
25603 var NodeType, XMLAttribute, XMLNode;
25604
25605 NodeType = require('./NodeType');
25606
25607 XMLNode = require('./XMLNode');
25608
25609 module.exports = XMLAttribute = function () {
25610 function XMLAttribute(parent, name, value) {
25611 this.parent = parent;
25612 if (this.parent) {
25613 this.options = this.parent.options;
25614 this.stringify = this.parent.stringify;
25615 }
25616 if (name == null) {
25617 throw new Error("Missing attribute name. " + this.debugInfo(name));
25618 }
25619 this.name = this.stringify.name(name);
25620 this.value = this.stringify.attValue(value);
25621 this.type = NodeType.Attribute;
25622 this.isId = false;
25623 this.schemaTypeInfo = null;
25624 }
25625
25626 Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
25627 get: function get() {
25628 return this.type;
25629 }
25630 });
25631
25632 Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
25633 get: function get() {
25634 return this.parent;
25635 }
25636 });
25637
25638 Object.defineProperty(XMLAttribute.prototype, 'textContent', {
25639 get: function get() {
25640 return this.value;
25641 },
25642 set: function set(value) {
25643 return this.value = value || '';
25644 }
25645 });
25646
25647 Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
25648 get: function get() {
25649 return '';
25650 }
25651 });
25652
25653 Object.defineProperty(XMLAttribute.prototype, 'prefix', {
25654 get: function get() {
25655 return '';
25656 }
25657 });
25658
25659 Object.defineProperty(XMLAttribute.prototype, 'localName', {
25660 get: function get() {
25661 return this.name;
25662 }
25663 });
25664
25665 Object.defineProperty(XMLAttribute.prototype, 'specified', {
25666 get: function get() {
25667 return true;
25668 }
25669 });
25670
25671 XMLAttribute.prototype.clone = function () {
25672 return (0, _create2.default)(this);
25673 };
25674
25675 XMLAttribute.prototype.toString = function (options) {
25676 return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
25677 };
25678
25679 XMLAttribute.prototype.debugInfo = function (name) {
25680 name = name || this.name;
25681 if (name == null) {
25682 return "parent: <" + this.parent.name + ">";
25683 } else {
25684 return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
25685 }
25686 };
25687
25688 XMLAttribute.prototype.isEqualNode = function (node) {
25689 if (node.namespaceURI !== this.namespaceURI) {
25690 return false;
25691 }
25692 if (node.prefix !== this.prefix) {
25693 return false;
25694 }
25695 if (node.localName !== this.localName) {
25696 return false;
25697 }
25698 if (node.value !== this.value) {
25699 return false;
25700 }
25701 return true;
25702 };
25703
25704 return XMLAttribute;
25705 }();
25706}).call(undefined);
25707
25708},{"./NodeType":285,"./XMLNode":307,"babel-runtime/core-js/object/create":40}],289:[function(require,module,exports){
25709'use strict';
25710
25711var _create = require('babel-runtime/core-js/object/create');
25712
25713var _create2 = _interopRequireDefault(_create);
25714
25715function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25716
25717// Generated by CoffeeScript 1.12.7
25718(function () {
25719 var NodeType,
25720 XMLCData,
25721 XMLCharacterData,
25722 extend = function extend(child, parent) {
25723 for (var key in parent) {
25724 if (hasProp.call(parent, key)) child[key] = parent[key];
25725 }function ctor() {
25726 this.constructor = child;
25727 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
25728 },
25729 hasProp = {}.hasOwnProperty;
25730
25731 NodeType = require('./NodeType');
25732
25733 XMLCharacterData = require('./XMLCharacterData');
25734
25735 module.exports = XMLCData = function (superClass) {
25736 extend(XMLCData, superClass);
25737
25738 function XMLCData(parent, text) {
25739 XMLCData.__super__.constructor.call(this, parent);
25740 if (text == null) {
25741 throw new Error("Missing CDATA text. " + this.debugInfo());
25742 }
25743 this.name = "#cdata-section";
25744 this.type = NodeType.CData;
25745 this.value = this.stringify.cdata(text);
25746 }
25747
25748 XMLCData.prototype.clone = function () {
25749 return (0, _create2.default)(this);
25750 };
25751
25752 XMLCData.prototype.toString = function (options) {
25753 return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
25754 };
25755
25756 return XMLCData;
25757 }(XMLCharacterData);
25758}).call(undefined);
25759
25760},{"./NodeType":285,"./XMLCharacterData":290,"babel-runtime/core-js/object/create":40}],290:[function(require,module,exports){
25761'use strict';
25762
25763var _create = require('babel-runtime/core-js/object/create');
25764
25765var _create2 = _interopRequireDefault(_create);
25766
25767function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25768
25769// Generated by CoffeeScript 1.12.7
25770(function () {
25771 var XMLCharacterData,
25772 XMLNode,
25773 extend = function extend(child, parent) {
25774 for (var key in parent) {
25775 if (hasProp.call(parent, key)) child[key] = parent[key];
25776 }function ctor() {
25777 this.constructor = child;
25778 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
25779 },
25780 hasProp = {}.hasOwnProperty;
25781
25782 XMLNode = require('./XMLNode');
25783
25784 module.exports = XMLCharacterData = function (superClass) {
25785 extend(XMLCharacterData, superClass);
25786
25787 function XMLCharacterData(parent) {
25788 XMLCharacterData.__super__.constructor.call(this, parent);
25789 this.value = '';
25790 }
25791
25792 Object.defineProperty(XMLCharacterData.prototype, 'data', {
25793 get: function get() {
25794 return this.value;
25795 },
25796 set: function set(value) {
25797 return this.value = value || '';
25798 }
25799 });
25800
25801 Object.defineProperty(XMLCharacterData.prototype, 'length', {
25802 get: function get() {
25803 return this.value.length;
25804 }
25805 });
25806
25807 Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
25808 get: function get() {
25809 return this.value;
25810 },
25811 set: function set(value) {
25812 return this.value = value || '';
25813 }
25814 });
25815
25816 XMLCharacterData.prototype.clone = function () {
25817 return (0, _create2.default)(this);
25818 };
25819
25820 XMLCharacterData.prototype.substringData = function (offset, count) {
25821 throw new Error("This DOM method is not implemented." + this.debugInfo());
25822 };
25823
25824 XMLCharacterData.prototype.appendData = function (arg) {
25825 throw new Error("This DOM method is not implemented." + this.debugInfo());
25826 };
25827
25828 XMLCharacterData.prototype.insertData = function (offset, arg) {
25829 throw new Error("This DOM method is not implemented." + this.debugInfo());
25830 };
25831
25832 XMLCharacterData.prototype.deleteData = function (offset, count) {
25833 throw new Error("This DOM method is not implemented." + this.debugInfo());
25834 };
25835
25836 XMLCharacterData.prototype.replaceData = function (offset, count, arg) {
25837 throw new Error("This DOM method is not implemented." + this.debugInfo());
25838 };
25839
25840 XMLCharacterData.prototype.isEqualNode = function (node) {
25841 if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
25842 return false;
25843 }
25844 if (node.data !== this.data) {
25845 return false;
25846 }
25847 return true;
25848 };
25849
25850 return XMLCharacterData;
25851 }(XMLNode);
25852}).call(undefined);
25853
25854},{"./XMLNode":307,"babel-runtime/core-js/object/create":40}],291:[function(require,module,exports){
25855'use strict';
25856
25857var _create = require('babel-runtime/core-js/object/create');
25858
25859var _create2 = _interopRequireDefault(_create);
25860
25861function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25862
25863// Generated by CoffeeScript 1.12.7
25864(function () {
25865 var NodeType,
25866 XMLCharacterData,
25867 XMLComment,
25868 extend = function extend(child, parent) {
25869 for (var key in parent) {
25870 if (hasProp.call(parent, key)) child[key] = parent[key];
25871 }function ctor() {
25872 this.constructor = child;
25873 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
25874 },
25875 hasProp = {}.hasOwnProperty;
25876
25877 NodeType = require('./NodeType');
25878
25879 XMLCharacterData = require('./XMLCharacterData');
25880
25881 module.exports = XMLComment = function (superClass) {
25882 extend(XMLComment, superClass);
25883
25884 function XMLComment(parent, text) {
25885 XMLComment.__super__.constructor.call(this, parent);
25886 if (text == null) {
25887 throw new Error("Missing comment text. " + this.debugInfo());
25888 }
25889 this.name = "#comment";
25890 this.type = NodeType.Comment;
25891 this.value = this.stringify.comment(text);
25892 }
25893
25894 XMLComment.prototype.clone = function () {
25895 return (0, _create2.default)(this);
25896 };
25897
25898 XMLComment.prototype.toString = function (options) {
25899 return this.options.writer.comment(this, this.options.writer.filterOptions(options));
25900 };
25901
25902 return XMLComment;
25903 }(XMLCharacterData);
25904}).call(undefined);
25905
25906},{"./NodeType":285,"./XMLCharacterData":290,"babel-runtime/core-js/object/create":40}],292:[function(require,module,exports){
25907'use strict';
25908
25909var _keys = require('babel-runtime/core-js/object/keys');
25910
25911var _keys2 = _interopRequireDefault(_keys);
25912
25913var _create = require('babel-runtime/core-js/object/create');
25914
25915var _create2 = _interopRequireDefault(_create);
25916
25917function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25918
25919// Generated by CoffeeScript 1.12.7
25920(function () {
25921 var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
25922
25923 XMLDOMErrorHandler = require('./XMLDOMErrorHandler');
25924
25925 XMLDOMStringList = require('./XMLDOMStringList');
25926
25927 module.exports = XMLDOMConfiguration = function () {
25928 function XMLDOMConfiguration() {
25929 var clonedSelf;
25930 this.defaultParams = {
25931 "canonical-form": false,
25932 "cdata-sections": false,
25933 "comments": false,
25934 "datatype-normalization": false,
25935 "element-content-whitespace": true,
25936 "entities": true,
25937 "error-handler": new XMLDOMErrorHandler(),
25938 "infoset": true,
25939 "validate-if-schema": false,
25940 "namespaces": true,
25941 "namespace-declarations": true,
25942 "normalize-characters": false,
25943 "schema-location": '',
25944 "schema-type": '',
25945 "split-cdata-sections": true,
25946 "validate": false,
25947 "well-formed": true
25948 };
25949 this.params = clonedSelf = (0, _create2.default)(this.defaultParams);
25950 }
25951
25952 Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', {
25953 get: function get() {
25954 return new XMLDOMStringList((0, _keys2.default)(this.defaultParams));
25955 }
25956 });
25957
25958 XMLDOMConfiguration.prototype.getParameter = function (name) {
25959 if (this.params.hasOwnProperty(name)) {
25960 return this.params[name];
25961 } else {
25962 return null;
25963 }
25964 };
25965
25966 XMLDOMConfiguration.prototype.canSetParameter = function (name, value) {
25967 return true;
25968 };
25969
25970 XMLDOMConfiguration.prototype.setParameter = function (name, value) {
25971 if (value != null) {
25972 return this.params[name] = value;
25973 } else {
25974 return delete this.params[name];
25975 }
25976 };
25977
25978 return XMLDOMConfiguration;
25979 }();
25980}).call(undefined);
25981
25982},{"./XMLDOMErrorHandler":293,"./XMLDOMStringList":295,"babel-runtime/core-js/object/create":40,"babel-runtime/core-js/object/keys":45}],293:[function(require,module,exports){
25983"use strict";
25984
25985// Generated by CoffeeScript 1.12.7
25986(function () {
25987 var XMLDOMErrorHandler;
25988
25989 module.exports = XMLDOMErrorHandler = function () {
25990 function XMLDOMErrorHandler() {}
25991
25992 XMLDOMErrorHandler.prototype.handleError = function (error) {
25993 throw new Error(error);
25994 };
25995
25996 return XMLDOMErrorHandler;
25997 }();
25998}).call(undefined);
25999
26000},{}],294:[function(require,module,exports){
26001"use strict";
26002
26003// Generated by CoffeeScript 1.12.7
26004(function () {
26005 var XMLDOMImplementation;
26006
26007 module.exports = XMLDOMImplementation = function () {
26008 function XMLDOMImplementation() {}
26009
26010 XMLDOMImplementation.prototype.hasFeature = function (feature, version) {
26011 return true;
26012 };
26013
26014 XMLDOMImplementation.prototype.createDocumentType = function (qualifiedName, publicId, systemId) {
26015 throw new Error("This DOM method is not implemented.");
26016 };
26017
26018 XMLDOMImplementation.prototype.createDocument = function (namespaceURI, qualifiedName, doctype) {
26019 throw new Error("This DOM method is not implemented.");
26020 };
26021
26022 XMLDOMImplementation.prototype.createHTMLDocument = function (title) {
26023 throw new Error("This DOM method is not implemented.");
26024 };
26025
26026 XMLDOMImplementation.prototype.getFeature = function (feature, version) {
26027 throw new Error("This DOM method is not implemented.");
26028 };
26029
26030 return XMLDOMImplementation;
26031 }();
26032}).call(undefined);
26033
26034},{}],295:[function(require,module,exports){
26035'use strict';
26036
26037// Generated by CoffeeScript 1.12.7
26038(function () {
26039 var XMLDOMStringList;
26040
26041 module.exports = XMLDOMStringList = function () {
26042 function XMLDOMStringList(arr) {
26043 this.arr = arr || [];
26044 }
26045
26046 Object.defineProperty(XMLDOMStringList.prototype, 'length', {
26047 get: function get() {
26048 return this.arr.length;
26049 }
26050 });
26051
26052 XMLDOMStringList.prototype.item = function (index) {
26053 return this.arr[index] || null;
26054 };
26055
26056 XMLDOMStringList.prototype.contains = function (str) {
26057 return this.arr.indexOf(str) !== -1;
26058 };
26059
26060 return XMLDOMStringList;
26061 }();
26062}).call(undefined);
26063
26064},{}],296:[function(require,module,exports){
26065'use strict';
26066
26067// Generated by CoffeeScript 1.12.7
26068(function () {
26069 var NodeType,
26070 XMLDTDAttList,
26071 XMLNode,
26072 extend = function extend(child, parent) {
26073 for (var key in parent) {
26074 if (hasProp.call(parent, key)) child[key] = parent[key];
26075 }function ctor() {
26076 this.constructor = child;
26077 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26078 },
26079 hasProp = {}.hasOwnProperty;
26080
26081 XMLNode = require('./XMLNode');
26082
26083 NodeType = require('./NodeType');
26084
26085 module.exports = XMLDTDAttList = function (superClass) {
26086 extend(XMLDTDAttList, superClass);
26087
26088 function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
26089 XMLDTDAttList.__super__.constructor.call(this, parent);
26090 if (elementName == null) {
26091 throw new Error("Missing DTD element name. " + this.debugInfo());
26092 }
26093 if (attributeName == null) {
26094 throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
26095 }
26096 if (!attributeType) {
26097 throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
26098 }
26099 if (!defaultValueType) {
26100 throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
26101 }
26102 if (defaultValueType.indexOf('#') !== 0) {
26103 defaultValueType = '#' + defaultValueType;
26104 }
26105 if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
26106 throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
26107 }
26108 if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
26109 throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
26110 }
26111 this.elementName = this.stringify.name(elementName);
26112 this.type = NodeType.AttributeDeclaration;
26113 this.attributeName = this.stringify.name(attributeName);
26114 this.attributeType = this.stringify.dtdAttType(attributeType);
26115 if (defaultValue) {
26116 this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
26117 }
26118 this.defaultValueType = defaultValueType;
26119 }
26120
26121 XMLDTDAttList.prototype.toString = function (options) {
26122 return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
26123 };
26124
26125 return XMLDTDAttList;
26126 }(XMLNode);
26127}).call(undefined);
26128
26129},{"./NodeType":285,"./XMLNode":307}],297:[function(require,module,exports){
26130'use strict';
26131
26132// Generated by CoffeeScript 1.12.7
26133(function () {
26134 var NodeType,
26135 XMLDTDElement,
26136 XMLNode,
26137 extend = function extend(child, parent) {
26138 for (var key in parent) {
26139 if (hasProp.call(parent, key)) child[key] = parent[key];
26140 }function ctor() {
26141 this.constructor = child;
26142 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26143 },
26144 hasProp = {}.hasOwnProperty;
26145
26146 XMLNode = require('./XMLNode');
26147
26148 NodeType = require('./NodeType');
26149
26150 module.exports = XMLDTDElement = function (superClass) {
26151 extend(XMLDTDElement, superClass);
26152
26153 function XMLDTDElement(parent, name, value) {
26154 XMLDTDElement.__super__.constructor.call(this, parent);
26155 if (name == null) {
26156 throw new Error("Missing DTD element name. " + this.debugInfo());
26157 }
26158 if (!value) {
26159 value = '(#PCDATA)';
26160 }
26161 if (Array.isArray(value)) {
26162 value = '(' + value.join(',') + ')';
26163 }
26164 this.name = this.stringify.name(name);
26165 this.type = NodeType.ElementDeclaration;
26166 this.value = this.stringify.dtdElementValue(value);
26167 }
26168
26169 XMLDTDElement.prototype.toString = function (options) {
26170 return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
26171 };
26172
26173 return XMLDTDElement;
26174 }(XMLNode);
26175}).call(undefined);
26176
26177},{"./NodeType":285,"./XMLNode":307}],298:[function(require,module,exports){
26178'use strict';
26179
26180// Generated by CoffeeScript 1.12.7
26181(function () {
26182 var NodeType,
26183 XMLDTDEntity,
26184 XMLNode,
26185 isObject,
26186 extend = function extend(child, parent) {
26187 for (var key in parent) {
26188 if (hasProp.call(parent, key)) child[key] = parent[key];
26189 }function ctor() {
26190 this.constructor = child;
26191 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26192 },
26193 hasProp = {}.hasOwnProperty;
26194
26195 isObject = require('./Utility').isObject;
26196
26197 XMLNode = require('./XMLNode');
26198
26199 NodeType = require('./NodeType');
26200
26201 module.exports = XMLDTDEntity = function (superClass) {
26202 extend(XMLDTDEntity, superClass);
26203
26204 function XMLDTDEntity(parent, pe, name, value) {
26205 XMLDTDEntity.__super__.constructor.call(this, parent);
26206 if (name == null) {
26207 throw new Error("Missing DTD entity name. " + this.debugInfo(name));
26208 }
26209 if (value == null) {
26210 throw new Error("Missing DTD entity value. " + this.debugInfo(name));
26211 }
26212 this.pe = !!pe;
26213 this.name = this.stringify.name(name);
26214 this.type = NodeType.EntityDeclaration;
26215 if (!isObject(value)) {
26216 this.value = this.stringify.dtdEntityValue(value);
26217 this.internal = true;
26218 } else {
26219 if (!value.pubID && !value.sysID) {
26220 throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
26221 }
26222 if (value.pubID && !value.sysID) {
26223 throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
26224 }
26225 this.internal = false;
26226 if (value.pubID != null) {
26227 this.pubID = this.stringify.dtdPubID(value.pubID);
26228 }
26229 if (value.sysID != null) {
26230 this.sysID = this.stringify.dtdSysID(value.sysID);
26231 }
26232 if (value.nData != null) {
26233 this.nData = this.stringify.dtdNData(value.nData);
26234 }
26235 if (this.pe && this.nData) {
26236 throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
26237 }
26238 }
26239 }
26240
26241 Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
26242 get: function get() {
26243 return this.pubID;
26244 }
26245 });
26246
26247 Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
26248 get: function get() {
26249 return this.sysID;
26250 }
26251 });
26252
26253 Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
26254 get: function get() {
26255 return this.nData || null;
26256 }
26257 });
26258
26259 Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
26260 get: function get() {
26261 return null;
26262 }
26263 });
26264
26265 Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
26266 get: function get() {
26267 return null;
26268 }
26269 });
26270
26271 Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
26272 get: function get() {
26273 return null;
26274 }
26275 });
26276
26277 XMLDTDEntity.prototype.toString = function (options) {
26278 return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
26279 };
26280
26281 return XMLDTDEntity;
26282 }(XMLNode);
26283}).call(undefined);
26284
26285},{"./NodeType":285,"./Utility":286,"./XMLNode":307}],299:[function(require,module,exports){
26286'use strict';
26287
26288// Generated by CoffeeScript 1.12.7
26289(function () {
26290 var NodeType,
26291 XMLDTDNotation,
26292 XMLNode,
26293 extend = function extend(child, parent) {
26294 for (var key in parent) {
26295 if (hasProp.call(parent, key)) child[key] = parent[key];
26296 }function ctor() {
26297 this.constructor = child;
26298 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26299 },
26300 hasProp = {}.hasOwnProperty;
26301
26302 XMLNode = require('./XMLNode');
26303
26304 NodeType = require('./NodeType');
26305
26306 module.exports = XMLDTDNotation = function (superClass) {
26307 extend(XMLDTDNotation, superClass);
26308
26309 function XMLDTDNotation(parent, name, value) {
26310 XMLDTDNotation.__super__.constructor.call(this, parent);
26311 if (name == null) {
26312 throw new Error("Missing DTD notation name. " + this.debugInfo(name));
26313 }
26314 if (!value.pubID && !value.sysID) {
26315 throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
26316 }
26317 this.name = this.stringify.name(name);
26318 this.type = NodeType.NotationDeclaration;
26319 if (value.pubID != null) {
26320 this.pubID = this.stringify.dtdPubID(value.pubID);
26321 }
26322 if (value.sysID != null) {
26323 this.sysID = this.stringify.dtdSysID(value.sysID);
26324 }
26325 }
26326
26327 Object.defineProperty(XMLDTDNotation.prototype, 'publicId', {
26328 get: function get() {
26329 return this.pubID;
26330 }
26331 });
26332
26333 Object.defineProperty(XMLDTDNotation.prototype, 'systemId', {
26334 get: function get() {
26335 return this.sysID;
26336 }
26337 });
26338
26339 XMLDTDNotation.prototype.toString = function (options) {
26340 return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
26341 };
26342
26343 return XMLDTDNotation;
26344 }(XMLNode);
26345}).call(undefined);
26346
26347},{"./NodeType":285,"./XMLNode":307}],300:[function(require,module,exports){
26348'use strict';
26349
26350// Generated by CoffeeScript 1.12.7
26351(function () {
26352 var NodeType,
26353 XMLDeclaration,
26354 XMLNode,
26355 isObject,
26356 extend = function extend(child, parent) {
26357 for (var key in parent) {
26358 if (hasProp.call(parent, key)) child[key] = parent[key];
26359 }function ctor() {
26360 this.constructor = child;
26361 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26362 },
26363 hasProp = {}.hasOwnProperty;
26364
26365 isObject = require('./Utility').isObject;
26366
26367 XMLNode = require('./XMLNode');
26368
26369 NodeType = require('./NodeType');
26370
26371 module.exports = XMLDeclaration = function (superClass) {
26372 extend(XMLDeclaration, superClass);
26373
26374 function XMLDeclaration(parent, version, encoding, standalone) {
26375 var ref;
26376 XMLDeclaration.__super__.constructor.call(this, parent);
26377 if (isObject(version)) {
26378 ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
26379 }
26380 if (!version) {
26381 version = '1.0';
26382 }
26383 this.type = NodeType.Declaration;
26384 this.version = this.stringify.xmlVersion(version);
26385 if (encoding != null) {
26386 this.encoding = this.stringify.xmlEncoding(encoding);
26387 }
26388 if (standalone != null) {
26389 this.standalone = this.stringify.xmlStandalone(standalone);
26390 }
26391 }
26392
26393 XMLDeclaration.prototype.toString = function (options) {
26394 return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
26395 };
26396
26397 return XMLDeclaration;
26398 }(XMLNode);
26399}).call(undefined);
26400
26401},{"./NodeType":285,"./Utility":286,"./XMLNode":307}],301:[function(require,module,exports){
26402'use strict';
26403
26404// Generated by CoffeeScript 1.12.7
26405(function () {
26406 var NodeType,
26407 XMLDTDAttList,
26408 XMLDTDElement,
26409 XMLDTDEntity,
26410 XMLDTDNotation,
26411 XMLDocType,
26412 XMLNamedNodeMap,
26413 XMLNode,
26414 isObject,
26415 extend = function extend(child, parent) {
26416 for (var key in parent) {
26417 if (hasProp.call(parent, key)) child[key] = parent[key];
26418 }function ctor() {
26419 this.constructor = child;
26420 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26421 },
26422 hasProp = {}.hasOwnProperty;
26423
26424 isObject = require('./Utility').isObject;
26425
26426 XMLNode = require('./XMLNode');
26427
26428 NodeType = require('./NodeType');
26429
26430 XMLDTDAttList = require('./XMLDTDAttList');
26431
26432 XMLDTDEntity = require('./XMLDTDEntity');
26433
26434 XMLDTDElement = require('./XMLDTDElement');
26435
26436 XMLDTDNotation = require('./XMLDTDNotation');
26437
26438 XMLNamedNodeMap = require('./XMLNamedNodeMap');
26439
26440 module.exports = XMLDocType = function (superClass) {
26441 extend(XMLDocType, superClass);
26442
26443 function XMLDocType(parent, pubID, sysID) {
26444 var child, i, len, ref, ref1, ref2;
26445 XMLDocType.__super__.constructor.call(this, parent);
26446 this.type = NodeType.DocType;
26447 if (parent.children) {
26448 ref = parent.children;
26449 for (i = 0, len = ref.length; i < len; i++) {
26450 child = ref[i];
26451 if (child.type === NodeType.Element) {
26452 this.name = child.name;
26453 break;
26454 }
26455 }
26456 }
26457 this.documentObject = parent;
26458 if (isObject(pubID)) {
26459 ref1 = pubID, pubID = ref1.pubID, sysID = ref1.sysID;
26460 }
26461 if (sysID == null) {
26462 ref2 = [pubID, sysID], sysID = ref2[0], pubID = ref2[1];
26463 }
26464 if (pubID != null) {
26465 this.pubID = this.stringify.dtdPubID(pubID);
26466 }
26467 if (sysID != null) {
26468 this.sysID = this.stringify.dtdSysID(sysID);
26469 }
26470 }
26471
26472 Object.defineProperty(XMLDocType.prototype, 'entities', {
26473 get: function get() {
26474 var child, i, len, nodes, ref;
26475 nodes = {};
26476 ref = this.children;
26477 for (i = 0, len = ref.length; i < len; i++) {
26478 child = ref[i];
26479 if (child.type === NodeType.EntityDeclaration && !child.pe) {
26480 nodes[child.name] = child;
26481 }
26482 }
26483 return new XMLNamedNodeMap(nodes);
26484 }
26485 });
26486
26487 Object.defineProperty(XMLDocType.prototype, 'notations', {
26488 get: function get() {
26489 var child, i, len, nodes, ref;
26490 nodes = {};
26491 ref = this.children;
26492 for (i = 0, len = ref.length; i < len; i++) {
26493 child = ref[i];
26494 if (child.type === NodeType.NotationDeclaration) {
26495 nodes[child.name] = child;
26496 }
26497 }
26498 return new XMLNamedNodeMap(nodes);
26499 }
26500 });
26501
26502 Object.defineProperty(XMLDocType.prototype, 'publicId', {
26503 get: function get() {
26504 return this.pubID;
26505 }
26506 });
26507
26508 Object.defineProperty(XMLDocType.prototype, 'systemId', {
26509 get: function get() {
26510 return this.sysID;
26511 }
26512 });
26513
26514 Object.defineProperty(XMLDocType.prototype, 'internalSubset', {
26515 get: function get() {
26516 throw new Error("This DOM method is not implemented." + this.debugInfo());
26517 }
26518 });
26519
26520 XMLDocType.prototype.element = function (name, value) {
26521 var child;
26522 child = new XMLDTDElement(this, name, value);
26523 this.children.push(child);
26524 return this;
26525 };
26526
26527 XMLDocType.prototype.attList = function (elementName, attributeName, attributeType, defaultValueType, defaultValue) {
26528 var child;
26529 child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
26530 this.children.push(child);
26531 return this;
26532 };
26533
26534 XMLDocType.prototype.entity = function (name, value) {
26535 var child;
26536 child = new XMLDTDEntity(this, false, name, value);
26537 this.children.push(child);
26538 return this;
26539 };
26540
26541 XMLDocType.prototype.pEntity = function (name, value) {
26542 var child;
26543 child = new XMLDTDEntity(this, true, name, value);
26544 this.children.push(child);
26545 return this;
26546 };
26547
26548 XMLDocType.prototype.notation = function (name, value) {
26549 var child;
26550 child = new XMLDTDNotation(this, name, value);
26551 this.children.push(child);
26552 return this;
26553 };
26554
26555 XMLDocType.prototype.toString = function (options) {
26556 return this.options.writer.docType(this, this.options.writer.filterOptions(options));
26557 };
26558
26559 XMLDocType.prototype.ele = function (name, value) {
26560 return this.element(name, value);
26561 };
26562
26563 XMLDocType.prototype.att = function (elementName, attributeName, attributeType, defaultValueType, defaultValue) {
26564 return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
26565 };
26566
26567 XMLDocType.prototype.ent = function (name, value) {
26568 return this.entity(name, value);
26569 };
26570
26571 XMLDocType.prototype.pent = function (name, value) {
26572 return this.pEntity(name, value);
26573 };
26574
26575 XMLDocType.prototype.not = function (name, value) {
26576 return this.notation(name, value);
26577 };
26578
26579 XMLDocType.prototype.up = function () {
26580 return this.root() || this.documentObject;
26581 };
26582
26583 XMLDocType.prototype.isEqualNode = function (node) {
26584 if (!XMLDocType.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
26585 return false;
26586 }
26587 if (node.name !== this.name) {
26588 return false;
26589 }
26590 if (node.publicId !== this.publicId) {
26591 return false;
26592 }
26593 if (node.systemId !== this.systemId) {
26594 return false;
26595 }
26596 return true;
26597 };
26598
26599 return XMLDocType;
26600 }(XMLNode);
26601}).call(undefined);
26602
26603},{"./NodeType":285,"./Utility":286,"./XMLDTDAttList":296,"./XMLDTDElement":297,"./XMLDTDEntity":298,"./XMLDTDNotation":299,"./XMLNamedNodeMap":306,"./XMLNode":307}],302:[function(require,module,exports){
26604'use strict';
26605
26606// Generated by CoffeeScript 1.12.7
26607(function () {
26608 var NodeType,
26609 XMLDOMConfiguration,
26610 XMLDOMImplementation,
26611 XMLDocument,
26612 XMLNode,
26613 XMLStringWriter,
26614 XMLStringifier,
26615 isPlainObject,
26616 extend = function extend(child, parent) {
26617 for (var key in parent) {
26618 if (hasProp.call(parent, key)) child[key] = parent[key];
26619 }function ctor() {
26620 this.constructor = child;
26621 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
26622 },
26623 hasProp = {}.hasOwnProperty;
26624
26625 isPlainObject = require('./Utility').isPlainObject;
26626
26627 XMLDOMImplementation = require('./XMLDOMImplementation');
26628
26629 XMLDOMConfiguration = require('./XMLDOMConfiguration');
26630
26631 XMLNode = require('./XMLNode');
26632
26633 NodeType = require('./NodeType');
26634
26635 XMLStringifier = require('./XMLStringifier');
26636
26637 XMLStringWriter = require('./XMLStringWriter');
26638
26639 module.exports = XMLDocument = function (superClass) {
26640 extend(XMLDocument, superClass);
26641
26642 function XMLDocument(options) {
26643 XMLDocument.__super__.constructor.call(this, null);
26644 this.name = "#document";
26645 this.type = NodeType.Document;
26646 this.documentURI = null;
26647 this.domConfig = new XMLDOMConfiguration();
26648 options || (options = {});
26649 if (!options.writer) {
26650 options.writer = new XMLStringWriter();
26651 }
26652 this.options = options;
26653 this.stringify = new XMLStringifier(options);
26654 }
26655
26656 Object.defineProperty(XMLDocument.prototype, 'implementation', {
26657 value: new XMLDOMImplementation()
26658 });
26659
26660 Object.defineProperty(XMLDocument.prototype, 'doctype', {
26661 get: function get() {
26662 var child, i, len, ref;
26663 ref = this.children;
26664 for (i = 0, len = ref.length; i < len; i++) {
26665 child = ref[i];
26666 if (child.type === NodeType.DocType) {
26667 return child;
26668 }
26669 }
26670 return null;
26671 }
26672 });
26673
26674 Object.defineProperty(XMLDocument.prototype, 'documentElement', {
26675 get: function get() {
26676 return this.rootObject || null;
26677 }
26678 });
26679
26680 Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
26681 get: function get() {
26682 return null;
26683 }
26684 });
26685
26686 Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
26687 get: function get() {
26688 return false;
26689 }
26690 });
26691
26692 Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
26693 get: function get() {
26694 if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
26695 return this.children[0].encoding;
26696 } else {
26697 return null;
26698 }
26699 }
26700 });
26701
26702 Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
26703 get: function get() {
26704 if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
26705 return this.children[0].standalone === 'yes';
26706 } else {
26707 return false;
26708 }
26709 }
26710 });
26711
26712 Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
26713 get: function get() {
26714 if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
26715 return this.children[0].version;
26716 } else {
26717 return "1.0";
26718 }
26719 }
26720 });
26721
26722 Object.defineProperty(XMLDocument.prototype, 'URL', {
26723 get: function get() {
26724 return this.documentURI;
26725 }
26726 });
26727
26728 Object.defineProperty(XMLDocument.prototype, 'origin', {
26729 get: function get() {
26730 return null;
26731 }
26732 });
26733
26734 Object.defineProperty(XMLDocument.prototype, 'compatMode', {
26735 get: function get() {
26736 return null;
26737 }
26738 });
26739
26740 Object.defineProperty(XMLDocument.prototype, 'characterSet', {
26741 get: function get() {
26742 return null;
26743 }
26744 });
26745
26746 Object.defineProperty(XMLDocument.prototype, 'contentType', {
26747 get: function get() {
26748 return null;
26749 }
26750 });
26751
26752 XMLDocument.prototype.end = function (writer) {
26753 var writerOptions;
26754 writerOptions = {};
26755 if (!writer) {
26756 writer = this.options.writer;
26757 } else if (isPlainObject(writer)) {
26758 writerOptions = writer;
26759 writer = this.options.writer;
26760 }
26761 return writer.document(this, writer.filterOptions(writerOptions));
26762 };
26763
26764 XMLDocument.prototype.toString = function (options) {
26765 return this.options.writer.document(this, this.options.writer.filterOptions(options));
26766 };
26767
26768 XMLDocument.prototype.createElement = function (tagName) {
26769 throw new Error("This DOM method is not implemented." + this.debugInfo());
26770 };
26771
26772 XMLDocument.prototype.createDocumentFragment = function () {
26773 throw new Error("This DOM method is not implemented." + this.debugInfo());
26774 };
26775
26776 XMLDocument.prototype.createTextNode = function (data) {
26777 throw new Error("This DOM method is not implemented." + this.debugInfo());
26778 };
26779
26780 XMLDocument.prototype.createComment = function (data) {
26781 throw new Error("This DOM method is not implemented." + this.debugInfo());
26782 };
26783
26784 XMLDocument.prototype.createCDATASection = function (data) {
26785 throw new Error("This DOM method is not implemented." + this.debugInfo());
26786 };
26787
26788 XMLDocument.prototype.createProcessingInstruction = function (target, data) {
26789 throw new Error("This DOM method is not implemented." + this.debugInfo());
26790 };
26791
26792 XMLDocument.prototype.createAttribute = function (name) {
26793 throw new Error("This DOM method is not implemented." + this.debugInfo());
26794 };
26795
26796 XMLDocument.prototype.createEntityReference = function (name) {
26797 throw new Error("This DOM method is not implemented." + this.debugInfo());
26798 };
26799
26800 XMLDocument.prototype.getElementsByTagName = function (tagname) {
26801 throw new Error("This DOM method is not implemented." + this.debugInfo());
26802 };
26803
26804 XMLDocument.prototype.importNode = function (importedNode, deep) {
26805 throw new Error("This DOM method is not implemented." + this.debugInfo());
26806 };
26807
26808 XMLDocument.prototype.createElementNS = function (namespaceURI, qualifiedName) {
26809 throw new Error("This DOM method is not implemented." + this.debugInfo());
26810 };
26811
26812 XMLDocument.prototype.createAttributeNS = function (namespaceURI, qualifiedName) {
26813 throw new Error("This DOM method is not implemented." + this.debugInfo());
26814 };
26815
26816 XMLDocument.prototype.getElementsByTagNameNS = function (namespaceURI, localName) {
26817 throw new Error("This DOM method is not implemented." + this.debugInfo());
26818 };
26819
26820 XMLDocument.prototype.getElementById = function (elementId) {
26821 throw new Error("This DOM method is not implemented." + this.debugInfo());
26822 };
26823
26824 XMLDocument.prototype.adoptNode = function (source) {
26825 throw new Error("This DOM method is not implemented." + this.debugInfo());
26826 };
26827
26828 XMLDocument.prototype.normalizeDocument = function () {
26829 throw new Error("This DOM method is not implemented." + this.debugInfo());
26830 };
26831
26832 XMLDocument.prototype.renameNode = function (node, namespaceURI, qualifiedName) {
26833 throw new Error("This DOM method is not implemented." + this.debugInfo());
26834 };
26835
26836 XMLDocument.prototype.getElementsByClassName = function (classNames) {
26837 throw new Error("This DOM method is not implemented." + this.debugInfo());
26838 };
26839
26840 XMLDocument.prototype.createEvent = function (eventInterface) {
26841 throw new Error("This DOM method is not implemented." + this.debugInfo());
26842 };
26843
26844 XMLDocument.prototype.createRange = function () {
26845 throw new Error("This DOM method is not implemented." + this.debugInfo());
26846 };
26847
26848 XMLDocument.prototype.createNodeIterator = function (root, whatToShow, filter) {
26849 throw new Error("This DOM method is not implemented." + this.debugInfo());
26850 };
26851
26852 XMLDocument.prototype.createTreeWalker = function (root, whatToShow, filter) {
26853 throw new Error("This DOM method is not implemented." + this.debugInfo());
26854 };
26855
26856 return XMLDocument;
26857 }(XMLNode);
26858}).call(undefined);
26859
26860},{"./NodeType":285,"./Utility":286,"./XMLDOMConfiguration":292,"./XMLDOMImplementation":294,"./XMLNode":307,"./XMLStringWriter":312,"./XMLStringifier":313}],303:[function(require,module,exports){
26861'use strict';
26862
26863// Generated by CoffeeScript 1.12.7
26864(function () {
26865 var NodeType,
26866 WriterState,
26867 XMLAttribute,
26868 XMLCData,
26869 XMLComment,
26870 XMLDTDAttList,
26871 XMLDTDElement,
26872 XMLDTDEntity,
26873 XMLDTDNotation,
26874 XMLDeclaration,
26875 XMLDocType,
26876 XMLDocument,
26877 XMLDocumentCB,
26878 XMLElement,
26879 XMLProcessingInstruction,
26880 XMLRaw,
26881 XMLStringWriter,
26882 XMLStringifier,
26883 XMLText,
26884 getValue,
26885 isFunction,
26886 isObject,
26887 isPlainObject,
26888 ref,
26889 hasProp = {}.hasOwnProperty;
26890
26891 ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue;
26892
26893 NodeType = require('./NodeType');
26894
26895 XMLDocument = require('./XMLDocument');
26896
26897 XMLElement = require('./XMLElement');
26898
26899 XMLCData = require('./XMLCData');
26900
26901 XMLComment = require('./XMLComment');
26902
26903 XMLRaw = require('./XMLRaw');
26904
26905 XMLText = require('./XMLText');
26906
26907 XMLProcessingInstruction = require('./XMLProcessingInstruction');
26908
26909 XMLDeclaration = require('./XMLDeclaration');
26910
26911 XMLDocType = require('./XMLDocType');
26912
26913 XMLDTDAttList = require('./XMLDTDAttList');
26914
26915 XMLDTDEntity = require('./XMLDTDEntity');
26916
26917 XMLDTDElement = require('./XMLDTDElement');
26918
26919 XMLDTDNotation = require('./XMLDTDNotation');
26920
26921 XMLAttribute = require('./XMLAttribute');
26922
26923 XMLStringifier = require('./XMLStringifier');
26924
26925 XMLStringWriter = require('./XMLStringWriter');
26926
26927 WriterState = require('./WriterState');
26928
26929 module.exports = XMLDocumentCB = function () {
26930 function XMLDocumentCB(options, onData, onEnd) {
26931 var writerOptions;
26932 this.name = "?xml";
26933 this.type = NodeType.Document;
26934 options || (options = {});
26935 writerOptions = {};
26936 if (!options.writer) {
26937 options.writer = new XMLStringWriter();
26938 } else if (isPlainObject(options.writer)) {
26939 writerOptions = options.writer;
26940 options.writer = new XMLStringWriter();
26941 }
26942 this.options = options;
26943 this.writer = options.writer;
26944 this.writerOptions = this.writer.filterOptions(writerOptions);
26945 this.stringify = new XMLStringifier(options);
26946 this.onDataCallback = onData || function () {};
26947 this.onEndCallback = onEnd || function () {};
26948 this.currentNode = null;
26949 this.currentLevel = -1;
26950 this.openTags = {};
26951 this.documentStarted = false;
26952 this.documentCompleted = false;
26953 this.root = null;
26954 }
26955
26956 XMLDocumentCB.prototype.createChildNode = function (node) {
26957 var att, attName, attributes, child, i, len, ref1, ref2;
26958 switch (node.type) {
26959 case NodeType.CData:
26960 this.cdata(node.value);
26961 break;
26962 case NodeType.Comment:
26963 this.comment(node.value);
26964 break;
26965 case NodeType.Element:
26966 attributes = {};
26967 ref1 = node.attribs;
26968 for (attName in ref1) {
26969 if (!hasProp.call(ref1, attName)) continue;
26970 att = ref1[attName];
26971 attributes[attName] = att.value;
26972 }
26973 this.node(node.name, attributes);
26974 break;
26975 case NodeType.Dummy:
26976 this.dummy();
26977 break;
26978 case NodeType.Raw:
26979 this.raw(node.value);
26980 break;
26981 case NodeType.Text:
26982 this.text(node.value);
26983 break;
26984 case NodeType.ProcessingInstruction:
26985 this.instruction(node.target, node.value);
26986 break;
26987 default:
26988 throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name);
26989 }
26990 ref2 = node.children;
26991 for (i = 0, len = ref2.length; i < len; i++) {
26992 child = ref2[i];
26993 this.createChildNode(child);
26994 if (child.type === NodeType.Element) {
26995 this.up();
26996 }
26997 }
26998 return this;
26999 };
27000
27001 XMLDocumentCB.prototype.dummy = function () {
27002 return this;
27003 };
27004
27005 XMLDocumentCB.prototype.node = function (name, attributes, text) {
27006 var ref1;
27007 if (name == null) {
27008 throw new Error("Missing node name.");
27009 }
27010 if (this.root && this.currentLevel === -1) {
27011 throw new Error("Document can only have one root node. " + this.debugInfo(name));
27012 }
27013 this.openCurrent();
27014 name = getValue(name);
27015 if (attributes == null) {
27016 attributes = {};
27017 }
27018 attributes = getValue(attributes);
27019 if (!isObject(attributes)) {
27020 ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
27021 }
27022 this.currentNode = new XMLElement(this, name, attributes);
27023 this.currentNode.children = false;
27024 this.currentLevel++;
27025 this.openTags[this.currentLevel] = this.currentNode;
27026 if (text != null) {
27027 this.text(text);
27028 }
27029 return this;
27030 };
27031
27032 XMLDocumentCB.prototype.element = function (name, attributes, text) {
27033 var child, i, len, oldValidationFlag, ref1, root;
27034 if (this.currentNode && this.currentNode.type === NodeType.DocType) {
27035 this.dtdElement.apply(this, arguments);
27036 } else {
27037 if (Array.isArray(name) || isObject(name) || isFunction(name)) {
27038 oldValidationFlag = this.options.noValidation;
27039 this.options.noValidation = true;
27040 root = new XMLDocument(this.options).element('TEMP_ROOT');
27041 root.element(name);
27042 this.options.noValidation = oldValidationFlag;
27043 ref1 = root.children;
27044 for (i = 0, len = ref1.length; i < len; i++) {
27045 child = ref1[i];
27046 this.createChildNode(child);
27047 if (child.type === NodeType.Element) {
27048 this.up();
27049 }
27050 }
27051 } else {
27052 this.node(name, attributes, text);
27053 }
27054 }
27055 return this;
27056 };
27057
27058 XMLDocumentCB.prototype.attribute = function (name, value) {
27059 var attName, attValue;
27060 if (!this.currentNode || this.currentNode.children) {
27061 throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
27062 }
27063 if (name != null) {
27064 name = getValue(name);
27065 }
27066 if (isObject(name)) {
27067 for (attName in name) {
27068 if (!hasProp.call(name, attName)) continue;
27069 attValue = name[attName];
27070 this.attribute(attName, attValue);
27071 }
27072 } else {
27073 if (isFunction(value)) {
27074 value = value.apply();
27075 }
27076 if (this.options.keepNullAttributes && value == null) {
27077 this.currentNode.attribs[name] = new XMLAttribute(this, name, "");
27078 } else if (value != null) {
27079 this.currentNode.attribs[name] = new XMLAttribute(this, name, value);
27080 }
27081 }
27082 return this;
27083 };
27084
27085 XMLDocumentCB.prototype.text = function (value) {
27086 var node;
27087 this.openCurrent();
27088 node = new XMLText(this, value);
27089 this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27090 return this;
27091 };
27092
27093 XMLDocumentCB.prototype.cdata = function (value) {
27094 var node;
27095 this.openCurrent();
27096 node = new XMLCData(this, value);
27097 this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27098 return this;
27099 };
27100
27101 XMLDocumentCB.prototype.comment = function (value) {
27102 var node;
27103 this.openCurrent();
27104 node = new XMLComment(this, value);
27105 this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27106 return this;
27107 };
27108
27109 XMLDocumentCB.prototype.raw = function (value) {
27110 var node;
27111 this.openCurrent();
27112 node = new XMLRaw(this, value);
27113 this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27114 return this;
27115 };
27116
27117 XMLDocumentCB.prototype.instruction = function (target, value) {
27118 var i, insTarget, insValue, len, node;
27119 this.openCurrent();
27120 if (target != null) {
27121 target = getValue(target);
27122 }
27123 if (value != null) {
27124 value = getValue(value);
27125 }
27126 if (Array.isArray(target)) {
27127 for (i = 0, len = target.length; i < len; i++) {
27128 insTarget = target[i];
27129 this.instruction(insTarget);
27130 }
27131 } else if (isObject(target)) {
27132 for (insTarget in target) {
27133 if (!hasProp.call(target, insTarget)) continue;
27134 insValue = target[insTarget];
27135 this.instruction(insTarget, insValue);
27136 }
27137 } else {
27138 if (isFunction(value)) {
27139 value = value.apply();
27140 }
27141 node = new XMLProcessingInstruction(this, target, value);
27142 this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27143 }
27144 return this;
27145 };
27146
27147 XMLDocumentCB.prototype.declaration = function (version, encoding, standalone) {
27148 var node;
27149 this.openCurrent();
27150 if (this.documentStarted) {
27151 throw new Error("declaration() must be the first node.");
27152 }
27153 node = new XMLDeclaration(this, version, encoding, standalone);
27154 this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27155 return this;
27156 };
27157
27158 XMLDocumentCB.prototype.doctype = function (root, pubID, sysID) {
27159 this.openCurrent();
27160 if (root == null) {
27161 throw new Error("Missing root node name.");
27162 }
27163 if (this.root) {
27164 throw new Error("dtd() must come before the root node.");
27165 }
27166 this.currentNode = new XMLDocType(this, pubID, sysID);
27167 this.currentNode.rootNodeName = root;
27168 this.currentNode.children = false;
27169 this.currentLevel++;
27170 this.openTags[this.currentLevel] = this.currentNode;
27171 return this;
27172 };
27173
27174 XMLDocumentCB.prototype.dtdElement = function (name, value) {
27175 var node;
27176 this.openCurrent();
27177 node = new XMLDTDElement(this, name, value);
27178 this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27179 return this;
27180 };
27181
27182 XMLDocumentCB.prototype.attList = function (elementName, attributeName, attributeType, defaultValueType, defaultValue) {
27183 var node;
27184 this.openCurrent();
27185 node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
27186 this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27187 return this;
27188 };
27189
27190 XMLDocumentCB.prototype.entity = function (name, value) {
27191 var node;
27192 this.openCurrent();
27193 node = new XMLDTDEntity(this, false, name, value);
27194 this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27195 return this;
27196 };
27197
27198 XMLDocumentCB.prototype.pEntity = function (name, value) {
27199 var node;
27200 this.openCurrent();
27201 node = new XMLDTDEntity(this, true, name, value);
27202 this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27203 return this;
27204 };
27205
27206 XMLDocumentCB.prototype.notation = function (name, value) {
27207 var node;
27208 this.openCurrent();
27209 node = new XMLDTDNotation(this, name, value);
27210 this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
27211 return this;
27212 };
27213
27214 XMLDocumentCB.prototype.up = function () {
27215 if (this.currentLevel < 0) {
27216 throw new Error("The document node has no parent.");
27217 }
27218 if (this.currentNode) {
27219 if (this.currentNode.children) {
27220 this.closeNode(this.currentNode);
27221 } else {
27222 this.openNode(this.currentNode);
27223 }
27224 this.currentNode = null;
27225 } else {
27226 this.closeNode(this.openTags[this.currentLevel]);
27227 }
27228 delete this.openTags[this.currentLevel];
27229 this.currentLevel--;
27230 return this;
27231 };
27232
27233 XMLDocumentCB.prototype.end = function () {
27234 while (this.currentLevel >= 0) {
27235 this.up();
27236 }
27237 return this.onEnd();
27238 };
27239
27240 XMLDocumentCB.prototype.openCurrent = function () {
27241 if (this.currentNode) {
27242 this.currentNode.children = true;
27243 return this.openNode(this.currentNode);
27244 }
27245 };
27246
27247 XMLDocumentCB.prototype.openNode = function (node) {
27248 var att, chunk, name, ref1;
27249 if (!node.isOpen) {
27250 if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) {
27251 this.root = node;
27252 }
27253 chunk = '';
27254 if (node.type === NodeType.Element) {
27255 this.writerOptions.state = WriterState.OpenTag;
27256 chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name;
27257 ref1 = node.attribs;
27258 for (name in ref1) {
27259 if (!hasProp.call(ref1, name)) continue;
27260 att = ref1[name];
27261 chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel);
27262 }
27263 chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel);
27264 this.writerOptions.state = WriterState.InsideTag;
27265 } else {
27266 this.writerOptions.state = WriterState.OpenTag;
27267 chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<!DOCTYPE ' + node.rootNodeName;
27268 if (node.pubID && node.sysID) {
27269 chunk += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
27270 } else if (node.sysID) {
27271 chunk += ' SYSTEM "' + node.sysID + '"';
27272 }
27273 if (node.children) {
27274 chunk += ' [';
27275 this.writerOptions.state = WriterState.InsideTag;
27276 } else {
27277 this.writerOptions.state = WriterState.CloseTag;
27278 chunk += '>';
27279 }
27280 chunk += this.writer.endline(node, this.writerOptions, this.currentLevel);
27281 }
27282 this.onData(chunk, this.currentLevel);
27283 return node.isOpen = true;
27284 }
27285 };
27286
27287 XMLDocumentCB.prototype.closeNode = function (node) {
27288 var chunk;
27289 if (!node.isClosed) {
27290 chunk = '';
27291 this.writerOptions.state = WriterState.CloseTag;
27292 if (node.type === NodeType.Element) {
27293 chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '</' + node.name + '>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
27294 } else {
27295 chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
27296 }
27297 this.writerOptions.state = WriterState.None;
27298 this.onData(chunk, this.currentLevel);
27299 return node.isClosed = true;
27300 }
27301 };
27302
27303 XMLDocumentCB.prototype.onData = function (chunk, level) {
27304 this.documentStarted = true;
27305 return this.onDataCallback(chunk, level + 1);
27306 };
27307
27308 XMLDocumentCB.prototype.onEnd = function () {
27309 this.documentCompleted = true;
27310 return this.onEndCallback();
27311 };
27312
27313 XMLDocumentCB.prototype.debugInfo = function (name) {
27314 if (name == null) {
27315 return "";
27316 } else {
27317 return "node: <" + name + ">";
27318 }
27319 };
27320
27321 XMLDocumentCB.prototype.ele = function () {
27322 return this.element.apply(this, arguments);
27323 };
27324
27325 XMLDocumentCB.prototype.nod = function (name, attributes, text) {
27326 return this.node(name, attributes, text);
27327 };
27328
27329 XMLDocumentCB.prototype.txt = function (value) {
27330 return this.text(value);
27331 };
27332
27333 XMLDocumentCB.prototype.dat = function (value) {
27334 return this.cdata(value);
27335 };
27336
27337 XMLDocumentCB.prototype.com = function (value) {
27338 return this.comment(value);
27339 };
27340
27341 XMLDocumentCB.prototype.ins = function (target, value) {
27342 return this.instruction(target, value);
27343 };
27344
27345 XMLDocumentCB.prototype.dec = function (version, encoding, standalone) {
27346 return this.declaration(version, encoding, standalone);
27347 };
27348
27349 XMLDocumentCB.prototype.dtd = function (root, pubID, sysID) {
27350 return this.doctype(root, pubID, sysID);
27351 };
27352
27353 XMLDocumentCB.prototype.e = function (name, attributes, text) {
27354 return this.element(name, attributes, text);
27355 };
27356
27357 XMLDocumentCB.prototype.n = function (name, attributes, text) {
27358 return this.node(name, attributes, text);
27359 };
27360
27361 XMLDocumentCB.prototype.t = function (value) {
27362 return this.text(value);
27363 };
27364
27365 XMLDocumentCB.prototype.d = function (value) {
27366 return this.cdata(value);
27367 };
27368
27369 XMLDocumentCB.prototype.c = function (value) {
27370 return this.comment(value);
27371 };
27372
27373 XMLDocumentCB.prototype.r = function (value) {
27374 return this.raw(value);
27375 };
27376
27377 XMLDocumentCB.prototype.i = function (target, value) {
27378 return this.instruction(target, value);
27379 };
27380
27381 XMLDocumentCB.prototype.att = function () {
27382 if (this.currentNode && this.currentNode.type === NodeType.DocType) {
27383 return this.attList.apply(this, arguments);
27384 } else {
27385 return this.attribute.apply(this, arguments);
27386 }
27387 };
27388
27389 XMLDocumentCB.prototype.a = function () {
27390 if (this.currentNode && this.currentNode.type === NodeType.DocType) {
27391 return this.attList.apply(this, arguments);
27392 } else {
27393 return this.attribute.apply(this, arguments);
27394 }
27395 };
27396
27397 XMLDocumentCB.prototype.ent = function (name, value) {
27398 return this.entity(name, value);
27399 };
27400
27401 XMLDocumentCB.prototype.pent = function (name, value) {
27402 return this.pEntity(name, value);
27403 };
27404
27405 XMLDocumentCB.prototype.not = function (name, value) {
27406 return this.notation(name, value);
27407 };
27408
27409 return XMLDocumentCB;
27410 }();
27411}).call(undefined);
27412
27413},{"./NodeType":285,"./Utility":286,"./WriterState":287,"./XMLAttribute":288,"./XMLCData":289,"./XMLComment":291,"./XMLDTDAttList":296,"./XMLDTDElement":297,"./XMLDTDEntity":298,"./XMLDTDNotation":299,"./XMLDeclaration":300,"./XMLDocType":301,"./XMLDocument":302,"./XMLElement":305,"./XMLProcessingInstruction":309,"./XMLRaw":310,"./XMLStringWriter":312,"./XMLStringifier":313,"./XMLText":314}],304:[function(require,module,exports){
27414'use strict';
27415
27416var _create = require('babel-runtime/core-js/object/create');
27417
27418var _create2 = _interopRequireDefault(_create);
27419
27420function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27421
27422// Generated by CoffeeScript 1.12.7
27423(function () {
27424 var NodeType,
27425 XMLDummy,
27426 XMLNode,
27427 extend = function extend(child, parent) {
27428 for (var key in parent) {
27429 if (hasProp.call(parent, key)) child[key] = parent[key];
27430 }function ctor() {
27431 this.constructor = child;
27432 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
27433 },
27434 hasProp = {}.hasOwnProperty;
27435
27436 XMLNode = require('./XMLNode');
27437
27438 NodeType = require('./NodeType');
27439
27440 module.exports = XMLDummy = function (superClass) {
27441 extend(XMLDummy, superClass);
27442
27443 function XMLDummy(parent) {
27444 XMLDummy.__super__.constructor.call(this, parent);
27445 this.type = NodeType.Dummy;
27446 }
27447
27448 XMLDummy.prototype.clone = function () {
27449 return (0, _create2.default)(this);
27450 };
27451
27452 XMLDummy.prototype.toString = function (options) {
27453 return '';
27454 };
27455
27456 return XMLDummy;
27457 }(XMLNode);
27458}).call(undefined);
27459
27460},{"./NodeType":285,"./XMLNode":307,"babel-runtime/core-js/object/create":40}],305:[function(require,module,exports){
27461'use strict';
27462
27463var _create = require('babel-runtime/core-js/object/create');
27464
27465var _create2 = _interopRequireDefault(_create);
27466
27467function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27468
27469// Generated by CoffeeScript 1.12.7
27470(function () {
27471 var NodeType,
27472 XMLAttribute,
27473 XMLElement,
27474 XMLNamedNodeMap,
27475 XMLNode,
27476 getValue,
27477 isFunction,
27478 isObject,
27479 ref,
27480 extend = function extend(child, parent) {
27481 for (var key in parent) {
27482 if (hasProp.call(parent, key)) child[key] = parent[key];
27483 }function ctor() {
27484 this.constructor = child;
27485 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
27486 },
27487 hasProp = {}.hasOwnProperty;
27488
27489 ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue;
27490
27491 XMLNode = require('./XMLNode');
27492
27493 NodeType = require('./NodeType');
27494
27495 XMLAttribute = require('./XMLAttribute');
27496
27497 XMLNamedNodeMap = require('./XMLNamedNodeMap');
27498
27499 module.exports = XMLElement = function (superClass) {
27500 extend(XMLElement, superClass);
27501
27502 function XMLElement(parent, name, attributes) {
27503 var child, j, len, ref1;
27504 XMLElement.__super__.constructor.call(this, parent);
27505 if (name == null) {
27506 throw new Error("Missing element name. " + this.debugInfo());
27507 }
27508 this.name = this.stringify.name(name);
27509 this.type = NodeType.Element;
27510 this.attribs = {};
27511 this.schemaTypeInfo = null;
27512 if (attributes != null) {
27513 this.attribute(attributes);
27514 }
27515 if (parent.type === NodeType.Document) {
27516 this.isRoot = true;
27517 this.documentObject = parent;
27518 parent.rootObject = this;
27519 if (parent.children) {
27520 ref1 = parent.children;
27521 for (j = 0, len = ref1.length; j < len; j++) {
27522 child = ref1[j];
27523 if (child.type === NodeType.DocType) {
27524 child.name = this.name;
27525 break;
27526 }
27527 }
27528 }
27529 }
27530 }
27531
27532 Object.defineProperty(XMLElement.prototype, 'tagName', {
27533 get: function get() {
27534 return this.name;
27535 }
27536 });
27537
27538 Object.defineProperty(XMLElement.prototype, 'namespaceURI', {
27539 get: function get() {
27540 return '';
27541 }
27542 });
27543
27544 Object.defineProperty(XMLElement.prototype, 'prefix', {
27545 get: function get() {
27546 return '';
27547 }
27548 });
27549
27550 Object.defineProperty(XMLElement.prototype, 'localName', {
27551 get: function get() {
27552 return this.name;
27553 }
27554 });
27555
27556 Object.defineProperty(XMLElement.prototype, 'id', {
27557 get: function get() {
27558 throw new Error("This DOM method is not implemented." + this.debugInfo());
27559 }
27560 });
27561
27562 Object.defineProperty(XMLElement.prototype, 'className', {
27563 get: function get() {
27564 throw new Error("This DOM method is not implemented." + this.debugInfo());
27565 }
27566 });
27567
27568 Object.defineProperty(XMLElement.prototype, 'classList', {
27569 get: function get() {
27570 throw new Error("This DOM method is not implemented." + this.debugInfo());
27571 }
27572 });
27573
27574 Object.defineProperty(XMLElement.prototype, 'attributes', {
27575 get: function get() {
27576 if (!this.attributeMap || !this.attributeMap.nodes) {
27577 this.attributeMap = new XMLNamedNodeMap(this.attribs);
27578 }
27579 return this.attributeMap;
27580 }
27581 });
27582
27583 XMLElement.prototype.clone = function () {
27584 var att, attName, clonedSelf, ref1;
27585 clonedSelf = (0, _create2.default)(this);
27586 if (clonedSelf.isRoot) {
27587 clonedSelf.documentObject = null;
27588 }
27589 clonedSelf.attribs = {};
27590 ref1 = this.attribs;
27591 for (attName in ref1) {
27592 if (!hasProp.call(ref1, attName)) continue;
27593 att = ref1[attName];
27594 clonedSelf.attribs[attName] = att.clone();
27595 }
27596 clonedSelf.children = [];
27597 this.children.forEach(function (child) {
27598 var clonedChild;
27599 clonedChild = child.clone();
27600 clonedChild.parent = clonedSelf;
27601 return clonedSelf.children.push(clonedChild);
27602 });
27603 return clonedSelf;
27604 };
27605
27606 XMLElement.prototype.attribute = function (name, value) {
27607 var attName, attValue;
27608 if (name != null) {
27609 name = getValue(name);
27610 }
27611 if (isObject(name)) {
27612 for (attName in name) {
27613 if (!hasProp.call(name, attName)) continue;
27614 attValue = name[attName];
27615 this.attribute(attName, attValue);
27616 }
27617 } else {
27618 if (isFunction(value)) {
27619 value = value.apply();
27620 }
27621 if (this.options.keepNullAttributes && value == null) {
27622 this.attribs[name] = new XMLAttribute(this, name, "");
27623 } else if (value != null) {
27624 this.attribs[name] = new XMLAttribute(this, name, value);
27625 }
27626 }
27627 return this;
27628 };
27629
27630 XMLElement.prototype.removeAttribute = function (name) {
27631 var attName, j, len;
27632 if (name == null) {
27633 throw new Error("Missing attribute name. " + this.debugInfo());
27634 }
27635 name = getValue(name);
27636 if (Array.isArray(name)) {
27637 for (j = 0, len = name.length; j < len; j++) {
27638 attName = name[j];
27639 delete this.attribs[attName];
27640 }
27641 } else {
27642 delete this.attribs[name];
27643 }
27644 return this;
27645 };
27646
27647 XMLElement.prototype.toString = function (options) {
27648 return this.options.writer.element(this, this.options.writer.filterOptions(options));
27649 };
27650
27651 XMLElement.prototype.att = function (name, value) {
27652 return this.attribute(name, value);
27653 };
27654
27655 XMLElement.prototype.a = function (name, value) {
27656 return this.attribute(name, value);
27657 };
27658
27659 XMLElement.prototype.getAttribute = function (name) {
27660 if (this.attribs.hasOwnProperty(name)) {
27661 return this.attribs[name].value;
27662 } else {
27663 return null;
27664 }
27665 };
27666
27667 XMLElement.prototype.setAttribute = function (name, value) {
27668 throw new Error("This DOM method is not implemented." + this.debugInfo());
27669 };
27670
27671 XMLElement.prototype.getAttributeNode = function (name) {
27672 if (this.attribs.hasOwnProperty(name)) {
27673 return this.attribs[name];
27674 } else {
27675 return null;
27676 }
27677 };
27678
27679 XMLElement.prototype.setAttributeNode = function (newAttr) {
27680 throw new Error("This DOM method is not implemented." + this.debugInfo());
27681 };
27682
27683 XMLElement.prototype.removeAttributeNode = function (oldAttr) {
27684 throw new Error("This DOM method is not implemented." + this.debugInfo());
27685 };
27686
27687 XMLElement.prototype.getElementsByTagName = function (name) {
27688 throw new Error("This DOM method is not implemented." + this.debugInfo());
27689 };
27690
27691 XMLElement.prototype.getAttributeNS = function (namespaceURI, localName) {
27692 throw new Error("This DOM method is not implemented." + this.debugInfo());
27693 };
27694
27695 XMLElement.prototype.setAttributeNS = function (namespaceURI, qualifiedName, value) {
27696 throw new Error("This DOM method is not implemented." + this.debugInfo());
27697 };
27698
27699 XMLElement.prototype.removeAttributeNS = function (namespaceURI, localName) {
27700 throw new Error("This DOM method is not implemented." + this.debugInfo());
27701 };
27702
27703 XMLElement.prototype.getAttributeNodeNS = function (namespaceURI, localName) {
27704 throw new Error("This DOM method is not implemented." + this.debugInfo());
27705 };
27706
27707 XMLElement.prototype.setAttributeNodeNS = function (newAttr) {
27708 throw new Error("This DOM method is not implemented." + this.debugInfo());
27709 };
27710
27711 XMLElement.prototype.getElementsByTagNameNS = function (namespaceURI, localName) {
27712 throw new Error("This DOM method is not implemented." + this.debugInfo());
27713 };
27714
27715 XMLElement.prototype.hasAttribute = function (name) {
27716 return this.attribs.hasOwnProperty(name);
27717 };
27718
27719 XMLElement.prototype.hasAttributeNS = function (namespaceURI, localName) {
27720 throw new Error("This DOM method is not implemented." + this.debugInfo());
27721 };
27722
27723 XMLElement.prototype.setIdAttribute = function (name, isId) {
27724 if (this.attribs.hasOwnProperty(name)) {
27725 return this.attribs[name].isId;
27726 } else {
27727 return isId;
27728 }
27729 };
27730
27731 XMLElement.prototype.setIdAttributeNS = function (namespaceURI, localName, isId) {
27732 throw new Error("This DOM method is not implemented." + this.debugInfo());
27733 };
27734
27735 XMLElement.prototype.setIdAttributeNode = function (idAttr, isId) {
27736 throw new Error("This DOM method is not implemented." + this.debugInfo());
27737 };
27738
27739 XMLElement.prototype.getElementsByTagName = function (tagname) {
27740 throw new Error("This DOM method is not implemented." + this.debugInfo());
27741 };
27742
27743 XMLElement.prototype.getElementsByTagNameNS = function (namespaceURI, localName) {
27744 throw new Error("This DOM method is not implemented." + this.debugInfo());
27745 };
27746
27747 XMLElement.prototype.getElementsByClassName = function (classNames) {
27748 throw new Error("This DOM method is not implemented." + this.debugInfo());
27749 };
27750
27751 XMLElement.prototype.isEqualNode = function (node) {
27752 var i, j, ref1;
27753 if (!XMLElement.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
27754 return false;
27755 }
27756 if (node.namespaceURI !== this.namespaceURI) {
27757 return false;
27758 }
27759 if (node.prefix !== this.prefix) {
27760 return false;
27761 }
27762 if (node.localName !== this.localName) {
27763 return false;
27764 }
27765 if (node.attribs.length !== this.attribs.length) {
27766 return false;
27767 }
27768 for (i = j = 0, ref1 = this.attribs.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; i = 0 <= ref1 ? ++j : --j) {
27769 if (!this.attribs[i].isEqualNode(node.attribs[i])) {
27770 return false;
27771 }
27772 }
27773 return true;
27774 };
27775
27776 return XMLElement;
27777 }(XMLNode);
27778}).call(undefined);
27779
27780},{"./NodeType":285,"./Utility":286,"./XMLAttribute":288,"./XMLNamedNodeMap":306,"./XMLNode":307,"babel-runtime/core-js/object/create":40}],306:[function(require,module,exports){
27781"use strict";
27782
27783var _keys = require("babel-runtime/core-js/object/keys");
27784
27785var _keys2 = _interopRequireDefault(_keys);
27786
27787function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27788
27789// Generated by CoffeeScript 1.12.7
27790(function () {
27791 var XMLNamedNodeMap;
27792
27793 module.exports = XMLNamedNodeMap = function () {
27794 function XMLNamedNodeMap(nodes) {
27795 this.nodes = nodes;
27796 }
27797
27798 Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
27799 get: function get() {
27800 return (0, _keys2.default)(this.nodes).length || 0;
27801 }
27802 });
27803
27804 XMLNamedNodeMap.prototype.clone = function () {
27805 return this.nodes = null;
27806 };
27807
27808 XMLNamedNodeMap.prototype.getNamedItem = function (name) {
27809 return this.nodes[name];
27810 };
27811
27812 XMLNamedNodeMap.prototype.setNamedItem = function (node) {
27813 var oldNode;
27814 oldNode = this.nodes[node.nodeName];
27815 this.nodes[node.nodeName] = node;
27816 return oldNode || null;
27817 };
27818
27819 XMLNamedNodeMap.prototype.removeNamedItem = function (name) {
27820 var oldNode;
27821 oldNode = this.nodes[name];
27822 delete this.nodes[name];
27823 return oldNode || null;
27824 };
27825
27826 XMLNamedNodeMap.prototype.item = function (index) {
27827 return this.nodes[(0, _keys2.default)(this.nodes)[index]] || null;
27828 };
27829
27830 XMLNamedNodeMap.prototype.getNamedItemNS = function (namespaceURI, localName) {
27831 throw new Error("This DOM method is not implemented.");
27832 };
27833
27834 XMLNamedNodeMap.prototype.setNamedItemNS = function (node) {
27835 throw new Error("This DOM method is not implemented.");
27836 };
27837
27838 XMLNamedNodeMap.prototype.removeNamedItemNS = function (namespaceURI, localName) {
27839 throw new Error("This DOM method is not implemented.");
27840 };
27841
27842 return XMLNamedNodeMap;
27843 }();
27844}).call(undefined);
27845
27846},{"babel-runtime/core-js/object/keys":45}],307:[function(require,module,exports){
27847'use strict';
27848
27849// Generated by CoffeeScript 1.12.7
27850(function () {
27851 var DocumentPosition,
27852 NodeType,
27853 XMLCData,
27854 XMLComment,
27855 XMLDeclaration,
27856 XMLDocType,
27857 XMLDummy,
27858 XMLElement,
27859 XMLNamedNodeMap,
27860 XMLNode,
27861 XMLNodeList,
27862 XMLProcessingInstruction,
27863 XMLRaw,
27864 XMLText,
27865 getValue,
27866 isEmpty,
27867 isFunction,
27868 isObject,
27869 ref1,
27870 hasProp = {}.hasOwnProperty;
27871
27872 ref1 = require('./Utility'), isObject = ref1.isObject, isFunction = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue;
27873
27874 XMLElement = null;
27875
27876 XMLCData = null;
27877
27878 XMLComment = null;
27879
27880 XMLDeclaration = null;
27881
27882 XMLDocType = null;
27883
27884 XMLRaw = null;
27885
27886 XMLText = null;
27887
27888 XMLProcessingInstruction = null;
27889
27890 XMLDummy = null;
27891
27892 NodeType = null;
27893
27894 XMLNodeList = null;
27895
27896 XMLNamedNodeMap = null;
27897
27898 DocumentPosition = null;
27899
27900 module.exports = XMLNode = function () {
27901 function XMLNode(parent1) {
27902 this.parent = parent1;
27903 if (this.parent) {
27904 this.options = this.parent.options;
27905 this.stringify = this.parent.stringify;
27906 }
27907 this.value = null;
27908 this.children = [];
27909 this.baseURI = null;
27910 if (!XMLElement) {
27911 XMLElement = require('./XMLElement');
27912 XMLCData = require('./XMLCData');
27913 XMLComment = require('./XMLComment');
27914 XMLDeclaration = require('./XMLDeclaration');
27915 XMLDocType = require('./XMLDocType');
27916 XMLRaw = require('./XMLRaw');
27917 XMLText = require('./XMLText');
27918 XMLProcessingInstruction = require('./XMLProcessingInstruction');
27919 XMLDummy = require('./XMLDummy');
27920 NodeType = require('./NodeType');
27921 XMLNodeList = require('./XMLNodeList');
27922 XMLNamedNodeMap = require('./XMLNamedNodeMap');
27923 DocumentPosition = require('./DocumentPosition');
27924 }
27925 }
27926
27927 Object.defineProperty(XMLNode.prototype, 'nodeName', {
27928 get: function get() {
27929 return this.name;
27930 }
27931 });
27932
27933 Object.defineProperty(XMLNode.prototype, 'nodeType', {
27934 get: function get() {
27935 return this.type;
27936 }
27937 });
27938
27939 Object.defineProperty(XMLNode.prototype, 'nodeValue', {
27940 get: function get() {
27941 return this.value;
27942 }
27943 });
27944
27945 Object.defineProperty(XMLNode.prototype, 'parentNode', {
27946 get: function get() {
27947 return this.parent;
27948 }
27949 });
27950
27951 Object.defineProperty(XMLNode.prototype, 'childNodes', {
27952 get: function get() {
27953 if (!this.childNodeList || !this.childNodeList.nodes) {
27954 this.childNodeList = new XMLNodeList(this.children);
27955 }
27956 return this.childNodeList;
27957 }
27958 });
27959
27960 Object.defineProperty(XMLNode.prototype, 'firstChild', {
27961 get: function get() {
27962 return this.children[0] || null;
27963 }
27964 });
27965
27966 Object.defineProperty(XMLNode.prototype, 'lastChild', {
27967 get: function get() {
27968 return this.children[this.children.length - 1] || null;
27969 }
27970 });
27971
27972 Object.defineProperty(XMLNode.prototype, 'previousSibling', {
27973 get: function get() {
27974 var i;
27975 i = this.parent.children.indexOf(this);
27976 return this.parent.children[i - 1] || null;
27977 }
27978 });
27979
27980 Object.defineProperty(XMLNode.prototype, 'nextSibling', {
27981 get: function get() {
27982 var i;
27983 i = this.parent.children.indexOf(this);
27984 return this.parent.children[i + 1] || null;
27985 }
27986 });
27987
27988 Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
27989 get: function get() {
27990 return this.document() || null;
27991 }
27992 });
27993
27994 Object.defineProperty(XMLNode.prototype, 'textContent', {
27995 get: function get() {
27996 var child, j, len, ref2, str;
27997 if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) {
27998 str = '';
27999 ref2 = this.children;
28000 for (j = 0, len = ref2.length; j < len; j++) {
28001 child = ref2[j];
28002 if (child.textContent) {
28003 str += child.textContent;
28004 }
28005 }
28006 return str;
28007 } else {
28008 return null;
28009 }
28010 },
28011 set: function set(value) {
28012 throw new Error("This DOM method is not implemented." + this.debugInfo());
28013 }
28014 });
28015
28016 XMLNode.prototype.setParent = function (parent) {
28017 var child, j, len, ref2, results;
28018 this.parent = parent;
28019 if (parent) {
28020 this.options = parent.options;
28021 this.stringify = parent.stringify;
28022 }
28023 ref2 = this.children;
28024 results = [];
28025 for (j = 0, len = ref2.length; j < len; j++) {
28026 child = ref2[j];
28027 results.push(child.setParent(this));
28028 }
28029 return results;
28030 };
28031
28032 XMLNode.prototype.element = function (name, attributes, text) {
28033 var childNode, item, j, k, key, lastChild, len, len1, ref2, ref3, val;
28034 lastChild = null;
28035 if (attributes === null && text == null) {
28036 ref2 = [{}, null], attributes = ref2[0], text = ref2[1];
28037 }
28038 if (attributes == null) {
28039 attributes = {};
28040 }
28041 attributes = getValue(attributes);
28042 if (!isObject(attributes)) {
28043 ref3 = [attributes, text], text = ref3[0], attributes = ref3[1];
28044 }
28045 if (name != null) {
28046 name = getValue(name);
28047 }
28048 if (Array.isArray(name)) {
28049 for (j = 0, len = name.length; j < len; j++) {
28050 item = name[j];
28051 lastChild = this.element(item);
28052 }
28053 } else if (isFunction(name)) {
28054 lastChild = this.element(name.apply());
28055 } else if (isObject(name)) {
28056 for (key in name) {
28057 if (!hasProp.call(name, key)) continue;
28058 val = name[key];
28059 if (isFunction(val)) {
28060 val = val.apply();
28061 }
28062 if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
28063 lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
28064 } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
28065 lastChild = this.dummy();
28066 } else if (isObject(val) && isEmpty(val)) {
28067 lastChild = this.element(key);
28068 } else if (!this.options.keepNullNodes && val == null) {
28069 lastChild = this.dummy();
28070 } else if (!this.options.separateArrayItems && Array.isArray(val)) {
28071 for (k = 0, len1 = val.length; k < len1; k++) {
28072 item = val[k];
28073 childNode = {};
28074 childNode[key] = item;
28075 lastChild = this.element(childNode);
28076 }
28077 } else if (isObject(val)) {
28078 if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
28079 lastChild = this.element(val);
28080 } else {
28081 lastChild = this.element(key);
28082 lastChild.element(val);
28083 }
28084 } else {
28085 lastChild = this.element(key, val);
28086 }
28087 }
28088 } else if (!this.options.keepNullNodes && text === null) {
28089 lastChild = this.dummy();
28090 } else {
28091 if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
28092 lastChild = this.text(text);
28093 } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
28094 lastChild = this.cdata(text);
28095 } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
28096 lastChild = this.comment(text);
28097 } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
28098 lastChild = this.raw(text);
28099 } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
28100 lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
28101 } else {
28102 lastChild = this.node(name, attributes, text);
28103 }
28104 }
28105 if (lastChild == null) {
28106 throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
28107 }
28108 return lastChild;
28109 };
28110
28111 XMLNode.prototype.insertBefore = function (name, attributes, text) {
28112 var child, i, newChild, refChild, removed;
28113 if (name != null ? name.type : void 0) {
28114 newChild = name;
28115 refChild = attributes;
28116 newChild.setParent(this);
28117 if (refChild) {
28118 i = children.indexOf(refChild);
28119 removed = children.splice(i);
28120 children.push(newChild);
28121 Array.prototype.push.apply(children, removed);
28122 } else {
28123 children.push(newChild);
28124 }
28125 return newChild;
28126 } else {
28127 if (this.isRoot) {
28128 throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
28129 }
28130 i = this.parent.children.indexOf(this);
28131 removed = this.parent.children.splice(i);
28132 child = this.parent.element(name, attributes, text);
28133 Array.prototype.push.apply(this.parent.children, removed);
28134 return child;
28135 }
28136 };
28137
28138 XMLNode.prototype.insertAfter = function (name, attributes, text) {
28139 var child, i, removed;
28140 if (this.isRoot) {
28141 throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
28142 }
28143 i = this.parent.children.indexOf(this);
28144 removed = this.parent.children.splice(i + 1);
28145 child = this.parent.element(name, attributes, text);
28146 Array.prototype.push.apply(this.parent.children, removed);
28147 return child;
28148 };
28149
28150 XMLNode.prototype.remove = function () {
28151 var i, ref2;
28152 if (this.isRoot) {
28153 throw new Error("Cannot remove the root element. " + this.debugInfo());
28154 }
28155 i = this.parent.children.indexOf(this);
28156 [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref2 = [])), ref2;
28157 return this.parent;
28158 };
28159
28160 XMLNode.prototype.node = function (name, attributes, text) {
28161 var child, ref2;
28162 if (name != null) {
28163 name = getValue(name);
28164 }
28165 attributes || (attributes = {});
28166 attributes = getValue(attributes);
28167 if (!isObject(attributes)) {
28168 ref2 = [attributes, text], text = ref2[0], attributes = ref2[1];
28169 }
28170 child = new XMLElement(this, name, attributes);
28171 if (text != null) {
28172 child.text(text);
28173 }
28174 this.children.push(child);
28175 return child;
28176 };
28177
28178 XMLNode.prototype.text = function (value) {
28179 var child;
28180 if (isObject(value)) {
28181 this.element(value);
28182 }
28183 child = new XMLText(this, value);
28184 this.children.push(child);
28185 return this;
28186 };
28187
28188 XMLNode.prototype.cdata = function (value) {
28189 var child;
28190 child = new XMLCData(this, value);
28191 this.children.push(child);
28192 return this;
28193 };
28194
28195 XMLNode.prototype.comment = function (value) {
28196 var child;
28197 child = new XMLComment(this, value);
28198 this.children.push(child);
28199 return this;
28200 };
28201
28202 XMLNode.prototype.commentBefore = function (value) {
28203 var child, i, removed;
28204 i = this.parent.children.indexOf(this);
28205 removed = this.parent.children.splice(i);
28206 child = this.parent.comment(value);
28207 Array.prototype.push.apply(this.parent.children, removed);
28208 return this;
28209 };
28210
28211 XMLNode.prototype.commentAfter = function (value) {
28212 var child, i, removed;
28213 i = this.parent.children.indexOf(this);
28214 removed = this.parent.children.splice(i + 1);
28215 child = this.parent.comment(value);
28216 Array.prototype.push.apply(this.parent.children, removed);
28217 return this;
28218 };
28219
28220 XMLNode.prototype.raw = function (value) {
28221 var child;
28222 child = new XMLRaw(this, value);
28223 this.children.push(child);
28224 return this;
28225 };
28226
28227 XMLNode.prototype.dummy = function () {
28228 var child;
28229 child = new XMLDummy(this);
28230 return child;
28231 };
28232
28233 XMLNode.prototype.instruction = function (target, value) {
28234 var insTarget, insValue, instruction, j, len;
28235 if (target != null) {
28236 target = getValue(target);
28237 }
28238 if (value != null) {
28239 value = getValue(value);
28240 }
28241 if (Array.isArray(target)) {
28242 for (j = 0, len = target.length; j < len; j++) {
28243 insTarget = target[j];
28244 this.instruction(insTarget);
28245 }
28246 } else if (isObject(target)) {
28247 for (insTarget in target) {
28248 if (!hasProp.call(target, insTarget)) continue;
28249 insValue = target[insTarget];
28250 this.instruction(insTarget, insValue);
28251 }
28252 } else {
28253 if (isFunction(value)) {
28254 value = value.apply();
28255 }
28256 instruction = new XMLProcessingInstruction(this, target, value);
28257 this.children.push(instruction);
28258 }
28259 return this;
28260 };
28261
28262 XMLNode.prototype.instructionBefore = function (target, value) {
28263 var child, i, removed;
28264 i = this.parent.children.indexOf(this);
28265 removed = this.parent.children.splice(i);
28266 child = this.parent.instruction(target, value);
28267 Array.prototype.push.apply(this.parent.children, removed);
28268 return this;
28269 };
28270
28271 XMLNode.prototype.instructionAfter = function (target, value) {
28272 var child, i, removed;
28273 i = this.parent.children.indexOf(this);
28274 removed = this.parent.children.splice(i + 1);
28275 child = this.parent.instruction(target, value);
28276 Array.prototype.push.apply(this.parent.children, removed);
28277 return this;
28278 };
28279
28280 XMLNode.prototype.declaration = function (version, encoding, standalone) {
28281 var doc, xmldec;
28282 doc = this.document();
28283 xmldec = new XMLDeclaration(doc, version, encoding, standalone);
28284 if (doc.children.length === 0) {
28285 doc.children.unshift(xmldec);
28286 } else if (doc.children[0].type === NodeType.Declaration) {
28287 doc.children[0] = xmldec;
28288 } else {
28289 doc.children.unshift(xmldec);
28290 }
28291 return doc.root() || doc;
28292 };
28293
28294 XMLNode.prototype.dtd = function (pubID, sysID) {
28295 var child, doc, doctype, i, j, k, len, len1, ref2, ref3;
28296 doc = this.document();
28297 doctype = new XMLDocType(doc, pubID, sysID);
28298 ref2 = doc.children;
28299 for (i = j = 0, len = ref2.length; j < len; i = ++j) {
28300 child = ref2[i];
28301 if (child.type === NodeType.DocType) {
28302 doc.children[i] = doctype;
28303 return doctype;
28304 }
28305 }
28306 ref3 = doc.children;
28307 for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) {
28308 child = ref3[i];
28309 if (child.isRoot) {
28310 doc.children.splice(i, 0, doctype);
28311 return doctype;
28312 }
28313 }
28314 doc.children.push(doctype);
28315 return doctype;
28316 };
28317
28318 XMLNode.prototype.up = function () {
28319 if (this.isRoot) {
28320 throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
28321 }
28322 return this.parent;
28323 };
28324
28325 XMLNode.prototype.root = function () {
28326 var node;
28327 node = this;
28328 while (node) {
28329 if (node.type === NodeType.Document) {
28330 return node.rootObject;
28331 } else if (node.isRoot) {
28332 return node;
28333 } else {
28334 node = node.parent;
28335 }
28336 }
28337 };
28338
28339 XMLNode.prototype.document = function () {
28340 var node;
28341 node = this;
28342 while (node) {
28343 if (node.type === NodeType.Document) {
28344 return node;
28345 } else {
28346 node = node.parent;
28347 }
28348 }
28349 };
28350
28351 XMLNode.prototype.end = function (options) {
28352 return this.document().end(options);
28353 };
28354
28355 XMLNode.prototype.prev = function () {
28356 var i;
28357 i = this.parent.children.indexOf(this);
28358 if (i < 1) {
28359 throw new Error("Already at the first node. " + this.debugInfo());
28360 }
28361 return this.parent.children[i - 1];
28362 };
28363
28364 XMLNode.prototype.next = function () {
28365 var i;
28366 i = this.parent.children.indexOf(this);
28367 if (i === -1 || i === this.parent.children.length - 1) {
28368 throw new Error("Already at the last node. " + this.debugInfo());
28369 }
28370 return this.parent.children[i + 1];
28371 };
28372
28373 XMLNode.prototype.importDocument = function (doc) {
28374 var clonedRoot;
28375 clonedRoot = doc.root().clone();
28376 clonedRoot.parent = this;
28377 clonedRoot.isRoot = false;
28378 this.children.push(clonedRoot);
28379 return this;
28380 };
28381
28382 XMLNode.prototype.debugInfo = function (name) {
28383 var ref2, ref3;
28384 name = name || this.name;
28385 if (name == null && !((ref2 = this.parent) != null ? ref2.name : void 0)) {
28386 return "";
28387 } else if (name == null) {
28388 return "parent: <" + this.parent.name + ">";
28389 } else if (!((ref3 = this.parent) != null ? ref3.name : void 0)) {
28390 return "node: <" + name + ">";
28391 } else {
28392 return "node: <" + name + ">, parent: <" + this.parent.name + ">";
28393 }
28394 };
28395
28396 XMLNode.prototype.ele = function (name, attributes, text) {
28397 return this.element(name, attributes, text);
28398 };
28399
28400 XMLNode.prototype.nod = function (name, attributes, text) {
28401 return this.node(name, attributes, text);
28402 };
28403
28404 XMLNode.prototype.txt = function (value) {
28405 return this.text(value);
28406 };
28407
28408 XMLNode.prototype.dat = function (value) {
28409 return this.cdata(value);
28410 };
28411
28412 XMLNode.prototype.com = function (value) {
28413 return this.comment(value);
28414 };
28415
28416 XMLNode.prototype.ins = function (target, value) {
28417 return this.instruction(target, value);
28418 };
28419
28420 XMLNode.prototype.doc = function () {
28421 return this.document();
28422 };
28423
28424 XMLNode.prototype.dec = function (version, encoding, standalone) {
28425 return this.declaration(version, encoding, standalone);
28426 };
28427
28428 XMLNode.prototype.e = function (name, attributes, text) {
28429 return this.element(name, attributes, text);
28430 };
28431
28432 XMLNode.prototype.n = function (name, attributes, text) {
28433 return this.node(name, attributes, text);
28434 };
28435
28436 XMLNode.prototype.t = function (value) {
28437 return this.text(value);
28438 };
28439
28440 XMLNode.prototype.d = function (value) {
28441 return this.cdata(value);
28442 };
28443
28444 XMLNode.prototype.c = function (value) {
28445 return this.comment(value);
28446 };
28447
28448 XMLNode.prototype.r = function (value) {
28449 return this.raw(value);
28450 };
28451
28452 XMLNode.prototype.i = function (target, value) {
28453 return this.instruction(target, value);
28454 };
28455
28456 XMLNode.prototype.u = function () {
28457 return this.up();
28458 };
28459
28460 XMLNode.prototype.importXMLBuilder = function (doc) {
28461 return this.importDocument(doc);
28462 };
28463
28464 XMLNode.prototype.replaceChild = function (newChild, oldChild) {
28465 throw new Error("This DOM method is not implemented." + this.debugInfo());
28466 };
28467
28468 XMLNode.prototype.removeChild = function (oldChild) {
28469 throw new Error("This DOM method is not implemented." + this.debugInfo());
28470 };
28471
28472 XMLNode.prototype.appendChild = function (newChild) {
28473 throw new Error("This DOM method is not implemented." + this.debugInfo());
28474 };
28475
28476 XMLNode.prototype.hasChildNodes = function () {
28477 return this.children.length !== 0;
28478 };
28479
28480 XMLNode.prototype.cloneNode = function (deep) {
28481 throw new Error("This DOM method is not implemented." + this.debugInfo());
28482 };
28483
28484 XMLNode.prototype.normalize = function () {
28485 throw new Error("This DOM method is not implemented." + this.debugInfo());
28486 };
28487
28488 XMLNode.prototype.isSupported = function (feature, version) {
28489 return true;
28490 };
28491
28492 XMLNode.prototype.hasAttributes = function () {
28493 return this.attribs.length !== 0;
28494 };
28495
28496 XMLNode.prototype.compareDocumentPosition = function (other) {
28497 var ref, res;
28498 ref = this;
28499 if (ref === other) {
28500 return 0;
28501 } else if (this.document() !== other.document()) {
28502 res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
28503 if (Math.random() < 0.5) {
28504 res |= DocumentPosition.Preceding;
28505 } else {
28506 res |= DocumentPosition.Following;
28507 }
28508 return res;
28509 } else if (ref.isAncestor(other)) {
28510 return DocumentPosition.Contains | DocumentPosition.Preceding;
28511 } else if (ref.isDescendant(other)) {
28512 return DocumentPosition.Contains | DocumentPosition.Following;
28513 } else if (ref.isPreceding(other)) {
28514 return DocumentPosition.Preceding;
28515 } else {
28516 return DocumentPosition.Following;
28517 }
28518 };
28519
28520 XMLNode.prototype.isSameNode = function (other) {
28521 throw new Error("This DOM method is not implemented." + this.debugInfo());
28522 };
28523
28524 XMLNode.prototype.lookupPrefix = function (namespaceURI) {
28525 throw new Error("This DOM method is not implemented." + this.debugInfo());
28526 };
28527
28528 XMLNode.prototype.isDefaultNamespace = function (namespaceURI) {
28529 throw new Error("This DOM method is not implemented." + this.debugInfo());
28530 };
28531
28532 XMLNode.prototype.lookupNamespaceURI = function (prefix) {
28533 throw new Error("This DOM method is not implemented." + this.debugInfo());
28534 };
28535
28536 XMLNode.prototype.isEqualNode = function (node) {
28537 var i, j, ref2;
28538 if (node.nodeType !== this.nodeType) {
28539 return false;
28540 }
28541 if (node.children.length !== this.children.length) {
28542 return false;
28543 }
28544 for (i = j = 0, ref2 = this.children.length - 1; 0 <= ref2 ? j <= ref2 : j >= ref2; i = 0 <= ref2 ? ++j : --j) {
28545 if (!this.children[i].isEqualNode(node.children[i])) {
28546 return false;
28547 }
28548 }
28549 return true;
28550 };
28551
28552 XMLNode.prototype.getFeature = function (feature, version) {
28553 throw new Error("This DOM method is not implemented." + this.debugInfo());
28554 };
28555
28556 XMLNode.prototype.setUserData = function (key, data, handler) {
28557 throw new Error("This DOM method is not implemented." + this.debugInfo());
28558 };
28559
28560 XMLNode.prototype.getUserData = function (key) {
28561 throw new Error("This DOM method is not implemented." + this.debugInfo());
28562 };
28563
28564 XMLNode.prototype.contains = function (other) {
28565 if (!other) {
28566 return false;
28567 }
28568 return other === this || this.isDescendant(other);
28569 };
28570
28571 XMLNode.prototype.isDescendant = function (node) {
28572 var child, isDescendantChild, j, len, ref2;
28573 ref2 = this.children;
28574 for (j = 0, len = ref2.length; j < len; j++) {
28575 child = ref2[j];
28576 if (node === child) {
28577 return true;
28578 }
28579 isDescendantChild = child.isDescendant(node);
28580 if (isDescendantChild) {
28581 return true;
28582 }
28583 }
28584 return false;
28585 };
28586
28587 XMLNode.prototype.isAncestor = function (node) {
28588 return node.isDescendant(this);
28589 };
28590
28591 XMLNode.prototype.isPreceding = function (node) {
28592 var nodePos, thisPos;
28593 nodePos = this.treePosition(node);
28594 thisPos = this.treePosition(this);
28595 if (nodePos === -1 || thisPos === -1) {
28596 return false;
28597 } else {
28598 return nodePos < thisPos;
28599 }
28600 };
28601
28602 XMLNode.prototype.isFollowing = function (node) {
28603 var nodePos, thisPos;
28604 nodePos = this.treePosition(node);
28605 thisPos = this.treePosition(this);
28606 if (nodePos === -1 || thisPos === -1) {
28607 return false;
28608 } else {
28609 return nodePos > thisPos;
28610 }
28611 };
28612
28613 XMLNode.prototype.treePosition = function (node) {
28614 var found, pos;
28615 pos = 0;
28616 found = false;
28617 this.foreachTreeNode(this.document(), function (childNode) {
28618 pos++;
28619 if (!found && childNode === node) {
28620 return found = true;
28621 }
28622 });
28623 if (found) {
28624 return pos;
28625 } else {
28626 return -1;
28627 }
28628 };
28629
28630 XMLNode.prototype.foreachTreeNode = function (node, func) {
28631 var child, j, len, ref2, res;
28632 node || (node = this.document());
28633 ref2 = node.children;
28634 for (j = 0, len = ref2.length; j < len; j++) {
28635 child = ref2[j];
28636 if (res = func(child)) {
28637 return res;
28638 } else {
28639 res = this.foreachTreeNode(child, func);
28640 if (res) {
28641 return res;
28642 }
28643 }
28644 }
28645 };
28646
28647 return XMLNode;
28648 }();
28649}).call(undefined);
28650
28651},{"./DocumentPosition":284,"./NodeType":285,"./Utility":286,"./XMLCData":289,"./XMLComment":291,"./XMLDeclaration":300,"./XMLDocType":301,"./XMLDummy":304,"./XMLElement":305,"./XMLNamedNodeMap":306,"./XMLNodeList":308,"./XMLProcessingInstruction":309,"./XMLRaw":310,"./XMLText":314}],308:[function(require,module,exports){
28652'use strict';
28653
28654// Generated by CoffeeScript 1.12.7
28655(function () {
28656 var XMLNodeList;
28657
28658 module.exports = XMLNodeList = function () {
28659 function XMLNodeList(nodes) {
28660 this.nodes = nodes;
28661 }
28662
28663 Object.defineProperty(XMLNodeList.prototype, 'length', {
28664 get: function get() {
28665 return this.nodes.length || 0;
28666 }
28667 });
28668
28669 XMLNodeList.prototype.clone = function () {
28670 return this.nodes = null;
28671 };
28672
28673 XMLNodeList.prototype.item = function (index) {
28674 return this.nodes[index] || null;
28675 };
28676
28677 return XMLNodeList;
28678 }();
28679}).call(undefined);
28680
28681},{}],309:[function(require,module,exports){
28682'use strict';
28683
28684var _create = require('babel-runtime/core-js/object/create');
28685
28686var _create2 = _interopRequireDefault(_create);
28687
28688function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28689
28690// Generated by CoffeeScript 1.12.7
28691(function () {
28692 var NodeType,
28693 XMLCharacterData,
28694 XMLProcessingInstruction,
28695 extend = function extend(child, parent) {
28696 for (var key in parent) {
28697 if (hasProp.call(parent, key)) child[key] = parent[key];
28698 }function ctor() {
28699 this.constructor = child;
28700 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
28701 },
28702 hasProp = {}.hasOwnProperty;
28703
28704 NodeType = require('./NodeType');
28705
28706 XMLCharacterData = require('./XMLCharacterData');
28707
28708 module.exports = XMLProcessingInstruction = function (superClass) {
28709 extend(XMLProcessingInstruction, superClass);
28710
28711 function XMLProcessingInstruction(parent, target, value) {
28712 XMLProcessingInstruction.__super__.constructor.call(this, parent);
28713 if (target == null) {
28714 throw new Error("Missing instruction target. " + this.debugInfo());
28715 }
28716 this.type = NodeType.ProcessingInstruction;
28717 this.target = this.stringify.insTarget(target);
28718 this.name = this.target;
28719 if (value) {
28720 this.value = this.stringify.insValue(value);
28721 }
28722 }
28723
28724 XMLProcessingInstruction.prototype.clone = function () {
28725 return (0, _create2.default)(this);
28726 };
28727
28728 XMLProcessingInstruction.prototype.toString = function (options) {
28729 return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
28730 };
28731
28732 XMLProcessingInstruction.prototype.isEqualNode = function (node) {
28733 if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
28734 return false;
28735 }
28736 if (node.target !== this.target) {
28737 return false;
28738 }
28739 return true;
28740 };
28741
28742 return XMLProcessingInstruction;
28743 }(XMLCharacterData);
28744}).call(undefined);
28745
28746},{"./NodeType":285,"./XMLCharacterData":290,"babel-runtime/core-js/object/create":40}],310:[function(require,module,exports){
28747'use strict';
28748
28749var _create = require('babel-runtime/core-js/object/create');
28750
28751var _create2 = _interopRequireDefault(_create);
28752
28753function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28754
28755// Generated by CoffeeScript 1.12.7
28756(function () {
28757 var NodeType,
28758 XMLNode,
28759 XMLRaw,
28760 extend = function extend(child, parent) {
28761 for (var key in parent) {
28762 if (hasProp.call(parent, key)) child[key] = parent[key];
28763 }function ctor() {
28764 this.constructor = child;
28765 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
28766 },
28767 hasProp = {}.hasOwnProperty;
28768
28769 NodeType = require('./NodeType');
28770
28771 XMLNode = require('./XMLNode');
28772
28773 module.exports = XMLRaw = function (superClass) {
28774 extend(XMLRaw, superClass);
28775
28776 function XMLRaw(parent, text) {
28777 XMLRaw.__super__.constructor.call(this, parent);
28778 if (text == null) {
28779 throw new Error("Missing raw text. " + this.debugInfo());
28780 }
28781 this.type = NodeType.Raw;
28782 this.value = this.stringify.raw(text);
28783 }
28784
28785 XMLRaw.prototype.clone = function () {
28786 return (0, _create2.default)(this);
28787 };
28788
28789 XMLRaw.prototype.toString = function (options) {
28790 return this.options.writer.raw(this, this.options.writer.filterOptions(options));
28791 };
28792
28793 return XMLRaw;
28794 }(XMLNode);
28795}).call(undefined);
28796
28797},{"./NodeType":285,"./XMLNode":307,"babel-runtime/core-js/object/create":40}],311:[function(require,module,exports){
28798'use strict';
28799
28800// Generated by CoffeeScript 1.12.7
28801(function () {
28802 var NodeType,
28803 WriterState,
28804 XMLStreamWriter,
28805 XMLWriterBase,
28806 extend = function extend(child, parent) {
28807 for (var key in parent) {
28808 if (hasProp.call(parent, key)) child[key] = parent[key];
28809 }function ctor() {
28810 this.constructor = child;
28811 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
28812 },
28813 hasProp = {}.hasOwnProperty;
28814
28815 NodeType = require('./NodeType');
28816
28817 XMLWriterBase = require('./XMLWriterBase');
28818
28819 WriterState = require('./WriterState');
28820
28821 module.exports = XMLStreamWriter = function (superClass) {
28822 extend(XMLStreamWriter, superClass);
28823
28824 function XMLStreamWriter(stream, options) {
28825 this.stream = stream;
28826 XMLStreamWriter.__super__.constructor.call(this, options);
28827 }
28828
28829 XMLStreamWriter.prototype.endline = function (node, options, level) {
28830 if (node.isLastRootNode && options.state === WriterState.CloseTag) {
28831 return '';
28832 } else {
28833 return XMLStreamWriter.__super__.endline.call(this, node, options, level);
28834 }
28835 };
28836
28837 XMLStreamWriter.prototype.document = function (doc, options) {
28838 var child, i, j, k, len, len1, ref, ref1, results;
28839 ref = doc.children;
28840 for (i = j = 0, len = ref.length; j < len; i = ++j) {
28841 child = ref[i];
28842 child.isLastRootNode = i === doc.children.length - 1;
28843 }
28844 options = this.filterOptions(options);
28845 ref1 = doc.children;
28846 results = [];
28847 for (k = 0, len1 = ref1.length; k < len1; k++) {
28848 child = ref1[k];
28849 results.push(this.writeChildNode(child, options, 0));
28850 }
28851 return results;
28852 };
28853
28854 XMLStreamWriter.prototype.attribute = function (att, options, level) {
28855 return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level));
28856 };
28857
28858 XMLStreamWriter.prototype.cdata = function (node, options, level) {
28859 return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level));
28860 };
28861
28862 XMLStreamWriter.prototype.comment = function (node, options, level) {
28863 return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level));
28864 };
28865
28866 XMLStreamWriter.prototype.declaration = function (node, options, level) {
28867 return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level));
28868 };
28869
28870 XMLStreamWriter.prototype.docType = function (node, options, level) {
28871 var child, j, len, ref;
28872 level || (level = 0);
28873 this.openNode(node, options, level);
28874 options.state = WriterState.OpenTag;
28875 this.stream.write(this.indent(node, options, level));
28876 this.stream.write('<!DOCTYPE ' + node.root().name);
28877 if (node.pubID && node.sysID) {
28878 this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
28879 } else if (node.sysID) {
28880 this.stream.write(' SYSTEM "' + node.sysID + '"');
28881 }
28882 if (node.children.length > 0) {
28883 this.stream.write(' [');
28884 this.stream.write(this.endline(node, options, level));
28885 options.state = WriterState.InsideTag;
28886 ref = node.children;
28887 for (j = 0, len = ref.length; j < len; j++) {
28888 child = ref[j];
28889 this.writeChildNode(child, options, level + 1);
28890 }
28891 options.state = WriterState.CloseTag;
28892 this.stream.write(']');
28893 }
28894 options.state = WriterState.CloseTag;
28895 this.stream.write(options.spaceBeforeSlash + '>');
28896 this.stream.write(this.endline(node, options, level));
28897 options.state = WriterState.None;
28898 return this.closeNode(node, options, level);
28899 };
28900
28901 XMLStreamWriter.prototype.element = function (node, options, level) {
28902 var att, child, childNodeCount, firstChildNode, j, len, name, prettySuppressed, ref, ref1;
28903 level || (level = 0);
28904 this.openNode(node, options, level);
28905 options.state = WriterState.OpenTag;
28906 this.stream.write(this.indent(node, options, level) + '<' + node.name);
28907 ref = node.attribs;
28908 for (name in ref) {
28909 if (!hasProp.call(ref, name)) continue;
28910 att = ref[name];
28911 this.attribute(att, options, level);
28912 }
28913 childNodeCount = node.children.length;
28914 firstChildNode = childNodeCount === 0 ? null : node.children[0];
28915 if (childNodeCount === 0 || node.children.every(function (e) {
28916 return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
28917 })) {
28918 if (options.allowEmpty) {
28919 this.stream.write('>');
28920 options.state = WriterState.CloseTag;
28921 this.stream.write('</' + node.name + '>');
28922 } else {
28923 options.state = WriterState.CloseTag;
28924 this.stream.write(options.spaceBeforeSlash + '/>');
28925 }
28926 } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && firstChildNode.value != null) {
28927 this.stream.write('>');
28928 options.state = WriterState.InsideTag;
28929 options.suppressPrettyCount++;
28930 prettySuppressed = true;
28931 this.writeChildNode(firstChildNode, options, level + 1);
28932 options.suppressPrettyCount--;
28933 prettySuppressed = false;
28934 options.state = WriterState.CloseTag;
28935 this.stream.write('</' + node.name + '>');
28936 } else {
28937 this.stream.write('>' + this.endline(node, options, level));
28938 options.state = WriterState.InsideTag;
28939 ref1 = node.children;
28940 for (j = 0, len = ref1.length; j < len; j++) {
28941 child = ref1[j];
28942 this.writeChildNode(child, options, level + 1);
28943 }
28944 options.state = WriterState.CloseTag;
28945 this.stream.write(this.indent(node, options, level) + '</' + node.name + '>');
28946 }
28947 this.stream.write(this.endline(node, options, level));
28948 options.state = WriterState.None;
28949 return this.closeNode(node, options, level);
28950 };
28951
28952 XMLStreamWriter.prototype.processingInstruction = function (node, options, level) {
28953 return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level));
28954 };
28955
28956 XMLStreamWriter.prototype.raw = function (node, options, level) {
28957 return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level));
28958 };
28959
28960 XMLStreamWriter.prototype.text = function (node, options, level) {
28961 return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level));
28962 };
28963
28964 XMLStreamWriter.prototype.dtdAttList = function (node, options, level) {
28965 return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level));
28966 };
28967
28968 XMLStreamWriter.prototype.dtdElement = function (node, options, level) {
28969 return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level));
28970 };
28971
28972 XMLStreamWriter.prototype.dtdEntity = function (node, options, level) {
28973 return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level));
28974 };
28975
28976 XMLStreamWriter.prototype.dtdNotation = function (node, options, level) {
28977 return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level));
28978 };
28979
28980 return XMLStreamWriter;
28981 }(XMLWriterBase);
28982}).call(undefined);
28983
28984},{"./NodeType":285,"./WriterState":287,"./XMLWriterBase":315}],312:[function(require,module,exports){
28985'use strict';
28986
28987// Generated by CoffeeScript 1.12.7
28988(function () {
28989 var XMLStringWriter,
28990 XMLWriterBase,
28991 extend = function extend(child, parent) {
28992 for (var key in parent) {
28993 if (hasProp.call(parent, key)) child[key] = parent[key];
28994 }function ctor() {
28995 this.constructor = child;
28996 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
28997 },
28998 hasProp = {}.hasOwnProperty;
28999
29000 XMLWriterBase = require('./XMLWriterBase');
29001
29002 module.exports = XMLStringWriter = function (superClass) {
29003 extend(XMLStringWriter, superClass);
29004
29005 function XMLStringWriter(options) {
29006 XMLStringWriter.__super__.constructor.call(this, options);
29007 }
29008
29009 XMLStringWriter.prototype.document = function (doc, options) {
29010 var child, i, len, r, ref;
29011 options = this.filterOptions(options);
29012 r = '';
29013 ref = doc.children;
29014 for (i = 0, len = ref.length; i < len; i++) {
29015 child = ref[i];
29016 r += this.writeChildNode(child, options, 0);
29017 }
29018 if (options.pretty && r.slice(-options.newline.length) === options.newline) {
29019 r = r.slice(0, -options.newline.length);
29020 }
29021 return r;
29022 };
29023
29024 return XMLStringWriter;
29025 }(XMLWriterBase);
29026}).call(undefined);
29027
29028},{"./XMLWriterBase":315}],313:[function(require,module,exports){
29029'use strict';
29030
29031// Generated by CoffeeScript 1.12.7
29032(function () {
29033 var XMLStringifier,
29034 bind = function bind(fn, me) {
29035 return function () {
29036 return fn.apply(me, arguments);
29037 };
29038 },
29039 hasProp = {}.hasOwnProperty;
29040
29041 module.exports = XMLStringifier = function () {
29042 function XMLStringifier(options) {
29043 this.assertLegalName = bind(this.assertLegalName, this);
29044 this.assertLegalChar = bind(this.assertLegalChar, this);
29045 var key, ref, value;
29046 options || (options = {});
29047 this.options = options;
29048 if (!this.options.version) {
29049 this.options.version = '1.0';
29050 }
29051 ref = options.stringify || {};
29052 for (key in ref) {
29053 if (!hasProp.call(ref, key)) continue;
29054 value = ref[key];
29055 this[key] = value;
29056 }
29057 }
29058
29059 XMLStringifier.prototype.name = function (val) {
29060 if (this.options.noValidation) {
29061 return val;
29062 }
29063 return this.assertLegalName('' + val || '');
29064 };
29065
29066 XMLStringifier.prototype.text = function (val) {
29067 if (this.options.noValidation) {
29068 return val;
29069 }
29070 return this.assertLegalChar(this.textEscape('' + val || ''));
29071 };
29072
29073 XMLStringifier.prototype.cdata = function (val) {
29074 if (this.options.noValidation) {
29075 return val;
29076 }
29077 val = '' + val || '';
29078 val = val.replace(']]>', ']]]]><![CDATA[>');
29079 return this.assertLegalChar(val);
29080 };
29081
29082 XMLStringifier.prototype.comment = function (val) {
29083 if (this.options.noValidation) {
29084 return val;
29085 }
29086 val = '' + val || '';
29087 if (val.match(/--/)) {
29088 throw new Error("Comment text cannot contain double-hypen: " + val);
29089 }
29090 return this.assertLegalChar(val);
29091 };
29092
29093 XMLStringifier.prototype.raw = function (val) {
29094 if (this.options.noValidation) {
29095 return val;
29096 }
29097 return '' + val || '';
29098 };
29099
29100 XMLStringifier.prototype.attValue = function (val) {
29101 if (this.options.noValidation) {
29102 return val;
29103 }
29104 return this.assertLegalChar(this.attEscape(val = '' + val || ''));
29105 };
29106
29107 XMLStringifier.prototype.insTarget = function (val) {
29108 if (this.options.noValidation) {
29109 return val;
29110 }
29111 return this.assertLegalChar('' + val || '');
29112 };
29113
29114 XMLStringifier.prototype.insValue = function (val) {
29115 if (this.options.noValidation) {
29116 return val;
29117 }
29118 val = '' + val || '';
29119 if (val.match(/\?>/)) {
29120 throw new Error("Invalid processing instruction value: " + val);
29121 }
29122 return this.assertLegalChar(val);
29123 };
29124
29125 XMLStringifier.prototype.xmlVersion = function (val) {
29126 if (this.options.noValidation) {
29127 return val;
29128 }
29129 val = '' + val || '';
29130 if (!val.match(/1\.[0-9]+/)) {
29131 throw new Error("Invalid version number: " + val);
29132 }
29133 return val;
29134 };
29135
29136 XMLStringifier.prototype.xmlEncoding = function (val) {
29137 if (this.options.noValidation) {
29138 return val;
29139 }
29140 val = '' + val || '';
29141 if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
29142 throw new Error("Invalid encoding: " + val);
29143 }
29144 return this.assertLegalChar(val);
29145 };
29146
29147 XMLStringifier.prototype.xmlStandalone = function (val) {
29148 if (this.options.noValidation) {
29149 return val;
29150 }
29151 if (val) {
29152 return "yes";
29153 } else {
29154 return "no";
29155 }
29156 };
29157
29158 XMLStringifier.prototype.dtdPubID = function (val) {
29159 if (this.options.noValidation) {
29160 return val;
29161 }
29162 return this.assertLegalChar('' + val || '');
29163 };
29164
29165 XMLStringifier.prototype.dtdSysID = function (val) {
29166 if (this.options.noValidation) {
29167 return val;
29168 }
29169 return this.assertLegalChar('' + val || '');
29170 };
29171
29172 XMLStringifier.prototype.dtdElementValue = function (val) {
29173 if (this.options.noValidation) {
29174 return val;
29175 }
29176 return this.assertLegalChar('' + val || '');
29177 };
29178
29179 XMLStringifier.prototype.dtdAttType = function (val) {
29180 if (this.options.noValidation) {
29181 return val;
29182 }
29183 return this.assertLegalChar('' + val || '');
29184 };
29185
29186 XMLStringifier.prototype.dtdAttDefault = function (val) {
29187 if (this.options.noValidation) {
29188 return val;
29189 }
29190 return this.assertLegalChar('' + val || '');
29191 };
29192
29193 XMLStringifier.prototype.dtdEntityValue = function (val) {
29194 if (this.options.noValidation) {
29195 return val;
29196 }
29197 return this.assertLegalChar('' + val || '');
29198 };
29199
29200 XMLStringifier.prototype.dtdNData = function (val) {
29201 if (this.options.noValidation) {
29202 return val;
29203 }
29204 return this.assertLegalChar('' + val || '');
29205 };
29206
29207 XMLStringifier.prototype.convertAttKey = '@';
29208
29209 XMLStringifier.prototype.convertPIKey = '?';
29210
29211 XMLStringifier.prototype.convertTextKey = '#text';
29212
29213 XMLStringifier.prototype.convertCDataKey = '#cdata';
29214
29215 XMLStringifier.prototype.convertCommentKey = '#comment';
29216
29217 XMLStringifier.prototype.convertRawKey = '#raw';
29218
29219 XMLStringifier.prototype.assertLegalChar = function (str) {
29220 var regex, res;
29221 if (this.options.noValidation) {
29222 return str;
29223 }
29224 regex = '';
29225 if (this.options.version === '1.0') {
29226 regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
29227 if (res = str.match(regex)) {
29228 throw new Error("Invalid character in string: " + str + " at index " + res.index);
29229 }
29230 } else if (this.options.version === '1.1') {
29231 regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
29232 if (res = str.match(regex)) {
29233 throw new Error("Invalid character in string: " + str + " at index " + res.index);
29234 }
29235 }
29236 return str;
29237 };
29238
29239 XMLStringifier.prototype.assertLegalName = function (str) {
29240 var regex;
29241 if (this.options.noValidation) {
29242 return str;
29243 }
29244 this.assertLegalChar(str);
29245 regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/;
29246 if (!str.match(regex)) {
29247 throw new Error("Invalid character in name");
29248 }
29249 return str;
29250 };
29251
29252 XMLStringifier.prototype.textEscape = function (str) {
29253 var ampregex;
29254 if (this.options.noValidation) {
29255 return str;
29256 }
29257 ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
29258 return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
29259 };
29260
29261 XMLStringifier.prototype.attEscape = function (str) {
29262 var ampregex;
29263 if (this.options.noValidation) {
29264 return str;
29265 }
29266 ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
29267 return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
29268 };
29269
29270 return XMLStringifier;
29271 }();
29272}).call(undefined);
29273
29274},{}],314:[function(require,module,exports){
29275'use strict';
29276
29277var _create = require('babel-runtime/core-js/object/create');
29278
29279var _create2 = _interopRequireDefault(_create);
29280
29281function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29282
29283// Generated by CoffeeScript 1.12.7
29284(function () {
29285 var NodeType,
29286 XMLCharacterData,
29287 XMLText,
29288 extend = function extend(child, parent) {
29289 for (var key in parent) {
29290 if (hasProp.call(parent, key)) child[key] = parent[key];
29291 }function ctor() {
29292 this.constructor = child;
29293 }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
29294 },
29295 hasProp = {}.hasOwnProperty;
29296
29297 NodeType = require('./NodeType');
29298
29299 XMLCharacterData = require('./XMLCharacterData');
29300
29301 module.exports = XMLText = function (superClass) {
29302 extend(XMLText, superClass);
29303
29304 function XMLText(parent, text) {
29305 XMLText.__super__.constructor.call(this, parent);
29306 if (text == null) {
29307 throw new Error("Missing element text. " + this.debugInfo());
29308 }
29309 this.name = "#text";
29310 this.type = NodeType.Text;
29311 this.value = this.stringify.text(text);
29312 }
29313
29314 Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', {
29315 get: function get() {
29316 throw new Error("This DOM method is not implemented." + this.debugInfo());
29317 }
29318 });
29319
29320 Object.defineProperty(XMLText.prototype, 'wholeText', {
29321 get: function get() {
29322 var next, prev, str;
29323 str = '';
29324 prev = this.previousSibling;
29325 while (prev) {
29326 str = prev.data + str;
29327 prev = prev.previousSibling;
29328 }
29329 str += this.data;
29330 next = this.nextSibling;
29331 while (next) {
29332 str = str + next.data;
29333 next = next.nextSibling;
29334 }
29335 return str;
29336 }
29337 });
29338
29339 XMLText.prototype.clone = function () {
29340 return (0, _create2.default)(this);
29341 };
29342
29343 XMLText.prototype.toString = function (options) {
29344 return this.options.writer.text(this, this.options.writer.filterOptions(options));
29345 };
29346
29347 XMLText.prototype.splitText = function (offset) {
29348 throw new Error("This DOM method is not implemented." + this.debugInfo());
29349 };
29350
29351 XMLText.prototype.replaceWholeText = function (content) {
29352 throw new Error("This DOM method is not implemented." + this.debugInfo());
29353 };
29354
29355 return XMLText;
29356 }(XMLCharacterData);
29357}).call(undefined);
29358
29359},{"./NodeType":285,"./XMLCharacterData":290,"babel-runtime/core-js/object/create":40}],315:[function(require,module,exports){
29360'use strict';
29361
29362// Generated by CoffeeScript 1.12.7
29363(function () {
29364 var NodeType,
29365 WriterState,
29366 XMLCData,
29367 XMLComment,
29368 XMLDTDAttList,
29369 XMLDTDElement,
29370 XMLDTDEntity,
29371 XMLDTDNotation,
29372 XMLDeclaration,
29373 XMLDocType,
29374 XMLDummy,
29375 XMLElement,
29376 XMLProcessingInstruction,
29377 XMLRaw,
29378 XMLText,
29379 XMLWriterBase,
29380 assign,
29381 hasProp = {}.hasOwnProperty;
29382
29383 assign = require('./Utility').assign;
29384
29385 NodeType = require('./NodeType');
29386
29387 XMLDeclaration = require('./XMLDeclaration');
29388
29389 XMLDocType = require('./XMLDocType');
29390
29391 XMLCData = require('./XMLCData');
29392
29393 XMLComment = require('./XMLComment');
29394
29395 XMLElement = require('./XMLElement');
29396
29397 XMLRaw = require('./XMLRaw');
29398
29399 XMLText = require('./XMLText');
29400
29401 XMLProcessingInstruction = require('./XMLProcessingInstruction');
29402
29403 XMLDummy = require('./XMLDummy');
29404
29405 XMLDTDAttList = require('./XMLDTDAttList');
29406
29407 XMLDTDElement = require('./XMLDTDElement');
29408
29409 XMLDTDEntity = require('./XMLDTDEntity');
29410
29411 XMLDTDNotation = require('./XMLDTDNotation');
29412
29413 WriterState = require('./WriterState');
29414
29415 module.exports = XMLWriterBase = function () {
29416 function XMLWriterBase(options) {
29417 var key, ref, value;
29418 options || (options = {});
29419 this.options = options;
29420 ref = options.writer || {};
29421 for (key in ref) {
29422 if (!hasProp.call(ref, key)) continue;
29423 value = ref[key];
29424 this["_" + key] = this[key];
29425 this[key] = value;
29426 }
29427 }
29428
29429 XMLWriterBase.prototype.filterOptions = function (options) {
29430 var filteredOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6;
29431 options || (options = {});
29432 options = assign({}, this.options, options);
29433 filteredOptions = {
29434 writer: this
29435 };
29436 filteredOptions.pretty = options.pretty || false;
29437 filteredOptions.allowEmpty = options.allowEmpty || false;
29438 filteredOptions.indent = (ref = options.indent) != null ? ref : ' ';
29439 filteredOptions.newline = (ref1 = options.newline) != null ? ref1 : '\n';
29440 filteredOptions.offset = (ref2 = options.offset) != null ? ref2 : 0;
29441 filteredOptions.dontPrettyTextNodes = (ref3 = (ref4 = options.dontPrettyTextNodes) != null ? ref4 : options.dontprettytextnodes) != null ? ref3 : 0;
29442 filteredOptions.spaceBeforeSlash = (ref5 = (ref6 = options.spaceBeforeSlash) != null ? ref6 : options.spacebeforeslash) != null ? ref5 : '';
29443 if (filteredOptions.spaceBeforeSlash === true) {
29444 filteredOptions.spaceBeforeSlash = ' ';
29445 }
29446 filteredOptions.suppressPrettyCount = 0;
29447 filteredOptions.user = {};
29448 filteredOptions.state = WriterState.None;
29449 return filteredOptions;
29450 };
29451
29452 XMLWriterBase.prototype.indent = function (node, options, level) {
29453 var indentLevel;
29454 if (!options.pretty || options.suppressPrettyCount) {
29455 return '';
29456 } else if (options.pretty) {
29457 indentLevel = (level || 0) + options.offset + 1;
29458 if (indentLevel > 0) {
29459 return new Array(indentLevel).join(options.indent);
29460 }
29461 }
29462 return '';
29463 };
29464
29465 XMLWriterBase.prototype.endline = function (node, options, level) {
29466 if (!options.pretty || options.suppressPrettyCount) {
29467 return '';
29468 } else {
29469 return options.newline;
29470 }
29471 };
29472
29473 XMLWriterBase.prototype.attribute = function (att, options, level) {
29474 var r;
29475 this.openAttribute(att, options, level);
29476 r = ' ' + att.name + '="' + att.value + '"';
29477 this.closeAttribute(att, options, level);
29478 return r;
29479 };
29480
29481 XMLWriterBase.prototype.cdata = function (node, options, level) {
29482 var r;
29483 this.openNode(node, options, level);
29484 options.state = WriterState.OpenTag;
29485 r = this.indent(node, options, level) + '<![CDATA[';
29486 options.state = WriterState.InsideTag;
29487 r += node.value;
29488 options.state = WriterState.CloseTag;
29489 r += ']]>' + this.endline(node, options, level);
29490 options.state = WriterState.None;
29491 this.closeNode(node, options, level);
29492 return r;
29493 };
29494
29495 XMLWriterBase.prototype.comment = function (node, options, level) {
29496 var r;
29497 this.openNode(node, options, level);
29498 options.state = WriterState.OpenTag;
29499 r = this.indent(node, options, level) + '<!-- ';
29500 options.state = WriterState.InsideTag;
29501 r += node.value;
29502 options.state = WriterState.CloseTag;
29503 r += ' -->' + this.endline(node, options, level);
29504 options.state = WriterState.None;
29505 this.closeNode(node, options, level);
29506 return r;
29507 };
29508
29509 XMLWriterBase.prototype.declaration = function (node, options, level) {
29510 var r;
29511 this.openNode(node, options, level);
29512 options.state = WriterState.OpenTag;
29513 r = this.indent(node, options, level) + '<?xml';
29514 options.state = WriterState.InsideTag;
29515 r += ' version="' + node.version + '"';
29516 if (node.encoding != null) {
29517 r += ' encoding="' + node.encoding + '"';
29518 }
29519 if (node.standalone != null) {
29520 r += ' standalone="' + node.standalone + '"';
29521 }
29522 options.state = WriterState.CloseTag;
29523 r += options.spaceBeforeSlash + '?>';
29524 r += this.endline(node, options, level);
29525 options.state = WriterState.None;
29526 this.closeNode(node, options, level);
29527 return r;
29528 };
29529
29530 XMLWriterBase.prototype.docType = function (node, options, level) {
29531 var child, i, len, r, ref;
29532 level || (level = 0);
29533 this.openNode(node, options, level);
29534 options.state = WriterState.OpenTag;
29535 r = this.indent(node, options, level);
29536 r += '<!DOCTYPE ' + node.root().name;
29537 if (node.pubID && node.sysID) {
29538 r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
29539 } else if (node.sysID) {
29540 r += ' SYSTEM "' + node.sysID + '"';
29541 }
29542 if (node.children.length > 0) {
29543 r += ' [';
29544 r += this.endline(node, options, level);
29545 options.state = WriterState.InsideTag;
29546 ref = node.children;
29547 for (i = 0, len = ref.length; i < len; i++) {
29548 child = ref[i];
29549 r += this.writeChildNode(child, options, level + 1);
29550 }
29551 options.state = WriterState.CloseTag;
29552 r += ']';
29553 }
29554 options.state = WriterState.CloseTag;
29555 r += options.spaceBeforeSlash + '>';
29556 r += this.endline(node, options, level);
29557 options.state = WriterState.None;
29558 this.closeNode(node, options, level);
29559 return r;
29560 };
29561
29562 XMLWriterBase.prototype.element = function (node, options, level) {
29563 var att, child, childNodeCount, firstChildNode, i, j, len, len1, name, prettySuppressed, r, ref, ref1, ref2;
29564 level || (level = 0);
29565 prettySuppressed = false;
29566 r = '';
29567 this.openNode(node, options, level);
29568 options.state = WriterState.OpenTag;
29569 r += this.indent(node, options, level) + '<' + node.name;
29570 ref = node.attribs;
29571 for (name in ref) {
29572 if (!hasProp.call(ref, name)) continue;
29573 att = ref[name];
29574 r += this.attribute(att, options, level);
29575 }
29576 childNodeCount = node.children.length;
29577 firstChildNode = childNodeCount === 0 ? null : node.children[0];
29578 if (childNodeCount === 0 || node.children.every(function (e) {
29579 return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
29580 })) {
29581 if (options.allowEmpty) {
29582 r += '>';
29583 options.state = WriterState.CloseTag;
29584 r += '</' + node.name + '>' + this.endline(node, options, level);
29585 } else {
29586 options.state = WriterState.CloseTag;
29587 r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
29588 }
29589 } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && firstChildNode.value != null) {
29590 r += '>';
29591 options.state = WriterState.InsideTag;
29592 options.suppressPrettyCount++;
29593 prettySuppressed = true;
29594 r += this.writeChildNode(firstChildNode, options, level + 1);
29595 options.suppressPrettyCount--;
29596 prettySuppressed = false;
29597 options.state = WriterState.CloseTag;
29598 r += '</' + node.name + '>' + this.endline(node, options, level);
29599 } else {
29600 if (options.dontPrettyTextNodes) {
29601 ref1 = node.children;
29602 for (i = 0, len = ref1.length; i < len; i++) {
29603 child = ref1[i];
29604 if ((child.type === NodeType.Text || child.type === NodeType.Raw) && child.value != null) {
29605 options.suppressPrettyCount++;
29606 prettySuppressed = true;
29607 break;
29608 }
29609 }
29610 }
29611 r += '>' + this.endline(node, options, level);
29612 options.state = WriterState.InsideTag;
29613 ref2 = node.children;
29614 for (j = 0, len1 = ref2.length; j < len1; j++) {
29615 child = ref2[j];
29616 r += this.writeChildNode(child, options, level + 1);
29617 }
29618 options.state = WriterState.CloseTag;
29619 r += this.indent(node, options, level) + '</' + node.name + '>';
29620 if (prettySuppressed) {
29621 options.suppressPrettyCount--;
29622 }
29623 r += this.endline(node, options, level);
29624 options.state = WriterState.None;
29625 }
29626 this.closeNode(node, options, level);
29627 return r;
29628 };
29629
29630 XMLWriterBase.prototype.writeChildNode = function (node, options, level) {
29631 switch (node.type) {
29632 case NodeType.CData:
29633 return this.cdata(node, options, level);
29634 case NodeType.Comment:
29635 return this.comment(node, options, level);
29636 case NodeType.Element:
29637 return this.element(node, options, level);
29638 case NodeType.Raw:
29639 return this.raw(node, options, level);
29640 case NodeType.Text:
29641 return this.text(node, options, level);
29642 case NodeType.ProcessingInstruction:
29643 return this.processingInstruction(node, options, level);
29644 case NodeType.Dummy:
29645 return '';
29646 case NodeType.Declaration:
29647 return this.declaration(node, options, level);
29648 case NodeType.DocType:
29649 return this.docType(node, options, level);
29650 case NodeType.AttributeDeclaration:
29651 return this.dtdAttList(node, options, level);
29652 case NodeType.ElementDeclaration:
29653 return this.dtdElement(node, options, level);
29654 case NodeType.EntityDeclaration:
29655 return this.dtdEntity(node, options, level);
29656 case NodeType.NotationDeclaration:
29657 return this.dtdNotation(node, options, level);
29658 default:
29659 throw new Error("Unknown XML node type: " + node.constructor.name);
29660 }
29661 };
29662
29663 XMLWriterBase.prototype.processingInstruction = function (node, options, level) {
29664 var r;
29665 this.openNode(node, options, level);
29666 options.state = WriterState.OpenTag;
29667 r = this.indent(node, options, level) + '<?';
29668 options.state = WriterState.InsideTag;
29669 r += node.target;
29670 if (node.value) {
29671 r += ' ' + node.value;
29672 }
29673 options.state = WriterState.CloseTag;
29674 r += options.spaceBeforeSlash + '?>';
29675 r += this.endline(node, options, level);
29676 options.state = WriterState.None;
29677 this.closeNode(node, options, level);
29678 return r;
29679 };
29680
29681 XMLWriterBase.prototype.raw = function (node, options, level) {
29682 var r;
29683 this.openNode(node, options, level);
29684 options.state = WriterState.OpenTag;
29685 r = this.indent(node, options, level);
29686 options.state = WriterState.InsideTag;
29687 r += node.value;
29688 options.state = WriterState.CloseTag;
29689 r += this.endline(node, options, level);
29690 options.state = WriterState.None;
29691 this.closeNode(node, options, level);
29692 return r;
29693 };
29694
29695 XMLWriterBase.prototype.text = function (node, options, level) {
29696 var r;
29697 this.openNode(node, options, level);
29698 options.state = WriterState.OpenTag;
29699 r = this.indent(node, options, level);
29700 options.state = WriterState.InsideTag;
29701 r += node.value;
29702 options.state = WriterState.CloseTag;
29703 r += this.endline(node, options, level);
29704 options.state = WriterState.None;
29705 this.closeNode(node, options, level);
29706 return r;
29707 };
29708
29709 XMLWriterBase.prototype.dtdAttList = function (node, options, level) {
29710 var r;
29711 this.openNode(node, options, level);
29712 options.state = WriterState.OpenTag;
29713 r = this.indent(node, options, level) + '<!ATTLIST';
29714 options.state = WriterState.InsideTag;
29715 r += ' ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
29716 if (node.defaultValueType !== '#DEFAULT') {
29717 r += ' ' + node.defaultValueType;
29718 }
29719 if (node.defaultValue) {
29720 r += ' "' + node.defaultValue + '"';
29721 }
29722 options.state = WriterState.CloseTag;
29723 r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
29724 options.state = WriterState.None;
29725 this.closeNode(node, options, level);
29726 return r;
29727 };
29728
29729 XMLWriterBase.prototype.dtdElement = function (node, options, level) {
29730 var r;
29731 this.openNode(node, options, level);
29732 options.state = WriterState.OpenTag;
29733 r = this.indent(node, options, level) + '<!ELEMENT';
29734 options.state = WriterState.InsideTag;
29735 r += ' ' + node.name + ' ' + node.value;
29736 options.state = WriterState.CloseTag;
29737 r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
29738 options.state = WriterState.None;
29739 this.closeNode(node, options, level);
29740 return r;
29741 };
29742
29743 XMLWriterBase.prototype.dtdEntity = function (node, options, level) {
29744 var r;
29745 this.openNode(node, options, level);
29746 options.state = WriterState.OpenTag;
29747 r = this.indent(node, options, level) + '<!ENTITY';
29748 options.state = WriterState.InsideTag;
29749 if (node.pe) {
29750 r += ' %';
29751 }
29752 r += ' ' + node.name;
29753 if (node.value) {
29754 r += ' "' + node.value + '"';
29755 } else {
29756 if (node.pubID && node.sysID) {
29757 r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
29758 } else if (node.sysID) {
29759 r += ' SYSTEM "' + node.sysID + '"';
29760 }
29761 if (node.nData) {
29762 r += ' NDATA ' + node.nData;
29763 }
29764 }
29765 options.state = WriterState.CloseTag;
29766 r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
29767 options.state = WriterState.None;
29768 this.closeNode(node, options, level);
29769 return r;
29770 };
29771
29772 XMLWriterBase.prototype.dtdNotation = function (node, options, level) {
29773 var r;
29774 this.openNode(node, options, level);
29775 options.state = WriterState.OpenTag;
29776 r = this.indent(node, options, level) + '<!NOTATION';
29777 options.state = WriterState.InsideTag;
29778 r += ' ' + node.name;
29779 if (node.pubID && node.sysID) {
29780 r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
29781 } else if (node.pubID) {
29782 r += ' PUBLIC "' + node.pubID + '"';
29783 } else if (node.sysID) {
29784 r += ' SYSTEM "' + node.sysID + '"';
29785 }
29786 options.state = WriterState.CloseTag;
29787 r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
29788 options.state = WriterState.None;
29789 this.closeNode(node, options, level);
29790 return r;
29791 };
29792
29793 XMLWriterBase.prototype.openNode = function (node, options, level) {};
29794
29795 XMLWriterBase.prototype.closeNode = function (node, options, level) {};
29796
29797 XMLWriterBase.prototype.openAttribute = function (att, options, level) {};
29798
29799 XMLWriterBase.prototype.closeAttribute = function (att, options, level) {};
29800
29801 return XMLWriterBase;
29802 }();
29803}).call(undefined);
29804
29805},{"./NodeType":285,"./Utility":286,"./WriterState":287,"./XMLCData":289,"./XMLComment":291,"./XMLDTDAttList":296,"./XMLDTDElement":297,"./XMLDTDEntity":298,"./XMLDTDNotation":299,"./XMLDeclaration":300,"./XMLDocType":301,"./XMLDummy":304,"./XMLElement":305,"./XMLProcessingInstruction":309,"./XMLRaw":310,"./XMLText":314}],316:[function(require,module,exports){
29806'use strict';
29807
29808// Generated by CoffeeScript 1.12.7
29809(function () {
29810 var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
29811
29812 ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
29813
29814 XMLDOMImplementation = require('./XMLDOMImplementation');
29815
29816 XMLDocument = require('./XMLDocument');
29817
29818 XMLDocumentCB = require('./XMLDocumentCB');
29819
29820 XMLStringWriter = require('./XMLStringWriter');
29821
29822 XMLStreamWriter = require('./XMLStreamWriter');
29823
29824 NodeType = require('./NodeType');
29825
29826 WriterState = require('./WriterState');
29827
29828 module.exports.create = function (name, xmldec, doctype, options) {
29829 var doc, root;
29830 if (name == null) {
29831 throw new Error("Root element needs a name.");
29832 }
29833 options = assign({}, xmldec, doctype, options);
29834 doc = new XMLDocument(options);
29835 root = doc.element(name);
29836 if (!options.headless) {
29837 doc.declaration(options);
29838 if (options.pubID != null || options.sysID != null) {
29839 doc.dtd(options);
29840 }
29841 }
29842 return root;
29843 };
29844
29845 module.exports.begin = function (options, onData, onEnd) {
29846 var ref1;
29847 if (isFunction(options)) {
29848 ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
29849 options = {};
29850 }
29851 if (onData) {
29852 return new XMLDocumentCB(options, onData, onEnd);
29853 } else {
29854 return new XMLDocument(options);
29855 }
29856 };
29857
29858 module.exports.stringWriter = function (options) {
29859 return new XMLStringWriter(options);
29860 };
29861
29862 module.exports.streamWriter = function (stream, options) {
29863 return new XMLStreamWriter(stream, options);
29864 };
29865
29866 module.exports.implementation = new XMLDOMImplementation();
29867
29868 module.exports.nodeType = NodeType;
29869
29870 module.exports.writerState = WriterState;
29871}).call(undefined);
29872
29873},{"./NodeType":285,"./Utility":286,"./WriterState":287,"./XMLDOMImplementation":294,"./XMLDocument":302,"./XMLDocumentCB":303,"./XMLStreamWriter":311,"./XMLStringWriter":312}],317:[function(require,module,exports){
29874module.exports = extend
29875
29876var hasOwnProperty = Object.prototype.hasOwnProperty;
29877
29878function extend() {
29879 var target = {}
29880
29881 for (var i = 0; i < arguments.length; i++) {
29882 var source = arguments[i]
29883
29884 for (var key in source) {
29885 if (hasOwnProperty.call(source, key)) {
29886 target[key] = source[key]
29887 }
29888 }
29889 }
29890
29891 return target
29892}
29893
29894},{}],318:[function(require,module,exports){
29895'use strict';
29896
29897var Buffer = require('buffer').Buffer;
29898var sha = require('./sha');
29899var sha256 = require('./sha256');
29900var md5 = require('./md5');
29901
29902var algorithms = {
29903 sha1: sha,
29904 sha256: sha256,
29905 md5: md5
29906};
29907
29908var blocksize = 64;
29909var zeroBuffer = Buffer.alloc(blocksize);
29910zeroBuffer.fill(0);
29911
29912function hmac(fn, key, data) {
29913 if (!Buffer.isBuffer(key)) key = Buffer.from(key);
29914 if (!Buffer.isBuffer(data)) data = Buffer.from(data);
29915
29916 if (key.length > blocksize) {
29917 key = fn(key);
29918 } else if (key.length < blocksize) {
29919 key = Buffer.concat([key, zeroBuffer], blocksize);
29920 }
29921
29922 var ipad = Buffer.alloc(blocksize),
29923 opad = Buffer.alloc(blocksize);
29924 for (var i = 0; i < blocksize; i++) {
29925 ipad[i] = key[i] ^ 0x36;
29926 opad[i] = key[i] ^ 0x5C;
29927 }
29928
29929 var hash = fn(Buffer.concat([ipad, data]));
29930 return fn(Buffer.concat([opad, hash]));
29931}
29932
29933function hash(alg, key) {
29934 alg = alg || 'sha1';
29935 var fn = algorithms[alg];
29936 var bufs = [];
29937 var length = 0;
29938 if (!fn) error('algorithm:', alg, 'is not yet supported');
29939 return {
29940 update: function update(data) {
29941 if (!Buffer.isBuffer(data)) data = Buffer.from(data);
29942
29943 bufs.push(data);
29944 length += data.length;
29945 return this;
29946 },
29947 digest: function digest(enc) {
29948 var buf = Buffer.concat(bufs);
29949 var r = key ? hmac(fn, key, buf) : fn(buf);
29950 bufs = null;
29951 return enc ? r.toString(enc) : r;
29952 }
29953 };
29954}
29955
29956function error() {
29957 var m = [].slice.call(arguments).join(' ');
29958 throw new Error([m, 'we accept pull requests', 'http://github.com/dominictarr/crypto-browserify'].join('\n'));
29959}
29960
29961exports.createHash = function (alg) {
29962 return hash(alg);
29963};
29964exports.createHmac = function (alg, key) {
29965 return hash(alg, key);
29966};
29967
29968function each(a, f) {
29969 for (var i in a) {
29970 f(a[i], i);
29971 }
29972}
29973
29974// the least I can do is make error messages for the rest of the node.js/crypto api.
29975each(['createCredentials', 'createCipher', 'createCipheriv', 'createDecipher', 'createDecipheriv', 'createSign', 'createVerify', 'createDiffieHellman', 'pbkdf2'], function (name) {
29976 exports[name] = function () {
29977 error('sorry,', name, 'is not implemented yet');
29978 };
29979});
29980
29981},{"./md5":320,"./sha":321,"./sha256":322,"buffer":60}],319:[function(require,module,exports){
29982'use strict';
29983
29984var Buffer = require('buffer').Buffer;
29985var intSize = 4;
29986var zeroBuffer = Buffer.alloc(intSize);zeroBuffer.fill(0);
29987var chrsz = 8;
29988
29989function toArray(buf, bigEndian) {
29990 if (buf.length % intSize !== 0) {
29991 var len = buf.length + (intSize - buf.length % intSize);
29992 buf = Buffer.concat([buf, zeroBuffer], len);
29993 }
29994
29995 var arr = [];
29996 var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
29997 for (var i = 0; i < buf.length; i += intSize) {
29998 arr.push(fn.call(buf, i));
29999 }
30000 return arr;
30001}
30002
30003function toBuffer(arr, size, bigEndian) {
30004 var buf = Buffer.alloc(size);
30005 var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
30006 for (var i = 0; i < arr.length; i++) {
30007 fn.call(buf, arr[i], i * 4, true);
30008 }
30009 return buf;
30010}
30011
30012function hash(buf, fn, hashSize, bigEndian) {
30013 if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
30014 var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
30015 return toBuffer(arr, hashSize, bigEndian);
30016}
30017
30018module.exports = { hash: hash };
30019
30020},{"buffer":60}],320:[function(require,module,exports){
30021"use strict";
30022
30023/*
30024 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
30025 * Digest Algorithm, as defined in RFC 1321.
30026 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
30027 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
30028 * Distributed under the BSD License
30029 * See http://pajhome.org.uk/crypt/md5 for more info.
30030 */
30031
30032var helpers = require('./helpers');
30033
30034/*
30035 * Perform a simple self-test to see if the VM is working
30036 */
30037function md5_vm_test() {
30038 return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
30039}
30040
30041/*
30042 * Calculate the MD5 of an array of little-endian words, and a bit length
30043 */
30044function core_md5(x, len) {
30045 /* append padding */
30046 x[len >> 5] |= 0x80 << len % 32;
30047 x[(len + 64 >>> 9 << 4) + 14] = len;
30048
30049 var a = 1732584193;
30050 var b = -271733879;
30051 var c = -1732584194;
30052 var d = 271733878;
30053
30054 for (var i = 0; i < x.length; i += 16) {
30055 var olda = a;
30056 var oldb = b;
30057 var oldc = c;
30058 var oldd = d;
30059
30060 a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
30061 d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
30062 c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
30063 b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
30064 a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
30065 d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
30066 c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
30067 b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
30068 a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
30069 d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
30070 c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
30071 b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
30072 a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
30073 d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
30074 c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
30075 b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
30076
30077 a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
30078 d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
30079 c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
30080 b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
30081 a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
30082 d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
30083 c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
30084 b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
30085 a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
30086 d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
30087 c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
30088 b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
30089 a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
30090 d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
30091 c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
30092 b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
30093
30094 a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
30095 d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
30096 c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
30097 b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
30098 a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
30099 d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
30100 c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
30101 b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
30102 a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
30103 d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
30104 c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
30105 b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
30106 a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
30107 d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
30108 c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
30109 b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
30110
30111 a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
30112 d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
30113 c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
30114 b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
30115 a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
30116 d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
30117 c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
30118 b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
30119 a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
30120 d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
30121 c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
30122 b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
30123 a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
30124 d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
30125 c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
30126 b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
30127
30128 a = safe_add(a, olda);
30129 b = safe_add(b, oldb);
30130 c = safe_add(c, oldc);
30131 d = safe_add(d, oldd);
30132 }
30133 return Array(a, b, c, d);
30134}
30135
30136/*
30137 * These functions implement the four basic operations the algorithm uses.
30138 */
30139function md5_cmn(q, a, b, x, s, t) {
30140 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
30141}
30142function md5_ff(a, b, c, d, x, s, t) {
30143 return md5_cmn(b & c | ~b & d, a, b, x, s, t);
30144}
30145function md5_gg(a, b, c, d, x, s, t) {
30146 return md5_cmn(b & d | c & ~d, a, b, x, s, t);
30147}
30148function md5_hh(a, b, c, d, x, s, t) {
30149 return md5_cmn(b ^ c ^ d, a, b, x, s, t);
30150}
30151function md5_ii(a, b, c, d, x, s, t) {
30152 return md5_cmn(c ^ (b | ~d), a, b, x, s, t);
30153}
30154
30155/*
30156 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
30157 * to work around bugs in some JS interpreters.
30158 */
30159function safe_add(x, y) {
30160 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
30161 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
30162 return msw << 16 | lsw & 0xFFFF;
30163}
30164
30165/*
30166 * Bitwise rotate a 32-bit number to the left.
30167 */
30168function bit_rol(num, cnt) {
30169 return num << cnt | num >>> 32 - cnt;
30170}
30171
30172module.exports = function md5(buf) {
30173 return helpers.hash(buf, core_md5, 16);
30174};
30175
30176},{"./helpers":319}],321:[function(require,module,exports){
30177'use strict';
30178
30179/*
30180 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
30181 * in FIPS PUB 180-1
30182 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
30183 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
30184 * Distributed under the BSD License
30185 * See http://pajhome.org.uk/crypt/md5 for details.
30186 */
30187
30188var helpers = require('./helpers');
30189
30190/*
30191 * Calculate the SHA-1 of an array of big-endian words, and a bit length
30192 */
30193function core_sha1(x, len) {
30194 /* append padding */
30195 x[len >> 5] |= 0x80 << 24 - len % 32;
30196 x[(len + 64 >> 9 << 4) + 15] = len;
30197
30198 var w = Array(80);
30199 var a = 1732584193;
30200 var b = -271733879;
30201 var c = -1732584194;
30202 var d = 271733878;
30203 var e = -1009589776;
30204
30205 for (var i = 0; i < x.length; i += 16) {
30206 var olda = a;
30207 var oldb = b;
30208 var oldc = c;
30209 var oldd = d;
30210 var olde = e;
30211
30212 for (var j = 0; j < 80; j++) {
30213 if (j < 16) w[j] = x[i + j];else w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
30214 var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j)));
30215 e = d;
30216 d = c;
30217 c = rol(b, 30);
30218 b = a;
30219 a = t;
30220 }
30221
30222 a = safe_add(a, olda);
30223 b = safe_add(b, oldb);
30224 c = safe_add(c, oldc);
30225 d = safe_add(d, oldd);
30226 e = safe_add(e, olde);
30227 }
30228 return Array(a, b, c, d, e);
30229}
30230
30231/*
30232 * Perform the appropriate triplet combination function for the current
30233 * iteration
30234 */
30235function sha1_ft(t, b, c, d) {
30236 if (t < 20) return b & c | ~b & d;
30237 if (t < 40) return b ^ c ^ d;
30238 if (t < 60) return b & c | b & d | c & d;
30239 return b ^ c ^ d;
30240}
30241
30242/*
30243 * Determine the appropriate additive constant for the current iteration
30244 */
30245function sha1_kt(t) {
30246 return t < 20 ? 1518500249 : t < 40 ? 1859775393 : t < 60 ? -1894007588 : -899497514;
30247}
30248
30249/*
30250 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
30251 * to work around bugs in some JS interpreters.
30252 */
30253function safe_add(x, y) {
30254 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
30255 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
30256 return msw << 16 | lsw & 0xFFFF;
30257}
30258
30259/*
30260 * Bitwise rotate a 32-bit number to the left.
30261 */
30262function rol(num, cnt) {
30263 return num << cnt | num >>> 32 - cnt;
30264}
30265
30266module.exports = function sha1(buf) {
30267 return helpers.hash(buf, core_sha1, 20, true);
30268};
30269
30270},{"./helpers":319}],322:[function(require,module,exports){
30271'use strict';
30272
30273/**
30274 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
30275 * in FIPS 180-2
30276 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
30277 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
30278 *
30279 */
30280
30281var helpers = require('./helpers');
30282
30283var safe_add = function safe_add(x, y) {
30284 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
30285 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
30286 return msw << 16 | lsw & 0xFFFF;
30287};
30288
30289var S = function S(X, n) {
30290 return X >>> n | X << 32 - n;
30291};
30292
30293var R = function R(X, n) {
30294 return X >>> n;
30295};
30296
30297var Ch = function Ch(x, y, z) {
30298 return x & y ^ ~x & z;
30299};
30300
30301var Maj = function Maj(x, y, z) {
30302 return x & y ^ x & z ^ y & z;
30303};
30304
30305var Sigma0256 = function Sigma0256(x) {
30306 return S(x, 2) ^ S(x, 13) ^ S(x, 22);
30307};
30308
30309var Sigma1256 = function Sigma1256(x) {
30310 return S(x, 6) ^ S(x, 11) ^ S(x, 25);
30311};
30312
30313var Gamma0256 = function Gamma0256(x) {
30314 return S(x, 7) ^ S(x, 18) ^ R(x, 3);
30315};
30316
30317var Gamma1256 = function Gamma1256(x) {
30318 return S(x, 17) ^ S(x, 19) ^ R(x, 10);
30319};
30320
30321var core_sha256 = function core_sha256(m, l) {
30322 var K = new Array(0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 0xFC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x6CA6351, 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);
30323 var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19);
30324 var W = new Array(64);
30325 var a, b, c, d, e, f, g, h, i, j;
30326 var T1, T2;
30327 /* append padding */
30328 m[l >> 5] |= 0x80 << 24 - l % 32;
30329 m[(l + 64 >> 9 << 4) + 15] = l;
30330 for (var i = 0; i < m.length; i += 16) {
30331 a = HASH[0];b = HASH[1];c = HASH[2];d = HASH[3];e = HASH[4];f = HASH[5];g = HASH[6];h = HASH[7];
30332 for (var j = 0; j < 64; j++) {
30333 if (j < 16) {
30334 W[j] = m[j + i];
30335 } else {
30336 W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]);
30337 }
30338 T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]);
30339 T2 = safe_add(Sigma0256(a), Maj(a, b, c));
30340 h = g;g = f;f = e;e = safe_add(d, T1);d = c;c = b;b = a;a = safe_add(T1, T2);
30341 }
30342 HASH[0] = safe_add(a, HASH[0]);HASH[1] = safe_add(b, HASH[1]);HASH[2] = safe_add(c, HASH[2]);HASH[3] = safe_add(d, HASH[3]);
30343 HASH[4] = safe_add(e, HASH[4]);HASH[5] = safe_add(f, HASH[5]);HASH[6] = safe_add(g, HASH[6]);HASH[7] = safe_add(h, HASH[7]);
30344 }
30345 return HASH;
30346};
30347
30348module.exports = function sha256(buf) {
30349 return helpers.hash(buf, core_sha256, 32, true);
30350};
30351
30352},{"./helpers":319}],323:[function(require,module,exports){
30353(function (global){
30354"use strict";
30355
30356var _create = require("babel-runtime/core-js/object/create");
30357
30358var _create2 = _interopRequireDefault(_create);
30359
30360var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
30361
30362var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
30363
30364var _createClass2 = require("babel-runtime/helpers/createClass");
30365
30366var _createClass3 = _interopRequireDefault(_createClass2);
30367
30368var _typeof2 = require("babel-runtime/helpers/typeof");
30369
30370var _typeof3 = _interopRequireDefault(_typeof2);
30371
30372function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30373
30374(function (f) {
30375 if ((typeof exports === "undefined" ? "undefined" : (0, _typeof3.default)(exports)) === "object" && typeof module !== "undefined") {
30376 module.exports = f();
30377 } else if (typeof define === "function" && define.amd) {
30378 define([], f);
30379 } else {
30380 var g;if (typeof window !== "undefined") {
30381 g = window;
30382 } else if (typeof global !== "undefined") {
30383 g = global;
30384 } else if (typeof self !== "undefined") {
30385 g = self;
30386 } else {
30387 g = this;
30388 }g.mime = f();
30389 }
30390})(function () {
30391 var define, module, exports;return function e(t, n, r) {
30392 function s(o, u) {
30393 if (!n[o]) {
30394 if (!t[o]) {
30395 var a = typeof require == "function" && require;if (!u && a) return a(o, !0);if (i) return i(o, !0);var f = new Error("Cannot find module '" + o + "'");throw f.code = "MODULE_NOT_FOUND", f;
30396 }var l = n[o] = { exports: {} };t[o][0].call(l.exports, function (e) {
30397 var n = t[o][1][e];return s(n ? n : e);
30398 }, l, l.exports, e, t, n, r);
30399 }return n[o].exports;
30400 }var i = typeof require == "function" && require;for (var o = 0; o < r.length; o++) {
30401 s(r[o]);
30402 }return s;
30403 }({ 1: [function (require, module, exports) {
30404 'use strict';
30405
30406 /**
30407 * @param typeMap [Object] Map of MIME type -> Array[extensions]
30408 * @param ...
30409 */
30410
30411 var Mime = function () {
30412 function Mime() {
30413 (0, _classCallCheck3.default)(this, Mime);
30414
30415 this._types = (0, _create2.default)(null);
30416 this._extensions = (0, _create2.default)(null);
30417
30418 for (var i = 0; i < arguments.length; i++) {
30419 this.define(arguments[i]);
30420 }
30421 }
30422
30423 /**
30424 * Define mimetype -> xtension mappings. Each key is a mime-type that maps
30425 * to an array of extensions associated with the type. The first extension is
30426 * used as the default extension for the type.
30427 *
30428 * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
30429 *
30430 * @param map (Object) type definitions
30431 */
30432
30433
30434 (0, _createClass3.default)(Mime, [{
30435 key: "define",
30436 value: function define(typeMap, force) {
30437 for (var type in typeMap) {
30438 var extensions = typeMap[type];
30439 for (var i = 0; i < extensions.length; i++) {
30440 var ext = extensions[i];
30441 if (!force && ext in this._types) {
30442 throw new Error("Attempt to change mapping for \"" + ext + "\" extension from \"" + this._types[ext] + "\" to \"" + type + "\". Pass `force=true` to allow this, otherwise remove \"" + ext + "\" from the list of extensions for \"" + type + "\".");
30443 }
30444
30445 this._types[ext] = type;
30446 }
30447
30448 // Use first extension as default
30449 if (force || !this._extensions[type]) {
30450 this._extensions[type] = extensions[0];
30451 }
30452 }
30453 }
30454
30455 /**
30456 * Lookup a mime type based on extension
30457 */
30458
30459 }, {
30460 key: "getType",
30461 value: function getType(path) {
30462 path = String(path);
30463 var last = path.replace(/^.*[/\\]/, '').toLowerCase();
30464 var ext = last.replace(/^.*\./, '').toLowerCase();
30465
30466 var hasPath = last.length < path.length;
30467 var hasDot = ext.length < last.length - 1;
30468
30469 return (hasDot || !hasPath) && this._types[ext] || null;
30470 }
30471
30472 /**
30473 * Return file extension associated with a mime type
30474 */
30475
30476 }, {
30477 key: "getExtension",
30478 value: function getExtension(type) {
30479 type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
30480 return type && this._extensions[type.toLowerCase()] || null;
30481 }
30482 }]);
30483 return Mime;
30484 }();
30485
30486 module.exports = Mime;
30487 }, {}], 2: [function (r, module, exports) {
30488 'use strict';
30489
30490 var Mime = r('./Mime');
30491 module.exports = new Mime(r('./types/standard'), r('./types/other'));
30492 }, { "./Mime": 1, "./types/other": 3, "./types/standard": 4 }], 3: [function (require, module, exports) {
30493 module.exports = { "application/prs.cww": ["cww"], "application/vnd.3gpp.pic-bw-large": ["plb"], "application/vnd.3gpp.pic-bw-small": ["psb"], "application/vnd.3gpp.pic-bw-var": ["pvb"], "application/vnd.3gpp2.tcap": ["tcap"], "application/vnd.3m.post-it-notes": ["pwn"], "application/vnd.accpac.simply.aso": ["aso"], "application/vnd.accpac.simply.imp": ["imp"], "application/vnd.acucobol": ["acu"], "application/vnd.acucorp": ["atc", "acutc"], "application/vnd.adobe.air-application-installer-package+zip": ["air"], "application/vnd.adobe.formscentral.fcdt": ["fcdt"], "application/vnd.adobe.fxp": ["fxp", "fxpl"], "application/vnd.adobe.xdp+xml": ["xdp"], "application/vnd.adobe.xfdf": ["xfdf"], "application/vnd.ahead.space": ["ahead"], "application/vnd.airzip.filesecure.azf": ["azf"], "application/vnd.airzip.filesecure.azs": ["azs"], "application/vnd.amazon.ebook": ["azw"], "application/vnd.americandynamics.acc": ["acc"], "application/vnd.amiga.ami": ["ami"], "application/vnd.android.package-archive": ["apk"], "application/vnd.anser-web-certificate-issue-initiation": ["cii"], "application/vnd.anser-web-funds-transfer-initiation": ["fti"], "application/vnd.antix.game-component": ["atx"], "application/vnd.apple.installer+xml": ["mpkg"], "application/vnd.apple.mpegurl": ["m3u8"], "application/vnd.apple.pkpass": ["pkpass"], "application/vnd.aristanetworks.swi": ["swi"], "application/vnd.astraea-software.iota": ["iota"], "application/vnd.audiograph": ["aep"], "application/vnd.blueice.multipass": ["mpm"], "application/vnd.bmi": ["bmi"], "application/vnd.businessobjects": ["rep"], "application/vnd.chemdraw+xml": ["cdxml"], "application/vnd.chipnuts.karaoke-mmd": ["mmd"], "application/vnd.cinderella": ["cdy"], "application/vnd.claymore": ["cla"], "application/vnd.cloanto.rp9": ["rp9"], "application/vnd.clonk.c4group": ["c4g", "c4d", "c4f", "c4p", "c4u"], "application/vnd.cluetrust.cartomobile-config": ["c11amc"], "application/vnd.cluetrust.cartomobile-config-pkg": ["c11amz"], "application/vnd.commonspace": ["csp"], "application/vnd.contact.cmsg": ["cdbcmsg"], "application/vnd.cosmocaller": ["cmc"], "application/vnd.crick.clicker": ["clkx"], "application/vnd.crick.clicker.keyboard": ["clkk"], "application/vnd.crick.clicker.palette": ["clkp"], "application/vnd.crick.clicker.template": ["clkt"], "application/vnd.crick.clicker.wordbank": ["clkw"], "application/vnd.criticaltools.wbs+xml": ["wbs"], "application/vnd.ctc-posml": ["pml"], "application/vnd.cups-ppd": ["ppd"], "application/vnd.curl.car": ["car"], "application/vnd.curl.pcurl": ["pcurl"], "application/vnd.dart": ["dart"], "application/vnd.data-vision.rdz": ["rdz"], "application/vnd.dece.data": ["uvf", "uvvf", "uvd", "uvvd"], "application/vnd.dece.ttml+xml": ["uvt", "uvvt"], "application/vnd.dece.unspecified": ["uvx", "uvvx"], "application/vnd.dece.zip": ["uvz", "uvvz"], "application/vnd.denovo.fcselayout-link": ["fe_launch"], "application/vnd.dna": ["dna"], "application/vnd.dolby.mlp": ["mlp"], "application/vnd.dpgraph": ["dpg"], "application/vnd.dreamfactory": ["dfac"], "application/vnd.ds-keypoint": ["kpxx"], "application/vnd.dvb.ait": ["ait"], "application/vnd.dvb.service": ["svc"], "application/vnd.dynageo": ["geo"], "application/vnd.ecowin.chart": ["mag"], "application/vnd.enliven": ["nml"], "application/vnd.epson.esf": ["esf"], "application/vnd.epson.msf": ["msf"], "application/vnd.epson.quickanime": ["qam"], "application/vnd.epson.salt": ["slt"], "application/vnd.epson.ssf": ["ssf"], "application/vnd.eszigno3+xml": ["es3", "et3"], "application/vnd.ezpix-album": ["ez2"], "application/vnd.ezpix-package": ["ez3"], "application/vnd.fdf": ["fdf"], "application/vnd.fdsn.mseed": ["mseed"], "application/vnd.fdsn.seed": ["seed", "dataless"], "application/vnd.flographit": ["gph"], "application/vnd.fluxtime.clip": ["ftc"], "application/vnd.framemaker": ["fm", "frame", "maker", "book"], "application/vnd.frogans.fnc": ["fnc"], "application/vnd.frogans.ltf": ["ltf"], "application/vnd.fsc.weblaunch": ["fsc"], "application/vnd.fujitsu.oasys": ["oas"], "application/vnd.fujitsu.oasys2": ["oa2"], "application/vnd.fujitsu.oasys3": ["oa3"], "application/vnd.fujitsu.oasysgp": ["fg5"], "application/vnd.fujitsu.oasysprs": ["bh2"], "application/vnd.fujixerox.ddd": ["ddd"], "application/vnd.fujixerox.docuworks": ["xdw"], "application/vnd.fujixerox.docuworks.binder": ["xbd"], "application/vnd.fuzzysheet": ["fzs"], "application/vnd.genomatix.tuxedo": ["txd"], "application/vnd.geogebra.file": ["ggb"], "application/vnd.geogebra.tool": ["ggt"], "application/vnd.geometry-explorer": ["gex", "gre"], "application/vnd.geonext": ["gxt"], "application/vnd.geoplan": ["g2w"], "application/vnd.geospace": ["g3w"], "application/vnd.gmx": ["gmx"], "application/vnd.google-apps.document": ["gdoc"], "application/vnd.google-apps.presentation": ["gslides"], "application/vnd.google-apps.spreadsheet": ["gsheet"], "application/vnd.google-earth.kml+xml": ["kml"], "application/vnd.google-earth.kmz": ["kmz"], "application/vnd.grafeq": ["gqf", "gqs"], "application/vnd.groove-account": ["gac"], "application/vnd.groove-help": ["ghf"], "application/vnd.groove-identity-message": ["gim"], "application/vnd.groove-injector": ["grv"], "application/vnd.groove-tool-message": ["gtm"], "application/vnd.groove-tool-template": ["tpl"], "application/vnd.groove-vcard": ["vcg"], "application/vnd.hal+xml": ["hal"], "application/vnd.handheld-entertainment+xml": ["zmm"], "application/vnd.hbci": ["hbci"], "application/vnd.hhe.lesson-player": ["les"], "application/vnd.hp-hpgl": ["hpgl"], "application/vnd.hp-hpid": ["hpid"], "application/vnd.hp-hps": ["hps"], "application/vnd.hp-jlyt": ["jlt"], "application/vnd.hp-pcl": ["pcl"], "application/vnd.hp-pclxl": ["pclxl"], "application/vnd.hydrostatix.sof-data": ["sfd-hdstx"], "application/vnd.ibm.minipay": ["mpy"], "application/vnd.ibm.modcap": ["afp", "listafp", "list3820"], "application/vnd.ibm.rights-management": ["irm"], "application/vnd.ibm.secure-container": ["sc"], "application/vnd.iccprofile": ["icc", "icm"], "application/vnd.igloader": ["igl"], "application/vnd.immervision-ivp": ["ivp"], "application/vnd.immervision-ivu": ["ivu"], "application/vnd.insors.igm": ["igm"], "application/vnd.intercon.formnet": ["xpw", "xpx"], "application/vnd.intergeo": ["i2g"], "application/vnd.intu.qbo": ["qbo"], "application/vnd.intu.qfx": ["qfx"], "application/vnd.ipunplugged.rcprofile": ["rcprofile"], "application/vnd.irepository.package+xml": ["irp"], "application/vnd.is-xpr": ["xpr"], "application/vnd.isac.fcs": ["fcs"], "application/vnd.jam": ["jam"], "application/vnd.jcp.javame.midlet-rms": ["rms"], "application/vnd.jisp": ["jisp"], "application/vnd.joost.joda-archive": ["joda"], "application/vnd.kahootz": ["ktz", "ktr"], "application/vnd.kde.karbon": ["karbon"], "application/vnd.kde.kchart": ["chrt"], "application/vnd.kde.kformula": ["kfo"], "application/vnd.kde.kivio": ["flw"], "application/vnd.kde.kontour": ["kon"], "application/vnd.kde.kpresenter": ["kpr", "kpt"], "application/vnd.kde.kspread": ["ksp"], "application/vnd.kde.kword": ["kwd", "kwt"], "application/vnd.kenameaapp": ["htke"], "application/vnd.kidspiration": ["kia"], "application/vnd.kinar": ["kne", "knp"], "application/vnd.koan": ["skp", "skd", "skt", "skm"], "application/vnd.kodak-descriptor": ["sse"], "application/vnd.las.las+xml": ["lasxml"], "application/vnd.llamagraphics.life-balance.desktop": ["lbd"], "application/vnd.llamagraphics.life-balance.exchange+xml": ["lbe"], "application/vnd.lotus-1-2-3": ["123"], "application/vnd.lotus-approach": ["apr"], "application/vnd.lotus-freelance": ["pre"], "application/vnd.lotus-notes": ["nsf"], "application/vnd.lotus-organizer": ["org"], "application/vnd.lotus-screencam": ["scm"], "application/vnd.lotus-wordpro": ["lwp"], "application/vnd.macports.portpkg": ["portpkg"], "application/vnd.mcd": ["mcd"], "application/vnd.medcalcdata": ["mc1"], "application/vnd.mediastation.cdkey": ["cdkey"], "application/vnd.mfer": ["mwf"], "application/vnd.mfmp": ["mfm"], "application/vnd.micrografx.flo": ["flo"], "application/vnd.micrografx.igx": ["igx"], "application/vnd.mif": ["mif"], "application/vnd.mobius.daf": ["daf"], "application/vnd.mobius.dis": ["dis"], "application/vnd.mobius.mbk": ["mbk"], "application/vnd.mobius.mqy": ["mqy"], "application/vnd.mobius.msl": ["msl"], "application/vnd.mobius.plc": ["plc"], "application/vnd.mobius.txf": ["txf"], "application/vnd.mophun.application": ["mpn"], "application/vnd.mophun.certificate": ["mpc"], "application/vnd.mozilla.xul+xml": ["xul"], "application/vnd.ms-artgalry": ["cil"], "application/vnd.ms-cab-compressed": ["cab"], "application/vnd.ms-excel": ["xls", "xlm", "xla", "xlc", "xlt", "xlw"], "application/vnd.ms-excel.addin.macroenabled.12": ["xlam"], "application/vnd.ms-excel.sheet.binary.macroenabled.12": ["xlsb"], "application/vnd.ms-excel.sheet.macroenabled.12": ["xlsm"], "application/vnd.ms-excel.template.macroenabled.12": ["xltm"], "application/vnd.ms-fontobject": ["eot"], "application/vnd.ms-htmlhelp": ["chm"], "application/vnd.ms-ims": ["ims"], "application/vnd.ms-lrm": ["lrm"], "application/vnd.ms-officetheme": ["thmx"], "application/vnd.ms-outlook": ["msg"], "application/vnd.ms-pki.seccat": ["cat"], "application/vnd.ms-pki.stl": ["stl"], "application/vnd.ms-powerpoint": ["ppt", "pps", "pot"], "application/vnd.ms-powerpoint.addin.macroenabled.12": ["ppam"], "application/vnd.ms-powerpoint.presentation.macroenabled.12": ["pptm"], "application/vnd.ms-powerpoint.slide.macroenabled.12": ["sldm"], "application/vnd.ms-powerpoint.slideshow.macroenabled.12": ["ppsm"], "application/vnd.ms-powerpoint.template.macroenabled.12": ["potm"], "application/vnd.ms-project": ["mpp", "mpt"], "application/vnd.ms-word.document.macroenabled.12": ["docm"], "application/vnd.ms-word.template.macroenabled.12": ["dotm"], "application/vnd.ms-works": ["wps", "wks", "wcm", "wdb"], "application/vnd.ms-wpl": ["wpl"], "application/vnd.ms-xpsdocument": ["xps"], "application/vnd.mseq": ["mseq"], "application/vnd.musician": ["mus"], "application/vnd.muvee.style": ["msty"], "application/vnd.mynfc": ["taglet"], "application/vnd.neurolanguage.nlu": ["nlu"], "application/vnd.nitf": ["ntf", "nitf"], "application/vnd.noblenet-directory": ["nnd"], "application/vnd.noblenet-sealer": ["nns"], "application/vnd.noblenet-web": ["nnw"], "application/vnd.nokia.n-gage.data": ["ngdat"], "application/vnd.nokia.n-gage.symbian.install": ["n-gage"], "application/vnd.nokia.radio-preset": ["rpst"], "application/vnd.nokia.radio-presets": ["rpss"], "application/vnd.novadigm.edm": ["edm"], "application/vnd.novadigm.edx": ["edx"], "application/vnd.novadigm.ext": ["ext"], "application/vnd.oasis.opendocument.chart": ["odc"], "application/vnd.oasis.opendocument.chart-template": ["otc"], "application/vnd.oasis.opendocument.database": ["odb"], "application/vnd.oasis.opendocument.formula": ["odf"], "application/vnd.oasis.opendocument.formula-template": ["odft"], "application/vnd.oasis.opendocument.graphics": ["odg"], "application/vnd.oasis.opendocument.graphics-template": ["otg"], "application/vnd.oasis.opendocument.image": ["odi"], "application/vnd.oasis.opendocument.image-template": ["oti"], "application/vnd.oasis.opendocument.presentation": ["odp"], "application/vnd.oasis.opendocument.presentation-template": ["otp"], "application/vnd.oasis.opendocument.spreadsheet": ["ods"], "application/vnd.oasis.opendocument.spreadsheet-template": ["ots"], "application/vnd.oasis.opendocument.text": ["odt"], "application/vnd.oasis.opendocument.text-master": ["odm"], "application/vnd.oasis.opendocument.text-template": ["ott"], "application/vnd.oasis.opendocument.text-web": ["oth"], "application/vnd.olpc-sugar": ["xo"], "application/vnd.oma.dd2+xml": ["dd2"], "application/vnd.openofficeorg.extension": ["oxt"], "application/vnd.openxmlformats-officedocument.presentationml.presentation": ["pptx"], "application/vnd.openxmlformats-officedocument.presentationml.slide": ["sldx"], "application/vnd.openxmlformats-officedocument.presentationml.slideshow": ["ppsx"], "application/vnd.openxmlformats-officedocument.presentationml.template": ["potx"], "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ["xlsx"], "application/vnd.openxmlformats-officedocument.spreadsheetml.template": ["xltx"], "application/vnd.openxmlformats-officedocument.wordprocessingml.document": ["docx"], "application/vnd.openxmlformats-officedocument.wordprocessingml.template": ["dotx"], "application/vnd.osgeo.mapguide.package": ["mgp"], "application/vnd.osgi.dp": ["dp"], "application/vnd.osgi.subsystem": ["esa"], "application/vnd.palm": ["pdb", "pqa", "oprc"], "application/vnd.pawaafile": ["paw"], "application/vnd.pg.format": ["str"], "application/vnd.pg.osasli": ["ei6"], "application/vnd.picsel": ["efif"], "application/vnd.pmi.widget": ["wg"], "application/vnd.pocketlearn": ["plf"], "application/vnd.powerbuilder6": ["pbd"], "application/vnd.previewsystems.box": ["box"], "application/vnd.proteus.magazine": ["mgz"], "application/vnd.publishare-delta-tree": ["qps"], "application/vnd.pvi.ptid1": ["ptid"], "application/vnd.quark.quarkxpress": ["qxd", "qxt", "qwd", "qwt", "qxl", "qxb"], "application/vnd.realvnc.bed": ["bed"], "application/vnd.recordare.musicxml": ["mxl"], "application/vnd.recordare.musicxml+xml": ["musicxml"], "application/vnd.rig.cryptonote": ["cryptonote"], "application/vnd.rim.cod": ["cod"], "application/vnd.rn-realmedia": ["rm"], "application/vnd.rn-realmedia-vbr": ["rmvb"], "application/vnd.route66.link66+xml": ["link66"], "application/vnd.sailingtracker.track": ["st"], "application/vnd.seemail": ["see"], "application/vnd.sema": ["sema"], "application/vnd.semd": ["semd"], "application/vnd.semf": ["semf"], "application/vnd.shana.informed.formdata": ["ifm"], "application/vnd.shana.informed.formtemplate": ["itp"], "application/vnd.shana.informed.interchange": ["iif"], "application/vnd.shana.informed.package": ["ipk"], "application/vnd.simtech-mindmapper": ["twd", "twds"], "application/vnd.smaf": ["mmf"], "application/vnd.smart.teacher": ["teacher"], "application/vnd.solent.sdkm+xml": ["sdkm", "sdkd"], "application/vnd.spotfire.dxp": ["dxp"], "application/vnd.spotfire.sfs": ["sfs"], "application/vnd.stardivision.calc": ["sdc"], "application/vnd.stardivision.draw": ["sda"], "application/vnd.stardivision.impress": ["sdd"], "application/vnd.stardivision.math": ["smf"], "application/vnd.stardivision.writer": ["sdw", "vor"], "application/vnd.stardivision.writer-global": ["sgl"], "application/vnd.stepmania.package": ["smzip"], "application/vnd.stepmania.stepchart": ["sm"], "application/vnd.sun.wadl+xml": ["wadl"], "application/vnd.sun.xml.calc": ["sxc"], "application/vnd.sun.xml.calc.template": ["stc"], "application/vnd.sun.xml.draw": ["sxd"], "application/vnd.sun.xml.draw.template": ["std"], "application/vnd.sun.xml.impress": ["sxi"], "application/vnd.sun.xml.impress.template": ["sti"], "application/vnd.sun.xml.math": ["sxm"], "application/vnd.sun.xml.writer": ["sxw"], "application/vnd.sun.xml.writer.global": ["sxg"], "application/vnd.sun.xml.writer.template": ["stw"], "application/vnd.sus-calendar": ["sus", "susp"], "application/vnd.svd": ["svd"], "application/vnd.symbian.install": ["sis", "sisx"], "application/vnd.syncml+xml": ["xsm"], "application/vnd.syncml.dm+wbxml": ["bdm"], "application/vnd.syncml.dm+xml": ["xdm"], "application/vnd.tao.intent-module-archive": ["tao"], "application/vnd.tcpdump.pcap": ["pcap", "cap", "dmp"], "application/vnd.tmobile-livetv": ["tmo"], "application/vnd.trid.tpt": ["tpt"], "application/vnd.triscape.mxs": ["mxs"], "application/vnd.trueapp": ["tra"], "application/vnd.ufdl": ["ufd", "ufdl"], "application/vnd.uiq.theme": ["utz"], "application/vnd.umajin": ["umj"], "application/vnd.unity": ["unityweb"], "application/vnd.uoml+xml": ["uoml"], "application/vnd.vcx": ["vcx"], "application/vnd.visio": ["vsd", "vst", "vss", "vsw"], "application/vnd.visionary": ["vis"], "application/vnd.vsf": ["vsf"], "application/vnd.wap.wbxml": ["wbxml"], "application/vnd.wap.wmlc": ["wmlc"], "application/vnd.wap.wmlscriptc": ["wmlsc"], "application/vnd.webturbo": ["wtb"], "application/vnd.wolfram.player": ["nbp"], "application/vnd.wordperfect": ["wpd"], "application/vnd.wqd": ["wqd"], "application/vnd.wt.stf": ["stf"], "application/vnd.xara": ["xar"], "application/vnd.xfdl": ["xfdl"], "application/vnd.yamaha.hv-dic": ["hvd"], "application/vnd.yamaha.hv-script": ["hvs"], "application/vnd.yamaha.hv-voice": ["hvp"], "application/vnd.yamaha.openscoreformat": ["osf"], "application/vnd.yamaha.openscoreformat.osfpvg+xml": ["osfpvg"], "application/vnd.yamaha.smaf-audio": ["saf"], "application/vnd.yamaha.smaf-phrase": ["spf"], "application/vnd.yellowriver-custom-menu": ["cmp"], "application/vnd.zul": ["zir", "zirz"], "application/vnd.zzazz.deck+xml": ["zaz"], "application/x-7z-compressed": ["7z"], "application/x-abiword": ["abw"], "application/x-ace-compressed": ["ace"], "application/x-apple-diskimage": [], "application/x-arj": ["arj"], "application/x-authorware-bin": ["aab", "x32", "u32", "vox"], "application/x-authorware-map": ["aam"], "application/x-authorware-seg": ["aas"], "application/x-bcpio": ["bcpio"], "application/x-bdoc": [], "application/x-bittorrent": ["torrent"], "application/x-blorb": ["blb", "blorb"], "application/x-bzip": ["bz"], "application/x-bzip2": ["bz2", "boz"], "application/x-cbr": ["cbr", "cba", "cbt", "cbz", "cb7"], "application/x-cdlink": ["vcd"], "application/x-cfs-compressed": ["cfs"], "application/x-chat": ["chat"], "application/x-chess-pgn": ["pgn"], "application/x-chrome-extension": ["crx"], "application/x-cocoa": ["cco"], "application/x-conference": ["nsc"], "application/x-cpio": ["cpio"], "application/x-csh": ["csh"], "application/x-debian-package": ["udeb"], "application/x-dgc-compressed": ["dgc"], "application/x-director": ["dir", "dcr", "dxr", "cst", "cct", "cxt", "w3d", "fgd", "swa"], "application/x-doom": ["wad"], "application/x-dtbncx+xml": ["ncx"], "application/x-dtbook+xml": ["dtb"], "application/x-dtbresource+xml": ["res"], "application/x-dvi": ["dvi"], "application/x-envoy": ["evy"], "application/x-eva": ["eva"], "application/x-font-bdf": ["bdf"], "application/x-font-ghostscript": ["gsf"], "application/x-font-linux-psf": ["psf"], "application/x-font-otf": [], "application/x-font-pcf": ["pcf"], "application/x-font-snf": ["snf"], "application/x-font-ttf": ["ttf", "ttc"], "application/x-font-type1": ["pfa", "pfb", "pfm", "afm"], "application/x-freearc": ["arc"], "application/x-futuresplash": ["spl"], "application/x-gca-compressed": ["gca"], "application/x-glulx": ["ulx"], "application/x-gnumeric": ["gnumeric"], "application/x-gramps-xml": ["gramps"], "application/x-gtar": ["gtar"], "application/x-hdf": ["hdf"], "application/x-httpd-php": ["php"], "application/x-install-instructions": ["install"], "application/x-iso9660-image": [], "application/x-java-archive-diff": ["jardiff"], "application/x-java-jnlp-file": ["jnlp"], "application/x-latex": ["latex"], "application/x-lua-bytecode": ["luac"], "application/x-lzh-compressed": ["lzh", "lha"], "application/x-makeself": ["run"], "application/x-mie": ["mie"], "application/x-mobipocket-ebook": ["prc", "mobi"], "application/x-ms-application": ["application"], "application/x-ms-shortcut": ["lnk"], "application/x-ms-wmd": ["wmd"], "application/x-ms-wmz": ["wmz"], "application/x-ms-xbap": ["xbap"], "application/x-msaccess": ["mdb"], "application/x-msbinder": ["obd"], "application/x-mscardfile": ["crd"], "application/x-msclip": ["clp"], "application/x-msdos-program": [], "application/x-msdownload": ["com", "bat"], "application/x-msmediaview": ["mvb", "m13", "m14"], "application/x-msmetafile": ["wmf", "emf", "emz"], "application/x-msmoney": ["mny"], "application/x-mspublisher": ["pub"], "application/x-msschedule": ["scd"], "application/x-msterminal": ["trm"], "application/x-mswrite": ["wri"], "application/x-netcdf": ["nc", "cdf"], "application/x-ns-proxy-autoconfig": ["pac"], "application/x-nzb": ["nzb"], "application/x-perl": ["pl", "pm"], "application/x-pilot": [], "application/x-pkcs12": ["p12", "pfx"], "application/x-pkcs7-certificates": ["p7b", "spc"], "application/x-pkcs7-certreqresp": ["p7r"], "application/x-rar-compressed": ["rar"], "application/x-redhat-package-manager": ["rpm"], "application/x-research-info-systems": ["ris"], "application/x-sea": ["sea"], "application/x-sh": ["sh"], "application/x-shar": ["shar"], "application/x-shockwave-flash": ["swf"], "application/x-silverlight-app": ["xap"], "application/x-sql": ["sql"], "application/x-stuffit": ["sit"], "application/x-stuffitx": ["sitx"], "application/x-subrip": ["srt"], "application/x-sv4cpio": ["sv4cpio"], "application/x-sv4crc": ["sv4crc"], "application/x-t3vm-image": ["t3"], "application/x-tads": ["gam"], "application/x-tar": ["tar"], "application/x-tcl": ["tcl", "tk"], "application/x-tex": ["tex"], "application/x-tex-tfm": ["tfm"], "application/x-texinfo": ["texinfo", "texi"], "application/x-tgif": ["obj"], "application/x-ustar": ["ustar"], "application/x-virtualbox-hdd": ["hdd"], "application/x-virtualbox-ova": ["ova"], "application/x-virtualbox-ovf": ["ovf"], "application/x-virtualbox-vbox": ["vbox"], "application/x-virtualbox-vbox-extpack": ["vbox-extpack"], "application/x-virtualbox-vdi": ["vdi"], "application/x-virtualbox-vhd": ["vhd"], "application/x-virtualbox-vmdk": ["vmdk"], "application/x-wais-source": ["src"], "application/x-web-app-manifest+json": ["webapp"], "application/x-x509-ca-cert": ["der", "crt", "pem"], "application/x-xfig": ["fig"], "application/x-xliff+xml": ["xlf"], "application/x-xpinstall": ["xpi"], "application/x-xz": ["xz"], "application/x-zmachine": ["z1", "z2", "z3", "z4", "z5", "z6", "z7", "z8"], "audio/vnd.dece.audio": ["uva", "uvva"], "audio/vnd.digital-winds": ["eol"], "audio/vnd.dra": ["dra"], "audio/vnd.dts": ["dts"], "audio/vnd.dts.hd": ["dtshd"], "audio/vnd.lucent.voice": ["lvp"], "audio/vnd.ms-playready.media.pya": ["pya"], "audio/vnd.nuera.ecelp4800": ["ecelp4800"], "audio/vnd.nuera.ecelp7470": ["ecelp7470"], "audio/vnd.nuera.ecelp9600": ["ecelp9600"], "audio/vnd.rip": ["rip"], "audio/x-aac": ["aac"], "audio/x-aiff": ["aif", "aiff", "aifc"], "audio/x-caf": ["caf"], "audio/x-flac": ["flac"], "audio/x-m4a": [], "audio/x-matroska": ["mka"], "audio/x-mpegurl": ["m3u"], "audio/x-ms-wax": ["wax"], "audio/x-ms-wma": ["wma"], "audio/x-pn-realaudio": ["ram", "ra"], "audio/x-pn-realaudio-plugin": ["rmp"], "audio/x-realaudio": [], "audio/x-wav": [], "chemical/x-cdx": ["cdx"], "chemical/x-cif": ["cif"], "chemical/x-cmdf": ["cmdf"], "chemical/x-cml": ["cml"], "chemical/x-csml": ["csml"], "chemical/x-xyz": ["xyz"], "image/prs.btif": ["btif"], "image/vnd.adobe.photoshop": ["psd"], "image/vnd.dece.graphic": ["uvi", "uvvi", "uvg", "uvvg"], "image/vnd.djvu": ["djvu", "djv"], "image/vnd.dvb.subtitle": [], "image/vnd.dwg": ["dwg"], "image/vnd.dxf": ["dxf"], "image/vnd.fastbidsheet": ["fbs"], "image/vnd.fpx": ["fpx"], "image/vnd.fst": ["fst"], "image/vnd.fujixerox.edmics-mmr": ["mmr"], "image/vnd.fujixerox.edmics-rlc": ["rlc"], "image/vnd.ms-modi": ["mdi"], "image/vnd.ms-photo": ["wdp"], "image/vnd.net-fpx": ["npx"], "image/vnd.wap.wbmp": ["wbmp"], "image/vnd.xiff": ["xif"], "image/x-3ds": ["3ds"], "image/x-cmu-raster": ["ras"], "image/x-cmx": ["cmx"], "image/x-freehand": ["fh", "fhc", "fh4", "fh5", "fh7"], "image/x-icon": ["ico"], "image/x-jng": ["jng"], "image/x-mrsid-image": ["sid"], "image/x-ms-bmp": [], "image/x-pcx": ["pcx"], "image/x-pict": ["pic", "pct"], "image/x-portable-anymap": ["pnm"], "image/x-portable-bitmap": ["pbm"], "image/x-portable-graymap": ["pgm"], "image/x-portable-pixmap": ["ppm"], "image/x-rgb": ["rgb"], "image/x-tga": ["tga"], "image/x-xbitmap": ["xbm"], "image/x-xpixmap": ["xpm"], "image/x-xwindowdump": ["xwd"], "model/vnd.collada+xml": ["dae"], "model/vnd.dwf": ["dwf"], "model/vnd.gdl": ["gdl"], "model/vnd.gtw": ["gtw"], "model/vnd.mts": ["mts"], "model/vnd.vtu": ["vtu"], "text/prs.lines.tag": ["dsc"], "text/vnd.curl": ["curl"], "text/vnd.curl.dcurl": ["dcurl"], "text/vnd.curl.mcurl": ["mcurl"], "text/vnd.curl.scurl": ["scurl"], "text/vnd.dvb.subtitle": ["sub"], "text/vnd.fly": ["fly"], "text/vnd.fmi.flexstor": ["flx"], "text/vnd.graphviz": ["gv"], "text/vnd.in3d.3dml": ["3dml"], "text/vnd.in3d.spot": ["spot"], "text/vnd.sun.j2me.app-descriptor": ["jad"], "text/vnd.wap.wml": ["wml"], "text/vnd.wap.wmlscript": ["wmls"], "text/x-asm": ["s", "asm"], "text/x-c": ["c", "cc", "cxx", "cpp", "h", "hh", "dic"], "text/x-component": ["htc"], "text/x-fortran": ["f", "for", "f77", "f90"], "text/x-handlebars-template": ["hbs"], "text/x-java-source": ["java"], "text/x-lua": ["lua"], "text/x-markdown": ["mkd"], "text/x-nfo": ["nfo"], "text/x-opml": ["opml"], "text/x-org": [], "text/x-pascal": ["p", "pas"], "text/x-processing": ["pde"], "text/x-sass": ["sass"], "text/x-scss": ["scss"], "text/x-setext": ["etx"], "text/x-sfv": ["sfv"], "text/x-suse-ymp": ["ymp"], "text/x-uuencode": ["uu"], "text/x-vcalendar": ["vcs"], "text/x-vcard": ["vcf"], "video/vnd.dece.hd": ["uvh", "uvvh"], "video/vnd.dece.mobile": ["uvm", "uvvm"], "video/vnd.dece.pd": ["uvp", "uvvp"], "video/vnd.dece.sd": ["uvs", "uvvs"], "video/vnd.dece.video": ["uvv", "uvvv"], "video/vnd.dvb.file": ["dvb"], "video/vnd.fvt": ["fvt"], "video/vnd.mpegurl": ["mxu", "m4u"], "video/vnd.ms-playready.media.pyv": ["pyv"], "video/vnd.uvvu.mp4": ["uvu", "uvvu"], "video/vnd.vivo": ["viv"], "video/x-f4v": ["f4v"], "video/x-fli": ["fli"], "video/x-flv": ["flv"], "video/x-m4v": ["m4v"], "video/x-matroska": ["mkv", "mk3d", "mks"], "video/x-mng": ["mng"], "video/x-ms-asf": ["asf", "asx"], "video/x-ms-vob": ["vob"], "video/x-ms-wm": ["wm"], "video/x-ms-wmv": ["wmv"], "video/x-ms-wmx": ["wmx"], "video/x-ms-wvx": ["wvx"], "video/x-msvideo": ["avi"], "video/x-sgi-movie": ["movie"], "video/x-smv": ["smv"], "x-conference/x-cooltalk": ["ice"] };
30494 }, {}], 4: [function (require, module, exports) {
30495 module.exports = { "application/andrew-inset": ["ez"], "application/applixware": ["aw"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomsvc+xml": ["atomsvc"], "application/bdoc": ["bdoc"], "application/ccxml+xml": ["ccxml"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cu-seeme": ["cu"], "application/dash+xml": ["mpd"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["ecma"], "application/emma+xml": ["emma"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/font-tdpfr": ["pfr"], "application/font-woff": ["woff"], "application/font-woff2": ["woff2"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["js", "mjs"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["mp4s", "m4p"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-signature": ["asc", "sig"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/pskc+xml": ["pskcxml"], "application/rdf+xml": ["rdf"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/voicexml+xml": ["vxml"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-diff+xml": ["xdf"], "application/xenc+xml": ["xenc"], "application/xhtml+xml": ["xhtml", "xht"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": [], "audio/adpcm": ["adp"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mp3": [], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": [], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/otf": ["otf"], "image/apng": ["apng"], "image/bmp": ["bmp"], "image/cgm": ["cgm"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/ief": ["ief"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/ktx": ["ktx"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/tiff": ["tiff", "tif"], "image/webp": ["webp"], "message/rfc822": ["eml", "mime"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/mesh": ["msh", "mesh", "silo"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["x3db", "x3dbz"], "model/x3d+vrml": ["x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/hjson": ["hjson"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["markdown", "md"], "text/mathml": ["mml"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": [], "text/sgml": ["sgml", "sgm"], "text/slim": ["slim", "slm"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/xml": [], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/jpeg": ["jpgv"], "video/jpm": ["jpm", "jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] };
30496 }, {}] }, {}, [2])(2);
30497});
30498
30499}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
30500},{"babel-runtime/core-js/object/create":40,"babel-runtime/helpers/classCallCheck":52,"babel-runtime/helpers/createClass":53,"babel-runtime/helpers/typeof":54}],324:[function(require,module,exports){
30501'use strict';
30502
30503// copy from https://github.com/node-modules/utility for browser
30504
30505exports.encodeURIComponent = function (text) {
30506 try {
30507 return encodeURIComponent(text);
30508 } catch (e) {
30509 return text;
30510 }
30511};
30512
30513exports.escape = require('escape-html');
30514
30515exports.timestamp = function timestamp(t) {
30516 if (t) {
30517 var v = t;
30518 if (typeof v === 'string') {
30519 v = Number(v);
30520 }
30521 if (String(t).length === 10) {
30522 v *= 1000;
30523 }
30524 return new Date(v);
30525 }
30526 return Math.round(Date.now() / 1000);
30527};
30528
30529},{"escape-html":205}],325:[function(require,module,exports){
30530(function (process,Buffer){
30531'use strict';
30532
30533var _stringify = require('babel-runtime/core-js/json/stringify');
30534
30535var _stringify2 = _interopRequireDefault(_stringify);
30536
30537var _typeof2 = require('babel-runtime/helpers/typeof');
30538
30539var _typeof3 = _interopRequireDefault(_typeof2);
30540
30541function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30542
30543var util = require('util');
30544var urlutil = require('url');
30545var http = require('http');
30546var https = require('https');
30547var debug = require('debug')('urllib');
30548var ms = require('humanize-ms');
30549
30550var _Promise;
30551
30552var REQUEST_ID = 0;
30553var MAX_VALUE = Math.pow(2, 31) - 10;
30554var PROTO_RE = /^https?:\/\//i;
30555
30556function getAgent(agent, defaultAgent) {
30557 return agent === undefined ? defaultAgent : agent;
30558}
30559
30560function makeCallback(resolve, reject) {
30561 return function (err, data, res) {
30562 if (err) {
30563 return reject(err);
30564 }
30565 resolve({
30566 data: data,
30567 status: res.statusCode,
30568 headers: res.headers,
30569 res: res
30570 });
30571 };
30572}
30573
30574// exports.TIMEOUT = ms('5s');
30575exports.TIMEOUTS = [ms('300s'), ms('300s')];
30576
30577var TEXT_DATA_TYPES = ['json', 'text'];
30578
30579exports.request = function request(url, args, callback) {
30580 // request(url, callback)
30581 if (arguments.length === 2 && typeof args === 'function') {
30582 callback = args;
30583 args = null;
30584 }
30585 if (typeof callback === 'function') {
30586 return exports.requestWithCallback(url, args, callback);
30587 }
30588
30589 // Promise
30590 if (!_Promise) {
30591 _Promise = require('any-promise');
30592 }
30593 return new _Promise(function (resolve, reject) {
30594 exports.requestWithCallback(url, args, makeCallback(resolve, reject));
30595 });
30596};
30597
30598exports.requestWithCallback = function requestWithCallback(url, args, callback) {
30599 // requestWithCallback(url, callback)
30600 if (!url || typeof url !== 'string' && (typeof url === 'undefined' ? 'undefined' : (0, _typeof3.default)(url)) !== 'object') {
30601 var msg = util.format('expect request url to be a string or a http request options, but got %j', url);
30602 throw new Error(msg);
30603 }
30604
30605 if (arguments.length === 2 && typeof args === 'function') {
30606 callback = args;
30607 args = null;
30608 }
30609
30610 args = args || {};
30611 if (REQUEST_ID >= MAX_VALUE) {
30612 REQUEST_ID = 0;
30613 }
30614 var reqId = ++REQUEST_ID;
30615
30616 args.requestUrls = args.requestUrls || [];
30617
30618 var reqMeta = {
30619 requestId: reqId,
30620 url: url,
30621 args: args,
30622 ctx: args.ctx
30623 };
30624 if (args.emitter) {
30625 args.emitter.emit('request', reqMeta);
30626 }
30627
30628 args.timeout = args.timeout || exports.TIMEOUTS;
30629 args.maxRedirects = args.maxRedirects || 10;
30630 args.streaming = args.streaming || args.customResponse;
30631 var requestStartTime = Date.now();
30632 var parsedUrl;
30633
30634 if (typeof url === 'string') {
30635 if (!PROTO_RE.test(url)) {
30636 // Support `request('www.server.com')`
30637 url = 'http://' + url;
30638 }
30639 parsedUrl = urlutil.parse(url);
30640 } else {
30641 parsedUrl = url;
30642 }
30643
30644 var method = (args.type || args.method || parsedUrl.method || 'GET').toUpperCase();
30645 var port = parsedUrl.port || 80;
30646 var httplib = http;
30647 var agent = getAgent(args.agent, exports.agent);
30648 var fixJSONCtlChars = args.fixJSONCtlChars;
30649
30650 if (parsedUrl.protocol === 'https:') {
30651 httplib = https;
30652 agent = getAgent(args.httpsAgent, exports.httpsAgent);
30653
30654 if (!parsedUrl.port) {
30655 port = 443;
30656 }
30657 }
30658
30659 // request through proxy tunnel
30660 // var proxyTunnelAgent = detectProxyAgent(parsedUrl, args);
30661 // if (proxyTunnelAgent) {
30662 // agent = proxyTunnelAgent;
30663 // }
30664
30665 var options = {
30666 host: parsedUrl.hostname || parsedUrl.host || 'localhost',
30667 path: parsedUrl.path || '/',
30668 method: method,
30669 port: port,
30670 agent: agent,
30671 headers: args.headers || {},
30672 // default is dns.lookup
30673 // https://github.com/nodejs/node/blob/master/lib/net.js#L986
30674 // custom dnslookup require node >= 4.0.0
30675 // https://github.com/nodejs/node/blob/archived-io.js-v0.12/lib/net.js#L952
30676 lookup: args.lookup
30677 };
30678
30679 if (Array.isArray(args.timeout)) {
30680 options.requestTimeout = args.timeout[args.timeout.length - 1];
30681 } else if (typeof args.timeout !== 'undefined') {
30682 options.requestTimeout = args.timeout;
30683 }
30684
30685 var sslNames = ['pfx', 'key', 'passphrase', 'cert', 'ca', 'ciphers', 'rejectUnauthorized', 'secureProtocol', 'secureOptions'];
30686 for (var i = 0; i < sslNames.length; i++) {
30687 var name = sslNames[i];
30688 if (args.hasOwnProperty(name)) {
30689 options[name] = args[name];
30690 }
30691 }
30692
30693 // don't check ssl
30694 if (options.rejectUnauthorized === false && !options.hasOwnProperty('secureOptions')) {
30695 options.secureOptions = require('constants').SSL_OP_NO_TLSv1_2;
30696 }
30697
30698 var auth = args.auth || parsedUrl.auth;
30699 if (auth) {
30700 options.auth = auth;
30701 }
30702
30703 var body = args.content || args.data;
30704 var dataAsQueryString = method === 'GET' || method === 'HEAD' || args.dataAsQueryString;
30705 if (!args.content) {
30706 if (body && !(typeof body === 'string' || Buffer.isBuffer(body))) {
30707 if (dataAsQueryString) {
30708 // read: GET, HEAD, use query string
30709 body = args.nestedQuerystring ? qs.stringify(body) : querystring.stringify(body);
30710 } else {
30711 var contentType = options.headers['Content-Type'] || options.headers['content-type'];
30712 // auto add application/x-www-form-urlencoded when using urlencode form request
30713 if (!contentType) {
30714 if (args.contentType === 'json') {
30715 contentType = 'application/json';
30716 } else {
30717 contentType = 'application/x-www-form-urlencoded';
30718 }
30719 options.headers['Content-Type'] = contentType;
30720 }
30721
30722 if (parseContentType(contentType).type === 'application/json') {
30723 body = (0, _stringify2.default)(body);
30724 } else {
30725 // 'application/x-www-form-urlencoded'
30726 body = args.nestedQuerystring ? qs.stringify(body) : querystring.stringify(body);
30727 }
30728 }
30729 }
30730 }
30731
30732 // if it's a GET or HEAD request, data should be sent as query string
30733 if (dataAsQueryString && body) {
30734 options.path += (parsedUrl.query ? '&' : '?') + body;
30735 body = null;
30736 }
30737
30738 var requestSize = 0;
30739 if (body) {
30740 var length = body.length;
30741 if (!Buffer.isBuffer(body)) {
30742 length = Buffer.byteLength(body);
30743 }
30744 requestSize = options.headers['Content-Length'] = length;
30745 }
30746
30747 if (args.dataType === 'json') {
30748 options.headers.Accept = 'application/json';
30749 }
30750
30751 if (typeof args.beforeRequest === 'function') {
30752 // you can use this hook to change every thing.
30753 args.beforeRequest(options);
30754 }
30755 var connectTimer = null;
30756 var responseTimer = null;
30757 var __err = null;
30758 var connected = false; // socket connected or not
30759 var keepAliveSocket = false; // request with keepalive socket
30760 var responseSize = 0;
30761 var statusCode = -1;
30762 var responseAborted = false;
30763 var remoteAddress = '';
30764 var remotePort = '';
30765 var timing = null;
30766 if (args.timing) {
30767 timing = {
30768 // socket assigned
30769 queuing: 0,
30770 // dns lookup time
30771 dnslookup: 0,
30772 // socket connected
30773 connected: 0,
30774 // request sent
30775 requestSent: 0,
30776 // Time to first byte (TTFB)
30777 waiting: 0,
30778 contentDownload: 0
30779 };
30780 }
30781
30782 function cancelConnectTimer() {
30783 if (connectTimer) {
30784 clearTimeout(connectTimer);
30785 connectTimer = null;
30786 }
30787 }
30788 function cancelResponseTimer() {
30789 if (responseTimer) {
30790 clearTimeout(responseTimer);
30791 responseTimer = null;
30792 }
30793 }
30794
30795 function done(err, data, res) {
30796 cancelResponseTimer();
30797 if (!callback) {
30798 console.warn('[urllib:warn] [%s] [%s] [worker:%s] %s %s callback twice!!!', Date(), reqId, process.pid, options.method, url);
30799 // https://github.com/node-modules/urllib/pull/30
30800 if (err) {
30801 console.warn('[urllib:warn] [%s] [%s] [worker:%s] %s: %s\nstack: %s', Date(), reqId, process.pid, err.name, err.message, err.stack);
30802 }
30803 return;
30804 }
30805 var cb = callback;
30806 callback = null;
30807 var headers = {};
30808 if (res) {
30809 statusCode = res.statusCode;
30810 headers = res.headers;
30811 }
30812
30813 // handle digest auth
30814 if (statusCode === 401 && headers['www-authenticate'] && (!args.headers || !args.headers.Authorization) && args.digestAuth) {
30815 var authenticate = headers['www-authenticate'];
30816 if (authenticate.indexOf('Digest ') >= 0) {
30817 debug('Request#%d %s: got digest auth header WWW-Authenticate: %s', reqId, url, authenticate);
30818 args.headers = args.headers || {};
30819 args.headers.Authorization = digestAuthHeader(options.method, options.path, authenticate, args.digestAuth);
30820 debug('Request#%d %s: auth with digest header: %s', reqId, url, args.headers.Authorization);
30821 if (res.headers['set-cookie']) {
30822 args.headers.Cookie = res.headers['set-cookie'].join(';');
30823 }
30824 return exports.requestWithCallback(url, args, cb);
30825 }
30826 }
30827
30828 var requestUseTime = Date.now() - requestStartTime;
30829 if (timing) {
30830 timing.contentDownload = requestUseTime;
30831 }
30832
30833 debug('[%sms] done, %s bytes HTTP %s %s %s %s, keepAliveSocket: %s, timing: %j', requestUseTime, responseSize, statusCode, options.method, options.host, options.path, keepAliveSocket, timing);
30834
30835 var response = {
30836 status: statusCode,
30837 statusCode: statusCode,
30838 headers: headers,
30839 size: responseSize,
30840 aborted: responseAborted,
30841 rt: requestUseTime,
30842 keepAliveSocket: keepAliveSocket,
30843 data: data,
30844 requestUrls: args.requestUrls,
30845 timing: timing,
30846 remoteAddress: remoteAddress,
30847 remotePort: remotePort
30848 };
30849
30850 if (err) {
30851 var agentStatus = '';
30852 if (agent && typeof agent.getCurrentStatus === 'function') {
30853 // add current agent status to error message for logging and debug
30854 agentStatus = ', agent status: ' + (0, _stringify2.default)(agent.getCurrentStatus());
30855 }
30856 err.message += ', ' + options.method + ' ' + url + ' ' + statusCode + ' (connected: ' + connected + ', keepalive socket: ' + keepAliveSocket + agentStatus + ')' + '\nheaders: ' + (0, _stringify2.default)(headers);
30857 err.data = data;
30858 err.path = options.path;
30859 err.status = statusCode;
30860 err.headers = headers;
30861 err.res = response;
30862 }
30863
30864 cb(err, data, args.streaming ? res : response);
30865
30866 if (args.emitter) {
30867 // keep to use the same reqMeta object on request event before
30868 reqMeta.url = url;
30869 reqMeta.socket = req && req.connection;
30870 reqMeta.options = options;
30871 reqMeta.size = requestSize;
30872
30873 args.emitter.emit('response', {
30874 requestId: reqId,
30875 error: err,
30876 ctx: args.ctx,
30877 req: reqMeta,
30878 res: response
30879 });
30880 }
30881 }
30882
30883 function handleRedirect(res) {
30884 var err = null;
30885 if (args.followRedirect && statuses.redirect[res.statusCode]) {
30886 // handle redirect
30887 args._followRedirectCount = (args._followRedirectCount || 0) + 1;
30888 var location = res.headers.location;
30889 if (!location) {
30890 err = new Error('Got statusCode ' + res.statusCode + ' but cannot resolve next location from headers');
30891 err.name = 'FollowRedirectError';
30892 } else if (args._followRedirectCount > args.maxRedirects) {
30893 err = new Error('Exceeded maxRedirects. Probably stuck in a redirect loop ' + url);
30894 err.name = 'MaxRedirectError';
30895 } else {
30896 var newUrl = args.formatRedirectUrl ? args.formatRedirectUrl(url, location) : urlutil.resolve(url, location);
30897 debug('Request#%d %s: `redirected` from %s to %s', reqId, options.path, url, newUrl);
30898 // make sure timer stop
30899 cancelResponseTimer();
30900 // should clean up headers.Host on `location: http://other-domain/url`
30901 if (args.headers && args.headers.Host && PROTO_RE.test(location)) {
30902 args.headers.Host = null;
30903 }
30904 // avoid done will be execute in the future change.
30905 var cb = callback;
30906 callback = null;
30907 exports.requestWithCallback(newUrl, args, cb);
30908 return {
30909 redirect: true,
30910 error: null
30911 };
30912 }
30913 }
30914 return {
30915 redirect: false,
30916 error: err
30917 };
30918 }
30919
30920 // set user-agent
30921 if (!options.headers['User-Agent'] && !options.headers['user-agent']) {
30922 options.headers['User-Agent'] = navigator.userAgent;
30923 }
30924
30925 if (args.gzip) {
30926 if (!options.headers['Accept-Encoding'] && !options.headers['accept-encoding']) {
30927 options.headers['Accept-Encoding'] = 'gzip';
30928 }
30929 }
30930
30931 function decodeContent(res, body, cb) {
30932 var encoding = res.headers['content-encoding'];
30933 // if (body.length === 0) {
30934 // return cb(null, body, encoding);
30935 // }
30936
30937 // if (!encoding || encoding.toLowerCase() !== 'gzip') {
30938 return cb(null, body, encoding);
30939 // }
30940
30941 // debug('gunzip %d length body', body.length);
30942 // zlib.gunzip(body, cb);
30943 }
30944
30945 var writeStream = args.writeStream;
30946
30947 debug('Request#%d %s %s with headers %j, options.path: %s', reqId, method, url, options.headers, options.path);
30948
30949 args.requestUrls.push(url);
30950
30951 function onResponse(res) {
30952 if (timing) {
30953 timing.waiting = Date.now() - requestStartTime;
30954 }
30955 debug('Request#%d %s `req response` event emit: status %d, headers: %j', reqId, url, res.statusCode, res.headers);
30956
30957 if (args.streaming) {
30958 var result = handleRedirect(res);
30959 if (result.redirect) {
30960 res.resume();
30961 return;
30962 }
30963 if (result.error) {
30964 res.resume();
30965 return done(result.error, null, res);
30966 }
30967
30968 return done(null, null, res);
30969 }
30970
30971 res.on('close', function () {
30972 debug('Request#%d %s: `res close` event emit, total size %d', reqId, url, responseSize);
30973 });
30974
30975 res.on('error', function () {
30976 debug('Request#%d %s: `res error` event emit, total size %d', reqId, url, responseSize);
30977 });
30978
30979 res.on('aborted', function () {
30980 responseAborted = true;
30981 debug('Request#%d %s: `res aborted` event emit, total size %d', reqId, url, responseSize);
30982 });
30983
30984 if (writeStream) {
30985 // If there's a writable stream to recieve the response data, just pipe the
30986 // response stream to that writable stream and call the callback when it has
30987 // finished writing.
30988 //
30989 // NOTE that when the response stream `res` emits an 'end' event it just
30990 // means that it has finished piping data to another stream. In the
30991 // meanwhile that writable stream may still writing data to the disk until
30992 // it emits a 'close' event.
30993 //
30994 // That means that we should not apply callback until the 'close' of the
30995 // writable stream is emited.
30996 //
30997 // See also:
30998 // - https://github.com/TBEDP/urllib/commit/959ac3365821e0e028c231a5e8efca6af410eabb
30999 // - http://nodejs.org/api/stream.html#stream_event_end
31000 // - http://nodejs.org/api/stream.html#stream_event_close_1
31001 var result = handleRedirect(res);
31002 if (result.redirect) {
31003 res.resume();
31004 return;
31005 }
31006 if (result.error) {
31007 res.resume();
31008 // end ths stream first
31009 writeStream.end();
31010 return done(result.error, null, res);
31011 }
31012 // you can set consumeWriteStream false that only wait response end
31013 if (args.consumeWriteStream === false) {
31014 res.on('end', done.bind(null, null, null, res));
31015 } else {
31016 // node 0.10, 0.12: only emit res aborted, writeStream close not fired
31017 if (isNode010 || isNode012) {
31018 first([[writeStream, 'close'], [res, 'aborted']], function (_, stream, event) {
31019 debug('Request#%d %s: writeStream or res %s event emitted', reqId, url, event);
31020 done(__err || null, null, res);
31021 });
31022 } else {
31023 writeStream.on('close', function () {
31024 debug('Request#%d %s: writeStream close event emitted', reqId, url);
31025 done(__err || null, null, res);
31026 });
31027 }
31028 }
31029 return res.pipe(writeStream);
31030 }
31031
31032 // Otherwise, just concat those buffers.
31033 //
31034 // NOTE that the `chunk` is not a String but a Buffer. It means that if
31035 // you simply concat two chunk with `+` you're actually converting both
31036 // Buffers into Strings before concating them. It'll cause problems when
31037 // dealing with multi-byte characters.
31038 //
31039 // The solution is to store each chunk in an array and concat them with
31040 // 'buffer-concat' when all chunks is recieved.
31041 //
31042 // See also:
31043 // http://cnodejs.org/topic/4faf65852e8fb5bc65113403
31044
31045 var chunks = [];
31046
31047 res.on('data', function (chunk) {
31048 debug('Request#%d %s: `res data` event emit, size %d', reqId, url, chunk.length);
31049 responseSize += chunk.length;
31050 chunks.push(chunk);
31051 });
31052
31053 res.on('end', function () {
31054 var body = Buffer.concat(chunks, responseSize);
31055 debug('Request#%d %s: `res end` event emit, total size %d, _dumped: %s', reqId, url, responseSize, res._dumped);
31056
31057 if (__err) {
31058 // req.abort() after `res data` event emit.
31059 return done(__err, body, res);
31060 }
31061
31062 var result = handleRedirect(res);
31063 if (result.error) {
31064 return done(result.error, body, res);
31065 }
31066 if (result.redirect) {
31067 return;
31068 }
31069
31070 decodeContent(res, body, function (err, data, encoding) {
31071 if (err) {
31072 return done(err, body, res);
31073 }
31074 // if body not decode, dont touch it
31075 if (!encoding && TEXT_DATA_TYPES.indexOf(args.dataType) >= 0) {
31076 // try to decode charset
31077 try {
31078 data = decodeBodyByCharset(data, res);
31079 } catch (e) {
31080 debug('decodeBodyByCharset error: %s', e);
31081 // if error, dont touch it
31082 return done(null, data, res);
31083 }
31084
31085 if (args.dataType === 'json') {
31086 if (responseSize === 0) {
31087 data = null;
31088 } else {
31089 var r = parseJSON(data, fixJSONCtlChars);
31090 if (r.error) {
31091 err = r.error;
31092 } else {
31093 data = r.data;
31094 }
31095 }
31096 }
31097 }
31098
31099 if (responseAborted) {
31100 // err = new Error('Remote socket was terminated before `response.end()` was called');
31101 // err.name = 'RemoteSocketClosedError';
31102 debug('Request#%d %s: Remote socket was terminated before `response.end()` was called', reqId, url);
31103 }
31104
31105 done(err, data, res);
31106 });
31107 });
31108 }
31109
31110 var connectTimeout, responseTimeout;
31111 if (Array.isArray(args.timeout)) {
31112 connectTimeout = ms(args.timeout[0]);
31113 responseTimeout = ms(args.timeout[1]);
31114 } else {
31115 // set both timeout equal
31116 connectTimeout = responseTimeout = ms(args.timeout);
31117 }
31118 debug('ConnectTimeout: %d, ResponseTimeout: %d', connectTimeout, responseTimeout);
31119
31120 function startConnectTimer() {
31121 debug('Connect timer ticking, timeout: %d', connectTimeout);
31122 connectTimer = setTimeout(function () {
31123 connectTimer = null;
31124 if (statusCode === -1) {
31125 statusCode = -2;
31126 }
31127 var msg = 'Connect timeout for ' + connectTimeout + 'ms';
31128 var errorName = 'ConnectionTimeoutError';
31129 if (!req.socket) {
31130 errorName = 'SocketAssignTimeoutError';
31131 msg += ', working sockets is full';
31132 }
31133 __err = new Error(msg);
31134 __err.name = errorName;
31135 __err.requestId = reqId;
31136 debug('ConnectTimeout: Request#%d %s %s: %s, connected: %s', reqId, url, __err.name, msg, connected);
31137 abortRequest();
31138 }, connectTimeout);
31139 }
31140
31141 function startResposneTimer() {
31142 debug('Response timer ticking, timeout: %d', responseTimeout);
31143 responseTimer = setTimeout(function () {
31144 responseTimer = null;
31145 var msg = 'Response timeout for ' + responseTimeout + 'ms';
31146 var errorName = 'ResponseTimeoutError';
31147 __err = new Error(msg);
31148 __err.name = errorName;
31149 __err.requestId = reqId;
31150 debug('ResponseTimeout: Request#%d %s %s: %s, connected: %s', reqId, url, __err.name, msg, connected);
31151 abortRequest();
31152 }, responseTimeout);
31153 }
31154
31155 var req;
31156 // request headers checker will throw error
31157 options.mode = args.mode ? args.mode : '';
31158 try {
31159 req = httplib.request(options, onResponse);
31160 } catch (err) {
31161 return done(err);
31162 }
31163
31164 // environment detection: browser or nodejs
31165 if (typeof window === 'undefined') {
31166 // start connect timer just after `request` return, and just in nodejs environment
31167 startConnectTimer();
31168 } else {
31169 req.on('requestTimeout', function () {
31170 if (statusCode === -1) {
31171 statusCode = -2;
31172 }
31173 var msg = 'Connect timeout for ' + connectTimeout + 'ms';
31174 var errorName = 'ConnectionTimeoutError';
31175 __err = new Error(msg);
31176 __err.name = errorName;
31177 __err.requestId = reqId;
31178 abortRequest();
31179 });
31180 }
31181
31182 function abortRequest() {
31183 debug('Request#%d %s abort, connected: %s', reqId, url, connected);
31184 // it wont case error event when req haven't been assigned a socket yet.
31185 if (!req.socket) {
31186 __err.noSocket = true;
31187 done(__err);
31188 }
31189 req.abort();
31190 }
31191
31192 if (timing) {
31193 // request sent
31194 req.on('finish', function () {
31195 timing.requestSent = Date.now() - requestStartTime;
31196 });
31197 }
31198
31199 req.once('socket', function (socket) {
31200 if (timing) {
31201 // socket queuing time
31202 timing.queuing = Date.now() - requestStartTime;
31203 }
31204
31205 // https://github.com/nodejs/node/blob/master/lib/net.js#L377
31206 // https://github.com/nodejs/node/blob/v0.10.40-release/lib/net.js#L352
31207 // should use socket.socket on 0.10.x
31208 if (isNode010 && socket.socket) {
31209 socket = socket.socket;
31210 }
31211
31212 var readyState = socket.readyState;
31213 if (readyState === 'opening') {
31214 socket.once('lookup', function (err, ip, addressType) {
31215 debug('Request#%d %s lookup: %s, %s, %s', reqId, url, err, ip, addressType);
31216 if (timing) {
31217 timing.dnslookup = Date.now() - requestStartTime;
31218 }
31219 if (ip) {
31220 remoteAddress = ip;
31221 }
31222 });
31223 socket.once('connect', function () {
31224 if (timing) {
31225 // socket connected
31226 timing.connected = Date.now() - requestStartTime;
31227 }
31228
31229 // cancel socket timer at first and start tick for TTFB
31230 cancelConnectTimer();
31231 startResposneTimer();
31232
31233 debug('Request#%d %s new socket connected', reqId, url);
31234 connected = true;
31235 if (!remoteAddress) {
31236 remoteAddress = socket.remoteAddress;
31237 }
31238 remotePort = socket.remotePort;
31239 });
31240 return;
31241 }
31242
31243 debug('Request#%d %s reuse socket connected, readyState: %s', reqId, url, readyState);
31244 connected = true;
31245 keepAliveSocket = true;
31246 if (!remoteAddress) {
31247 remoteAddress = socket.remoteAddress;
31248 }
31249 remotePort = socket.remotePort;
31250
31251 // reuse socket, timer should be canceled.
31252 cancelConnectTimer();
31253 startResposneTimer();
31254 });
31255
31256 req.on('error', function (err) {
31257 //TypeError for browser fetch api, Error for browser xmlhttprequest api
31258 if (err.name === 'Error' || err.name === 'TypeError') {
31259 err.name = connected ? 'ResponseError' : 'RequestError';
31260 }
31261 err.message += ' (req "error")';
31262 debug('Request#%d %s `req error` event emit, %s: %s', reqId, url, err.name, err.message);
31263 done(__err || err);
31264 });
31265
31266 if (writeStream) {
31267 writeStream.once('error', function (err) {
31268 err.message += ' (writeStream "error")';
31269 __err = err;
31270 debug('Request#%d %s `writeStream error` event emit, %s: %s', reqId, url, err.name, err.message);
31271 abortRequest();
31272 });
31273 }
31274
31275 if (args.stream) {
31276 args.stream.pipe(req);
31277 args.stream.once('error', function (err) {
31278 err.message += ' (stream "error")';
31279 __err = err;
31280 debug('Request#%d %s `readStream error` event emit, %s: %s', reqId, url, err.name, err.message);
31281 abortRequest();
31282 });
31283 } else {
31284 req.end(body);
31285 }
31286
31287 req.requestId = reqId;
31288 return req;
31289};
31290
31291}).call(this,require('_process'),require("buffer").Buffer)
31292},{"_process":239,"any-promise":34,"babel-runtime/core-js/json/stringify":38,"babel-runtime/helpers/typeof":54,"buffer":60,"constants":62,"debug":178,"http":262,"https":213,"humanize-ms":214,"url":269,"util":277}]},{},[1])(1)
31293});
31294