diff --git a/CHANGELOG.md b/CHANGELOG.md index d5d646a..561aded 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 2.1.0 +- Updated dependencies. +- Migrated code to ES6 + ## 2.0.2 - Updated dependencies. - Fixed missing /dist directory. diff --git a/babel-settings.json b/babel-settings.json new file mode 100644 index 0000000..2a42698 --- /dev/null +++ b/babel-settings.json @@ -0,0 +1,7 @@ +{ + "babelrc": false, + "plugins": [ + "transform-es2015-modules-commonjs", + ["transform-object-rest-spread", { "useBuiltIns": true }] + ] +} diff --git a/build/browserify.js b/build/browserify.js new file mode 100644 index 0000000..b5dac3e --- /dev/null +++ b/build/browserify.js @@ -0,0 +1,68 @@ +import gulp from 'gulp'; +import header from 'gulp-header'; +import uglify from 'gulp-uglify'; +import gulpIf from 'gulp-if'; +import browserify from 'browserify'; +import babelify from 'babelify'; +import source from 'vinyl-source-stream2'; +import pkg from '../package.json'; + +const banner = [ + '/*', + ' * <%= pkg.name %> - <%= pkg.description %>', + ' * @version v<%= pkg.version %>', + ' * @author <%= pkg.author %>', + ' * @link <%= pkg.homepage %>', + ' * @license <%= pkg.license %>', + ' */', + ''].join('\n'); + +function handleErrors(...args) { + console.error(args); + this.emit('end'); // Keep gulp from hanging on this task +} + +gulp.task('script', () => { + + const isProduction = (process.env.NODE_ENV === 'production'); + + const bundleConfig = { + name: 'inkjet', + entries: [`./index.js`], // require.resolve('babel-polyfill'), + dest: './dist', + outputName: `inkjet${isProduction ? '.min' : ''}.js`, + isUglify: isProduction, + }; + + let bundler = browserify({ + entries: bundleConfig.entries, + insertGlobals: false, + detectGlobals: true, + standalone: bundleConfig.name, + debug: false + }); + + let bundle = () => { + return bundler + .bundle() + .on('error', handleErrors) + .pipe(source(bundleConfig.outputName)) + .pipe(header(banner, { pkg: pkg })) + .pipe(gulpIf(bundleConfig.isUglify, uglify())) + .pipe(gulp.dest(bundleConfig.dest)) + }; + + bundler + .transform(babelify.configure({ + "presets": [ + ["es2015"], + ], + "plugins": [ + "add-module-exports", + "transform-es2015-modules-commonjs", + ] + } + )); + + bundle(); +}); diff --git a/dist/inkjet.js b/dist/inkjet.js index b5a93f2..9eaf814 100644 --- a/dist/inkjet.js +++ b/dist/inkjet.js @@ -1,6 +1,6 @@ /* * inkjet - JPEG-image decoding, encoding & EXIF reading library for browser and node.js - * @version v2.0.2 + * @version v2.1.0 * @author Grigoriy Chudnov (https://github.com/gchudnov) * @link https://github.com/gchudnov/inkjet * @license MIT @@ -8,27 +8,51 @@ (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.inkjet = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= this._APP0_MARKER && appMarker <= this._APP15_MARKER; }; - ExifReader.prototype._hasExifData = function() { + ExifReader.prototype._hasExifData = function () { return this._tiffHeaderOffset !== 0; }; - ExifReader.prototype._readTags = function() { + ExifReader.prototype._readTags = function () { this._setByteOrder(); this._read0thIfd(); this._readExifIfd(); @@ -347,7 +382,7 @@ function infoBuffer(buf, cb) { return this._readInteroperabilityIfd(); }; - ExifReader.prototype._setByteOrder = function() { + ExifReader.prototype._setByteOrder = function () { if (this._dataView.getUint16(this._tiffHeaderOffset) === this._BYTE_ORDER_BIG_ENDIAN) { return this._littleEndian = true; } else if (this._dataView.getUint16(this._tiffHeaderOffset) === this._BYTE_ORDER_LITTLE_ENDIAN) { @@ -357,18 +392,18 @@ function infoBuffer(buf, cb) { } }; - ExifReader.prototype._read0thIfd = function() { + ExifReader.prototype._read0thIfd = function () { var ifdOffset; ifdOffset = this._getIfdOffset(); return this._readIfd('0th', ifdOffset); }; - ExifReader.prototype._getIfdOffset = function() { + ExifReader.prototype._getIfdOffset = function () { return this._tiffHeaderOffset + this._getLongAt(this._tiffHeaderOffset + 4); }; - ExifReader.prototype._readExifIfd = function() { + ExifReader.prototype._readExifIfd = function () { var ifdOffset; if (this._tags['Exif IFD Pointer'] != null) { @@ -377,7 +412,7 @@ function infoBuffer(buf, cb) { } }; - ExifReader.prototype._readGpsIfd = function() { + ExifReader.prototype._readGpsIfd = function () { var ifdOffset; if (this._tags['GPS Info IFD Pointer'] != null) { @@ -386,7 +421,7 @@ function infoBuffer(buf, cb) { } }; - ExifReader.prototype._readInteroperabilityIfd = function() { + ExifReader.prototype._readInteroperabilityIfd = function () { var ifdOffset; if (this._tags['Interoperability IFD Pointer'] != null) { @@ -395,7 +430,7 @@ function infoBuffer(buf, cb) { } }; - ExifReader.prototype._readIfd = function(ifdType, offset) { + ExifReader.prototype._readIfd = function (ifdType, offset) { var fieldIndex, numberOfFields, tag, _i, _results; numberOfFields = this._getShortAt(offset); @@ -414,7 +449,7 @@ function infoBuffer(buf, cb) { return _results; }; - ExifReader.prototype._readTag = function(ifdType, offset) { + ExifReader.prototype._readTag = function (ifdType, offset) { var tagCode, tagCount, tagDescription, tagName, tagType, tagValue, tagValueOffset; tagCode = this._getShortAt(offset); @@ -433,7 +468,7 @@ function infoBuffer(buf, cb) { tagValue = this._splitNullSeparatedAsciiString(tagValue); } if (this._tagNames[ifdType][tagCode] != null) { - if ((this._tagNames[ifdType][tagCode]['name'] != null) && (this._tagNames[ifdType][tagCode]['description'] != null)) { + if (this._tagNames[ifdType][tagCode]['name'] != null && this._tagNames[ifdType][tagCode]['description'] != null) { tagName = this._tagNames[ifdType][tagCode]['name']; tagDescription = this._tagNames[ifdType][tagCode]['description'](tagValue); } else { @@ -458,10 +493,10 @@ function infoBuffer(buf, cb) { } }; - ExifReader.prototype._getTagValue = function(offset, type, count) { + ExifReader.prototype._getTagValue = function (offset, type, count) { var tagValue, value, valueIndex; - value = (function() { + value = function () { var _i, _results; _results = []; @@ -471,7 +506,7 @@ function infoBuffer(buf, cb) { _results.push(tagValue); } return _results; - }).call(this); + }.call(this); if (value.length === 1) { value = value[0]; } else if (type === this._tagTypes['ASCII']) { @@ -480,10 +515,10 @@ function infoBuffer(buf, cb) { return value; }; - ExifReader.prototype._getAsciiValue = function(charArray) { + ExifReader.prototype._getAsciiValue = function (charArray) { var charCode, newCharArray; - return newCharArray = (function() { + return newCharArray = function () { var _i, _len, _results; _results = []; @@ -492,42 +527,42 @@ function infoBuffer(buf, cb) { _results.push(String.fromCharCode(charCode)); } return _results; - })(); + }(); }; - ExifReader.prototype._getByteAt = function(offset) { + ExifReader.prototype._getByteAt = function (offset) { return this._dataView.getUint8(offset); }; - ExifReader.prototype._getAsciiAt = function(offset) { + ExifReader.prototype._getAsciiAt = function (offset) { return this._dataView.getUint8(offset); }; - ExifReader.prototype._getShortAt = function(offset) { + ExifReader.prototype._getShortAt = function (offset) { return this._dataView.getUint16(offset, this._littleEndian); }; - ExifReader.prototype._getLongAt = function(offset) { + ExifReader.prototype._getLongAt = function (offset) { return this._dataView.getUint32(offset, this._littleEndian); }; - ExifReader.prototype._getRationalAt = function(offset) { + ExifReader.prototype._getRationalAt = function (offset) { return this._getLongAt(offset) / this._getLongAt(offset + 4); }; - ExifReader.prototype._getUndefinedAt = function(offset) { + ExifReader.prototype._getUndefinedAt = function (offset) { return this._getByteAt(offset); }; - ExifReader.prototype._getSlongAt = function(offset) { + ExifReader.prototype._getSlongAt = function (offset) { return this._dataView.getInt32(offset, this._littleEndian); }; - ExifReader.prototype._getSrationalAt = function(offset) { + ExifReader.prototype._getSrationalAt = function (offset) { return this._getSlongAt(offset) / this._getSlongAt(offset + 4); }; - ExifReader.prototype._splitNullSeparatedAsciiString = function(string) { + ExifReader.prototype._splitNullSeparatedAsciiString = function (string) { var character, i, tagValue, _i, _len; tagValue = []; @@ -581,7 +616,7 @@ function infoBuffer(buf, cb) { 0x0111: 'StripOffsets', 0x0112: { 'name': 'Orientation', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 1: return 'top-left'; @@ -612,7 +647,7 @@ function infoBuffer(buf, cb) { 0x011c: 'PlanarConfiguration', 0x0128: { 'name': 'ResolutionUnit', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 2: return 'inches'; @@ -635,7 +670,7 @@ function infoBuffer(buf, cb) { 0x0212: 'YCbCrSubSampling', 0x0213: { 'name': 'YCbCrPositioning', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 1: return 'centered'; @@ -649,7 +684,7 @@ function infoBuffer(buf, cb) { 0x0214: 'ReferenceBlackWhite', 0x8298: { 'name': 'Copyright', - 'description': function(value) { + 'description': function description(value) { return value.join('; '); } }, @@ -661,7 +696,7 @@ function infoBuffer(buf, cb) { 0x829d: 'FNumber', 0x8822: { 'name': 'ExposureProgram', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'Undefined'; @@ -690,13 +725,13 @@ function infoBuffer(buf, cb) { 0x8827: 'ISOSpeedRatings', 0x8828: { 'name': 'OECF', - 'description': function(value) { + 'description': function description(value) { return '[Raw OECF table data]'; } }, 0x9000: { 'name': 'ExifVersion', - 'description': function(value) { + 'description': function description(value) { var charCode, string, _i, _len; string = ''; @@ -711,7 +746,7 @@ function infoBuffer(buf, cb) { 0x9004: 'DateTimeDigitized', 0x9101: { 'name': 'ComponentsConfiguration', - 'description': function(value) { + 'description': function description(value) { var character, string, _i, _len; string = ''; @@ -749,7 +784,7 @@ function infoBuffer(buf, cb) { 0x9206: 'SubjectDistance', 0x9207: { 'name': 'MeteringMode', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 1: return 'Average'; @@ -772,7 +807,7 @@ function infoBuffer(buf, cb) { }, 0x9208: { 'name': 'LightSource', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 1: return 'Daylight'; @@ -821,7 +856,7 @@ function infoBuffer(buf, cb) { }, 0x9209: { 'name': 'Flash', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0x00: return 'Flash did not fire'; @@ -875,7 +910,7 @@ function infoBuffer(buf, cb) { 0x920a: 'FocalLength', 0x9214: { 'name': 'SubjectArea', - 'description': function(value) { + 'description': function description(value) { switch (value.length) { case 2: return "Location; X: " + value[0] + ", Y: " + value[1]; @@ -890,18 +925,18 @@ function infoBuffer(buf, cb) { }, 0x927c: { 'name': 'MakerNote', - 'description': function(value) { + 'description': function description(value) { return '[Raw maker note data]'; } }, 0x9286: { 'name': 'UserComment', - 'description': function(value) { - switch (value.slice(0, 8).map(function(charCode) { - return String.fromCharCode(charCode); - }).join('')) { + 'description': function description(value) { + switch (value.slice(0, 8).map(function (charCode) { + return String.fromCharCode(charCode); + }).join('')) { case 'ASCII\x00\x00\x00': - return value.slice(8, value.length).map(function(charCode) { + return value.slice(8, value.length).map(function (charCode) { return String.fromCharCode(charCode); }).join(''); case 'JIS\x00\x00\x00\x00\x00': @@ -918,7 +953,7 @@ function infoBuffer(buf, cb) { 0x9292: 'SubSecTimeDigitized', 0xa000: { 'name': 'FlashpixVersion', - 'description': function(value) { + 'description': function description(value) { var charCode, string, _i, _len; string = ''; @@ -931,7 +966,7 @@ function infoBuffer(buf, cb) { }, 0xa001: { 'name': 'ColorSpace', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 1: return 'sRGB'; @@ -949,7 +984,7 @@ function infoBuffer(buf, cb) { 0xa20b: 'FlashEnergy', 0xa20c: { 'name': 'SpatialFrequencyResponse', - 'description': function(value) { + 'description': function description(value) { return '[Raw SFR table data]'; } }, @@ -957,7 +992,7 @@ function infoBuffer(buf, cb) { 0xa20f: 'FocalPlaneYResolution', 0xa210: { 'name': 'FocalPlaneResolutionUnit', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 2: return 'inches'; @@ -970,14 +1005,14 @@ function infoBuffer(buf, cb) { }, 0xa214: { 'name': 'SubjectLocation', - 'description': function(value) { + 'description': function description(value) { return "X: " + value[0] + ", Y: " + value[1]; } }, 0xa215: 'ExposureIndex', 0xa217: { 'name': 'SensingMethod', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 1: return 'Undefined'; @@ -1000,7 +1035,7 @@ function infoBuffer(buf, cb) { }, 0xa300: { 'name': 'FileSource', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 3: return 'DSC'; @@ -1011,7 +1046,7 @@ function infoBuffer(buf, cb) { }, 0xa301: { 'name': 'SceneType', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 1: return 'A directly photographed image'; @@ -1022,13 +1057,13 @@ function infoBuffer(buf, cb) { }, 0xa302: { 'name': 'CFAPattern', - 'description': function(value) { + 'description': function description(value) { return '[Raw CFA pattern table data]'; } }, 0xa401: { 'name': 'CustomRendered', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'Normal process'; @@ -1041,7 +1076,7 @@ function infoBuffer(buf, cb) { }, 0xa402: { 'name': 'ExposureMode', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'Auto exposure'; @@ -1056,7 +1091,7 @@ function infoBuffer(buf, cb) { }, 0xa403: { 'name': 'WhiteBalance', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'Auto white balance'; @@ -1069,7 +1104,7 @@ function infoBuffer(buf, cb) { }, 0xa404: { 'name': 'DigitalZoomRatio', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'Digital zoom was not used'; @@ -1080,7 +1115,7 @@ function infoBuffer(buf, cb) { }, 0xa405: { 'name': 'FocalLengthIn35mmFilm', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'Unknown'; @@ -1091,7 +1126,7 @@ function infoBuffer(buf, cb) { }, 0xa406: { 'name': 'SceneCaptureType', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'Standard'; @@ -1108,7 +1143,7 @@ function infoBuffer(buf, cb) { }, 0xa407: { 'name': 'GainControl', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'None'; @@ -1127,7 +1162,7 @@ function infoBuffer(buf, cb) { }, 0xa408: { 'name': 'Contrast', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'Normal'; @@ -1142,7 +1177,7 @@ function infoBuffer(buf, cb) { }, 0xa409: { 'name': 'Saturation', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'Normal'; @@ -1157,7 +1192,7 @@ function infoBuffer(buf, cb) { }, 0xa40a: { 'name': 'Sharpness', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'Normal'; @@ -1172,13 +1207,13 @@ function infoBuffer(buf, cb) { }, 0xa40b: { 'name': 'DeviceSettingDescription', - 'description': function(value) { + 'description': function description(value) { return '[Raw device settings table data]'; } }, 0xa40c: { 'name': 'SubjectDistanceRange', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 1: return 'Macro'; @@ -1196,10 +1231,10 @@ function infoBuffer(buf, cb) { 'gps': { 0x0000: { 'name': 'GPSVersionID', - 'description': function(value) { + 'description': function description(value) { var _ref, _ref1; - if ((value[0] === (_ref = value[1]) && _ref === 2) && (value[2] === (_ref1 = value[3]) && _ref1 === 0)) { + if (value[0] === (_ref = value[1]) && _ref === 2 && value[2] === (_ref1 = value[3]) && _ref1 === 0) { return 'Version 2.2'; } else { return 'Unknown'; @@ -1208,7 +1243,7 @@ function infoBuffer(buf, cb) { }, 0x0001: { 'name': 'GPSLatitudeRef', - 'description': function(value) { + 'description': function description(value) { switch (value.join('')) { case 'N': return 'North latitude'; @@ -1221,13 +1256,13 @@ function infoBuffer(buf, cb) { }, 0x0002: { 'name': 'GPSLatitude', - 'description': function(value) { + 'description': function description(value) { return value[0] + value[1] / 60 + value[2] / 3600; } }, 0x0003: { 'name': 'GPSLongitudeRef', - 'description': function(value) { + 'description': function description(value) { switch (value.join('')) { case 'E': return 'East longitude'; @@ -1240,13 +1275,13 @@ function infoBuffer(buf, cb) { }, 0x0004: { 'name': 'GPSLongitude', - 'description': function(value) { + 'description': function description(value) { return value[0] + value[1] / 60 + value[2] / 3600; } }, 0x0005: { 'name': 'GPSAltitudeRef', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'Sea level'; @@ -1259,19 +1294,19 @@ function infoBuffer(buf, cb) { }, 0x0006: { 'name': 'GPSAltitude', - 'description': function(value) { + 'description': function description(value) { return value + ' m'; } }, 0x0007: { 'name': 'GPSTimeStamp', - 'description': function(value) { + 'description': function description(value) { var padZero; - padZero = function(num) { + padZero = function padZero(num) { var i; - return ((function() { + return function () { var _i, _ref, _results; _results = []; @@ -1279,7 +1314,7 @@ function infoBuffer(buf, cb) { _results.push('0'); } return _results; - })()) + num; + }() + num; }; return value.map(padZero).join(':'); } @@ -1287,7 +1322,7 @@ function infoBuffer(buf, cb) { 0x0008: 'GPSSatellites', 0x0009: { 'name': 'GPSStatus', - 'description': function(value) { + 'description': function description(value) { switch (value.join('')) { case 'A': return 'Measurement in progress'; @@ -1300,7 +1335,7 @@ function infoBuffer(buf, cb) { }, 0x000a: { 'name': 'GPSMeasureMode', - 'description': function(value) { + 'description': function description(value) { switch (value.join('')) { case '2': return '2-dimensional measurement'; @@ -1314,7 +1349,7 @@ function infoBuffer(buf, cb) { 0x000b: 'GPSDOP', 0x000c: { 'name': 'GPSSpeedRef', - 'description': function(value) { + 'description': function description(value) { switch (value.join('')) { case 'K': return 'Kilometers per hour'; @@ -1330,7 +1365,7 @@ function infoBuffer(buf, cb) { 0x000d: 'GPSSpeed', 0x000e: { 'name': 'GPSTrackRef', - 'description': function(value) { + 'description': function description(value) { switch (value.join('')) { case 'T': return 'True direction'; @@ -1344,7 +1379,7 @@ function infoBuffer(buf, cb) { 0x000f: 'GPSTrack', 0x0010: { 'name': 'GPSImgDirectionRef', - 'description': function(value) { + 'description': function description(value) { switch (value.join('')) { case 'T': return 'True direction'; @@ -1359,7 +1394,7 @@ function infoBuffer(buf, cb) { 0x0012: 'GPSMapDatum', 0x0013: { 'name': 'GPSDestLatitudeRef', - 'description': function(value) { + 'description': function description(value) { switch (value.join('')) { case 'N': return 'North latitude'; @@ -1372,13 +1407,13 @@ function infoBuffer(buf, cb) { }, 0x0014: { 'name': 'GPSDestLatitude', - 'description': function(value) { + 'description': function description(value) { return value[0] + value[1] / 60 + value[2] / 3600; } }, 0x0015: { 'name': 'GPSDestLongitudeRef', - 'description': function(value) { + 'description': function description(value) { switch (value.join('')) { case 'E': return 'East longitude'; @@ -1391,13 +1426,13 @@ function infoBuffer(buf, cb) { }, 0x0016: { 'name': 'GPSDestLongitude', - 'description': function(value) { + 'description': function description(value) { return value[0] + value[1] / 60 + value[2] / 3600; } }, 0x0017: { 'name': 'GPSDestBearingRef', - 'description': function(value) { + 'description': function description(value) { switch (value.join('')) { case 'T': return 'True direction'; @@ -1411,7 +1446,7 @@ function infoBuffer(buf, cb) { 0x0018: 'GPSDestBearing', 0x0019: { 'name': 'GPSDestDistanceRef', - 'description': function(value) { + 'description': function description(value) { switch (value.join('')) { case 'K': return 'Kilometers'; @@ -1427,15 +1462,15 @@ function infoBuffer(buf, cb) { 0x001a: 'GPSDestDistance', 0x001b: { 'name': 'GPSProcessingMethod', - 'description': function(value) { + 'description': function description(value) { if (value === 0) { return 'Undefined'; } else { - switch (value.slice(0, 8).map(function(charCode) { - return String.fromCharCode(charCode); - }).join('')) { + switch (value.slice(0, 8).map(function (charCode) { + return String.fromCharCode(charCode); + }).join('')) { case 'ASCII\x00\x00\x00': - return value.slice(8, value.length).map(function(charCode) { + return value.slice(8, value.length).map(function (charCode) { return String.fromCharCode(charCode); }).join(''); case 'JIS\x00\x00\x00\x00\x00': @@ -1450,15 +1485,15 @@ function infoBuffer(buf, cb) { }, 0x001c: { 'name': 'GPSAreaInformation', - 'description': function(value) { + 'description': function description(value) { if (value === 0) { return 'Undefined'; } else { - switch (value.slice(0, 8).map(function(charCode) { - return String.fromCharCode(charCode); - }).join('')) { + switch (value.slice(0, 8).map(function (charCode) { + return String.fromCharCode(charCode); + }).join('')) { case 'ASCII\x00\x00\x00': - return value.slice(8, value.length).map(function(charCode) { + return value.slice(8, value.length).map(function (charCode) { return String.fromCharCode(charCode); }).join(''); case 'JIS\x00\x00\x00\x00\x00': @@ -1474,7 +1509,7 @@ function infoBuffer(buf, cb) { 0x001d: 'GPSDateStamp', 0x001e: { 'name': 'GPSDifferential', - 'description': function(value) { + 'description': function description(value) { switch (value) { case 0: return 'Measurement without differential correction'; @@ -1503,8 +1538,7 @@ function infoBuffer(buf, cb) { # otherwise throws "Undefined". */ - - ExifReader.prototype.getTagValue = function(name) { + ExifReader.prototype.getTagValue = function (name) { if (this._tags[name] != null) { return this._tags[name].value; } else { @@ -1521,8 +1555,7 @@ function infoBuffer(buf, cb) { # otherwise throws "Undefined". */ - - ExifReader.prototype.getTagDescription = function(name) { + ExifReader.prototype.getTagDescription = function (name) { if (this._tags[name] != null) { return this._tags[name].description; } else { @@ -1536,8 +1569,7 @@ function infoBuffer(buf, cb) { # Returns the image's tags as an associative array: name -> description. */ - - ExifReader.prototype.getAllTags = function() { + ExifReader.prototype.getAllTags = function () { return this._tags; }; @@ -1550,18 +1582,17 @@ function infoBuffer(buf, cb) { # E.g., the MakerNote tag can be really large. */ - - ExifReader.prototype.deleteTag = function(name) { + ExifReader.prototype.deleteTag = function (name) { return delete this._tags[name]; }; return ExifReader; - - })(); - -}).call(this); + }(); +}).call(undefined); },{}],3:[function(require,module,exports){ +"use strict"; + /* Copyright (c) 2008, Adobe Systems Incorporated All rights reserved. @@ -1604,7 +1635,7 @@ Basic GUI blocking jpeg encoder //}; function JPEGEncoder(quality) { - var self = this; + var self = this; var fround = Math.round; var ffloor = Math.floor; var YTable = new Array(64); @@ -1615,7 +1646,7 @@ function JPEGEncoder(quality) { var UVDC_HT; var YAC_HT; var UVAC_HT; - + var bitcode = new Array(65535); var category = new Array(65535); var outputfDCTQuant = new Array(64); @@ -1623,698 +1654,604 @@ function JPEGEncoder(quality) { var byteout = []; var bytenew = 0; var bytepos = 7; - + var YDU = new Array(64); var UDU = new Array(64); var VDU = new Array(64); var clt = new Array(256); var RGB_YUV_TABLE = new Array(2048); var currentQuality; - - var ZigZag = [ - 0, 1, 5, 6,14,15,27,28, - 2, 4, 7,13,16,26,29,42, - 3, 8,12,17,25,30,41,43, - 9,11,18,24,31,40,44,53, - 10,19,23,32,39,45,52,54, - 20,22,33,38,46,51,55,60, - 21,34,37,47,50,56,59,61, - 35,36,48,49,57,58,62,63 - ]; - - var std_dc_luminance_nrcodes = [0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0]; - var std_dc_luminance_values = [0,1,2,3,4,5,6,7,8,9,10,11]; - var std_ac_luminance_nrcodes = [0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d]; - var std_ac_luminance_values = [ - 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12, - 0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07, - 0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, - 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0, - 0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16, - 0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, - 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39, - 0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49, - 0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, - 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69, - 0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79, - 0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, - 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98, - 0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7, - 0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, - 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5, - 0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4, - 0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, - 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea, - 0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8, - 0xf9,0xfa - ]; - - var std_dc_chrominance_nrcodes = [0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0]; - var std_dc_chrominance_values = [0,1,2,3,4,5,6,7,8,9,10,11]; - var std_ac_chrominance_nrcodes = [0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77]; - var std_ac_chrominance_values = [ - 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21, - 0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71, - 0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, - 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0, - 0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34, - 0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, - 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38, - 0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48, - 0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, - 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68, - 0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78, - 0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, - 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96, - 0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5, - 0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, - 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3, - 0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2, - 0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, - 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9, - 0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8, - 0xf9,0xfa - ]; - - function initQuantTables(sf){ - var YQT = [ - 16, 11, 10, 16, 24, 40, 51, 61, - 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, - 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 56, 68,109,103, 77, - 24, 35, 55, 64, 81,104,113, 92, - 49, 64, 78, 87,103,121,120,101, - 72, 92, 95, 98,112,100,103, 99 - ]; - - for (var i = 0; i < 64; i++) { - var t = ffloor((YQT[i]*sf+50)/100); - if (t < 1) { - t = 1; - } else if (t > 255) { - t = 255; - } - YTable[ZigZag[i]] = t; - } - var UVQT = [ - 17, 18, 24, 47, 99, 99, 99, 99, - 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, - 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 - ]; - for (var j = 0; j < 64; j++) { - var u = ffloor((UVQT[j]*sf+50)/100); - if (u < 1) { - u = 1; - } else if (u > 255) { - u = 255; - } - UVTable[ZigZag[j]] = u; - } - var aasf = [ - 1.0, 1.387039845, 1.306562965, 1.175875602, - 1.0, 0.785694958, 0.541196100, 0.275899379 - ]; - var k = 0; - for (var row = 0; row < 8; row++) - { - for (var col = 0; col < 8; col++) - { - fdtbl_Y[k] = (1.0 / (YTable [ZigZag[k]] * aasf[row] * aasf[col] * 8.0)); - fdtbl_UV[k] = (1.0 / (UVTable[ZigZag[k]] * aasf[row] * aasf[col] * 8.0)); - k++; - } + + var ZigZag = [0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63]; + + var std_dc_luminance_nrcodes = [0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]; + var std_dc_luminance_values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + var std_ac_luminance_nrcodes = [0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d]; + var std_ac_luminance_values = [0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa]; + + var std_dc_chrominance_nrcodes = [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]; + var std_dc_chrominance_values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + var std_ac_chrominance_nrcodes = [0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77]; + var std_ac_chrominance_values = [0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa]; + + function initQuantTables(sf) { + var YQT = [16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, 14, 17, 22, 29, 51, 87, 80, 62, 18, 22, 37, 56, 68, 109, 103, 77, 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, 103, 121, 120, 101, 72, 92, 95, 98, 112, 100, 103, 99]; + + for (var i = 0; i < 64; i++) { + var t = ffloor((YQT[i] * sf + 50) / 100); + if (t < 1) { + t = 1; + } else if (t > 255) { + t = 255; } + YTable[ZigZag[i]] = t; } - - function computeHuffmanTbl(nrcodes, std_table){ - var codevalue = 0; - var pos_in_table = 0; - var HT = new Array(); - for (var k = 1; k <= 16; k++) { - for (var j = 1; j <= nrcodes[k]; j++) { - HT[std_table[pos_in_table]] = []; - HT[std_table[pos_in_table]][0] = codevalue; - HT[std_table[pos_in_table]][1] = k; - pos_in_table++; - codevalue++; - } - codevalue*=2; + var UVQT = [17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99, 47, 66, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99]; + for (var j = 0; j < 64; j++) { + var u = ffloor((UVQT[j] * sf + 50) / 100); + if (u < 1) { + u = 1; + } else if (u > 255) { + u = 255; } - return HT; + UVTable[ZigZag[j]] = u; } - - function initHuffmanTbl() - { - YDC_HT = computeHuffmanTbl(std_dc_luminance_nrcodes,std_dc_luminance_values); - UVDC_HT = computeHuffmanTbl(std_dc_chrominance_nrcodes,std_dc_chrominance_values); - YAC_HT = computeHuffmanTbl(std_ac_luminance_nrcodes,std_ac_luminance_values); - UVAC_HT = computeHuffmanTbl(std_ac_chrominance_nrcodes,std_ac_chrominance_values); + var aasf = [1.0, 1.387039845, 1.306562965, 1.175875602, 1.0, 0.785694958, 0.541196100, 0.275899379]; + var k = 0; + for (var row = 0; row < 8; row++) { + for (var col = 0; col < 8; col++) { + fdtbl_Y[k] = 1.0 / (YTable[ZigZag[k]] * aasf[row] * aasf[col] * 8.0); + fdtbl_UV[k] = 1.0 / (UVTable[ZigZag[k]] * aasf[row] * aasf[col] * 8.0); + k++; + } } - - function initCategoryNumber() - { - var nrlower = 1; - var nrupper = 2; - for (var cat = 1; cat <= 15; cat++) { - //Positive numbers - for (var nr = nrlower; nr>0] = 38470 * i; - RGB_YUV_TABLE[(i+ 512)>>0] = 7471 * i + 0x8000; - RGB_YUV_TABLE[(i+ 768)>>0] = -11059 * i; - RGB_YUV_TABLE[(i+1024)>>0] = -21709 * i; - RGB_YUV_TABLE[(i+1280)>>0] = 32768 * i + 0x807FFF; - RGB_YUV_TABLE[(i+1536)>>0] = -27439 * i; - RGB_YUV_TABLE[(i+1792)>>0] = - 5329 * i; + return HT; + } + + function initHuffmanTbl() { + YDC_HT = computeHuffmanTbl(std_dc_luminance_nrcodes, std_dc_luminance_values); + UVDC_HT = computeHuffmanTbl(std_dc_chrominance_nrcodes, std_dc_chrominance_values); + YAC_HT = computeHuffmanTbl(std_ac_luminance_nrcodes, std_ac_luminance_values); + UVAC_HT = computeHuffmanTbl(std_ac_chrominance_nrcodes, std_ac_chrominance_values); + } + + function initCategoryNumber() { + var nrlower = 1; + var nrupper = 2; + for (var cat = 1; cat <= 15; cat++) { + //Positive numbers + for (var nr = nrlower; nr < nrupper; nr++) { + category[32767 + nr] = cat; + bitcode[32767 + nr] = []; + bitcode[32767 + nr][1] = cat; + bitcode[32767 + nr][0] = nr; + } + //Negative numbers + for (var nrneg = -(nrupper - 1); nrneg <= -nrlower; nrneg++) { + category[32767 + nrneg] = cat; + bitcode[32767 + nrneg] = []; + bitcode[32767 + nrneg][1] = cat; + bitcode[32767 + nrneg][0] = nrupper - 1 + nrneg; } + nrlower <<= 1; + nrupper <<= 1; } - - // IO functions - function writeBits(bs) - { - var value = bs[0]; - var posval = bs[1]-1; - while ( posval >= 0 ) { - if (value & (1 << posval) ) { - bytenew |= (1 << bytepos); - } - posval--; - bytepos--; - if (bytepos < 0) { - if (bytenew == 0xFF) { - writeByte(0xFF); - writeByte(0); - } - else { - writeByte(bytenew); - } - bytepos=7; - bytenew=0; + } + + function initRGBYUVTable() { + for (var i = 0; i < 256; i++) { + RGB_YUV_TABLE[i] = 19595 * i; + RGB_YUV_TABLE[i + 256 >> 0] = 38470 * i; + RGB_YUV_TABLE[i + 512 >> 0] = 7471 * i + 0x8000; + RGB_YUV_TABLE[i + 768 >> 0] = -11059 * i; + RGB_YUV_TABLE[i + 1024 >> 0] = -21709 * i; + RGB_YUV_TABLE[i + 1280 >> 0] = 32768 * i + 0x807FFF; + RGB_YUV_TABLE[i + 1536 >> 0] = -27439 * i; + RGB_YUV_TABLE[i + 1792 >> 0] = -5329 * i; + } + } + + // IO functions + function writeBits(bs) { + var value = bs[0]; + var posval = bs[1] - 1; + while (posval >= 0) { + if (value & 1 << posval) { + bytenew |= 1 << bytepos; + } + posval--; + bytepos--; + if (bytepos < 0) { + if (bytenew == 0xFF) { + writeByte(0xFF); + writeByte(0); + } else { + writeByte(bytenew); } + bytepos = 7; + bytenew = 0; } } - - function writeByte(value) - { - //byteout.push(clt[value]); // write char directly instead of converting later - byteout.push(value); + } + + function writeByte(value) { + //byteout.push(clt[value]); // write char directly instead of converting later + byteout.push(value); + } + + function writeWord(value) { + writeByte(value >> 8 & 0xFF); + writeByte(value & 0xFF); + } + + // DCT & quantization core + function fDCTQuant(data, fdtbl) { + var d0, d1, d2, d3, d4, d5, d6, d7; + /* Pass 1: process rows. */ + var dataOff = 0; + var i; + var I8 = 8; + var I64 = 64; + for (i = 0; i < I8; ++i) { + d0 = data[dataOff]; + d1 = data[dataOff + 1]; + d2 = data[dataOff + 2]; + d3 = data[dataOff + 3]; + d4 = data[dataOff + 4]; + d5 = data[dataOff + 5]; + d6 = data[dataOff + 6]; + d7 = data[dataOff + 7]; + + var tmp0 = d0 + d7; + var tmp7 = d0 - d7; + var tmp1 = d1 + d6; + var tmp6 = d1 - d6; + var tmp2 = d2 + d5; + var tmp5 = d2 - d5; + var tmp3 = d3 + d4; + var tmp4 = d3 - d4; + + /* Even part */ + var tmp10 = tmp0 + tmp3; /* phase 2 */ + var tmp13 = tmp0 - tmp3; + var tmp11 = tmp1 + tmp2; + var tmp12 = tmp1 - tmp2; + + data[dataOff] = tmp10 + tmp11; /* phase 3 */ + data[dataOff + 4] = tmp10 - tmp11; + + var z1 = (tmp12 + tmp13) * 0.707106781; /* c4 */ + data[dataOff + 2] = tmp13 + z1; /* phase 5 */ + data[dataOff + 6] = tmp13 - z1; + + /* Odd part */ + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + var z5 = (tmp10 - tmp12) * 0.382683433; /* c6 */ + var z2 = 0.541196100 * tmp10 + z5; /* c2-c6 */ + var z4 = 1.306562965 * tmp12 + z5; /* c2+c6 */ + var z3 = tmp11 * 0.707106781; /* c4 */ + + var z11 = tmp7 + z3; /* phase 5 */ + var z13 = tmp7 - z3; + + data[dataOff + 5] = z13 + z2; /* phase 6 */ + data[dataOff + 3] = z13 - z2; + data[dataOff + 1] = z11 + z4; + data[dataOff + 7] = z11 - z4; + + dataOff += 8; /* advance pointer to next row */ } - - function writeWord(value) - { - writeByte((value>>8)&0xFF); - writeByte((value )&0xFF); + + /* Pass 2: process columns. */ + dataOff = 0; + for (i = 0; i < I8; ++i) { + d0 = data[dataOff]; + d1 = data[dataOff + 8]; + d2 = data[dataOff + 16]; + d3 = data[dataOff + 24]; + d4 = data[dataOff + 32]; + d5 = data[dataOff + 40]; + d6 = data[dataOff + 48]; + d7 = data[dataOff + 56]; + + var tmp0p2 = d0 + d7; + var tmp7p2 = d0 - d7; + var tmp1p2 = d1 + d6; + var tmp6p2 = d1 - d6; + var tmp2p2 = d2 + d5; + var tmp5p2 = d2 - d5; + var tmp3p2 = d3 + d4; + var tmp4p2 = d3 - d4; + + /* Even part */ + var tmp10p2 = tmp0p2 + tmp3p2; /* phase 2 */ + var tmp13p2 = tmp0p2 - tmp3p2; + var tmp11p2 = tmp1p2 + tmp2p2; + var tmp12p2 = tmp1p2 - tmp2p2; + + data[dataOff] = tmp10p2 + tmp11p2; /* phase 3 */ + data[dataOff + 32] = tmp10p2 - tmp11p2; + + var z1p2 = (tmp12p2 + tmp13p2) * 0.707106781; /* c4 */ + data[dataOff + 16] = tmp13p2 + z1p2; /* phase 5 */ + data[dataOff + 48] = tmp13p2 - z1p2; + + /* Odd part */ + tmp10p2 = tmp4p2 + tmp5p2; /* phase 2 */ + tmp11p2 = tmp5p2 + tmp6p2; + tmp12p2 = tmp6p2 + tmp7p2; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + var z5p2 = (tmp10p2 - tmp12p2) * 0.382683433; /* c6 */ + var z2p2 = 0.541196100 * tmp10p2 + z5p2; /* c2-c6 */ + var z4p2 = 1.306562965 * tmp12p2 + z5p2; /* c2+c6 */ + var z3p2 = tmp11p2 * 0.707106781; /* c4 */ + + var z11p2 = tmp7p2 + z3p2; /* phase 5 */ + var z13p2 = tmp7p2 - z3p2; + + data[dataOff + 40] = z13p2 + z2p2; /* phase 6 */ + data[dataOff + 24] = z13p2 - z2p2; + data[dataOff + 8] = z11p2 + z4p2; + data[dataOff + 56] = z11p2 - z4p2; + + dataOff++; /* advance pointer to next column */ } - - // DCT & quantization core - function fDCTQuant(data, fdtbl) - { - var d0, d1, d2, d3, d4, d5, d6, d7; - /* Pass 1: process rows. */ - var dataOff=0; - var i; - var I8 = 8; - var I64 = 64; - for (i=0; i 0.0) ? ((fDCTQuant + 0.5)|0) : ((fDCTQuant - 0.5)|0); - //outputfDCTQuant[i] = fround(fDCTQuant); - } - return outputfDCTQuant; + // Quantize/descale the coefficients + var fDCTQuant; + for (i = 0; i < I64; ++i) { + // Apply the quantization and scaling factor & Round to nearest integer + fDCTQuant = data[i] * fdtbl[i]; + outputfDCTQuant[i] = fDCTQuant > 0.0 ? fDCTQuant + 0.5 | 0 : fDCTQuant - 0.5 | 0; + //outputfDCTQuant[i] = fround(fDCTQuant); } - - function writeAPP0() - { - writeWord(0xFFE0); // marker - writeWord(16); // length - writeByte(0x4A); // J - writeByte(0x46); // F - writeByte(0x49); // I - writeByte(0x46); // F - writeByte(0); // = "JFIF",'\0' - writeByte(1); // versionhi - writeByte(1); // versionlo - writeByte(0); // xyunits - writeWord(1); // xdensity - writeWord(1); // ydensity - writeByte(0); // thumbnwidth - writeByte(0); // thumbnheight + return outputfDCTQuant; + } + + function writeAPP0() { + writeWord(0xFFE0); // marker + writeWord(16); // length + writeByte(0x4A); // J + writeByte(0x46); // F + writeByte(0x49); // I + writeByte(0x46); // F + writeByte(0); // = "JFIF",'\0' + writeByte(1); // versionhi + writeByte(1); // versionlo + writeByte(0); // xyunits + writeWord(1); // xdensity + writeWord(1); // ydensity + writeByte(0); // thumbnwidth + writeByte(0); // thumbnheight + } + + function writeSOF0(width, height) { + writeWord(0xFFC0); // marker + writeWord(17); // length, truecolor YUV JPG + writeByte(8); // precision + writeWord(height); + writeWord(width); + writeByte(3); // nrofcomponents + writeByte(1); // IdY + writeByte(0x11); // HVY + writeByte(0); // QTY + writeByte(2); // IdU + writeByte(0x11); // HVU + writeByte(1); // QTU + writeByte(3); // IdV + writeByte(0x11); // HVV + writeByte(1); // QTV + } + + function writeDQT() { + writeWord(0xFFDB); // marker + writeWord(132); // length + writeByte(0); + for (var i = 0; i < 64; i++) { + writeByte(YTable[i]); } - - function writeSOF0(width, height) - { - writeWord(0xFFC0); // marker - writeWord(17); // length, truecolor YUV JPG - writeByte(8); // precision - writeWord(height); - writeWord(width); - writeByte(3); // nrofcomponents - writeByte(1); // IdY - writeByte(0x11); // HVY - writeByte(0); // QTY - writeByte(2); // IdU - writeByte(0x11); // HVU - writeByte(1); // QTU - writeByte(3); // IdV - writeByte(0x11); // HVV - writeByte(1); // QTV + writeByte(1); + for (var j = 0; j < 64; j++) { + writeByte(UVTable[j]); } - - function writeDQT() - { - writeWord(0xFFDB); // marker - writeWord(132); // length - writeByte(0); - for (var i=0; i<64; i++) { - writeByte(YTable[i]); - } - writeByte(1); - for (var j=0; j<64; j++) { - writeByte(UVTable[j]); - } + } + + function writeDHT() { + writeWord(0xFFC4); // marker + writeWord(0x01A2); // length + + writeByte(0); // HTYDCinfo + for (var i = 0; i < 16; i++) { + writeByte(std_dc_luminance_nrcodes[i + 1]); } - - function writeDHT() - { - writeWord(0xFFC4); // marker - writeWord(0x01A2); // length - - writeByte(0); // HTYDCinfo - for (var i=0; i<16; i++) { - writeByte(std_dc_luminance_nrcodes[i+1]); - } - for (var j=0; j<=11; j++) { - writeByte(std_dc_luminance_values[j]); - } - - writeByte(0x10); // HTYACinfo - for (var k=0; k<16; k++) { - writeByte(std_ac_luminance_nrcodes[k+1]); - } - for (var l=0; l<=161; l++) { - writeByte(std_ac_luminance_values[l]); - } - - writeByte(1); // HTUDCinfo - for (var m=0; m<16; m++) { - writeByte(std_dc_chrominance_nrcodes[m+1]); - } - for (var n=0; n<=11; n++) { - writeByte(std_dc_chrominance_values[n]); - } - - writeByte(0x11); // HTUACinfo - for (var o=0; o<16; o++) { - writeByte(std_ac_chrominance_nrcodes[o+1]); - } - for (var p=0; p<=161; p++) { - writeByte(std_ac_chrominance_values[p]); - } + for (var j = 0; j <= 11; j++) { + writeByte(std_dc_luminance_values[j]); } - - function writeSOS() - { - writeWord(0xFFDA); // marker - writeWord(12); // length - writeByte(3); // nrofcomponents - writeByte(1); // IdY - writeByte(0); // HTY - writeByte(2); // IdU - writeByte(0x11); // HTU - writeByte(3); // IdV - writeByte(0x11); // HTV - writeByte(0); // Ss - writeByte(0x3f); // Se - writeByte(0); // Bf + + writeByte(0x10); // HTYACinfo + for (var k = 0; k < 16; k++) { + writeByte(std_ac_luminance_nrcodes[k + 1]); } - - function processDU(CDU, fdtbl, DC, HTDC, HTAC){ - var EOB = HTAC[0x00]; - var M16zeroes = HTAC[0xF0]; - var pos; - var I16 = 16; - var I63 = 63; - var I64 = 64; - var DU_DCT = fDCTQuant(CDU, fdtbl); - //ZigZag reorder - for (var j=0;j0)&&(DU[end0pos]==0); end0pos--) {}; - //end0pos = first element in reverse order !=0 - if ( end0pos == 0) { - writeBits(EOB); - return DC; - } - var i = 1; - var lng; - while ( i <= end0pos ) { - var startpos = i; - for (; (DU[i]==0) && (i<=end0pos); ++i) {} - var nrzeroes = i-startpos; - if ( nrzeroes >= I16 ) { - lng = nrzeroes>>4; - for (var nrmarker=1; nrmarker <= lng; ++nrmarker) - writeBits(M16zeroes); - nrzeroes = nrzeroes&0xF; - } - pos = 32767+DU[i]; - writeBits(HTAC[(nrzeroes<<4)+category[pos]]); - writeBits(bitcode[pos]); - i++; - } - if ( end0pos != I63 ) { - writeBits(EOB); - } - return DC; + for (var l = 0; l <= 161; l++) { + writeByte(std_ac_luminance_values[l]); + } + + writeByte(1); // HTUDCinfo + for (var m = 0; m < 16; m++) { + writeByte(std_dc_chrominance_nrcodes[m + 1]); } + for (var n = 0; n <= 11; n++) { + writeByte(std_dc_chrominance_values[n]); + } + + writeByte(0x11); // HTUACinfo + for (var o = 0; o < 16; o++) { + writeByte(std_ac_chrominance_nrcodes[o + 1]); + } + for (var p = 0; p <= 161; p++) { + writeByte(std_ac_chrominance_values[p]); + } + } + + function writeSOS() { + writeWord(0xFFDA); // marker + writeWord(12); // length + writeByte(3); // nrofcomponents + writeByte(1); // IdY + writeByte(0); // HTY + writeByte(2); // IdU + writeByte(0x11); // HTU + writeByte(3); // IdV + writeByte(0x11); // HTV + writeByte(0); // Ss + writeByte(0x3f); // Se + writeByte(0); // Bf + } - function initCharLookupTable(){ - var sfcc = String.fromCharCode; - for(var i=0; i < 256; i++){ ///// ACHTUNG // 255 - clt[i] = sfcc(i); + function processDU(CDU, fdtbl, DC, HTDC, HTAC) { + var EOB = HTAC[0x00]; + var M16zeroes = HTAC[0xF0]; + var pos; + var I16 = 16; + var I63 = 63; + var I64 = 64; + var DU_DCT = fDCTQuant(CDU, fdtbl); + //ZigZag reorder + for (var j = 0; j < I64; ++j) { + DU[ZigZag[j]] = DU_DCT[j]; + } + var Diff = DU[0] - DC;DC = DU[0]; + //Encode DC + if (Diff == 0) { + writeBits(HTDC[0]); // Diff might be 0 + } else { + pos = 32767 + Diff; + writeBits(HTDC[category[pos]]); + writeBits(bitcode[pos]); + } + //Encode ACs + var end0pos = 63; // was const... which is crazy + for (; end0pos > 0 && DU[end0pos] == 0; end0pos--) {}; + //end0pos = first element in reverse order !=0 + if (end0pos == 0) { + writeBits(EOB); + return DC; + } + var i = 1; + var lng; + while (i <= end0pos) { + var startpos = i; + for (; DU[i] == 0 && i <= end0pos; ++i) {} + var nrzeroes = i - startpos; + if (nrzeroes >= I16) { + lng = nrzeroes >> 4; + for (var nrmarker = 1; nrmarker <= lng; ++nrmarker) { + writeBits(M16zeroes); + }nrzeroes = nrzeroes & 0xF; } + pos = 32767 + DU[i]; + writeBits(HTAC[(nrzeroes << 4) + category[pos]]); + writeBits(bitcode[pos]); + i++; } - - this.encode = function(image,quality) // image data object - { - var time_start = new Date().getTime(); - - if(quality) setQuality(quality); - - // Initialize bit writer - byteout = new Array(); - bytenew=0; - bytepos=7; - - // Add JPEG headers - writeWord(0xFFD8); // SOI - writeAPP0(); - writeDQT(); - writeSOF0(image.width,image.height); - writeDHT(); - writeSOS(); + if (end0pos != I63) { + writeBits(EOB); + } + return DC; + } - - // Encode 8x8 macroblocks - var DCY=0; - var DCU=0; - var DCV=0; - - bytenew=0; - bytepos=7; - - - this.encode.displayName = "_encode_"; - - var imageData = image.data; - var width = image.width; - var height = image.height; - - var quadWidth = width*4; - var tripleWidth = width*3; - - var x, y = 0; - var r, g, b; - var start,p, col,row,pos; - while(y < height){ - x = 0; - while(x < quadWidth){ + function initCharLookupTable() { + var sfcc = String.fromCharCode; + for (var i = 0; i < 256; i++) { + ///// ACHTUNG // 255 + clt[i] = sfcc(i); + } + } + + this.encode = function (image, quality) // image data object + { + var time_start = new Date().getTime(); + + if (quality) setQuality(quality); + + // Initialize bit writer + byteout = new Array(); + bytenew = 0; + bytepos = 7; + + // Add JPEG headers + writeWord(0xFFD8); // SOI + writeAPP0(); + writeDQT(); + writeSOF0(image.width, image.height); + writeDHT(); + writeSOS(); + + // Encode 8x8 macroblocks + var DCY = 0; + var DCU = 0; + var DCV = 0; + + bytenew = 0; + bytepos = 7; + + this.encode.displayName = "_encode_"; + + var imageData = image.data; + var width = image.width; + var height = image.height; + + var quadWidth = width * 4; + var tripleWidth = width * 3; + + var x, + y = 0; + var r, g, b; + var start, p, col, row, pos; + while (y < height) { + x = 0; + while (x < quadWidth) { start = quadWidth * y + x; p = start; col = -1; row = 0; - - for(pos=0; pos < 64; pos++){ - row = pos >> 3;// /8 - col = ( pos & 7 ) * 4; // %8 - p = start + ( row * quadWidth ) + col; - - if(y+row >= height){ // padding bottom - p-= (quadWidth*(y+1+row-height)); + + for (pos = 0; pos < 64; pos++) { + row = pos >> 3; // /8 + col = (pos & 7) * 4; // %8 + p = start + row * quadWidth + col; + + if (y + row >= height) { + // padding bottom + p -= quadWidth * (y + 1 + row - height); } - if(x+col >= quadWidth){ // padding right - p-= ((x+col) - quadWidth +4) + if (x + col >= quadWidth) { + // padding right + p -= x + col - quadWidth + 4; } - - r = imageData[ p++ ]; - g = imageData[ p++ ]; - b = imageData[ p++ ]; - - + + r = imageData[p++]; + g = imageData[p++]; + b = imageData[p++]; + /* // calculate YUV values dynamically - YDU[pos]=((( 0.29900)*r+( 0.58700)*g+( 0.11400)*b))-128; //-0x80 - UDU[pos]=(((-0.16874)*r+(-0.33126)*g+( 0.50000)*b)); - VDU[pos]=((( 0.50000)*r+(-0.41869)*g+(-0.08131)*b)); - */ - - // use lookup table (slightly faster) - YDU[pos] = ((RGB_YUV_TABLE[r] + RGB_YUV_TABLE[(g + 256)>>0] + RGB_YUV_TABLE[(b + 512)>>0]) >> 16)-128; - UDU[pos] = ((RGB_YUV_TABLE[(r + 768)>>0] + RGB_YUV_TABLE[(g + 1024)>>0] + RGB_YUV_TABLE[(b + 1280)>>0]) >> 16)-128; - VDU[pos] = ((RGB_YUV_TABLE[(r + 1280)>>0] + RGB_YUV_TABLE[(g + 1536)>>0] + RGB_YUV_TABLE[(b + 1792)>>0]) >> 16)-128; + YDU[pos]=((( 0.29900)*r+( 0.58700)*g+( 0.11400)*b))-128; //-0x80 + UDU[pos]=(((-0.16874)*r+(-0.33126)*g+( 0.50000)*b)); + VDU[pos]=((( 0.50000)*r+(-0.41869)*g+(-0.08131)*b)); + */ + // use lookup table (slightly faster) + YDU[pos] = (RGB_YUV_TABLE[r] + RGB_YUV_TABLE[g + 256 >> 0] + RGB_YUV_TABLE[b + 512 >> 0] >> 16) - 128; + UDU[pos] = (RGB_YUV_TABLE[r + 768 >> 0] + RGB_YUV_TABLE[g + 1024 >> 0] + RGB_YUV_TABLE[b + 1280 >> 0] >> 16) - 128; + VDU[pos] = (RGB_YUV_TABLE[r + 1280 >> 0] + RGB_YUV_TABLE[g + 1536 >> 0] + RGB_YUV_TABLE[b + 1792 >> 0] >> 16) - 128; } - + DCY = processDU(YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCU = processDU(UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCV = processDU(VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); - x+=32; - } - y+=8; - } - - - //////////////////////////////////////////////////////////////// - - // Do the bit alignment of the EOI marker - if ( bytepos >= 0 ) { - var fillbits = []; - fillbits[1] = bytepos+1; - fillbits[0] = (1<<(bytepos+1))-1; - writeBits(fillbits); + x += 32; } - - writeWord(0xFFD9); //EOI - - return new Uint8Array(byteout); - //return new Buffer(byteout); - // - //var jpegDataUri = 'data:image/jpeg;base64,' + btoa(byteout.join('')); - // - //byteout = []; - // - //// benchmarking - //var duration = new Date().getTime() - time_start; - ////console.log('Encoding time: '+ duration + 'ms'); - //// - // - //return jpegDataUri - } - - function setQuality(quality){ + y += 8; + } + + //////////////////////////////////////////////////////////////// + + // Do the bit alignment of the EOI marker + if (bytepos >= 0) { + var fillbits = []; + fillbits[1] = bytepos + 1; + fillbits[0] = (1 << bytepos + 1) - 1; + writeBits(fillbits); + } + + writeWord(0xFFD9); //EOI + + return new Uint8Array(byteout); + //return new Buffer(byteout); + // + //var jpegDataUri = 'data:image/jpeg;base64,' + btoa(byteout.join('')); + // + //byteout = []; + // + //// benchmarking + //var duration = new Date().getTime() - time_start; + ////console.log('Encoding time: '+ duration + 'ms'); + //// + // + //return jpegDataUri + }; + + function setQuality(quality) { if (quality <= 0) { quality = 1; } if (quality > 100) { quality = 100; } - - if(currentQuality == quality) return // don't recalc if unchanged - + + if (currentQuality == quality) return; // don't recalc if unchanged + var sf = 0; if (quality < 50) { sf = Math.floor(5000 / quality); } else { - sf = Math.floor(200 - quality*2); + sf = Math.floor(200 - quality * 2); } - + initQuantTables(sf); currentQuality = quality; //console.log('Quality set to: '+quality +'%'); } - - function init(){ + + function init() { var time_start = new Date().getTime(); - if(!quality) quality = 50; + if (!quality) quality = 50; // Create tables - initCharLookupTable() + initCharLookupTable(); initHuffmanTbl(); initCategoryNumber(); initRGBYUVTable(); - + setQuality(quality); var duration = new Date().getTime() - time_start; - //console.log('Initialization '+ duration + 'ms'); + //console.log('Initialization '+ duration + 'ms'); } - + init(); - }; module.exports = encode; function encode(imgData, qu) { - if (typeof qu === 'undefined') qu = 50; - var encoder = new JPEGEncoder(qu); + if (typeof qu === 'undefined') qu = 50; + var encoder = new JPEGEncoder(qu); var data = encoder.encode(imgData, qu); - return { - data: data, - width: imgData.width, - height: imgData.height - }; + return { + data: data, + width: imgData.width, + height: imgData.height + }; } // helper function to get the imageData of an existing image on the current page. @@ -2330,6 +2267,10 @@ function encode(imgData, qu) { //} },{}],4:[function(require,module,exports){ +"use strict"; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + /** * @license * Copyright 2015 Mozilla Foundation @@ -2360,7 +2301,7 @@ function loadURLasArrayBuffer(path, callback) { var xhr = new XMLHttpRequest(); xhr.open("GET", path, true); xhr.responseType = "arraybuffer"; - xhr.onload = function() { + xhr.onload = function () { callback(xhr.response); }; xhr.send(null); @@ -2387,30 +2328,31 @@ var JpegImage = function jpegImage() { }, load: function load(path) { this._src = path; - loadURLasArrayBuffer(path, function(buffer) { + loadURLasArrayBuffer(path, function (buffer) { this.parse(new Uint8Array(buffer)); if (this.onload) { this.onload(); } }.bind(this)); }, - parse: function(data) { + parse: function parse(data) { this._parser.parse(data); }, - getData: function(width, height) { + getData: function getData(width, height) { return this._parser.getData(width, height, false); }, copyToImageData: function copyToImageData(imageData) { if (this._parser.numComponents === 2 || this._parser.numComponents > 4) { throw new Error("Unsupported amount of components"); } - var width = imageData.width, height = imageData.height; + var width = imageData.width, + height = imageData.height; var imageDataBytes = width * height * 4; var imageDataArray = imageData.data; var i, j; if (this._parser.numComponents === 1) { var values = this._parser.getData(width, height, false); - for (i = 0, j = 0; i < imageDataBytes; ) { + for (i = 0, j = 0; i < imageDataBytes;) { var value = values[j++]; imageDataArray[i++] = value; imageDataArray[i++] = value; @@ -2420,7 +2362,7 @@ var JpegImage = function jpegImage() { return; } var rgb = this._parser.getData(width, height, true); - for (i = 0, j = 0; i < imageDataBytes; ) { + for (i = 0, j = 0; i < imageDataBytes;) { imageDataArray[i++] = rgb[j++]; imageDataArray[i++] = rgb[j++]; imageDataArray[i++] = rgb[j++]; @@ -2440,10 +2382,11 @@ module.exports = { var PDFJS; -(function(PDFJS) { +(function (PDFJS) { "use strict"; + var JpegImage = function jpegImage() { - var dctZigZag = new Uint8Array([ 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 ]); + var dctZigZag = new Uint8Array([0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63]); var dctCos1 = 4017; var dctSin1 = 799; var dctCos3 = 3406; @@ -2454,7 +2397,11 @@ var PDFJS; var dctSqrt1d2 = 2896; function constructor() {} function buildHuffmanTable(codeLengths, values) { - var k = 0, code = [], i, j, length = 16; + var k = 0, + code = [], + i, + j, + length = 16; while (length > 0 && !codeLengths[length - 1]) { length--; } @@ -2462,7 +2409,8 @@ var PDFJS; children: [], index: 0 }); - var p = code[0], q; + var p = code[0], + q; for (i = 0; i < length; i++) { for (j = 0; j < codeLengths[i]; j++) { p = code.pop(); @@ -2502,8 +2450,11 @@ var PDFJS; var scanLines = frame.scanLines; var mcusPerLine = frame.mcusPerLine; var progressive = frame.progressive; - var maxH = frame.maxH, maxV = frame.maxV; - var startOffset = offset, bitsData = 0, bitsCount = 0; + var maxH = frame.maxH, + maxV = frame.maxV; + var startOffset = offset, + bitsData = 0, + bitsCount = 0; function readBit() { if (bitsCount > 0) { bitsCount--; @@ -2526,7 +2477,7 @@ var PDFJS; if (typeof node === "number") { return node; } - if (typeof node !== "object") { + if ((typeof node === "undefined" ? "undefined" : _typeof(node)) !== "object") { throw "invalid huffman sequence"; } } @@ -2556,7 +2507,8 @@ var PDFJS; var k = 1; while (k < 64) { var rs = decodeHuffman(component.huffmanTableAC); - var s = rs & 15, r = rs >> 4; + var s = rs & 15, + r = rs >> 4; if (s === 0) { if (r < 15) { break; @@ -2584,10 +2536,12 @@ var PDFJS; eobrun--; return; } - var k = spectralStart, e = spectralEnd; + var k = spectralStart, + e = spectralEnd; while (k <= e) { var rs = decodeHuffman(component.huffmanTableAC); - var s = rs & 15, r = rs >> 4; + var s = rs & 15, + r = rs >> 4; if (s === 0) { if (r < 15) { eobrun = receive(r) + (1 << r) - 1; @@ -2602,7 +2556,8 @@ var PDFJS; k++; } } - var successiveACState = 0, successiveACNextValue; + var successiveACState = 0, + successiveACNextValue; function decodeACSuccessive(component, offset) { var k = spectralStart; var e = spectralEnd; @@ -2612,53 +2567,53 @@ var PDFJS; while (k <= e) { var z = dctZigZag[k]; switch (successiveACState) { - case 0: - rs = decodeHuffman(component.huffmanTableAC); - s = rs & 15; - r = rs >> 4; - if (s === 0) { - if (r < 15) { - eobrun = receive(r) + (1 << r); - successiveACState = 4; + case 0: + rs = decodeHuffman(component.huffmanTableAC); + s = rs & 15; + r = rs >> 4; + if (s === 0) { + if (r < 15) { + eobrun = receive(r) + (1 << r); + successiveACState = 4; + } else { + r = 16; + successiveACState = 1; + } } else { - r = 16; - successiveACState = 1; - } - } else { - if (s !== 1) { - throw "invalid ACn encoding"; + if (s !== 1) { + throw "invalid ACn encoding"; + } + successiveACNextValue = receiveAndExtend(s); + successiveACState = r ? 2 : 3; } - successiveACNextValue = receiveAndExtend(s); - successiveACState = r ? 2 : 3; - } - continue; + continue; - case 1: - case 2: - if (component.blockData[offset + z]) { - component.blockData[offset + z] += readBit() << successive; - } else { - r--; - if (r === 0) { - successiveACState = successiveACState === 2 ? 3 : 0; + case 1: + case 2: + if (component.blockData[offset + z]) { + component.blockData[offset + z] += readBit() << successive; + } else { + r--; + if (r === 0) { + successiveACState = successiveACState === 2 ? 3 : 0; + } } - } - break; + break; - case 3: - if (component.blockData[offset + z]) { - component.blockData[offset + z] += readBit() << successive; - } else { - component.blockData[offset + z] = successiveACNextValue << successive; - successiveACState = 0; - } - break; + case 3: + if (component.blockData[offset + z]) { + component.blockData[offset + z] += readBit() << successive; + } else { + component.blockData[offset + z] = successiveACNextValue << successive; + successiveACState = 0; + } + break; - case 4: - if (component.blockData[offset + z]) { - component.blockData[offset + z] += readBit() << successive; - } - break; + case 4: + if (component.blockData[offset + z]) { + component.blockData[offset + z] += readBit() << successive; + } + break; } k++; } @@ -2695,7 +2650,8 @@ var PDFJS; } else { decodeFn = decodeBaseline; } - var mcu = 0, marker; + var mcu = 0, + marker; var mcuExpected; if (componentsLength === 1) { mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn; @@ -2746,7 +2702,8 @@ var PDFJS; return offset - startOffset; } function quantizeAndInverse(component, blockBufferOffset, p) { - var qt = component.quantizationTable, blockData = component.blockData; + var qt = component.quantizationTable, + blockData = component.blockData; var v0, v1, v2, v3, v4, v5, v6, v7; var p0, p1, p2, p3, p4, p5, p6, p7; var t; @@ -2935,13 +2892,15 @@ var PDFJS; frame.mcusPerLine = mcusPerLine; frame.mcusPerColumn = mcusPerColumn; } - var offset = 0, length = data.length; + var offset = 0, + length = data.length; var jfif = null; var adobe = null; var pixels = null; var frame, resetInterval; var quantizationTables = []; - var huffmanTablesAC = [], huffmanTablesDC = []; + var huffmanTablesAC = [], + huffmanTablesDC = []; var fileMarker = readUint16(); if (fileMarker !== 65496) { throw "SOI not found"; @@ -2950,171 +2909,174 @@ var PDFJS; while (fileMarker !== 65497) { var i, j, l; switch (fileMarker) { - case 65504: - case 65505: - case 65506: - case 65507: - case 65508: - case 65509: - case 65510: - case 65511: - case 65512: - case 65513: - case 65514: - case 65515: - case 65516: - case 65517: - case 65518: - case 65519: - case 65534: - var appData = readDataBlock(); - if (fileMarker === 65504) { - if (appData[0] === 74 && appData[1] === 70 && appData[2] === 73 && appData[3] === 70 && appData[4] === 0) { - jfif = { - version: { - major: appData[5], - minor: appData[6] - }, - densityUnits: appData[7], - xDensity: appData[8] << 8 | appData[9], - yDensity: appData[10] << 8 | appData[11], - thumbWidth: appData[12], - thumbHeight: appData[13], - thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13]) - }; + case 65504: + case 65505: + case 65506: + case 65507: + case 65508: + case 65509: + case 65510: + case 65511: + case 65512: + case 65513: + case 65514: + case 65515: + case 65516: + case 65517: + case 65518: + case 65519: + case 65534: + var appData = readDataBlock(); + if (fileMarker === 65504) { + if (appData[0] === 74 && appData[1] === 70 && appData[2] === 73 && appData[3] === 70 && appData[4] === 0) { + jfif = { + version: { + major: appData[5], + minor: appData[6] + }, + densityUnits: appData[7], + xDensity: appData[8] << 8 | appData[9], + yDensity: appData[10] << 8 | appData[11], + thumbWidth: appData[12], + thumbHeight: appData[13], + thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13]) + }; + } } - } - if (fileMarker === 65518) { - if (appData[0] === 65 && appData[1] === 100 && appData[2] === 111 && appData[3] === 98 && appData[4] === 101) { - adobe = { - version: appData[5] << 8 | appData[6], - flags0: appData[7] << 8 | appData[8], - flags1: appData[9] << 8 | appData[10], - transformCode: appData[11] - }; + if (fileMarker === 65518) { + if (appData[0] === 65 && appData[1] === 100 && appData[2] === 111 && appData[3] === 98 && appData[4] === 101) { + adobe = { + version: appData[5] << 8 | appData[6], + flags0: appData[7] << 8 | appData[8], + flags1: appData[9] << 8 | appData[10], + transformCode: appData[11] + }; + } } - } - break; + break; - case 65499: - var quantizationTablesLength = readUint16(); - var quantizationTablesEnd = quantizationTablesLength + offset - 2; - var z; - while (offset < quantizationTablesEnd) { - var quantizationTableSpec = data[offset++]; - var tableData = new Uint16Array(64); - if (quantizationTableSpec >> 4 === 0) { - for (j = 0; j < 64; j++) { - z = dctZigZag[j]; - tableData[z] = data[offset++]; - } - } else if (quantizationTableSpec >> 4 === 1) { - for (j = 0; j < 64; j++) { - z = dctZigZag[j]; - tableData[z] = readUint16(); + case 65499: + var quantizationTablesLength = readUint16(); + var quantizationTablesEnd = quantizationTablesLength + offset - 2; + var z; + while (offset < quantizationTablesEnd) { + var quantizationTableSpec = data[offset++]; + var tableData = new Uint16Array(64); + if (quantizationTableSpec >> 4 === 0) { + for (j = 0; j < 64; j++) { + z = dctZigZag[j]; + tableData[z] = data[offset++]; + } + } else if (quantizationTableSpec >> 4 === 1) { + for (j = 0; j < 64; j++) { + z = dctZigZag[j]; + tableData[z] = readUint16(); + } + } else { + throw "DQT: invalid table spec"; } - } else { - throw "DQT: invalid table spec"; + quantizationTables[quantizationTableSpec & 15] = tableData; } - quantizationTables[quantizationTableSpec & 15] = tableData; - } - break; + break; - case 65472: - case 65473: - case 65474: - if (frame) { - throw "Only single frame JPEGs supported"; - } - readUint16(); - frame = {}; - frame.extended = fileMarker === 65473; - frame.progressive = fileMarker === 65474; - frame.precision = data[offset++]; - frame.scanLines = readUint16(); - frame.samplesPerLine = readUint16(); - frame.components = []; - frame.componentIds = {}; - var componentsCount = data[offset++], componentId; - var maxH = 0, maxV = 0; - for (i = 0; i < componentsCount; i++) { - componentId = data[offset]; - var h = data[offset + 1] >> 4; - var v = data[offset + 1] & 15; - if (maxH < h) { - maxH = h; + case 65472: + case 65473: + case 65474: + if (frame) { + throw "Only single frame JPEGs supported"; } - if (maxV < v) { - maxV = v; + readUint16(); + frame = {}; + frame.extended = fileMarker === 65473; + frame.progressive = fileMarker === 65474; + frame.precision = data[offset++]; + frame.scanLines = readUint16(); + frame.samplesPerLine = readUint16(); + frame.components = []; + frame.componentIds = {}; + var componentsCount = data[offset++], + componentId; + var maxH = 0, + maxV = 0; + for (i = 0; i < componentsCount; i++) { + componentId = data[offset]; + var h = data[offset + 1] >> 4; + var v = data[offset + 1] & 15; + if (maxH < h) { + maxH = h; + } + if (maxV < v) { + maxV = v; + } + var qId = data[offset + 2]; + l = frame.components.push({ + h: h, + v: v, + quantizationTable: quantizationTables[qId] + }); + frame.componentIds[componentId] = l - 1; + offset += 3; } - var qId = data[offset + 2]; - l = frame.components.push({ - h: h, - v: v, - quantizationTable: quantizationTables[qId] - }); - frame.componentIds[componentId] = l - 1; - offset += 3; - } - frame.maxH = maxH; - frame.maxV = maxV; - prepareComponents(frame); - break; + frame.maxH = maxH; + frame.maxV = maxV; + prepareComponents(frame); + break; - case 65476: - var huffmanLength = readUint16(); - for (i = 2; i < huffmanLength; ) { - var huffmanTableSpec = data[offset++]; - var codeLengths = new Uint8Array(16); - var codeLengthSum = 0; - for (j = 0; j < 16; j++, offset++) { - codeLengthSum += codeLengths[j] = data[offset]; - } - var huffmanValues = new Uint8Array(codeLengthSum); - for (j = 0; j < codeLengthSum; j++, offset++) { - huffmanValues[j] = data[offset]; + case 65476: + var huffmanLength = readUint16(); + for (i = 2; i < huffmanLength;) { + var huffmanTableSpec = data[offset++]; + var codeLengths = new Uint8Array(16); + var codeLengthSum = 0; + for (j = 0; j < 16; j++, offset++) { + codeLengthSum += codeLengths[j] = data[offset]; + } + var huffmanValues = new Uint8Array(codeLengthSum); + for (j = 0; j < codeLengthSum; j++, offset++) { + huffmanValues[j] = data[offset]; + } + i += 17 + codeLengthSum; + (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues); } - i += 17 + codeLengthSum; - (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues); - } - break; + break; - case 65501: - readUint16(); - resetInterval = readUint16(); - break; - - case 65498: - var scanLength = readUint16(); - var selectorsCount = data[offset++]; - var components = [], component; - for (i = 0; i < selectorsCount; i++) { - var componentIndex = frame.componentIds[data[offset++]]; - component = frame.components[componentIndex]; - var tableSpec = data[offset++]; - component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4]; - component.huffmanTableAC = huffmanTablesAC[tableSpec & 15]; - components.push(component); - } - var spectralStart = data[offset++]; - var spectralEnd = data[offset++]; - var successiveApproximation = data[offset++]; - var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15); - offset += processed; - break; + case 65501: + readUint16(); + resetInterval = readUint16(); + break; - case 65535: - if (data[offset] !== 255) { - offset--; - } - break; + case 65498: + var scanLength = readUint16(); + var selectorsCount = data[offset++]; + var components = [], + component; + for (i = 0; i < selectorsCount; i++) { + var componentIndex = frame.componentIds[data[offset++]]; + component = frame.components[componentIndex]; + var tableSpec = data[offset++]; + component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4]; + component.huffmanTableAC = huffmanTablesAC[tableSpec & 15]; + components.push(component); + } + var spectralStart = data[offset++]; + var spectralEnd = data[offset++]; + var successiveApproximation = data[offset++]; + var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15); + offset += processed; + break; - default: - if (data[offset - 3] === 255 && data[offset - 2] >= 192 && data[offset - 2] <= 254) { - offset -= 3; + case 65535: + if (data[offset] !== 255) { + offset--; + } break; - } - throw "unknown JPEG marker " + fileMarker.toString(16); + + default: + if (data[offset - 3] === 255 && data[offset - 2] >= 192 && data[offset - 2] <= 254) { + offset -= 3; + break; + } + throw "unknown JPEG marker " + fileMarker.toString(16); } fileMarker = readUint16(); } @@ -3136,7 +3098,8 @@ var PDFJS; this.numComponents = this.components.length; }, _getLinearizedBlockData: function getLinearizedBlockData(width, height) { - var scaleX = this.width / width, scaleY = this.height / height; + var scaleX = this.width / width, + scaleY = this.height / height; var component, componentScaleX, componentScaleY, blocksPerScanline; var x, y, i, j, k; var index; @@ -3169,7 +3132,7 @@ var PDFJS; } var transform = this.decodeTransform; if (transform) { - for (i = 0; i < dataLength; ) { + for (i = 0; i < dataLength;) { for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) { data[i] = (data[i] * transform[k] >> 8) + transform[k + 1]; } @@ -3271,7 +3234,7 @@ var PDFJS; }(); "use strict"; var ArithmeticDecoder = function ArithmeticDecoderClosure() { - var QeTable = [ { + var QeTable = [{ qe: 22017, nmps: 1, nlps: 1, @@ -3506,7 +3469,7 @@ var PDFJS; nmps: 46, nlps: 46, switchFlag: 0 - } ]; + }]; function ArithmeticDecoder(data, start, end) { this.data = data; this.bp = start; @@ -3546,7 +3509,8 @@ var PDFJS; } }, readBit: function ArithmeticDecoder_readBit(contexts, pos) { - var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1; + var cx_index = contexts[pos] >> 1, + cx_mps = contexts[pos] & 1; var qeTableIcx = QeTable[cx_index]; var qeIcx = qeTableIcx.qe; var d; @@ -3615,7 +3579,8 @@ var PDFJS; this.parseCodestream(data, 0, data.length); return; } - var position = 0, length = data.length; + var position = 0, + length = data.length; while (position < length) { var headerSize = 8; var lbox = readUint32(data, position); @@ -3635,52 +3600,52 @@ var PDFJS; var dataLength = lbox - headerSize; var jumpDataLength = true; switch (tbox) { - case 1785737832: - jumpDataLength = false; - break; + case 1785737832: + jumpDataLength = false; + break; - case 1668246642: - var method = data[position]; - var precedence = data[position + 1]; - var approximation = data[position + 2]; - if (method === 1) { - var colorspace = readUint32(data, position + 3); - switch (colorspace) { - case 16: - case 17: - case 18: - break; + case 1668246642: + var method = data[position]; + var precedence = data[position + 1]; + var approximation = data[position + 2]; + if (method === 1) { + var colorspace = readUint32(data, position + 3); + switch (colorspace) { + case 16: + case 17: + case 18: + break; - default: - warn("Unknown colorspace " + colorspace); - break; + default: + warn("Unknown colorspace " + colorspace); + break; + } + } else if (method === 2) { + info("ICC profile not supported"); } - } else if (method === 2) { - info("ICC profile not supported"); - } - break; + break; - case 1785737827: - this.parseCodestream(data, position, position + dataLength); - break; + case 1785737827: + this.parseCodestream(data, position, position + dataLength); + break; - case 1783636e3: - if (218793738 !== readUint32(data, position)) { - warn("Invalid JP2 signature"); - } - break; + case 1783636e3: + if (218793738 !== readUint32(data, position)) { + warn("Invalid JP2 signature"); + } + break; - case 1783634458: - case 1718909296: - case 1920099697: - case 1919251232: - case 1768449138: - break; + case 1783634458: + case 1718909296: + case 1920099697: + case 1919251232: + case 1768449138: + break; - default: - var headerType = String.fromCharCode(tbox >> 24 & 255, tbox >> 16 & 255, tbox >> 8 & 255, tbox & 255); - warn("Unsupported header type " + tbox + " (" + headerType + ")"); - break; + default: + var headerType = String.fromCharCode(tbox >> 24 & 255, tbox >> 16 & 255, tbox >> 8 & 255, tbox & 255); + warn("Unsupported header type " + tbox + " (" + headerType + ")"); + break; } if (jumpDataLength) { position += dataLength; @@ -3718,253 +3683,259 @@ var PDFJS; while (position + 1 < end) { var code = readUint16(data, position); position += 2; - var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile; + var length = 0, + j, + sqcd, + spqcds, + spqcdSize, + scalarExpounded, + tile; switch (code) { - case 65359: - context.mainHeader = true; - break; - - case 65497: - break; - - case 65361: - length = readUint16(data, position); - var siz = {}; - siz.Xsiz = readUint32(data, position + 4); - siz.Ysiz = readUint32(data, position + 8); - siz.XOsiz = readUint32(data, position + 12); - siz.YOsiz = readUint32(data, position + 16); - siz.XTsiz = readUint32(data, position + 20); - siz.YTsiz = readUint32(data, position + 24); - siz.XTOsiz = readUint32(data, position + 28); - siz.YTOsiz = readUint32(data, position + 32); - var componentsCount = readUint16(data, position + 36); - siz.Csiz = componentsCount; - var components = []; - j = position + 38; - for (var i = 0; i < componentsCount; i++) { - var component = { - precision: (data[j] & 127) + 1, - isSigned: !!(data[j] & 128), - XRsiz: data[j + 1], - YRsiz: data[j + 1] - }; - calculateComponentDimensions(component, siz); - components.push(component); - } - context.SIZ = siz; - context.components = components; - calculateTileGrids(context, components); - context.QCC = []; - context.COC = []; - break; + case 65359: + context.mainHeader = true; + break; - case 65372: - length = readUint16(data, position); - var qcd = {}; - j = position + 2; - sqcd = data[j++]; - switch (sqcd & 31) { - case 0: - spqcdSize = 8; - scalarExpounded = true; + case 65497: break; - case 1: - spqcdSize = 16; - scalarExpounded = false; + case 65361: + length = readUint16(data, position); + var siz = {}; + siz.Xsiz = readUint32(data, position + 4); + siz.Ysiz = readUint32(data, position + 8); + siz.XOsiz = readUint32(data, position + 12); + siz.YOsiz = readUint32(data, position + 16); + siz.XTsiz = readUint32(data, position + 20); + siz.YTsiz = readUint32(data, position + 24); + siz.XTOsiz = readUint32(data, position + 28); + siz.YTOsiz = readUint32(data, position + 32); + var componentsCount = readUint16(data, position + 36); + siz.Csiz = componentsCount; + var components = []; + j = position + 38; + for (var i = 0; i < componentsCount; i++) { + var component = { + precision: (data[j] & 127) + 1, + isSigned: !!(data[j] & 128), + XRsiz: data[j + 1], + YRsiz: data[j + 1] + }; + calculateComponentDimensions(component, siz); + components.push(component); + } + context.SIZ = siz; + context.components = components; + calculateTileGrids(context, components); + context.QCC = []; + context.COC = []; break; - case 2: - spqcdSize = 16; - scalarExpounded = true; + case 65372: + length = readUint16(data, position); + var qcd = {}; + j = position + 2; + sqcd = data[j++]; + switch (sqcd & 31) { + case 0: + spqcdSize = 8; + scalarExpounded = true; + break; + + case 1: + spqcdSize = 16; + scalarExpounded = false; + break; + + case 2: + spqcdSize = 16; + scalarExpounded = true; + break; + + default: + throw new Error("JPX Error: Invalid SQcd value " + sqcd); + } + qcd.noQuantization = spqcdSize === 8; + qcd.scalarExpounded = scalarExpounded; + qcd.guardBits = sqcd >> 5; + spqcds = []; + while (j < length + position) { + var spqcd = {}; + if (spqcdSize === 8) { + spqcd.epsilon = data[j++] >> 3; + spqcd.mu = 0; + } else { + spqcd.epsilon = data[j] >> 3; + spqcd.mu = (data[j] & 7) << 8 | data[j + 1]; + j += 2; + } + spqcds.push(spqcd); + } + qcd.SPqcds = spqcds; + if (context.mainHeader) { + context.QCD = qcd; + } else { + context.currentTile.QCD = qcd; + context.currentTile.QCC = []; + } break; - default: - throw new Error("JPX Error: Invalid SQcd value " + sqcd); - } - qcd.noQuantization = spqcdSize === 8; - qcd.scalarExpounded = scalarExpounded; - qcd.guardBits = sqcd >> 5; - spqcds = []; - while (j < length + position) { - var spqcd = {}; - if (spqcdSize === 8) { - spqcd.epsilon = data[j++] >> 3; - spqcd.mu = 0; + case 65373: + length = readUint16(data, position); + var qcc = {}; + j = position + 2; + var cqcc; + if (context.SIZ.Csiz < 257) { + cqcc = data[j++]; } else { - spqcd.epsilon = data[j] >> 3; - spqcd.mu = (data[j] & 7) << 8 | data[j + 1]; + cqcc = readUint16(data, j); j += 2; } - spqcds.push(spqcd); - } - qcd.SPqcds = spqcds; - if (context.mainHeader) { - context.QCD = qcd; - } else { - context.currentTile.QCD = qcd; - context.currentTile.QCC = []; - } - break; + sqcd = data[j++]; + switch (sqcd & 31) { + case 0: + spqcdSize = 8; + scalarExpounded = true; + break; - case 65373: - length = readUint16(data, position); - var qcc = {}; - j = position + 2; - var cqcc; - if (context.SIZ.Csiz < 257) { - cqcc = data[j++]; - } else { - cqcc = readUint16(data, j); - j += 2; - } - sqcd = data[j++]; - switch (sqcd & 31) { - case 0: - spqcdSize = 8; - scalarExpounded = true; - break; + case 1: + spqcdSize = 16; + scalarExpounded = false; + break; - case 1: - spqcdSize = 16; - scalarExpounded = false; - break; + case 2: + spqcdSize = 16; + scalarExpounded = true; + break; - case 2: - spqcdSize = 16; - scalarExpounded = true; + default: + throw new Error("JPX Error: Invalid SQcd value " + sqcd); + } + qcc.noQuantization = spqcdSize === 8; + qcc.scalarExpounded = scalarExpounded; + qcc.guardBits = sqcd >> 5; + spqcds = []; + while (j < length + position) { + spqcd = {}; + if (spqcdSize === 8) { + spqcd.epsilon = data[j++] >> 3; + spqcd.mu = 0; + } else { + spqcd.epsilon = data[j] >> 3; + spqcd.mu = (data[j] & 7) << 8 | data[j + 1]; + j += 2; + } + spqcds.push(spqcd); + } + qcc.SPqcds = spqcds; + if (context.mainHeader) { + context.QCC[cqcc] = qcc; + } else { + context.currentTile.QCC[cqcc] = qcc; + } break; - default: - throw new Error("JPX Error: Invalid SQcd value " + sqcd); - } - qcc.noQuantization = spqcdSize === 8; - qcc.scalarExpounded = scalarExpounded; - qcc.guardBits = sqcd >> 5; - spqcds = []; - while (j < length + position) { - spqcd = {}; - if (spqcdSize === 8) { - spqcd.epsilon = data[j++] >> 3; - spqcd.mu = 0; + case 65362: + length = readUint16(data, position); + var cod = {}; + j = position + 2; + var scod = data[j++]; + cod.entropyCoderWithCustomPrecincts = !!(scod & 1); + cod.sopMarkerUsed = !!(scod & 2); + cod.ephMarkerUsed = !!(scod & 4); + cod.progressionOrder = data[j++]; + cod.layersCount = readUint16(data, j); + j += 2; + cod.multipleComponentTransform = data[j++]; + cod.decompositionLevelsCount = data[j++]; + cod.xcb = (data[j++] & 15) + 2; + cod.ycb = (data[j++] & 15) + 2; + var blockStyle = data[j++]; + cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1); + cod.resetContextProbabilities = !!(blockStyle & 2); + cod.terminationOnEachCodingPass = !!(blockStyle & 4); + cod.verticalyStripe = !!(blockStyle & 8); + cod.predictableTermination = !!(blockStyle & 16); + cod.segmentationSymbolUsed = !!(blockStyle & 32); + cod.reversibleTransformation = data[j++]; + if (cod.entropyCoderWithCustomPrecincts) { + var precinctsSizes = []; + while (j < length + position) { + var precinctsSize = data[j++]; + precinctsSizes.push({ + PPx: precinctsSize & 15, + PPy: precinctsSize >> 4 + }); + } + cod.precinctsSizes = precinctsSizes; + } + var unsupported = []; + if (cod.selectiveArithmeticCodingBypass) { + unsupported.push("selectiveArithmeticCodingBypass"); + } + if (cod.resetContextProbabilities) { + unsupported.push("resetContextProbabilities"); + } + if (cod.terminationOnEachCodingPass) { + unsupported.push("terminationOnEachCodingPass"); + } + if (cod.verticalyStripe) { + unsupported.push("verticalyStripe"); + } + if (cod.predictableTermination) { + unsupported.push("predictableTermination"); + } + if (unsupported.length > 0) { + doNotRecover = true; + throw new Error("JPX Error: Unsupported COD options (" + unsupported.join(", ") + ")"); + } + if (context.mainHeader) { + context.COD = cod; } else { - spqcd.epsilon = data[j] >> 3; - spqcd.mu = (data[j] & 7) << 8 | data[j + 1]; - j += 2; + context.currentTile.COD = cod; + context.currentTile.COC = []; } - spqcds.push(spqcd); - } - qcc.SPqcds = spqcds; - if (context.mainHeader) { - context.QCC[cqcc] = qcc; - } else { - context.currentTile.QCC[cqcc] = qcc; - } - break; + break; - case 65362: - length = readUint16(data, position); - var cod = {}; - j = position + 2; - var scod = data[j++]; - cod.entropyCoderWithCustomPrecincts = !!(scod & 1); - cod.sopMarkerUsed = !!(scod & 2); - cod.ephMarkerUsed = !!(scod & 4); - cod.progressionOrder = data[j++]; - cod.layersCount = readUint16(data, j); - j += 2; - cod.multipleComponentTransform = data[j++]; - cod.decompositionLevelsCount = data[j++]; - cod.xcb = (data[j++] & 15) + 2; - cod.ycb = (data[j++] & 15) + 2; - var blockStyle = data[j++]; - cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1); - cod.resetContextProbabilities = !!(blockStyle & 2); - cod.terminationOnEachCodingPass = !!(blockStyle & 4); - cod.verticalyStripe = !!(blockStyle & 8); - cod.predictableTermination = !!(blockStyle & 16); - cod.segmentationSymbolUsed = !!(blockStyle & 32); - cod.reversibleTransformation = data[j++]; - if (cod.entropyCoderWithCustomPrecincts) { - var precinctsSizes = []; - while (j < length + position) { - var precinctsSize = data[j++]; - precinctsSizes.push({ - PPx: precinctsSize & 15, - PPy: precinctsSize >> 4 - }); + case 65424: + length = readUint16(data, position); + tile = {}; + tile.index = readUint16(data, position + 2); + tile.length = readUint32(data, position + 4); + tile.dataEnd = tile.length + position - 2; + tile.partIndex = data[position + 8]; + tile.partsCount = data[position + 9]; + context.mainHeader = false; + if (tile.partIndex === 0) { + tile.COD = context.COD; + tile.COC = context.COC.slice(0); + tile.QCD = context.QCD; + tile.QCC = context.QCC.slice(0); } - cod.precinctsSizes = precinctsSizes; - } - var unsupported = []; - if (cod.selectiveArithmeticCodingBypass) { - unsupported.push("selectiveArithmeticCodingBypass"); - } - if (cod.resetContextProbabilities) { - unsupported.push("resetContextProbabilities"); - } - if (cod.terminationOnEachCodingPass) { - unsupported.push("terminationOnEachCodingPass"); - } - if (cod.verticalyStripe) { - unsupported.push("verticalyStripe"); - } - if (cod.predictableTermination) { - unsupported.push("predictableTermination"); - } - if (unsupported.length > 0) { - doNotRecover = true; - throw new Error("JPX Error: Unsupported COD options (" + unsupported.join(", ") + ")"); - } - if (context.mainHeader) { - context.COD = cod; - } else { - context.currentTile.COD = cod; - context.currentTile.COC = []; - } - break; - - case 65424: - length = readUint16(data, position); - tile = {}; - tile.index = readUint16(data, position + 2); - tile.length = readUint32(data, position + 4); - tile.dataEnd = tile.length + position - 2; - tile.partIndex = data[position + 8]; - tile.partsCount = data[position + 9]; - context.mainHeader = false; - if (tile.partIndex === 0) { - tile.COD = context.COD; - tile.COC = context.COC.slice(0); - tile.QCD = context.QCD; - tile.QCC = context.QCC.slice(0); - } - context.currentTile = tile; - break; + context.currentTile = tile; + break; - case 65427: - tile = context.currentTile; - if (tile.partIndex === 0) { - initializeTile(context, tile.index); - buildPackets(context); - } - length = tile.dataEnd - position; - parseTilePackets(context, data, position, length); - break; + case 65427: + tile = context.currentTile; + if (tile.partIndex === 0) { + initializeTile(context, tile.index); + buildPackets(context); + } + length = tile.dataEnd - position; + parseTilePackets(context, data, position, length); + break; - case 65365: - case 65367: - case 65368: - case 65380: - length = readUint16(data, position); - break; + case 65365: + case 65367: + case 65368: + case 65380: + length = readUint16(data, position); + break; - case 65363: - throw new Error("JPX Error: Codestream code 0xFF53 (COC) is " + "not implemented"); + case 65363: + throw new Error("JPX Error: Codestream code 0xFF53 (COC) is " + "not implemented"); - default: - throw new Error("JPX Error: Unknown codestream code: " + code.toString(16)); + default: + throw new Error("JPX Error: Unknown codestream code: " + code.toString(16)); } position += length; } @@ -3991,7 +3962,8 @@ var PDFJS; } function calculateTileGrids(context, components) { var siz = context.SIZ; - var tile, tiles = []; + var tile, + tiles = []; var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz); var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz); for (var q = 0; q < numYtiles; q++) { @@ -4155,18 +4127,21 @@ var PDFJS; for (var q = 0; q < componentsCount; q++) { maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount); } - var l = 0, r = 0, i = 0, k = 0; + var l = 0, + r = 0, + i = 0, + k = 0; this.nextPacket = function JpxImage_nextPacket() { - for (;l < layersCount; l++) { - for (;r <= maxDecompositionLevelsCount; r++) { - for (;i < componentsCount; i++) { + for (; l < layersCount; l++) { + for (; r <= maxDecompositionLevelsCount; r++) { + for (; i < componentsCount; i++) { var component = tile.components[i]; if (r > component.codingStyleParameters.decompositionLevelsCount) { continue; } var resolution = component.resolutions[r]; var numprecincts = resolution.precinctParameters.numprecincts; - for (;k < numprecincts; ) { + for (; k < numprecincts;) { var packet = createPacket(resolution, k, l); k++; return packet; @@ -4190,18 +4165,21 @@ var PDFJS; for (var q = 0; q < componentsCount; q++) { maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount); } - var r = 0, l = 0, i = 0, k = 0; + var r = 0, + l = 0, + i = 0, + k = 0; this.nextPacket = function JpxImage_nextPacket() { - for (;r <= maxDecompositionLevelsCount; r++) { - for (;l < layersCount; l++) { - for (;i < componentsCount; i++) { + for (; r <= maxDecompositionLevelsCount; r++) { + for (; l < layersCount; l++) { + for (; i < componentsCount; i++) { var component = tile.components[i]; if (r > component.codingStyleParameters.decompositionLevelsCount) { continue; } var resolution = component.resolutions[r]; var numprecincts = resolution.precinctParameters.numprecincts; - for (;k < numprecincts; ) { + for (; k < numprecincts;) { var packet = createPacket(resolution, k, l); k++; return packet; @@ -4243,9 +4221,9 @@ var PDFJS; c = 0; p = 0; this.nextPacket = function JpxImage_nextPacket() { - for (;r <= maxDecompositionLevelsCount; r++) { - for (;p < maxNumPrecinctsInLevel[r]; p++) { - for (;c < componentsCount; c++) { + for (; r <= maxDecompositionLevelsCount; r++) { + for (; p < maxNumPrecinctsInLevel[r]; p++) { + for (; c < componentsCount; c++) { var component = tile.components[c]; if (r > component.codingStyleParameters.decompositionLevelsCount) { continue; @@ -4255,7 +4233,7 @@ var PDFJS; if (p >= numprecincts) { continue; } - for (;l < layersCount; ) { + for (; l < layersCount;) { var packet = createPacket(resolution, p, l); l++; return packet; @@ -4277,21 +4255,25 @@ var PDFJS; var componentsCount = siz.Csiz; var precinctsSizes = getPrecinctSizesInImageScale(tile); var precinctsIterationSizes = precinctsSizes; - var l = 0, r = 0, c = 0, px = 0, py = 0; + var l = 0, + r = 0, + c = 0, + px = 0, + py = 0; this.nextPacket = function JpxImage_nextPacket() { - for (;py < precinctsIterationSizes.maxNumHigh; py++) { - for (;px < precinctsIterationSizes.maxNumWide; px++) { - for (;c < componentsCount; c++) { + for (; py < precinctsIterationSizes.maxNumHigh; py++) { + for (; px < precinctsIterationSizes.maxNumWide; px++) { + for (; c < componentsCount; c++) { var component = tile.components[c]; var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount; - for (;r <= decompositionLevelsCount; r++) { + for (; r <= decompositionLevelsCount; r++) { var resolution = component.resolutions[r]; var sizeInImageScale = precinctsSizes.components[c].resolutions[r]; var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution); if (k === null) { continue; } - for (;l < layersCount; ) { + for (; l < layersCount;) { var packet = createPacket(resolution, k, l); l++; return packet; @@ -4314,22 +4296,26 @@ var PDFJS; var layersCount = tile.codingStyleDefaultParameters.layersCount; var componentsCount = siz.Csiz; var precinctsSizes = getPrecinctSizesInImageScale(tile); - var l = 0, r = 0, c = 0, px = 0, py = 0; + var l = 0, + r = 0, + c = 0, + px = 0, + py = 0; this.nextPacket = function JpxImage_nextPacket() { - for (;c < componentsCount; ++c) { + for (; c < componentsCount; ++c) { var component = tile.components[c]; var precinctsIterationSizes = precinctsSizes.components[c]; var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount; - for (;py < precinctsIterationSizes.maxNumHigh; py++) { - for (;px < precinctsIterationSizes.maxNumWide; px++) { - for (;r <= decompositionLevelsCount; r++) { + for (; py < precinctsIterationSizes.maxNumHigh; py++) { + for (; px < precinctsIterationSizes.maxNumWide; px++) { + for (; r <= decompositionLevelsCount; r++) { var resolution = component.resolutions[r]; var sizeInImageScale = precinctsIterationSizes.resolutions[r]; var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution); if (k === null) { continue; } - for (;l < layersCount; ) { + for (; l < layersCount;) { var packet = createPacket(resolution, k, l); l++; return packet; @@ -4436,7 +4422,7 @@ var PDFJS; subband.resolution = resolution; buildCodeblocks(context, subband, blocksDimensions); subbands.push(subband); - resolution.subbands = [ subband ]; + resolution.subbands = [subband]; } else { var bscale = 1 << decompositionLevelsCount - r + 1; var resolutionSubbands = []; @@ -4478,33 +4464,35 @@ var PDFJS; } var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder; switch (progressionOrder) { - case 0: - tile.packetsIterator = new LayerResolutionComponentPositionIterator(context); - break; + case 0: + tile.packetsIterator = new LayerResolutionComponentPositionIterator(context); + break; - case 1: - tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context); - break; + case 1: + tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context); + break; - case 2: - tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context); - break; + case 2: + tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context); + break; - case 3: - tile.packetsIterator = new PositionComponentResolutionLayerIterator(context); - break; + case 3: + tile.packetsIterator = new PositionComponentResolutionLayerIterator(context); + break; - case 4: - tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context); - break; + case 4: + tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context); + break; - default: - throw new Error("JPX Error: Unsupported progression order " + progressionOrder); + default: + throw new Error("JPX Error: Unsupported progression order " + progressionOrder); } } function parseTilePackets(context, data, offset, dataLength) { var position = 0; - var buffer, bufferSize = 0, skipNextBit = false; + var buffer, + bufferSize = 0, + skipNextBit = false; function readBits(count) { while (bufferSize < count) { var b = data[offset + position]; @@ -4577,7 +4565,8 @@ var PDFJS; continue; } var layerNumber = packet.layerNumber; - var queue = [], codeblock; + var queue = [], + codeblock; for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) { codeblock = packet.codeblocks[i]; var precinct = codeblock.precinct; @@ -4689,7 +4678,9 @@ var PDFJS; var bitModel, currentCodingpassType; bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb); currentCodingpassType = 2; - var data = codeblock.data, totalLength = 0, codingpasses = 0; + var data = codeblock.data, + totalLength = 0, + codingpasses = 0; var j, jj, dataItem; for (j = 0, jj = data.length; j < jj; j++) { dataItem = data[j]; @@ -4708,20 +4699,20 @@ var PDFJS; bitModel.setDecoder(decoder); for (j = 0; j < codingpasses; j++) { switch (currentCodingpassType) { - case 0: - bitModel.runSignificancePropogationPass(); - break; + case 0: + bitModel.runSignificancePropogationPass(); + break; - case 1: - bitModel.runMagnitudeRefinementPass(); - break; + case 1: + bitModel.runMagnitudeRefinementPass(); + break; - case 2: - bitModel.runCleanupPass(); - if (segmentationSymbolUsed) { - bitModel.checkSegmentationSymbol(); - } - break; + case 2: + bitModel.runCleanupPass(); + if (segmentationSymbolUsed) { + bitModel.checkSegmentationSymbol(); + } + break; } currentCodingpassType = (currentCodingpassType + 1) % 3; } @@ -4830,7 +4821,17 @@ var PDFJS; items: out }; var shift, offset, max, min, maxK; - var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val; + var pos = 0, + j, + jj, + y0, + y1, + y2, + r, + g, + b, + k, + val; if (tile.codingStyleDefaultParameters.multipleComponentTransform) { var fourComponents = componentsCount === 4; var y0items = transformedTiles[0].items; @@ -4924,7 +4925,9 @@ var PDFJS; } TagTree.prototype = { reset: function TagTree_reset(i, j) { - var currentLevel = 0, value = 0, level; + var currentLevel = 0, + value = 0, + level; while (currentLevel < this.levels.length) { level = this.levels[currentLevel]; var index = i + j * level.width; @@ -5040,9 +5043,9 @@ var PDFJS; var BitModel = function BitModelClosure() { var UNIFORM_CONTEXT = 17; var RUNLENGTH_CONTEXT = 18; - var LLAndLHContextsLabel = new Uint8Array([ 0, 5, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 1, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8 ]); - var HLContextLabel = new Uint8Array([ 0, 3, 4, 0, 5, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 1, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8 ]); - var HHContextLabel = new Uint8Array([ 0, 1, 2, 0, 1, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 0, 3, 4, 5, 0, 4, 5, 5, 0, 5, 5, 5, 0, 0, 0, 0, 0, 6, 7, 7, 0, 7, 7, 7, 0, 7, 7, 7, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8 ]); + var LLAndLHContextsLabel = new Uint8Array([0, 5, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 1, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8]); + var HLContextLabel = new Uint8Array([0, 3, 4, 0, 5, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 1, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8]); + var HHContextLabel = new Uint8Array([0, 1, 2, 0, 1, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 0, 3, 4, 5, 0, 4, 5, 5, 0, 5, 5, 5, 0, 0, 0, 0, 0, 6, 7, 7, 0, 7, 7, 7, 0, 7, 7, 7, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8]); function BitModel(width, height, subband, zeroBitPlanes, mb) { this.width = width; this.height = height; @@ -5073,7 +5076,8 @@ var PDFJS; }, setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) { var neighborsSignificance = this.neighborsSignificance; - var width = this.width, height = this.height; + var width = this.width, + height = this.height; var left = column > 0; var right = column + 1 < width; var i; @@ -5107,7 +5111,8 @@ var PDFJS; }, runSignificancePropogationPass: function BitModel_runSignificancePropogationPass() { var decoder = this.decoder; - var width = this.width, height = this.height; + var width = this.width, + height = this.height; var coefficentsMagnitude = this.coefficentsMagnitude; var coefficentsSign = this.coefficentsSign; var neighborsSignificance = this.neighborsSignificance; @@ -5146,7 +5151,8 @@ var PDFJS; } }, decodeSignBit: function BitModel_decodeSignBit(row, column, index) { - var width = this.width, height = this.height; + var width = this.width, + height = this.height; var coefficentsMagnitude = this.coefficentsMagnitude; var coefficentsSign = this.coefficentsSign; var contribution, sign0, sign1, significance1; @@ -5193,7 +5199,8 @@ var PDFJS; }, runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() { var decoder = this.decoder; - var width = this.width, height = this.height; + var width = this.width, + height = this.height; var coefficentsMagnitude = this.coefficentsMagnitude; var neighborsSignificance = this.neighborsSignificance; var contexts = this.contexts; @@ -5226,7 +5233,8 @@ var PDFJS; }, runCleanupPass: function BitModel_runCleanupPass() { var decoder = this.decoder; - var width = this.width, height = this.height; + var width = this.width, + height = this.height; var neighborsSignificance = this.neighborsSignificance; var coefficentsMagnitude = this.coefficentsMagnitude; var coefficentsSign = this.coefficentsSign; @@ -5247,8 +5255,10 @@ var PDFJS; for (var j = 0; j < width; j++) { var index0 = indexBase + j; var allEmpty = checkAllEmpty && processingFlags[index0] === 0 && processingFlags[index0 + oneRowDown] === 0 && processingFlags[index0 + twoRowsDown] === 0 && processingFlags[index0 + threeRowsDown] === 0 && neighborsSignificance[index0] === 0 && neighborsSignificance[index0 + oneRowDown] === 0 && neighborsSignificance[index0 + twoRowsDown] === 0 && neighborsSignificance[index0 + threeRowsDown] === 0; - var i1 = 0, index = index0; - var i = i0, sign; + var i1 = 0, + index = index0; + var i = i0, + sign; if (allEmpty) { var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT); if (!hasSignificantCoefficent) { @@ -5313,8 +5323,10 @@ var PDFJS; return ll; }; Transform.prototype.extend = function extend(buffer, offset, size) { - var i1 = offset - 1, j1 = offset + 1; - var i2 = offset + size - 2, j2 = offset + size; + var i1 = offset - 1, + j1 = offset + 1; + var i2 = offset + size - 2, + j2 = offset + size; buffer[i1--] = buffer[j1++]; buffer[j2++] = buffer[i2--]; buffer[i1--] = buffer[j1++]; @@ -5325,7 +5337,9 @@ var PDFJS; buffer[j2] = buffer[i2]; }; Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) { - var llWidth = ll.width, llHeight = ll.height, llItems = ll.items; + var llWidth = ll.width, + llHeight = ll.height, + llItems = ll.items; var width = hl_lh_hh.width; var height = hl_lh_hh.height; var items = hl_lh_hh.items; @@ -5358,7 +5372,8 @@ var PDFJS; for (i = 0; i < numBuffers; i++) { colBuffers.push(new Float32Array(height + 2 * bufferPadding)); } - var b, currentBuffer = 0; + var b, + currentBuffer = 0; ll = bufferPadding + height; if (height === 1) { if ((v0 & 1) !== 0) { @@ -5499,7 +5514,7 @@ var PDFJS; var Jbig2Image = function Jbig2ImageClosure() { function ContextCache() {} ContextCache.prototype = { - getContexts: function(id) { + getContexts: function getContexts(id) { if (id in this) { return this[id]; } @@ -5549,8 +5564,8 @@ var PDFJS; } return prev & 2147483647; } - var SegmentTypes = [ "SymbolDictionary", null, null, null, "IntermediateTextRegion", null, "ImmediateTextRegion", "ImmediateLosslessTextRegion", null, null, null, null, null, null, null, null, "patternDictionary", null, null, null, "IntermediateHalftoneRegion", null, "ImmediateHalftoneRegion", "ImmediateLosslessHalftoneRegion", null, null, null, null, null, null, null, null, null, null, null, null, "IntermediateGenericRegion", null, "ImmediateGenericRegion", "ImmediateLosslessGenericRegion", "IntermediateGenericRefinementRegion", null, "ImmediateGenericRefinementRegion", "ImmediateLosslessGenericRefinementRegion", null, null, null, null, "PageInformation", "EndOfPage", "EndOfStripe", "EndOfFile", "Profiles", "Tables", null, null, null, null, null, null, null, null, "Extension" ]; - var CodingTemplates = [ [ { + var SegmentTypes = ["SymbolDictionary", null, null, null, "IntermediateTextRegion", null, "ImmediateTextRegion", "ImmediateLosslessTextRegion", null, null, null, null, null, null, null, null, "patternDictionary", null, null, null, "IntermediateHalftoneRegion", null, "ImmediateHalftoneRegion", "ImmediateLosslessHalftoneRegion", null, null, null, null, null, null, null, null, null, null, null, null, "IntermediateGenericRegion", null, "ImmediateGenericRegion", "ImmediateLosslessGenericRegion", "IntermediateGenericRefinementRegion", null, "ImmediateGenericRefinementRegion", "ImmediateLosslessGenericRefinementRegion", null, null, null, null, "PageInformation", "EndOfPage", "EndOfStripe", "EndOfFile", "Profiles", "Tables", null, null, null, null, null, null, null, null, "Extension"]; + var CodingTemplates = [[{ x: -1, y: -2 }, { @@ -5586,7 +5601,7 @@ var PDFJS; }, { x: -1, y: 0 - } ], [ { + }], [{ x: -1, y: -2 }, { @@ -5622,7 +5637,7 @@ var PDFJS; }, { x: -1, y: 0 - } ], [ { + }], [{ x: -1, y: -2 }, { @@ -5649,7 +5664,7 @@ var PDFJS; }, { x: -1, y: 0 - } ], [ { + }], [{ x: -3, y: -1 }, { @@ -5676,9 +5691,9 @@ var PDFJS; }, { x: -1, y: 0 - } ] ]; - var RefinementTemplates = [ { - coding: [ { + }]]; + var RefinementTemplates = [{ + coding: [{ x: 0, y: -1 }, { @@ -5687,8 +5702,8 @@ var PDFJS; }, { x: -1, y: 0 - } ], - reference: [ { + }], + reference: [{ x: 0, y: -1 }, { @@ -5712,9 +5727,9 @@ var PDFJS; }, { x: 1, y: 1 - } ] + }] }, { - coding: [ { + coding: [{ x: -1, y: -1 }, { @@ -5726,8 +5741,8 @@ var PDFJS; }, { x: -1, y: 0 - } ], - reference: [ { + }], + reference: [{ x: 0, y: -1 }, { @@ -5745,14 +5760,21 @@ var PDFJS; }, { x: 1, y: 1 - } ] - } ]; - var ReusedContexts = [ 39717, 1941, 229, 405 ]; - var RefinementReusedContexts = [ 32, 8 ]; + }] + }]; + var ReusedContexts = [39717, 1941, 229, 405]; + var RefinementReusedContexts = [32, 8]; function decodeBitmapTemplate0(width, height, decodingContext) { var decoder = decodingContext.decoder; var contexts = decodingContext.contextCache.getContexts("GB"); - var contextLabel, i, j, pixel, row, row1, row2, bitmap = []; + var contextLabel, + i, + j, + pixel, + row, + row1, + row2, + bitmap = []; var OLD_PIXEL_MASK = 31735; for (i = 0; i < height; i++) { row = bitmap[i] = new Uint8Array(width); @@ -5775,14 +5797,17 @@ var PDFJS; } var useskip = !!skip; var template = CodingTemplates[templateIndex].concat(at); - template.sort(function(a, b) { + template.sort(function (a, b) { return a.y - b.y || a.x - b.x; }); var templateLength = template.length; var templateX = new Int8Array(templateLength); var templateY = new Int8Array(templateLength); var changingTemplateEntries = []; - var reuseMask = 0, minX = 0, maxX = 0, minY = 0; + var reuseMask = 0, + minX = 0, + maxX = 0, + minY = 0; var c, k; for (k = 0; k < templateLength; k++) { templateX[k] = template[k].x; @@ -5814,7 +5839,13 @@ var PDFJS; var bitmap = []; var decoder = decodingContext.decoder; var contexts = decodingContext.contextCache.getContexts("GB"); - var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift; + var ltp = 0, + j, + i0, + j0, + contextLabel = 0, + bit, + shift; for (var i = 0; i < height; i++) { if (prediction) { var sltp = decoder.readBit(contexts, pseudoPixelContext); @@ -5867,7 +5898,7 @@ var PDFJS; function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) { var codingTemplate = RefinementTemplates[templateIndex].coding; if (templateIndex === 0) { - codingTemplate = codingTemplate.concat([ at[0] ]); + codingTemplate = codingTemplate.concat([at[0]]); } var codingTemplateLength = codingTemplate.length; var codingTemplateX = new Int32Array(codingTemplateLength); @@ -5879,7 +5910,7 @@ var PDFJS; } var referenceTemplate = RefinementTemplates[templateIndex].reference; if (templateIndex === 0) { - referenceTemplate = referenceTemplate.concat([ at[1] ]); + referenceTemplate = referenceTemplate.concat([at[1]]); } var referenceTemplateLength = referenceTemplate.length; var referenceTemplateX = new Int32Array(referenceTemplateLength); @@ -5972,7 +6003,8 @@ var PDFJS; } } var exportedSymbols = []; - var flags = [], currentFlag = false; + var flags = [], + currentFlag = false; var totalSymbolsLength = symbols.length + numberOfNewSymbols; while (flags.length < totalSymbolsLength) { var runLength = decodeInteger(contextCache, "IAEX", decoder); @@ -6048,20 +6080,20 @@ var PDFJS; symbolRow = symbolBitmap[s2]; var maxWidth = Math.min(width - offsetT, symbolWidth); switch (combinationOperator) { - case 0: - for (t2 = 0; t2 < maxWidth; t2++) { - row[offsetT + t2] |= symbolRow[t2]; - } - break; + case 0: + for (t2 = 0; t2 < maxWidth; t2++) { + row[offsetT + t2] |= symbolRow[t2]; + } + break; - case 2: - for (t2 = 0; t2 < maxWidth; t2++) { - row[offsetT + t2] ^= symbolRow[t2]; - } - break; + case 2: + for (t2 = 0; t2 < maxWidth; t2++) { + row[offsetT + t2] ^= symbolRow[t2]; + } + break; - default: - error("JBIG2 error: operator " + combinationOperator + " is not supported"); + default: + error("JBIG2 error: operator " + combinationOperator + " is not supported"); } } currentS += symbolHeight - 1; @@ -6073,20 +6105,20 @@ var PDFJS; } symbolRow = symbolBitmap[t2]; switch (combinationOperator) { - case 0: - for (s2 = 0; s2 < symbolWidth; s2++) { - row[offsetS + s2] |= symbolRow[s2]; - } - break; + case 0: + for (s2 = 0; s2 < symbolWidth; s2++) { + row[offsetS + s2] |= symbolRow[s2]; + } + break; - case 2: - for (s2 = 0; s2 < symbolWidth; s2++) { - row[offsetS + s2] ^= symbolRow[s2]; - } - break; + case 2: + for (s2 = 0; s2 < symbolWidth; s2++) { + row[offsetS + s2] ^= symbolRow[s2]; + } + break; - default: - error("JBIG2 error: operator " + combinationOperator + " is not supported"); + default: + error("JBIG2 error: operator " + combinationOperator + " is not supported"); } } currentS += symbolWidth - 1; @@ -6115,7 +6147,7 @@ var PDFJS; var pageAssociationFieldSize = !!(flags & 64); var referredFlags = data[start + 5]; var referredToCount = referredFlags >> 5 & 7; - var retainBits = [ referredFlags & 31 ]; + var retainBits = [referredFlags & 31]; var position = start + 6; if (referredFlags === 7) { referredToCount = readUint32(data, position - 1) & 536870911; @@ -6222,159 +6254,161 @@ var PDFJS; var RegionSegmentInformationFieldLength = 17; function processSegment(segment, visitor) { var header = segment.header; - var data = segment.data, position = segment.start, end = segment.end; + var data = segment.data, + position = segment.start, + end = segment.end; var args, at, i, atLength; switch (header.type) { - case 0: - var dictionary = {}; - var dictionaryFlags = readUint16(data, position); - dictionary.huffman = !!(dictionaryFlags & 1); - dictionary.refinement = !!(dictionaryFlags & 2); - dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3; - dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3; - dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1; - dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1; - dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256); - dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512); - dictionary.template = dictionaryFlags >> 10 & 3; - dictionary.refinementTemplate = dictionaryFlags >> 12 & 1; - position += 2; - if (!dictionary.huffman) { - atLength = dictionary.template === 0 ? 4 : 1; - at = []; - for (i = 0; i < atLength; i++) { - at.push({ - x: readInt8(data, position), - y: readInt8(data, position + 1) - }); - position += 2; + case 0: + var dictionary = {}; + var dictionaryFlags = readUint16(data, position); + dictionary.huffman = !!(dictionaryFlags & 1); + dictionary.refinement = !!(dictionaryFlags & 2); + dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3; + dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3; + dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1; + dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1; + dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256); + dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512); + dictionary.template = dictionaryFlags >> 10 & 3; + dictionary.refinementTemplate = dictionaryFlags >> 12 & 1; + position += 2; + if (!dictionary.huffman) { + atLength = dictionary.template === 0 ? 4 : 1; + at = []; + for (i = 0; i < atLength; i++) { + at.push({ + x: readInt8(data, position), + y: readInt8(data, position + 1) + }); + position += 2; + } + dictionary.at = at; } - dictionary.at = at; - } - if (dictionary.refinement && !dictionary.refinementTemplate) { - at = []; - for (i = 0; i < 2; i++) { - at.push({ - x: readInt8(data, position), - y: readInt8(data, position + 1) - }); - position += 2; + if (dictionary.refinement && !dictionary.refinementTemplate) { + at = []; + for (i = 0; i < 2; i++) { + at.push({ + x: readInt8(data, position), + y: readInt8(data, position + 1) + }); + position += 2; + } + dictionary.refinementAt = at; } - dictionary.refinementAt = at; - } - dictionary.numberOfExportedSymbols = readUint32(data, position); - position += 4; - dictionary.numberOfNewSymbols = readUint32(data, position); - position += 4; - args = [ dictionary, header.number, header.referredTo, data, position, end ]; - break; + dictionary.numberOfExportedSymbols = readUint32(data, position); + position += 4; + dictionary.numberOfNewSymbols = readUint32(data, position); + position += 4; + args = [dictionary, header.number, header.referredTo, data, position, end]; + break; - case 6: - case 7: - var textRegion = {}; - textRegion.info = readRegionSegmentInformation(data, position); - position += RegionSegmentInformationFieldLength; - var textRegionSegmentFlags = readUint16(data, position); - position += 2; - textRegion.huffman = !!(textRegionSegmentFlags & 1); - textRegion.refinement = !!(textRegionSegmentFlags & 2); - textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3); - textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3; - textRegion.transposed = !!(textRegionSegmentFlags & 64); - textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3; - textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1; - textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27; - textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1; - if (textRegion.huffman) { - var textRegionHuffmanFlags = readUint16(data, position); + case 6: + case 7: + var textRegion = {}; + textRegion.info = readRegionSegmentInformation(data, position); + position += RegionSegmentInformationFieldLength; + var textRegionSegmentFlags = readUint16(data, position); position += 2; - textRegion.huffmanFS = textRegionHuffmanFlags & 3; - textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3; - textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3; - textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3; - textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3; - textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3; - textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3; - textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14); - } - if (textRegion.refinement && !textRegion.refinementTemplate) { - at = []; - for (i = 0; i < 2; i++) { - at.push({ - x: readInt8(data, position), - y: readInt8(data, position + 1) - }); + textRegion.huffman = !!(textRegionSegmentFlags & 1); + textRegion.refinement = !!(textRegionSegmentFlags & 2); + textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3); + textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3; + textRegion.transposed = !!(textRegionSegmentFlags & 64); + textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3; + textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1; + textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27; + textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1; + if (textRegion.huffman) { + var textRegionHuffmanFlags = readUint16(data, position); position += 2; + textRegion.huffmanFS = textRegionHuffmanFlags & 3; + textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3; + textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3; + textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3; + textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3; + textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3; + textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3; + textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14); } - textRegion.refinementAt = at; - } - textRegion.numberOfSymbolInstances = readUint32(data, position); - position += 4; - if (textRegion.huffman) { - error("JBIG2 error: huffman is not supported"); - } - args = [ textRegion, header.referredTo, data, position, end ]; - break; - - case 38: - case 39: - var genericRegion = {}; - genericRegion.info = readRegionSegmentInformation(data, position); - position += RegionSegmentInformationFieldLength; - var genericRegionSegmentFlags = data[position++]; - genericRegion.mmr = !!(genericRegionSegmentFlags & 1); - genericRegion.template = genericRegionSegmentFlags >> 1 & 3; - genericRegion.prediction = !!(genericRegionSegmentFlags & 8); - if (!genericRegion.mmr) { - atLength = genericRegion.template === 0 ? 4 : 1; - at = []; - for (i = 0; i < atLength; i++) { - at.push({ - x: readInt8(data, position), - y: readInt8(data, position + 1) - }); - position += 2; + if (textRegion.refinement && !textRegion.refinementTemplate) { + at = []; + for (i = 0; i < 2; i++) { + at.push({ + x: readInt8(data, position), + y: readInt8(data, position + 1) + }); + position += 2; + } + textRegion.refinementAt = at; } - genericRegion.at = at; - } - args = [ genericRegion, data, position, end ]; - break; - - case 48: - var pageInfo = { - width: readUint32(data, position), - height: readUint32(data, position + 4), - resolutionX: readUint32(data, position + 8), - resolutionY: readUint32(data, position + 12) - }; - if (pageInfo.height === 4294967295) { - delete pageInfo.height; - } - var pageSegmentFlags = data[position + 16]; - var pageStripingInformatiom = readUint16(data, position + 17); - pageInfo.lossless = !!(pageSegmentFlags & 1); - pageInfo.refinement = !!(pageSegmentFlags & 2); - pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1; - pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3; - pageInfo.requiresBuffer = !!(pageSegmentFlags & 32); - pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64); - args = [ pageInfo ]; - break; + textRegion.numberOfSymbolInstances = readUint32(data, position); + position += 4; + if (textRegion.huffman) { + error("JBIG2 error: huffman is not supported"); + } + args = [textRegion, header.referredTo, data, position, end]; + break; - case 49: - break; + case 38: + case 39: + var genericRegion = {}; + genericRegion.info = readRegionSegmentInformation(data, position); + position += RegionSegmentInformationFieldLength; + var genericRegionSegmentFlags = data[position++]; + genericRegion.mmr = !!(genericRegionSegmentFlags & 1); + genericRegion.template = genericRegionSegmentFlags >> 1 & 3; + genericRegion.prediction = !!(genericRegionSegmentFlags & 8); + if (!genericRegion.mmr) { + atLength = genericRegion.template === 0 ? 4 : 1; + at = []; + for (i = 0; i < atLength; i++) { + at.push({ + x: readInt8(data, position), + y: readInt8(data, position + 1) + }); + position += 2; + } + genericRegion.at = at; + } + args = [genericRegion, data, position, end]; + break; - case 50: - break; + case 48: + var pageInfo = { + width: readUint32(data, position), + height: readUint32(data, position + 4), + resolutionX: readUint32(data, position + 8), + resolutionY: readUint32(data, position + 12) + }; + if (pageInfo.height === 4294967295) { + delete pageInfo.height; + } + var pageSegmentFlags = data[position + 16]; + var pageStripingInformatiom = readUint16(data, position + 17); + pageInfo.lossless = !!(pageSegmentFlags & 1); + pageInfo.refinement = !!(pageSegmentFlags & 2); + pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1; + pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3; + pageInfo.requiresBuffer = !!(pageSegmentFlags & 32); + pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64); + args = [pageInfo]; + break; - case 51: - break; + case 49: + break; - case 62: - break; + case 50: + break; - default: - error("JBIG2 error: segment type " + header.typeName + "(" + header.type + ") is not implemented"); + case 51: + break; + + case 62: + break; + + default: + error("JBIG2 error: segment type " + header.typeName + "(" + header.type + ") is not implemented"); } var callbackName = "on" + header.typeName; if (callbackName in visitor) { @@ -6426,7 +6460,8 @@ var PDFJS; }, drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) { var pageInfo = this.currentPageInfo; - var width = regionInfo.width, height = regionInfo.height; + var width = regionInfo.width, + height = regionInfo.height; var rowSize = pageInfo.width + 7 >> 3; var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator; var buffer = this.buffer; @@ -6434,44 +6469,44 @@ var PDFJS; var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3); var i, j, mask, offset; switch (combinationOperator) { - case 0: - for (i = 0; i < height; i++) { - mask = mask0; - offset = offset0; - for (j = 0; j < width; j++) { - if (bitmap[i][j]) { - buffer[offset] |= mask; - } - mask >>= 1; - if (!mask) { - mask = 128; - offset++; + case 0: + for (i = 0; i < height; i++) { + mask = mask0; + offset = offset0; + for (j = 0; j < width; j++) { + if (bitmap[i][j]) { + buffer[offset] |= mask; + } + mask >>= 1; + if (!mask) { + mask = 128; + offset++; + } } + offset0 += rowSize; } - offset0 += rowSize; - } - break; + break; - case 2: - for (i = 0; i < height; i++) { - mask = mask0; - offset = offset0; - for (j = 0; j < width; j++) { - if (bitmap[i][j]) { - buffer[offset] ^= mask; - } - mask >>= 1; - if (!mask) { - mask = 128; - offset++; + case 2: + for (i = 0; i < height; i++) { + mask = mask0; + offset = offset0; + for (j = 0; j < width; j++) { + if (bitmap[i][j]) { + buffer[offset] ^= mask; + } + mask >>= 1; + if (!mask) { + mask = 128; + offset++; + } } + offset0 += rowSize; } - offset0 += rowSize; - } - break; + break; - default: - error("JBIG2 error: operator " + combinationOperator + " is not supported"); + default: + error("JBIG2 error: operator " + combinationOperator + " is not supported"); } }, onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) { @@ -6525,7 +6560,8 @@ var PDFJS; return Jbig2Image; }(); function log2(x) { - var n = 1, i = 0; + var n = 1, + i = 0; while (x > n) { n <<= 1; i++; @@ -6550,18 +6586,19 @@ var PDFJS; }); return value; } - var error = function() { + var error = function error() { console.error.apply(console, arguments); throw new Error("PDFJS error: " + arguments[0]); }; - var warn = function() { + var warn = function warn() { console.warn.apply(console, arguments); }; - var info = function() { + var info = function info() { console.info.apply(console, arguments); }; Jbig2Image.prototype.parse = function parseJbig2(data) { - var position = 0, end = data.length; + var position = 0, + end = data.length; if (data[position] !== 151 || data[position + 1] !== 74 || data[position + 2] !== 66 || data[position + 3] !== 50 || data[position + 4] !== 13 || data[position + 5] !== 10 || data[position + 6] !== 26 || data[position + 7] !== 10) { error("JBIG2 error: invalid header"); } @@ -6573,18 +6610,20 @@ var PDFJS; header.numberOfPages = readUint32(data, position); position += 4; } - var visitor = this.parseChunks([ { + var visitor = this.parseChunks([{ data: data, start: position, end: end - } ]); + }]); var width = visitor.currentPageInfo.width; var height = visitor.currentPageInfo.height; var bitPacked = visitor.buffer; var data = new Uint8Array(width * height); - var q = 0, k = 0; + var q = 0, + k = 0; for (var i = 0; i < height; i++) { - var mask = 0, buffer; + var mask = 0, + buffer; for (var j = 0; j < width; j++) { if (!mask) { mask = 128; @@ -6608,17 +6647,20 @@ var JpegDecoder = PDFJS.JpegImage; var JpxDecoder = PDFJS.JpxImage; var Jbig2Decoder = PDFJS.Jbig2Image; + },{}],5:[function(require,module,exports){ (function (Buffer){ -'use strict'; +"use strict"; -module.exports.toBuffer = toBuffer; -module.exports.toArrayBuffer = toArrayBuffer; -module.exports.toUint8Array = toUint8Array; -module.exports.toArrayLike = toArrayLike; - -module.exports.bufferToArrayBuffer = bufferToArrayBuffer; -module.exports.arrayBufferToBuffer = arrayBufferToBuffer; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.toBuffer = toBuffer; +exports.toArrayBuffer = toArrayBuffer; +exports.toUint8Array = toUint8Array; +exports.toArrayLike = toArrayLike; +exports.bufferToArrayBuffer = bufferToArrayBuffer; +exports.arrayBufferToBuffer = arrayBufferToBuffer; /** * Converts the buffer to Buffer @@ -6626,11 +6668,11 @@ module.exports.arrayBufferToBuffer = arrayBufferToBuffer; * @returns {Buffer} */ function toBuffer(buf) { - if(buf instanceof ArrayBuffer) { + if (buf instanceof ArrayBuffer) { return arrayBufferToBuffer(buf); - } else if(Buffer.isBuffer(buf)) { + } else if (Buffer.isBuffer(buf)) { return buf; - } else if(buf instanceof Uint8Array) { + } else if (buf instanceof Uint8Array) { return new Buffer(buf); } else { return buf; // type unknown, trust the user @@ -6643,11 +6685,11 @@ function toBuffer(buf) { * @returns {ArrayBuffer} */ function toArrayBuffer(buf) { - if(buf instanceof ArrayBuffer) { + if (buf instanceof ArrayBuffer) { return buf; - } else if(Buffer.isBuffer(buf)) { + } else if (Buffer.isBuffer(buf)) { return bufferToArrayBuffer(buf); - } else if(buf instanceof Uint8Array) { + } else if (buf instanceof Uint8Array) { return bufferToArrayBuffer(buf); } else { return buf; // type unknown, trust the user @@ -6660,11 +6702,11 @@ function toArrayBuffer(buf) { * @returns {Uint8Array} */ function toUint8Array(buf) { - if(buf instanceof Uint8Array) { + if (buf instanceof Uint8Array) { return buf; - } else if(buf instanceof ArrayBuffer) { + } else if (buf instanceof ArrayBuffer) { return new Uint8Array(buf); - } else if(Buffer.isBuffer(buf)) { + } else if (Buffer.isBuffer(buf)) { return new Uint8Array(buf); } else { return buf; // type unknown, trust the user @@ -6677,11 +6719,11 @@ function toUint8Array(buf) { * @returns {Buffer|Uint8Array} */ function toArrayLike(buf) { - if(buf instanceof Uint8Array) { + if (buf instanceof Uint8Array) { return buf; - } else if(buf instanceof ArrayBuffer) { + } else if (buf instanceof ArrayBuffer) { return new Uint8Array(buf); - } else if(Buffer.isBuffer(buf)) { + } else if (Buffer.isBuffer(buf)) { return buf; } else { return buf; // type unknown, trust the user @@ -6712,15 +6754,19 @@ function arrayBufferToBuffer(arr) { } }).call(this,require("buffer").Buffer) -},{"buffer":21}],6:[function(require,module,exports){ +},{"buffer":22}],6:[function(require,module,exports){ 'use strict'; -module.exports = function(self) { +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports.default = function (self) { var decode = require('./decode'); + self.onmessage = function (_ref) { + var msg = _ref.data; - self.onmessage = function (ev) { - var msg = ev.data; - decode(msg.buf, msg.options, function(err, result) { + decode(msg.buf, msg.options, function (err, result) { if (err) { var errValue = err instanceof Error ? err.message : err; // Error is not clonable self.postMessage({ err: errValue }); @@ -6731,13 +6777,18 @@ module.exports = function(self) { }; }; +; +module.exports = exports['default']; + },{"./decode":7}],7:[function(require,module,exports){ 'use strict'; -var JpegImage = require('./backend/jpg').JpegImage; - -module.exports = decode; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = decode; +var _jpg = require('./backend/jpg'); /** * Decode the JPEG data @@ -6760,7 +6811,7 @@ function decode(buf, options, cb) { } try { - var j = new JpegImage(); + var j = new _jpg.JpegImage(); j.parse(buf); var width = options.width || j.width; @@ -6774,24 +6825,29 @@ function decode(buf, options, cb) { }; cb(null, result); - } catch(err) { - if(typeof err === 'string') { + } catch (err) { + if (typeof err === 'string') { // jpg.js throws 'string' values, convert to an Error err = new Error(err); } cb(err); } } +module.exports = exports['default']; },{"./backend/jpg":4}],8:[function(require,module,exports){ 'use strict'; -module.exports = function(self) { +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports.default = function (self) { var encode = require('./encode'); + self.onmessage = function (_ref) { + var msg = _ref.data; - self.onmessage = function (ev) { - var msg = ev.data; - encode(msg.buf, msg.options, function(err, result) { + encode(msg.buf, msg.options, function (err, result) { if (err) { var errValue = err instanceof Error ? err.message : err; // Error is not clonable self.postMessage({ err: errValue }); @@ -6802,12 +6858,22 @@ module.exports = function(self) { }; }; +; +module.exports = exports['default']; + },{"./encode":9}],9:[function(require,module,exports){ 'use strict'; -var encoder = require('./backend/encoder'); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = encode; -module.exports = encode; +var _encoder = require('./backend/encoder'); + +var _encoder2 = _interopRequireDefault(_encoder); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Encode the data to JPEG format @@ -6825,22 +6891,27 @@ function encode(buf, options, cb) { width: options.width, height: options.height }; - var data = encoder(imageData, options.quality); + var data = (0, _encoder2.default)(imageData, options.quality); cb(null, data); - } catch(err) { + } catch (err) { cb(err); } } +module.exports = exports['default']; },{"./backend/encoder":3}],10:[function(require,module,exports){ 'use strict'; -module.exports = function(self) { +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports.default = function (self) { var exif = require('./exif'); + self.onmessage = function (_ref) { + var msg = _ref.data; - self.onmessage = function (ev) { - var msg = ev.data; - exif(msg.buf, {}, function(err, result) { + exif(msg.buf, {}, function (err, result) { if (err) { var errValue = err instanceof Error ? err.message : err; // Error is not clonable self.postMessage({ err: errValue }); @@ -6851,13 +6922,18 @@ module.exports = function(self) { }; }; +; +module.exports = exports['default']; + },{"./exif":11}],11:[function(require,module,exports){ 'use strict'; -var ExifReader = require('./backend/ExifReader').ExifReader; - -module.exports = exif; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = exif; +var _ExifReader = require('./backend/ExifReader'); /** * Read EXIF data from the provided buffer @@ -6870,57 +6946,69 @@ module.exports = exif; */ function exif(buf, options, cb) { try { - var exif = new ExifReader(); - exif.load(buf); + var _exif = new _ExifReader.ExifReader(); + _exif.load(buf); // The MakerNote tag can be really large. Remove it to lower memory usage. - if(!options.hasOwnProperty('hasMakerNote') || !options.hasMakerNote) { - exif.deleteTag('MakerNote'); + if (!options.hasOwnProperty('hasMakerNote') || !options.hasMakerNote) { + _exif.deleteTag('MakerNote'); } - var metadata = exif.getAllTags(); + var metadata = _exif.getAllTags(); cb(null, metadata); - } catch(err) { - if(err.message === 'No Exif data') { + } catch (err) { + if (err.message === 'No Exif data') { cb(null, {}); } else { cb(err); } } } +module.exports = exports['default']; },{"./backend/ExifReader":2}],12:[function(require,module,exports){ 'use strict'; -var hasWorker = (typeof window !== 'undefined') && ('Worker' in window); +Object.defineProperty(exports, "__esModule", { + value: true +}); +var hasWorker = typeof window !== 'undefined' && 'Worker' in window; + if (hasWorker) { try { var w = require('webworkify')(function () {}); w.terminate(); } catch (e) { - hasWorker = false; + exports.hasWorker = hasWorker = false; } } -module.exports.HAS_WORKER = hasWorker; +exports.hasWorker = hasWorker; -},{"webworkify":60}],13:[function(require,module,exports){ +},{"webworkify":54}],13:[function(require,module,exports){ 'use strict'; -var imageinfo = require('imageinfo'); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = info; + +var _imageinfo = require('imageinfo'); + +var _imageinfo2 = _interopRequireDefault(_imageinfo); -module.exports.collect = collect; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Get image information * @param {Buffer} buf Image or image part that contains image parameters * @param {function} cb Callback to invoke on completion */ -function collect(buf, cb) { - setTimeout(function() { - var info = imageinfo(buf); - if(!info) { +function info(buf, cb) { + setTimeout(function () { + var info = (0, _imageinfo2.default)(buf); + if (!info) { cb(new Error('Cannot get image info')); } else { cb(null, { @@ -6933,7 +7021,9 @@ function collect(buf, cb) { } }, 0); } -},{"imageinfo":27}],14:[function(require,module,exports){ +module.exports = exports['default']; + +},{"imageinfo":26}],14:[function(require,module,exports){ module.exports={ "474946383961": { "mimeType": "image/gif", @@ -6991,69 +7081,140 @@ module.exports={ },{}],15:[function(require,module,exports){ 'use strict'; -var find = require('lodash.find'); -var db = require('./magic-db'); -var debug = require('debug')('inkjet:magic'); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = magic; + +var _magicDb = require('./magic-db'); + +var _magicDb2 = _interopRequireDefault(_magicDb); -module.exports.lookup = lookup; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Lookup the magic number in magic-number DB * @param {Buffer} buf Data buffer * @param {function} cb Callback to invoke on completion */ -function lookup(buf, cb) { - setTimeout(function() { +function magic(buf, cb) { + setTimeout(function () { var sampleLength = 24; var sample = buf.slice(0, sampleLength).toString('hex'); // lookup data - var keys = Object.keys(db); - var found = find(keys, function(it) { - debug('%s <---- %s', sample, it); - return (sample.indexOf(it) != -1); + var found = Object.keys(_magicDb2.default).find(function (it) { + return sample.indexOf(it) != -1; }); - if(found) { - cb(null, db[found]); + if (found) { + cb(null, _magicDb2.default[found]); } else { cb(new Error('Magic number not found')); } }, 0); } +module.exports = exports['default']; -},{"./magic-db":14,"debug":23,"lodash.find":36}],16:[function(require,module,exports){ -// http://wiki.commonjs.org/wiki/Unit_Testing/1.0 -// -// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! -// -// Originally from narwhal.js (http://narwhaljs.org) -// Copyright (c) 2009 Thomas Robinson <280north.com> -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the 'Software'), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +},{"./magic-db":14}],16:[function(require,module,exports){ +(function (global){ +'use strict'; + +// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js +// original notice: + +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +function compare(a, b) { + if (a === b) { + return 0; + } + + var x = a.length; + var y = b.length; + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break; + } + } + + if (x < y) { + return -1; + } + if (y < x) { + return 1; + } + return 0; +} +function isBuffer(b) { + if (global.Buffer && typeof global.Buffer.isBuffer === 'function') { + return global.Buffer.isBuffer(b); + } + return !!(b != null && b._isBuffer); +} + +// based on node assert, original notice: + +// http://wiki.commonjs.org/wiki/Unit_Testing/1.0 +// +// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! +// +// Originally from narwhal.js (http://narwhaljs.org) +// Copyright (c) 2009 Thomas Robinson <280north.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the 'Software'), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// when used in node, this will actually load the util module we depend on -// versus loading the builtin util module as happens otherwise -// this is a bug in node module loading as far as I am concerned var util = require('util/'); - -var pSlice = Array.prototype.slice; var hasOwn = Object.prototype.hasOwnProperty; - +var pSlice = Array.prototype.slice; +var functionsHaveNames = (function () { + return function foo() {}.name === 'foo'; +}()); +function pToString (obj) { + return Object.prototype.toString.call(obj); +} +function isView(arrbuf) { + if (isBuffer(arrbuf)) { + return false; + } + if (typeof global.ArrayBuffer !== 'function') { + return false; + } + if (typeof ArrayBuffer.isView === 'function') { + return ArrayBuffer.isView(arrbuf); + } + if (!arrbuf) { + return false; + } + if (arrbuf instanceof DataView) { + return true; + } + if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) { + return true; + } + return false; +} // 1. The assert module provides functions that throw // AssertionError's when particular conditions are not met. The // assert module must conform to the following interface. @@ -7065,6 +7226,19 @@ var assert = module.exports = ok; // actual: actual, // expected: expected }) +var regex = /\s*function\s+([^\(\s]*)\s*/; +// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js +function getName(func) { + if (!util.isFunction(func)) { + return; + } + if (functionsHaveNames) { + return func.name; + } + var str = func.toString(); + var match = str.match(regex); + return match && match[1]; +} assert.AssertionError = function AssertionError(options) { this.name = 'AssertionError'; this.actual = options.actual; @@ -7078,18 +7252,16 @@ assert.AssertionError = function AssertionError(options) { this.generatedMessage = true; } var stackStartFunction = options.stackStartFunction || fail; - if (Error.captureStackTrace) { Error.captureStackTrace(this, stackStartFunction); - } - else { + } else { // non v8 browsers so we can have a stacktrace var err = new Error(); if (err.stack) { var out = err.stack; // try to strip useless frames - var fn_name = stackStartFunction.name; + var fn_name = getName(stackStartFunction); var idx = out.indexOf('\n' + fn_name); if (idx >= 0) { // once we have located the function frame @@ -7106,31 +7278,25 @@ assert.AssertionError = function AssertionError(options) { // assert.AssertionError instanceof Error util.inherits(assert.AssertionError, Error); -function replacer(key, value) { - if (util.isUndefined(value)) { - return '' + value; - } - if (util.isNumber(value) && !isFinite(value)) { - return value.toString(); - } - if (util.isFunction(value) || util.isRegExp(value)) { - return value.toString(); - } - return value; -} - function truncate(s, n) { - if (util.isString(s)) { + if (typeof s === 'string') { return s.length < n ? s : s.slice(0, n); } else { return s; } } - +function inspect(something) { + if (functionsHaveNames || !util.isFunction(something)) { + return util.inspect(something); + } + var rawname = getName(something); + var name = rawname ? ': ' + rawname : ''; + return '[Function' + name + ']'; +} function getMessage(self) { - return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' + + return truncate(inspect(self.actual), 128) + ' ' + self.operator + ' ' + - truncate(JSON.stringify(self.expected, replacer), 128); + truncate(inspect(self.expected), 128); } // At present only the three keys mentioned above are used and @@ -7190,24 +7356,23 @@ assert.notEqual = function notEqual(actual, expected, message) { // assert.deepEqual(actual, expected, message_opt); assert.deepEqual = function deepEqual(actual, expected, message) { - if (!_deepEqual(actual, expected)) { + if (!_deepEqual(actual, expected, false)) { fail(actual, expected, message, 'deepEqual', assert.deepEqual); } }; -function _deepEqual(actual, expected) { +assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { + if (!_deepEqual(actual, expected, true)) { + fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual); + } +}; + +function _deepEqual(actual, expected, strict, memos) { // 7.1. All identical values are equivalent, as determined by ===. if (actual === expected) { return true; - - } else if (util.isBuffer(actual) && util.isBuffer(expected)) { - if (actual.length != expected.length) return false; - - for (var i = 0; i < actual.length; i++) { - if (actual[i] !== expected[i]) return false; - } - - return true; + } else if (isBuffer(actual) && isBuffer(expected)) { + return compare(actual, expected) === 0; // 7.2. If the expected value is a Date object, the actual value is // equivalent if it is also a Date object that refers to the same time. @@ -7226,8 +7391,22 @@ function _deepEqual(actual, expected) { // 7.4. Other pairs that do not both pass typeof value == 'object', // equivalence is determined by ==. - } else if (!util.isObject(actual) && !util.isObject(expected)) { - return actual == expected; + } else if ((actual === null || typeof actual !== 'object') && + (expected === null || typeof expected !== 'object')) { + return strict ? actual === expected : actual == expected; + + // If both values are instances of typed arrays, wrap their underlying + // ArrayBuffers in a Buffer each to increase performance + // This optimization requires the arrays to have the same type as checked by + // Object.prototype.toString (aka pToString). Never perform binary + // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their + // bit patterns are not identical. + } else if (isView(actual) && isView(expected) && + pToString(actual) === pToString(expected) && + !(actual instanceof Float32Array || + actual instanceof Float64Array)) { + return compare(new Uint8Array(actual.buffer), + new Uint8Array(expected.buffer)) === 0; // 7.5 For all other Object pairs, including Array objects, equivalence is // determined by having the same number of owned properties (as verified @@ -7235,8 +7414,22 @@ function _deepEqual(actual, expected) { // (although not necessarily the same order), equivalent values for every // corresponding key, and an identical 'prototype' property. Note: this // accounts for both named and indexed properties on Arrays. + } else if (isBuffer(actual) !== isBuffer(expected)) { + return false; } else { - return objEquiv(actual, expected); + memos = memos || {actual: [], expected: []}; + + var actualIndex = memos.actual.indexOf(actual); + if (actualIndex !== -1) { + if (actualIndex === memos.expected.indexOf(expected)) { + return true; + } + } + + memos.actual.push(actual); + memos.expected.push(expected); + + return objEquiv(actual, expected, strict, memos); } } @@ -7244,44 +7437,44 @@ function isArguments(object) { return Object.prototype.toString.call(object) == '[object Arguments]'; } -function objEquiv(a, b) { - if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b)) +function objEquiv(a, b, strict, actualVisitedObjects) { + if (a === null || a === undefined || b === null || b === undefined) return false; - // an identical 'prototype' property. - if (a.prototype !== b.prototype) return false; // if one is a primitive, the other must be same - if (util.isPrimitive(a) || util.isPrimitive(b)) { + if (util.isPrimitive(a) || util.isPrimitive(b)) return a === b; - } - var aIsArgs = isArguments(a), - bIsArgs = isArguments(b); + if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) + return false; + var aIsArgs = isArguments(a); + var bIsArgs = isArguments(b); if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) return false; if (aIsArgs) { a = pSlice.call(a); b = pSlice.call(b); - return _deepEqual(a, b); + return _deepEqual(a, b, strict); } - var ka = objectKeys(a), - kb = objectKeys(b), - key, i; + var ka = objectKeys(a); + var kb = objectKeys(b); + var key, i; // having the same number of owned properties (keys incorporates // hasOwnProperty) - if (ka.length != kb.length) + if (ka.length !== kb.length) return false; //the same set of keys (although not necessarily the same order), ka.sort(); kb.sort(); //~~~cheap key test for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) + if (ka[i] !== kb[i]) return false; } //equivalent values for every corresponding key, and //~~~possibly expensive deep test for (i = ka.length - 1; i >= 0; i--) { key = ka[i]; - if (!_deepEqual(a[key], b[key])) return false; + if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) + return false; } return true; } @@ -7290,11 +7483,19 @@ function objEquiv(a, b) { // assert.notDeepEqual(actual, expected, message_opt); assert.notDeepEqual = function notDeepEqual(actual, expected, message) { - if (_deepEqual(actual, expected)) { + if (_deepEqual(actual, expected, false)) { fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); } }; +assert.notDeepStrictEqual = notDeepStrictEqual; +function notDeepStrictEqual(actual, expected, message) { + if (_deepEqual(actual, expected, true)) { + fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual); + } +} + + // 9. The strict equality assertion tests strict equality, as determined by ===. // assert.strictEqual(actual, expected, message_opt); @@ -7320,28 +7521,46 @@ function expectedException(actual, expected) { if (Object.prototype.toString.call(expected) == '[object RegExp]') { return expected.test(actual); - } else if (actual instanceof expected) { - return true; - } else if (expected.call({}, actual) === true) { - return true; } - return false; + try { + if (actual instanceof expected) { + return true; + } + } catch (e) { + // Ignore. The instanceof check doesn't work for arrow functions. + } + + if (Error.isPrototypeOf(expected)) { + return false; + } + + return expected.call({}, actual) === true; +} + +function _tryBlock(block) { + var error; + try { + block(); + } catch (e) { + error = e; + } + return error; } function _throws(shouldThrow, block, expected, message) { var actual; - if (util.isString(expected)) { + if (typeof block !== 'function') { + throw new TypeError('"block" argument must be a function'); + } + + if (typeof expected === 'string') { message = expected; expected = null; } - try { - block(); - } catch (e) { - actual = e; - } + actual = _tryBlock(block); message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + (message ? ' ' + message : '.'); @@ -7350,7 +7569,14 @@ function _throws(shouldThrow, block, expected, message) { fail(actual, expected, 'Missing expected exception' + message); } - if (!shouldThrow && expectedException(actual, expected)) { + var userProvidedMessage = typeof message === 'string'; + var isUnwantedException = !shouldThrow && util.isError(actual); + var isUnexpectedException = !shouldThrow && actual && !expected; + + if ((isUnwantedException && + userProvidedMessage && + expectedException(actual, expected)) || + isUnexpectedException) { fail(actual, expected, 'Got unwanted exception' + message); } @@ -7364,15 +7590,15 @@ function _throws(shouldThrow, block, expected, message) { // assert.throws(block, Error_opt, message_opt); assert.throws = function(block, /*optional*/error, /*optional*/message) { - _throws.apply(this, [true].concat(pSlice.call(arguments))); + _throws(true, block, error, message); }; // EXTENSION! This is annoying to write outside this module. -assert.doesNotThrow = function(block, /*optional*/message) { - _throws.apply(this, [false].concat(pSlice.call(arguments))); +assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { + _throws(false, block, error, message); }; -assert.ifError = function(err) { if (err) {throw err;}}; +assert.ifError = function(err) { if (err) throw err; }; var objectKeys = Object.keys || function (obj) { var keys = []; @@ -7382,9 +7608,11 @@ var objectKeys = Object.keys || function (obj) { return keys; }; -},{"util/":59}],17:[function(require,module,exports){ +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"util/":53}],17:[function(require,module,exports){ 'use strict' +exports.byteLength = byteLength exports.toByteArray = toByteArray exports.fromByteArray = fromByteArray @@ -7392,23 +7620,17 @@ var lookup = [] var revLookup = [] var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array -function init () { - var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' - for (var i = 0, len = code.length; i < len; ++i) { - lookup[i] = code[i] - revLookup[code.charCodeAt(i)] = i - } - - revLookup['-'.charCodeAt(0)] = 62 - revLookup['_'.charCodeAt(0)] = 63 +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i } -init() +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 -function toByteArray (b64) { - var i, j, l, tmp, placeHolders, arr +function placeHoldersCount (b64) { var len = b64.length - if (len % 4 > 0) { throw new Error('Invalid string. Length must be a multiple of 4') } @@ -7418,9 +7640,19 @@ function toByteArray (b64) { // represent one byte // if there is only one, then the three characters before it represent 2 bytes // this is just a cheap hack to not do indexOf twice - placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 +} +function byteLength (b64) { // base64 is 4/3 + up to two characters of the original data + return b64.length * 3 / 4 - placeHoldersCount(b64) +} + +function toByteArray (b64) { + var i, j, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) + arr = new Arr(len * 3 / 4 - placeHolders) // if there are placeholders, only get up to the last complete 4 chars @@ -7735,7 +7967,7 @@ Zlib.prototype._error = function(status) { exports.Zlib = Zlib; }).call(this,require('_process'),require("buffer").Buffer) -},{"_process":50,"buffer":21,"pako/lib/zlib/constants":40,"pako/lib/zlib/deflate.js":42,"pako/lib/zlib/inflate.js":44,"pako/lib/zlib/messages":46,"pako/lib/zlib/zstream":48}],20:[function(require,module,exports){ +},{"_process":42,"buffer":22,"pako/lib/zlib/constants":32,"pako/lib/zlib/deflate.js":34,"pako/lib/zlib/inflate.js":36,"pako/lib/zlib/messages":38,"pako/lib/zlib/zstream":40}],20:[function(require,module,exports){ (function (process,Buffer){ // Copyright Joyent, Inc. and other Node contributors. // @@ -8349,8 +8581,119 @@ util.inherits(InflateRaw, Zlib); util.inherits(Unzip, Zlib); }).call(this,require('_process'),require("buffer").Buffer) -},{"./binding":19,"_process":50,"_stream_transform":55,"assert":16,"buffer":21,"util":59}],21:[function(require,module,exports){ +},{"./binding":19,"_process":42,"_stream_transform":48,"assert":16,"buffer":22,"util":53}],21:[function(require,module,exports){ (function (global){ +'use strict'; + +var buffer = require('buffer'); +var Buffer = buffer.Buffer; +var SlowBuffer = buffer.SlowBuffer; +var MAX_LEN = buffer.kMaxLength || 2147483647; +exports.alloc = function alloc(size, fill, encoding) { + if (typeof Buffer.alloc === 'function') { + return Buffer.alloc(size, fill, encoding); + } + if (typeof encoding === 'number') { + throw new TypeError('encoding must not be number'); + } + if (typeof size !== 'number') { + throw new TypeError('size must be a number'); + } + if (size > MAX_LEN) { + throw new RangeError('size is too large'); + } + var enc = encoding; + var _fill = fill; + if (_fill === undefined) { + enc = undefined; + _fill = 0; + } + var buf = new Buffer(size); + if (typeof _fill === 'string') { + var fillBuf = new Buffer(_fill, enc); + var flen = fillBuf.length; + var i = -1; + while (++i < size) { + buf[i] = fillBuf[i % flen]; + } + } else { + buf.fill(_fill); + } + return buf; +} +exports.allocUnsafe = function allocUnsafe(size) { + if (typeof Buffer.allocUnsafe === 'function') { + return Buffer.allocUnsafe(size); + } + if (typeof size !== 'number') { + throw new TypeError('size must be a number'); + } + if (size > MAX_LEN) { + throw new RangeError('size is too large'); + } + return new Buffer(size); +} +exports.from = function from(value, encodingOrOffset, length) { + if (typeof Buffer.from === 'function' && (!global.Uint8Array || Uint8Array.from !== Buffer.from)) { + return Buffer.from(value, encodingOrOffset, length); + } + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number'); + } + if (typeof value === 'string') { + return new Buffer(value, encodingOrOffset); + } + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + var offset = encodingOrOffset; + if (arguments.length === 1) { + return new Buffer(value); + } + if (typeof offset === 'undefined') { + offset = 0; + } + var len = length; + if (typeof len === 'undefined') { + len = value.byteLength - offset; + } + if (offset >= value.byteLength) { + throw new RangeError('\'offset\' is out of bounds'); + } + if (len > value.byteLength - offset) { + throw new RangeError('\'length\' is out of bounds'); + } + return new Buffer(value.slice(offset, offset + len)); + } + if (Buffer.isBuffer(value)) { + var out = new Buffer(value.length); + value.copy(out, 0, 0, value.length); + return out; + } + if (value) { + if (Array.isArray(value) || (typeof ArrayBuffer !== 'undefined' && value.buffer instanceof ArrayBuffer) || 'length' in value) { + return new Buffer(value); + } + if (value.type === 'Buffer' && Array.isArray(value.data)) { + return new Buffer(value.data); + } + } + + throw new TypeError('First argument must be a string, Buffer, ' + 'ArrayBuffer, Array, or array-like object.'); +} +exports.allocUnsafeSlow = function allocUnsafeSlow(size) { + if (typeof Buffer.allocUnsafeSlow === 'function') { + return Buffer.allocUnsafeSlow(size); + } + if (typeof size !== 'number') { + throw new TypeError('size must be a number'); + } + if (size >= MAX_LEN) { + throw new RangeError('size is too large'); + } + return new SlowBuffer(size); +} + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"buffer":22}],22:[function(require,module,exports){ /*! * The buffer module from node.js, for the browser. * @@ -8363,80 +8706,57 @@ util.inherits(Unzip, Zlib); var base64 = require('base64-js') var ieee754 = require('ieee754') -var isArray = require('isarray') exports.Buffer = Buffer exports.SlowBuffer = SlowBuffer exports.INSPECT_MAX_BYTES = 50 +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH + /** * If `Buffer.TYPED_ARRAY_SUPPORT`: * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (most compatible, even IE6) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) * * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, * Opera 11.6+, iOS 4.2+. * - * Due to various browser bugs, sometimes the Object implementation will be used even - * when the browser supports typed arrays. - * - * Note: - * - * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. - * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. - * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. - - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they - * get the Object implementation, which is slower but behaves correctly. + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. */ -Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined - ? global.TYPED_ARRAY_SUPPORT - : typedArraySupport() +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() -/* - * Export kMaxLength after typed array support is determined. - */ -exports.kMaxLength = kMaxLength() +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) +} function typedArraySupport () { + // Can typed array instances can be augmented? try { var arr = new Uint8Array(1) - arr.foo = function () { return 42 } - return arr.foo() === 42 && // typed array instances can be augmented - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 } catch (e) { return false } } -function kMaxLength () { - return Buffer.TYPED_ARRAY_SUPPORT - ? 0x7fffffff - : 0x3fffffff -} - -function createBuffer (that, length) { - if (kMaxLength() < length) { +function createBuffer (length) { + if (length > K_MAX_LENGTH) { throw new RangeError('Invalid typed array length') } - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = new Uint8Array(length) - that.__proto__ = Buffer.prototype - } else { - // Fallback: Return an object instance of the Buffer class - if (that === null) { - that = new Buffer(length) - } - that.length = length - } - - return that + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf } /** @@ -8450,10 +8770,6 @@ function createBuffer (that, length) { */ function Buffer (arg, encodingOrOffset, length) { - if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { - return new Buffer(arg, encodingOrOffset, length) - } - // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { @@ -8461,33 +8777,38 @@ function Buffer (arg, encodingOrOffset, length) { 'If encoding is specified then the first argument must be a string' ) } - return allocUnsafe(this, arg) + return allocUnsafe(arg) } - return from(this, arg, encodingOrOffset, length) + return from(arg, encodingOrOffset, length) } -Buffer.poolSize = 8192 // not used by this implementation - -// TODO: Legacy, not needed anymore. Remove in next major version. -Buffer._augment = function (arr) { - arr.__proto__ = Buffer.prototype - return arr +// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) } -function from (that, value, encodingOrOffset, length) { +Buffer.poolSize = 8192 // not used by this implementation + +function from (value, encodingOrOffset, length) { if (typeof value === 'number') { throw new TypeError('"value" argument must not be a number') } - if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { - return fromArrayBuffer(that, value, encodingOrOffset, length) + if (value instanceof ArrayBuffer) { + return fromArrayBuffer(value, encodingOrOffset, length) } if (typeof value === 'string') { - return fromString(that, value, encodingOrOffset) + return fromString(value, encodingOrOffset) } - return fromObject(that, value) + return fromObject(value) } /** @@ -8499,42 +8820,36 @@ function from (that, value, encodingOrOffset, length) { * Buffer.from(arrayBuffer[, byteOffset[, length]]) **/ Buffer.from = function (value, encodingOrOffset, length) { - return from(null, value, encodingOrOffset, length) + return from(value, encodingOrOffset, length) } -if (Buffer.TYPED_ARRAY_SUPPORT) { - Buffer.prototype.__proto__ = Uint8Array.prototype - Buffer.__proto__ = Uint8Array - if (typeof Symbol !== 'undefined' && Symbol.species && - Buffer[Symbol.species] === Buffer) { - // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true - }) - } -} +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Buffer.prototype.__proto__ = Uint8Array.prototype +Buffer.__proto__ = Uint8Array function assertSize (size) { if (typeof size !== 'number') { throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') } } -function alloc (that, size, fill, encoding) { +function alloc (size, fill, encoding) { assertSize(size) if (size <= 0) { - return createBuffer(that, size) + return createBuffer(size) } if (fill !== undefined) { // Only pay attention to encoding if it's a string. This // prevents accidentally sending in a number that would // be interpretted as a start offset. return typeof encoding === 'string' - ? createBuffer(that, size).fill(fill, encoding) - : createBuffer(that, size).fill(fill) + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) } - return createBuffer(that, size) + return createBuffer(size) } /** @@ -8542,34 +8857,28 @@ function alloc (that, size, fill, encoding) { * alloc(size[, fill[, encoding]]) **/ Buffer.alloc = function (size, fill, encoding) { - return alloc(null, size, fill, encoding) + return alloc(size, fill, encoding) } -function allocUnsafe (that, size) { +function allocUnsafe (size) { assertSize(size) - that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < size; i++) { - that[i] = 0 - } - } - return that + return createBuffer(size < 0 ? 0 : checked(size) | 0) } /** * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. * */ Buffer.allocUnsafe = function (size) { - return allocUnsafe(null, size) + return allocUnsafe(size) } /** * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. */ Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(null, size) + return allocUnsafe(size) } -function fromString (that, string, encoding) { +function fromString (string, encoding) { if (typeof encoding !== 'string' || encoding === '') { encoding = 'utf8' } @@ -8579,24 +8888,30 @@ function fromString (that, string, encoding) { } var length = byteLength(string, encoding) | 0 - that = createBuffer(that, length) + var buf = createBuffer(length) + + var actual = buf.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } - that.write(string, encoding) - return that + return buf } -function fromArrayLike (that, array) { - var length = checked(array.length) | 0 - that = createBuffer(that, length) +function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 + buf[i] = array[i] & 255 } - return that + return buf } -function fromArrayBuffer (that, array, byteOffset, length) { - array.byteLength // this throws if `array` is not a valid ArrayBuffer - +function fromArrayBuffer (array, byteOffset, length) { if (byteOffset < 0 || array.byteLength < byteOffset) { throw new RangeError('\'offset\' is out of bounds') } @@ -8605,47 +8920,43 @@ function fromArrayBuffer (that, array, byteOffset, length) { throw new RangeError('\'length\' is out of bounds') } - if (length === undefined) { - array = new Uint8Array(array, byteOffset) + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) } else { - array = new Uint8Array(array, byteOffset, length) + buf = new Uint8Array(array, byteOffset, length) } - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = array - that.__proto__ = Buffer.prototype - } else { - // Fallback: Return an object instance of the Buffer class - that = fromArrayLike(that, array) - } - return that + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf } -function fromObject (that, obj) { +function fromObject (obj) { if (Buffer.isBuffer(obj)) { var len = checked(obj.length) | 0 - that = createBuffer(that, len) + var buf = createBuffer(len) - if (that.length === 0) { - return that + if (buf.length === 0) { + return buf } - obj.copy(that, 0, 0, len) - return that + obj.copy(buf, 0, 0, len) + return buf } if (obj) { - if ((typeof ArrayBuffer !== 'undefined' && - obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (ArrayBuffer.isView(obj) || 'length' in obj) { if (typeof obj.length !== 'number' || isnan(obj.length)) { - return createBuffer(that, 0) + return createBuffer(0) } - return fromArrayLike(that, obj) + return fromArrayLike(obj) } - if (obj.type === 'Buffer' && isArray(obj.data)) { - return fromArrayLike(that, obj.data) + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) } } @@ -8653,11 +8964,11 @@ function fromObject (that, obj) { } function checked (length) { - // Note: cannot use `length < kMaxLength` here because that fails when + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when // length is NaN (which is otherwise coerced to zero.) - if (length >= kMaxLength()) { + if (length >= K_MAX_LENGTH) { throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + kMaxLength().toString(16) + ' bytes') + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') } return length | 0 } @@ -8670,7 +8981,7 @@ function SlowBuffer (length) { } Buffer.isBuffer = function isBuffer (b) { - return !!(b != null && b._isBuffer) + return b != null && b._isBuffer === true } Buffer.compare = function compare (a, b) { @@ -8702,9 +9013,9 @@ Buffer.isEncoding = function isEncoding (encoding) { case 'utf8': case 'utf-8': case 'ascii': + case 'latin1': case 'binary': case 'base64': - case 'raw': case 'ucs2': case 'ucs-2': case 'utf16le': @@ -8716,7 +9027,7 @@ Buffer.isEncoding = function isEncoding (encoding) { } Buffer.concat = function concat (list, length) { - if (!isArray(list)) { + if (!Array.isArray(list)) { throw new TypeError('"list" argument must be an Array of Buffers') } @@ -8727,14 +9038,14 @@ Buffer.concat = function concat (list, length) { var i if (length === undefined) { length = 0 - for (i = 0; i < list.length; i++) { + for (i = 0; i < list.length; ++i) { length += list[i].length } } var buffer = Buffer.allocUnsafe(length) var pos = 0 - for (i = 0; i < list.length; i++) { + for (i = 0; i < list.length; ++i) { var buf = list[i] if (!Buffer.isBuffer(buf)) { throw new TypeError('"list" argument must be an Array of Buffers') @@ -8749,8 +9060,7 @@ function byteLength (string, encoding) { if (Buffer.isBuffer(string)) { return string.length } - if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && - (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + if (ArrayBuffer.isView(string) || string instanceof ArrayBuffer) { return string.byteLength } if (typeof string !== 'string') { @@ -8765,10 +9075,8 @@ function byteLength (string, encoding) { for (;;) { switch (encoding) { case 'ascii': + case 'latin1': case 'binary': - // Deprecated - case 'raw': - case 'raws': return len case 'utf8': case 'utf-8': @@ -8841,8 +9149,9 @@ function slowToString (encoding, start, end) { case 'ascii': return asciiSlice(this, start, end) + case 'latin1': case 'binary': - return binarySlice(this, start, end) + return latin1Slice(this, start, end) case 'base64': return base64Slice(this, start, end) @@ -8861,8 +9170,12 @@ function slowToString (encoding, start, end) { } } -// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect -// Buffer instances. +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 Buffer.prototype._isBuffer = true function swap (b, n, m) { @@ -8894,8 +9207,22 @@ Buffer.prototype.swap32 = function swap32 () { return this } +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + Buffer.prototype.toString = function toString () { - var length = this.length | 0 + var length = this.length if (length === 0) return '' if (arguments.length === 0) return utf8Slice(this, 0, length) return slowToString.apply(this, arguments) @@ -8976,7 +9303,72 @@ Buffer.prototype.compare = function compare (target, start, end, thisStart, this return 0 } -function arrayIndexOf (arr, val, byteOffset, encoding) { +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { var indexSize = 1 var arrLength = arr.length var valLength = val.length @@ -9003,61 +9395,47 @@ function arrayIndexOf (arr, val, byteOffset, encoding) { } } - var foundIndex = -1 - for (var i = 0; byteOffset + i < arrLength; i++) { - if (read(arr, byteOffset + i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return (byteOffset + foundIndex) * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } } - } - return -1 -} - -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset >>= 0 - - if (this.length === 0) return -1 - if (byteOffset >= this.length) return -1 - - // Negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) - - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - if (Buffer.isBuffer(val)) { - // special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(this, val, byteOffset, encoding) - } - if (typeof val === 'number') { - if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { - return Uint8Array.prototype.indexOf.call(this, val, byteOffset) + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i } - return arrayIndexOf(this, [ val ], byteOffset, encoding) } - throw new TypeError('val must be string, number or Buffer') + return -1 } Buffer.prototype.includes = function includes (val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1 } +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + function hexWrite (buf, string, offset, length) { offset = Number(offset) || 0 var remaining = buf.length - offset @@ -9072,12 +9450,12 @@ function hexWrite (buf, string, offset, length) { // must be an even number of digits var strLen = string.length - if (strLen % 2 !== 0) throw new Error('Invalid hex string') + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') if (length > strLen / 2) { length = strLen / 2 } - for (var i = 0; i < length; i++) { + for (var i = 0; i < length; ++i) { var parsed = parseInt(string.substr(i * 2, 2), 16) if (isNaN(parsed)) return i buf[offset + i] = parsed @@ -9093,7 +9471,7 @@ function asciiWrite (buf, string, offset, length) { return blitBuffer(asciiToBytes(string), buf, offset, length) } -function binaryWrite (buf, string, offset, length) { +function latin1Write (buf, string, offset, length) { return asciiWrite(buf, string, offset, length) } @@ -9118,15 +9496,14 @@ Buffer.prototype.write = function write (string, offset, length, encoding) { offset = 0 // Buffer#write(string, offset[, length][, encoding]) } else if (isFinite(offset)) { - offset = offset | 0 + offset = offset >>> 0 if (isFinite(length)) { - length = length | 0 + length = length >>> 0 if (encoding === undefined) encoding = 'utf8' } else { encoding = length length = undefined } - // legacy write(string, encoding, offset, length) - remove in v0.13 } else { throw new Error( 'Buffer.write(string, encoding, offset[, length]) is no longer supported' @@ -9155,8 +9532,9 @@ Buffer.prototype.write = function write (string, offset, length, encoding) { case 'ascii': return asciiWrite(this, string, offset, length) + case 'latin1': case 'binary': - return binaryWrite(this, string, offset, length) + return latin1Write(this, string, offset, length) case 'base64': // Warning: maxLength not taken into account in base64Write @@ -9291,17 +9669,17 @@ function asciiSlice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) - for (var i = start; i < end; i++) { + for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i] & 0x7F) } return ret } -function binarySlice (buf, start, end) { +function latin1Slice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) - for (var i = start; i < end; i++) { + for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i]) } return ret @@ -9314,7 +9692,7 @@ function hexSlice (buf, start, end) { if (!end || end < 0 || end > len) end = len var out = '' - for (var i = start; i < end; i++) { + for (var i = start; i < end; ++i) { out += toHex(buf[i]) } return out @@ -9324,7 +9702,7 @@ function utf16leSlice (buf, start, end) { var bytes = buf.slice(start, end) var res = '' for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) } return res } @@ -9350,18 +9728,9 @@ Buffer.prototype.slice = function slice (start, end) { if (end < start) end = start - var newBuf - if (Buffer.TYPED_ARRAY_SUPPORT) { - newBuf = this.subarray(start, end) - newBuf.__proto__ = Buffer.prototype - } else { - var sliceLen = end - start - newBuf = new Buffer(sliceLen, undefined) - for (var i = 0; i < sliceLen; i++) { - newBuf[i] = this[i + start] - } - } - + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype return newBuf } @@ -9374,8 +9743,8 @@ function checkOffset (offset, ext, length) { } Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 + offset = offset >>> 0 + byteLength = byteLength >>> 0 if (!noAssert) checkOffset(offset, byteLength, this.length) var val = this[offset] @@ -9389,8 +9758,8 @@ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) } Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 + offset = offset >>> 0 + byteLength = byteLength >>> 0 if (!noAssert) { checkOffset(offset, byteLength, this.length) } @@ -9405,21 +9774,25 @@ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) } Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 1, this.length) return this[offset] } Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 2, this.length) return this[offset] | (this[offset + 1] << 8) } Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 2, this.length) return (this[offset] << 8) | this[offset + 1] } Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) return ((this[offset]) | @@ -9429,6 +9802,7 @@ Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { } Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset] * 0x1000000) + @@ -9438,8 +9812,8 @@ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { } Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 + offset = offset >>> 0 + byteLength = byteLength >>> 0 if (!noAssert) checkOffset(offset, byteLength, this.length) var val = this[offset] @@ -9456,8 +9830,8 @@ Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { } Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 + offset = offset >>> 0 + byteLength = byteLength >>> 0 if (!noAssert) checkOffset(offset, byteLength, this.length) var i = byteLength @@ -9474,24 +9848,28 @@ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { } Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 1, this.length) if (!(this[offset] & 0x80)) return (this[offset]) return ((0xff - this[offset] + 1) * -1) } Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 2, this.length) var val = this[offset] | (this[offset + 1] << 8) return (val & 0x8000) ? val | 0xFFFF0000 : val } Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 2, this.length) var val = this[offset + 1] | (this[offset] << 8) return (val & 0x8000) ? val | 0xFFFF0000 : val } Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset]) | @@ -9501,6 +9879,7 @@ Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { } Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset] << 24) | @@ -9510,21 +9889,25 @@ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { } Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) return ieee754.read(this, offset, true, 23, 4) } Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) return ieee754.read(this, offset, false, 23, 4) } Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 8, this.length) return ieee754.read(this, offset, true, 52, 8) } Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 8, this.length) return ieee754.read(this, offset, false, 52, 8) } @@ -9537,8 +9920,8 @@ function checkInt (buf, value, offset, ext, max, min) { Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { value = +value - offset = offset | 0 - byteLength = byteLength | 0 + offset = offset >>> 0 + byteLength = byteLength >>> 0 if (!noAssert) { var maxBytes = Math.pow(2, 8 * byteLength) - 1 checkInt(this, value, offset, byteLength, maxBytes, 0) @@ -9556,8 +9939,8 @@ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { value = +value - offset = offset | 0 - byteLength = byteLength | 0 + offset = offset >>> 0 + byteLength = byteLength >>> 0 if (!noAssert) { var maxBytes = Math.pow(2, 8 * byteLength) - 1 checkInt(this, value, offset, byteLength, maxBytes, 0) @@ -9575,89 +9958,57 @@ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) this[offset] = (value & 0xff) return offset + 1 } -function objectWriteUInt16 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { - buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> - (littleEndian ? i : 1 - i) * 8 - } -} - Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) return offset + 2 } Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - } else { - objectWriteUInt16(this, value, offset, false) - } + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) return offset + 2 } -function objectWriteUInt32 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffffffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { - buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff - } -} - Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, true) - } + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) return offset + 4 } Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, false) - } + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) return offset + 4 } Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) + var limit = Math.pow(2, (8 * byteLength) - 1) checkInt(this, value, offset, byteLength, limit - 1, -limit) } @@ -9678,9 +10029,9 @@ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, no Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) + var limit = Math.pow(2, (8 * byteLength) - 1) checkInt(this, value, offset, byteLength, limit - 1, -limit) } @@ -9701,9 +10052,8 @@ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, no Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) if (value < 0) value = 0xff + value + 1 this[offset] = (value & 0xff) return offset + 1 @@ -9711,58 +10061,42 @@ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) return offset + 2 } Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - } else { - objectWriteUInt16(this, value, offset, false) - } + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) return offset + 2 } Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - } else { - objectWriteUInt32(this, value, offset, true) - } + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) return offset + 4 } Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) if (value < 0) value = 0xffffffff + value + 1 - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, false) - } + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) return offset + 4 } @@ -9772,6 +10106,8 @@ function checkIEEE754 (buf, value, offset, ext, max, min) { } function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 if (!noAssert) { checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) } @@ -9788,6 +10124,8 @@ Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) } function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 if (!noAssert) { checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) } @@ -9833,12 +10171,12 @@ Buffer.prototype.copy = function copy (target, targetStart, start, end) { if (this === target && start < targetStart && targetStart < end) { // descending copy from end - for (i = len - 1; i >= 0; i--) { + for (i = len - 1; i >= 0; --i) { target[i + targetStart] = this[i + start] } - } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + } else if (len < 1000) { // ascending copy from start - for (i = 0; i < len; i++) { + for (i = 0; i < len; ++i) { target[i + targetStart] = this[i + start] } } else { @@ -9899,15 +10237,15 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) { var i if (typeof val === 'number') { - for (i = start; i < end; i++) { + for (i = start; i < end; ++i) { this[i] = val } } else { var bytes = Buffer.isBuffer(val) ? val - : utf8ToBytes(new Buffer(val, encoding).toString()) + : new Buffer(val, encoding) var len = bytes.length - for (i = 0; i < end - start; i++) { + for (i = 0; i < end - start; ++i) { this[i + start] = bytes[i % len] } } @@ -9918,7 +10256,7 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) { // HELPER FUNCTIONS // ================ -var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g +var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g function base64clean (str) { // Node strips out invalid characters like \n and \t from the string, base64-js does not @@ -9949,7 +10287,7 @@ function utf8ToBytes (string, units) { var leadSurrogate = null var bytes = [] - for (var i = 0; i < length; i++) { + for (var i = 0; i < length; ++i) { codePoint = string.charCodeAt(i) // is surrogate component @@ -10024,7 +10362,7 @@ function utf8ToBytes (string, units) { function asciiToBytes (str) { var byteArray = [] - for (var i = 0; i < str.length; i++) { + for (var i = 0; i < str.length; ++i) { // Node's code seems to be doing this and not & 0x7F.. byteArray.push(str.charCodeAt(i) & 0xFF) } @@ -10034,7 +10372,7 @@ function asciiToBytes (str) { function utf16leToBytes (str, units) { var c, hi, lo var byteArray = [] - for (var i = 0; i < str.length; i++) { + for (var i = 0; i < str.length; ++i) { if ((units -= 2) < 0) break c = str.charCodeAt(i) @@ -10052,7 +10390,7 @@ function base64ToBytes (str) { } function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; i++) { + for (var i = 0; i < length; ++i) { if ((i + offset >= dst.length) || (i >= src.length)) break dst[i + offset] = src[i] } @@ -10063,8 +10401,7 @@ function isnan (val) { return val !== val // eslint-disable-line no-self-compare } -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"base64-js":17,"ieee754":26,"isarray":30}],22:[function(require,module,exports){ +},{"base64-js":17,"ieee754":25}],23:[function(require,module,exports){ (function (Buffer){ // Copyright Joyent, Inc. and other Node contributors. // @@ -10175,376 +10512,7 @@ function objectToString(o) { } }).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":29}],23:[function(require,module,exports){ - -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // is webkit? http://stackoverflow.com/a/16459606/376773 - return ('WebkitAppearance' in document.documentElement.style) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (window.console && (console.firebug || (console.exception && console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - return JSON.stringify(v); -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs() { - var args = arguments; - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return args; - - var c = 'color: ' + this.color; - args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); - return args; -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} - return r; -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage(){ - try { - return window.localStorage; - } catch (e) {} -} - -},{"./debug":24}],24:[function(require,module,exports){ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = debug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lowercased letter, i.e. "n". - */ - -exports.formatters = {}; - -/** - * Previously assigned color. - */ - -var prevColor = 0; - -/** - * Previous log timestamp. - */ - -var prevTime; - -/** - * Select a color. - * - * @return {Number} - * @api private - */ - -function selectColor() { - return exports.colors[prevColor++ % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function debug(namespace) { - - // define the `disabled` version - function disabled() { - } - disabled.enabled = false; - - // define the `enabled` version - function enabled() { - - var self = enabled; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // add the `color` if not set - if (null == self.useColors) self.useColors = exports.useColors(); - if (null == self.color && self.useColors) self.color = selectColor(); - - var args = Array.prototype.slice.call(arguments); - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %o - args = ['%o'].concat(args); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - if ('function' === typeof exports.formatArgs) { - args = exports.formatArgs.apply(self, args); - } - var logFn = enabled.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - enabled.enabled = true; - - var fn = exports.enabled(namespace) ? enabled : disabled; - - fn.namespace = namespace; - - return fn; -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - var split = (namespaces || '').split(/[\s,]+/); - var len = split.length; - - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} - -},{"ms":37}],25:[function(require,module,exports){ +},{"../../is-buffer/index.js":28}],24:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -10604,8 +10572,12 @@ EventEmitter.prototype.emit = function(type) { er = arguments[1]; if (er instanceof Error) { throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; } - throw TypeError('Uncaught, unspecified "error" event.'); } } @@ -10844,7 +10816,7 @@ function isUndefined(arg) { return arg === void 0; } -},{}],26:[function(require,module,exports){ +},{}],25:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = nBytes * 8 - mLen - 1 @@ -10930,7 +10902,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],27:[function(require,module,exports){ +},{}],26:[function(require,module,exports){ (function (Buffer){ function readUInt32(buffer, offset, bigEndian) { if (buffer.readUInt32) { @@ -11164,7 +11136,7 @@ module.exports = function imageInfo(buffer, path) { }).call(this,require("buffer").Buffer) -},{"buffer":21,"zlib":20}],28:[function(require,module,exports){ +},{"buffer":22,"zlib":20}],27:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -11189,3612 +11161,37 @@ if (typeof Object.create === 'function') { } } -},{}],29:[function(require,module,exports){ -/** - * Determine if an object is Buffer - * - * Author: Feross Aboukhadijeh - * License: MIT +},{}],28:[function(require,module,exports){ +/*! + * Determine if an object is a Buffer * - * `npm install is-buffer` - */ - -module.exports = function (obj) { - return !!(obj != null && - (obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor) - (obj.constructor && - typeof obj.constructor.isBuffer === 'function' && - obj.constructor.isBuffer(obj)) - )) -} - -},{}],30:[function(require,module,exports){ -var toString = {}.toString; - -module.exports = Array.isArray || function (arr) { - return toString.call(arr) == '[object Array]'; -}; - -},{}],31:[function(require,module,exports){ -/** - * lodash 4.1.2 (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ - -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - stringTag = '[object String]'; - -/** Used to detect unsigned integer values. */ -var reIsUint = /^(?:0|[1-9]\d*)$/; - -/** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. - * - * @private - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. - */ -function baseTimes(n, iteratee) { - var index = -1, - result = Array(n); - - while (++index < n) { - result[index] = iteratee(index); - } - return result; -} - -/** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -function isIndex(value, length) { - value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; - length = length == null ? MAX_SAFE_INTEGER : length; - return value > -1 && value % 1 == 0 && value < length; -} - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ -var objectToString = objectProto.toString; - -/** Built-in value references. */ -var propertyIsEnumerable = objectProto.propertyIsEnumerable; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeGetPrototype = Object.getPrototypeOf, - nativeKeys = Object.keys; - -/** - * The base implementation of `_.forEach` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - */ -var baseEach = createBaseEach(baseForOwn); - -/** - * The base implementation of `baseForOwn` which iterates over `object` - * properties returned by `keysFunc` invoking `iteratee` for each property. - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ -var baseFor = createBaseFor(); - -/** - * The base implementation of `_.forOwn` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ -function baseForOwn(object, iteratee) { - return object && baseFor(object, iteratee, keys); -} - -/** - * The base implementation of `_.has` without support for deep paths. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - */ -function baseHas(object, key) { - // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`, - // that are composed entirely of index properties, return `false` for - // `hasOwnProperty` checks of them. - return hasOwnProperty.call(object, key) || - (typeof object == 'object' && key in object && getPrototype(object) === null); -} - -/** - * The base implementation of `_.keys` which doesn't skip the constructor - * property of prototypes or treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function baseKeys(object) { - return nativeKeys(Object(object)); -} - -/** - * The base implementation of `_.property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new function. - */ -function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; -} - -/** - * Creates a `baseEach` or `baseEachRight` function. - * - * @private - * @param {Function} eachFunc The function to iterate over a collection. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ -function createBaseEach(eachFunc, fromRight) { - return function(collection, iteratee) { - if (collection == null) { - return collection; - } - if (!isArrayLike(collection)) { - return eachFunc(collection, iteratee); - } - var length = collection.length, - index = fromRight ? length : -1, - iterable = Object(collection); - - while ((fromRight ? index-- : ++index < length)) { - if (iteratee(iterable[index], index, iterable) === false) { - break; - } - } - return collection; - }; -} - -/** - * Creates a base function for methods like `_.forIn` and `_.forOwn`. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ -function createBaseFor(fromRight) { - return function(object, iteratee, keysFunc) { - var index = -1, - iterable = Object(object), - props = keysFunc(object), - length = props.length; - - while (length--) { - var key = props[fromRight ? length : ++index]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; - }; -} - -/** - * Gets the "length" property value of `object`. - * - * **Note:** This function is used to avoid a - * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects - * Safari on at least iOS 8.1-8.3 ARM64. - * - * @private - * @param {Object} object The object to query. - * @returns {*} Returns the "length" value. - */ -var getLength = baseProperty('length'); - -/** - * Gets the `[[Prototype]]` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {null|Object} Returns the `[[Prototype]]`. - */ -function getPrototype(value) { - return nativeGetPrototype(Object(value)); -} - -/** - * Creates an array of index keys for `object` values of arrays, - * `arguments` objects, and strings, otherwise `null` is returned. - * - * @private - * @param {Object} object The object to query. - * @returns {Array|null} Returns index keys, else `null`. - */ -function indexKeys(object) { - var length = object ? object.length : undefined; - if (isLength(length) && - (isArray(object) || isString(object) || isArguments(object))) { - return baseTimes(length, String); - } - return null; -} - -/** - * Checks if `value` is likely a prototype object. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. - */ -function isPrototype(value) { - var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; - - return value === proto; -} - -/** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ -function isArguments(value) { - // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode. - return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && - (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); -} - -/** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @type {Function} - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ -var isArray = Array.isArray; - -/** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false - */ -function isArrayLike(value) { - return value != null && isLength(getLength(value)) && !isFunction(value); -} - -/** - * This method is like `_.isArrayLike` except that it also checks if `value` - * is an object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, - * else `false`. - * @example - * - * _.isArrayLikeObject([1, 2, 3]); - * // => true - * - * _.isArrayLikeObject(document.body.children); - * // => true - * - * _.isArrayLikeObject('abc'); - * // => false - * - * _.isArrayLikeObject(_.noop); - * // => false - */ -function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); -} - -/** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ -function isFunction(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 8 which returns 'object' for typed array and weak map constructors, - // and PhantomJS 1.9 which returns 'function' for `NodeList` instances. - var tag = isObject(value) ? objectToString.call(value) : ''; - return tag == funcTag || tag == genTag; -} - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This function is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, - * else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false - */ -function isLength(value) { - return typeof value == 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - -/** - * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. - * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ -function isObject(value) { - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); -} - -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; -} - -/** - * Checks if `value` is classified as a `String` primitive or object. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isString('abc'); - * // => true - * - * _.isString(1); - * // => false - */ -function isString(value) { - return typeof value == 'string' || - (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag); -} - -/** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) - * for more details. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ -function keys(object) { - var isProto = isPrototype(object); - if (!(isProto || isArrayLike(object))) { - return baseKeys(object); - } - var indexes = indexKeys(object), - skipIndexes = !!indexes, - result = indexes || [], - length = result.length; - - for (var key in object) { - if (baseHas(object, key) && - !(skipIndexes && (key == 'length' || isIndex(key, length))) && - !(isProto && key == 'constructor')) { - result.push(key); - } - } - return result; -} - -module.exports = baseEach; - -},{}],32:[function(require,module,exports){ -/** - * lodash 3.0.0 (Custom Build) - * Build: `lodash modern modularize exports="npm" -o ./` - * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.7.0 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ - -/** - * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`, - * without support for callback shorthands and `this` binding, which iterates - * over `collection` using the provided `eachFunc`. - * - * @private - * @param {Array|Object|string} collection The collection to search. - * @param {Function} predicate The function invoked per iteration. - * @param {Function} eachFunc The function to iterate over `collection`. - * @param {boolean} [retKey] Specify returning the key of the found element - * instead of the element itself. - * @returns {*} Returns the found element or its key, else `undefined`. - */ -function baseFind(collection, predicate, eachFunc, retKey) { - var result; - eachFunc(collection, function(value, key, collection) { - if (predicate(value, key, collection)) { - result = retKey ? key : value; - return false; - } - }); - return result; -} - -module.exports = baseFind; - -},{}],33:[function(require,module,exports){ -/** - * lodash 3.6.0 (Custom Build) - * Build: `lodash modern modularize exports="npm" -o ./` - * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.8.2 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ - -/** - * The base implementation of `_.findIndex` and `_.findLastIndex` without - * support for callback shorthands and `this` binding. - * - * @private - * @param {Array} array The array to search. - * @param {Function} predicate The function invoked per iteration. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function baseFindIndex(array, predicate, fromRight) { - var length = array.length, - index = fromRight ? length : -1; - - while ((fromRight ? index-- : ++index < length)) { - if (predicate(array[index], index, array)) { - return index; - } - } - return -1; -} - -module.exports = baseFindIndex; - -},{}],34:[function(require,module,exports){ -(function (global){ -/** - * lodash 4.6.1 (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ -var stringToPath = require('lodash._stringtopath'); - -/** Used as the size to enable large array optimizations. */ -var LARGE_ARRAY_SIZE = 200; - -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; - -/** Used to compose bitmasks for comparison styles. */ -var UNORDERED_COMPARE_FLAG = 1, - PARTIAL_COMPARE_FLAG = 2; - -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - mapTag = '[object Map]', - numberTag = '[object Number]', - objectTag = '[object Object]', - promiseTag = '[object Promise]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - symbolTag = '[object Symbol]', - weakMapTag = '[object WeakMap]'; - -var arrayBufferTag = '[object ArrayBuffer]', - dataViewTag = '[object DataView]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; - -/** Used to match property names within property paths. */ -var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, - reIsPlainProp = /^\w*$/; - -/** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). - */ -var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; - -/** Used to detect host constructors (Safari). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; - -/** Used to detect unsigned integer values. */ -var reIsUint = /^(?:0|[1-9]\d*)$/; - -/** Used to identify `toStringTag` values of typed arrays. */ -var typedArrayTags = {}; -typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = -typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = -typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = -typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = -typedArrayTags[uint32Tag] = true; -typedArrayTags[argsTag] = typedArrayTags[arrayTag] = -typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = -typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = -typedArrayTags[errorTag] = typedArrayTags[funcTag] = -typedArrayTags[mapTag] = typedArrayTags[numberTag] = -typedArrayTags[objectTag] = typedArrayTags[regexpTag] = -typedArrayTags[setTag] = typedArrayTags[stringTag] = -typedArrayTags[weakMapTag] = false; - -/** Used to determine if values are of the language type `Object`. */ -var objectTypes = { - 'function': true, - 'object': true -}; - -/** Detect free variable `exports`. */ -var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) - ? exports - : undefined; - -/** Detect free variable `module`. */ -var freeModule = (objectTypes[typeof module] && module && !module.nodeType) - ? module - : undefined; - -/** Detect free variable `global` from Node.js. */ -var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global); - -/** Detect free variable `self`. */ -var freeSelf = checkGlobal(objectTypes[typeof self] && self); - -/** Detect free variable `window`. */ -var freeWindow = checkGlobal(objectTypes[typeof window] && window); - -/** Detect `this` as the global object. */ -var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - -/** - * Used as a reference to the global object. - * - * The `this` value is used if it's the global object to avoid Greasemonkey's - * restricted `window` object, otherwise the `window` object is used. - */ -var root = freeGlobal || - ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || - freeSelf || thisGlobal || Function('return this')(); - -/** - * A specialized version of `_.map` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ -function arrayMap(array, iteratee) { - var index = -1, - length = array.length, - result = Array(length); - - while (++index < length) { - result[index] = iteratee(array[index], index, array); - } - return result; -} - -/** - * A specialized version of `_.some` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - */ -function arraySome(array, predicate) { - var index = -1, - length = array.length; - - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; - } - } - return false; -} - -/** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. - * - * @private - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. - */ -function baseTimes(n, iteratee) { - var index = -1, - result = Array(n); - - while (++index < n) { - result[index] = iteratee(index); - } - return result; -} - -/** - * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array - * of key-value pairs for `object` corresponding to the property names of `props`. - * - * @private - * @param {Object} object The object to query. - * @param {Array} props The property names to get values for. - * @returns {Object} Returns the new array of key-value pairs. - */ -function baseToPairs(object, props) { - return arrayMap(props, function(key) { - return [key, object[key]]; - }); -} - -/** - * Checks if `value` is a global object. - * - * @private - * @param {*} value The value to check. - * @returns {null|Object} Returns `value` if it's a global object, else `null`. - */ -function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; -} - -/** - * Checks if `value` is a host object in IE < 9. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a host object, else `false`. - */ -function isHostObject(value) { - // Many host objects are `Object` objects that can coerce to strings - // despite having improperly defined `toString` methods. - var result = false; - if (value != null && typeof value.toString != 'function') { - try { - result = !!(value + ''); - } catch (e) {} - } - return result; -} - -/** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -function isIndex(value, length) { - value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; - length = length == null ? MAX_SAFE_INTEGER : length; - return value > -1 && value % 1 == 0 && value < length; -} - -/** - * Converts `map` to an array. - * - * @private - * @param {Object} map The map to convert. - * @returns {Array} Returns the converted array. - */ -function mapToArray(map) { - var index = -1, - result = Array(map.size); - - map.forEach(function(value, key) { - result[++index] = [key, value]; - }); - return result; -} - -/** - * Converts `set` to an array. - * - * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the converted array. - */ -function setToArray(set) { - var index = -1, - result = Array(set.size); - - set.forEach(function(value) { - result[++index] = value; - }); - return result; -} - -/** Used for built-in method references. */ -var arrayProto = Array.prototype, - objectProto = Object.prototype; - -/** Used to resolve the decompiled source of functions. */ -var funcToString = Function.prototype.toString; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ -var objectToString = objectProto.toString; - -/** Used to detect if a method is native. */ -var reIsNative = RegExp('^' + - funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' -); - -/** Built-in value references. */ -var Symbol = root.Symbol, - Uint8Array = root.Uint8Array, - propertyIsEnumerable = objectProto.propertyIsEnumerable, - splice = arrayProto.splice; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeGetPrototype = Object.getPrototypeOf, - nativeKeys = Object.keys; - -/* Built-in method references that are verified to be native. */ -var DataView = getNative(root, 'DataView'), - Map = getNative(root, 'Map'), - Promise = getNative(root, 'Promise'), - Set = getNative(root, 'Set'), - WeakMap = getNative(root, 'WeakMap'), - nativeCreate = getNative(Object, 'create'); - -/** Used to detect maps, sets, and weakmaps. */ -var dataViewCtorString = toSource(DataView), - mapCtorString = toSource(Map), - promiseCtorString = toSource(Promise), - setCtorString = toSource(Set), - weakMapCtorString = toSource(WeakMap); - -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; - -/** - * Creates a hash object. - * - * @private - * @constructor - * @returns {Object} Returns the new hash object. - */ -function Hash() {} - -/** - * Removes `key` and its value from the hash. - * - * @private - * @param {Object} hash The hash to modify. - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function hashDelete(hash, key) { - return hashHas(hash, key) && delete hash[key]; -} - -/** - * Gets the hash value for `key`. - * - * @private - * @param {Object} hash The hash to query. - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function hashGet(hash, key) { - if (nativeCreate) { - var result = hash[key]; - return result === HASH_UNDEFINED ? undefined : result; - } - return hasOwnProperty.call(hash, key) ? hash[key] : undefined; -} - -/** - * Checks if a hash value for `key` exists. - * - * @private - * @param {Object} hash The hash to query. - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function hashHas(hash, key) { - return nativeCreate ? hash[key] !== undefined : hasOwnProperty.call(hash, key); -} - -/** - * Sets the hash `key` to `value`. - * - * @private - * @param {Object} hash The hash to modify. - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - */ -function hashSet(hash, key, value) { - hash[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; -} - -// Avoid inheriting from `Object.prototype` when possible. -Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto; - -/** - * Creates a map cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [values] The values to cache. - */ -function MapCache(values) { - var index = -1, - length = values ? values.length : 0; - - this.clear(); - while (++index < length) { - var entry = values[index]; - this.set(entry[0], entry[1]); - } -} - -/** - * Removes all key-value entries from the map. - * - * @private - * @name clear - * @memberOf MapCache - */ -function mapClear() { - this.__data__ = { - 'hash': new Hash, - 'map': Map ? new Map : [], - 'string': new Hash - }; -} - -/** - * Removes `key` and its value from the map. - * - * @private - * @name delete - * @memberOf MapCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function mapDelete(key) { - var data = this.__data__; - if (isKeyable(key)) { - return hashDelete(typeof key == 'string' ? data.string : data.hash, key); - } - return Map ? data.map['delete'](key) : assocDelete(data.map, key); -} - -/** - * Gets the map value for `key`. - * - * @private - * @name get - * @memberOf MapCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function mapGet(key) { - var data = this.__data__; - if (isKeyable(key)) { - return hashGet(typeof key == 'string' ? data.string : data.hash, key); - } - return Map ? data.map.get(key) : assocGet(data.map, key); -} - -/** - * Checks if a map value for `key` exists. - * - * @private - * @name has - * @memberOf MapCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function mapHas(key) { - var data = this.__data__; - if (isKeyable(key)) { - return hashHas(typeof key == 'string' ? data.string : data.hash, key); - } - return Map ? data.map.has(key) : assocHas(data.map, key); -} - -/** - * Sets the map `key` to `value`. - * - * @private - * @name set - * @memberOf MapCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the map cache instance. - */ -function mapSet(key, value) { - var data = this.__data__; - if (isKeyable(key)) { - hashSet(typeof key == 'string' ? data.string : data.hash, key, value); - } else if (Map) { - data.map.set(key, value); - } else { - assocSet(data.map, key, value); - } - return this; -} - -// Add methods to `MapCache`. -MapCache.prototype.clear = mapClear; -MapCache.prototype['delete'] = mapDelete; -MapCache.prototype.get = mapGet; -MapCache.prototype.has = mapHas; -MapCache.prototype.set = mapSet; - -/** - * Creates a stack cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [values] The values to cache. - */ -function Stack(values) { - var index = -1, - length = values ? values.length : 0; - - this.clear(); - while (++index < length) { - var entry = values[index]; - this.set(entry[0], entry[1]); - } -} - -/** - * Removes all key-value entries from the stack. - * - * @private - * @name clear - * @memberOf Stack - */ -function stackClear() { - this.__data__ = { 'array': [], 'map': null }; -} - -/** - * Removes `key` and its value from the stack. - * - * @private - * @name delete - * @memberOf Stack - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function stackDelete(key) { - var data = this.__data__, - array = data.array; - - return array ? assocDelete(array, key) : data.map['delete'](key); -} - -/** - * Gets the stack value for `key`. - * - * @private - * @name get - * @memberOf Stack - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function stackGet(key) { - var data = this.__data__, - array = data.array; - - return array ? assocGet(array, key) : data.map.get(key); -} - -/** - * Checks if a stack value for `key` exists. - * - * @private - * @name has - * @memberOf Stack - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function stackHas(key) { - var data = this.__data__, - array = data.array; - - return array ? assocHas(array, key) : data.map.has(key); -} - -/** - * Sets the stack `key` to `value`. - * - * @private - * @name set - * @memberOf Stack - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the stack cache instance. - */ -function stackSet(key, value) { - var data = this.__data__, - array = data.array; - - if (array) { - if (array.length < (LARGE_ARRAY_SIZE - 1)) { - assocSet(array, key, value); - } else { - data.array = null; - data.map = new MapCache(array); - } - } - var map = data.map; - if (map) { - map.set(key, value); - } - return this; -} - -// Add methods to `Stack`. -Stack.prototype.clear = stackClear; -Stack.prototype['delete'] = stackDelete; -Stack.prototype.get = stackGet; -Stack.prototype.has = stackHas; -Stack.prototype.set = stackSet; - -/** - * Removes `key` and its value from the associative array. - * - * @private - * @param {Array} array The array to modify. - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function assocDelete(array, key) { - var index = assocIndexOf(array, key); - if (index < 0) { - return false; - } - var lastIndex = array.length - 1; - if (index == lastIndex) { - array.pop(); - } else { - splice.call(array, index, 1); - } - return true; -} - -/** - * Gets the associative array value for `key`. - * - * @private - * @param {Array} array The array to query. - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function assocGet(array, key) { - var index = assocIndexOf(array, key); - return index < 0 ? undefined : array[index][1]; -} - -/** - * Checks if an associative array value for `key` exists. - * - * @private - * @param {Array} array The array to query. - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function assocHas(array, key) { - return assocIndexOf(array, key) > -1; -} - -/** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to search. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } - } - return -1; -} - -/** - * Sets the associative array `key` to `value`. - * - * @private - * @param {Array} array The array to modify. - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - */ -function assocSet(array, key, value) { - var index = assocIndexOf(array, key); - if (index < 0) { - array.push([key, value]); - } else { - array[index][1] = value; - } -} - -/** - * Casts `value` to a path array if it's not one. - * - * @private - * @param {*} value The value to inspect. - * @returns {Array} Returns the cast property path array. - */ -function baseCastPath(value) { - return isArray(value) ? value : stringToPath(value); -} - -/** - * The base implementation of `_.get` without support for default values. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @returns {*} Returns the resolved value. - */ -function baseGet(object, path) { - path = isKey(path, object) ? [path] : baseCastPath(path); - - var index = 0, - length = path.length; - - while (object != null && index < length) { - object = object[path[index++]]; - } - return (index && index == length) ? object : undefined; -} - -/** - * The base implementation of `_.has` without support for deep paths. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - */ -function baseHas(object, key) { - // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`, - // that are composed entirely of index properties, return `false` for - // `hasOwnProperty` checks of them. - return hasOwnProperty.call(object, key) || - (typeof object == 'object' && key in object && getPrototype(object) === null); -} - -/** - * The base implementation of `_.hasIn` without support for deep paths. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - */ -function baseHasIn(object, key) { - return key in Object(object); -} - -/** - * The base implementation of `_.isEqual` which supports partial comparisons - * and tracks traversed objects. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {Function} [customizer] The function to customize comparisons. - * @param {boolean} [bitmask] The bitmask of comparison flags. - * The bitmask may be composed of the following flags: - * 1 - Unordered comparison - * 2 - Partial comparison - * @param {Object} [stack] Tracks traversed `value` and `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ -function baseIsEqual(value, other, customizer, bitmask, stack) { - if (value === other) { - return true; - } - if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack); -} - -/** - * A specialized version of `baseIsEqual` for arrays and objects which performs - * deep comparisons and tracks traversed objects enabling objects with circular - * references to be compared. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} [customizer] The function to customize comparisons. - * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` - * for more details. - * @param {Object} [stack] Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) { - var objIsArr = isArray(object), - othIsArr = isArray(other), - objTag = arrayTag, - othTag = arrayTag; - - if (!objIsArr) { - objTag = getTag(object); - objTag = objTag == argsTag ? objectTag : objTag; - } - if (!othIsArr) { - othTag = getTag(other); - othTag = othTag == argsTag ? objectTag : othTag; - } - var objIsObj = objTag == objectTag && !isHostObject(object), - othIsObj = othTag == objectTag && !isHostObject(other), - isSameTag = objTag == othTag; - - if (isSameTag && !objIsObj) { - stack || (stack = new Stack); - return (objIsArr || isTypedArray(object)) - ? equalArrays(object, other, equalFunc, customizer, bitmask, stack) - : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack); - } - if (!(bitmask & PARTIAL_COMPARE_FLAG)) { - var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - - if (objIsWrapped || othIsWrapped) { - var objUnwrapped = objIsWrapped ? object.value() : object, - othUnwrapped = othIsWrapped ? other.value() : other; - - stack || (stack = new Stack); - return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack); - } - } - if (!isSameTag) { - return false; - } - stack || (stack = new Stack); - return equalObjects(object, other, equalFunc, customizer, bitmask, stack); -} - -/** - * The base implementation of `_.isMatch` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Array} matchData The property names, values, and compare flags to match. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - */ -function baseIsMatch(object, source, matchData, customizer) { - var index = matchData.length, - length = index, - noCustomizer = !customizer; - - if (object == null) { - return !length; - } - object = Object(object); - while (index--) { - var data = matchData[index]; - if ((noCustomizer && data[2]) - ? data[1] !== object[data[0]] - : !(data[0] in object) - ) { - return false; - } - } - while (++index < length) { - data = matchData[index]; - var key = data[0], - objValue = object[key], - srcValue = data[1]; - - if (noCustomizer && data[2]) { - if (objValue === undefined && !(key in object)) { - return false; - } - } else { - var stack = new Stack; - if (customizer) { - var result = customizer(objValue, srcValue, key, object, source, stack); - } - if (!(result === undefined - ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) - : result - )) { - return false; - } - } - } - return true; -} - -/** - * The base implementation of `_.iteratee`. - * - * @private - * @param {*} [value=_.identity] The value to convert to an iteratee. - * @returns {Function} Returns the iteratee. - */ -function baseIteratee(value) { - // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. - // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. - if (typeof value == 'function') { - return value; - } - if (value == null) { - return identity; - } - if (typeof value == 'object') { - return isArray(value) - ? baseMatchesProperty(value[0], value[1]) - : baseMatches(value); - } - return property(value); -} - -/** - * The base implementation of `_.keys` which doesn't skip the constructor - * property of prototypes or treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function baseKeys(object) { - return nativeKeys(Object(object)); -} - -/** - * The base implementation of `_.matches` which doesn't clone `source`. - * - * @private - * @param {Object} source The object of property values to match. - * @returns {Function} Returns the new function. - */ -function baseMatches(source) { - var matchData = getMatchData(source); - if (matchData.length == 1 && matchData[0][2]) { - return matchesStrictComparable(matchData[0][0], matchData[0][1]); - } - return function(object) { - return object === source || baseIsMatch(object, source, matchData); - }; -} - -/** - * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. - * - * @private - * @param {string} path The path of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new function. - */ -function baseMatchesProperty(path, srcValue) { - if (isKey(path) && isStrictComparable(srcValue)) { - return matchesStrictComparable(path, srcValue); - } - return function(object) { - var objValue = get(object, path); - return (objValue === undefined && objValue === srcValue) - ? hasIn(object, path) - : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG); - }; -} - -/** - * The base implementation of `_.property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new function. - */ -function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; -} - -/** - * A specialized version of `baseProperty` which supports deep paths. - * - * @private - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new function. - */ -function basePropertyDeep(path) { - return function(object) { - return baseGet(object, path); - }; -} - -/** - * A specialized version of `baseIsEqualDeep` for arrays with support for - * partial deep comparisons. - * - * @private - * @param {Array} array The array to compare. - * @param {Array} other The other array to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} customizer The function to customize comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` - * for more details. - * @param {Object} stack Tracks traversed `array` and `other` objects. - * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. - */ -function equalArrays(array, other, equalFunc, customizer, bitmask, stack) { - var index = -1, - isPartial = bitmask & PARTIAL_COMPARE_FLAG, - isUnordered = bitmask & UNORDERED_COMPARE_FLAG, - arrLength = array.length, - othLength = other.length; - - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(array); - if (stacked) { - return stacked == other; - } - var result = true; - stack.set(array, other); - - // Ignore non-index properties. - while (++index < arrLength) { - var arrValue = array[index], - othValue = other[index]; - - if (customizer) { - var compared = isPartial - ? customizer(othValue, arrValue, index, other, array, stack) - : customizer(arrValue, othValue, index, array, other, stack); - } - if (compared !== undefined) { - if (compared) { - continue; - } - result = false; - break; - } - // Recursively compare arrays (susceptible to call stack limits). - if (isUnordered) { - if (!arraySome(other, function(othValue) { - return arrValue === othValue || - equalFunc(arrValue, othValue, customizer, bitmask, stack); - })) { - result = false; - break; - } - } else if (!( - arrValue === othValue || - equalFunc(arrValue, othValue, customizer, bitmask, stack) - )) { - result = false; - break; - } - } - stack['delete'](array); - return result; -} - -/** - * A specialized version of `baseIsEqualDeep` for comparing objects of - * the same `toStringTag`. - * - * **Note:** This function only supports comparing values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {string} tag The `toStringTag` of the objects to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} customizer The function to customize comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` - * for more details. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) { - switch (tag) { - case dataViewTag: - if ((object.byteLength != other.byteLength) || - (object.byteOffset != other.byteOffset)) { - return false; - } - object = object.buffer; - other = other.buffer; - - case arrayBufferTag: - if ((object.byteLength != other.byteLength) || - !equalFunc(new Uint8Array(object), new Uint8Array(other))) { - return false; - } - return true; - - case boolTag: - case dateTag: - // Coerce dates and booleans to numbers, dates to milliseconds and - // booleans to `1` or `0` treating invalid dates coerced to `NaN` as - // not equal. - return +object == +other; - - case errorTag: - return object.name == other.name && object.message == other.message; - - case numberTag: - // Treat `NaN` vs. `NaN` as equal. - return (object != +object) ? other != +other : object == +other; - - case regexpTag: - case stringTag: - // Coerce regexes to strings and treat strings, primitives and objects, - // as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring - // for more details. - return object == (other + ''); - - case mapTag: - var convert = mapToArray; - - case setTag: - var isPartial = bitmask & PARTIAL_COMPARE_FLAG; - convert || (convert = setToArray); - - if (object.size != other.size && !isPartial) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - bitmask |= UNORDERED_COMPARE_FLAG; - stack.set(object, other); - - // Recursively compare objects (susceptible to call stack limits). - return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack); - - case symbolTag: - if (symbolValueOf) { - return symbolValueOf.call(object) == symbolValueOf.call(other); - } - } - return false; -} - -/** - * A specialized version of `baseIsEqualDeep` for objects with support for - * partial deep comparisons. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} customizer The function to customize comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` - * for more details. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function equalObjects(object, other, equalFunc, customizer, bitmask, stack) { - var isPartial = bitmask & PARTIAL_COMPARE_FLAG, - objProps = keys(object), - objLength = objProps.length, - othProps = keys(other), - othLength = othProps.length; - - if (objLength != othLength && !isPartial) { - return false; - } - var index = objLength; - while (index--) { - var key = objProps[index]; - if (!(isPartial ? key in other : baseHas(other, key))) { - return false; - } - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - var result = true; - stack.set(object, other); - - var skipCtor = isPartial; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], - othValue = other[key]; - - if (customizer) { - var compared = isPartial - ? customizer(othValue, objValue, key, other, object, stack) - : customizer(objValue, othValue, key, object, other, stack); - } - // Recursively compare objects (susceptible to call stack limits). - if (!(compared === undefined - ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack)) - : compared - )) { - result = false; - break; - } - skipCtor || (skipCtor = key == 'constructor'); - } - if (result && !skipCtor) { - var objCtor = object.constructor, - othCtor = other.constructor; - - // Non `Object` object instances with different constructors are not equal. - if (objCtor != othCtor && - ('constructor' in object && 'constructor' in other) && - !(typeof objCtor == 'function' && objCtor instanceof objCtor && - typeof othCtor == 'function' && othCtor instanceof othCtor)) { - result = false; - } - } - stack['delete'](object); - return result; -} - -/** - * Gets the "length" property value of `object`. - * - * **Note:** This function is used to avoid a - * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects - * Safari on at least iOS 8.1-8.3 ARM64. - * - * @private - * @param {Object} object The object to query. - * @returns {*} Returns the "length" value. - */ -var getLength = baseProperty('length'); - -/** - * Gets the property names, values, and compare flags of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the match data of `object`. - */ -function getMatchData(object) { - var result = toPairs(object), - length = result.length; - - while (length--) { - result[length][2] = isStrictComparable(result[length][1]); - } - return result; -} - -/** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ -function getNative(object, key) { - var value = object[key]; - return isNative(value) ? value : undefined; -} - -/** - * Gets the `[[Prototype]]` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {null|Object} Returns the `[[Prototype]]`. - */ -function getPrototype(value) { - return nativeGetPrototype(Object(value)); -} - -/** - * Gets the `toStringTag` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -function getTag(value) { - return objectToString.call(value); -} - -// Fallback for data views, maps, sets, and weak maps in IE 11, -// for data views in Edge, and promises in Node.js. -if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || - (Map && getTag(new Map) != mapTag) || - (Promise && getTag(Promise.resolve()) != promiseTag) || - (Set && getTag(new Set) != setTag) || - (WeakMap && getTag(new WeakMap) != weakMapTag)) { - getTag = function(value) { - var result = objectToString.call(value), - Ctor = result == objectTag ? value.constructor : undefined, - ctorString = Ctor ? toSource(Ctor) : undefined; - - if (ctorString) { - switch (ctorString) { - case dataViewCtorString: return dataViewTag; - case mapCtorString: return mapTag; - case promiseCtorString: return promiseTag; - case setCtorString: return setTag; - case weakMapCtorString: return weakMapTag; - } - } - return result; - }; -} - -/** - * Checks if `path` exists on `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @param {Function} hasFunc The function to check properties. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - */ -function hasPath(object, path, hasFunc) { - path = isKey(path, object) ? [path] : baseCastPath(path); - - var result, - index = -1, - length = path.length; - - while (++index < length) { - var key = path[index]; - if (!(result = object != null && hasFunc(object, key))) { - break; - } - object = object[key]; - } - if (result) { - return result; - } - var length = object ? object.length : 0; - return !!length && isLength(length) && isIndex(key, length) && - (isArray(object) || isString(object) || isArguments(object)); -} - -/** - * Creates an array of index keys for `object` values of arrays, - * `arguments` objects, and strings, otherwise `null` is returned. - * - * @private - * @param {Object} object The object to query. - * @returns {Array|null} Returns index keys, else `null`. - */ -function indexKeys(object) { - var length = object ? object.length : undefined; - if (isLength(length) && - (isArray(object) || isString(object) || isArguments(object))) { - return baseTimes(length, String); - } - return null; -} - -/** - * Checks if `value` is a property name and not a property path. - * - * @private - * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. - */ -function isKey(value, object) { - var type = typeof value; - if (type == 'number' || type == 'symbol') { - return true; - } - return !isArray(value) && - (isSymbol(value) || reIsPlainProp.test(value) || !reIsDeepProp.test(value) || - (object != null && value in Object(object))); -} - -/** - * Checks if `value` is suitable for use as unique object key. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is suitable, else `false`. - */ -function isKeyable(value) { - var type = typeof value; - return type == 'number' || type == 'boolean' || - (type == 'string' && value != '__proto__') || value == null; -} - -/** - * Checks if `value` is likely a prototype object. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. - */ -function isPrototype(value) { - var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; - - return value === proto; -} - -/** - * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` if suitable for strict - * equality comparisons, else `false`. - */ -function isStrictComparable(value) { - return value === value && !isObject(value); -} - -/** - * A specialized version of `matchesProperty` for source values suitable - * for strict equality comparisons, i.e. `===`. - * - * @private - * @param {string} key The key of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new function. - */ -function matchesStrictComparable(key, srcValue) { - return function(object) { - if (object == null) { - return false; - } - return object[key] === srcValue && - (srcValue !== undefined || (key in Object(object))); - }; -} - -/** - * Converts `func` to its source code. - * - * @private - * @param {Function} func The function to process. - * @returns {string} Returns the source code. - */ -function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) {} - try { - return (func + ''); - } catch (e) {} - } - return ''; -} - -/** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'user': 'fred' }; - * var other = { 'user': 'fred' }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false - * - * _.eq(NaN, NaN); - * // => true - */ -function eq(value, other) { - return value === other || (value !== value && other !== other); -} - -/** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ -function isArguments(value) { - // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode. - return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && - (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); -} - -/** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @type {Function} - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ -var isArray = Array.isArray; - -/** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false - */ -function isArrayLike(value) { - return value != null && isLength(getLength(value)) && !isFunction(value); -} - -/** - * This method is like `_.isArrayLike` except that it also checks if `value` - * is an object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, - * else `false`. - * @example - * - * _.isArrayLikeObject([1, 2, 3]); - * // => true - * - * _.isArrayLikeObject(document.body.children); - * // => true - * - * _.isArrayLikeObject('abc'); - * // => false - * - * _.isArrayLikeObject(_.noop); - * // => false - */ -function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); -} - -/** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ -function isFunction(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 8 which returns 'object' for typed array and weak map constructors, - // and PhantomJS 1.9 which returns 'function' for `NodeList` instances. - var tag = isObject(value) ? objectToString.call(value) : ''; - return tag == funcTag || tag == genTag; -} - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This function is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, - * else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false - */ -function isLength(value) { - return typeof value == 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - -/** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ -function isObject(value) { - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); -} - -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; -} - -/** - * Checks if `value` is a native function. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - * @example - * - * _.isNative(Array.prototype.push); - * // => true - * - * _.isNative(_); - * // => false - */ -function isNative(value) { - if (!isObject(value)) { - return false; - } - var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); -} - -/** - * Checks if `value` is classified as a `String` primitive or object. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isString('abc'); - * // => true - * - * _.isString(1); - * // => false - */ -function isString(value) { - return typeof value == 'string' || - (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag); -} - -/** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ -function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && objectToString.call(value) == symbolTag); -} - -/** - * Checks if `value` is classified as a typed array. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isTypedArray(new Uint8Array); - * // => true - * - * _.isTypedArray([]); - * // => false - */ -function isTypedArray(value) { - return isObjectLike(value) && - isLength(value.length) && !!typedArrayTags[objectToString.call(value)]; -} - -/** - * Gets the value at `path` of `object`. If the resolved value is - * `undefined`, the `defaultValue` is used in its place. - * - * @static - * @memberOf _ - * @since 3.7.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; - * - * _.get(object, 'a[0].b.c'); - * // => 3 - * - * _.get(object, ['a', '0', 'b', 'c']); - * // => 3 - * - * _.get(object, 'a.b.c', 'default'); - * // => 'default' - */ -function get(object, path, defaultValue) { - var result = object == null ? undefined : baseGet(object, path); - return result === undefined ? defaultValue : result; -} - -/** - * Checks if `path` is a direct or inherited property of `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - * @example - * - * var object = _.create({ 'a': _.create({ 'b': 2 }) }); - * - * _.hasIn(object, 'a'); - * // => true - * - * _.hasIn(object, 'a.b'); - * // => true - * - * _.hasIn(object, ['a', 'b']); - * // => true - * - * _.hasIn(object, 'b'); - * // => false - */ -function hasIn(object, path) { - return object != null && hasPath(object, path, baseHasIn); -} - -/** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) - * for more details. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ -function keys(object) { - var isProto = isPrototype(object); - if (!(isProto || isArrayLike(object))) { - return baseKeys(object); - } - var indexes = indexKeys(object), - skipIndexes = !!indexes, - result = indexes || [], - length = result.length; - - for (var key in object) { - if (baseHas(object, key) && - !(skipIndexes && (key == 'length' || isIndex(key, length))) && - !(isProto && key == 'constructor')) { - result.push(key); - } - } - return result; -} - -/** - * Creates an array of own enumerable string keyed-value pairs for `object` - * which can be consumed by `_.fromPairs`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias entries - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the new array of key-value pairs. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.toPairs(new Foo); - * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) - */ -function toPairs(object) { - return baseToPairs(object, keys(object)); -} - -/** - * This method returns the first argument given to it. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Util - * @param {*} value Any value. - * @returns {*} Returns `value`. - * @example - * - * var object = { 'user': 'fred' }; - * - * _.identity(object) === object; - * // => true - */ -function identity(value) { - return value; -} - -/** - * Creates a function that returns the value at `path` of a given object. - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Util - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new function. - * @example - * - * var objects = [ - * { 'a': { 'b': 2 } }, - * { 'a': { 'b': 1 } } - * ]; - * - * _.map(objects, _.property('a.b')); - * // => [2, 1] - * - * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); - * // => [1, 2] - */ -function property(path) { - return isKey(path) ? baseProperty(path) : basePropertyDeep(path); -} - -module.exports = baseIteratee; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"lodash._stringtopath":35}],35:[function(require,module,exports){ -(function (global){ -/** - * lodash 4.7.1 (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ - -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; - -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; - -/** `Object#toString` result references. */ -var funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - symbolTag = '[object Symbol]'; - -/** Used to match property names within property paths. */ -var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g; - -/** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). - */ -var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; - -/** Used to match backslashes in property paths. */ -var reEscapeChar = /\\(\\)?/g; - -/** Used to detect host constructors (Safari). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; - -/** Used to determine if values are of the language type `Object`. */ -var objectTypes = { - 'function': true, - 'object': true -}; - -/** Detect free variable `exports`. */ -var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) - ? exports - : undefined; - -/** Detect free variable `module`. */ -var freeModule = (objectTypes[typeof module] && module && !module.nodeType) - ? module - : undefined; - -/** Detect free variable `global` from Node.js. */ -var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global); - -/** Detect free variable `self`. */ -var freeSelf = checkGlobal(objectTypes[typeof self] && self); - -/** Detect free variable `window`. */ -var freeWindow = checkGlobal(objectTypes[typeof window] && window); - -/** Detect `this` as the global object. */ -var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - -/** - * Used as a reference to the global object. - * - * The `this` value is used if it's the global object to avoid Greasemonkey's - * restricted `window` object, otherwise the `window` object is used. - */ -var root = freeGlobal || - ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || - freeSelf || thisGlobal || Function('return this')(); - -/** - * Checks if `value` is a global object. - * - * @private - * @param {*} value The value to check. - * @returns {null|Object} Returns `value` if it's a global object, else `null`. - */ -function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; -} - -/** - * Checks if `value` is a host object in IE < 9. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a host object, else `false`. - */ -function isHostObject(value) { - // Many host objects are `Object` objects that can coerce to strings - // despite having improperly defined `toString` methods. - var result = false; - if (value != null && typeof value.toString != 'function') { - try { - result = !!(value + ''); - } catch (e) {} - } - return result; -} - -/** Used for built-in method references. */ -var arrayProto = Array.prototype, - objectProto = Object.prototype; - -/** Used to resolve the decompiled source of functions. */ -var funcToString = Function.prototype.toString; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ -var objectToString = objectProto.toString; - -/** Used to detect if a method is native. */ -var reIsNative = RegExp('^' + - funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' -); - -/** Built-in value references. */ -var Symbol = root.Symbol, - splice = arrayProto.splice; - -/* Built-in method references that are verified to be native. */ -var Map = getNative(root, 'Map'), - nativeCreate = getNative(Object, 'create'); - -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolToString = symbolProto ? symbolProto.toString : undefined; - -/** - * Creates a hash object. - * - * @private - * @constructor - * @returns {Object} Returns the new hash object. - */ -function Hash() {} - -/** - * Removes `key` and its value from the hash. - * - * @private - * @param {Object} hash The hash to modify. - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function hashDelete(hash, key) { - return hashHas(hash, key) && delete hash[key]; -} - -/** - * Gets the hash value for `key`. - * - * @private - * @param {Object} hash The hash to query. - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function hashGet(hash, key) { - if (nativeCreate) { - var result = hash[key]; - return result === HASH_UNDEFINED ? undefined : result; - } - return hasOwnProperty.call(hash, key) ? hash[key] : undefined; -} - -/** - * Checks if a hash value for `key` exists. - * - * @private - * @param {Object} hash The hash to query. - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function hashHas(hash, key) { - return nativeCreate ? hash[key] !== undefined : hasOwnProperty.call(hash, key); -} - -/** - * Sets the hash `key` to `value`. - * - * @private - * @param {Object} hash The hash to modify. - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - */ -function hashSet(hash, key, value) { - hash[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; -} - -// Avoid inheriting from `Object.prototype` when possible. -Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto; - -/** - * Creates a map cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [values] The values to cache. - */ -function MapCache(values) { - var index = -1, - length = values ? values.length : 0; - - this.clear(); - while (++index < length) { - var entry = values[index]; - this.set(entry[0], entry[1]); - } -} - -/** - * Removes all key-value entries from the map. - * - * @private - * @name clear - * @memberOf MapCache - */ -function mapClear() { - this.__data__ = { - 'hash': new Hash, - 'map': Map ? new Map : [], - 'string': new Hash - }; -} - -/** - * Removes `key` and its value from the map. - * - * @private - * @name delete - * @memberOf MapCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function mapDelete(key) { - var data = this.__data__; - if (isKeyable(key)) { - return hashDelete(typeof key == 'string' ? data.string : data.hash, key); - } - return Map ? data.map['delete'](key) : assocDelete(data.map, key); -} - -/** - * Gets the map value for `key`. - * - * @private - * @name get - * @memberOf MapCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function mapGet(key) { - var data = this.__data__; - if (isKeyable(key)) { - return hashGet(typeof key == 'string' ? data.string : data.hash, key); - } - return Map ? data.map.get(key) : assocGet(data.map, key); -} - -/** - * Checks if a map value for `key` exists. - * - * @private - * @name has - * @memberOf MapCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function mapHas(key) { - var data = this.__data__; - if (isKeyable(key)) { - return hashHas(typeof key == 'string' ? data.string : data.hash, key); - } - return Map ? data.map.has(key) : assocHas(data.map, key); -} - -/** - * Sets the map `key` to `value`. - * - * @private - * @name set - * @memberOf MapCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the map cache instance. - */ -function mapSet(key, value) { - var data = this.__data__; - if (isKeyable(key)) { - hashSet(typeof key == 'string' ? data.string : data.hash, key, value); - } else if (Map) { - data.map.set(key, value); - } else { - assocSet(data.map, key, value); - } - return this; -} - -// Add methods to `MapCache`. -MapCache.prototype.clear = mapClear; -MapCache.prototype['delete'] = mapDelete; -MapCache.prototype.get = mapGet; -MapCache.prototype.has = mapHas; -MapCache.prototype.set = mapSet; - -/** - * Removes `key` and its value from the associative array. - * - * @private - * @param {Array} array The array to modify. - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function assocDelete(array, key) { - var index = assocIndexOf(array, key); - if (index < 0) { - return false; - } - var lastIndex = array.length - 1; - if (index == lastIndex) { - array.pop(); - } else { - splice.call(array, index, 1); - } - return true; -} - -/** - * Gets the associative array value for `key`. - * - * @private - * @param {Array} array The array to query. - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function assocGet(array, key) { - var index = assocIndexOf(array, key); - return index < 0 ? undefined : array[index][1]; -} - -/** - * Checks if an associative array value for `key` exists. - * - * @private - * @param {Array} array The array to query. - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function assocHas(array, key) { - return assocIndexOf(array, key) > -1; -} - -/** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to search. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } - } - return -1; -} - -/** - * Sets the associative array `key` to `value`. - * - * @private - * @param {Array} array The array to modify. - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - */ -function assocSet(array, key, value) { - var index = assocIndexOf(array, key); - if (index < 0) { - array.push([key, value]); - } else { - array[index][1] = value; - } -} - -/** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ -function getNative(object, key) { - var value = object[key]; - return isNative(value) ? value : undefined; -} - -/** - * Checks if `value` is suitable for use as unique object key. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is suitable, else `false`. - */ -function isKeyable(value) { - var type = typeof value; - return type == 'number' || type == 'boolean' || - (type == 'string' && value != '__proto__') || value == null; -} - -/** - * Converts `string` to a property path array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the property path array. - */ -var stringToPath = memoize(function(string) { - var result = []; - toString(string).replace(rePropName, function(match, number, quote, string) { - result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); - }); - return result; -}); - -/** - * Converts `func` to its source code. - * - * @private - * @param {Function} func The function to process. - * @returns {string} Returns the source code. - */ -function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) {} - try { - return (func + ''); - } catch (e) {} - } - return ''; -} - -/** - * Creates a function that memoizes the result of `func`. If `resolver` is - * provided, it determines the cache key for storing the result based on the - * arguments provided to the memoized function. By default, the first argument - * provided to the memoized function is used as the map cache key. The `func` - * is invoked with the `this` binding of the memoized function. - * - * **Note:** The cache is exposed as the `cache` property on the memoized - * function. Its creation may be customized by replacing the `_.memoize.Cache` - * constructor with one whose instances implement the - * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) - * method interface of `delete`, `get`, `has`, and `set`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to have its output memoized. - * @param {Function} [resolver] The function to resolve the cache key. - * @returns {Function} Returns the new memoizing function. - * @example - * - * var object = { 'a': 1, 'b': 2 }; - * var other = { 'c': 3, 'd': 4 }; - * - * var values = _.memoize(_.values); - * values(object); - * // => [1, 2] - * - * values(other); - * // => [3, 4] - * - * object.a = 2; - * values(object); - * // => [1, 2] - * - * // Modify the result cache. - * values.cache.set(object, ['a', 'b']); - * values(object); - * // => ['a', 'b'] - * - * // Replace `_.memoize.Cache`. - * _.memoize.Cache = WeakMap; - */ -function memoize(func, resolver) { - if (typeof func != 'function' || (resolver && typeof resolver != 'function')) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var memoized = function() { - var args = arguments, - key = resolver ? resolver.apply(this, args) : args[0], - cache = memoized.cache; - - if (cache.has(key)) { - return cache.get(key); - } - var result = func.apply(this, args); - memoized.cache = cache.set(key, result); - return result; - }; - memoized.cache = new (memoize.Cache || MapCache); - return memoized; -} - -// Assign cache to `_.memoize`. -memoize.Cache = MapCache; - -/** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'user': 'fred' }; - * var other = { 'user': 'fred' }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false - * - * _.eq(NaN, NaN); - * // => true - */ -function eq(value, other) { - return value === other || (value !== value && other !== other); -} - -/** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ -function isFunction(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 8 which returns 'object' for typed array and weak map constructors, - // and PhantomJS 1.9 which returns 'function' for `NodeList` instances. - var tag = isObject(value) ? objectToString.call(value) : ''; - return tag == funcTag || tag == genTag; -} - -/** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ -function isObject(value) { - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); -} - -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; -} - -/** - * Checks if `value` is a native function. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - * @example - * - * _.isNative(Array.prototype.push); - * // => true - * - * _.isNative(_); - * // => false - */ -function isNative(value) { - if (!isObject(value)) { - return false; - } - var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); -} - -/** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ -function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && objectToString.call(value) == symbolTag); -} - -/** - * Converts `value` to a string if it's not one. An empty string is returned - * for `null` and `undefined` values. The sign of `-0` is preserved. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to process. - * @returns {string} Returns the string. - * @example - * - * _.toString(null); - * // => '' - * - * _.toString(-0); - * // => '-0' - * - * _.toString([1, 2, 3]); - * // => '1,2,3' - */ -function toString(value) { - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value == 'string') { - return value; - } - if (value == null) { - return ''; - } - if (isSymbol(value)) { - return symbolToString ? symbolToString.call(value) : ''; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; -} - -module.exports = stringToPath; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],36:[function(require,module,exports){ -/** - * lodash 4.3.0 (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ -var baseEach = require('lodash._baseeach'), - baseFind = require('lodash._basefind'), - baseFindIndex = require('lodash._basefindindex'), - baseIteratee = require('lodash._baseiteratee'); - -/** - * Iterates over elements of `collection`, returning the first element - * `predicate` returns truthy for. The predicate is invoked with three - * arguments: (value, index|key, collection). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to search. - * @param {Array|Function|Object|string} [predicate=_.identity] - * The function invoked per iteration. - * @returns {*} Returns the matched element, else `undefined`. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false }, - * { 'user': 'pebbles', 'age': 1, 'active': true } - * ]; - * - * _.find(users, function(o) { return o.age < 40; }); - * // => object for 'barney' - * - * // The `_.matches` iteratee shorthand. - * _.find(users, { 'age': 1, 'active': true }); - * // => object for 'pebbles' - * - * // The `_.matchesProperty` iteratee shorthand. - * _.find(users, ['active', false]); - * // => object for 'fred' - * - * // The `_.property` iteratee shorthand. - * _.find(users, 'active'); - * // => object for 'barney' - */ -function find(collection, predicate) { - predicate = baseIteratee(predicate, 3); - if (isArray(collection)) { - var index = baseFindIndex(collection, predicate); - return index > -1 ? collection[index] : undefined; - } - return baseFind(collection, predicate, baseEach); -} - -/** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @type {Function} - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, - * else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ -var isArray = Array.isArray; - -module.exports = find; - -},{"lodash._baseeach":31,"lodash._basefind":32,"lodash._basefindindex":33,"lodash._baseiteratee":34}],37:[function(require,module,exports){ -/** - * Helpers. - */ - -var s = 1000; -var m = s * 60; -var h = m * 60; -var d = h * 24; -var y = d * 365.25; - -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} options - * @return {String|Number} - * @api public - */ - -module.exports = function(val, options){ - options = options || {}; - if ('string' == typeof val) return parse(val); - return options.long - ? long(val) - : short(val); -}; - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - str = '' + str; - if (str.length > 10000) return; - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); - if (!match) return; - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - case 'days': - case 'day': - case 'd': - return n * d; - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private + * @author Feross Aboukhadijeh + * @license MIT */ -function short(ms) { - if (ms >= d) return Math.round(ms / d) + 'd'; - if (ms >= h) return Math.round(ms / h) + 'h'; - if (ms >= m) return Math.round(ms / m) + 'm'; - if (ms >= s) return Math.round(ms / s) + 's'; - return ms + 'ms'; +// The _isBuffer check is for Safari 5-7 support, because it's missing +// Object.prototype.constructor. Remove this eventually +module.exports = function (obj) { + return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) } -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ +function isBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) +} -function long(ms) { - return plural(ms, d, 'day') - || plural(ms, h, 'hour') - || plural(ms, m, 'minute') - || plural(ms, s, 'second') - || ms + ' ms'; +// For Node v0.10 support. Remove this eventually. +function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) } -/** - * Pluralization helper. - */ +},{}],29:[function(require,module,exports){ +var toString = {}.toString; -function plural(ms, n, name) { - if (ms < n) return; - if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; - return Math.ceil(ms / n) + ' ' + name + 's'; -} +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; -},{}],38:[function(require,module,exports){ +},{}],30:[function(require,module,exports){ 'use strict'; @@ -14836,28 +11233,28 @@ exports.shrinkBuf = function (buf, size) { var fnTyped = { arraySet: function (dest, src, src_offs, len, dest_offs) { if (src.subarray && dest.subarray) { - dest.set(src.subarray(src_offs, src_offs+len), dest_offs); + dest.set(src.subarray(src_offs, src_offs + len), dest_offs); return; } // Fallback to ordinary array - for (var i=0; i>> 1)) : (c >>> 1)); + for (var k = 0; k < 8; k++) { + c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1)); } table[n] = c; } @@ -15012,7 +11412,7 @@ function crc32(crc, buf, len, pos) { var t = crcTable, end = pos + len; - crc = crc ^ (-1); + crc ^= -1; for (var i = pos; i < end; i++) { crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF]; @@ -15024,14 +11424,14 @@ function crc32(crc, buf, len, pos) { module.exports = crc32; -},{}],42:[function(require,module,exports){ +},{}],34:[function(require,module,exports){ 'use strict'; var utils = require('../utils/common'); var trees = require('./trees'); var adler32 = require('./adler32'); var crc32 = require('./crc32'); -var msg = require('./messages'); +var msg = require('./messages'); /* Public constants ==========================================================*/ /* ===========================================================================*/ @@ -15104,7 +11504,7 @@ var D_CODES = 30; /* number of distance codes */ var BL_CODES = 19; /* number of codes used to transfer the bit lengths */ -var HEAP_SIZE = 2*L_CODES + 1; +var HEAP_SIZE = 2 * L_CODES + 1; /* maximum heap size */ var MAX_BITS = 15; /* All codes must not exceed MAX_BITS bits */ @@ -15170,7 +11570,7 @@ function flush_pending(strm) { } -function flush_block_only (s, last) { +function flush_block_only(s, last) { trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last); s.block_start = s.strstart; flush_pending(s.strm); @@ -15210,6 +11610,7 @@ function read_buf(strm, buf, start, size) { strm.avail_in -= len; + // zmemcpy(buf, strm->next_in, len); utils.arraySet(buf, strm.input, strm.next_in, len, start); if (strm.state.wrap === 1) { strm.adler = adler32(strm.adler, buf, len, start); @@ -15440,7 +11841,7 @@ function fill_window(s) { //#endif while (s.insert) { /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */ - s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH-1]) & s.hash_mask; + s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask; s.prev[str & s.w_mask] = s.head[s.ins_h]; s.head[s.ins_h] = str; @@ -15704,7 +12105,7 @@ function deflate_fast(s, flush) { /***/ } } - s.insert = ((s.strstart < (MIN_MATCH-1)) ? s.strstart : MIN_MATCH-1); + s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1); if (flush === Z_FINISH) { /*** FLUSH_BLOCK(s, 1); ***/ flush_block_only(s, true); @@ -15767,10 +12168,10 @@ function deflate_slow(s, flush) { */ s.prev_length = s.match_length; s.prev_match = s.match_start; - s.match_length = MIN_MATCH-1; + s.match_length = MIN_MATCH - 1; if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match && - s.strstart - hash_head <= (s.w_size-MIN_LOOKAHEAD)/*MAX_DIST(s)*/) { + s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). @@ -15784,7 +12185,7 @@ function deflate_slow(s, flush) { /* If prev_match is also MIN_MATCH, match_start is garbage * but we will ignore the current match anyway. */ - s.match_length = MIN_MATCH-1; + s.match_length = MIN_MATCH - 1; } } /* If there was a match at the previous step and the current @@ -15798,13 +12199,13 @@ function deflate_slow(s, flush) { /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH, bflush);***/ - bflush = trees._tr_tally(s, s.strstart - 1- s.prev_match, s.prev_length - MIN_MATCH); + bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH); /* Insert in hash table all strings up to the end of the match. * strstart-1 and strstart are already inserted. If there is not * enough lookahead, the last two strings are not inserted in * the hash table. */ - s.lookahead -= s.prev_length-1; + s.lookahead -= s.prev_length - 1; s.prev_length -= 2; do { if (++s.strstart <= max_insert) { @@ -15816,7 +12217,7 @@ function deflate_slow(s, flush) { } } while (--s.prev_length !== 0); s.match_available = 0; - s.match_length = MIN_MATCH-1; + s.match_length = MIN_MATCH - 1; s.strstart++; if (bflush) { @@ -15835,7 +12236,7 @@ function deflate_slow(s, flush) { */ //Tracevv((stderr,"%c", s->window[s->strstart-1])); /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/ - bflush = trees._tr_tally(s, 0, s.window[s.strstart-1]); + bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]); if (bflush) { /*** FLUSH_BLOCK_ONLY(s, 0) ***/ @@ -15860,11 +12261,11 @@ function deflate_slow(s, flush) { if (s.match_available) { //Tracevv((stderr,"%c", s->window[s->strstart-1])); /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/ - bflush = trees._tr_tally(s, 0, s.window[s.strstart-1]); + bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]); s.match_available = 0; } - s.insert = s.strstart < MIN_MATCH-1 ? s.strstart : MIN_MATCH-1; + s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1; if (flush === Z_FINISH) { /*** FLUSH_BLOCK(s, 1); ***/ flush_block_only(s, true); @@ -16044,13 +12445,13 @@ function deflate_huff(s, flush) { * exclude worst case performance for pathological files. Better values may be * found for specific files. */ -var Config = function (good_length, max_lazy, nice_length, max_chain, func) { +function Config(good_length, max_lazy, nice_length, max_chain, func) { this.good_length = good_length; this.max_lazy = max_lazy; this.nice_length = nice_length; this.max_chain = max_chain; this.func = func; -}; +} var configuration_table; @@ -16200,8 +12601,8 @@ function DeflateState() { // Use flat array of DOUBLE size, with interleaved fata, // because JS does not support effective this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2); - this.dyn_dtree = new utils.Buf16((2*D_CODES+1) * 2); - this.bl_tree = new utils.Buf16((2*BL_CODES+1) * 2); + this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2); + this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2); zero(this.dyn_ltree); zero(this.dyn_dtree); zero(this.bl_tree); @@ -16211,11 +12612,11 @@ function DeflateState() { this.bl_desc = null; /* desc. for bit length tree */ //ush bl_count[MAX_BITS+1]; - this.bl_count = new utils.Buf16(MAX_BITS+1); + this.bl_count = new utils.Buf16(MAX_BITS + 1); /* number of codes at each bit length for an optimal tree */ //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - this.heap = new utils.Buf16(2*L_CODES+1); /* heap used to build the Huffman trees */ + this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */ zero(this.heap); this.heap_len = 0; /* number of elements in the heap */ @@ -16224,7 +12625,7 @@ function DeflateState() { * The same heap array is used to build all trees. */ - this.depth = new utils.Buf16(2*L_CODES+1); //uch depth[2*L_CODES+1]; + this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1]; zero(this.depth); /* Depth of each subtree used as tie breaker for trees of equal frequency */ @@ -16390,9 +12791,16 @@ function deflateInit2(strm, level, method, windowBits, memLevel, strategy) { s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ s.pending_buf_size = s.lit_bufsize * 4; + + //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); + //s->pending_buf = (uchf *) overlay; s.pending_buf = new utils.Buf8(s.pending_buf_size); - s.d_buf = s.lit_bufsize >> 1; + // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`) + //s->d_buf = overlay + s->lit_bufsize/sizeof(ush); + s.d_buf = 1 * s.lit_bufsize; + + //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; s.l_buf = (1 + 2) * s.lit_bufsize; s.level = level; @@ -16765,12 +13173,94 @@ function deflateEnd(strm) { return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK; } + /* ========================================================================= - * Copy the source state to the destination state + * Initializes the compression dictionary from the given byte + * sequence without producing any compressed output. */ -//function deflateCopy(dest, source) { -// -//} +function deflateSetDictionary(strm, dictionary) { + var dictLength = dictionary.length; + + var s; + var str, n; + var wrap; + var avail; + var next; + var input; + var tmpDict; + + if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) { + return Z_STREAM_ERROR; + } + + s = strm.state; + wrap = s.wrap; + + if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) { + return Z_STREAM_ERROR; + } + + /* when using zlib wrappers, compute Adler-32 for provided dictionary */ + if (wrap === 1) { + /* adler32(strm->adler, dictionary, dictLength); */ + strm.adler = adler32(strm.adler, dictionary, dictLength, 0); + } + + s.wrap = 0; /* avoid computing Adler-32 in read_buf */ + + /* if dictionary would fill window, just replace the history */ + if (dictLength >= s.w_size) { + if (wrap === 0) { /* already empty otherwise */ + /*** CLEAR_HASH(s); ***/ + zero(s.head); // Fill with NIL (= 0); + s.strstart = 0; + s.block_start = 0; + s.insert = 0; + } + /* use the tail */ + // dictionary = dictionary.slice(dictLength - s.w_size); + tmpDict = new utils.Buf8(s.w_size); + utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0); + dictionary = tmpDict; + dictLength = s.w_size; + } + /* insert dictionary into window and hash */ + avail = strm.avail_in; + next = strm.next_in; + input = strm.input; + strm.avail_in = dictLength; + strm.next_in = 0; + strm.input = dictionary; + fill_window(s); + while (s.lookahead >= MIN_MATCH) { + str = s.strstart; + n = s.lookahead - (MIN_MATCH - 1); + do { + /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */ + s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask; + + s.prev[str & s.w_mask] = s.head[s.ins_h]; + + s.head[s.ins_h] = str; + str++; + } while (--n); + s.strstart = str; + s.lookahead = MIN_MATCH - 1; + fill_window(s); + } + s.strstart += s.lookahead; + s.block_start = s.strstart; + s.insert = s.lookahead; + s.lookahead = 0; + s.match_length = s.prev_length = MIN_MATCH - 1; + s.match_available = 0; + strm.next_in = next; + strm.input = input; + strm.avail_in = avail; + s.wrap = wrap; + return Z_OK; +} + exports.deflateInit = deflateInit; exports.deflateInit2 = deflateInit2; @@ -16779,19 +13269,19 @@ exports.deflateResetKeep = deflateResetKeep; exports.deflateSetHeader = deflateSetHeader; exports.deflate = deflate; exports.deflateEnd = deflateEnd; +exports.deflateSetDictionary = deflateSetDictionary; exports.deflateInfo = 'pako deflate (from Nodeca project)'; /* Not implemented exports.deflateBound = deflateBound; exports.deflateCopy = deflateCopy; -exports.deflateSetDictionary = deflateSetDictionary; exports.deflateParams = deflateParams; exports.deflatePending = deflatePending; exports.deflatePrime = deflatePrime; exports.deflateTune = deflateTune; */ -},{"../utils/common":38,"./adler32":39,"./crc32":41,"./messages":46,"./trees":47}],43:[function(require,module,exports){ +},{"../utils/common":30,"./adler32":31,"./crc32":33,"./messages":38,"./trees":39}],35:[function(require,module,exports){ 'use strict'; // See state defs from inflate.js @@ -17119,14 +13609,14 @@ module.exports = function inflate_fast(strm, start) { return; }; -},{}],44:[function(require,module,exports){ +},{}],36:[function(require,module,exports){ 'use strict'; -var utils = require('../utils/common'); -var adler32 = require('./adler32'); -var crc32 = require('./crc32'); -var inflate_fast = require('./inffast'); +var utils = require('../utils/common'); +var adler32 = require('./adler32'); +var crc32 = require('./crc32'); +var inflate_fast = require('./inffast'); var inflate_table = require('./inftrees'); var CODES = 0; @@ -17214,7 +13704,7 @@ var MAX_WBITS = 15; var DEF_WBITS = MAX_WBITS; -function ZSWAP32(q) { +function zswap32(q) { return (((q >>> 24) & 0xff) + ((q >>> 8) & 0xff00) + ((q & 0xff00) << 8) + @@ -17407,13 +13897,13 @@ function fixedtables(state) { while (sym < 280) { state.lens[sym++] = 7; } while (sym < 288) { state.lens[sym++] = 8; } - inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, {bits: 9}); + inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 }); /* distance table */ sym = 0; while (sym < 32) { state.lens[sym++] = 5; } - inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, {bits: 5}); + inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 }); /* do this just once */ virgin = false; @@ -17455,7 +13945,7 @@ function updatewindow(strm, src, end, copy) { /* copy state->wsize or less output bytes into the circular window */ if (copy >= state.wsize) { - utils.arraySet(state.window,src, end - state.wsize, state.wsize, 0); + utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0); state.wnext = 0; state.whave = state.wsize; } @@ -17465,11 +13955,11 @@ function updatewindow(strm, src, end, copy) { dist = copy; } //zmemcpy(state->window + state->wnext, end - copy, dist); - utils.arraySet(state.window,src, end - copy, dist, state.wnext); + utils.arraySet(state.window, src, end - copy, dist, state.wnext); copy -= dist; if (copy) { //zmemcpy(state->window, end - copy, copy); - utils.arraySet(state.window,src, end - copy, copy, 0); + utils.arraySet(state.window, src, end - copy, copy, 0); state.wnext = copy; state.whave = state.wsize; } @@ -17506,7 +13996,7 @@ function inflate(strm, flush) { var n; // temporary var for NEED_BITS var order = /* permutation of code lengths */ - [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; + [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]; if (!strm || !strm.state || !strm.output || @@ -17833,7 +14323,7 @@ function inflate(strm, flush) { state.head.hcrc = ((state.flags >> 9) & 1); state.head.done = true; } - strm.adler = state.check = 0 /*crc32(0L, Z_NULL, 0)*/; + strm.adler = state.check = 0; state.mode = TYPE; break; case DICTID: @@ -17845,7 +14335,7 @@ function inflate(strm, flush) { bits += 8; } //===// - strm.adler = state.check = ZSWAP32(hold); + strm.adler = state.check = zswap32(hold); //=== INITBITS(); hold = 0; bits = 0; @@ -18037,7 +14527,7 @@ function inflate(strm, flush) { state.lencode = state.lendyn; state.lenbits = 7; - opts = {bits: state.lenbits}; + opts = { bits: state.lenbits }; ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts); state.lenbits = opts.bits; @@ -18168,7 +14658,7 @@ function inflate(strm, flush) { concerning the ENOUGH constants, which depend on those values */ state.lenbits = 9; - opts = {bits: state.lenbits}; + opts = { bits: state.lenbits }; ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts); // We have separate tables & no pointers. 2 commented lines below not needed. // state.next_index = opts.table_index; @@ -18185,7 +14675,7 @@ function inflate(strm, flush) { //state.distcode.copy(state.codes); // Switch to use dynamic table state.distcode = state.distdyn; - opts = {bits: state.distbits}; + opts = { bits: state.distbits }; ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts); // We have separate tables & no pointers. 2 commented lines below not needed. // state.next_index = opts.table_index; @@ -18233,7 +14723,7 @@ function inflate(strm, flush) { } state.back = 0; for (;;) { - here = state.lencode[hold & ((1 << state.lenbits) -1)]; /*BITS(state.lenbits)*/ + here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/ here_bits = here >>> 24; here_op = (here >>> 16) & 0xff; here_val = here & 0xffff; @@ -18252,7 +14742,7 @@ function inflate(strm, flush) { last_val = here_val; for (;;) { here = state.lencode[last_val + - ((hold & ((1 << (last_bits + last_op)) -1))/*BITS(last.bits + last.op)*/ >> last_bits)]; + ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)]; here_bits = here >>> 24; here_op = (here >>> 16) & 0xff; here_val = here & 0xffff; @@ -18309,7 +14799,7 @@ function inflate(strm, flush) { bits += 8; } //===// - state.length += hold & ((1 << state.extra) -1)/*BITS(state.extra)*/; + state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/; //--- DROPBITS(state.extra) ---// hold >>>= state.extra; bits -= state.extra; @@ -18322,7 +14812,7 @@ function inflate(strm, flush) { /* falls through */ case DIST: for (;;) { - here = state.distcode[hold & ((1 << state.distbits) -1)];/*BITS(state.distbits)*/ + here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/ here_bits = here >>> 24; here_op = (here >>> 16) & 0xff; here_val = here & 0xffff; @@ -18341,7 +14831,7 @@ function inflate(strm, flush) { last_val = here_val; for (;;) { here = state.distcode[last_val + - ((hold & ((1 << (last_bits + last_op)) -1))/*BITS(last.bits + last.op)*/ >> last_bits)]; + ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)]; here_bits = here >>> 24; here_op = (here >>> 16) & 0xff; here_val = here & 0xffff; @@ -18385,7 +14875,7 @@ function inflate(strm, flush) { bits += 8; } //===// - state.offset += hold & ((1 << state.extra) -1)/*BITS(state.extra)*/; + state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/; //--- DROPBITS(state.extra) ---// hold >>>= state.extra; bits -= state.extra; @@ -18479,8 +14969,8 @@ function inflate(strm, flush) { } _out = left; - // NB: crc32 stored as signed 32-bit int, ZSWAP32 returns signed too - if ((state.flags ? hold : ZSWAP32(hold)) !== state.check) { + // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too + if ((state.flags ? hold : zswap32(hold)) !== state.check) { strm.msg = 'incorrect data check'; state.mode = BAD; break; @@ -18602,6 +15092,41 @@ function inflateGetHeader(strm, head) { return Z_OK; } +function inflateSetDictionary(strm, dictionary) { + var dictLength = dictionary.length; + + var state; + var dictid; + var ret; + + /* check state */ + if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; } + state = strm.state; + + if (state.wrap !== 0 && state.mode !== DICT) { + return Z_STREAM_ERROR; + } + + /* check for correct dictionary identifier */ + if (state.mode === DICT) { + dictid = 1; /* adler32(0, null, 0)*/ + /* dictid = adler32(dictid, dictionary, dictLength); */ + dictid = adler32(dictid, dictionary, dictLength, 0); + if (dictid !== state.check) { + return Z_DATA_ERROR; + } + } + /* copy dictionary to window using updatewindow(), which will amend the + existing dictionary if appropriate */ + ret = updatewindow(strm, dictionary, dictLength, dictLength); + if (ret) { + state.mode = MEM; + return Z_MEM_ERROR; + } + state.havedict = 1; + // Tracev((stderr, "inflate: dictionary set\n")); + return Z_OK; +} exports.inflateReset = inflateReset; exports.inflateReset2 = inflateReset2; @@ -18611,6 +15136,7 @@ exports.inflateInit2 = inflateInit2; exports.inflate = inflate; exports.inflateEnd = inflateEnd; exports.inflateGetHeader = inflateGetHeader; +exports.inflateSetDictionary = inflateSetDictionary; exports.inflateInfo = 'pako inflate (from Nodeca project)'; /* Not implemented @@ -18618,13 +15144,12 @@ exports.inflateCopy = inflateCopy; exports.inflateGetDictionary = inflateGetDictionary; exports.inflateMark = inflateMark; exports.inflatePrime = inflatePrime; -exports.inflateSetDictionary = inflateSetDictionary; exports.inflateSync = inflateSync; exports.inflateSyncPoint = inflateSyncPoint; exports.inflateUndermine = inflateUndermine; */ -},{"../utils/common":38,"./adler32":39,"./crc32":41,"./inffast":43,"./inftrees":45}],45:[function(require,module,exports){ +},{"../utils/common":30,"./adler32":31,"./crc32":33,"./inffast":35,"./inftrees":37}],37:[function(require,module,exports){ 'use strict'; @@ -18684,8 +15209,8 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta var base_index = 0; // var shoextra; /* extra bits table to use */ var end; /* use base and extra for symbol > end */ - var count = new utils.Buf16(MAXBITS+1); //[MAXBITS+1]; /* number of codes of each length */ - var offs = new utils.Buf16(MAXBITS+1); //[MAXBITS+1]; /* offsets in table for each length */ + var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */ + var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */ var extra = null; var extra_index = 0; @@ -18854,7 +15379,7 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta return 1; } - var i=0; + var i = 0; /* process all codes and make table entries */ for (;;) { i++; @@ -18953,13 +15478,13 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta return 0; }; -},{"../utils/common":38}],46:[function(require,module,exports){ +},{"../utils/common":30}],38:[function(require,module,exports){ 'use strict'; module.exports = { - '2': 'need dictionary', /* Z_NEED_DICT 2 */ - '1': 'stream end', /* Z_STREAM_END 1 */ - '0': '', /* Z_OK 0 */ + 2: 'need dictionary', /* Z_NEED_DICT 2 */ + 1: 'stream end', /* Z_STREAM_END 1 */ + 0: '', /* Z_OK 0 */ '-1': 'file error', /* Z_ERRNO (-1) */ '-2': 'stream error', /* Z_STREAM_ERROR (-2) */ '-3': 'data error', /* Z_DATA_ERROR (-3) */ @@ -18968,7 +15493,7 @@ module.exports = { '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */ }; -},{}],47:[function(require,module,exports){ +},{}],39:[function(require,module,exports){ 'use strict'; @@ -19026,7 +15551,7 @@ var D_CODES = 30; var BL_CODES = 19; /* number of codes used to transfer the bit lengths */ -var HEAP_SIZE = 2*L_CODES + 1; +var HEAP_SIZE = 2 * L_CODES + 1; /* maximum heap size */ var MAX_BITS = 15; @@ -19055,6 +15580,7 @@ var REPZ_3_10 = 17; var REPZ_11_138 = 18; /* repeat a zero length 11-138 times (7 bits of repeat count) */ +/* eslint-disable comma-spacing,array-bracket-spacing */ var extra_lbits = /* extra bits for each length code */ [0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]; @@ -19066,6 +15592,8 @@ var extra_blbits = /* extra bits for each bit length code */ var bl_order = [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]; +/* eslint-enable comma-spacing,array-bracket-spacing */ + /* The lengths of the bit length codes are sent in order of decreasing * probability, to avoid transmitting the lengths for unused bit length codes. */ @@ -19079,7 +15607,7 @@ var bl_order = var DIST_CODE_LEN = 512; /* see definition of array dist_code below */ // !!!! Use flat array insdead of structure, Freq = i*2, Len = i*2+1 -var static_ltree = new Array((L_CODES+2) * 2); +var static_ltree = new Array((L_CODES + 2) * 2); zero(static_ltree); /* The static literal tree. Since the bit lengths are imposed, there is no * need for the L_CODES extra codes used during heap construction. However @@ -19100,7 +15628,7 @@ zero(_dist_code); * the 15 bit distances. */ -var _length_code = new Array(MAX_MATCH-MIN_MATCH+1); +var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1); zero(_length_code); /* length code for each normalized match length (0 == MIN_MATCH) */ @@ -19113,7 +15641,7 @@ zero(base_dist); /* First normalized distance for each code (0 = distance of 1) */ -var StaticTreeDesc = function (static_tree, extra_bits, extra_base, elems, max_length) { +function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) { this.static_tree = static_tree; /* static tree or NULL */ this.extra_bits = extra_bits; /* extra bits for each code or NULL */ @@ -19123,7 +15651,7 @@ var StaticTreeDesc = function (static_tree, extra_bits, extra_base, elems, max_l // show if `static_tree` has data or dummy - needed for monomorphic objects this.has_stree = static_tree && static_tree.length; -}; +} var static_l_desc; @@ -19131,11 +15659,11 @@ var static_d_desc; var static_bl_desc; -var TreeDesc = function(dyn_tree, stat_desc) { +function TreeDesc(dyn_tree, stat_desc) { this.dyn_tree = dyn_tree; /* the dynamic tree */ this.max_code = 0; /* largest code with non zero frequency */ this.stat_desc = stat_desc; /* the corresponding static tree */ -}; +} @@ -19148,7 +15676,7 @@ function d_code(dist) { * Output a short LSB first on the stream. * IN assertion: there is enough room in pendingBuf. */ -function put_short (s, w) { +function put_short(s, w) { // put_byte(s, (uch)((w) & 0xff)); // put_byte(s, (uch)((ush)(w) >> 8)); s.pending_buf[s.pending++] = (w) & 0xff; @@ -19174,7 +15702,7 @@ function send_bits(s, value, length) { function send_code(s, c, tree) { - send_bits(s, tree[c*2]/*.Code*/, tree[c*2 + 1]/*.Len*/); + send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/); } @@ -19246,16 +15774,16 @@ function gen_bitlen(s, desc) /* In a first pass, compute the optimal bit lengths (which may * overflow in the case of the bit length tree). */ - tree[s.heap[s.heap_max]*2 + 1]/*.Len*/ = 0; /* root of the heap */ + tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */ - for (h = s.heap_max+1; h < HEAP_SIZE; h++) { + for (h = s.heap_max + 1; h < HEAP_SIZE; h++) { n = s.heap[h]; - bits = tree[tree[n*2 +1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1; + bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1; if (bits > max_length) { bits = max_length; overflow++; } - tree[n*2 + 1]/*.Len*/ = bits; + tree[n * 2 + 1]/*.Len*/ = bits; /* We overwrite tree[n].Dad which is no longer needed */ if (n > max_code) { continue; } /* not a leaf node */ @@ -19263,12 +15791,12 @@ function gen_bitlen(s, desc) s.bl_count[bits]++; xbits = 0; if (n >= base) { - xbits = extra[n-base]; + xbits = extra[n - base]; } f = tree[n * 2]/*.Freq*/; s.opt_len += f * (bits + xbits); if (has_stree) { - s.static_len += f * (stree[n*2 + 1]/*.Len*/ + xbits); + s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits); } } if (overflow === 0) { return; } @@ -19278,10 +15806,10 @@ function gen_bitlen(s, desc) /* Find the first bit length which could increase: */ do { - bits = max_length-1; + bits = max_length - 1; while (s.bl_count[bits] === 0) { bits--; } s.bl_count[bits]--; /* move one leaf down the tree */ - s.bl_count[bits+1] += 2; /* move one overflow item as its brother */ + s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */ s.bl_count[max_length]--; /* The brother of the overflow item also moves one step up, * but this does not affect bl_count[max_length] @@ -19299,10 +15827,10 @@ function gen_bitlen(s, desc) while (n !== 0) { m = s.heap[--h]; if (m > max_code) { continue; } - if (tree[m*2 + 1]/*.Len*/ !== bits) { + if (tree[m * 2 + 1]/*.Len*/ !== bits) { // Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - s.opt_len += (bits - tree[m*2 + 1]/*.Len*/)*tree[m*2]/*.Freq*/; - tree[m*2 + 1]/*.Len*/ = bits; + s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/; + tree[m * 2 + 1]/*.Len*/ = bits; } n--; } @@ -19323,7 +15851,7 @@ function gen_codes(tree, max_code, bl_count) // int max_code; /* largest code with non zero frequency */ // ushf *bl_count; /* number of codes at each bit length */ { - var next_code = new Array(MAX_BITS+1); /* next code value for each bit length */ + var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */ var code = 0; /* running code value */ var bits; /* bit index */ var n; /* code index */ @@ -19332,7 +15860,7 @@ function gen_codes(tree, max_code, bl_count) * without bit reversal. */ for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = (code + bl_count[bits-1]) << 1; + next_code[bits] = code = (code + bl_count[bits - 1]) << 1; } /* Check that the bit counts in bl_count are consistent. The last code * must be all ones. @@ -19342,10 +15870,10 @@ function gen_codes(tree, max_code, bl_count) //Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); for (n = 0; n <= max_code; n++) { - var len = tree[n*2 + 1]/*.Len*/; + var len = tree[n * 2 + 1]/*.Len*/; if (len === 0) { continue; } /* Now reverse the bits */ - tree[n*2]/*.Code*/ = bi_reverse(next_code[len]++, len); + tree[n * 2]/*.Code*/ = bi_reverse(next_code[len]++, len); //Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", // n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1)); @@ -19362,7 +15890,7 @@ function tr_static_init() { var length; /* length value */ var code; /* code value */ var dist; /* distance index */ - var bl_count = new Array(MAX_BITS+1); + var bl_count = new Array(MAX_BITS + 1); /* number of codes at each bit length for an optimal tree */ // do check in _tr_init() @@ -19379,9 +15907,9 @@ function tr_static_init() { /* Initialize the mapping length (0..255) -> length code (0..28) */ length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { + for (code = 0; code < LENGTH_CODES - 1; code++) { base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ dist = 0; - for (code = 0 ; code < 16; code++) { + for (code = 0; code < 16; code++) { base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ for (; code < D_CODES; code++) { base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { + for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) { _dist_code[256 + dist++] = code; } } @@ -19417,22 +15945,22 @@ function tr_static_init() { n = 0; while (n <= 143) { - static_ltree[n*2 + 1]/*.Len*/ = 8; + static_ltree[n * 2 + 1]/*.Len*/ = 8; n++; bl_count[8]++; } while (n <= 255) { - static_ltree[n*2 + 1]/*.Len*/ = 9; + static_ltree[n * 2 + 1]/*.Len*/ = 9; n++; bl_count[9]++; } while (n <= 279) { - static_ltree[n*2 + 1]/*.Len*/ = 7; + static_ltree[n * 2 + 1]/*.Len*/ = 7; n++; bl_count[7]++; } while (n <= 287) { - static_ltree[n*2 + 1]/*.Len*/ = 8; + static_ltree[n * 2 + 1]/*.Len*/ = 8; n++; bl_count[8]++; } @@ -19440,18 +15968,18 @@ function tr_static_init() { * tree construction to get a canonical Huffman tree (longest code * all ones) */ - gen_codes(static_ltree, L_CODES+1, bl_count); + gen_codes(static_ltree, L_CODES + 1, bl_count); /* The static distance tree is trivial: */ for (n = 0; n < D_CODES; n++) { - static_dtree[n*2 + 1]/*.Len*/ = 5; - static_dtree[n*2]/*.Code*/ = bi_reverse(n, 5); + static_dtree[n * 2 + 1]/*.Len*/ = 5; + static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5); } // Now data ready and we can init static trees - static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS); + static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS); static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS); - static_bl_desc =new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS); + static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS); //static_init_done = true; } @@ -19464,11 +15992,11 @@ function init_block(s) { var n; /* iterates over tree elements */ /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n*2]/*.Freq*/ = 0; } - for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n*2]/*.Freq*/ = 0; } - for (n = 0; n < BL_CODES; n++) { s.bl_tree[n*2]/*.Freq*/ = 0; } + for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; } + for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; } + for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; } - s.dyn_ltree[END_BLOCK*2]/*.Freq*/ = 1; + s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1; s.opt_len = s.static_len = 0; s.last_lit = s.matches = 0; } @@ -19517,8 +16045,8 @@ function copy_block(s, buf, len, header) * the subtrees have equal frequency. This minimizes the worst case length. */ function smaller(tree, n, m, depth) { - var _n2 = n*2; - var _m2 = m*2; + var _n2 = n * 2; + var _m2 = m * 2; return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ || (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m])); } @@ -19539,7 +16067,7 @@ function pqdownheap(s, tree, k) while (j <= s.heap_len) { /* Set j to the smallest of the two sons: */ if (j < s.heap_len && - smaller(tree, s.heap[j+1], s.heap[j], s.depth)) { + smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) { j++; } /* Exit if v is smaller than both sons */ @@ -19575,7 +16103,7 @@ function compress_block(s, ltree, dtree) if (s.last_lit !== 0) { do { - dist = (s.pending_buf[s.d_buf + lx*2] << 8) | (s.pending_buf[s.d_buf + lx*2 + 1]); + dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]); lc = s.pending_buf[s.l_buf + lx]; lx++; @@ -19585,7 +16113,7 @@ function compress_block(s, ltree, dtree) } else { /* Here, lc is the match length - MIN_MATCH */ code = _length_code[lc]; - send_code(s, code+LITERALS+1, ltree); /* send the length code */ + send_code(s, code + LITERALS + 1, ltree); /* send the length code */ extra = extra_lbits[code]; if (extra !== 0) { lc -= base_length[code]; @@ -19647,7 +16175,7 @@ function build_tree(s, desc) s.depth[n] = 0; } else { - tree[n*2 + 1]/*.Len*/ = 0; + tree[n * 2 + 1]/*.Len*/ = 0; } } @@ -19663,7 +16191,7 @@ function build_tree(s, desc) s.opt_len--; if (has_stree) { - s.static_len -= stree[node*2 + 1]/*.Len*/; + s.static_len -= stree[node * 2 + 1]/*.Len*/; } /* node is 0 or 1 so it does not have extra bits */ } @@ -19694,7 +16222,7 @@ function build_tree(s, desc) /* Create a new node father of n and m */ tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/; s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1; - tree[n*2 + 1]/*.Dad*/ = tree[m*2 + 1]/*.Dad*/ = node; + tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node; /* and insert the new node in the heap */ s.heap[1/*SMALLEST*/] = node++; @@ -19727,7 +16255,7 @@ function scan_tree(s, tree, max_code) var prevlen = -1; /* last emitted length */ var curlen; /* length of current code */ - var nextlen = tree[0*2 + 1]/*.Len*/; /* length of next code */ + var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */ var count = 0; /* repeat count of the current code */ var max_count = 7; /* max repeat count */ @@ -19737,11 +16265,11 @@ function scan_tree(s, tree, max_code) max_count = 138; min_count = 3; } - tree[(max_code+1)*2 + 1]/*.Len*/ = 0xffff; /* guard */ + tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */ for (n = 0; n <= max_code; n++) { curlen = nextlen; - nextlen = tree[(n+1)*2 + 1]/*.Len*/; + nextlen = tree[(n + 1) * 2 + 1]/*.Len*/; if (++count < max_count && curlen === nextlen) { continue; @@ -19752,13 +16280,13 @@ function scan_tree(s, tree, max_code) } else if (curlen !== 0) { if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; } - s.bl_tree[REP_3_6*2]/*.Freq*/++; + s.bl_tree[REP_3_6 * 2]/*.Freq*/++; } else if (count <= 10) { - s.bl_tree[REPZ_3_10*2]/*.Freq*/++; + s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++; } else { - s.bl_tree[REPZ_11_138*2]/*.Freq*/++; + s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++; } count = 0; @@ -19793,7 +16321,7 @@ function send_tree(s, tree, max_code) var prevlen = -1; /* last emitted length */ var curlen; /* length of current code */ - var nextlen = tree[0*2 + 1]/*.Len*/; /* length of next code */ + var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */ var count = 0; /* repeat count of the current code */ var max_count = 7; /* max repeat count */ @@ -19807,7 +16335,7 @@ function send_tree(s, tree, max_code) for (n = 0; n <= max_code; n++) { curlen = nextlen; - nextlen = tree[(n+1)*2 + 1]/*.Len*/; + nextlen = tree[(n + 1) * 2 + 1]/*.Len*/; if (++count < max_count && curlen === nextlen) { continue; @@ -19822,15 +16350,15 @@ function send_tree(s, tree, max_code) } //Assert(count >= 3 && count <= 6, " 3_6?"); send_code(s, REP_3_6, s.bl_tree); - send_bits(s, count-3, 2); + send_bits(s, count - 3, 2); } else if (count <= 10) { send_code(s, REPZ_3_10, s.bl_tree); - send_bits(s, count-3, 3); + send_bits(s, count - 3, 3); } else { send_code(s, REPZ_11_138, s.bl_tree); - send_bits(s, count-11, 7); + send_bits(s, count - 11, 7); } count = 0; @@ -19872,13 +16400,13 @@ function build_bl_tree(s) { * requires that at least 4 bit length codes be sent. (appnote.txt says * 3 but the actual value used is 4.) */ - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { - if (s.bl_tree[bl_order[max_blindex]*2 + 1]/*.Len*/ !== 0) { + for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { + if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) { break; } } /* Update opt_len to include the bit length tree and counts */ - s.opt_len += 3*(max_blindex+1) + 5+5+4; + s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; //Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", // s->opt_len, s->static_len)); @@ -19901,19 +16429,19 @@ function send_all_trees(s, lcodes, dcodes, blcodes) //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, // "too many codes"); //Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes-1, 5); - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ + send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */ + send_bits(s, dcodes - 1, 5); + send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */ for (rank = 0; rank < blcodes; rank++) { //Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(s, s.bl_tree[bl_order[rank]*2 + 1]/*.Len*/, 3); + send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3); } //Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); - send_tree(s, s.dyn_ltree, lcodes-1); /* literal tree */ + send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */ //Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); - send_tree(s, s.dyn_dtree, dcodes-1); /* distance tree */ + send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */ //Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); } @@ -19941,7 +16469,7 @@ function detect_data_type(s) { /* Check for non-textual ("black-listed") bytes. */ for (n = 0; n <= 31; n++, black_mask >>>= 1) { - if ((black_mask & 1) && (s.dyn_ltree[n*2]/*.Freq*/ !== 0)) { + if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) { return Z_BINARY; } } @@ -19998,7 +16526,7 @@ function _tr_stored_block(s, buf, stored_len, last) //ulg stored_len; /* length of input block */ //int last; /* one if this is the last block for a file */ { - send_bits(s, (STORED_BLOCK<<1)+(last ? 1 : 0), 3); /* send block type */ + send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */ copy_block(s, buf, stored_len, true); /* with header */ } @@ -20008,7 +16536,7 @@ function _tr_stored_block(s, buf, stored_len, last) * This takes 10 bits, of which 7 may remain in the bit buffer. */ function _tr_align(s) { - send_bits(s, STATIC_TREES<<1, 3); + send_bits(s, STATIC_TREES << 1, 3); send_code(s, END_BLOCK, static_ltree); bi_flush(s); } @@ -20053,8 +16581,8 @@ function _tr_flush_block(s, buf, stored_len, last) max_blindex = build_bl_tree(s); /* Determine the best encoding. Compute the block lengths in bytes. */ - opt_lenb = (s.opt_len+3+7) >>> 3; - static_lenb = (s.static_len+3+7) >>> 3; + opt_lenb = (s.opt_len + 3 + 7) >>> 3; + static_lenb = (s.static_len + 3 + 7) >>> 3; // Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, @@ -20067,7 +16595,7 @@ function _tr_flush_block(s, buf, stored_len, last) opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ } - if ((stored_len+4 <= opt_lenb) && (buf !== -1)) { + if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) { /* 4: two words for the lengths */ /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. @@ -20080,12 +16608,12 @@ function _tr_flush_block(s, buf, stored_len, last) } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) { - send_bits(s, (STATIC_TREES<<1) + (last ? 1 : 0), 3); + send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3); compress_block(s, static_ltree, static_dtree); } else { - send_bits(s, (DYN_TREES<<1) + (last ? 1 : 0), 3); - send_all_trees(s, s.l_desc.max_code+1, s.d_desc.max_code+1, max_blindex+1); + send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3); + send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1); compress_block(s, s.dyn_ltree, s.dyn_dtree); } // Assert (s->compressed_len == s->bits_sent, "bad compressed size"); @@ -20120,7 +16648,7 @@ function _tr_tally(s, dist, lc) if (dist === 0) { /* lc is the unmatched char */ - s.dyn_ltree[lc*2]/*.Freq*/++; + s.dyn_ltree[lc * 2]/*.Freq*/++; } else { s.matches++; /* Here, lc is the match length - MIN_MATCH */ @@ -20129,7 +16657,7 @@ function _tr_tally(s, dist, lc) // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && // (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); - s.dyn_ltree[(_length_code[lc]+LITERALS+1) * 2]/*.Freq*/++; + s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++; s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++; } @@ -20156,7 +16684,7 @@ function _tr_tally(s, dist, lc) // } //#endif - return (s.last_lit === s.lit_bufsize-1); + return (s.last_lit === s.lit_bufsize - 1); /* We avoid equality with lit_bufsize because of wraparound at 64K * on 16 bit machines and because stored blocks are restricted to * 64K-1 bytes. @@ -20169,7 +16697,7 @@ exports._tr_flush_block = _tr_flush_block; exports._tr_tally = _tr_tally; exports._tr_align = _tr_align; -},{"../utils/common":38}],48:[function(require,module,exports){ +},{"../utils/common":30}],40:[function(require,module,exports){ 'use strict'; @@ -20200,7 +16728,7 @@ function ZStream() { module.exports = ZStream; -},{}],49:[function(require,module,exports){ +},{}],41:[function(require,module,exports){ (function (process){ 'use strict'; @@ -20212,28 +16740,140 @@ if (!process.version || module.exports = process.nextTick; } -function nextTick(fn) { - var args = new Array(arguments.length - 1); - var i = 0; - while (i < args.length) { - args[i++] = arguments[i]; +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; + } + return process.nextTick(function afterTick() { + fn.apply(null, args); + }); } - process.nextTick(function afterTick() { - fn.apply(null, args); - }); } }).call(this,require('_process')) -},{"_process":50}],50:[function(require,module,exports){ +},{"_process":42}],42:[function(require,module,exports){ // shim for using process in browser - var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); @@ -20249,7 +16889,7 @@ function drainQueue() { if (draining) { return; } - var timeout = setTimeout(cleanUpNextTick); + var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; @@ -20266,7 +16906,7 @@ function drainQueue() { } currentQueue = null; draining = false; - clearTimeout(timeout); + runClearTimeout(timeout); } process.nextTick = function (fun) { @@ -20278,7 +16918,7 @@ process.nextTick = function (fun) { } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { - setTimeout(drainQueue, 0); + runTimeout(drainQueue); } }; @@ -20317,7 +16957,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],51:[function(require,module,exports){ +},{}],43:[function(require,module,exports){ // a duplex stream is just a stream that is both readable and writable. // Since JS doesn't have multiple prototypal inheritance, this class // prototypally inherits from Readable, and then parasitically from @@ -20393,7 +17033,7 @@ function forEach(xs, f) { f(xs[i], i); } } -},{"./_stream_readable":52,"./_stream_writable":54,"core-util-is":22,"inherits":28,"process-nextick-args":49}],52:[function(require,module,exports){ +},{"./_stream_readable":44,"./_stream_writable":46,"core-util-is":23,"inherits":27,"process-nextick-args":41}],44:[function(require,module,exports){ (function (process){ 'use strict'; @@ -20408,14 +17048,14 @@ var isArray = require('isarray'); /**/ /**/ -var Buffer = require('buffer').Buffer; +var Duplex; /**/ Readable.ReadableState = ReadableState; -var EE = require('events'); - /**/ +var EE = require('events').EventEmitter; + var EElistenerCount = function (emitter, type) { return emitter.listeners(type).length; }; @@ -20433,6 +17073,9 @@ var Stream; /**/ var Buffer = require('buffer').Buffer; +/**/ +var bufferShim = require('buffer-shims'); +/**/ /**/ var util = require('core-util-is'); @@ -20441,7 +17084,7 @@ util.inherits = require('inherits'); /**/ var debugUtil = require('util'); -var debug = undefined; +var debug = void 0; if (debugUtil && debugUtil.debuglog) { debug = debugUtil.debuglog('stream'); } else { @@ -20449,11 +17092,25 @@ if (debugUtil && debugUtil.debuglog) { } /**/ +var BufferList = require('./internal/streams/BufferList'); var StringDecoder; util.inherits(Readable, Stream); -var Duplex; +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') { + return emitter.prependListener(event, fn); + } else { + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; + } +} + function ReadableState(options, stream) { Duplex = Duplex || require('./_stream_duplex'); @@ -20474,7 +17131,10 @@ function ReadableState(options, stream) { // cast to ints. this.highWaterMark = ~ ~this.highWaterMark; - this.buffer = []; + // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + this.buffer = new BufferList(); this.length = 0; this.pipes = null; this.pipesCount = 0; @@ -20520,7 +17180,6 @@ function ReadableState(options, stream) { } } -var Duplex; function Readable(options) { Duplex = Duplex || require('./_stream_duplex'); @@ -20546,7 +17205,7 @@ Readable.prototype.push = function (chunk, encoding) { if (!state.objectMode && typeof chunk === 'string') { encoding = encoding || state.defaultEncoding; if (encoding !== state.encoding) { - chunk = new Buffer(chunk, encoding); + chunk = bufferShim.from(chunk, encoding); encoding = ''; } } @@ -20576,8 +17235,8 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) { var e = new Error('stream.push() after EOF'); stream.emit('error', e); } else if (state.endEmitted && addToFront) { - var e = new Error('stream.unshift() after end event'); - stream.emit('error', e); + var _e = new Error('stream.unshift() after end event'); + stream.emit('error', _e); } else { var skipAdd; if (state.decoder && !addToFront && !encoding) { @@ -20637,7 +17296,8 @@ function computeNewHighWaterMark(n) { if (n >= MAX_HWM) { n = MAX_HWM; } else { - // Get the next highest power of 2 + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts n--; n |= n >>> 1; n |= n >>> 2; @@ -20649,44 +17309,34 @@ function computeNewHighWaterMark(n) { return n; } +// This function is designed to be inlinable, so please take care when making +// changes to the function body. function howMuchToRead(n, state) { - if (state.length === 0 && state.ended) return 0; - - if (state.objectMode) return n === 0 ? 0 : 1; - - if (n === null || isNaN(n)) { - // only flow one buffer at a time - if (state.flowing && state.buffer.length) return state.buffer[0].length;else return state.length; + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; } - - if (n <= 0) return 0; - - // If we're asking for more than the target buffer level, - // then raise the water mark. Bump up to the next highest - // power of 2, to prevent increasing it excessively in tiny - // amounts. + // If we're asking for more than the current hwm, then raise the hwm. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); - - // don't have that much. return null, unless we've ended. - if (n > state.length) { - if (!state.ended) { - state.needReadable = true; - return 0; - } else { - return state.length; - } + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; } - - return n; + return state.length; } // you can override either this method, or the async _read(n) below. Readable.prototype.read = function (n) { debug('read', n); + n = parseInt(n, 10); var state = this._readableState; var nOrig = n; - if (typeof n !== 'number' || n > 0) state.emittedReadable = false; + if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we // already have a bunch of data in the buffer, then just trigger @@ -20742,9 +17392,7 @@ Readable.prototype.read = function (n) { if (state.ended || state.reading) { doRead = false; debug('reading or ended', doRead); - } - - if (doRead) { + } else if (doRead) { debug('do read'); state.reading = true; state.sync = true; @@ -20753,28 +17401,29 @@ Readable.prototype.read = function (n) { // call internal read method this._read(state.highWaterMark); state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); } - // If _read pushed data synchronously, then `reading` will be false, - // and we need to re-evaluate how much data we can return to the user. - if (doRead && !state.reading) n = howMuchToRead(nOrig, state); - var ret; if (n > 0) ret = fromList(n, state);else ret = null; if (ret === null) { state.needReadable = true; n = 0; + } else { + state.length -= n; } - state.length -= n; - - // If we have nothing in the buffer, then we want to know - // as soon as we *do* get something into the buffer. - if (state.length === 0 && !state.ended) state.needReadable = true; + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; - // If we tried to read() past the EOF, then emit end on the next tick. - if (nOrig !== n && state.ended && state.length === 0) endReadable(this); + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended) endReadable(this); + } if (ret !== null) this.emit('data', ret); @@ -20853,7 +17502,7 @@ function maybeReadMore_(stream, state) { // for virtual (non-string, non-buffer) streams, "length" is somewhat // arbitrary, and perhaps not very meaningful. Readable.prototype._read = function (n) { - this.emit('error', new Error('not implemented')); + this.emit('error', new Error('_read() is not implemented')); }; Readable.prototype.pipe = function (dest, pipeOpts) { @@ -20922,17 +17571,25 @@ Readable.prototype.pipe = function (dest, pipeOpts) { if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); } + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; src.on('data', ondata); function ondata(chunk) { debug('ondata'); + increasedAwaitDrain = false; var ret = dest.write(chunk); - if (false === ret) { + if (false === ret && !increasedAwaitDrain) { // If the user unpiped during `dest.write()`, it is possible // to get stuck in a permanently paused state if that write // also returned false. - if (state.pipesCount === 1 && state.pipes[0] === dest && src.listenerCount('data') === 1 && !cleanedUp) { + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { debug('false write response, pause', src._readableState.awaitDrain); src._readableState.awaitDrain++; + increasedAwaitDrain = true; } src.pause(); } @@ -20946,9 +17603,9 @@ Readable.prototype.pipe = function (dest, pipeOpts) { dest.removeListener('error', onerror); if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); } - // This is a brutally ugly hack to make sure that our error handler - // is attached before any userland ones. NEVER DO THIS. - if (!dest._events || !dest._events.error) dest.on('error', onerror);else if (isArray(dest._events.error)) dest._events.error.unshift(onerror);else dest._events.error = [onerror, dest._events.error]; + + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once. function onclose() { @@ -21023,16 +17680,16 @@ Readable.prototype.unpipe = function (dest) { state.pipesCount = 0; state.flowing = false; - for (var _i = 0; _i < len; _i++) { - dests[_i].emit('unpipe', this); + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this); }return this; } // try to find the right one. - var i = indexOf(state.pipes, dest); - if (i === -1) return this; + var index = indexOf(state.pipes, dest); + if (index === -1) return this; - state.pipes.splice(i, 1); + state.pipes.splice(index, 1); state.pipesCount -= 1; if (state.pipesCount === 1) state.pipes = state.pipes[0]; @@ -21046,18 +17703,14 @@ Readable.prototype.unpipe = function (dest) { Readable.prototype.on = function (ev, fn) { var res = Stream.prototype.on.call(this, ev, fn); - // If listening to data, and it has not explicitly been paused, - // then call resume to start the flow of data on the next tick. - if (ev === 'data' && false !== this._readableState.flowing) { - this.resume(); - } - - if (ev === 'readable' && !this._readableState.endEmitted) { + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); + } else if (ev === 'readable') { var state = this._readableState; - if (!state.readableListening) { - state.readableListening = true; + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; state.emittedReadable = false; - state.needReadable = true; if (!state.reading) { processNextTick(nReadingNextTick, this); } else if (state.length) { @@ -21101,6 +17754,7 @@ function resume_(stream, state) { } state.resumeScheduled = false; + state.awaitDrain = 0; stream.emit('resume'); flow(stream); if (state.flowing && !state.reading) stream.read(0); @@ -21119,11 +17773,7 @@ Readable.prototype.pause = function () { function flow(stream) { var state = stream._readableState; debug('flow', state.flowing); - if (state.flowing) { - do { - var chunk = stream.read(); - } while (null !== chunk && state.flowing); - } + while (state.flowing && stream.read() !== null) {} } // wrap an old-style stream as the async data source. @@ -21194,50 +17844,101 @@ Readable._fromList = fromList; // Pluck off n bytes from an array of buffers. // Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. function fromList(n, state) { - var list = state.buffer; - var length = state.length; - var stringMode = !!state.decoder; - var objectMode = !!state.objectMode; - var ret; - - // nothing in the list, definitely empty. - if (list.length === 0) return null; + // nothing buffered + if (state.length === 0) return null; - if (length === 0) ret = null;else if (objectMode) ret = list.shift();else if (!n || n >= length) { - // read it all, truncate the array. - if (stringMode) ret = list.join('');else if (list.length === 1) ret = list[0];else ret = Buffer.concat(list, length); - list.length = 0; + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + state.buffer.clear(); } else { - // read just some of it. - if (n < list[0].length) { - // just take a part of the first list item. - // slice is the same for buffers and strings. - var buf = list[0]; - ret = buf.slice(0, n); - list[0] = buf.slice(n); - } else if (n === list[0].length) { - // first list is a perfect match - ret = list.shift(); - } else { - // complex case. - // we have enough to cover it, but it spans past the first buffer. - if (stringMode) ret = '';else ret = new Buffer(n); - - var c = 0; - for (var i = 0, l = list.length; i < l && c < n; i++) { - var buf = list[0]; - var cpy = Math.min(n - c, buf.length); + // read part of list + ret = fromListPartial(n, state.buffer, state.decoder); + } - if (stringMode) ret += buf.slice(0, cpy);else buf.copy(ret, c, 0, cpy); + return ret; +} - if (cpy < buf.length) list[0] = buf.slice(cpy);else list.shift(); +// Extracts only enough buffered data to satisfy the amount requested. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); + } + return ret; +} - c += cpy; +// Copies a specified amount of characters from the list of buffered data +// chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); } + break; } + ++c; } + list.length -= c; + return ret; +} +// Copies a specified amount of bytes from the list of buffered data chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBuffer(n, list) { + var ret = bufferShim.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; return ret; } @@ -21246,7 +17947,7 @@ function endReadable(stream) { // If we get here before consuming all the bytes, then that is a // bug in node. Should never happen. - if (state.length > 0) throw new Error('endReadable called on non-empty stream'); + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); if (!state.endEmitted) { state.ended = true; @@ -21276,7 +17977,7 @@ function indexOf(xs, x) { return -1; } }).call(this,require('_process')) -},{"./_stream_duplex":51,"_process":50,"buffer":21,"core-util-is":22,"events":25,"inherits":28,"isarray":30,"process-nextick-args":49,"string_decoder/":56,"util":18}],53:[function(require,module,exports){ +},{"./_stream_duplex":43,"./internal/streams/BufferList":47,"_process":42,"buffer":22,"buffer-shims":21,"core-util-is":23,"events":24,"inherits":27,"isarray":29,"process-nextick-args":41,"string_decoder/":49,"util":18}],45:[function(require,module,exports){ // a transform stream is a readable/writable stream where you do // something with the data. Sometimes it's called a "filter", // but that's not a great name for it, since that implies a thing where @@ -21373,7 +18074,6 @@ function Transform(options) { this._transformState = new TransformState(this); - // when the writable side finishes, then flush out anything remaining. var stream = this; // start out asking for a readable event once data is transformed. @@ -21390,9 +18090,10 @@ function Transform(options) { if (typeof options.flush === 'function') this._flush = options.flush; } + // When the writable side finishes, then flush out anything remaining. this.once('prefinish', function () { - if (typeof this._flush === 'function') this._flush(function (er) { - done(stream, er); + if (typeof this._flush === 'function') this._flush(function (er, data) { + done(stream, er, data); });else done(stream); }); } @@ -21413,7 +18114,7 @@ Transform.prototype.push = function (chunk, encoding) { // an error, then that'll put the hurt on the whole operation. If you // never call cb(), then you'll never get another chunk. Transform.prototype._transform = function (chunk, encoding, cb) { - throw new Error('not implemented'); + throw new Error('_transform() is not implemented'); }; Transform.prototype._write = function (chunk, encoding, cb) { @@ -21443,21 +18144,23 @@ Transform.prototype._read = function (n) { } }; -function done(stream, er) { +function done(stream, er, data) { if (er) return stream.emit('error', er); + if (data !== null && data !== undefined) stream.push(data); + // if there's nothing in the write buffer, then that means // that nothing more will ever be provided var ws = stream._writableState; var ts = stream._transformState; - if (ws.length) throw new Error('calling transform done when ws.length != 0'); + if (ws.length) throw new Error('Calling transform done when ws.length != 0'); - if (ts.transforming) throw new Error('calling transform done when still transforming'); + if (ts.transforming) throw new Error('Calling transform done when still transforming'); return stream.push(null); } -},{"./_stream_duplex":51,"core-util-is":22,"inherits":28}],54:[function(require,module,exports){ +},{"./_stream_duplex":43,"core-util-is":23,"inherits":27}],46:[function(require,module,exports){ (function (process){ // A bit simpler than readable streams. // Implement an async ._write(chunk, encoding, cb), and it'll handle all @@ -21476,7 +18179,7 @@ var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version. /**/ /**/ -var Buffer = require('buffer').Buffer; +var Duplex; /**/ Writable.WritableState = WritableState; @@ -21504,6 +18207,9 @@ var Stream; /**/ var Buffer = require('buffer').Buffer; +/**/ +var bufferShim = require('buffer-shims'); +/**/ util.inherits(Writable, Stream); @@ -21516,7 +18222,6 @@ function WriteReq(chunk, encoding, cb) { this.next = null; } -var Duplex; function WritableState(options, stream) { Duplex = Duplex || require('./_stream_duplex'); @@ -21538,6 +18243,7 @@ function WritableState(options, stream) { // cast to ints. this.highWaterMark = ~ ~this.highWaterMark; + // drain event flag. this.needDrain = false; // at the start of calling end() this.ending = false; @@ -21607,13 +18313,12 @@ function WritableState(options, stream) { // count buffered requests this.bufferedRequestCount = 0; - // create the two objects needed to store the corked requests - // they are not a linked list, as no new elements are inserted in there + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two this.corkedRequestsFree = new CorkedRequest(this); - this.corkedRequestsFree.next = new CorkedRequest(this); } -WritableState.prototype.getBuffer = function writableStateGetBuffer() { +WritableState.prototype.getBuffer = function getBuffer() { var current = this.bufferedRequest; var out = []; while (current) { @@ -21633,13 +18338,37 @@ WritableState.prototype.getBuffer = function writableStateGetBuffer() { } catch (_) {} })(); -var Duplex; +// Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. +var realHasInstance; +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function (object) { + if (realHasInstance.call(this, object)) return true; + + return object && object._writableState instanceof WritableState; + } + }); +} else { + realHasInstance = function (object) { + return object instanceof this; + }; +} + function Writable(options) { Duplex = Duplex || require('./_stream_duplex'); - // Writable ctor is applied to Duplexes, though they're not - // instanceof Writable, they're instanceof Readable. - if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options); + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { + return new Writable(options); + } this._writableState = new WritableState(options, this); @@ -21657,7 +18386,7 @@ function Writable(options) { // Otherwise people can pipe Writable streams, which is just wrong. Writable.prototype.pipe = function () { - this.emit('error', new Error('Cannot pipe. Not readable.')); + this.emit('error', new Error('Cannot pipe, not readable')); }; function writeAfterEnd(stream, cb) { @@ -21674,9 +18403,16 @@ function writeAfterEnd(stream, cb) { // how many bytes or characters. function validChunk(stream, state, chunk, cb) { var valid = true; - - if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { - var er = new TypeError('Invalid non-string/buffer chunk'); + var er = false; + // Always throw error if a null is written + // if we are not in object mode then throw + // if it is not a buffer, string, or undefined. + if (chunk === null) { + er = new TypeError('May not write null values to stream'); + } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + if (er) { stream.emit('error', er); processNextTick(cb, er); valid = false; @@ -21726,11 +18462,12 @@ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { if (typeof encoding === 'string') encoding = encoding.toLowerCase(); if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); this._writableState.defaultEncoding = encoding; + return this; }; function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { - chunk = new Buffer(chunk, encoding); + chunk = bufferShim.from(chunk, encoding); } return chunk; } @@ -21853,12 +18590,16 @@ function clearBuffer(stream, state) { doWrite(stream, state, true, state.length, buffer, '', holder.finish); - // doWrite is always async, defer these to save a bit of time + // doWrite is almost always async, defer these to save a bit of time // as the hot path ends with doWrite state.pendingcb++; state.lastBufferedRequest = null; - state.corkedRequestsFree = holder.next; - holder.next = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } } else { // Slow case, write chunks one-by-one while (entry) { @@ -21887,7 +18628,7 @@ function clearBuffer(stream, state) { } Writable.prototype._write = function (chunk, encoding, cb) { - cb(new Error('not implemented')); + cb(new Error('_write() is not implemented')); }; Writable.prototype._writev = null; @@ -21976,10 +18717,75 @@ function CorkedRequest(state) { }; } }).call(this,require('_process')) -},{"./_stream_duplex":51,"_process":50,"buffer":21,"core-util-is":22,"events":25,"inherits":28,"process-nextick-args":49,"util-deprecate":57}],55:[function(require,module,exports){ +},{"./_stream_duplex":43,"_process":42,"buffer":22,"buffer-shims":21,"core-util-is":23,"events":24,"inherits":27,"process-nextick-args":41,"util-deprecate":50}],47:[function(require,module,exports){ +'use strict'; + +var Buffer = require('buffer').Buffer; +/**/ +var bufferShim = require('buffer-shims'); +/**/ + +module.exports = BufferList; + +function BufferList() { + this.head = null; + this.tail = null; + this.length = 0; +} + +BufferList.prototype.push = function (v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; +}; + +BufferList.prototype.unshift = function (v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; +}; + +BufferList.prototype.shift = function () { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; +}; + +BufferList.prototype.clear = function () { + this.head = this.tail = null; + this.length = 0; +}; + +BufferList.prototype.join = function (s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; +}; + +BufferList.prototype.concat = function (n) { + if (this.length === 0) return bufferShim.alloc(0); + if (this.length === 1) return this.head.data; + var ret = bufferShim.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + p.data.copy(ret, i); + i += p.data.length; + p = p.next; + } + return ret; +}; +},{"buffer":22,"buffer-shims":21}],48:[function(require,module,exports){ module.exports = require("./lib/_stream_transform.js") -},{"./lib/_stream_transform.js":53}],56:[function(require,module,exports){ +},{"./lib/_stream_transform.js":45}],49:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -22202,7 +19008,7 @@ function base64DetectIncompleteChar(buffer) { this.charLength = this.charReceived ? 3 : 0; } -},{"buffer":21}],57:[function(require,module,exports){ +},{"buffer":22}],50:[function(require,module,exports){ (function (global){ /** @@ -22273,14 +19079,16 @@ function config (name) { } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],58:[function(require,module,exports){ +},{}],51:[function(require,module,exports){ +arguments[4][27][0].apply(exports,arguments) +},{"dup":27}],52:[function(require,module,exports){ module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function'; } -},{}],59:[function(require,module,exports){ +},{}],53:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -22870,15 +19678,14 @@ function hasOwnProperty(obj, prop) { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":58,"_process":50,"inherits":28}],60:[function(require,module,exports){ +},{"./support/isBuffer":52,"_process":42,"inherits":51}],54:[function(require,module,exports){ var bundleFn = arguments[3]; var sources = arguments[4]; var cache = arguments[5]; var stringify = JSON.stringify; -module.exports = function (fn) { - var keys = []; +module.exports = function (fn, options) { var wkey; var cacheKeys = Object.keys(cache); @@ -22889,7 +19696,7 @@ module.exports = function (fn) { // be an object with the default export as a property of it. To ensure // the existing api and babel esmodule exports are both supported we // check for both - if (exp === fn || exp.default === fn) { + if (exp === fn || exp && exp.default === fn) { wkey = key; break; } @@ -22920,8 +19727,22 @@ module.exports = function (fn) { scache ]; + var workerSources = {}; + resolveSources(skey); + + function resolveSources(key) { + workerSources[key] = true; + + for (var depPath in sources[key][1]) { + var depKey = sources[key][1][depPath]; + if (!workerSources[depKey]) { + resolveSources(depKey); + } + } + } + var src = '(' + bundleFn + ')({' - + Object.keys(sources).map(function (key) { + + Object.keys(workerSources).map(function (key) { return stringify(key) + ':[' + sources[key][0] + ',' + stringify(sources[key][1]) + ']' @@ -22932,9 +19753,12 @@ module.exports = function (fn) { var URL = window.URL || window.webkitURL || window.mozURL || window.msURL; - return new Worker(URL.createObjectURL( - new Blob([src], { type: 'text/javascript' }) - )); + var blob = new Blob([src], { type: 'text/javascript' }); + if (options && options.bare) { return blob; } + var workerUrl = URL.createObjectURL(blob); + var worker = new Worker(workerUrl); + worker.objectURL = workerUrl; + return worker; }; },{}]},{},[1])(1) diff --git a/dist/inkjet.min.js b/dist/inkjet.min.js index 2ff2659..9472a23 100644 --- a/dist/inkjet.min.js +++ b/dist/inkjet.min.js @@ -1,14 +1,7 @@ -/* - * inkjet - JPEG-image decoding, encoding & EXIF reading library for browser and node.js - * @version v2.0.2 - * @author Grigoriy Chudnov (https://github.com/gchudnov) - * @link https://github.com/gchudnov/inkjet - * @license MIT - */ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.inkjet=e()}}(function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var u="function"==typeof require&&require;if(!s&&u)return u(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[o]={exports:{}};t[o][0].call(f.exports,function(e){var r=t[o][1][e];return i(r?r:e)},f,f.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o=this._APP0_MARKER&&r<=this._APP15_MARKER},e.prototype._hasExifData=function(){return 0!==this._tiffHeaderOffset},e.prototype._readTags=function(){return this._setByteOrder(),this._read0thIfd(),this._readExifIfd(),this._readGpsIfd(),this._readInteroperabilityIfd()},e.prototype._setByteOrder=function(){if(this._dataView.getUint16(this._tiffHeaderOffset)===this._BYTE_ORDER_BIG_ENDIAN)return this._littleEndian=!0;if(this._dataView.getUint16(this._tiffHeaderOffset)===this._BYTE_ORDER_LITTLE_ENDIAN)return this._littleEndian=!1;throw new Error("Illegal byte order value. Faulty image.")},e.prototype._read0thIfd=function(){var e;return e=this._getIfdOffset(),this._readIfd("0th",e)},e.prototype._getIfdOffset=function(){return this._tiffHeaderOffset+this._getLongAt(this._tiffHeaderOffset+4)},e.prototype._readExifIfd=function(){var e;return null!=this._tags["Exif IFD Pointer"]?(e=this._tiffHeaderOffset+this._tags["Exif IFD Pointer"].value,this._readIfd("exif",e)):void 0},e.prototype._readGpsIfd=function(){var e;return null!=this._tags["GPS Info IFD Pointer"]?(e=this._tiffHeaderOffset+this._tags["GPS Info IFD Pointer"].value,this._readIfd("gps",e)):void 0},e.prototype._readInteroperabilityIfd=function(){var e;return null!=this._tags["Interoperability IFD Pointer"]?(e=this._tiffHeaderOffset+this._tags["Interoperability IFD Pointer"].value,this._readIfd("interoperability",e)):void 0},e.prototype._readIfd=function(e,t){var r,n,i,a,o;for(n=this._getShortAt(t),t+=2,o=[],r=a=0;n>=0?n>a:a>n;r=n>=0?++a:--a)i=this._readTag(e,t),void 0!==i&&(this._tags[i.name]={value:i.value,description:i.description}),o.push(t+=12);return o},e.prototype._readTag=function(e,t){var r,n,i,a,o,s,u;return r=this._getShortAt(t),o=this._getShortAt(t+2),n=this._getLongAt(t+4),void 0!==this._typeSizes[o]?(this._typeSizes[o]*n<=4?s=this._getTagValue(t+8,o,n):(u=this._getLongAt(t+8),s=this._getTagValue(this._tiffHeaderOffset+u,o,n)),o===this._tagTypes.ASCII&&(s=this._splitNullSeparatedAsciiString(s)),null!=this._tagNames[e][r]?(null!=this._tagNames[e][r].name&&null!=this._tagNames[e][r].description?(a=this._tagNames[e][r].name,i=this._tagNames[e][r].description(s)):(a=this._tagNames[e][r],i=s instanceof Array?s.join(", "):s),{name:a,value:s,description:i}):{name:"undefined-"+r,value:s,description:s}):void 0},e.prototype._getTagValue=function(e,t,r){var n,i,a;return i=function(){var i,o;for(o=[],a=i=0;r>=0?r>i:i>r;a=r>=0?++i:--i)n=this._getTagValueAt[t](e),e+=this._typeSizes[t],o.push(n);return o}.call(this),1===i.length?i=i[0]:t===this._tagTypes.ASCII&&(i=this._getAsciiValue(i)),i},e.prototype._getAsciiValue=function(e){var t,r;return r=function(){var r,n,i;for(i=[],r=0,n=e.length;n>r;r++)t=e[r],i.push(String.fromCharCode(t));return i}()},e.prototype._getByteAt=function(e){return this._dataView.getUint8(e)},e.prototype._getAsciiAt=function(e){return this._dataView.getUint8(e)},e.prototype._getShortAt=function(e){return this._dataView.getUint16(e,this._littleEndian)},e.prototype._getLongAt=function(e){return this._dataView.getUint32(e,this._littleEndian)},e.prototype._getRationalAt=function(e){return this._getLongAt(e)/this._getLongAt(e+4)},e.prototype._getUndefinedAt=function(e){return this._getByteAt(e)},e.prototype._getSlongAt=function(e){return this._dataView.getInt32(e,this._littleEndian)},e.prototype._getSrationalAt=function(e){return this._getSlongAt(e)/this._getSlongAt(e+4)},e.prototype._splitNullSeparatedAsciiString=function(e){var t,r,n,i,a;for(n=[],r=0,i=0,a=e.length;a>i;i++)t=e[i],"\x00"!==t?(null==n[r]&&(n[r]=""),n[r]+=t):r++;return n},e.prototype._typeSizes={1:1,2:1,3:2,4:4,5:8,7:1,9:4,10:8},e.prototype._tagTypes={BYTE:1,ASCII:2,SHORT:3,LONG:4,RATIONAL:5,UNDEFINED:7,SLONG:9,SRATIONAL:10},e.prototype._tagNames={"0th":{256:"ImageWidth",257:"ImageLength",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",270:"ImageDescription",271:"Make",272:"Model",273:"StripOffsets",274:{name:"Orientation",description:function(e){switch(e){case 1:return"top-left";case 2:return"top-right";case 3:return"bottom-right";case 4:return"bottom-left";case 5:return"left-top";case 6:return"right-top";case 7:return"right-bottom";case 8:return"left-bottom";default:return"Undefined"}}},277:"SamplesPerPixel",278:"RowsPerStrip",279:"StripByteCounts",282:"XResolution",283:"YResolution",284:"PlanarConfiguration",296:{name:"ResolutionUnit",description:function(e){switch(e){case 2:return"inches";case 3:return"centimeters";default:return"Unknown"}}},301:"TransferFunction",305:"Software",306:"DateTime",315:"Artist",318:"WhitePoint",319:"PrimaryChromaticities",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",529:"YCbCrCoefficients",530:"YCbCrSubSampling",531:{name:"YCbCrPositioning",description:function(e){switch(e){case 1:return"centered";case 2:return"co-sited";default:return"undefied "+e}}},532:"ReferenceBlackWhite",33432:{name:"Copyright",description:function(e){return e.join("; ")}},34665:"Exif IFD Pointer",34853:"GPS Info IFD Pointer"},exif:{33434:"ExposureTime",33437:"FNumber",34850:{name:"ExposureProgram",description:function(e){switch(e){case 0:return"Undefined";case 1:return"Manual";case 2:return"Normal program";case 3:return"Aperture priority";case 4:return"Shutter priority";case 5:return"Creative program";case 6:return"Action program";case 7:return"Portrait mode";case 8:return"Landscape mode";default:return"Unknown"}}},34852:"SpectralSensitivity",34855:"ISOSpeedRatings",34856:{name:"OECF",description:function(e){return"[Raw OECF table data]"}},36864:{name:"ExifVersion",description:function(e){var t,r,n,i;for(r="",n=0,i=e.length;i>n;n++)t=e[n],r+=String.fromCharCode(t);return r}},36867:"DateTimeOriginal",36868:"DateTimeDigitized",37121:{name:"ComponentsConfiguration",description:function(e){var t,r,n,i;for(r="",n=0,i=e.length;i>n;n++)switch(t=e[n]){case 49:r+="Y";break;case 50:r+="Cb";break;case 51:r+="Cr";break;case 52:r+="R";break;case 53:r+="G";break;case 54:r+="B"}return r}},37122:"CompressedBitsPerPixel",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBiasValue",37381:"MaxApertureValue",37382:"SubjectDistance",37383:{name:"MeteringMode",description:function(e){switch(e){case 1:return"Average";case 2:return"CenterWeightedAverage";case 3:return"Spot";case 4:return"MultiSpot";case 5:return"Pattern";case 6:return"Partial";case 255:return"Other";default:return"Unknown"}}},37384:{name:"LightSource",description:function(e){switch(e){case 1:return"Daylight";case 2:return"Fluorescent";case 3:return"Tungsten (incandescent light)";case 4:return"Flash";case 9:return"Fine weather";case 10:return"Cloudy weather";case 11:return"Shade";case 12:return"Daylight fluorescent (D 5700 – 7100K)";case 13:return"Day white fluorescent (N 4600 – 5400K)";case 14:return"Cool white fluorescent (W 3900 – 4500K)";case 15:return"White fluorescent (WW 3200 – 3700K)";case 17:return"Standard light A";case 18:return"Standard light B";case 19:return"Standard light C";case 20:return"D55";case 21:return"D65";case 22:return"D75";case 23:return"D50";case 24:return"ISO studio tungsten";case 255:return"Other light source";default:return"Unknown"}}},37385:{name:"Flash",description:function(e){switch(e){case 0:return"Flash did not fire";case 1:return"Flash fired";case 5:return"Strobe return light not detected";case 7:return"Strobe return light detected";case 9:return"Flash fired, compulsory flash mode";case 13:return"Flash fired, compulsory flash mode, return light not detected";case 15:return"Flash fired, compulsory flash mode, return light detected";case 16:return"Flash did not fire, compulsory flash mode";case 24:return"Flash did not fire, auto mode";case 25:return"Flash fired, auto mode";case 29:return"Flash fired, auto mode, return light not detected";case 31:return"Flash fired, auto mode, return light detected";case 32:return"No flash function";case 65:return"Flash fired, red-eye reduction mode";case 69:return"Flash fired, red-eye reduction mode, return light not detected";case 71:return"Flash fired, red-eye reduction mode, return light detected";case 73:return"Flash fired, compulsory flash mode, red-eye reduction mode";case 77:return"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected";case 79:return"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected";case 89:return"Flash fired, auto mode, red-eye reduction mode";case 93:return"Flash fired, auto mode, return light not detected, red-eye reduction mode";case 95:return"Flash fired, auto mode, return light detected, red-eye reduction mode";default:return"Unknown"}}},37386:"FocalLength",37396:{name:"SubjectArea",description:function(e){switch(e.length){case 2:return"Location; X: "+e[0]+", Y: "+e[1];case 3:return"Circle; X: "+e[0]+", Y: "+e[1]+", diameter: "+e[2];case 4:return"Rectangle; X: "+e[0]+", Y: "+e[1]+", width: "+e[2]+", height: "+e[3];default:return"Unknown"}}},37500:{name:"MakerNote",description:function(e){return"[Raw maker note data]"}},37510:{name:"UserComment",description:function(e){switch(e.slice(0,8).map(function(e){return String.fromCharCode(e)}).join("")){case"ASCII\x00\x00\x00":return e.slice(8,e.length).map(function(e){return String.fromCharCode(e)}).join("");case"JIS\x00\x00\x00\x00\x00":return"[JIS encoded text]";case"UNICODE\x00":return"[Unicode encoded text]";case"\x00\x00\x00\x00\x00\x00\x00\x00":return"[Undefined encoding]"}}},37520:"SubSecTime",37521:"SubSecTimeOriginal",37522:"SubSecTimeDigitized",40960:{name:"FlashpixVersion",description:function(e){var t,r,n,i;for(r="",n=0,i=e.length;i>n;n++)t=e[n],r+=String.fromCharCode(t);return r}},40961:{name:"ColorSpace",description:function(e){switch(e){case 1:return"sRGB";case 65535:return"Uncalibrated";default:return"Unknown"}}},40962:"PixelXDimension",40963:"PixelYDimension",40964:"RelatedSoundFile",40965:"Interoperability IFD Pointer",41483:"FlashEnergy",41484:{name:"SpatialFrequencyResponse",description:function(e){return"[Raw SFR table data]"}},41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:{name:"FocalPlaneResolutionUnit",description:function(e){switch(e){case 2:return"inches";case 3:return"centimeters";default:return"Unknown"}}},41492:{name:"SubjectLocation",description:function(e){return"X: "+e[0]+", Y: "+e[1]}},41493:"ExposureIndex",41495:{name:"SensingMethod",description:function(e){switch(e){case 1:return"Undefined";case 2:return"One-chip color area sensor";case 3:return"Two-chip color area sensor";case 4:return"Three-chip color area sensor";case 5:return"Color sequential area sensor";case 7:return"Trilinear sensor";case 8:return"Color sequential linear sensor";default:return"Unknown"}}},41728:{name:"FileSource",description:function(e){switch(e){case 3:return"DSC";default:return"Unknown"}}},41729:{name:"SceneType",description:function(e){switch(e){case 1:return"A directly photographed image";default:return"Unknown"}}},41730:{name:"CFAPattern",description:function(e){return"[Raw CFA pattern table data]"}},41985:{name:"CustomRendered",description:function(e){switch(e){case 0:return"Normal process";case 1:return"Custom process";default:return"Unknown"}}},41986:{name:"ExposureMode",description:function(e){switch(e){case 0:return"Auto exposure";case 1:return"Manual exposure";case 2:return"Auto bracket";default:return"Unknown"}}},41987:{name:"WhiteBalance",description:function(e){switch(e){case 0:return"Auto white balance";case 1:return"Manual white balance";default:return"Unknown"}}},41988:{name:"DigitalZoomRatio",description:function(e){switch(e){case 0:return"Digital zoom was not used";default:return e}}},41989:{name:"FocalLengthIn35mmFilm",description:function(e){switch(e){case 0:return"Unknown";default:return e}}},41990:{name:"SceneCaptureType",description:function(e){switch(e){case 0:return"Standard";case 1:return"Landscape";case 2:return"Portrait";case 3:return"Night scene";default:return"Unknown"}}},41991:{name:"GainControl",description:function(e){switch(e){case 0:return"None";case 1:return"Low gain up";case 2:return"High gain up";case 3:return"Low gain down";case 4:return"High gain down";default:return"Unknown"}}},41992:{name:"Contrast",description:function(e){switch(e){case 0:return"Normal";case 1:return"Soft";case 2:return"Hard";default:return"Unknown"}}},41993:{name:"Saturation",description:function(e){switch(e){case 0:return"Normal";case 1:return"Low saturation";case 2:return"High saturation";default:return"Unknown"}}},41994:{name:"Sharpness",description:function(e){switch(e){case 0:return"Normal";case 1:return"Soft";case 2:return"Hard";default:return"Unknown"}}},41995:{name:"DeviceSettingDescription",description:function(e){return"[Raw device settings table data]"}},41996:{name:"SubjectDistanceRange",description:function(e){switch(e){case 1:return"Macro";case 2:return"Close view";case 3:return"Distant view";default:return"Unknown"}}},42016:"ImageUniqueID"},gps:{0:{name:"GPSVersionID",description:function(e){var t,r;return e[0]===(t=e[1])&&2===t&&e[2]===(r=e[3])&&0===r?"Version 2.2":"Unknown"}},1:{name:"GPSLatitudeRef",description:function(e){switch(e.join("")){case"N":return"North latitude";case"S":return"South latitude";default:return"Unknown"}}},2:{name:"GPSLatitude",description:function(e){return e[0]+e[1]/60+e[2]/3600}},3:{name:"GPSLongitudeRef",description:function(e){switch(e.join("")){case"E":return"East longitude";case"W":return"West longitude";default:return"Unknown"}}},4:{name:"GPSLongitude",description:function(e){return e[0]+e[1]/60+e[2]/3600}},5:{name:"GPSAltitudeRef",description:function(e){switch(e){case 0:return"Sea level";case 1:return"Sea level reference (negative value)";default:return"Unknown"}}},6:{name:"GPSAltitude",description:function(e){return e+" m"}},7:{name:"GPSTimeStamp",description:function(e){var t;return t=function(e){var t;return function(){var r,n,i;for(i=[],t=r=0,n=2-(""+Math.floor(e)).length;n>=0?n>r:r>n;t=n>=0?++r:--r)i.push("0");return i}()+e},e.map(t).join(":")}},8:"GPSSatellites",9:{name:"GPSStatus",description:function(e){switch(e.join("")){case"A":return"Measurement in progress";case"V":return"Measurement Interoperability";default:return"Unknown"}}},10:{name:"GPSMeasureMode",description:function(e){switch(e.join("")){case"2":return"2-dimensional measurement";case"3":return"3-dimensional measurement";default:return"Unknown"}}},11:"GPSDOP",12:{name:"GPSSpeedRef",description:function(e){switch(e.join("")){case"K":return"Kilometers per hour";case"M":return"Miles per hour";case"N":return"Knots";default:return"Unknown"}}},13:"GPSSpeed",14:{name:"GPSTrackRef",description:function(e){switch(e.join("")){case"T":return"True direction";case"M":return"Magnetic direction";default:return"Unknown"}}},15:"GPSTrack",16:{name:"GPSImgDirectionRef",description:function(e){switch(e.join("")){case"T":return"True direction";case"M":return"Magnetic direction";default:return"Unknown"}}},17:"GPSImgDirection",18:"GPSMapDatum",19:{name:"GPSDestLatitudeRef",description:function(e){switch(e.join("")){case"N":return"North latitude";case"S":return"South latitude";default:return"Unknown"}}},20:{name:"GPSDestLatitude",description:function(e){return e[0]+e[1]/60+e[2]/3600}},21:{name:"GPSDestLongitudeRef",description:function(e){switch(e.join("")){case"E":return"East longitude";case"W":return"West longitude";default:return"Unknown"}}},22:{name:"GPSDestLongitude",description:function(e){return e[0]+e[1]/60+e[2]/3600}},23:{name:"GPSDestBearingRef",description:function(e){switch(e.join("")){case"T":return"True direction";case"M":return"Magnetic direction";default:return"Unknown"}}},24:"GPSDestBearing",25:{name:"GPSDestDistanceRef",description:function(e){switch(e.join("")){case"K":return"Kilometers";case"M":return"Miles";case"N":return"Knots";default:return"Unknown"}}},26:"GPSDestDistance",27:{name:"GPSProcessingMethod",description:function(e){if(0===e)return"Undefined";switch(e.slice(0,8).map(function(e){return String.fromCharCode(e)}).join("")){case"ASCII\x00\x00\x00":return e.slice(8,e.length).map(function(e){return String.fromCharCode(e)}).join("");case"JIS\x00\x00\x00\x00\x00":return"[JIS encoded text]";case"UNICODE\x00":return"[Unicode encoded text]";case"\x00\x00\x00\x00\x00\x00\x00\x00":return"[Undefined encoding]"}}},28:{name:"GPSAreaInformation",description:function(e){if(0===e)return"Undefined";switch(e.slice(0,8).map(function(e){return String.fromCharCode(e)}).join("")){case"ASCII\x00\x00\x00":return e.slice(8,e.length).map(function(e){return String.fromCharCode(e)}).join("");case"JIS\x00\x00\x00\x00\x00":return"[JIS encoded text]";case"UNICODE\x00":return"[Unicode encoded text]";case"\x00\x00\x00\x00\x00\x00\x00\x00":return"[Undefined encoding]"}}},29:"GPSDateStamp",30:{name:"GPSDifferential",description:function(e){switch(e){case 0:return"Measurement without differential correction";case 1:return"Differential correction applied";default:return"Unknown"}}}},interoperability:{1:"InteroperabilityIndex",2:"UnknownInteroperabilityTag0x0002",4097:"UnknownInteroperabilityTag0x1001",4098:"UnknownInteroperabilityTag0x1002"}},e.prototype.getTagValue=function(e){return null!=this._tags[e]?this._tags[e].value:void 0},e.prototype.getTagDescription=function(e){return null!=this._tags[e]?this._tags[e].description:void 0},e.prototype.getAllTags=function(){return this._tags},e.prototype.deleteTag=function(e){return delete this._tags[e]},e}()}).call(this)},{}],3:[function(e,t,r){function n(e){function t(e){for(var t=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],r=0;64>r;r++){var n=E((t[r]*e+50)/100);1>n?n=1:n>255&&(n=255),S[N[r]]=n}for(var i=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],a=0;64>a;a++){var o=E((i[a]*e+50)/100);1>o?o=1:o>255&&(o=255),A[N[a]]=o}for(var s=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],u=0,c=0;8>c;c++)for(var f=0;8>f;f++)I[u]=1/(S[N[u]]*s[c]*s[f]*8),R[u]=1/(A[N[u]]*s[c]*s[f]*8),u++}function r(e,t){for(var r=0,n=0,i=new Array,a=1;16>=a;a++){for(var o=1;o<=e[a];o++)i[t[n]]=[],i[t[n]][0]=r,i[t[n]][1]=a,n++,r++;r*=2}return i}function n(){b=r(Z,q),y=r(Y,W),w=r(G,H),x=r(V,X)}function i(){for(var e=1,t=2,r=1;15>=r;r++){for(var n=e;t>n;n++)T[32767+n]=r,P[32767+n]=[],P[32767+n][1]=r,P[32767+n][0]=n;for(var i=-(t-1);-e>=i;i++)T[32767+i]=r,P[32767+i]=[],P[32767+i][1]=r,P[32767+i][0]=t-1+i;e<<=1,t<<=1}}function a(){for(var e=0;256>e;e++)j[e]=19595*e,j[e+256>>0]=38470*e,j[e+512>>0]=7471*e+32768,j[e+768>>0]=-11059*e,j[e+1024>>0]=-21709*e,j[e+1280>>0]=32768*e+8421375,j[e+1536>>0]=-27439*e,j[e+1792>>0]=-5329*e}function o(e){for(var t=e[0],r=e[1]-1;r>=0;)t&1<D&&(255==O?(s(255),s(0)):s(O),D=7,O=0)}function s(e){C.push(e)}function u(e){s(e>>8&255),s(255&e)}function c(e,t){var r,n,i,a,o,s,u,c,f,l=0,h=8,d=64;for(f=0;h>f;++f){r=e[l],n=e[l+1],i=e[l+2],a=e[l+3],o=e[l+4],s=e[l+5],u=e[l+6],c=e[l+7];var p=r+c,g=r-c,m=n+u,v=n-u,_=i+s,b=i-s,y=a+o,w=a-o,x=p+y,k=p-y,E=m+_,S=m-_;e[l]=x+E,e[l+4]=x-E;var A=.707106781*(S+k);e[l+2]=k+A,e[l+6]=k-A,x=w+b,E=b+v,S=v+g;var I=.382683433*(x-S),R=.5411961*x+I,P=1.306562965*S+I,T=.707106781*E,M=g+T,C=g-T;e[l+5]=C+R,e[l+3]=C-R,e[l+1]=M+P,e[l+7]=M-P,l+=8}for(l=0,f=0;h>f;++f){r=e[l],n=e[l+8],i=e[l+16],a=e[l+24],o=e[l+32],s=e[l+40],u=e[l+48],c=e[l+56];var O=r+c,D=r-c,U=n+u,B=n-u,z=i+s,F=i-s,j=a+o,N=a-o,Z=O+j,q=O-j,G=U+z,H=U-z;e[l]=Z+G,e[l+32]=Z-G;var Y=.707106781*(H+q);e[l+16]=q+Y,e[l+48]=q-Y,Z=N+F,G=F+B,H=B+D;var W=.382683433*(Z-H),V=.5411961*Z+W,X=1.306562965*H+W,J=.707106781*G,K=D+J,$=D-J;e[l+40]=$+V,e[l+24]=$-V,e[l+8]=K+X,e[l+56]=K-X,l++}var Q;for(f=0;d>f;++f)Q=e[f]*t[f],L[f]=Q>0?Q+.5|0:Q-.5|0;return L}function f(){u(65504),u(16),s(74),s(70),s(73),s(70),s(0),s(1),s(1),s(0),u(1),u(1),s(0),s(0)}function l(e,t){u(65472),u(17),s(8),u(t),u(e),s(3),s(1),s(17),s(0),s(2),s(17),s(1),s(3),s(17),s(1)}function h(){u(65499),u(132),s(0);for(var e=0;64>e;e++)s(S[e]);s(1);for(var t=0;64>t;t++)s(A[t])}function d(){u(65476),u(418),s(0);for(var e=0;16>e;e++)s(Z[e+1]);for(var t=0;11>=t;t++)s(q[t]);s(16);for(var r=0;16>r;r++)s(G[r+1]);for(var n=0;161>=n;n++)s(H[n]);s(1);for(var i=0;16>i;i++)s(Y[i+1]);for(var a=0;11>=a;a++)s(W[a]);s(17);for(var o=0;16>o;o++)s(V[o+1]);for(var c=0;161>=c;c++)s(X[c])}function p(){u(65498),u(12),s(3),s(1),s(0),s(2),s(17),s(3),s(17),s(0),s(63),s(0)}function g(e,t,r,n,i){for(var a,s=i[0],u=i[240],f=16,l=63,h=64,d=c(e,t),p=0;h>p;++p)M[N[p]]=d[p];var g=M[0]-r;r=M[0],0==g?o(n[0]):(a=32767+g,o(n[T[a]]),o(P[a]));for(var m=63;m>0&&0==M[m];m--);if(0==m)return o(s),r;for(var v,_=1;m>=_;){for(var b=_;0==M[_]&&m>=_;++_);var y=_-b;if(y>=f){v=y>>4;for(var w=1;v>=w;++w)o(u);y=15&y}a=32767+M[_],o(i[(y<<4)+T[a]]),o(P[a]),_++}return m!=l&&o(s),r}function m(){for(var e=String.fromCharCode,t=0;256>t;t++)F[t]=e(t)}function v(e){if(0>=e&&(e=1),e>100&&(e=100),k!=e){var r=0;r=50>e?Math.floor(5e3/e):Math.floor(200-2*e),t(r),k=e}}function _(){var t=(new Date).getTime();e||(e=50),m(),n(),i(),a(),v(e);(new Date).getTime()-t}var b,y,w,x,k,E=(Math.round,Math.floor),S=new Array(64),A=new Array(64),I=new Array(64),R=new Array(64),P=new Array(65535),T=new Array(65535),L=new Array(64),M=new Array(64),C=[],O=0,D=7,U=new Array(64),B=new Array(64),z=new Array(64),F=new Array(256),j=new Array(2048),N=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],Z=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],q=[0,1,2,3,4,5,6,7,8,9,10,11],G=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],H=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],Y=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],W=[0,1,2,3,4,5,6,7,8,9,10,11],V=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],X=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];this.encode=function(e,t){(new Date).getTime();t&&v(t),C=new Array,O=0,D=7,u(65496),f(),h(),l(e.width,e.height),d(),p();var r=0,n=0,i=0;O=0,D=7,this.encode.displayName="_encode_";for(var a,s,c,m,_,k,E,S,A,P=e.data,T=e.width,L=e.height,M=4*T,F=0;L>F;){for(a=0;M>a;){for(_=M*F+a,k=_,E=-1,S=0,A=0;64>A;A++)S=A>>3,E=4*(7&A),k=_+S*M+E,F+S>=L&&(k-=M*(F+1+S-L)),a+E>=M&&(k-=a+E-M+4),s=P[k++],c=P[k++],m=P[k++],U[A]=(j[s]+j[c+256>>0]+j[m+512>>0]>>16)-128,B[A]=(j[s+768>>0]+j[c+1024>>0]+j[m+1280>>0]>>16)-128,z[A]=(j[s+1280>>0]+j[c+1536>>0]+j[m+1792>>0]>>16)-128;r=g(U,I,r,b,w),n=g(B,R,n,y,x),i=g(z,R,i,y,x),a+=32}F+=8}if(D>=0){var N=[];N[1]=D+1,N[0]=(1<=0;a--)i[a]=n.charCodeAt(a);return void t(i.buffer)}var o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="arraybuffer",o.onload=function(){t(o.response)},o.send(null)}var i=function(){function e(){this._src=null,this._parser=new a.JpegImage,this.onload=null}return e.prototype={get src(){return this._src},set src(e){this.load(e)},get width(){return this._parser.width},get height(){return this._parser.height},load:function(e){this._src=e,n(e,function(e){this.parse(new Uint8Array(e)),this.onload&&this.onload()}.bind(this))},parse:function(e){this._parser.parse(e)},getData:function(e,t){return this._parser.getData(e,t,!1)},copyToImageData:function(e){if(2===this._parser.numComponents||this._parser.numComponents>4)throw new Error("Unsupported amount of components");var t,r,n=e.width,i=e.height,a=n*i*4,o=e.data;if(1!==this._parser.numComponents){var s=this._parser.getData(n,i,!0);for(t=0,r=0;a>t;)o[t++]=s[r++],o[t++]=s[r++],o[t++]=s[r++],o[t++]=255}else{var u=this._parser.getData(n,i,!1);for(t=0,r=0;a>t;){var c=u[r++];o[t++]=c,o[t++]=c,o[t++]=c,o[t++]=255}}}},e}();t.exports={JpegImage:i,JpegDecoder:o,JpxDecoder:s,Jbig2Decoder:u};var a;!function(e){"use strict";function t(e){for(var t=1,r=0;e>t;)t<<=1,r++;return r}function r(e,t){return e[t]<<24>>24}function n(e,t){return e[t]<<8|e[t+1]}function i(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!1}),r}var o=function(){function e(){}function t(e,t){for(var r,n,i=0,a=[],o=16;o>0&&!e[o-1];)o--;a.push({children:[],index:0});var s,u=a[0];for(r=0;o>r;r++){for(n=0;n0;)u=a.pop();for(u.index++,a.push(u);a.length<=r;)a.push(s={children:[],index:0}),u.children[u.index]=s.children,u=s;i++}o>r+1&&(a.push(s={children:[],index:0}),u.children[u.index]=s.children,u=s)}return a[0].children}function r(e,t,r){return 64*((e.blocksPerLine+1)*t+r)}function n(e,t,n,i,a,o,u,c,f){function l(){if(C>0)return C--,M>>C&1;if(M=e[t++],255===M){var r=e[t++];if(r)throw"unexpected marker: "+(M<<8|r).toString(16)}return C=7,M>>>7}function h(e){for(var t=e;;){if(t=t[l()],"number"==typeof t)return t;if("object"!=typeof t)throw"invalid huffman sequence"}}function d(e){for(var t=0;e>0;)t=t<<1|l(),e--;return t}function p(e){if(1===e)return 1===l()?1:-1;var t=d(e);return t>=1<i;){var a=h(e.huffmanTableAC),o=15&a,u=a>>4;if(0!==o){i+=u;var c=s[i];e.blockData[t+c]=p(o),i++}else{if(15>u)break;i+=16}}}function m(e,t){var r=h(e.huffmanTableDC),n=0===r?0:p(r)<0)return void O--;for(var r=o,n=u;n>=r;){var i=h(e.huffmanTableAC),a=15&i,c=i>>4;if(0!==a){r+=c;var l=s[r];e.blockData[t+l]=p(a)*(1<c){O=d(c)+(1<=i;){var g=s[i];switch(D){case 0:if(n=h(e.huffmanTableAC),r=15&n,c=n>>4,0===r)15>c?(O=d(c)+(1<F;){for(E=0;U>E;E++)i[E].pred=0;if(O=0,1===U)for(k=i[0],I=0;a>I;I++)w(k,R,F),F++;else for(I=0;a>I;I++){for(E=0;U>E;E++)for(k=i[E],j=k.h,N=k.v,S=0;N>S;S++)for(A=0;j>A;A++)y(k,R,F,S,A);F++}if(C=0,B=e[t]<<8|e[t+1],65280>=B)throw"marker was not found";if(!(B>=65488&&65495>=B))break;t+=2}return t-L}function i(e,t,r){for(var n,i,a,o,s,m,v,_,b,y,w,x,k,E,S,A,I,R=e.quantizationTable,P=e.blockData,T=0;64>T;T+=8)b=P[t+T],y=P[t+T+1],w=P[t+T+2],x=P[t+T+3],k=P[t+T+4],E=P[t+T+5],S=P[t+T+6],A=P[t+T+7],b*=R[T],0!==(y|w|x|k|E|S|A)?(y*=R[T+1],w*=R[T+2],x*=R[T+3],k*=R[T+4],E*=R[T+5],S*=R[T+6],A*=R[T+7],n=p*b+128>>8,i=p*k+128>>8,a=w,o=S,s=g*(y-A)+128>>8,_=g*(y+A)+128>>8,m=x<<4,v=E<<4,n=n+i+1>>1,i=n-i,I=a*d+o*h+128>>8,a=a*h-o*d+128>>8,o=I,s=s+v+1>>1,v=s-v,_=_+m+1>>1,m=_-m,n=n+o+1>>1,o=n-o,i=i+a+1>>1,a=i-a,I=s*l+_*f+2048>>12,s=s*f-_*l+2048>>12,_=I,I=m*c+v*u+2048>>12,m=m*u-v*c+2048>>12,v=I,r[T]=n+_,r[T+7]=n-_,r[T+1]=i+v,r[T+6]=i-v,r[T+2]=a+m,r[T+5]=a-m,r[T+3]=o+s,r[T+4]=o-s):(I=p*b+512>>10,r[T]=I,r[T+1]=I,r[T+2]=I,r[T+3]=I,r[T+4]=I,r[T+5]=I,r[T+6]=I,r[T+7]=I);for(var L=0;8>L;++L)b=r[L],y=r[L+8],w=r[L+16],x=r[L+24],k=r[L+32],E=r[L+40],S=r[L+48],A=r[L+56],0!==(y|w|x|k|E|S|A)?(n=p*b+2048>>12,i=p*k+2048>>12,a=w,o=S,s=g*(y-A)+2048>>12,_=g*(y+A)+2048>>12,m=x,v=E,n=(n+i+1>>1)+4112,i=n-i,I=a*d+o*h+2048>>12,a=a*h-o*d+2048>>12,o=I,s=s+v+1>>1,v=s-v,_=_+m+1>>1,m=_-m,n=n+o+1>>1,o=n-o,i=i+a+1>>1,a=i-a,I=s*l+_*f+2048>>12,s=s*f-_*l+2048>>12,_=I,I=m*c+v*u+2048>>12,m=m*u-v*c+2048>>12,v=I,b=n+_,A=n-_,y=i+v,S=i-v,w=a+m,E=a-m,x=o+s,k=o-s,b=16>b?0:b>=4080?255:b>>4,y=16>y?0:y>=4080?255:y>>4,w=16>w?0:w>=4080?255:w>>4,x=16>x?0:x>=4080?255:x>>4,k=16>k?0:k>=4080?255:k>>4,E=16>E?0:E>=4080?255:E>>4,S=16>S?0:S>=4080?255:S>>4,A=16>A?0:A>=4080?255:A>>4,P[t+L]=b,P[t+L+8]=y,P[t+L+16]=w,P[t+L+24]=x,P[t+L+32]=k,P[t+L+40]=E,P[t+L+48]=S,P[t+L+56]=A):(I=p*b+8192>>14,I=-2040>I?0:I>=2024?255:I+2056>>4,P[t+L]=I,P[t+L+8]=I,P[t+L+16]=I,P[t+L+24]=I,P[t+L+32]=I,P[t+L+40]=I,P[t+L+48]=I,P[t+L+56]=I)}function a(e,t){for(var n=t.blocksPerLine,a=t.blocksPerColumn,o=new Int16Array(64),s=0;a>s;s++)for(var u=0;n>u;u++){var c=r(t,s,u);i(t,c,o)}return t.blockData}function o(e){return 0>=e?0:e>=255?255:e}var s=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),u=4017,c=799,f=3406,l=2276,h=1567,d=3784,p=5793,g=2896;return e.prototype={parse:function(e){function r(){var t=e[f]<<8|e[f+1];return f+=2,t}function i(){var t=r(),n=e.subarray(f,f+t-2);return f+=n.length,n}function o(e){for(var t=Math.ceil(e.samplesPerLine/8/e.maxH),r=Math.ceil(e.scanLines/8/e.maxV),n=0;nf;){var E=e[f++],S=new Uint16Array(64);if(E>>4===0)for(_=0;64>_;_++)w=s[_],S[w]=e[f++];else{if(E>>4!==1)throw"DQT: invalid table spec";for(_=0;64>_;_++)w=s[_],S[w]=r()}d[15&E]=S}break;case 65472:case 65473:case 65474:if(u)throw"Only single frame JPEGs supported";r(),u={},u.extended=65473===m,u.progressive=65474===m,u.precision=e[f++],u.scanLines=r(),u.samplesPerLine=r(),u.components=[],u.componentIds={};var A,I=e[f++],R=0,P=0;for(v=0;I>v;v++){A=e[f];var T=e[f+1]>>4,L=15&e[f+1];T>R&&(R=T),L>P&&(P=L);var M=e[f+2];b=u.components.push({h:T,v:L,quantizationTable:d[M]}),u.componentIds[A]=b-1,f+=3}u.maxH=R,u.maxV=P,o(u);break;case 65476:var C=r();for(v=2;C>v;){var O=e[f++],D=new Uint8Array(16),U=0;for(_=0;16>_;_++,f++)U+=D[_]=e[f];var B=new Uint8Array(U);for(_=0;U>_;_++,f++)B[_]=e[f];v+=17+U,(O>>4===0?g:p)[15&O]=t(D,B)}break;case 65501:r(),c=r();break;case 65498:var z,F=(r(),e[f++]),j=[];for(v=0;F>v;v++){var N=u.componentIds[e[f++]];z=u.components[N];var Z=e[f++];z.huffmanTableDC=g[Z>>4],z.huffmanTableAC=p[15&Z],j.push(z)}var q=e[f++],G=e[f++],H=e[f++],Y=n(e,f,u,j,c,q,G,H>>4,15&H);f+=Y;break;case 65535:255!==e[f]&&f--;break;default:if(255===e[f-3]&&e[f-2]>=192&&e[f-2]<=254){f-=3;break}throw"unknown JPEG marker "+m.toString(16)}m=r()}for(this.width=u.samplesPerLine,this.height=u.scanLines,this.jfif=l,this.adobe=h,this.components=[],v=0;vu;u++){for(r=this.components[u],n=r.scaleX*d,i=r.scaleY*p,g=u,h=r.output,a=r.blocksPerLine+1<<3,o=0;e>o;o++)c=0|o*n,b[o]=(c&y)<<3|7&c;for(s=0;t>s;s++)for(c=0|s*i,l=a*(c&y)|(7&c)<<3,o=0;e>o;o++)_[g]=h[l+b[o]],g+=m}var w=this.decodeTransform;if(w)for(u=0;v>u;)for(c=0,f=0;m>c;c++,u++,f+=2)_[u]=(_[u]*w[f]>>8)+w[f+1];return _},_isColorConversionNeeded:function(){return this.adobe&&this.adobe.transformCode?!0:3===this.numComponents},_convertYccToRgb:function(e){for(var t,r,n,i=0,a=e.length;a>i;i+=3)t=e[i],r=e[i+1],n=e[i+2],e[i]=o(t-179.456+1.402*n),e[i+1]=o(t+135.459-.344*r-.714*n),e[i+2]=o(t-226.816+1.772*r);return e},_convertYcckToRgb:function(e){for(var t,r,n,i,a=0,s=0,u=e.length;u>s;s+=4){t=e[s],r=e[s+1],n=e[s+2],i=e[s+3];var c=-122.67195406894+r*(-660635669420364e-19*r+.000437130475926232*n-54080610064599e-18*t+.00048449797120281*i-.154362151871126)+n*(-.000957964378445773*n+.000817076911346625*t-.00477271405408747*i+1.53380253221734)+t*(.000961250184130688*t-.00266257332283933*i+.48357088451265)+i*(-.000336197177618394*i+.484791561490776),f=107.268039397724+r*(219927104525741e-19*r-.000640992018297945*n+.000659397001245577*t+.000426105652938837*i-.176491792462875)+n*(-.000778269941513683*n+.00130872261408275*t+.000770482631801132*i-.151051492775562)+t*(.00126935368114843*t-.00265090189010898*i+.25802910206845)+i*(-.000318913117588328*i-.213742400323665),l=-20.810012546947+r*(-.000570115196973677*r-263409051004589e-19*n+.0020741088115012*t-.00288260236853442*i+.814272968359295)+n*(-153496057440975e-19*n-.000132689043961446*t+.000560833691242812*i-.195152027534049)+t*(.00174418132927582*t-.00255243321439347*i+.116935020465145)+i*(-.000343531996510555*i+.24165260232407);e[a++]=o(c),e[a++]=o(f),e[a++]=o(l)}return e},_convertYcckToCmyk:function(e){for(var t,r,n,i=0,a=e.length;a>i;i+=4)t=e[i],r=e[i+1],n=e[i+2],e[i]=o(434.456-t-1.402*n),e[i+1]=o(119.541-t+.344*r+.714*n),e[i+2]=o(481.816-t-1.772*r);return e},_convertCmykToRgb:function(e){for(var t,r,n,i,a=0,o=-16581375,s=1/255/255,u=0,c=e.length;c>u;u+=4){t=e[u],r=e[u+1],n=e[u+2],i=e[u+3];var f=t*(-4.387332384609988*t+54.48615194189176*r+18.82290502165302*n+212.25662451639585*i-72734.4411664936)+r*(1.7149763477362134*r-5.6096736904047315*n-17.873870861415444*i-1401.7366389350734)+n*(-2.5217340131683033*n-21.248923337353073*i+4465.541406466231)-i*(21.86122147463605*i+48317.86113160301),l=t*(8.841041422036149*t+60.118027045597366*r+6.871425592049007*n+31.159100130055922*i-20220.756542821975)+r*(-15.310361306967817*r+17.575251261109482*n+131.35250912493976*i-48691.05921601825)+n*(4.444339102852739*n+9.8632861493405*i-6341.191035517494)-i*(20.737325471181034*i+47890.15695978492),h=t*(.8842522430003296*t+8.078677503112928*r+30.89978309703729*n-.23883238689178934*i-3616.812083916688)+r*(10.49593273432072*r+63.02378494754052*n+50.606957656360734*i-28620.90484698408)+n*(.03296041114873217*n+115.60384449646641*i-49363.43385999684)-i*(22.33816807309886*i+45932.16563550634);e[a++]=f>=0?255:o>=f?0:255+f*s|0,e[a++]=l>=0?255:o>=l?0:255+l*s|0,e[a++]=h>=0?255:o>=h?0:255+h*s|0}return e},getData:function(e,t,r){if(this.numComponents>4)throw"Unsupported color mode";var n=this._getLinearizedBlockData(e,t);if(3===this.numComponents)return this._convertYccToRgb(n);if(4===this.numComponents){if(this._isColorConversionNeeded())return r?this._convertYcckToRgb(n):this._convertYcckToCmyk(n);if(r)return this._convertCmykToRgb(n)}return n}},e}(),s=function(){function e(e,t,r){this.data=e,this.bp=t,this.dataEnd=r,this.chigh=e[t],this.clow=0,this.byteIn(),this.chigh=this.chigh<<7&65535|this.clow>>9&127,this.clow=this.clow<<7&65535,this.ct-=7,this.a=32768}var t=[{qe:22017,nmps:1,nlps:1,switchFlag:1},{qe:13313,nmps:2,nlps:6,switchFlag:0},{qe:6145,nmps:3,nlps:9,switchFlag:0},{qe:2753,nmps:4,nlps:12,switchFlag:0},{qe:1313,nmps:5,nlps:29,switchFlag:0},{qe:545,nmps:38,nlps:33,switchFlag:0},{qe:22017,nmps:7,nlps:6,switchFlag:1},{qe:21505,nmps:8,nlps:14,switchFlag:0},{qe:18433,nmps:9,nlps:14,switchFlag:0},{qe:14337,nmps:10,nlps:14,switchFlag:0},{qe:12289,nmps:11,nlps:17,switchFlag:0},{qe:9217,nmps:12,nlps:18,switchFlag:0},{qe:7169,nmps:13,nlps:20,switchFlag:0},{qe:5633,nmps:29,nlps:21,switchFlag:0},{qe:22017,nmps:15,nlps:14,switchFlag:1},{qe:21505,nmps:16,nlps:14,switchFlag:0},{qe:20737,nmps:17,nlps:15,switchFlag:0},{qe:18433,nmps:18,nlps:16,switchFlag:0},{qe:14337,nmps:19,nlps:17,switchFlag:0},{qe:13313,nmps:20,nlps:18,switchFlag:0},{qe:12289,nmps:21,nlps:19,switchFlag:0},{qe:10241,nmps:22,nlps:19,switchFlag:0},{qe:9217,nmps:23,nlps:20,switchFlag:0},{qe:8705,nmps:24,nlps:21,switchFlag:0},{qe:7169,nmps:25,nlps:22,switchFlag:0},{qe:6145,nmps:26,nlps:23,switchFlag:0},{qe:5633,nmps:27,nlps:24,switchFlag:0},{qe:5121,nmps:28,nlps:25,switchFlag:0},{qe:4609,nmps:29,nlps:26,switchFlag:0},{qe:4353,nmps:30,nlps:27,switchFlag:0},{qe:2753,nmps:31,nlps:28,switchFlag:0},{qe:2497,nmps:32,nlps:29,switchFlag:0},{qe:2209,nmps:33,nlps:30,switchFlag:0},{qe:1313,nmps:34,nlps:31,switchFlag:0},{qe:1089,nmps:35,nlps:32,switchFlag:0},{qe:673,nmps:36,nlps:33,switchFlag:0},{qe:545,nmps:37,nlps:34,switchFlag:0},{qe:321,nmps:38,nlps:35,switchFlag:0},{qe:273,nmps:39,nlps:36,switchFlag:0},{qe:133,nmps:40,nlps:37,switchFlag:0},{qe:73,nmps:41,nlps:38,switchFlag:0},{qe:37,nmps:42,nlps:39,switchFlag:0},{qe:21,nmps:43,nlps:40,switchFlag:0},{qe:9,nmps:44,nlps:41,switchFlag:0},{qe:5,nmps:45,nlps:42,switchFlag:0},{qe:1,nmps:45,nlps:43,switchFlag:0},{qe:22017,nmps:46,nlps:46,switchFlag:0}];return e.prototype={byteIn:function(){var e=this.data,t=this.bp;if(255===e[t]){var r=e[t+1];r>143?(this.clow+=65280,this.ct=8):(t++,this.clow+=e[t]<<9,this.ct=7,this.bp=t)}else t++,this.clow+=t65535&&(this.chigh+=this.clow>>16,this.clow&=65535)},readBit:function(e,r){var n,i=e[r]>>1,a=1&e[r],o=t[i],s=o.qe,u=this.a-s;if(this.chighu?(u=s,n=a,i=o.nmps):(u=s,n=1^a,1===o.switchFlag&&(a=n),i=o.nlps);else{if(this.chigh-=s,0!==(32768&u))return this.a=u,a;s>u?(n=1^a,1===o.switchFlag&&(a=n),i=o.nlps):(n=a,i=o.nmps)}do 0===this.ct&&this.byteIn(),u<<=1,this.chigh=this.chigh<<1&65535|this.clow>>15&1,this.clow=this.clow<<1&65535,this.ct--;while(0===(32768&u));return this.a=u,e[r]=i<<1|a,n}},e}(),u=function(){function e(){this.failOnCorruptedImage=!1}function r(e,t){e.x0=Math.ceil(t.XOsiz/e.XRsiz),e.x1=Math.ceil(t.Xsiz/e.XRsiz),e.y0=Math.ceil(t.YOsiz/e.YRsiz),e.y1=Math.ceil(t.Ysiz/e.YRsiz),e.width=e.x1-e.x0,e.height=e.y1-e.y0}function a(e,t){for(var r,n=e.SIZ,i=[],a=Math.ceil((n.Xsiz-n.XTOsiz)/n.XTsiz),o=Math.ceil((n.Ysiz-n.YTOsiz)/n.YTsiz),s=0;o>s;s++)for(var u=0;a>u;u++)r={},r.tx0=Math.max(n.XTOsiz+u*n.XTsiz,n.XOsiz),r.ty0=Math.max(n.YTOsiz+s*n.YTsiz,n.YOsiz),r.tx1=Math.min(n.XTOsiz+(u+1)*n.XTsiz,n.Xsiz),r.ty1=Math.min(n.YTOsiz+(s+1)*n.YTsiz,n.Ysiz),r.width=r.tx1-r.tx0,r.height=r.ty1-r.ty0,r.components=[],i.push(r);e.tiles=i;for(var c=n.Csiz,f=0,l=c;l>f;f++)for(var h=t[f],d=0,p=i.length;p>d;d++){var g={};r=i[d],g.tcx0=Math.ceil(r.tx0/h.XRsiz),g.tcy0=Math.ceil(r.ty0/h.YRsiz),g.tcx1=Math.ceil(r.tx1/h.XRsiz),g.tcy1=Math.ceil(r.ty1/h.YRsiz),g.width=g.tcx1-g.tcx0,g.height=g.tcy1-g.tcy0,r.components[f]=g}}function o(e,t,r){var n=t.codingStyleParameters,i={};return n.entropyCoderWithCustomPrecincts?(i.PPx=n.precinctsSizes[r].PPx,i.PPy=n.precinctsSizes[r].PPy):(i.PPx=15,i.PPy=15),i.xcb_=r>0?Math.min(n.xcb,i.PPx-1):Math.min(n.xcb,i.PPx),i.ycb_=r>0?Math.min(n.ycb,i.PPy-1):Math.min(n.ycb,i.PPy),i}function u(e,t,r){var n=1<t.trx0?Math.ceil(t.trx1/n)-Math.floor(t.trx0/n):0,c=t.try1>t.try0?Math.ceil(t.try1/i)-Math.floor(t.try0/i):0,f=u*c;t.precinctParameters={precinctWidth:n,precinctHeight:i,numprecinctswide:u,numprecinctshigh:c,numprecincts:f,precinctWidthInSubband:o,precinctHeightInSubband:s}}function c(e,t,r){var n,i,a,o,s=r.xcb_,u=r.ycb_,c=1<>s,h=t.tby0>>u,d=t.tbx1+c-1>>s,p=t.tby1+f-1>>u,g=t.resolution.precinctParameters,m=[],v=[];for(i=h;p>i;i++)for(n=l;d>n;n++){a={cbx:n,cby:i,tbx0:c*n,tby0:f*i,tbx1:c*(n+1),tby1:f*(i+1)},a.tbx0_=Math.max(t.tbx0,a.tbx0),a.tby0_=Math.max(t.tby0,a.tby0),a.tbx1_=Math.min(t.tbx1,a.tbx1),a.tby1_=Math.min(t.tby1,a.tby1);var _=Math.floor((a.tbx0_-t.tbx0)/g.precinctWidthInSubband),b=Math.floor((a.tby0_-t.tby0)/g.precinctHeightInSubband);if(o=_+b*g.numprecinctswide,a.precinctNumber=o,a.subbandType=t.type,a.Lblock=3,!(a.tbx1_<=a.tbx0_||a.tby1_<=a.tby0_)){m.push(a);var y=v[o];void 0!==y?(ny.cbxMax&&(y.cbxMax=n),iy.cbyMax&&(y.cbyMax=i)):v[o]=y={cbxMin:n,cbyMin:i,cbxMax:n,cbyMax:i},a.precinct=y}}t.codeblockParameters={codeblockWidth:s,codeblockHeight:u,numcodeblockwide:d-l+1,numcodeblockhigh:p-h+1},t.codeblocks=m,t.precincts=v}function f(e,t,r){for(var n=[],i=e.subbands,a=0,o=i.length;o>a;a++)for(var s=i[a],u=s.codeblocks,c=0,f=u.length;f>c;c++){var l=u[c];l.precinctNumber===t&&n.push(l)}return{layerNumber:r,codeblocks:n}}function d(e){for(var t=e.SIZ,r=e.currentTile.index,n=e.tiles[r],i=n.codingStyleDefaultParameters.layersCount,a=t.Csiz,o=0,s=0;a>s;s++)o=Math.max(o,n.components[s].codingStyleParameters.decompositionLevelsCount);var u=0,c=0,l=0,h=0;this.nextPacket=function(){for(;i>u;u++){for(;o>=c;c++){for(;a>l;l++){var e=n.components[l];if(!(c>e.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[c],r=t.precinctParameters.numprecincts;r>h;){var s=f(t,h,u);return h++,s}h=0}}l=0}c=0}throw new Error("JPX Error: Out of packets")}}function p(e){for(var t=e.SIZ,r=e.currentTile.index,n=e.tiles[r],i=n.codingStyleDefaultParameters.layersCount,a=t.Csiz,o=0,s=0;a>s;s++)o=Math.max(o,n.components[s].codingStyleParameters.decompositionLevelsCount);var u=0,c=0,l=0,h=0;this.nextPacket=function(){for(;o>=u;u++){for(;i>c;c++){for(;a>l;l++){var e=n.components[l];if(!(u>e.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[u],r=t.precinctParameters.numprecincts;r>h;){var s=f(t,h,c);return h++,s}h=0}}l=0}c=0}throw new Error("JPX Error: Out of packets")}}function g(e){var t,r,n,i,a=e.SIZ,o=e.currentTile.index,s=e.tiles[o],u=s.codingStyleDefaultParameters.layersCount,c=a.Csiz,l=0;for(n=0;c>n;n++){var h=s.components[n];l=Math.max(l,h.codingStyleParameters.decompositionLevelsCount)}var d=new Int32Array(l+1);for(r=0;l>=r;++r){var p=0;for(n=0;c>n;++n){var g=s.components[n].resolutions;r=r;r++){for(;in;n++){var e=s.components[n];if(!(r>e.codingStyleParameters.decompositionLevelsCount)){var a=e.resolutions[r],o=a.precinctParameters.numprecincts;if(!(i>=o)){for(;u>t;){var h=f(a,i,t);return t++,h}t=0}}}n=0}i=0}throw new Error("JPX Error: Out of packets")}}function m(e){var t=e.SIZ,r=e.currentTile.index,n=e.tiles[r],i=n.codingStyleDefaultParameters.layersCount,a=t.Csiz,o=b(n),s=o,u=0,c=0,l=0,h=0,d=0;this.nextPacket=function(){for(;dl;l++){for(var e=n.components[l],t=e.codingStyleParameters.decompositionLevelsCount;t>=c;c++){var r=e.resolutions[c],p=o.components[l].resolutions[c],g=_(h,d,p,s,r);if(null!==g){for(;i>u;){var m=f(r,g,u);return u++,m}u=0}}c=0}l=0}h=0}throw new Error("JPX Error: Out of packets")}}function v(e){var t=e.SIZ,r=e.currentTile.index,n=e.tiles[r],i=n.codingStyleDefaultParameters.layersCount,a=t.Csiz,o=b(n),s=0,u=0,c=0,l=0,h=0;this.nextPacket=function(){for(;a>c;++c){for(var e=n.components[c],t=o.components[c],r=e.codingStyleParameters.decompositionLevelsCount;h=u;u++){var d=e.resolutions[u],p=t.resolutions[u],g=_(l,h,p,t,d);if(null!==g){for(;i>s;){var m=f(d,g,s);return s++,m}s=0}}u=0}l=0}h=0}throw new Error("JPX Error: Out of packets")}}function _(e,t,r,n,i){var a=e*n.minWidth,o=t*n.minHeight;if(a%r.width!==0||o%r.height!==0)return null;var s=o/r.width*i.precinctParameters.numprecinctswide;return a/r.height+s}function b(e){for(var t=e.components.length,r=Number.MAX_VALUE,n=Number.MAX_VALUE,i=0,a=0,o=new Array(t),s=0;t>s;s++){for(var u=e.components[s],c=u.codingStyleParameters.decompositionLevelsCount,f=new Array(c+1),l=Number.MAX_VALUE,h=Number.MAX_VALUE,d=0,p=0,g=1,m=c;m>=0;--m){var v=u.resolutions[m],_=g*v.precinctParameters.precinctWidth,b=g*v.precinctParameters.precinctHeight;l=Math.min(l,_),h=Math.min(h,b),d=Math.max(d,v.precinctParameters.numprecinctswide),p=Math.max(p,v.precinctParameters.numprecinctshigh),f[m]={width:_,height:b},g<<=1}r=Math.min(r,l),n=Math.min(n,h),i=Math.max(i,d),a=Math.max(a,p),o[s]={resolutions:f,minWidth:l,minHeight:h,maxNumWide:d,maxNumHigh:p}}return{components:o,minWidth:r,minHeight:n,maxNumWide:i,maxNumHigh:a}}function y(e){for(var t=e.SIZ,r=e.currentTile.index,n=e.tiles[r],i=t.Csiz,a=0;i>a;a++){for(var s=n.components[a],f=s.codingStyleParameters.decompositionLevelsCount,l=[],h=[],_=0;f>=_;_++){var b=o(e,s,_),y={},w=1<h;){var t=r[n+l];l++,d?(f=f<<7|t,h+=7,d=!1):(f=f<<8|t,h+=8),255===t&&(d=!0)}return h-=e,f>>>h&(1<e?e+3:(e=a(5),31>e?e+6:(e=a(7),e+37))}for(var f,l=0,h=0,d=!1,p=e.currentTile.index,g=e.tiles[p],m=e.COD.sopMarkerUsed,v=e.COD.ephMarkerUsed,_=g.packetsIterator;i>l;){u(),m&&o(145)&&s(4);var b=_.nextPacket();if(a(1)){for(var y,w=b.layerNumber,x=[],k=0,E=b.codeblocks.length;E>k;k++){y=b.codeblocks[k];var S,A=y.precinct,P=y.cbx-A.cbxMin,T=y.cby-A.cbyMin,L=!1,M=!1;if(void 0!==y.included)L=!!a(1);else{A=y.precinct;var C,O;if(void 0!==A.inclusionTree)C=A.inclusionTree;else{var D=A.cbxMax-A.cbxMin+1,U=A.cbyMax-A.cbyMin+1;C=new R(D,U,w),O=new I(D,U),A.inclusionTree=C,A.zeroBitPlanesTree=O}if(C.reset(P,T,w))for(;;){if(!a(1)){C.incrementValue(w);break}if(S=!C.nextLevel()){y.included=!0,L=M=!0;break}}}if(L){if(M){for(O=A.zeroBitPlanesTree,O.reset(P,T);;)if(a(1)){if(S=!O.nextLevel())break}else O.incrementValue();y.zeroBitPlanes=O.value}for(var B=c();a(1);)y.Lblock++;var z=t(B),F=(1<B?z-1:z)+y.Lblock,j=a(F);x.push({codeblock:y,codingpasses:B,dataLength:j})}}for(u(),v&&o(146);x.length>0;){var N=x.shift();y=N.codeblock,void 0===y.data&&(y.data=[]),y.data.push({data:r,start:n+l,end:n+l+N.dataLength,codingpasses:N.codingpasses}),l+=N.dataLength}}}return l}function x(e,t,r,n,i,a,o,u){for(var c=n.tbx0,f=n.tby0,l=n.tbx1-n.tbx0,h=n.codeblocks,d="H"===n.type.charAt(0)?1:0,p="H"===n.type.charAt(1)?t:0,g=0,m=h.length;m>g;++g){var v=h[g],_=v.tbx1_-v.tbx0_,b=v.tby1_-v.tby0_;if(0!==_&&0!==b&&void 0!==v.data){var y,w;y=new P(_,b,v.subbandType,v.zeroBitPlanes,a),w=2;var x,k,E,S=v.data,A=0,I=0;for(x=0,k=S.length;k>x;x++)E=S[x],A+=E.end-E.start,I+=E.codingpasses;var R=new Uint8Array(A),T=0;for(x=0,k=S.length;k>x;x++){E=S[x];var L=E.data.subarray(E.start,E.end);R.set(L,T),T+=L.length}var M=new s(R,0,A);for(y.setDecoder(M),x=0;I>x;x++){switch(w){case 0:y.runSignificancePropogationPass();break;case 1:y.runMagnitudeRefinementPass();break;case 2:y.runCleanupPass(),u&&y.checkSegmentationSymbol()}w=(w+1)%3}var C,O,D,U=v.tbx0_-c+(v.tby0_-f)*l,B=y.coefficentsSign,z=y.coefficentsMagnitude,F=y.bitsDecoded,j=o?0:.5;T=0;var N="LL"!==n.type;for(x=0;b>x;x++){var Z=U/l|0,q=2*Z*(t-l)+d+p;for(C=0;_>C;C++){if(O=z[T],0!==O){O=(O+j)*i,0!==B[T]&&(O=-O),D=F[T];var G=N?q+(U<<1):U;o&&D>=a?e[G]=O:e[G]=O*(1<=m;m++){for(var v=n.resolutions[m],_=v.trx1-v.trx0,b=v.try1-v.try0,y=new Float32Array(_*b),w=0,k=v.subbands.length;k>w;w++){var E,S;u?(E=s[g].mu,S=s[g].epsilon,g++):(E=s[0].mu,S=s[0].epsilon+(m>0?1-m:0));var I=v.subbands[w],R=A[I.type],P=h?1:Math.pow(2,l+R-S)*(1+E/2048),T=c+S-1;x(y,_,b,I,P,T,h,f)}p.push({width:_,height:b,items:y})}var C=d.calculate(p,n.tcx0,n.tcy0);return{left:n.tcx0,top:n.tcy0,width:C.width,height:C.height,items:C.items}}function E(e){for(var t=e.SIZ,r=e.components,n=t.Csiz,i=[],a=0,o=e.tiles.length;o>a;a++){var s,u=e.tiles[a],c=[];for(s=0;n>s;s++)c[s]=k(e,u,s);var f,l,h,d,p,g,m,v,_,b,y,w,x,E,S,A=c[0],I=new Uint8Array(A.items.length*n),R={left:A.left,top:A.top,width:A.width,height:A.height,items:I},P=0;if(u.codingStyleDefaultParameters.multipleComponentTransform){var T=4===n,L=c[0].items,M=c[1].items,C=c[2].items,O=T?c[3].items:null;f=r[0].precision-8,l=(128<g;g++,P+=U)v=L[g]+l,_=M[g],b=C[g],w=v-(b+_>>2),y=w+b,x=w+_,I[P++]=0>=y?0:y>=h?255:y>>f,I[P++]=0>=w?0:w>=h?255:w>>f,I[P++]=0>=x?0:x>=h?255:x>>f;else for(g=0;m>g;g++,P+=U)v=L[g]+l,_=M[g],b=C[g],y=v+1.402*b,w=v-.34413*_-.71414*b,x=v+1.772*_,I[P++]=0>=y?0:y>=h?255:y>>f,I[P++]=0>=w?0:w>=h?255:w>>f,I[P++]=0>=x?0:x>=h?255:x>>f;if(T)for(g=0,P=3;m>g;g++,P+=4)E=O[g],I[P]=d>=E?0:E>=p?255:E+l>>f}else for(s=0;n>s;s++){var B=c[s].items;for(f=r[s].precision-8,l=(128<g;g++)S=B[g],I[P]=d>=S?0:S>=h?255:S+l>>f,P+=n}i.push(R)}return i}function S(e,t){for(var r=e.SIZ,n=r.Csiz,i=e.tiles[t],a=0;n>a;a++){var o=i.components[a],s=void 0!==e.currentTile.QCC[a]?e.currentTile.QCC[a]:e.currentTile.QCD;o.quantizationParameters=s;var u=void 0!==e.currentTile.COC[a]?e.currentTile.COC[a]:e.currentTile.COD;o.codingStyleParameters=u}i.codingStyleDefaultParameters=e.currentTile.COD}var A={LL:0,LH:1,HL:1,HH:2};e.prototype={parse:function(e){var t=n(e,0);if(65359===t)return void this.parseCodestream(e,0,e.length);for(var r=0,a=e.length;a>r;){var o=8,s=i(e,r),u=i(e,r+4);if(r+=o,1===s&&(s=4294967296*i(e,r)+i(e,r+4),r+=8,o+=8),0===s&&(s=a-r+o),o>s)throw new Error("JPX Error: Invalid box field size");var c=s-o,f=!0;switch(u){case 1785737832:f=!1;break;case 1668246642:var d=e[r];e[r+1],e[r+2];if(1===d){var p=i(e,r+3);switch(p){case 16:case 17:case 18:break;default:l("Unknown colorspace "+p)}}else 2===d&&h("ICC profile not supported");break;case 1785737827:this.parseCodestream(e,r,r+c);break;case 1783636e3:218793738!==i(e,r)&&l("Invalid JP2 signature");break;case 1783634458:case 1718909296:case 1920099697:case 1919251232:case 1768449138:break;default:var g=String.fromCharCode(u>>24&255,u>>16&255,u>>8&255,255&u);l("Unsupported header type "+u+" ("+g+")")}f&&(r+=c)}},parseImageProperties:function(e){for(var t=e.getByte();t>=0;){var r=t;t=e.getByte();var n=r<<8|t;if(65361===n){e.skip(4);var i=e.getInt32()>>>0,a=e.getInt32()>>>0,o=e.getInt32()>>>0,s=e.getInt32()>>>0;e.skip(16);var u=e.getUint16();return this.width=i-o,this.height=a-s,this.componentsCount=u,void(this.bitsPerComponent=8)}}throw new Error("JPX Error: No size marker found in JPX stream")},parseCodestream:function(e,t,o){var s={};try{for(var u=!1,c=t;o>c+1;){var f=n(e,c);c+=2;var h,d,p,g,m,v,_=0;switch(f){case 65359:s.mainHeader=!0;break;case 65497:break;case 65361:_=n(e,c);var b={};b.Xsiz=i(e,c+4),b.Ysiz=i(e,c+8),b.XOsiz=i(e,c+12),b.YOsiz=i(e,c+16),b.XTsiz=i(e,c+20),b.YTsiz=i(e,c+24),b.XTOsiz=i(e,c+28),b.YTOsiz=i(e,c+32);var x=n(e,c+36);b.Csiz=x;var k=[];h=c+38;for(var A=0;x>A;A++){var I={precision:(127&e[h])+1,isSigned:!!(128&e[h]),XRsiz:e[h+1],YRsiz:e[h+1]};r(I,b),k.push(I)}s.SIZ=b,s.components=k,a(s,k),s.QCC=[],s.COC=[];break;case 65372:_=n(e,c);var R={};switch(h=c+2,d=e[h++],31&d){case 0:g=8,m=!0;break;case 1:g=16,m=!1;break;case 2:g=16,m=!0;break;default:throw new Error("JPX Error: Invalid SQcd value "+d)}for(R.noQuantization=8===g,R.scalarExpounded=m,R.guardBits=d>>5,p=[];_+c>h;){var P={};8===g?(P.epsilon=e[h++]>>3,P.mu=0):(P.epsilon=e[h]>>3,P.mu=(7&e[h])<<8|e[h+1],h+=2),p.push(P)}R.SPqcds=p,s.mainHeader?s.QCD=R:(s.currentTile.QCD=R,s.currentTile.QCC=[]);break;case 65373:_=n(e,c);var T={};h=c+2;var L;switch(s.SIZ.Csiz<257?L=e[h++]:(L=n(e,h),h+=2),d=e[h++],31&d){case 0:g=8,m=!0;break;case 1:g=16,m=!1;break;case 2:g=16,m=!0;break;default:throw new Error("JPX Error: Invalid SQcd value "+d)}for(T.noQuantization=8===g,T.scalarExpounded=m,T.guardBits=d>>5,p=[];_+c>h;)P={},8===g?(P.epsilon=e[h++]>>3,P.mu=0):(P.epsilon=e[h]>>3,P.mu=(7&e[h])<<8|e[h+1],h+=2),p.push(P);T.SPqcds=p,s.mainHeader?s.QCC[L]=T:s.currentTile.QCC[L]=T;break;case 65362:_=n(e,c);var M={};h=c+2;var C=e[h++];M.entropyCoderWithCustomPrecincts=!!(1&C),M.sopMarkerUsed=!!(2&C),M.ephMarkerUsed=!!(4&C),M.progressionOrder=e[h++],M.layersCount=n(e,h),h+=2,M.multipleComponentTransform=e[h++],M.decompositionLevelsCount=e[h++],M.xcb=(15&e[h++])+2,M.ycb=(15&e[h++])+2;var O=e[h++];if(M.selectiveArithmeticCodingBypass=!!(1&O),M.resetContextProbabilities=!!(2&O),M.terminationOnEachCodingPass=!!(4&O),M.verticalyStripe=!!(8&O),M.predictableTermination=!!(16&O),M.segmentationSymbolUsed=!!(32&O),M.reversibleTransformation=e[h++],M.entropyCoderWithCustomPrecincts){for(var D=[];_+c>h;){var U=e[h++];D.push({PPx:15&U,PPy:U>>4})}M.precinctsSizes=D}var B=[];if(M.selectiveArithmeticCodingBypass&&B.push("selectiveArithmeticCodingBypass"),M.resetContextProbabilities&&B.push("resetContextProbabilities"),M.terminationOnEachCodingPass&&B.push("terminationOnEachCodingPass"),M.verticalyStripe&&B.push("verticalyStripe"),M.predictableTermination&&B.push("predictableTermination"),B.length>0)throw u=!0,new Error("JPX Error: Unsupported COD options ("+B.join(", ")+")");s.mainHeader?s.COD=M:(s.currentTile.COD=M,s.currentTile.COC=[]);break;case 65424:_=n(e,c),v={},v.index=n(e,c+2),v.length=i(e,c+4),v.dataEnd=v.length+c-2,v.partIndex=e[c+8],v.partsCount=e[c+9],s.mainHeader=!1,0===v.partIndex&&(v.COD=s.COD,v.COC=s.COC.slice(0),v.QCD=s.QCD,v.QCC=s.QCC.slice(0)),s.currentTile=v;break;case 65427:v=s.currentTile,0===v.partIndex&&(S(s,v.index),y(s)),_=v.dataEnd-c,w(s,e,c,_);break;case 65365:case 65367:case 65368:case 65380:_=n(e,c);break;case 65363:throw new Error("JPX Error: Codestream code 0xFF53 (COC) is not implemented");default:throw new Error("JPX Error: Unknown codestream code: "+f.toString(16))}c+=_}}catch(z){if(u||this.failOnCorruptedImage)throw z;l("Trying to recover from "+z.message)}this.tiles=E(s),this.width=s.SIZ.Xsiz-s.SIZ.XOsiz,this.height=s.SIZ.Ysiz-s.SIZ.YOsiz,this.componentsCount=s.SIZ.Csiz}};var I=function(){function e(e,r){var n=t(Math.max(e,r))+1;this.levels=[];for(var i=0;n>i;i++){var a={width:e,height:r,items:[]};this.levels.push(a),e=Math.ceil(e/2),r=Math.ceil(r/2)}}return e.prototype={reset:function(e,t){for(var r,n=0,i=0;n>=1,t>>=1,n++}n--,r=this.levels[n],r.items[r.index]=i,this.currentLevel=n,delete this.value},incrementValue:function(){var e=this.levels[this.currentLevel];e.items[e.index]++},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];return e--,0>e?(this.value=r,!1):(this.currentLevel=e,t=this.levels[e],t.items[t.index]=r,!0)}},e}(),R=function(){function e(e,r,n){var i=t(Math.max(e,r))+1;this.levels=[];for(var a=0;i>a;a++){for(var o=new Uint8Array(e*r),s=0,u=o.length;u>s;s++)o[s]=n;var c={width:e,height:r,items:o};this.levels.push(c),e=Math.ceil(e/2),r=Math.ceil(r/2)}}return e.prototype={reset:function(e,t,r){for(var n=0;nr)return this.currentLevel=n,this.propagateValues(),!1;e>>=1,t>>=1,n++}return this.currentLevel=n-1,!0},incrementValue:function(e){var t=this.levels[this.currentLevel];t.items[t.index]=e+1,this.propagateValues()},propagateValues:function(){for(var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];--e>=0;)t=this.levels[e],t.items[t.index]=r},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];return t.items[t.index]=255,e--,0>e?!1:(this.currentLevel=e,t=this.levels[e],t.items[t.index]=r,!0)}},e}(),P=function(){function e(e,t,r,o,s){this.width=e,this.height=t,this.contextLabelTable="HH"===r?a:"HL"===r?i:n;var u=e*t;this.neighborsSignificance=new Uint8Array(u),this.coefficentsSign=new Uint8Array(u),this.coefficentsMagnitude=s>14?new Uint32Array(u):s>6?new Uint16Array(u):new Uint8Array(u),this.processingFlags=new Uint8Array(u);var c=new Uint8Array(u);if(0!==o)for(var f=0;u>f;f++)c[f]=o;this.bitsDecoded=c,this.reset()}var t=17,r=18,n=new Uint8Array([0,5,8,0,3,7,8,0,4,7,8,0,0,0,0,0,1,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8]),i=new Uint8Array([0,3,4,0,5,7,7,0,8,8,8,0,0,0,0,0,1,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8]),a=new Uint8Array([0,1,2,0,1,2,2,0,2,2,2,0,0,0,0,0,3,4,5,0,4,5,5,0,5,5,5,0,0,0,0,0,6,7,7,0,7,7,7,0,7,7,7,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8]); -return e.prototype={setDecoder:function(e){this.decoder=e},reset:function(){this.contexts=new Int8Array(19),this.contexts[0]=8,this.contexts[t]=92,this.contexts[r]=6},setNeighborsSignificance:function(e,t,r){var n,i=this.neighborsSignificance,a=this.width,o=this.height,s=t>0,u=a>t+1;e>0&&(n=r-a,s&&(i[n-1]+=16),u&&(i[n+1]+=16),i[n]+=4),o>e+1&&(n=r+a,s&&(i[n-1]+=16),u&&(i[n+1]+=16),i[n]+=4),s&&(i[r-1]+=1),u&&(i[r+1]+=1),i[r]|=128},runSignificancePropogationPass:function(){for(var e=this.decoder,t=this.width,r=this.height,n=this.coefficentsMagnitude,i=this.coefficentsSign,a=this.neighborsSignificance,o=this.processingFlags,s=this.contexts,u=this.contextLabelTable,c=this.bitsDecoded,f=-2,l=1,h=2,d=0;r>d;d+=4)for(var p=0;t>p;p++)for(var g=d*t+p,m=0;4>m;m++,g+=t){var v=d+m;if(v>=r)break;if(o[g]&=f,!n[g]&&a[g]){var _=u[a[g]],b=e.readBit(s,_);if(b){var y=this.decodeSignBit(v,p,g);i[g]=y,n[g]=1,this.setNeighborsSignificance(v,p,g),o[g]|=h}c[g]++,o[g]|=l}}},decodeSignBit:function(e,t,r){var n,i,a,o,s,u,c=this.width,f=this.height,l=this.coefficentsMagnitude,h=this.coefficentsSign;o=t>0&&0!==l[r-1],c>t+1&&0!==l[r+1]?(a=h[r+1],o?(i=h[r-1],n=1-a-i):n=1-a-a):o?(i=h[r-1],n=1-i-i):n=0;var d=3*n;return o=e>0&&0!==l[r-c],f>e+1&&0!==l[r+c]?(a=h[r+c],o?(i=h[r-c],n=1-a-i+d):n=1-a-a+d):o?(i=h[r-c],n=1-i-i+d):n=d,n>=0?(s=9+n,u=this.decoder.readBit(this.contexts,s)):(s=9-n,u=1^this.decoder.readBit(this.contexts,s)),u},runMagnitudeRefinementPass:function(){for(var e,t=this.decoder,r=this.width,n=this.height,i=this.coefficentsMagnitude,a=this.neighborsSignificance,o=this.contexts,s=this.bitsDecoded,u=this.processingFlags,c=1,f=2,l=r*n,h=4*r,d=0;l>d;d=e){e=Math.min(l,d+h);for(var p=0;r>p;p++)for(var g=d+p;e>g;g+=r)if(i[g]&&0===(u[g]&c)){var m=16;if(0!==(u[g]&f)){u[g]^=f;var v=127&a[g];m=0===v?15:14}var _=t.readBit(o,m);i[g]=i[g]<<1|_,s[g]++,u[g]|=c}}},runCleanupPass:function(){for(var e,n=this.decoder,i=this.width,a=this.height,o=this.neighborsSignificance,s=this.coefficentsMagnitude,u=this.coefficentsSign,c=this.contexts,f=this.contextLabelTable,l=this.bitsDecoded,h=this.processingFlags,d=1,p=2,g=i,m=2*i,v=3*i,_=0;a>_;_=e){e=Math.min(_+4,a);for(var b=_*i,y=a>_+3,w=0;i>w;w++){var x,k=b+w,E=y&&0===h[k]&&0===h[k+g]&&0===h[k+m]&&0===h[k+v]&&0===o[k]&&0===o[k+g]&&0===o[k+m]&&0===o[k+v],S=0,A=k,I=_;if(E){var R=n.readBit(c,r);if(!R){l[k]++,l[k+g]++,l[k+m]++,l[k+v]++;continue}S=n.readBit(c,t)<<1|n.readBit(c,t),0!==S&&(I=_+S,A+=S*i),x=this.decodeSignBit(I,w,A),u[A]=x,s[A]=1,this.setNeighborsSignificance(I,w,A),h[A]|=p,A=k;for(var P=_;I>=P;P++,A+=i)l[A]++;S++}for(I=_+S;e>I;I++,A+=i)if(!s[A]&&0===(h[A]&d)){var T=f[o[A]],L=n.readBit(c,T);1===L&&(x=this.decodeSignBit(I,w,A),u[A]=x,s[A]=1,this.setNeighborsSignificance(I,w,A),h[A]|=p),l[A]++}}}},checkSegmentationSymbol:function(){var e=this.decoder,r=this.contexts,n=e.readBit(r,t)<<3|e.readBit(r,t)<<2|e.readBit(r,t)<<1|e.readBit(r,t);if(10!==n)throw new Error("JPX Error: Invalid segmentation symbol")}},e}(),T=function(){function e(){}return e.prototype.calculate=function(e,t,r){for(var n=e[0],i=1,a=e.length;a>i;i++)n=this.iterate(n,e[i],t,r);return n},e.prototype.extend=function(e,t,r){var n=t-1,i=t+1,a=t+r-2,o=t+r;e[n--]=e[i++],e[o++]=e[a--],e[n--]=e[i++],e[o++]=e[a--],e[n--]=e[i++],e[o++]=e[a--],e[n]=e[i],e[o]=e[a]},e.prototype.iterate=function(e,t,r,n){var i,a,o,s,u,c,f=e.width,l=e.height,h=e.items,d=t.width,p=t.height,g=t.items;for(o=0,i=0;l>i;i++)for(s=2*i*d,a=0;f>a;a++,o++,s+=2)g[s]=h[o];h=e.items=null;var m=4,v=new Float32Array(d+2*m);if(1===d){if(0!==(1&r))for(c=0,o=0;p>c;c++,o+=d)g[o]*=.5}else for(c=0,o=0;p>c;c++,o+=d)v.set(g.subarray(o,o+d),m),this.extend(v,m,d),this.filter(v,m,d),g.set(v.subarray(m,m+d),o);var _=16,b=[];for(i=0;_>i;i++)b.push(new Float32Array(p+2*m));var y,w=0;if(e=m+p,1===p){if(0!==(1&n))for(u=0;d>u;u++)g[u]*=.5}else for(u=0;d>u;u++){if(0===w){for(_=Math.min(d-u,_),o=u,s=m;e>s;o+=d,s++)for(y=0;_>y;y++)b[y][s]=g[o+y];w=_}w--;var x=b[w];if(this.extend(x,m,p),this.filter(x,m,p),0===w)for(o=u-_+1,s=m;e>s;o+=d,s++)for(y=0;_>y;y++)g[o+y]=b[y][s]}return{width:d,height:p,items:g}},e}(),L=function(){function e(){T.call(this)}return e.prototype=Object.create(T.prototype),e.prototype.filter=function(e,t,r){var n=r>>1;t=0|t;var i,a,o,s,u=-1.586134342059924,c=-.052980118572961,f=.882911075530934,l=.443506852043971,h=1.230174104914001,d=1/h;for(i=t-3,a=n+4;a--;i+=2)e[i]*=d;for(i=t-2,o=l*e[i-1],a=n+3;a--&&(s=l*e[i+1],e[i]=h*e[i]-o-s,a--);i+=2)i+=2,o=l*e[i+1],e[i]=h*e[i]-o-s;for(i=t-1,o=f*e[i-1],a=n+2;a--&&(s=f*e[i+1],e[i]-=o+s,a--);i+=2)i+=2,o=f*e[i+1],e[i]-=o+s;for(i=t,o=c*e[i-1],a=n+1;a--&&(s=c*e[i+1],e[i]-=o+s,a--);i+=2)i+=2,o=c*e[i+1],e[i]-=o+s;if(0!==n)for(i=t+1,o=u*e[i-1],a=n;a--&&(s=u*e[i+1],e[i]-=o+s,a--);i+=2)i+=2,o=u*e[i+1],e[i]-=o+s},e}(),M=function(){function e(){T.call(this)}return e.prototype=Object.create(T.prototype),e.prototype.filter=function(e,t,r){var n=r>>1;t=0|t;var i,a;for(i=t,a=n+1;a--;i+=2)e[i]-=e[i-1]+e[i+1]+2>>2;for(i=t+1,a=n;a--;i+=2)e[i]+=e[i-1]+e[i+1]>>1},e}();return e}(),c=function(){function e(){}function o(e,t,r){this.data=e,this.start=t,this.end=r}function u(e,t,r){function n(e){for(var t=0,n=0;e>n;n++){var o=r.readBit(i,a);a=256>a?a<<1|o:511&(a<<1|o)|256,t=t<<1|o}return t>>>0}var i=e.getContexts(t),a=1,o=n(1),s=n(1)?n(1)?n(1)?n(1)?n(1)?n(32)+4436:n(12)+340:n(8)+84:n(6)+20:n(4)+4:n(2);return 0===o?s:s>0?-s:null}function c(e,t,r){for(var n=e.getContexts("IAID"),i=1,a=0;r>a;a++){var o=t.readBit(n,i);i=i<<1|o}return 31>r?i&(1<i;i++)for(s=h[i]=new Uint8Array(e),u=1>i?s:h[i-1],c=2>i?s:h[i-2],n=c[0]<<13|c[1]<<12|c[2]<<11|u[0]<<7|u[1]<<6|u[2]<<5|u[3]<<4,a=0;e>a;a++)s[a]=o=f.readBit(l,n),n=(n&d)<<1|(e>a+3?c[a+3]<<11:0)|(e>a+4?u[a+4]<<4:0)|o;return h}function h(e,t,r,n,i,a,o,s){if(e&&f("JBIG2 error: MMR encoding is not supported"),0===n&&!a&&!i&&4===o.length&&3===o[0].x&&-1===o[0].y&&-3===o[1].x&&-1===o[1].y&&2===o[2].x&&-2===o[2].y&&-2===o[3].x&&-2===o[3].y)return l(t,r,s);var u=!!a,c=S[n].concat(o);c.sort(function(e,t){return e.y-t.y||e.x-t.x});var h,d,p=c.length,g=new Int8Array(p),m=new Int8Array(p),v=[],_=0,b=0,y=0,w=0;for(d=0;p>d;d++)g[d]=c[d].x,m[d]=c[d].y,b=Math.min(b,c[d].x),y=Math.max(y,c[d].x),w=Math.min(w,c[d].y),p-1>d&&c[d].y===c[d+1].y&&c[d].x===c[d+1].x-1?_|=1<h;h++)d=v[h],k[h]=c[d].x,E[h]=c[d].y,A[h]=1<q;q++){if(i){var G=F.readBit(j,U);if(N^=G){z.push(B);continue}}for(B=new Uint8Array(B),z.push(B),R=0;t>R;R++)if(u&&a[q][R])B[R]=0;else{if(R>=C&&D>R&&q>=O)for(Z=Z<<1&_,d=0;x>d;d++)P=q+E[d],T=R+k[d],L=z[P][T],L&&(L=A[d],Z|=L);else for(Z=0,M=p-1,d=0;p>d;d++,M--)T=R+g[d],T>=0&&t>T&&(P=q+m[d],P>=0&&(L=z[P][T],L&&(Z|=L<l;l++)d[l]=c[l].x,p[l]=c[l].y;var g=A[r].reference;0===r&&(g=g.concat([s[1]]));var m=g.length,v=new Int32Array(m),_=new Int32Array(m);for(l=0;m>l;l++)v[l]=g[l].x,_[l]=g[l].y;for(var b=n[0].length,y=n.length,w=R[r],x=[],k=u.decoder,E=u.contextCache.getContexts("GR"),S=0,I=0;t>I;I++){if(o){var P=k.readBit(E,w);S^=P,S&&f("JBIG2 error: prediction is not supported")}var T=new Uint8Array(e);x.push(T);for(var L=0;e>L;L++){var M,C,O=0;for(l=0;h>l;l++)M=I+p[l],C=L+d[l],0>M||0>C||C>=e?O<<=1:O=O<<1|x[M][C];for(l=0;m>l;l++)M=I+_[l]+a,C=L+v[l]+i,0>M||M>=y||0>C||C>=b?O<<=1:O=O<<1|n[M][C];var D=k.readBit(E,O);T[L]=D}}return x}function p(e,r,n,i,a,o,s,l,p,m,v){e&&f("JBIG2 error: huffman is not supported");for(var _=[],b=0,y=t(n.length+i),w=v.decoder,x=v.contextCache;_.length1)I=g(e,r,E,b,0,R,1,n.concat(_),y,0,0,1,0,o,p,m,v);else{var P=c(x,w,y),T=u(x,"IARDX",w),L=u(x,"IARDY",w),M=Pz;z++)O[z]&&C.push(n[z]);for(var j=0;i>j;z++,j++)O[z]&&C.push(_[j]);return C}function g(e,t,r,n,i,a,o,s,l,h,p,g,m,v,_,b,y){e&&f("JBIG2 error: huffman is not supported");var w,x,k=[];for(w=0;n>w;w++){if(x=new Uint8Array(r),i)for(var E=0;r>E;E++)x[E]=i;k.push(x)}var S=y.decoder,A=y.contextCache,I=-u(A,"IADT",S),R=0;for(w=0;a>w;){var P=u(A,"IADT",S);I+=P;var T=u(A,"IAFS",S);R+=T;for(var L=R;;){var M=1===o?0:u(A,"IAIT",S),C=o*I+M,O=c(A,S,l),D=t&&u(A,"IARI",S),U=s[O],B=U[0].length,z=U.length;if(D){var F=u(A,"IARDW",S),j=u(A,"IARDH",S),N=u(A,"IARDX",S),Z=u(A,"IARDY",S);B+=F,z+=j,U=d(B,z,_,U,(F>>1)+N,(j>>1)+Z,!1,b,y)}var q,G,H,Y=C-(1&g?0:z),W=L-(2&g?B:0);if(h){for(q=0;z>q;q++)if(x=k[W+q]){H=U[q];var V=Math.min(r-Y,B);switch(m){case 0:for(G=0;V>G;G++)x[Y+G]|=H[G];break;case 2:for(G=0;V>G;G++)x[Y+G]^=H[G];break;default:f("JBIG2 error: operator "+m+" is not supported")}}L+=z-1}else{for(G=0;z>G;G++)if(x=k[Y+G])switch(H=U[G],m){case 0:for(q=0;B>q;q++)x[W+q]|=H[q];break;case 2:for(q=0;B>q;q++)x[W+q]^=H[q];break;default:f("JBIG2 error: operator "+m+" is not supported")}L+=B-1}w++;var X=u(A,"IADS",S);if(null===X)break;L+=X+p}}return k}function m(e,t){var r={};r.number=i(e,t);var a=e[t+4],o=63&a;E[o]||f("JBIG2 error: invalid segment type: "+o),r.type=o,r.typeName=E[o],r.deferredNonRetain=!!(128&a);var s=!!(64&a),u=e[t+5],c=u>>5&7,l=[31&u],h=t+6;if(7===u){c=536870911&i(e,h-1),h+=3;var d=c+7>>3;for(l[0]=e[h++];--d>0;)l.push(e[h++])}else 5!==u&&6!==u||f("JBIG2 error: invalid referred-to flags");r.retainBits=l;var p,g,m=r.number<=256?1:r.number<=65536?2:4,v=[];for(p=0;c>p;p++){var b=1===m?e[h]:2===m?n(e,h):i(e,h);v.push(b),h+=m}if(r.referredTo=v,s?(r.pageAssociation=i(e,h),h+=4):r.pageAssociation=e[h++],r.length=i(e,h),h+=4,4294967295===r.length)if(38===o){var y=_(e,h),w=e[h+P],x=!!(1&w),k=6,S=new Uint8Array(k);for(x||(S[0]=255,S[1]=172),S[2]=y.height>>>24&255,S[3]=y.height>>16&255,S[4]=y.height>>8&255,S[5]=255&y.height,p=h,g=e.length;g>p;p++){for(var A=0;k>A&&S[A]===e[p+A];)A++;if(A===k){r.length=p+k;break}}4294967295===r.length&&f("JBIG2 error: segment end was not found")}else f("JBIG2 error: invalid unknown segment length");return r.headerEnd=h,r}function v(e,t,r,n){for(var i=[],a=r;n>a;){var o=m(t,a);a=o.headerEnd;var s={header:o,data:t};if(e.randomAccess||(s.start=a,a+=o.length,s.end=a),i.push(s),51===o.type)break}if(e.randomAccess)for(var u=0,c=i.length;c>u;u++)i[u].start=a,a+=i[u].header.length,i[u].end=a;return i}function _(e,t){return{width:i(e,t),height:i(e,t+4),x:i(e,t+8),y:i(e,t+12),combinationOperator:7&e[t+16]}}function b(e,t){var a,o,s,u,c=e.header,l=e.data,h=e.start,d=e.end;switch(c.type){case 0:var p={},g=n(l,h);if(p.huffman=!!(1&g),p.refinement=!!(2&g),p.huffmanDHSelector=g>>2&3,p.huffmanDWSelector=g>>4&3,p.bitmapSizeSelector=g>>6&1,p.aggregationInstancesSelector=g>>7&1,p.bitmapCodingContextUsed=!!(256&g),p.bitmapCodingContextRetained=!!(512&g),p.template=g>>10&3,p.refinementTemplate=g>>12&1,h+=2,!p.huffman){for(u=0===p.template?4:1,o=[],s=0;u>s;s++)o.push({x:r(l,h),y:r(l,h+1)}),h+=2;p.at=o}if(p.refinement&&!p.refinementTemplate){for(o=[],s=0;2>s;s++)o.push({x:r(l,h),y:r(l,h+1)}),h+=2;p.refinementAt=o}p.numberOfExportedSymbols=i(l,h),h+=4,p.numberOfNewSymbols=i(l,h),h+=4,a=[p,c.number,c.referredTo,l,h,d];break;case 6:case 7:var m={};m.info=_(l,h),h+=P;var v=n(l,h);if(h+=2,m.huffman=!!(1&v),m.refinement=!!(2&v),m.stripSize=1<<(v>>2&3),m.referenceCorner=v>>4&3,m.transposed=!!(64&v),m.combinationOperator=v>>7&3,m.defaultPixelValue=v>>9&1,m.dsOffset=v<<17>>27,m.refinementTemplate=v>>15&1,m.huffman){var b=n(l,h);h+=2,m.huffmanFS=3&b,m.huffmanDS=b>>2&3,m.huffmanDT=b>>4&3,m.huffmanRefinementDW=b>>6&3,m.huffmanRefinementDH=b>>8&3,m.huffmanRefinementDX=b>>10&3,m.huffmanRefinementDY=b>>12&3,m.huffmanRefinementSizeSelector=!!(14&b)}if(m.refinement&&!m.refinementTemplate){for(o=[],s=0;2>s;s++)o.push({x:r(l,h),y:r(l,h+1)}),h+=2;m.refinementAt=o}m.numberOfSymbolInstances=i(l,h),h+=4,m.huffman&&f("JBIG2 error: huffman is not supported"),a=[m,c.referredTo,l,h,d];break;case 38:case 39:var y={};y.info=_(l,h),h+=P;var w=l[h++];if(y.mmr=!!(1&w),y.template=w>>1&3,y.prediction=!!(8&w),!y.mmr){for(u=0===y.template?4:1,o=[],s=0;u>s;s++)o.push({x:r(l,h),y:r(l,h+1)}),h+=2;y.at=o}a=[y,l,h,d];break;case 48:var x={width:i(l,h),height:i(l,h+4),resolutionX:i(l,h+8),resolutionY:i(l,h+12)};4294967295===x.height&&delete x.height;var k=l[h+16];n(l,h+17);x.lossless=!!(1&k),x.refinement=!!(2&k),x.defaultPixelValue=k>>2&1,x.combinationOperator=k>>3&3,x.requiresBuffer=!!(32&k),x.combinationOperatorOverride=!!(64&k),a=[x];break;case 49:break;case 50:break;case 51:break;case 62:break;default:f("JBIG2 error: segment type "+c.typeName+"("+c.type+") is not implemented")}var E="on"+c.typeName;E in t&&t[E].apply(t,a)}function y(e,t){for(var r=0,n=e.length;n>r;r++)b(e[r],t)}function w(e){for(var t=new x,r=0,n=e.length;n>r;r++){var i=e[r],a=v({},i.data,i.start,i.end);y(a,t)}return t}function x(){}function k(){}e.prototype={getContexts:function(e){return e in this?this[e]:this[e]=new Int8Array(65536)}},o.prototype={get decoder(){var e=new s(this.data,this.start,this.end);return a(this,"decoder",e)},get contextCache(){var t=new e;return a(this,"contextCache",t)}};var E=["SymbolDictionary",null,null,null,"IntermediateTextRegion",null,"ImmediateTextRegion","ImmediateLosslessTextRegion",null,null,null,null,null,null,null,null,"patternDictionary",null,null,null,"IntermediateHalftoneRegion",null,"ImmediateHalftoneRegion","ImmediateLosslessHalftoneRegion",null,null,null,null,null,null,null,null,null,null,null,null,"IntermediateGenericRegion",null,"ImmediateGenericRegion","ImmediateLosslessGenericRegion","IntermediateGenericRefinementRegion",null,"ImmediateGenericRefinementRegion","ImmediateLosslessGenericRefinementRegion",null,null,null,null,"PageInformation","EndOfPage","EndOfStripe","EndOfFile","Profiles","Tables",null,null,null,null,null,null,null,null,"Extension"],S=[[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:2,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-2,y:0},{x:-1,y:0}],[{x:-3,y:-1},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}]],A=[{coding:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:-1,y:1},{x:0,y:1},{x:1,y:1}]},{coding:[{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:0,y:1},{x:1,y:1}]}],I=[39717,1941,229,405],R=[32,8],P=17;return x.prototype={onPageInformation:function(e){this.currentPageInfo=e;var t=e.width+7>>3,r=new Uint8Array(t*e.height);if(e.defaultPixelValue)for(var n=0,i=r.length;i>n;n++)r[n]=255;this.buffer=r},drawBitmap:function(e,t){var r,n,i,a,o=this.currentPageInfo,s=e.width,u=e.height,c=o.width+7>>3,l=o.combinationOperatorOverride?e.combinationOperator:o.combinationOperator,h=this.buffer,d=128>>(7&e.x),p=e.y*c+(e.x>>3);switch(l){case 0:for(r=0;u>r;r++){for(i=d,a=p,n=0;s>n;n++)t[r][n]&&(h[a]|=i),i>>=1,i||(i=128,a++);p+=c}break;case 2:for(r=0;u>r;r++){for(i=d,a=p,n=0;s>n;n++)t[r][n]&&(h[a]^=i),i>>=1,i||(i=128,a++);p+=c}break;default:f("JBIG2 error: operator "+l+" is not supported")}},onImmediateGenericRegion:function(e,t,r,n){var i=e.info,a=new o(t,r,n),s=h(e.mmr,i.width,i.height,e.template,e.prediction,null,e.at,a);this.drawBitmap(i,s)},onImmediateLosslessGenericRegion:function(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function(e,t,r,n,i,a){var s;e.huffman&&f("JBIG2 error: huffman is not supported");var u=this.symbols;u||(this.symbols=u={});for(var c=[],l=0,h=r.length;h>l;l++)c=c.concat(u[r[l]]);var d=new o(n,i,a);u[t]=p(e.huffman,e.refinement,c,e.numberOfNewSymbols,e.numberOfExportedSymbols,s,e.template,e.at,e.refinementTemplate,e.refinementAt,d)},onImmediateTextRegion:function(e,r,n,i,a){for(var s,u=e.info,c=this.symbols,f=[],l=0,h=r.length;h>l;l++)f=f.concat(c[r[l]]);var d=t(f.length),p=new o(n,i,a),m=g(e.huffman,e.refinement,u.width,u.height,e.defaultPixelValue,e.numberOfSymbolInstances,e.stripSize,f,d,e.transposed,e.dsOffset,e.referenceCorner,e.combinationOperator,s,e.refinementTemplate,e.refinementAt,p);this.drawBitmap(u,m)},onImmediateLosslessTextRegion:function(){this.onImmediateTextRegion.apply(this,arguments)}},k.prototype={parseChunks:function(e){return w(e)}},k}(),f=function(){throw console.error.apply(console,arguments),new Error("PDFJS error: "+arguments[0])},l=function(){console.warn.apply(console,arguments)},h=function(){console.info.apply(console,arguments)};c.prototype.parse=function(e){var t=0,r=e.length;151===e[t]&&74===e[t+1]&&66===e[t+2]&&50===e[t+3]&&13===e[t+4]&&10===e[t+5]&&26===e[t+6]&&10===e[t+7]||f("JBIG2 error: invalid header");var n={};t+=8;var a=e[t++];n.randomAccess=!(1&a),2&a||(n.numberOfPages=i(e,t),t+=4);for(var o=this.parseChunks([{data:e,start:t,end:r}]),s=o.currentPageInfo.width,u=o.currentPageInfo.height,c=o.buffer,e=new Uint8Array(s*u),l=0,h=0,d=0;u>d;d++)for(var p,g=0,m=0;s>m;m++)g||(g=128,p=c[h++]),e[l++]=p&g?0:255,g>>=1;this.width=s,this.height=u,this.data=e},e.JpegImage=o,e.JpxImage=u,e.Jbig2Image=c}(a||(a={}));var o=a.JpegImage,s=a.JpxImage,u=a.Jbig2Image},{}],5:[function(e,t,r){(function(e){"use strict";function r(t){return t instanceof ArrayBuffer?s(t):e.isBuffer(t)?t:t instanceof Uint8Array?new e(t):t}function n(t){return t instanceof ArrayBuffer?t:e.isBuffer(t)?o(t):t instanceof Uint8Array?o(t):t}function i(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):e.isBuffer(t)?new Uint8Array(t):t}function a(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):e.isBuffer(t)?t:t}function o(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n=0;a--)if(o[a]!=s[a])return!1;for(a=o.length-1;a>=0;a--)if(i=o[a],!u(e[i],t[i]))return!1;return!0}function l(e,t){return e&&t?"[object RegExp]"==Object.prototype.toString.call(t)?t.test(e):e instanceof t?!0:t.call({},e)===!0:!1}function h(e,t,r,n){var i;d.isString(r)&&(n=r,r=null);try{t()}catch(a){i=a}if(n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&o(i,r,"Missing expected exception"+n),!e&&l(i,r)&&o(i,r,"Got unwanted exception"+n),e&&i&&r&&!l(i,r)||!e&&i)throw i}var d=e("util/"),p=Array.prototype.slice,g=Object.prototype.hasOwnProperty,m=t.exports=s;m.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=a(this),this.generatedMessage=!0);var t=e.stackStartFunction||o;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=t.name,s=n.indexOf("\n"+i);if(s>=0){var u=n.indexOf("\n",s+1);n=n.substring(u+1)}this.stack=n}}},d.inherits(m.AssertionError,Error),m.fail=o,m.ok=s,m.equal=function(e,t,r){e!=t&&o(e,t,r,"==",m.equal)},m.notEqual=function(e,t,r){e==t&&o(e,t,r,"!=",m.notEqual)},m.deepEqual=function(e,t,r){u(e,t)||o(e,t,r,"deepEqual",m.deepEqual)},m.notDeepEqual=function(e,t,r){u(e,t)&&o(e,t,r,"notDeepEqual",m.notDeepEqual)},m.strictEqual=function(e,t,r){e!==t&&o(e,t,r,"===",m.strictEqual)},m.notStrictEqual=function(e,t,r){e===t&&o(e,t,r,"!==",m.notStrictEqual)},m["throws"]=function(e,t,r){h.apply(this,[!0].concat(p.call(arguments)))},m.doesNotThrow=function(e,t){h.apply(this,[!1].concat(p.call(arguments)))},m.ifError=function(e){if(e)throw e};var v=Object.keys||function(e){var t=[];for(var r in e)g.call(e,r)&&t.push(r);return t}},{"util/":59}],17:[function(e,t,r){"use strict";function n(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;r>t;++t)u[t]=e[t],c[e.charCodeAt(t)]=t;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63}function i(e){var t,r,n,i,a,o,s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===e[s-2]?2:"="===e[s-1]?1:0,o=new f(3*s/4-a),n=a>0?s-4:s;var u=0;for(t=0,r=0;n>t;t+=4,r+=3)i=c[e.charCodeAt(t)]<<18|c[e.charCodeAt(t+1)]<<12|c[e.charCodeAt(t+2)]<<6|c[e.charCodeAt(t+3)],o[u++]=i>>16&255,o[u++]=i>>8&255,o[u++]=255&i;return 2===a?(i=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,o[u++]=255&i):1===a&&(i=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,o[u++]=i>>8&255,o[u++]=255&i),o}function a(e){return u[e>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}function o(e,t,r){for(var n,i=[],o=t;r>o;o+=3)n=(e[o]<<16)+(e[o+1]<<8)+e[o+2],i.push(a(n));return i.join("")}function s(e){for(var t,r=e.length,n=r%3,i="",a=[],s=16383,c=0,f=r-n;f>c;c+=s)a.push(o(e,c,c+s>f?f:c+s));return 1===n?(t=e[r-1],i+=u[t>>2],i+=u[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=u[t>>10],i+=u[t>>4&63],i+=u[t<<2&63],i+="="),a.push(i),a.join("")}r.toByteArray=i,r.fromByteArray=s;var u=[],c=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],18:[function(e,t,r){},{}],19:[function(e,t,r){(function(t,n){function i(e){if(er.UNZIP)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function a(e,t){for(var r=0;rr.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBitsr.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.levelr.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevelr.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=r.Z_FILTERED&&e.strategy!=r.Z_HUFFMAN_ONLY&&e.strategy!=r.Z_RLE&&e.strategy!=r.Z_FIXED&&e.strategy!=r.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!n.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance"); -this._binding=new g.Zlib(t);var i=this;this._hadError=!1,this._binding.onerror=function(e,t){i._binding=null,i._hadError=!0;var n=new Error(e);n.errno=t,n.code=r.codes[t],i.emit("error",n)};var a=r.Z_DEFAULT_COMPRESSION;"number"==typeof e.level&&(a=e.level);var o=r.Z_DEFAULT_STRATEGY;"number"==typeof e.strategy&&(o=e.strategy),this._binding.init(e.windowBits||r.Z_DEFAULT_WINDOWBITS,a,e.memLevel||r.Z_DEFAULT_MEMLEVEL,o,e.dictionary),this._buffer=new n(this._chunkSize),this._offset=0,this._closed=!1,this._level=a,this._strategy=o,this.once("end",this.close)}var p=e("_stream_transform"),g=e("./binding"),m=e("util"),v=e("assert").ok;g.Z_MIN_WINDOWBITS=8,g.Z_MAX_WINDOWBITS=15,g.Z_DEFAULT_WINDOWBITS=15,g.Z_MIN_CHUNK=64,g.Z_MAX_CHUNK=1/0,g.Z_DEFAULT_CHUNK=16384,g.Z_MIN_MEMLEVEL=1,g.Z_MAX_MEMLEVEL=9,g.Z_DEFAULT_MEMLEVEL=8,g.Z_MIN_LEVEL=-1,g.Z_MAX_LEVEL=9,g.Z_DEFAULT_LEVEL=g.Z_DEFAULT_COMPRESSION,Object.keys(g).forEach(function(e){e.match(/^Z/)&&(r[e]=g[e])}),r.codes={Z_OK:g.Z_OK,Z_STREAM_END:g.Z_STREAM_END,Z_NEED_DICT:g.Z_NEED_DICT,Z_ERRNO:g.Z_ERRNO,Z_STREAM_ERROR:g.Z_STREAM_ERROR,Z_DATA_ERROR:g.Z_DATA_ERROR,Z_MEM_ERROR:g.Z_MEM_ERROR,Z_BUF_ERROR:g.Z_BUF_ERROR,Z_VERSION_ERROR:g.Z_VERSION_ERROR},Object.keys(r.codes).forEach(function(e){r.codes[r.codes[e]]=e}),r.Deflate=o,r.Inflate=s,r.Gzip=u,r.Gunzip=c,r.DeflateRaw=f,r.InflateRaw=l,r.Unzip=h,r.createDeflate=function(e){return new o(e)},r.createInflate=function(e){return new s(e)},r.createDeflateRaw=function(e){return new f(e)},r.createInflateRaw=function(e){return new l(e)},r.createGzip=function(e){return new u(e)},r.createGunzip=function(e){return new c(e)},r.createUnzip=function(e){return new h(e)},r.deflate=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new o(t),e,r)},r.deflateSync=function(e,t){return a(new o(t),e)},r.gzip=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new u(t),e,r)},r.gzipSync=function(e,t){return a(new u(t),e)},r.deflateRaw=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new f(t),e,r)},r.deflateRawSync=function(e,t){return a(new f(t),e)},r.unzip=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new h(t),e,r)},r.unzipSync=function(e,t){return a(new h(t),e)},r.inflate=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new s(t),e,r)},r.inflateSync=function(e,t){return a(new s(t),e)},r.gunzip=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new c(t),e,r)},r.gunzipSync=function(e,t){return a(new c(t),e)},r.inflateRaw=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new l(t),e,r)},r.inflateRawSync=function(e,t){return a(new l(t),e)},m.inherits(d,p),d.prototype.params=function(e,n,i){if(er.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(n!=r.Z_FILTERED&&n!=r.Z_HUFFMAN_ONLY&&n!=r.Z_RLE&&n!=r.Z_FIXED&&n!=r.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+n);if(this._level!==e||this._strategy!==n){var a=this;this.flush(g.Z_SYNC_FLUSH,function(){a._binding.params(e,n),a._hadError||(a._level=e,a._strategy=n,i&&i())})}else t.nextTick(i)},d.prototype.reset=function(){return this._binding.reset()},d.prototype._flush=function(e){this._transform(new n(0),"",e)},d.prototype.flush=function(e,r){var i=this._writableState;if(("function"==typeof e||void 0===e&&!r)&&(r=e,e=g.Z_FULL_FLUSH),i.ended)r&&t.nextTick(r);else if(i.ending)r&&this.once("end",r);else if(i.needDrain){var a=this;this.once("drain",function(){a.flush(r)})}else this._flushFlag=e,this.write(new n(0),"",r)},d.prototype.close=function(e){if(e&&t.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var r=this;t.nextTick(function(){r.emit("close")})}},d.prototype._transform=function(e,t,r){var i,a=this._writableState,o=a.ending||a.ended,s=o&&(!e||a.length===e.length);if(null===!e&&!n.isBuffer(e))return r(new Error("invalid input"));s?i=g.Z_FINISH:(i=this._flushFlag,e.length>=a.length&&(this._flushFlag=this._opts.flush||g.Z_NO_FLUSH));this._processChunk(e,i,r)},d.prototype._processChunk=function(e,t,r){function i(f,d){if(!u._hadError){var p=o-d;if(v(p>=0,"have should not go down"),p>0){var g=u._buffer.slice(u._offset,u._offset+p);u._offset+=p,c?u.push(g):(l.push(g),h+=g.length)}if((0===d||u._offset>=u._chunkSize)&&(o=u._chunkSize,u._offset=0,u._buffer=new n(u._chunkSize)),0===d){if(s+=a-f,a=f,!c)return!0;var m=u._binding.write(t,e,s,a,u._buffer,u._offset,u._chunkSize);return m.callback=i,void(m.buffer=e)}return c?void r():!1}}var a=e&&e.length,o=this._chunkSize-this._offset,s=0,u=this,c="function"==typeof r;if(!c){var f,l=[],h=0;this.on("error",function(e){f=e});do var d=this._binding.writeSync(t,e,s,a,this._buffer,this._offset,o);while(!this._hadError&&i(d[0],d[1]));if(this._hadError)throw f;var p=n.concat(l,h);return this.close(),p}var g=this._binding.write(t,e,s,a,this._buffer,this._offset,o);g.buffer=e,g.callback=i},m.inherits(o,d),m.inherits(s,d),m.inherits(u,d),m.inherits(c,d),m.inherits(f,d),m.inherits(l,d),m.inherits(h,d)}).call(this,e("_process"),e("buffer").Buffer)},{"./binding":19,_process:50,_stream_transform:55,assert:16,buffer:21,util:59}],21:[function(e,t,r){(function(t){"use strict";function n(){try{var e=new Uint8Array(1);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(t){return!1}}function i(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(i()=t?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}function f(e,t){if(u(t),e=a(e,0>t?0:0|g(t)),!o.TYPED_ARRAY_SUPPORT)for(var r=0;t>r;r++)e[r]=0;return e}function l(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!o.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|v(t,r);return e=a(e,n),e.write(t,r),e}function h(e,t){var r=0|g(t.length);e=a(e,r);for(var n=0;r>n;n+=1)e[n]=255&t[n];return e}function d(e,t,r,n){if(t.byteLength,0>r||t.byteLength=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function m(e){return+e!=e&&(e=0),o.alloc(+e)}function v(e,t){if(o.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":case void 0:return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(e).length;default:if(n)return G(e).length;t=(""+t).toLowerCase(),n=!0}}function _(e,t,r){var n=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),0>=r)return"";if(r>>>=0,t>>>=0,t>=r)return"";for(e||(e="utf8");;)switch(e){case"hex":return M(this,t,r);case"utf8":case"utf-8":return R(this,t,r);case"ascii":return T(this,t,r);case"binary":return L(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function b(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function y(e,t,r,n){function i(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var a=1,o=e.length,s=t.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,r/=2}for(var u=-1,c=0;o>r+c;c++)if(i(e,r+c)===i(t,-1===u?0:c-u)){if(-1===u&&(u=c),c-u+1===s)return(r+u)*a}else-1!==u&&(c-=c-u),u=-1;return-1}function w(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=t.length;if(a%2!==0)throw new Error("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;n>o;o++){var s=parseInt(t.substr(2*o,2),16);if(isNaN(s))return o;e[r+o]=s}return o}function x(e,t,r,n){return V(G(t,e.length-r),e,r,n)}function k(e,t,r,n){return V(H(t),e,r,n)}function E(e,t,r,n){return k(e,t,r,n)}function S(e,t,r,n){return V(W(t),e,r,n)}function A(e,t,r,n){return V(Y(t,e.length-r),e,r,n)}function I(e,t,r){return 0===t&&r===e.length?J.fromByteArray(e):J.fromByteArray(e.slice(t,r))}function R(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;r>i;){var a=e[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(r>=i+s){var u,c,f,l;switch(s){case 1:128>a&&(o=a);break;case 2:u=e[i+1],128===(192&u)&&(l=(31&a)<<6|63&u,l>127&&(o=l));break;case 3:u=e[i+1],c=e[i+2],128===(192&u)&&128===(192&c)&&(l=(15&a)<<12|(63&u)<<6|63&c,l>2047&&(55296>l||l>57343)&&(o=l));break;case 4:u=e[i+1],c=e[i+2],f=e[i+3],128===(192&u)&&128===(192&c)&&128===(192&f)&&(l=(15&a)<<18|(63&u)<<12|(63&c)<<6|63&f,l>65535&&1114112>l&&(o=l))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return P(n)}function P(e){var t=e.length;if(Q>=t)return String.fromCharCode.apply(String,e);for(var r="",n=0;t>n;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Q));return r}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)n+=String.fromCharCode(127&e[i]);return n}function L(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)n+=String.fromCharCode(e[i]);return n}function M(e,t,r){var n=e.length;(!t||0>t)&&(t=0),(!r||0>r||r>n)&&(r=n);for(var i="",a=t;r>a;a++)i+=q(e[a]);return i}function C(e,t,r){for(var n=e.slice(t,r),i="",a=0;ae)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,r,n,i,a){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||a>t)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function U(e,t,r,n){0>t&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-r,2);a>i;i++)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function B(e,t,r,n){0>t&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-r,4);a>i;i++)e[r+i]=t>>>8*(n?i:3-i)&255}function z(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("Index out of range")}function F(e,t,r,n,i){return i||z(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(e,t,r,n,23,4),r+4}function j(e,t,r,n,i){return i||z(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(e,t,r,n,52,8),r+8}function N(e){if(e=Z(e).replace(ee,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function Z(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function q(e){return 16>e?"0"+e.toString(16):e.toString(16)}function G(e,t){t=t||1/0;for(var r,n=e.length,i=null,a=[],o=0;n>o;o++){if(r=e.charCodeAt(o),r>55295&&57344>r){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(56320>r){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,128>r){if((t-=1)<0)break;a.push(r)}else if(2048>r){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(65536>r){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function H(e){for(var t=[],r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function W(e){return J.toByteArray(N(e))}function V(e,t,r,n){for(var i=0;n>i&&!(i+r>=t.length||i>=e.length);i++)t[i+r]=e[i];return i}function X(e){return e!==e}var J=e("base64-js"),K=e("ieee754"),$=e("isarray");r.Buffer=o,r.SlowBuffer=m,r.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:n(),r.kMaxLength=i(),o.poolSize=8192,o._augment=function(e){return e.__proto__=o.prototype,e},o.from=function(e,t,r){return s(null,e,t,r)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(e,t,r){return c(null,e,t,r)},o.allocUnsafe=function(e){return f(null,e)},o.allocUnsafeSlow=function(e){return f(null,e)},o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);a>i;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return n>r?-1:r>n?1:0},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!$(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);var r;if(void 0===t)for(t=0,r=0;rt;t+=2)b(this,t,t+1);return this},o.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;e>t;t+=4)b(this,t,t+3),b(this,t+1,t+2);return this},o.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?R(this,0,e):_.apply(this,arguments)},o.prototype.equals=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:0===o.compare(this,e)},o.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},o.prototype.compare=function(e,t,r,n,i){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),0>t||r>e.length||0>n||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var a=i-n,s=r-t,u=Math.min(a,s),c=this.slice(n,i),f=e.slice(t,r),l=0;u>l;++l)if(c[l]!==f[l]){a=c[l],s=f[l];break}return s>a?-1:a>s?1:0},o.prototype.indexOf=function(e,t,r){if("string"==typeof t?(r=t,t=0):t>2147483647?t=2147483647:-2147483648>t&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(0>t&&(t=Math.max(this.length+t,0)),"string"==typeof e&&(e=o.from(e,r)),o.isBuffer(e))return 0===e.length?-1:y(this,e,t,r);if("number"==typeof e)return o.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):y(this,[e],t,r);throw new TypeError("val must be string, number or Buffer")},o.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},o.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t=0|t,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(0>r||0>t)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return x(this,e,t,r);case"ascii":return k(this,e,t,r);case"binary":return E(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;o.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),e>t&&(t=e);var n;if(o.TYPED_ARRAY_SUPPORT)n=this.subarray(e,t),n.__proto__=o.prototype;else{var i=t-e;n=new o(i,void 0);for(var a=0;i>a;a++)n[a]=this[a+e]}return n},o.prototype.readUIntLE=function(e,t,r){e=0|e,t=0|t,r||O(e,t,this.length);for(var n=this[e],i=1,a=0;++a0&&(i*=256);)n+=this[e+--t]*i;return n},o.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,r){e=0|e,t=0|t,r||O(e,t,this.length);for(var n=this[e],i=1,a=0;++a=i&&(n-=Math.pow(2,8*t)),n},o.prototype.readIntBE=function(e,t,r){e=0|e,t=0|t,r||O(e,t,this.length);for(var n=t,i=1,a=this[e+--n];n>0&&(i*=256);)a+=this[e+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*t)),a},o.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt32LE=function(e,t){return t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return t||O(e,4,this.length),K.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),K.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),K.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),K.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t=0|t,r=0|r,!n){var i=Math.pow(2,8*r)-1;D(this,e,t,r,i,0)}var a=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+a]=e/o&255;return t+r},o.prototype.writeUInt8=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):B(this,e,t,!0),t+4},o.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},o.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t=0|t,!n){var i=Math.pow(2,8*r-1);D(this,e,t,r,i-1,-i)}var a=0,o=1,s=0;for(this[t]=255&e;++ae&&0===s&&0!==this[t+a-1]&&(s=1),this[t+a]=(e/o>>0)-s&255;return t+r},o.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t=0|t,!n){var i=Math.pow(2,8*r-1);D(this,e,t,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[t+a]=255&e;--a>=0&&(o*=256);)0>e&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(e/o>>0)-s&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):B(this,e,t,!0),t+4},o.prototype.writeInt32BE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},o.prototype.writeFloatLE=function(e,t,r){return F(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return F(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return j(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return j(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-tr&&n>t)for(i=a-1;i>=0;i--)e[i+t]=this[i+r];else if(1e3>a||!o.TYPED_ARRAY_SUPPORT)for(i=0;a>i;i++)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+a),t);return a},o.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);256>i&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e=255&e);if(0>t||this.length=r)return this;t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var a;if("number"==typeof e)for(a=t;r>a;a++)this[a]=e;else{var s=o.isBuffer(e)?e:G(new o(e,n).toString()),u=s.length;for(a=0;r-t>a;a++)this[a+t]=s[a%u]}return this};var ee=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":17,ieee754:26,isarray:30}],22:[function(e,t,r){(function(e){function t(e){return Array.isArray?Array.isArray(e):"[object Array]"===m(e)}function n(e){return"boolean"==typeof e}function i(e){return null===e}function a(e){return null==e}function o(e){return"number"==typeof e}function s(e){return"string"==typeof e}function u(e){return"symbol"==typeof e}function c(e){return void 0===e}function f(e){return"[object RegExp]"===m(e)}function l(e){return"object"==typeof e&&null!==e}function h(e){return"[object Date]"===m(e)}function d(e){return"[object Error]"===m(e)||e instanceof Error}function p(e){return"function"==typeof e}function g(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function m(e){return Object.prototype.toString.call(e)}r.isArray=t,r.isBoolean=n,r.isNull=i,r.isNullOrUndefined=a,r.isNumber=o,r.isString=s,r.isSymbol=u,r.isUndefined=c,r.isRegExp=f,r.isObject=l,r.isDate=h,r.isError=d,r.isFunction=p,r.isPrimitive=g,r.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":29}],23:[function(e,t,r){function n(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function i(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff),!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0,a=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(a=i))}),e.splice(a,0,n),e}function a(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function o(e){try{null==e?r.storage.removeItem("debug"):r.storage.debug=e}catch(t){}}function s(){var e;try{e=r.storage.debug}catch(t){}return e}function u(){try{return window.localStorage}catch(e){}}r=t.exports=e("./debug"),r.log=a,r.formatArgs=i,r.save=o,r.load=s,r.useColors=n,r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(e){return JSON.stringify(e)},r.enable(s())},{"./debug":24}],24:[function(e,t,r){function n(){return r.colors[f++%r.colors.length]}function i(e){function t(){}function i(){var e=i,t=+new Date,a=t-(c||t);e.diff=a,e.prev=c,e.curr=t,c=t,null==e.useColors&&(e.useColors=r.useColors()),null==e.color&&e.useColors&&(e.color=n());var o=Array.prototype.slice.call(arguments);o[0]=r.coerce(o[0]),"string"!=typeof o[0]&&(o=["%o"].concat(o));var s=0;o[0]=o[0].replace(/%([a-z%])/g,function(t,n){if("%%"===t)return t;s++;var i=r.formatters[n];if("function"==typeof i){var a=o[s];t=i.call(e,a),o.splice(s,1),s--}return t}),"function"==typeof r.formatArgs&&(o=r.formatArgs.apply(e,o));var u=i.log||r.log||console.log.bind(console);u.apply(e,o)}t.enabled=!1,i.enabled=!0;var a=r.enabled(e)?i:t;return a.namespace=e,a}function a(e){r.save(e);for(var t=(e||"").split(/[\s,]+/),n=t.length,i=0;n>i;i++)t[i]&&(e=t[i].replace(/\*/g,".*?"),"-"===e[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")))}function o(){r.enable("")}function s(e){var t,n;for(t=0,n=r.skips.length;n>t;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;n>t;t++)if(r.names[t].test(e))return!0;return!1}function u(e){return e instanceof Error?e.stack||e.message:e}r=t.exports=i,r.coerce=u,r.disable=o,r.enable=a,r.enabled=s,r.humanize=e("ms"),r.names=[],r.skips=[],r.formatters={};var c,f=0},{ms:37}],25:[function(e,t,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function a(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!a(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,r,n,a,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[e],s(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,u=0;n>u;u++)c[u].apply(this,a);return!0},n.prototype.addListener=function(e,t){var r;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(r=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var n=!1;return r.listener=t,this.on(e,r),this},n.prototype.removeListener=function(e,t){var r,n,a,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],a=r.length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],i(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],26:[function(e,t,r){r.read=function(e,t,r,n,i){var a,o,s=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];for(l+=h,a=d&(1<<-f)-1,d>>=-f,f+=s;f>0;a=256*a+e[t+l],l+=h,f-=8);for(o=a&(1<<-f)-1,a>>=-f,f+=n;f>0;o=256*o+e[t+l],l+=h,f-=8);if(0===a)a=1-c;else{if(a===u)return o?NaN:(d?-1:1)*(1/0);o+=Math.pow(2,n),a-=c}return(d?-1:1)*o*Math.pow(2,a-n)},r.write=function(e,t,r,n,i,a){ -var o,s,u,c=8*a-i-1,f=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:a-1,p=n?1:-1,g=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=f):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),t+=o+l>=1?h/u:h*Math.pow(2,1-l),t*u>=2&&(o++,u/=2),o+l>=f?(s=0,o=f):o+l>=1?(s=(t*u-1)*Math.pow(2,i),o+=l):(s=t*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(o=o<0;e[r+d]=255&o,d+=p,o/=256,c-=8);e[r+d-p]|=128*g}},{}],27:[function(e,t,r){(function(r){function n(e,t,r){if(e.readUInt32)return e.readUInt32(t,r);var n;if(r){if(e.readUInt32BE)return e.readUInt32BE(t);n=(e[t]<<24)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]}else{if(e.readUInt32LE)return e.readUInt32LE(t);n=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24)}return n}function i(e,t,r){if(e.readUInt16)return e.readUInt16(t,r);var n;if(r){if(e.readUInt16BE)return e.readUInt16BE(t);n=(e[t]<<8)+e[t+1]}else{if(e.readUInt16LE)return e.readUInt16LE(t);n=e[t]+(e[t+1]<<8)}return n}function a(e,t,r){r>7&&(t+=Math.floor(r/8),r%=8);var n=e[t];7>r&&(n>>>=7-r);var i=1&n;return i}function o(e,t,n,i,o){var s=0,u=!1;o&&(a(e,t,n)>0&&(u=!0),i--,n++);for(var c=[],f=0;i>f;f++){var l=a(e,t,n+f);f>0&&(i-f)%8==0&&(c.push(s),s=0),s<<=1,s|=l}return c.push(s),s=new r(c),s.negative=!!u,s}function s(e){var t=[73,72,68,82],r=12;return l(e,r,t)?(r+=4,{type:"image",format:"PNG",mimeType:"image/png",width:n(e,r,!0),height:n(e,r+4,!0)}):!1}function u(e){for(var t=2,r=e.length,n=[255,[192,194]];r>t;){if(l(e,t,n))return t+=5,{type:"image",format:"JPG",mimeType:"image/jpeg",width:i(e,t+2,!0),height:i(e,t,!0)};t+=2;var a=i(e,t,!0);t+=a}}function c(e){var t=6;return{type:"image",format:"GIF",mimeType:"image/gif",width:i(e,t,!1),height:i(e,t+2,!1)}}function f(t){var r,n=8,a=0;if(67===t[0])try{t=e("zlib").inflate(t.slice(8,100)),n=0}catch(s){return{type:"flash",format:"SWF",mimeType:"application/x-shockwave-flash",width:null,height:null}}var u=o(t,n,a,5)[0];a+=5,r=o(t,n,a,u,!0);var c=(u>9?i(r,0,!0):r[0])*(r.negative?-1:1);a+=u,r=o(t,n,a,u,!0);var f=(u>9?i(r,0,!0):r[0])*(r.negative?-1:1);a+=u,r=o(t,n,a,u,!0);var l=(u>9?i(r,0,!0):r[0])*(r.negative?-1:1);a+=u,r=o(t,n,a,u,!0);var h=(u>9?i(r,0,!0):r[0])*(r.negative?-1:1);return{type:"flash",format:"SWF",mimeType:"application/x-shockwave-flash",width:Math.ceil((f-c)/20),height:Math.ceil((h-l)/20)}}function l(e,t,r){for(var n=r.length,i=0;n>i;i++){var a=e[i+t],o=r[i],s=!1;if("number"==typeof o)s=o===a;else for(var u in o){var c=o[u];c===a&&(s=!0)}if(!s)return!1}return!0}t.exports=function(e,t){var r=[137,80,78,71,13,10,26,10],n=[255,216,255],i=[71,73,70,56,[55,57],97],a=[[70,67],87,83];return l(e,0,r)?s(e):l(e,0,n)?u(e):l(e,0,i)?c(e):l(e,0,a)?f(e):!1}}).call(this,e("buffer").Buffer)},{buffer:21,zlib:20}],28:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],29:[function(e,t,r){t.exports=function(e){return!(null==e||!(e._isBuffer||e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)))}},{}],30:[function(e,t,r){var n={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],31:[function(e,t,r){function n(e,t){for(var r=-1,n=Array(e);++r-1&&e%1==0&&t>e}function a(e,t){return e&&U(e,t,x)}function o(e,t){return T.call(e,t)||"object"==typeof e&&t in e&&null===l(e)}function s(e){return O(Object(e))}function u(e){return function(t){return null==t?void 0:t[e]}}function c(e,t){return function(r,n){if(null==r)return r;if(!g(r))return e(r,n);for(var i=r.length,a=t?i:-1,o=Object(r);(t?a--:++a-1&&e%1==0&&k>=e}function b(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function y(e){return!!e&&"object"==typeof e}function w(e){return"string"==typeof e||!z(e)&&y(e)&&L.call(e)==I}function x(e){var t=d(e);if(!t&&!g(e))return s(e);var r=h(e),n=!!r,a=r||[],u=a.length;for(var c in e)!o(e,c)||n&&("length"==c||i(c,u))||t&&"constructor"==c||a.push(c);return a}var k=9007199254740991,E="[object Arguments]",S="[object Function]",A="[object GeneratorFunction]",I="[object String]",R=/^(?:0|[1-9]\d*)$/,P=Object.prototype,T=P.hasOwnProperty,L=P.toString,M=P.propertyIsEnumerable,C=Object.getPrototypeOf,O=Object.keys,D=c(a),U=f(),B=u("length"),z=Array.isArray;t.exports=D},{}],32:[function(e,t,r){function n(e,t,r,n){var i;return r(e,function(e,r,a){return t(e,r,a)?(i=n?r:e,!1):void 0}),i}t.exports=n},{}],33:[function(e,t,r){function n(e,t,r){for(var n=e.length,i=r?n:-1;r?i--:++i-1&&e%1==0&&t>e}function l(e){var t=-1,r=Array(e.size);return e.forEach(function(e,n){r[++t]=[n,e]}),r}function h(e){var t=-1,r=Array(e.size);return e.forEach(function(e){r[++t]=e}),r}function d(){}function p(e,t){return m(e,t)&&delete e[t]}function g(e,t){if(Bt){var r=e[t];return r===Pe?void 0:r}return kt.call(e,t)?e[t]:void 0}function m(e,t){return Bt?void 0!==e[t]:kt.call(e,t)}function v(e,t,r){e[t]=Bt&&void 0===r?Pe:r}function _(e){var t=-1,r=e?e.length:0;for(this.clear();++tr)return!1;var n=e.length-1;return r==n?e.pop():Pt.call(e,r,1),!0}function L(e,t){var r=C(e,t);return 0>r?void 0:e[r][1]}function M(e,t){return C(e,t)>-1}function C(e,t){for(var r=e.length;r--;)if(ce(e[r][0],t))return r;return-1}function O(e,t,r){var n=C(e,t);0>n?e.push([t,r]):e[n][1]=r}function D(e){return Yt(e)?e:Ie(e)}function U(e,t){t=ne(t,e)?[t]:D(t);for(var r=0,n=t.length;null!=e&&n>r;)e=e[t[r++]];return r&&r==n?e:void 0}function B(e,t){return kt.call(e,t)||"object"==typeof e&&t in e&&null===Q(e)}function z(e,t){return t in Object(e)}function F(e,t,r,n,i){return e===t?!0:null==e||null==t||!ge(e)&&!me(t)?e!==e&&t!==t:j(e,t,F,r,n,i)}function j(e,t,r,n,i,a){var o=Yt(e),s=Yt(t),u=Oe,f=Oe;o||(u=ee(e),u=u==Ce?Ze:u),s||(f=ee(t),f=f==Ce?Ze:f);var l=u==Ze&&!c(e),h=f==Ze&&!c(t),d=u==f;if(d&&!l)return a||(a=new E),o||ye(e)?V(e,t,r,n,i,a):X(e,t,u,r,n,i,a);if(!(i&Le)){var p=l&&kt.call(e,"__wrapped__"),g=h&&kt.call(t,"__wrapped__");if(p||g){var m=p?e.value():e,v=g?t.value():t;return a||(a=new E),r(m,v,n,i,a)}}return d?(a||(a=new E),J(e,t,r,n,i,a)):!1}function N(e,t,r,n){var i=r.length,a=i,o=!n;if(null==e)return!a;for(e=Object(e);i--;){var s=r[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++if))return!1;var h=o.get(e);if(h)return h==t;var d=!0;for(o.set(e,t);++s-1&&e%1==0&&Me>=e}function ge(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function me(e){return!!e&&"object"==typeof e}function ve(e){if(!ge(e))return!1;var t=de(e)||c(e)?St:ct;return t.test(ue(e))}function _e(e){return"string"==typeof e||!Yt(e)&&me(e)&&Et.call(e)==Ye}function be(e){return"symbol"==typeof e||me(e)&&Et.call(e)==We}function ye(e){return me(e)&&pe(e.length)&&!!lt[Et.call(e)]}function we(e,t,r){var n=null==e?void 0:U(e,t);return void 0===n?r:n}function xe(e,t){return null!=e&&te(e,t,z)}function ke(e){var t=ae(e);if(!t&&!le(e))return q(e);var r=re(e),n=!!r,i=r||[],a=i.length;for(var o in e)!B(e,o)||n&&("length"==o||f(o,a))||t&&"constructor"==o||i.push(o);return i}function Ee(e){return s(e,ke(e))}function Se(e){return e}function Ae(e){return ne(e)?Y(e):W(e)}var Ie=e("lodash._stringtopath"),Re=200,Pe="__lodash_hash_undefined__",Te=1,Le=2,Me=9007199254740991,Ce="[object Arguments]",Oe="[object Array]",De="[object Boolean]",Ue="[object Date]",Be="[object Error]",ze="[object Function]",Fe="[object GeneratorFunction]",je="[object Map]",Ne="[object Number]",Ze="[object Object]",qe="[object Promise]",Ge="[object RegExp]",He="[object Set]",Ye="[object String]",We="[object Symbol]",Ve="[object WeakMap]",Xe="[object ArrayBuffer]",Je="[object DataView]",Ke="[object Float32Array]",$e="[object Float64Array]",Qe="[object Int8Array]",et="[object Int16Array]",tt="[object Int32Array]",rt="[object Uint8Array]",nt="[object Uint8ClampedArray]",it="[object Uint16Array]",at="[object Uint32Array]",ot=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,st=/^\w*$/,ut=/[\\^$.*+?()[\]{}|]/g,ct=/^\[object .+?Constructor\]$/,ft=/^(?:0|[1-9]\d*)$/,lt={};lt[Ke]=lt[$e]=lt[Qe]=lt[et]=lt[tt]=lt[rt]=lt[nt]=lt[it]=lt[at]=!0,lt[Ce]=lt[Oe]=lt[Xe]=lt[De]=lt[Je]=lt[Ue]=lt[Be]=lt[ze]=lt[je]=lt[Ne]=lt[Ze]=lt[Ge]=lt[He]=lt[Ye]=lt[Ve]=!1;var ht={"function":!0,object:!0},dt=ht[typeof r]&&r&&!r.nodeType?r:void 0,pt=ht[typeof t]&&t&&!t.nodeType?t:void 0,gt=u(dt&&pt&&"object"==typeof n&&n),mt=u(ht[typeof self]&&self),vt=u(ht[typeof window]&&window),_t=u(ht[typeof this]&&this),bt=gt||vt!==(_t&&_t.window)&&vt||mt||_t||Function("return this")(),yt=Array.prototype,wt=Object.prototype,xt=Function.prototype.toString,kt=wt.hasOwnProperty,Et=wt.toString,St=RegExp("^"+xt.call(kt).replace(ut,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),At=bt.Symbol,It=bt.Uint8Array,Rt=wt.propertyIsEnumerable,Pt=yt.splice,Tt=Object.getPrototypeOf,Lt=Object.keys,Mt=$(bt,"DataView"),Ct=$(bt,"Map"),Ot=$(bt,"Promise"),Dt=$(bt,"Set"),Ut=$(bt,"WeakMap"),Bt=$(Object,"create"),zt=ue(Mt),Ft=ue(Ct),jt=ue(Ot),Nt=ue(Dt),Zt=ue(Ut),qt=At?At.prototype:void 0,Gt=qt?qt.valueOf:void 0;d.prototype=Bt?Bt(null):wt,_.prototype.clear=b,_.prototype["delete"]=y,_.prototype.get=w,_.prototype.has=x,_.prototype.set=k,E.prototype.clear=S,E.prototype["delete"]=A,E.prototype.get=I,E.prototype.has=R,E.prototype.set=P;var Ht=Y("length");(Mt&&ee(new Mt(new ArrayBuffer(1)))!=Je||Ct&&ee(new Ct)!=je||Ot&&ee(Ot.resolve())!=qe||Dt&&ee(new Dt)!=He||Ut&&ee(new Ut)!=Ve)&&(ee=function(e){var t=Et.call(e),r=t==Ze?e.constructor:void 0,n=r?ue(r):void 0;if(n)switch(n){case zt:return Je;case Ft:return je;case jt:return qe;case Nt:return He;case Zt:return Ve}return t});var Yt=Array.isArray;t.exports=Z}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"lodash._stringtopath":35}],35:[function(e,t,r){(function(e){function n(e){return e&&e.Object===Object?e:null}function i(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(r){}return t}function a(){}function o(e,t){return u(e,t)&&delete e[t]}function s(e,t){if(ae){var r=e[t];return r===C?void 0:r}return Q.call(e,t)?e[t]:void 0}function u(e,t){return ae?void 0!==e[t]:Q.call(e,t)}function c(e,t,r){e[t]=ae&&void 0===r?C:r}function f(e){var t=-1,r=e?e.length:0;for(this.clear();++tr)return!1;var n=e.length-1;return r==n?e.pop():ne.call(e,r,1),!0}function v(e,t){var r=b(e,t);return 0>r?void 0:e[r][1]}function _(e,t){return b(e,t)>-1}function b(e,t){for(var r=e.length;r--;)if(S(e[r][0],t))return r;return-1}function y(e,t,r){var n=b(e,t);0>n?e.push([t,r]):e[n][1]=r}function w(e,t){var r=e[t];return P(r)?r:void 0}function x(e){var t=typeof e;return"number"==t||"boolean"==t||"string"==t&&"__proto__"!=e||null==e}function k(e){if(null!=e){try{return $.call(e)}catch(t){}try{return e+""}catch(t){}}return""}function E(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(M);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var o=e.apply(this,n);return r.cache=a.set(i,o),o};return r.cache=new(E.Cache||f),r}function S(e,t){return e===t||e!==e&&t!==t}function A(e){var t=I(e)?ee.call(e):"";return t==D||t==U}function I(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function R(e){return!!e&&"object"==typeof e}function P(e){if(!I(e))return!1;var t=A(e)||i(e)?te:N;return t.test(k(e))}function T(e){return"symbol"==typeof e||R(e)&&ee.call(e)==B}function L(e){if("string"==typeof e)return e;if(null==e)return"";if(T(e))return se?se.call(e):"";var t=e+"";return"0"==t&&1/e==-O?"-0":t}var M="Expected a function",C="__lodash_hash_undefined__",O=1/0,D="[object Function]",U="[object GeneratorFunction]",B="[object Symbol]",z=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g,F=/[\\^$.*+?()[\]{}|]/g,j=/\\(\\)?/g,N=/^\[object .+?Constructor\]$/,Z={"function":!0,object:!0},q=Z[typeof r]&&r&&!r.nodeType?r:void 0,G=Z[typeof t]&&t&&!t.nodeType?t:void 0,H=n(q&&G&&"object"==typeof e&&e),Y=n(Z[typeof self]&&self),W=n(Z[typeof window]&&window),V=n(Z[typeof this]&&this),X=H||W!==(V&&V.window)&&W||Y||V||Function("return this")(),J=Array.prototype,K=Object.prototype,$=Function.prototype.toString,Q=K.hasOwnProperty,ee=K.toString,te=RegExp("^"+$.call(Q).replace(F,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=X.Symbol,ne=J.splice,ie=w(X,"Map"),ae=w(Object,"create"),oe=re?re.prototype:void 0,se=oe?oe.toString:void 0;a.prototype=ae?ae(null):K,f.prototype.clear=l,f.prototype["delete"]=h,f.prototype.get=d,f.prototype.has=p,f.prototype.set=g;var ue=E(function(e){var t=[];return L(e).replace(z,function(e,r,n,i){t.push(n?i.replace(j,"$1"):r||e)}),t});E.Cache=f,t.exports=ue}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],36:[function(e,t,r){function n(e,t){if(t=s(t,3),u(e)){var r=o(e,t);return r>-1?e[r]:void 0}return a(e,t,i)}var i=e("lodash._baseeach"),a=e("lodash._basefind"),o=e("lodash._basefindindex"),s=e("lodash._baseiteratee"),u=Array.isArray;t.exports=n},{"lodash._baseeach":31,"lodash._basefind":32,"lodash._basefindindex":33,"lodash._baseiteratee":34}],37:[function(e,t,r){function n(e){if(e=""+e,!(e.length>1e4)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*l;case"days":case"day":case"d":return r*f;case"hours":case"hour":case"hrs":case"hr":case"h":return r*c;case"minutes":case"minute":case"mins":case"min":case"m":return r*u;case"seconds":case"second":case"secs":case"sec":case"s":return r*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}}}function i(e){return e>=f?Math.round(e/f)+"d":e>=c?Math.round(e/c)+"h":e>=u?Math.round(e/u)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function a(e){return o(e,f,"day")||o(e,c,"hour")||o(e,u,"minute")||o(e,s,"second")||e+" ms"}function o(e,t,r){return t>e?void 0:1.5*t>e?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}var s=1e3,u=60*s,c=60*u,f=24*c,l=365.25*f;t.exports=function(e,t){return t=t||{},"string"==typeof e?n(e):t["long"]?a(e):i(e)}},{}],38:[function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;r.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])}}return e},r.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)return void e.set(t.subarray(r,r+n),i);for(var a=0;n>a;a++)e[i+a]=t[r+a]},flattenChunks:function(e){var t,r,n,i,a,o;for(n=0,t=0,r=e.length;r>t;t++)n+=e[t].length;for(o=new Uint8Array(n),i=0,t=0,r=e.length;r>t;t++)a=e[t],o.set(a,i),i+=a.length;return o}},a={arraySet:function(e,t,r,n,i){for(var a=0;n>a;a++)e[i+a]=t[r+a]},flattenChunks:function(e){return[].concat.apply([],e)}};r.setTyped=function(e){e?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,i)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,a))},r.setTyped(n)},{}],39:[function(e,t,r){"use strict";function n(e,t,r,n){for(var i=65535&e|0,a=e>>>16&65535|0,o=0;0!==r;){o=r>2e3?2e3:r,r-=o;do i=i+t[n++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0}t.exports=n},{}],40:[function(e,t,r){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],41:[function(e,t,r){"use strict";function n(){for(var e,t=[],r=0;256>r;r++){e=r;for(var n=0;8>n;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}function i(e,t,r,n){var i=a,o=n+r;e=-1^e;for(var s=n;o>s;s++)e=e>>>8^i[255&(e^t[s])];return-1^e}var a=n();t.exports=i},{}],42:[function(e,t,r){"use strict";function n(e,t){return e.msg=M[t],t}function i(e){return(e<<1)-(e>4?9:0)}function a(e){for(var t=e.length;--t>=0;)e[t]=0}function o(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(R.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function s(e,t){P._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,o(e.strm)}function u(e,t){e.pending_buf[e.pending++]=t}function c(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function f(e,t,r,n){var i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,R.arraySet(t,e.input,e.next_in,i,r),1===e.state.wrap?e.adler=T(e.adler,t,i,r):2===e.state.wrap&&(e.adler=L(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)}function l(e,t){var r,n,i=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match,u=e.strstart>e.w_size-ce?e.strstart-(e.w_size-ce):0,c=e.window,f=e.w_mask,l=e.prev,h=e.strstart+ue,d=c[a+o-1],p=c[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do if(r=t,c[r+o]===p&&c[r+o-1]===d&&c[r]===c[a]&&c[++r]===c[a+1]){a+=2,r++;do;while(c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&h>a);if(n=ue-(h-a),a=h-ue,n>o){if(e.match_start=t,o=n,n>=s)break;d=c[a+o-1],p=c[a+o]}}while((t=l[t&f])>u&&0!==--i);return o<=e.lookahead?o:e.lookahead}function h(e){var t,r,n,i,a,o=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=o+(o-ce)){R.arraySet(e.window,e.window,o,o,0),e.match_start-=o,e.strstart-=o,e.block_start-=o,r=e.hash_size,t=r;do n=e.head[--t],e.head[t]=n>=o?n-o:0;while(--r);r=o,t=r;do n=e.prev[--t],e.prev[t]=n>=o?n-o:0;while(--r);i+=o}if(0===e.strm.avail_in)break;if(r=f(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=se)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(h(e),0===e.lookahead&&t===C)return _e;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,s(e,!1),0===e.strm.avail_out))return _e;if(e.strstart-e.block_start>=e.w_size-ce&&(s(e,!1),0===e.strm.avail_out))return _e}return e.insert=0,t===U?(s(e,!0),0===e.strm.avail_out?ye:we):e.strstart>e.block_start&&(s(e,!1),0===e.strm.avail_out)?_e:_e}function p(e,t){for(var r,n;;){if(e.lookahead=se&&(e.ins_h=(e.ins_h<=se)if(n=P._tr_tally(e,e.strstart-e.match_start,e.match_length-se),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=se){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=se&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=se-1)),e.prev_length>=se&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-se,n=P._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-se),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=(e.ins_h<=se&&e.strstart>0&&(i=e.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){a=e.strstart+ue;do;while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&a>i);e.match_length=ue-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=se?(r=P._tr_tally(e,1,e.match_length-se),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=P._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(s(e,!1),0===e.strm.avail_out))return _e}return e.insert=0,t===U?(s(e,!0),0===e.strm.avail_out?ye:we):e.last_lit&&(s(e,!1),0===e.strm.avail_out)?_e:be}function v(e,t){for(var r;;){if(0===e.lookahead&&(h(e),0===e.lookahead)){if(t===C)return _e;break}if(e.match_length=0,r=P._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(s(e,!1),0===e.strm.avail_out))return _e}return e.insert=0,t===U?(s(e,!0),0===e.strm.avail_out?ye:we):e.last_lit&&(s(e,!1),0===e.strm.avail_out)?_e:be}function _(e){e.window_size=2*e.w_size,a(e.head),e.max_lazy_match=I[e.level].max_lazy,e.good_match=I[e.level].good_length,e.nice_match=I[e.level].nice_length,e.max_chain_length=I[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=se-1,e.match_available=0,e.ins_h=0}function b(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=J,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new R.Buf16(2*ae),this.dyn_dtree=new R.Buf16(2*(2*ne+1)),this.bl_tree=new R.Buf16(2*(2*ie+1)),a(this.dyn_ltree),a(this.dyn_dtree),a(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new R.Buf16(oe+1),this.heap=new R.Buf16(2*re+1),a(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new R.Buf16(2*re+1),a(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function y(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=X,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?le:me,e.adler=2===t.wrap?0:1,t.last_flush=C,P._tr_init(t),z):n(e,j)}function w(e){var t=y(e);return t===z&&_(e.state),t}function x(e,t){return e&&e.state?2!==e.state.wrap?j:(e.state.gzhead=t,z):j}function k(e,t,r,i,a,o){if(!e)return j;var s=1;if(t===q&&(t=6),0>i?(s=0,i=-i):i>15&&(s=2,i-=16),1>a||a>K||r!==J||8>i||i>15||0>t||t>9||0>o||o>W)return n(e,j);8===i&&(i=9);var u=new b;return e.state=u,u.strm=e,u.wrap=s,u.gzhead=null,u.w_bits=i,u.w_size=1<>1,u.l_buf=3*u.lit_bufsize,u.level=t,u.strategy=o,u.method=r,w(e)}function E(e,t){return k(e,t,J,$,Q,V)}function S(e,t){var r,s,f,l; -if(!e||!e.state||t>B||0>t)return e?n(e,j):j;if(s=e.state,!e.output||!e.input&&0!==e.avail_in||s.status===ve&&t!==U)return n(e,0===e.avail_out?Z:j);if(s.strm=e,r=s.last_flush,s.last_flush=t,s.status===le)if(2===s.wrap)e.adler=0,u(s,31),u(s,139),u(s,8),s.gzhead?(u(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),u(s,255&s.gzhead.time),u(s,s.gzhead.time>>8&255),u(s,s.gzhead.time>>16&255),u(s,s.gzhead.time>>24&255),u(s,9===s.level?2:s.strategy>=H||s.level<2?4:0),u(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(u(s,255&s.gzhead.extra.length),u(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=L(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=he):(u(s,0),u(s,0),u(s,0),u(s,0),u(s,0),u(s,9===s.level?2:s.strategy>=H||s.level<2?4:0),u(s,xe),s.status=me);else{var h=J+(s.w_bits-8<<4)<<8,d=-1;d=s.strategy>=H||s.level<2?0:s.level<6?1:6===s.level?2:3,h|=d<<6,0!==s.strstart&&(h|=fe),h+=31-h%31,s.status=me,c(s,h),0!==s.strstart&&(c(s,e.adler>>>16),c(s,65535&e.adler)),e.adler=1}if(s.status===he)if(s.gzhead.extra){for(f=s.pending;s.gzindex<(65535&s.gzhead.extra.length)&&(s.pending!==s.pending_buf_size||(s.gzhead.hcrc&&s.pending>f&&(e.adler=L(e.adler,s.pending_buf,s.pending-f,f)),o(e),f=s.pending,s.pending!==s.pending_buf_size));)u(s,255&s.gzhead.extra[s.gzindex]),s.gzindex++;s.gzhead.hcrc&&s.pending>f&&(e.adler=L(e.adler,s.pending_buf,s.pending-f,f)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=de)}else s.status=de;if(s.status===de)if(s.gzhead.name){f=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>f&&(e.adler=L(e.adler,s.pending_buf,s.pending-f,f)),o(e),f=s.pending,s.pending===s.pending_buf_size)){l=1;break}l=s.gzindexf&&(e.adler=L(e.adler,s.pending_buf,s.pending-f,f)),0===l&&(s.gzindex=0,s.status=pe)}else s.status=pe;if(s.status===pe)if(s.gzhead.comment){f=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>f&&(e.adler=L(e.adler,s.pending_buf,s.pending-f,f)),o(e),f=s.pending,s.pending===s.pending_buf_size)){l=1;break}l=s.gzindexf&&(e.adler=L(e.adler,s.pending_buf,s.pending-f,f)),0===l&&(s.status=ge)}else s.status=ge;if(s.status===ge&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&o(e),s.pending+2<=s.pending_buf_size&&(u(s,255&e.adler),u(s,e.adler>>8&255),e.adler=0,s.status=me)):s.status=me),0!==s.pending){if(o(e),0===e.avail_out)return s.last_flush=-1,z}else if(0===e.avail_in&&i(t)<=i(r)&&t!==U)return n(e,Z);if(s.status===ve&&0!==e.avail_in)return n(e,Z);if(0!==e.avail_in||0!==s.lookahead||t!==C&&s.status!==ve){var p=s.strategy===H?v(s,t):s.strategy===Y?m(s,t):I[s.level].func(s,t);if(p!==ye&&p!==we||(s.status=ve),p===_e||p===ye)return 0===e.avail_out&&(s.last_flush=-1),z;if(p===be&&(t===O?P._tr_align(s):t!==B&&(P._tr_stored_block(s,0,0,!1),t===D&&(a(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),o(e),0===e.avail_out))return s.last_flush=-1,z}return t!==U?z:s.wrap<=0?F:(2===s.wrap?(u(s,255&e.adler),u(s,e.adler>>8&255),u(s,e.adler>>16&255),u(s,e.adler>>24&255),u(s,255&e.total_in),u(s,e.total_in>>8&255),u(s,e.total_in>>16&255),u(s,e.total_in>>24&255)):(c(s,e.adler>>>16),c(s,65535&e.adler)),o(e),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?z:F)}function A(e){var t;return e&&e.state?(t=e.state.status,t!==le&&t!==he&&t!==de&&t!==pe&&t!==ge&&t!==me&&t!==ve?n(e,j):(e.state=null,t===me?n(e,N):z)):j}var I,R=e("../utils/common"),P=e("./trees"),T=e("./adler32"),L=e("./crc32"),M=e("./messages"),C=0,O=1,D=3,U=4,B=5,z=0,F=1,j=-2,N=-3,Z=-5,q=-1,G=1,H=2,Y=3,W=4,V=0,X=2,J=8,K=9,$=15,Q=8,ee=29,te=256,re=te+1+ee,ne=30,ie=19,ae=2*re+1,oe=15,se=3,ue=258,ce=ue+se+1,fe=32,le=42,he=69,de=73,pe=91,ge=103,me=113,ve=666,_e=1,be=2,ye=3,we=4,xe=3,ke=function(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i};I=[new ke(0,0,0,0,d),new ke(4,4,8,4,p),new ke(4,5,16,8,p),new ke(4,6,32,32,p),new ke(4,4,16,16,g),new ke(8,16,32,32,g),new ke(8,16,128,128,g),new ke(8,32,128,256,g),new ke(32,128,258,1024,g),new ke(32,258,258,4096,g)],r.deflateInit=E,r.deflateInit2=k,r.deflateReset=w,r.deflateResetKeep=y,r.deflateSetHeader=x,r.deflate=S,r.deflateEnd=A,r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":38,"./adler32":39,"./crc32":41,"./messages":46,"./trees":47}],43:[function(e,t,r){"use strict";var n=30,i=12;t.exports=function(e,t){var r,a,o,s,u,c,f,l,h,d,p,g,m,v,_,b,y,w,x,k,E,S,A,I,R;r=e.state,a=e.next_in,I=e.input,o=a+(e.avail_in-5),s=e.next_out,R=e.output,u=s-(t-e.avail_out),c=s+(e.avail_out-257),f=r.dmax,l=r.wsize,h=r.whave,d=r.wnext,p=r.window,g=r.hold,m=r.bits,v=r.lencode,_=r.distcode,b=(1<m&&(g+=I[a++]<>>24,g>>>=x,m-=x,x=w>>>16&255,0===x)R[s++]=65535&w;else{if(!(16&x)){if(0===(64&x)){w=v[(65535&w)+(g&(1<m&&(g+=I[a++]<>>=x,m-=x),15>m&&(g+=I[a++]<>>24,g>>>=x,m-=x,x=w>>>16&255,!(16&x)){if(0===(64&x)){w=_[(65535&w)+(g&(1<m&&(g+=I[a++]<m&&(g+=I[a++]<f){e.msg="invalid distance too far back",r.mode=n;break e}if(g>>>=x,m-=x,x=s-u,E>x){if(x=E-x,x>h&&r.sane){e.msg="invalid distance too far back",r.mode=n;break e}if(S=0,A=p,0===d){if(S+=l-x,k>x){k-=x;do R[s++]=p[S++];while(--x);S=s-E,A=R}}else if(x>d){if(S+=l+d-x,x-=d,k>x){k-=x;do R[s++]=p[S++];while(--x);if(S=0,k>d){x=d,k-=x;do R[s++]=p[S++];while(--x);S=s-E,A=R}}}else if(S+=d-x,k>x){k-=x;do R[s++]=p[S++];while(--x);S=s-E,A=R}for(;k>2;)R[s++]=A[S++],R[s++]=A[S++],R[s++]=A[S++],k-=3;k&&(R[s++]=A[S++],k>1&&(R[s++]=A[S++]))}else{S=s-E;do R[s++]=R[S++],R[s++]=R[S++],R[s++]=R[S++],k-=3;while(k>2);k&&(R[s++]=R[S++],k>1&&(R[s++]=R[S++]))}break}}break}}while(o>a&&c>s);k=m>>3,a-=k,m-=k<<3,g&=(1<a?5+(o-a):5-(a-o),e.avail_out=c>s?257+(c-s):257-(s-c),r.hold=g,r.bits=m}},{}],44:[function(e,t,r){"use strict";function n(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function i(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new v.Buf16(320),this.work=new v.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=U,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new v.Buf32(pe),t.distcode=t.distdyn=new v.Buf32(ge),t.sane=1,t.back=-1,R):L}function o(e){var t;return e&&e.state?(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,a(e)):L}function s(e,t){var r,n;return e&&e.state?(n=e.state,0>t?(r=0,t=-t):(r=(t>>4)+1,48>t&&(t&=15)),t&&(8>t||t>15)?L:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,o(e))):L}function u(e,t){var r,n;return e?(n=new i,e.state=n,n.window=null,r=s(e,t),r!==R&&(e.state=null),r):L}function c(e){return u(e,ve)}function f(e){if(_e){var t;for(g=new v.Buf32(512),m=new v.Buf32(32),t=0;144>t;)e.lens[t++]=8;for(;256>t;)e.lens[t++]=9;for(;280>t;)e.lens[t++]=7;for(;288>t;)e.lens[t++]=8;for(w(k,e.lens,0,288,g,0,e.work,{bits:9}),t=0;32>t;)e.lens[t++]=5;w(E,e.lens,0,32,m,0,e.work,{bits:5}),_e=!1}e.lencode=g,e.lenbits=9,e.distcode=m,e.distbits=5}function l(e,t,r,n){var i,a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(v.arraySet(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),v.arraySet(a.window,t,r-n,i,a.wnext),n-=i,n?(v.arraySet(a.window,t,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whaved;){if(0===u)break e;u--,h+=i[o++]<>>8&255,r.check=b(r.check,Ie,2,0),h=0,d=0,r.mode=B;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&h)<<8)+(h>>8))%31){e.msg="incorrect header check",r.mode=le;break}if((15&h)!==D){e.msg="unknown compression method",r.mode=le;break}if(h>>>=4,d-=4,xe=(15&h)+8,0===r.wbits)r.wbits=xe;else if(xe>r.wbits){e.msg="invalid window size",r.mode=le;break}r.dmax=1<d;){if(0===u)break e;u--,h+=i[o++]<>8&1),512&r.flags&&(Ie[0]=255&h,Ie[1]=h>>>8&255,r.check=b(r.check,Ie,2,0)),h=0,d=0,r.mode=z;case z:for(;32>d;){if(0===u)break e;u--,h+=i[o++]<>>8&255,Ie[2]=h>>>16&255,Ie[3]=h>>>24&255,r.check=b(r.check,Ie,4,0)),h=0,d=0,r.mode=F;case F:for(;16>d;){if(0===u)break e;u--,h+=i[o++]<>8),512&r.flags&&(Ie[0]=255&h,Ie[1]=h>>>8&255,r.check=b(r.check,Ie,2,0)),h=0,d=0,r.mode=j;case j:if(1024&r.flags){for(;16>d;){if(0===u)break e;u--,h+=i[o++]<>>8&255,r.check=b(r.check,Ie,2,0)),h=0,d=0}else r.head&&(r.head.extra=null);r.mode=N;case N:if(1024&r.flags&&(m=r.length,m>u&&(m=u),m&&(r.head&&(xe=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),v.arraySet(r.head.extra,i,o,m,xe)),512&r.flags&&(r.check=b(r.check,i,m,o)),u-=m,o+=m,r.length-=m),r.length))break e;r.length=0,r.mode=Z;case Z:if(2048&r.flags){if(0===u)break e;m=0;do xe=i[o+m++],r.head&&xe&&r.length<65536&&(r.head.name+=String.fromCharCode(xe));while(xe&&u>m);if(512&r.flags&&(r.check=b(r.check,i,m,o)),u-=m,o+=m,xe)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=q;case q:if(4096&r.flags){if(0===u)break e;m=0;do xe=i[o+m++],r.head&&xe&&r.length<65536&&(r.head.comment+=String.fromCharCode(xe));while(xe&&u>m);if(512&r.flags&&(r.check=b(r.check,i,m,o)),u-=m,o+=m,xe)break e}else r.head&&(r.head.comment=null);r.mode=G;case G:if(512&r.flags){for(;16>d;){if(0===u)break e;u--,h+=i[o++]<>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=W;break;case H:for(;32>d;){if(0===u)break e;u--,h+=i[o++]<>>=7&d,d-=7&d,r.mode=ue;break}for(;3>d;){if(0===u)break e;u--,h+=i[o++]<>>=1,d-=1,3&h){case 0:r.mode=X;break;case 1:if(f(r),r.mode=te,t===I){h>>>=2,d-=2;break e}break;case 2:r.mode=$;break;case 3:e.msg="invalid block type",r.mode=le}h>>>=2,d-=2;break;case X:for(h>>>=7&d,d-=7&d;32>d;){if(0===u)break e;u--,h+=i[o++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=le;break}if(r.length=65535&h,h=0,d=0,r.mode=J,t===I)break e;case J:r.mode=K;case K:if(m=r.length){if(m>u&&(m=u),m>c&&(m=c),0===m)break e;v.arraySet(a,i,o,m,s),u-=m,o+=m,c-=m,s+=m,r.length-=m;break}r.mode=W;break;case $:for(;14>d;){if(0===u)break e;u--,h+=i[o++]<>>=5,d-=5,r.ndist=(31&h)+1,h>>>=5,d-=5,r.ncode=(15&h)+4,h>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=le;break}r.have=0,r.mode=Q;case Q:for(;r.haved;){if(0===u)break e;u--,h+=i[o++]<>>=3,d-=3}for(;r.have<19;)r.lens[Re[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,Ee={bits:r.lenbits},ke=w(x,r.lens,0,19,r.lencode,0,r.work,Ee),r.lenbits=Ee.bits,ke){e.msg="invalid code lengths set",r.mode=le;break}r.have=0,r.mode=ee;case ee:for(;r.have>>24,ve=Ae>>>16&255,_e=65535&Ae,!(d>=me);){if(0===u)break e;u--,h+=i[o++]<_e)h>>>=me,d-=me,r.lens[r.have++]=_e;else{if(16===_e){for(Se=me+2;Se>d;){if(0===u)break e;u--,h+=i[o++]<>>=me,d-=me,0===r.have){e.msg="invalid bit length repeat",r.mode=le;break}xe=r.lens[r.have-1],m=3+(3&h),h>>>=2,d-=2}else if(17===_e){for(Se=me+3;Se>d;){if(0===u)break e;u--,h+=i[o++]<>>=me,d-=me,xe=0,m=3+(7&h),h>>>=3,d-=3}else{for(Se=me+7;Se>d;){if(0===u)break e;u--,h+=i[o++]<>>=me,d-=me,xe=0,m=11+(127&h),h>>>=7,d-=7}if(r.have+m>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=le;break}for(;m--;)r.lens[r.have++]=xe}}if(r.mode===le)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=le;break}if(r.lenbits=9,Ee={bits:r.lenbits},ke=w(k,r.lens,0,r.nlen,r.lencode,0,r.work,Ee),r.lenbits=Ee.bits,ke){e.msg="invalid literal/lengths set",r.mode=le;break}if(r.distbits=6,r.distcode=r.distdyn,Ee={bits:r.distbits},ke=w(E,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,Ee),r.distbits=Ee.bits,ke){e.msg="invalid distances set",r.mode=le;break}if(r.mode=te,t===I)break e;case te:r.mode=re;case re:if(u>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=u,r.hold=h,r.bits=d,y(e,g),s=e.next_out,a=e.output,c=e.avail_out,o=e.next_in,i=e.input,u=e.avail_in,h=r.hold,d=r.bits,r.mode===W&&(r.back=-1);break}for(r.back=0;Ae=r.lencode[h&(1<>>24,ve=Ae>>>16&255,_e=65535&Ae,!(d>=me);){if(0===u)break e;u--,h+=i[o++]<>be)],me=Ae>>>24,ve=Ae>>>16&255,_e=65535&Ae,!(d>=be+me);){if(0===u)break e;u--,h+=i[o++]<>>=be,d-=be,r.back+=be}if(h>>>=me,d-=me,r.back+=me,r.length=_e,0===ve){r.mode=se;break}if(32&ve){r.back=-1,r.mode=W;break}if(64&ve){e.msg="invalid literal/length code",r.mode=le;break}r.extra=15&ve,r.mode=ne;case ne:if(r.extra){for(Se=r.extra;Se>d;){if(0===u)break e;u--,h+=i[o++]<>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=ie;case ie:for(;Ae=r.distcode[h&(1<>>24,ve=Ae>>>16&255,_e=65535&Ae,!(d>=me);){if(0===u)break e;u--,h+=i[o++]<>be)],me=Ae>>>24,ve=Ae>>>16&255,_e=65535&Ae,!(d>=be+me);){if(0===u)break e;u--,h+=i[o++]<>>=be,d-=be,r.back+=be}if(h>>>=me,d-=me,r.back+=me,64&ve){e.msg="invalid distance code",r.mode=le;break}r.offset=_e,r.extra=15&ve,r.mode=ae;case ae:if(r.extra){for(Se=r.extra;Se>d;){if(0===u)break e;u--,h+=i[o++]<>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=le;break}r.mode=oe;case oe:if(0===c)break e;if(m=g-c,r.offset>m){if(m=r.offset-m,m>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=le;break}m>r.wnext?(m-=r.wnext,pe=r.wsize-m):pe=r.wnext-m,m>r.length&&(m=r.length),ge=r.window}else ge=a,pe=s-r.offset,m=r.length;m>c&&(m=c),c-=m,r.length-=m;do a[s++]=ge[pe++];while(--m);0===r.length&&(r.mode=re);break;case se:if(0===c)break e;a[s++]=r.length,c--,r.mode=re;break;case ue:if(r.wrap){for(;32>d;){if(0===u)break e;u--,h|=i[o++]<d;){if(0===u)break e;u--,h+=i[o++]<=P;P++)N[P]=0;for(T=0;p>T;T++)N[t[r+T]]++;for(C=R,M=i;M>=1&&0===N[M];M--);if(C>M&&(C=M),0===M)return g[m++]=20971520,g[m++]=20971520,_.bits=1,0;for(L=1;M>L&&0===N[L];L++);for(L>C&&(C=L),U=1,P=1;i>=P;P++)if(U<<=1,U-=N[P],0>U)return-1;if(U>0&&(e===s||1!==M))return-1;for(Z[1]=0,P=1;i>P;P++)Z[P+1]=Z[P]+N[P];for(T=0;p>T;T++)0!==t[r+T]&&(v[Z[t[r+T]]++]=T);if(e===s?(F=q=v,E=19):e===u?(F=f,j-=257,q=l,G-=257,E=256):(F=h,q=d,E=-1),z=0,T=0,P=L,k=m,O=C,D=0,w=-1,B=1<a||e===c&&B>o)return 1;for(var H=0;;){H++,S=P-D,v[T]E?(A=q[G+v[T]],I=F[j+v[T]]):(A=96,I=0),b=1<>D)+y]=S<<24|A<<16|I|0;while(0!==y);for(b=1<>=1;if(0!==b?(z&=b-1,z+=b):z=0,T++,0===--N[P]){if(P===M)break;P=t[r+v[T]]}if(P>C&&(z&x)!==w){for(0===D&&(D=C),k+=L,O=P-D,U=1<O+D&&(U-=N[O+D],!(0>=U));)O++,U<<=1;if(B+=1<a||e===c&&B>o)return 1;w=z&x,g[w]=C<<24|O<<16|k-m|0}}return 0!==z&&(g[k+z]=P-D<<24|64<<16|0),_.bits=C,0}},{"../utils/common":38}],46:[function(e,t,r){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],47:[function(e,t,r){"use strict";function n(e){for(var t=e.length;--t>=0;)e[t]=0}function i(e){return 256>e?oe[e]:oe[256+(e>>>7)]}function a(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function o(e,t,r){e.bi_valid>W-r?(e.bi_buf|=t<>W-e.bi_valid,e.bi_valid+=r-W):(e.bi_buf|=t<>>=1,r<<=1;while(--t>0);return r>>>1}function c(e){16===e.bi_valid?(a(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}function f(e,t){var r,n,i,a,o,s,u=t.dyn_tree,c=t.max_code,f=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,g=0;for(a=0;Y>=a;a++)e.bl_count[a]=0;for(u[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;H>r;r++)n=e.heap[r],a=u[2*u[2*n+1]+1]+1,a>p&&(a=p,g++),u[2*n+1]=a,n>c||(e.bl_count[a]++,o=0,n>=d&&(o=h[n-d]),s=u[2*n],e.opt_len+=s*(a+o),l&&(e.static_len+=s*(f[2*n+1]+o)));if(0!==g){do{for(a=p-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[p]--,g-=2}while(g>0);for(a=p;0!==a;a--)for(n=e.bl_count[a];0!==n;)i=e.heap[--r],i>c||(u[2*i+1]!==a&&(e.opt_len+=(a-u[2*i+1])*u[2*i],u[2*i+1]=a),n--)}}function l(e,t,r){var n,i,a=new Array(Y+1),o=0;for(n=1;Y>=n;n++)a[n]=o=o+r[n-1]<<1;for(i=0;t>=i;i++){var s=e[2*i+1];0!==s&&(e[2*i]=u(a[s]++,s))}}function h(){var e,t,r,n,i,a=new Array(Y+1);for(r=0,n=0;j-1>n;n++)for(ue[n]=r,e=0;e<1<n;n++)for(ce[n]=i,e=0;e<1<>=7;q>n;n++)for(ce[n]=i<<7,e=0;e<1<=t;t++)a[t]=0;for(e=0;143>=e;)ie[2*e+1]=8,e++,a[8]++;for(;255>=e;)ie[2*e+1]=9,e++,a[9]++;for(;279>=e;)ie[2*e+1]=7,e++,a[7]++;for(;287>=e;)ie[2*e+1]=8,e++,a[8]++;for(l(ie,Z+1,a),e=0;q>e;e++)ae[2*e+1]=5,ae[2*e]=u(e,5);fe=new de(ie,Q,N+1,Z,Y),le=new de(ae,ee,0,q,Y),he=new de(new Array(0),te,0,G,V)}function d(e){var t;for(t=0;Z>t;t++)e.dyn_ltree[2*t]=0;for(t=0;q>t;t++)e.dyn_dtree[2*t]=0;for(t=0;G>t;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*X]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function p(e){e.bi_valid>8?a(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function g(e,t,r,n){p(e),n&&(a(e,r),a(e,~r)),T.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}function m(e,t,r,n){var i=2*t,a=2*r;return e[i]r;r++)0!==a[2*r]?(e.heap[++e.heap_len]=c=r,e.depth[r]=0):a[2*r+1]=0;for(;e.heap_len<2;)i=e.heap[++e.heap_len]=2>c?++c:0,a[2*i]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=o[2*i+1]);for(t.max_code=c,r=e.heap_len>>1;r>=1;r--)v(e,a,r);i=u;do r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],v(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,a[2*i]=a[2*r]+a[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,a[2*r+1]=a[2*n+1]=i,e.heap[1]=i++,v(e,a,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],f(e,t),l(a,c,e.bl_count)}function y(e,t,r){var n,i,a=-1,o=t[1],s=0,u=7,c=4;for(0===o&&(u=138,c=3),t[2*(r+1)+1]=65535,n=0;r>=n;n++)i=o,o=t[2*(n+1)+1],++ss?e.bl_tree[2*i]+=s:0!==i?(i!==a&&e.bl_tree[2*i]++,e.bl_tree[2*J]++):10>=s?e.bl_tree[2*K]++:e.bl_tree[2*$]++,s=0,a=i,0===o?(u=138,c=3):i===o?(u=6,c=3):(u=7,c=4))}function w(e,t,r){var n,i,a=-1,u=t[1],c=0,f=7,l=4;for(0===u&&(f=138,l=3),n=0;r>=n;n++)if(i=u,u=t[2*(n+1)+1],!(++cc){do s(e,i,e.bl_tree);while(0!==--c)}else 0!==i?(i!==a&&(s(e,i,e.bl_tree),c--),s(e,J,e.bl_tree),o(e,c-3,2)):10>=c?(s(e,K,e.bl_tree),o(e,c-3,3)):(s(e,$,e.bl_tree),o(e,c-11,7));c=0,a=i,0===u?(f=138,l=3):i===u?(f=6,l=3):(f=7,l=4)}}function x(e){var t;for(y(e,e.dyn_ltree,e.l_desc.max_code),y(e,e.dyn_dtree,e.d_desc.max_code),b(e,e.bl_desc),t=G-1;t>=3&&0===e.bl_tree[2*re[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}function k(e,t,r,n){var i;for(o(e,t-257,5),o(e,r-1,5),o(e,n-4,4),i=0;n>i;i++)o(e,e.bl_tree[2*re[i]+1],3);w(e,e.dyn_ltree,t-1),w(e,e.dyn_dtree,r-1)}function E(e){var t,r=4093624447;for(t=0;31>=t;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return M;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return C;for(t=32;N>t;t++)if(0!==e.dyn_ltree[2*t])return C;return M}function S(e){ge||(h(),ge=!0),e.l_desc=new pe(e.dyn_ltree,fe),e.d_desc=new pe(e.dyn_dtree,le),e.bl_desc=new pe(e.bl_tree,he),e.bi_buf=0,e.bi_valid=0,d(e)}function A(e,t,r,n){o(e,(D<<1)+(n?1:0),3),g(e,t,r,!0)}function I(e){o(e,U<<1,3),s(e,X,ie),c(e)}function R(e,t,r,n){var i,a,s=0;e.level>0?(e.strm.data_type===O&&(e.strm.data_type=E(e)),b(e,e.l_desc),b(e,e.d_desc),s=x(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,i>=a&&(i=a)):i=a=r+5,i>=r+4&&-1!==t?A(e,t,r,n):e.strategy===L||a===i?(o(e,(U<<1)+(n?1:0),3),_(e,ie,ae)):(o(e,(B<<1)+(n?1:0),3),k(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),_(e,e.dyn_ltree,e.dyn_dtree)),d(e),n&&p(e)}function P(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(se[r]+N+1)]++,e.dyn_dtree[2*i(t)]++),e.last_lit===e.lit_bufsize-1}var T=e("../utils/common"),L=4,M=0,C=1,O=2,D=0,U=1,B=2,z=3,F=258,j=29,N=256,Z=N+1+j,q=30,G=19,H=2*Z+1,Y=15,W=16,V=7,X=256,J=16,K=17,$=18,Q=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ee=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],te=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],re=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],ne=512,ie=new Array(2*(Z+2));n(ie);var ae=new Array(2*q);n(ae);var oe=new Array(ne);n(oe);var se=new Array(F-z+1);n(se);var ue=new Array(j);n(ue);var ce=new Array(q);n(ce);var fe,le,he,de=function(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length},pe=function(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t},ge=!1;r._tr_init=S,r._tr_stored_block=A,r._tr_flush_block=R,r._tr_tally=P,r._tr_align=I},{"../utils/common":38}],48:[function(e,t,r){"use strict";function n(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}t.exports=n},{}],49:[function(e,t,r){(function(e){"use strict";function r(t){for(var r=new Array(arguments.length-1),n=0;n1)for(var r=1;r0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&l(e))),d(e,t)}else i||(t.reading=!1);return o(t)}function o(e){return!e.ended&&(e.needReadable||e.length=D?e=D:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function u(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=s(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function c(e,t){var r=null;return I.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function f(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,l(e)}}function l(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(M("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?S(h,e):h(e))}function h(e){M("emit readable"),e.emit("readable"),b(e)}function d(e,t){t.readingMore||(t.readingMore=!0,S(p,e,t))}function p(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=i)r=a?n.join(""):1===n.length?n[0]:I.concat(n,i),n.length=0;else if(ec&&e>u;c++){var s=n[0],l=Math.min(e-u,s.length);a?r+=s.slice(0,l):s.copy(r,u,0,l),l0)throw new Error("endReadable called on non-empty stream");t.endEmitted||(t.ended=!0,S(x,t,e))}function x(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function k(e,t){for(var r=0,n=e.length;n>r;r++)t(e[r],r)}function E(e,t){for(var r=0,n=e.length;n>r;r++)if(e[r]===t)return r;return-1}t.exports=i;var S=e("process-nextick-args"),A=e("isarray"),I=e("buffer").Buffer;i.ReadableState=n;var R,P=(e("events"),function(e,t){return e.listeners(t).length});!function(){try{R=e("stream")}catch(t){}finally{R||(R=e("events").EventEmitter)}}();var I=e("buffer").Buffer,T=e("core-util-is");T.inherits=e("inherits");var L=e("util"),M=void 0;M=L&&L.debuglog?L.debuglog("stream"):function(){};var C;T.inherits(i,R);var O,O;i.prototype.push=function(e,t){var r=this._readableState;return r.objectMode||"string"!=typeof e||(t=t||r.defaultEncoding,t!==r.encoding&&(e=new I(e,t),t="")),a(this,r,e,t,!1)},i.prototype.unshift=function(e){var t=this._readableState;return a(this,t,e,"",!0)},i.prototype.isPaused=function(){return this._readableState.flowing===!1},i.prototype.setEncoding=function(t){return C||(C=e("string_decoder/").StringDecoder),this._readableState.decoder=new C(t),this._readableState.encoding=t,this};var D=8388608;i.prototype.read=function(e){M("read",e);var t=this._readableState,r=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return M("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?w(this):l(this),null;if(e=u(e,t),0===e&&t.ended)return 0===t.length&&w(this),null;var n=t.needReadable;M("need readable",n),(0===t.length||t.length-e0?y(e,t):null,null===i&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),r!==e&&t.ended&&0===t.length&&w(this),null!==i&&this.emit("data",i),i},i.prototype._read=function(e){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(e,t){function n(e){M("onunpipe"),e===l&&a()}function i(){M("onend"),e.end()}function a(){M("cleanup"),e.removeListener("close",u),e.removeListener("finish",c),e.removeListener("drain",m),e.removeListener("error",s),e.removeListener("unpipe",n),l.removeListener("end",i),l.removeListener("end",a),l.removeListener("data",o),v=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||m()}function o(t){M("ondata");var r=e.write(t);!1===r&&(1!==h.pipesCount||h.pipes[0]!==e||1!==l.listenerCount("data")||v||(M("false write response, pause",l._readableState.awaitDrain),l._readableState.awaitDrain++),l.pause())}function s(t){M("onerror",t),f(),e.removeListener("error",s),0===P(e,"error")&&e.emit("error",t)}function u(){e.removeListener("finish",c),f()}function c(){M("onfinish"),e.removeListener("close",u),f()}function f(){M("unpipe"),l.unpipe(e)}var l=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,M("pipe count=%d opts=%j",h.pipesCount,t);var d=(!t||t.end!==!1)&&e!==r.stdout&&e!==r.stderr,p=d?i:a;h.endEmitted?S(p):l.once("end",p),e.on("unpipe",n);var m=g(l);e.on("drain",m);var v=!1;return l.on("data",o),e._events&&e._events.error?A(e._events.error)?e._events.error.unshift(s):e._events.error=[s,e._events.error]:e.on("error",s),e.once("close",u),e.once("finish",c),e.emit("pipe",l),h.flowing||(M("pipe resume"),l.resume()),e},i.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;n>i;i++)r[i].emit("unpipe",this);return this}var a=E(t.pipes,e);return-1===a?this:(t.pipes.splice(a,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},i.prototype.on=function(e,t){var r=R.prototype.on.call(this,e,t);if("data"===e&&!1!==this._readableState.flowing&&this.resume(),"readable"===e&&!this._readableState.endEmitted){var n=this._readableState;n.readableListening||(n.readableListening=!0,n.emittedReadable=!1,n.needReadable=!0,n.reading?n.length&&l(this,n):S(m,this))}return r},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){var e=this._readableState;return e.flowing||(M("resume"),e.flowing=!0,v(this,e)),this},i.prototype.pause=function(){return M("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(M("pause"),this._readableState.flowing=!1,this.emit("pause")),this},i.prototype.wrap=function(e){var t=this._readableState,r=!1,n=this;e.on("end",function(){if(M("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&n.push(e)}n.push(null)}),e.on("data",function(i){if(M("wrapped data"),t.decoder&&(i=t.decoder.write(i)),(!t.objectMode||null!==i&&void 0!==i)&&(t.objectMode||i&&i.length)){var a=n.push(i);a||(r=!0,e.pause())}});for(var i in e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var a=["error","close","destroy","pause","resume"];return k(a,function(t){e.on(t,n.emit.bind(n,t))}),n._read=function(t){M("wrapped _read",t),r&&(r=!1,e.resume())},n},i._fromList=y}).call(this,e("_process"))},{"./_stream_duplex":51,_process:50,buffer:21,"core-util-is":22,events:25,inherits:28,isarray:30,"process-nextick-args":49,"string_decoder/":56,util:18}],53:[function(e,t,r){"use strict";function n(e){this.afterTransform=function(t,r){return i(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function i(e,t,r){var n=e._transformState;n.transforming=!1;var i=n.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,null!==r&&void 0!==r&&e.push(r),i(t);var a=e._readableState;a.reading=!1,(a.needReadable||a.length-1?setImmediate:k,S=e("buffer").Buffer;o.WritableState=a;var A=e("core-util-is");A.inherits=e("inherits");var I,R={deprecate:e("util-deprecate")};!function(){try{I=e("stream")}catch(t){}finally{I||(I=e("events").EventEmitter)}}();var S=e("buffer").Buffer;A.inherits(o,I);var P;a.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(a.prototype,"buffer",{get:R.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var P;o.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},o.prototype.write=function(e,t,r){var i=this._writableState,a=!1;return"function"==typeof t&&(r=t,t=null),S.isBuffer(e)?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=n),i.ended?s(this,r):u(this,i,e,r)&&(i.pendingcb++,a=f(this,i,e,t,r)),a},o.prototype.cork=function(){var e=this._writableState;e.corked++},o.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||v(this,e))},o.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);this._writableState.defaultEncoding=e},o.prototype._write=function(e,t,r){r(new Error("not implemented"))},o.prototype._writev=null,o.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||w(this,n,r)}}).call(this,e("_process"))},{"./_stream_duplex":51,_process:50,buffer:21,"core-util-is":22,events:25,inherits:28,"process-nextick-args":49,"util-deprecate":57}],55:[function(e,t,r){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":53}],56:[function(e,t,r){function n(e){if(e&&!u(e))throw new Error("Unknown encoding: "+e)}function i(e){return e.toString(this.encoding)}function a(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function o(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var s=e("buffer").Buffer,u=s.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},c=r.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),n(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=a;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=o;break;default:return void(this.write=i)}this.charBuffer=new s(6),this.charReceived=0,this.charLength=0};c.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&56319>=n)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i);var i=t.length-1,n=t.charCodeAt(i);if(n>=55296&&56319>=n){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),e.copy(this.charBuffer,0,0,a),t.substring(0,i)}return t},c.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(2>=t&&r>>4==14){this.charLength=3;break}if(3>=t&&r>>3==30){this.charLength=4;break}}this.charReceived=t},c.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t}},{buffer:21}],57:[function(e,t,r){(function(e){function r(e,t){function r(){if(!i){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}if(n("noDeprecation"))return e;var i=!1;return r}function n(t){try{if(!e.localStorage)return!1}catch(r){return!1}var n=e.localStorage[t];return null==n?!1:"true"===String(n).toLowerCase()}t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],58:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],59:[function(e,t,r){(function(t,n){function i(e,t){var n={seen:[],stylize:o};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(t)?n.showHidden=t:t&&r._extend(n,t),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=a),u(n,e,n.depth)}function a(e,t){var r=i.styles[t];return r?"["+i.colors[r][0]+"m"+e+"["+i.colors[r][1]+"m":e}function o(e,t){return e}function s(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}function u(e,t,n){if(e.customInspect&&t&&A(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return b(i)||(i=u(e,i,n)),i}var a=c(e,t);if(a)return a;var o=Object.keys(t),g=s(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),S(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(t);if(0===o.length){if(A(t)){var m=t.name?": "+t.name:"";return e.stylize("[Function"+m+"]","special")}if(x(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(E(t))return e.stylize(Date.prototype.toString.call(t),"date");if(S(t))return f(t)}var v="",_=!1,y=["{","}"];if(p(t)&&(_=!0,y=["[","]"]),A(t)){var w=t.name?": "+t.name:"";v=" [Function"+w+"]"}if(x(t)&&(v=" "+RegExp.prototype.toString.call(t)),E(t)&&(v=" "+Date.prototype.toUTCString.call(t)),S(t)&&(v=" "+f(t)),0===o.length&&(!_||0==t.length))return y[0]+v+y[1];if(0>n)return x(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var k;return k=_?l(e,t,n,g,o):o.map(function(r){return h(e,t,n,g,r,_)}),e.seen.pop(),d(k,v,y)}function c(e,t){if(w(t))return e.stylize("undefined","undefined");if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return _(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i){for(var a=[],o=0,s=t.length;s>o;++o)L(t,String(o))?a.push(h(e,t,r,n,String(o),!0)):a.push("");return i.forEach(function(i){i.match(/^\d+$/)||a.push(h(e,t,r,n,i,!0))}),a}function h(e,t,r,n,i,a){var o,s,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?s=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(s=e.stylize("[Setter]","special")),L(n,i)||(o="["+i+"]"),s||(e.seen.indexOf(c.value)<0?(s=m(r)?u(e,c.value,null):u(e,c.value,r-1),s.indexOf("\n")>-1&&(s=a?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n"))):s=e.stylize("[Circular]","special")),w(o)){if(a&&i.match(/^\d+$/))return s;o=JSON.stringify(""+i),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+s}function d(e,t,r){var n=0,i=e.reduce(function(e,t){return n++,t.indexOf("\n")>=0&&n++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function p(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function m(e){return null===e}function v(e){return null==e}function _(e){return"number"==typeof e}function b(e){return"string"==typeof e}function y(e){return"symbol"==typeof e}function w(e){return void 0===e}function x(e){return k(e)&&"[object RegExp]"===R(e)}function k(e){return"object"==typeof e&&null!==e}function E(e){return k(e)&&"[object Date]"===R(e)}function S(e){return k(e)&&("[object Error]"===R(e)||e instanceof Error)}function A(e){return"function"==typeof e}function I(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function R(e){return Object.prototype.toString.call(e)}function P(e){return 10>e?"0"+e.toString(10):e.toString(10)}function T(){var e=new Date,t=[P(e.getHours()),P(e.getMinutes()),P(e.getSeconds())].join(":");return[e.getDate(),D[e.getMonth()],t].join(" ")}function L(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var M=/%[sdj%]/g;r.format=function(e){if(!b(e)){for(var t=[],r=0;r=a)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return e}}),s=n[r];a>r;s=n[++r])o+=m(s)||!k(s)?" "+s:" "+i(s);return o},r.deprecate=function(e,i){function a(){if(!o){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),o=!0}return e.apply(this,arguments)}if(w(n.process))return function(){return r.deprecate(e,i).apply(this,arguments)};if(t.noDeprecation===!0)return e;var o=!1;return a};var C,O={};r.debuglog=function(e){if(w(C)&&(C=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!O[e])if(new RegExp("\\b"+e+"\\b","i").test(C)){var n=t.pid;O[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else O[e]=function(){};return O[e]},r.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=p,r.isBoolean=g,r.isNull=m,r.isNullOrUndefined=v,r.isNumber=_,r.isString=b,r.isSymbol=y,r.isUndefined=w,r.isRegExp=x,r.isObject=k,r.isDate=E,r.isError=S,r.isFunction=A,r.isPrimitive=I,r.isBuffer=e("./support/isBuffer");var D=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];r.log=function(){console.log("%s - %s",T(),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!k(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":58,_process:50,inherits:28}],60:[function(e,t,r){var n=arguments[3],i=arguments[4],a=arguments[5],o=JSON.stringify;t.exports=function(e){for(var t,r=Object.keys(a),s=0,u=r.length;u>s;s++){var c=r[s],f=a[c].exports;if(f===e||f["default"]===e){t=c;break}}if(!t){t=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var l={},s=0,u=r.length;u>s;s++){var c=r[s];l[c]=c}i[t]=[Function(["require","module","exports"],"("+e+")(self)"),l]}var h=Math.floor(Math.pow(16,8)*Math.random()).toString(16),d={};d[t]=t,i[h]=[Function(["require"],"var f = require("+o(t)+");(f.default ? f.default : f)(self);"),d];var p="("+n+")({"+Object.keys(i).map(function(e){return o(e)+":["+i[e][0]+","+o(i[e][1])+"]"}).join(",")+"},{},["+o(h)+"])",g=window.URL||window.webkitURL||window.mozURL||window.msURL;return new Worker(g.createObjectURL(new Blob([p],{type:"text/javascript"})))}},{}]},{},[1])(1)}); \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.inkjet=e()}}(function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var u="function"==typeof require&&require;if(!s&&u)return u(o,!0);if(a)return a(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[o]={exports:{}};t[o][0].call(c.exports,function(e){var r=t[o][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o=this._APP0_MARKER&&r<=this._APP15_MARKER},e.prototype._hasExifData=function(){return 0!==this._tiffHeaderOffset},e.prototype._readTags=function(){return this._setByteOrder(),this._read0thIfd(),this._readExifIfd(),this._readGpsIfd(),this._readInteroperabilityIfd()},e.prototype._setByteOrder=function(){if(this._dataView.getUint16(this._tiffHeaderOffset)===this._BYTE_ORDER_BIG_ENDIAN)return this._littleEndian=!0;if(this._dataView.getUint16(this._tiffHeaderOffset)===this._BYTE_ORDER_LITTLE_ENDIAN)return this._littleEndian=!1;throw new Error("Illegal byte order value. Faulty image.")},e.prototype._read0thIfd=function(){var e;return e=this._getIfdOffset(),this._readIfd("0th",e)},e.prototype._getIfdOffset=function(){return this._tiffHeaderOffset+this._getLongAt(this._tiffHeaderOffset+4)},e.prototype._readExifIfd=function(){var e;if(null!=this._tags["Exif IFD Pointer"])return e=this._tiffHeaderOffset+this._tags["Exif IFD Pointer"].value,this._readIfd("exif",e)},e.prototype._readGpsIfd=function(){var e;if(null!=this._tags["GPS Info IFD Pointer"])return e=this._tiffHeaderOffset+this._tags["GPS Info IFD Pointer"].value,this._readIfd("gps",e)},e.prototype._readInteroperabilityIfd=function(){var e;if(null!=this._tags["Interoperability IFD Pointer"])return e=this._tiffHeaderOffset+this._tags["Interoperability IFD Pointer"].value,this._readIfd("interoperability",e)},e.prototype._readIfd=function(e,t){var r,n,i,a,o;for(n=this._getShortAt(t),t+=2,o=[],r=a=0;0<=n?an;r=0<=n?++a:--a)i=this._readTag(e,t),void 0!==i&&(this._tags[i.name]={value:i.value,description:i.description}),o.push(t+=12);return o},e.prototype._readTag=function(e,t){var r,n,i,a,o,s,u;if(r=this._getShortAt(t),o=this._getShortAt(t+2),n=this._getLongAt(t+4),void 0!==this._typeSizes[o])return this._typeSizes[o]*n<=4?s=this._getTagValue(t+8,o,n):(u=this._getLongAt(t+8),s=this._getTagValue(this._tiffHeaderOffset+u,o,n)),o===this._tagTypes.ASCII&&(s=this._splitNullSeparatedAsciiString(s)),null!=this._tagNames[e][r]?(null!=this._tagNames[e][r].name&&null!=this._tagNames[e][r].description?(a=this._tagNames[e][r].name,i=this._tagNames[e][r].description(s)):(a=this._tagNames[e][r],i=s instanceof Array?s.join(", "):s),{name:a,value:s,description:i}):{name:"undefined-"+r,value:s,description:s}},e.prototype._getTagValue=function(e,t,r){var n,i,a;return i=function(){var i,o;for(o=[],a=i=0;0<=r?ir;a=0<=r?++i:--i)n=this._getTagValueAt[t](e),e+=this._typeSizes[t],o.push(n);return o}.call(this),1===i.length?i=i[0]:t===this._tagTypes.ASCII&&(i=this._getAsciiValue(i)),i},e.prototype._getAsciiValue=function(e){var t,r;return r=function(){var r,n,i;for(i=[],r=0,n=e.length;rn;t=0<=n?++r:--r)i.push("0");return i}()+e},e.map(t).join(":")}},8:"GPSSatellites",9:{name:"GPSStatus",description:function(e){switch(e.join("")){case"A":return"Measurement in progress";case"V":return"Measurement Interoperability";default:return"Unknown"}}},10:{name:"GPSMeasureMode",description:function(e){switch(e.join("")){case"2":return"2-dimensional measurement";case"3":return"3-dimensional measurement";default:return"Unknown"}}},11:"GPSDOP",12:{name:"GPSSpeedRef",description:function(e){switch(e.join("")){case"K":return"Kilometers per hour";case"M":return"Miles per hour";case"N":return"Knots";default:return"Unknown"}}},13:"GPSSpeed",14:{name:"GPSTrackRef",description:function(e){switch(e.join("")){case"T":return"True direction";case"M":return"Magnetic direction";default:return"Unknown"}}},15:"GPSTrack",16:{name:"GPSImgDirectionRef",description:function(e){switch(e.join("")){case"T":return"True direction";case"M":return"Magnetic direction";default:return"Unknown"}}},17:"GPSImgDirection",18:"GPSMapDatum",19:{name:"GPSDestLatitudeRef",description:function(e){switch(e.join("")){case"N":return"North latitude";case"S":return"South latitude";default:return"Unknown"}}},20:{name:"GPSDestLatitude",description:function(e){return e[0]+e[1]/60+e[2]/3600}},21:{name:"GPSDestLongitudeRef",description:function(e){switch(e.join("")){case"E":return"East longitude";case"W":return"West longitude";default:return"Unknown"}}},22:{name:"GPSDestLongitude",description:function(e){return e[0]+e[1]/60+e[2]/3600}},23:{name:"GPSDestBearingRef",description:function(e){switch(e.join("")){case"T":return"True direction";case"M":return"Magnetic direction";default:return"Unknown"}}},24:"GPSDestBearing",25:{name:"GPSDestDistanceRef",description:function(e){switch(e.join("")){case"K":return"Kilometers";case"M":return"Miles";case"N":return"Knots";default:return"Unknown"}}},26:"GPSDestDistance",27:{name:"GPSProcessingMethod",description:function(e){if(0===e)return"Undefined";switch(e.slice(0,8).map(function(e){return String.fromCharCode(e)}).join("")){case"ASCII\0\0\0":return e.slice(8,e.length).map(function(e){return String.fromCharCode(e)}).join("");case"JIS\0\0\0\0\0":return"[JIS encoded text]";case"UNICODE\0":return"[Unicode encoded text]";case"\0\0\0\0\0\0\0\0":return"[Undefined encoding]"}}},28:{name:"GPSAreaInformation",description:function(e){if(0===e)return"Undefined";switch(e.slice(0,8).map(function(e){return String.fromCharCode(e)}).join("")){case"ASCII\0\0\0":return e.slice(8,e.length).map(function(e){return String.fromCharCode(e)}).join("");case"JIS\0\0\0\0\0":return"[JIS encoded text]";case"UNICODE\0":return"[Unicode encoded text]";case"\0\0\0\0\0\0\0\0":return"[Undefined encoding]"}}},29:"GPSDateStamp",30:{name:"GPSDifferential",description:function(e){switch(e){case 0:return"Measurement without differential correction";case 1:return"Differential correction applied";default:return"Unknown"}}}},interoperability:{1:"InteroperabilityIndex",2:"UnknownInteroperabilityTag0x0002",4097:"UnknownInteroperabilityTag0x1001",4098:"UnknownInteroperabilityTag0x1002"}},e.prototype.getTagValue=function(e){return null!=this._tags[e]?this._tags[e].value:void 0},e.prototype.getTagDescription=function(e){return null!=this._tags[e]?this._tags[e].description:void 0},e.prototype.getAllTags=function(){return this._tags},e.prototype.deleteTag=function(e){return delete this._tags[e]},e}()}).call(void 0)},{}],3:[function(e,t,r){"use strict";function n(e){function t(e){for(var t=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],r=0;r<64;r++){var n=E((t[r]*e+50)/100);n<1?n=1:n>255&&(n=255),S[j[r]]=n}for(var i=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],a=0;a<64;a++){var o=E((i[a]*e+50)/100);o<1?o=1:o>255&&(o=255),A[j[a]]=o}for(var s=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],u=0,f=0;f<8;f++)for(var c=0;c<8;c++)I[u]=1/(S[j[u]]*s[f]*s[c]*8),T[u]=1/(A[j[u]]*s[f]*s[c]*8),u++}function r(e,t){for(var r=0,n=0,i=new Array,a=1;a<=16;a++){for(var o=1;o<=e[a];o++)i[t[n]]=[],i[t[n]][0]=r,i[t[n]][1]=a,n++,r++;r*=2}return i}function n(){w=r(Z,q),b=r(W,V),y=r(G,H),x=r(X,Y)}function i(){for(var e=1,t=2,r=1;r<=15;r++){for(var n=e;n>0]=38470*e,N[e+512>>0]=7471*e+32768,N[e+768>>0]=-11059*e,N[e+1024>>0]=-21709*e,N[e+1280>>0]=32768*e+8421375,N[e+1536>>0]=-27439*e,N[e+1792>>0]=-5329*e}function o(e){for(var t=e[0],r=e[1]-1;r>=0;)t&1<>8&255),s(255&e)}function f(e,t){var r,n,i,a,o,s,u,f,c,l=0,h=8,d=64;for(c=0;c0?$+.5|0:$-.5|0;return R}function c(){u(65504),u(16),s(74),s(70),s(73),s(70),s(0),s(1),s(1),s(0),u(1),u(1),s(0),s(0)}function l(e,t){u(65472),u(17),s(8),u(t),u(e),s(3),s(1),s(17),s(0),s(2),s(17),s(1),s(3),s(17),s(1)}function h(){u(65499),u(132),s(0);for(var e=0;e<64;e++)s(S[e]);s(1);for(var t=0;t<64;t++)s(A[t])}function d(){u(65476),u(418),s(0);for(var e=0;e<16;e++)s(Z[e+1]);for(var t=0;t<=11;t++)s(q[t]);s(16);for(var r=0;r<16;r++)s(G[r+1]);for(var n=0;n<=161;n++)s(H[n]);s(1);for(var i=0;i<16;i++)s(W[i+1]);for(var a=0;a<=11;a++)s(V[a]);s(17);for(var o=0;o<16;o++)s(X[o+1]);for(var f=0;f<=161;f++)s(Y[f])}function p(){u(65498),u(12),s(3),s(1),s(0),s(2),s(17),s(3),s(17),s(0),s(63),s(0)}function g(e,t,r,n,i){for(var a,s=i[0],u=i[240],c=16,l=63,h=64,d=f(e,t),p=0;p0&&0==C[m];m--);if(0==m)return o(s),r;for(var v,_=1;_<=m;){for(var w=_;0==C[_]&&_<=m;++_);var b=_-w;if(b>=c){v=b>>4;for(var y=1;y<=v;++y)o(u);b&=15}a=32767+C[_],o(i[(b<<4)+M[a]]),o(L[a]),_++}return m!=l&&o(s),r}function m(){for(var e=String.fromCharCode,t=0;t<256;t++)F[t]=e(t)}function v(e){if(e<=0&&(e=1),e>100&&(e=100),k!=e){var r=0;r=e<50?Math.floor(5e3/e):Math.floor(200-2*e),t(r),k=e}}function _(){var t=(new Date).getTime();e||(e=50),m(),n(),i(),a(),v(e);(new Date).getTime()-t}var w,b,y,x,k,E=(Math.round,Math.floor),S=new Array(64),A=new Array(64),I=new Array(64),T=new Array(64),L=new Array(65535),M=new Array(65535),R=new Array(64),C=new Array(64),P=[],B=0,D=7,U=new Array(64),z=new Array(64),O=new Array(64),F=new Array(256),N=new Array(2048),j=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],Z=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],q=[0,1,2,3,4,5,6,7,8,9,10,11],G=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],H=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],W=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],V=[0,1,2,3,4,5,6,7,8,9,10,11],X=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],Y=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];this.encode=function(e,t){(new Date).getTime();t&&v(t),P=new Array,B=0,D=7,u(65496),c(),h(),l(e.width,e.height),d(),p();var r=0,n=0,i=0;B=0,D=7,this.encode.displayName="_encode_";for(var a,s,f,m,_,k,E,S,A,L=e.data,M=e.width,R=e.height,C=4*M,F=0;F>3,E=4*(7&A),k=_+S*C+E,F+S>=R&&(k-=C*(F+1+S-R)),a+E>=C&&(k-=a+E-C+4),s=L[k++],f=L[k++],m=L[k++],U[A]=(N[s]+N[f+256>>0]+N[m+512>>0]>>16)-128,z[A]=(N[s+768>>0]+N[f+1024>>0]+N[m+1280>>0]>>16)-128,O[A]=(N[s+1280>>0]+N[f+1536>>0]+N[m+1792>>0]>>16)-128;r=g(U,I,r,w,y),n=g(z,T,n,b,x),i=g(O,T,i,b,x),a+=32}F+=8}if(D>=0){var j=[];j[1]=D+1,j[0]=(1<=0;a--)i[a]=n.charCodeAt(a);return void t(i.buffer)}var o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="arraybuffer",o.onload=function(){t(o.response)},o.send(null)}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function e(){this._src=null,this._parser=new o.JpegImage,this.onload=null}return e.prototype={get src(){return this._src},set src(e){this.load(e)},get width(){return this._parser.width},get height(){return this._parser.height},load:function(e){this._src=e,n(e,function(e){this.parse(new Uint8Array(e)),this.onload&&this.onload()}.bind(this))},parse:function(e){this._parser.parse(e)},getData:function(e,t){return this._parser.getData(e,t,!1)},copyToImageData:function(e){if(2===this._parser.numComponents||this._parser.numComponents>4)throw new Error("Unsupported amount of components");var t,r,n=e.width,i=e.height,a=n*i*4,o=e.data;if(1!==this._parser.numComponents){var s=this._parser.getData(n,i,!0);for(t=0,r=0;tt;)t<<=1,r++;return r}function r(e,t){return e[t]<<24>>24}function n(e,t){return e[t]<<8|e[t+1]}function a(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function o(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!1}),r}var s=function(){function e(){}function t(e,t){for(var r,n,i=0,a=[],o=16;o>0&&!e[o-1];)o--;a.push({children:[],index:0});var s,u=a[0];for(r=0;r0;)u=a.pop();for(u.index++,a.push(u);a.length<=r;)a.push(s={children:[],index:0}),u.children[u.index]=s.children,u=s;i++}r+10)return B--,P>>B&1;if(P=e[t++],255===P){var r=e[t++];if(r)throw"unexpected marker: "+(P<<8|r).toString(16)}return B=7,P>>>7}function d(e){for(var t=e;;){if(t=t[h()],"number"==typeof t)return t;if("object"!==("undefined"==typeof t?"undefined":i(t)))throw"invalid huffman sequence"}}function p(e){for(var t=0;e>0;)t=t<<1|h(),e--;return t}function g(e){if(1===e)return 1===h()?1:-1;var t=p(e);return t>=1<>4;if(0!==o){i+=s;var f=u[i];e.blockData[t+f]=g(o),i++}else{if(s<15)break;i+=16}}}function v(e,t){var r=d(e.huffmanTableDC),n=0===r?0:g(r)<0)return void D--;for(var r=s,n=f;r<=n;){var i=d(e.huffmanTableAC),a=15&i,o=i>>4;if(0!==a){r+=o;var c=u[r];e.blockData[t+c]=g(a)*(1<>4,0===r)o<15?(D=p(o)+(1<=65488&&O<=65495))break;t+=2}return t-C}function a(e,t,r){for(var n,i,a,o,s,u,v,_,w,b,y,x,k,E,S,A,I,T=e.quantizationTable,L=e.blockData,M=0;M<64;M+=8)w=L[t+M],b=L[t+M+1],y=L[t+M+2],x=L[t+M+3],k=L[t+M+4],E=L[t+M+5],S=L[t+M+6],A=L[t+M+7],w*=T[M],0!==(b|y|x|k|E|S|A)?(b*=T[M+1],y*=T[M+2],x*=T[M+3],k*=T[M+4],E*=T[M+5],S*=T[M+6],A*=T[M+7],n=g*w+128>>8,i=g*k+128>>8,a=y,o=S,s=m*(b-A)+128>>8,_=m*(b+A)+128>>8,u=x<<4,v=E<<4,n=n+i+1>>1,i=n-i,I=a*p+o*d+128>>8,a=a*d-o*p+128>>8,o=I,s=s+v+1>>1,v=s-v,_=_+u+1>>1,u=_-u,n=n+o+1>>1,o=n-o,i=i+a+1>>1,a=i-a,I=s*h+_*l+2048>>12,s=s*l-_*h+2048>>12,_=I,I=u*c+v*f+2048>>12,u=u*f-v*c+2048>>12,v=I,r[M]=n+_,r[M+7]=n-_,r[M+1]=i+v,r[M+6]=i-v,r[M+2]=a+u,r[M+5]=a-u,r[M+3]=o+s,r[M+4]=o-s):(I=g*w+512>>10,r[M]=I,r[M+1]=I,r[M+2]=I,r[M+3]=I,r[M+4]=I,r[M+5]=I,r[M+6]=I,r[M+7]=I);for(var R=0;R<8;++R)w=r[R],b=r[R+8],y=r[R+16],x=r[R+24],k=r[R+32],E=r[R+40],S=r[R+48],A=r[R+56],0!==(b|y|x|k|E|S|A)?(n=g*w+2048>>12,i=g*k+2048>>12,a=y,o=S,s=m*(b-A)+2048>>12,_=m*(b+A)+2048>>12,u=x,v=E,n=(n+i+1>>1)+4112,i=n-i,I=a*p+o*d+2048>>12,a=a*d-o*p+2048>>12,o=I,s=s+v+1>>1,v=s-v,_=_+u+1>>1,u=_-u,n=n+o+1>>1,o=n-o,i=i+a+1>>1,a=i-a,I=s*h+_*l+2048>>12,s=s*l-_*h+2048>>12,_=I,I=u*c+v*f+2048>>12,u=u*f-v*c+2048>>12,v=I,w=n+_,A=n-_,b=i+v,S=i-v,y=a+u,E=a-u,x=o+s,k=o-s,w=w<16?0:w>=4080?255:w>>4,b=b<16?0:b>=4080?255:b>>4,y=y<16?0:y>=4080?255:y>>4,x=x<16?0:x>=4080?255:x>>4,k=k<16?0:k>=4080?255:k>>4,E=E<16?0:E>=4080?255:E>>4,S=S<16?0:S>=4080?255:S>>4,A=A<16?0:A>=4080?255:A>>4,L[t+R]=w,L[t+R+8]=b,L[t+R+16]=y,L[t+R+24]=x,L[t+R+32]=k,L[t+R+40]=E,L[t+R+48]=S,L[t+R+56]=A):(I=g*w+8192>>14,I=I<-2040?0:I>=2024?255:I+2056>>4,L[t+R]=I,L[t+R+8]=I,L[t+R+16]=I,L[t+R+24]=I,L[t+R+32]=I,L[t+R+40]=I,L[t+R+48]=I,L[t+R+56]=I)}function o(e,t){for(var n=t.blocksPerLine,i=t.blocksPerColumn,o=new Int16Array(64),s=0;s=255?255:e}var u=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),f=4017,c=799,l=3406,h=2276,d=1567,p=3784,g=5793,m=2896;return e.prototype={parse:function(e){function r(){var t=e[c]<<8|e[c+1];return c+=2,t}function i(){var t=r(),n=e.subarray(c,c+t-2);return c+=n.length,n}function a(e){for(var t=Math.ceil(e.samplesPerLine/8/e.maxH),r=Math.ceil(e.scanLines/8/e.maxV),n=0;n>4===0)for(_=0;_<64;_++)y=u[_],S[y]=e[c++];else{if(E>>4!==1)throw"DQT: invalid table spec";for(_=0;_<64;_++)y=u[_],S[y]=r()}d[15&E]=S}break;case 65472:case 65473:case 65474:if(s)throw"Only single frame JPEGs supported";r(),s={},s.extended=65473===m,s.progressive=65474===m,s.precision=e[c++],s.scanLines=r(),s.samplesPerLine=r(),s.components=[],s.componentIds={};var A,I=e[c++],T=0,L=0;for(v=0;v>4,R=15&e[c+1];T>4===0?g:p)[15&B]=t(D,z)}break;case 65501:r(),f=r();break;case 65498:var O,F=(r(),e[c++]),N=[];for(v=0;v>4],O.huffmanTableAC=p[15&Z],N.push(O)}var q=e[c++],G=e[c++],H=e[c++],W=n(e,c,s,N,f,q,G,H>>4,15&H);c+=W;break;case 65535:255!==e[c]&&c--;break;default:if(255===e[c-3]&&e[c-2]>=192&&e[c-2]<=254){c-=3;break}throw"unknown JPEG marker "+m.toString(16)}m=r()}for(this.width=s.samplesPerLine,this.height=s.scanLines,this.jfif=l,this.adobe=h,this.components=[],v=0;v>8)+y[c+1];return _},_isColorConversionNeeded:function(){return!(!this.adobe||!this.adobe.transformCode)||3===this.numComponents},_convertYccToRgb:function(e){for(var t,r,n,i=0,a=e.length;i=0?255:c<=o?0:255+c*s|0,e[a++]=l>=0?255:l<=o?0:255+l*s|0,e[a++]=h>=0?255:h<=o?0:255+h*s|0}return e},getData:function(e,t,r){if(this.numComponents>4)throw"Unsupported color mode";var n=this._getLinearizedBlockData(e,t);if(3===this.numComponents)return this._convertYccToRgb(n);if(4===this.numComponents){if(this._isColorConversionNeeded())return r?this._convertYcckToRgb(n):this._convertYcckToCmyk(n);if(r)return this._convertCmykToRgb(n)}return n}},e}(),u=function(){function e(e,t,r){this.data=e,this.bp=t,this.dataEnd=r,this.chigh=e[t],this.clow=0,this.byteIn(),this.chigh=this.chigh<<7&65535|this.clow>>9&127,this.clow=this.clow<<7&65535,this.ct-=7,this.a=32768}var t=[{qe:22017,nmps:1,nlps:1,switchFlag:1},{qe:13313,nmps:2,nlps:6,switchFlag:0},{qe:6145,nmps:3,nlps:9,switchFlag:0},{qe:2753,nmps:4,nlps:12,switchFlag:0},{qe:1313,nmps:5,nlps:29,switchFlag:0},{qe:545,nmps:38,nlps:33,switchFlag:0},{qe:22017,nmps:7,nlps:6,switchFlag:1},{qe:21505,nmps:8,nlps:14,switchFlag:0},{qe:18433,nmps:9,nlps:14,switchFlag:0},{qe:14337,nmps:10,nlps:14,switchFlag:0},{qe:12289,nmps:11,nlps:17,switchFlag:0},{qe:9217,nmps:12,nlps:18,switchFlag:0},{qe:7169,nmps:13,nlps:20,switchFlag:0},{qe:5633,nmps:29,nlps:21,switchFlag:0},{qe:22017,nmps:15,nlps:14,switchFlag:1},{qe:21505,nmps:16,nlps:14,switchFlag:0},{qe:20737,nmps:17,nlps:15,switchFlag:0},{qe:18433,nmps:18,nlps:16,switchFlag:0},{qe:14337,nmps:19,nlps:17,switchFlag:0},{qe:13313,nmps:20,nlps:18,switchFlag:0},{qe:12289,nmps:21,nlps:19,switchFlag:0},{qe:10241,nmps:22,nlps:19,switchFlag:0},{qe:9217,nmps:23,nlps:20,switchFlag:0},{qe:8705,nmps:24,nlps:21,switchFlag:0},{qe:7169,nmps:25,nlps:22,switchFlag:0},{qe:6145,nmps:26,nlps:23,switchFlag:0},{qe:5633,nmps:27,nlps:24,switchFlag:0},{qe:5121,nmps:28,nlps:25,switchFlag:0},{qe:4609,nmps:29,nlps:26,switchFlag:0},{qe:4353,nmps:30,nlps:27,switchFlag:0},{qe:2753,nmps:31,nlps:28,switchFlag:0},{qe:2497,nmps:32,nlps:29,switchFlag:0},{qe:2209,nmps:33,nlps:30,switchFlag:0},{qe:1313,nmps:34,nlps:31,switchFlag:0},{qe:1089,nmps:35,nlps:32,switchFlag:0},{qe:673,nmps:36,nlps:33,switchFlag:0},{qe:545,nmps:37,nlps:34,switchFlag:0},{qe:321,nmps:38,nlps:35,switchFlag:0},{qe:273,nmps:39,nlps:36,switchFlag:0},{qe:133,nmps:40,nlps:37,switchFlag:0},{qe:73,nmps:41,nlps:38,switchFlag:0},{qe:37,nmps:42,nlps:39,switchFlag:0},{qe:21,nmps:43,nlps:40,switchFlag:0},{qe:9,nmps:44,nlps:41,switchFlag:0},{qe:5,nmps:45,nlps:42,switchFlag:0},{qe:1,nmps:45,nlps:43,switchFlag:0},{qe:22017,nmps:46,nlps:46,switchFlag:0}];return e.prototype={byteIn:function(){var e=this.data,t=this.bp;if(255===e[t]){var r=e[t+1];r>143?(this.clow+=65280,this.ct=8):(t++,this.clow+=e[t]<<9,this.ct=7,this.bp=t)}else t++,this.clow+=t65535&&(this.chigh+=this.clow>>16,this.clow&=65535)},readBit:function(e,r){var n,i=e[r]>>1,a=1&e[r],o=t[i],s=o.qe,u=this.a-s;if(this.chigh>15&1,this.clow=this.clow<<1&65535,this.ct--;while(0===(32768&u));return this.a=u,e[r]=i<<1|a,n}},e}(),f=function(){function e(){this.failOnCorruptedImage=!1}function r(e,t){e.x0=Math.ceil(t.XOsiz/e.XRsiz),e.x1=Math.ceil(t.Xsiz/e.XRsiz),e.y0=Math.ceil(t.YOsiz/e.YRsiz),e.y1=Math.ceil(t.Ysiz/e.YRsiz),e.width=e.x1-e.x0,e.height=e.y1-e.y0}function i(e,t){for(var r,n=e.SIZ,i=[],a=Math.ceil((n.Xsiz-n.XTOsiz)/n.XTsiz),o=Math.ceil((n.Ysiz-n.YTOsiz)/n.YTsiz),s=0;s0?Math.min(n.xcb,i.PPx-1):Math.min(n.xcb,i.PPx),i.ycb_=r>0?Math.min(n.ycb,i.PPy-1):Math.min(n.ycb,i.PPy),i}function s(e,t,r){var n=1<t.trx0?Math.ceil(t.trx1/n)-Math.floor(t.trx0/n):0,f=t.try1>t.try0?Math.ceil(t.try1/i)-Math.floor(t.try0/i):0,c=u*f;t.precinctParameters={precinctWidth:n,precinctHeight:i,numprecinctswide:u,numprecinctshigh:f,numprecincts:c,precinctWidthInSubband:o,precinctHeightInSubband:s}}function f(e,t,r){var n,i,a,o,s=r.xcb_,u=r.ycb_,f=1<>s,h=t.tby0>>u,d=t.tbx1+f-1>>s,p=t.tby1+c-1>>u,g=t.resolution.precinctParameters,m=[],v=[];for(i=h;ib.cbxMax&&(b.cbxMax=n),ib.cbyMax&&(b.cbyMax=i)):v[o]=b={cbxMin:n,cbyMin:i,cbxMax:n,cbyMax:i},a.precinct=b}}t.codeblockParameters={codeblockWidth:s,codeblockHeight:u,numcodeblockwide:d-l+1,numcodeblockhigh:p-h+1},t.codeblocks=m,t.precincts=v}function c(e,t,r){for(var n=[],i=e.subbands,a=0,o=i.length;ae.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[f],r=t.precinctParameters.numprecincts;he.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[u],r=t.precinctParameters.numprecincts;he.codingStyleParameters.decompositionLevelsCount)){var a=e.resolutions[r],o=a.precinctParameters.numprecincts;if(!(i>=o)){for(;t=0;--m){var v=u.resolutions[m],_=g*v.precinctParameters.precinctWidth,w=g*v.precinctParameters.precinctHeight;l=Math.min(l,_),h=Math.min(h,w),d=Math.max(d,v.precinctParameters.numprecinctswide),p=Math.max(p,v.precinctParameters.numprecinctshigh),c[m]={width:_,height:w},g<<=1}r=Math.min(r,l),n=Math.min(n,h),i=Math.max(i,d),a=Math.max(a,p),o[s]={resolutions:c,minWidth:l,minHeight:h,maxNumWide:d,maxNumHigh:p}}return{components:o,minWidth:r,minHeight:n,maxNumWide:i,maxNumHigh:a}}function b(e){for(var t=e.SIZ,r=e.currentTile.index,n=e.tiles[r],i=t.Csiz,a=0;a>>h&(1<0;){var j=x.shift();b=j.codeblock,void 0===b.data&&(b.data=[]),b.data.push({data:r,start:n+l,end:n+l+j.dataLength,codingpasses:j.codingpasses}),l+=j.dataLength}}}return l}function x(e,t,r,n,i,a,o,s){for(var f=n.tbx0,c=n.tby0,l=n.tbx1-n.tbx0,h=n.codeblocks,d="H"===n.type.charAt(0)?1:0,p="H"===n.type.charAt(1)?t:0,g=0,m=h.length;g=a?e[G]=B:e[G]=B*(1<0?1-m:0));var I=v.subbands[y],T=A[I.type],L=h?1:Math.pow(2,l+T-S)*(1+E/2048),M=f+S-1;x(b,_,w,I,L,M,h,c)}p.push({width:_,height:w,items:b})}var P=d.calculate(p,n.tcx0,n.tcy0);return{left:n.tcx0,top:n.tcy0,width:P.width,height:P.height,items:P.items}}function E(e){for(var t=e.SIZ,r=e.components,n=t.Csiz,i=[],a=0,o=e.tiles.length;a>2),b=y+w,x=y+_,I[L++]=b<=0?0:b>=h?255:b>>c,I[L++]=y<=0?0:y>=h?255:y>>c,I[L++]=x<=0?0:x>=h?255:x>>c;else for(g=0;g=h?255:b>>c,I[L++]=y<=0?0:y>=h?255:y>>c,I[L++]=x<=0?0:x>=h?255:x>>c;if(M)for(g=0,L=3;g=p?255:E+l>>c}else for(s=0;s=h?255:S+l>>c,L+=n}i.push(T)}return i}function S(e,t){for(var r=e.SIZ,n=r.Csiz,i=e.tiles[t],a=0;a>24&255,u>>16&255,u>>8&255,255&u);h("Unsupported header type "+u+" ("+g+")")}c&&(r+=f)}},parseImageProperties:function(e){for(var t=e.getByte();t>=0;){var r=t;t=e.getByte();var n=r<<8|t;if(65361===n){e.skip(4);var i=e.getInt32()>>>0,a=e.getInt32()>>>0,o=e.getInt32()>>>0,s=e.getInt32()>>>0;e.skip(16);var u=e.getUint16();return this.width=i-o,this.height=a-s,this.componentsCount=u,void(this.bitsPerComponent=8)}}throw new Error("JPX Error: No size marker found in JPX stream")},parseCodestream:function(e,t,o){var s={};try{for(var u=!1,f=t;f+1>5,p=[];l<_+f;){var L={};8===g?(L.epsilon=e[l++]>>3,L.mu=0):(L.epsilon=e[l]>>3,L.mu=(7&e[l])<<8|e[l+1],l+=2),p.push(L)}T.SPqcds=p,s.mainHeader?s.QCD=T:(s.currentTile.QCD=T,s.currentTile.QCC=[]);break;case 65373:_=n(e,f);var M={};l=f+2;var R;switch(s.SIZ.Csiz<257?R=e[l++]:(R=n(e,l),l+=2),d=e[l++],31&d){case 0:g=8,m=!0;break;case 1:g=16,m=!1;break;case 2:g=16,m=!0;break;default:throw new Error("JPX Error: Invalid SQcd value "+d)}for(M.noQuantization=8===g,M.scalarExpounded=m,M.guardBits=d>>5,p=[];l<_+f;)L={},8===g?(L.epsilon=e[l++]>>3,L.mu=0):(L.epsilon=e[l]>>3,L.mu=(7&e[l])<<8|e[l+1],l+=2),p.push(L);M.SPqcds=p,s.mainHeader?s.QCC[R]=M:s.currentTile.QCC[R]=M;break;case 65362:_=n(e,f);var C={};l=f+2;var P=e[l++];C.entropyCoderWithCustomPrecincts=!!(1&P),C.sopMarkerUsed=!!(2&P),C.ephMarkerUsed=!!(4&P),C.progressionOrder=e[l++],C.layersCount=n(e,l),l+=2,C.multipleComponentTransform=e[l++],C.decompositionLevelsCount=e[l++],C.xcb=(15&e[l++])+2,C.ycb=(15&e[l++])+2;var B=e[l++];if(C.selectiveArithmeticCodingBypass=!!(1&B),C.resetContextProbabilities=!!(2&B),C.terminationOnEachCodingPass=!!(4&B),C.verticalyStripe=!!(8&B),C.predictableTermination=!!(16&B),C.segmentationSymbolUsed=!!(32&B),C.reversibleTransformation=e[l++],C.entropyCoderWithCustomPrecincts){for(var D=[];l<_+f;){var U=e[l++];D.push({PPx:15&U,PPy:U>>4})}C.precinctsSizes=D}var z=[];if(C.selectiveArithmeticCodingBypass&&z.push("selectiveArithmeticCodingBypass"),C.resetContextProbabilities&&z.push("resetContextProbabilities"),C.terminationOnEachCodingPass&&z.push("terminationOnEachCodingPass"),C.verticalyStripe&&z.push("verticalyStripe"),C.predictableTermination&&z.push("predictableTermination"),z.length>0)throw u=!0,new Error("JPX Error: Unsupported COD options ("+z.join(", ")+")");s.mainHeader?s.COD=C:(s.currentTile.COD=C,s.currentTile.COC=[]);break;case 65424:_=n(e,f),v={},v.index=n(e,f+2),v.length=a(e,f+4),v.dataEnd=v.length+f-2,v.partIndex=e[f+8],v.partsCount=e[f+9],s.mainHeader=!1,0===v.partIndex&&(v.COD=s.COD,v.COC=s.COC.slice(0),v.QCD=s.QCD,v.QCC=s.QCC.slice(0)),s.currentTile=v;break;case 65427:v=s.currentTile,0===v.partIndex&&(S(s,v.index),b(s)),_=v.dataEnd-f,y(s,e,f,_);break;case 65365:case 65367:case 65368:case 65380:_=n(e,f);break;case 65363:throw new Error("JPX Error: Codestream code 0xFF53 (COC) is not implemented");default:throw new Error("JPX Error: Unknown codestream code: "+c.toString(16))}f+=_}}catch(e){if(u||this.failOnCorruptedImage)throw e;h("Trying to recover from "+e.message)}this.tiles=E(s),this.width=s.SIZ.Xsiz-s.SIZ.XOsiz,this.height=s.SIZ.Ysiz-s.SIZ.YOsiz,this.componentsCount=s.SIZ.Csiz}};var I=function(){function e(e,r){var n=t(Math.max(e,r))+1;this.levels=[];for(var i=0;i>=1,t>>=1,n++}n--,r=this.levels[n],r.items[r.index]=i,this.currentLevel=n,delete this.value},incrementValue:function(){var e=this.levels[this.currentLevel];e.items[e.index]++},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];return e--,e<0?(this.value=r,!1):(this.currentLevel=e,t=this.levels[e],t.items[t.index]=r,!0)}},e}(),T=function(){function e(e,r,n){var i=t(Math.max(e,r))+1;this.levels=[];for(var a=0;ar)return this.currentLevel=n,this.propagateValues(),!1;e>>=1,t>>=1,n++}return this.currentLevel=n-1,!0},incrementValue:function(e){var t=this.levels[this.currentLevel];t.items[t.index]=e+1,this.propagateValues()},propagateValues:function(){for(var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];--e>=0;)t=this.levels[e],t.items[t.index]=r},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];return t.items[t.index]=255,e--,!(e<0)&&(this.currentLevel=e,t=this.levels[e],t.items[t.index]=r,!0)}},e}(),L=function(){function e(e,t,r,o,s){this.width=e,this.height=t,this.contextLabelTable="HH"===r?a:"HL"===r?i:n;var u=e*t;this.neighborsSignificance=new Uint8Array(u),this.coefficentsSign=new Uint8Array(u),this.coefficentsMagnitude=s>14?new Uint32Array(u):s>6?new Uint16Array(u):new Uint8Array(u),this.processingFlags=new Uint8Array(u); +var f=new Uint8Array(u);if(0!==o)for(var c=0;c0,u=t+10&&(n=r-a,s&&(i[n-1]+=16),u&&(i[n+1]+=16),i[n]+=4),e+1=r)break;if(o[g]&=c,!n[g]&&a[g]){var _=u[a[g]],w=e.readBit(s,_);if(w){var b=this.decodeSignBit(v,p,g);i[g]=b,n[g]=1,this.setNeighborsSignificance(v,p,g),o[g]|=h}f[g]++,o[g]|=l}}},decodeSignBit:function(e,t,r){var n,i,a,o,s,u,f=this.width,c=this.height,l=this.coefficentsMagnitude,h=this.coefficentsSign;o=t>0&&0!==l[r-1],t+10&&0!==l[r-f],e+1=0?(s=9+n,u=this.decoder.readBit(this.contexts,s)):(s=9-n,u=1^this.decoder.readBit(this.contexts,s)),u},runMagnitudeRefinementPass:function(){for(var e,t=this.decoder,r=this.width,n=this.height,i=this.coefficentsMagnitude,a=this.neighborsSignificance,o=this.contexts,s=this.bitsDecoded,u=this.processingFlags,f=1,c=2,l=r*n,h=4*r,d=0;d>1;t|=0;var i,a,o,s,u=-1.586134342059924,f=-.052980118572961,c=.882911075530934,l=.443506852043971,h=1.230174104914001,d=1/h;for(i=t-3,a=n+4;a--;i+=2)e[i]*=d;for(i=t-2,o=l*e[i-1],a=n+3;a--&&(s=l*e[i+1],e[i]=h*e[i]-o-s,a--);i+=2)i+=2,o=l*e[i+1],e[i]=h*e[i]-o-s;for(i=t-1,o=c*e[i-1],a=n+2;a--&&(s=c*e[i+1],e[i]-=o+s,a--);i+=2)i+=2,o=c*e[i+1],e[i]-=o+s;for(i=t,o=f*e[i-1],a=n+1;a--&&(s=f*e[i+1],e[i]-=o+s,a--);i+=2)i+=2,o=f*e[i+1],e[i]-=o+s;if(0!==n)for(i=t+1,o=u*e[i-1],a=n;a--&&(s=u*e[i+1],e[i]-=o+s,a--);i+=2)i+=2,o=u*e[i+1],e[i]-=o+s},e}(),C=function(){function e(){M.call(this)}return e.prototype=Object.create(M.prototype),e.prototype.filter=function(e,t,r){var n=r>>1;t|=0;var i,a;for(i=t,a=n+1;a--;i+=2)e[i]-=e[i-1]+e[i+1]+2>>2;for(i=t+1,a=n;a--;i+=2)e[i]+=e[i-1]+e[i+1]>>1},e}();return e}(),c=function(){function e(){}function i(e,t,r){this.data=e,this.start=t,this.end=r}function s(e,t,r){function n(e){for(var t=0,n=0;n>>0}var i=e.getContexts(t),a=1,o=n(1),s=n(1)?n(1)?n(1)?n(1)?n(1)?n(32)+4436:n(12)+340:n(8)+84:n(6)+20:n(4)+4:n(2);return 0===o?s:s>0?-s:null}function f(e,t,r){for(var n=e.getContexts("IAID"),i=1,a=0;a=P&&T=B)for(Z=Z<<1&_,d=0;d=0&&M=0&&(R=O[L][M],R&&(Z|=R<=e?B<<=1:B=B<<1|x[C][P];for(c=0;c=b||P<0||P>=w?B<<=1:B=B<<1|n[C][P];var D=k.readBit(E,B);M[R]=D}}return x}function p(e,r,n,i,a,o,u,c,p,m,v){e&&l("JBIG2 error: huffman is not supported");for(var _=[],w=0,b=t(n.length+i),y=v.decoder,x=v.contextCache;_.length1)I=g(e,r,E,w,0,T,1,n.concat(_),b,0,0,1,0,o,p,m,v);else{var L=f(x,y,b),M=s(x,"IARDX",y),R=s(x,"IARDY",y),C=L>1)+j,(N>>1)+Z,!1,w,b)}var q,G,H,W=P-(1&g?0:O),V=R-(2&g?z:0);if(h){for(q=0;q>5&7,c=[31&u],h=t+6;if(7===u){f=536870911&a(e,h-1),h+=3;var d=f+7>>3;for(c[0]=e[h++];--d>0;)c.push(e[h++])}else 5!==u&&6!==u||l("JBIG2 error: invalid referred-to flags");r.retainBits=c;var p,g,m=r.number<=256?1:r.number<=65536?2:4,v=[];for(p=0;p>>24&255,S[3]=b.height>>16&255,S[4]=b.height>>8&255,S[5]=255&b.height,p=h,g=e.length;p>2&3,p.huffmanDWSelector=g>>4&3,p.bitmapSizeSelector=g>>6&1,p.aggregationInstancesSelector=g>>7&1,p.bitmapCodingContextUsed=!!(256&g),p.bitmapCodingContextRetained=!!(512&g),p.template=g>>10&3,p.refinementTemplate=g>>12&1,h+=2,!p.huffman){for(u=0===p.template?4:1,o=[],s=0;s>2&3),m.referenceCorner=v>>4&3,m.transposed=!!(64&v),m.combinationOperator=v>>7&3,m.defaultPixelValue=v>>9&1,m.dsOffset=v<<17>>27,m.refinementTemplate=v>>15&1,m.huffman){var w=n(c,h);h+=2,m.huffmanFS=3&w,m.huffmanDS=w>>2&3,m.huffmanDT=w>>4&3,m.huffmanRefinementDW=w>>6&3,m.huffmanRefinementDH=w>>8&3,m.huffmanRefinementDX=w>>10&3,m.huffmanRefinementDY=w>>12&3,m.huffmanRefinementSizeSelector=!!(14&w)}if(m.refinement&&!m.refinementTemplate){for(o=[],s=0;s<2;s++)o.push({x:r(c,h),y:r(c,h+1)}),h+=2;m.refinementAt=o}m.numberOfSymbolInstances=a(c,h),h+=4,m.huffman&&l("JBIG2 error: huffman is not supported"),i=[m,f.referredTo,c,h,d];break;case 38:case 39:var b={};b.info=_(c,h),h+=L;var y=c[h++];if(b.mmr=!!(1&y),b.template=y>>1&3,b.prediction=!!(8&y),!b.mmr){for(u=0===b.template?4:1,o=[],s=0;s>2&1,x.combinationOperator=k>>3&3,x.requiresBuffer=!!(32&k),x.combinationOperatorOverride=!!(64&k),i=[x];break;case 49:break;case 50:break;case 51:break;case 62:break;default:l("JBIG2 error: segment type "+f.typeName+"("+f.type+") is not implemented")}var E="on"+f.typeName;E in t&&t[E].apply(t,i)}function b(e,t){for(var r=0,n=e.length;r>3,r=new Uint8Array(t*e.height);if(e.defaultPixelValue)for(var n=0,i=r.length;n>3,c=o.combinationOperatorOverride?e.combinationOperator:o.combinationOperator,h=this.buffer,d=128>>(7&e.x),p=e.y*f+(e.x>>3);switch(c){case 0:for(r=0;r>=1,i||(i=128,a++);p+=f}break;case 2:for(r=0;r>=1,i||(i=128,a++);p+=f}break;default:l("JBIG2 error: operator "+c+" is not supported")}},onImmediateGenericRegion:function(e,t,r,n){var a=e.info,o=new i(t,r,n),s=h(e.mmr,a.width,a.height,e.template,e.prediction,null,e.at,o);this.drawBitmap(a,s)},onImmediateLosslessGenericRegion:function(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function(e,t,r,n,a,o){var s;e.huffman&&l("JBIG2 error: huffman is not supported");var u=this.symbols;u||(this.symbols=u={});for(var f=[],c=0,h=r.length;c>=1;this.width=s,this.height=u,this.data=e},e.JpegImage=s,e.JpxImage=f,e.Jbig2Image=c}(o||(o={}));var s=o.JpegImage,u=o.JpxImage,f=o.Jbig2Image},{}],5:[function(e,t,r){(function(e){"use strict";function t(t){return t instanceof ArrayBuffer?s(t):e.isBuffer(t)?t:t instanceof Uint8Array?new e(t):t}function n(t){return t instanceof ArrayBuffer?t:e.isBuffer(t)?o(t):t instanceof Uint8Array?o(t):t}function i(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):e.isBuffer(t)?new Uint8Array(t):t}function a(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):e.isBuffer(t)?t:t}function o(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n=0;s--)if(u[s]!==f[s])return!1;for(s=u.length-1;s>=0;s--)if(o=u[s],!d(e[o],t[o],r,n))return!1;return!0}function m(e,t,r){d(e,t,!0)&&l(e,t,r,"notDeepStrictEqual",m)}function v(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&t.call({},e)===!0}function _(e){var t;try{e()}catch(e){t=e}return t}function w(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=_(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&l(i,r,"Missing expected exception"+n);var a="string"==typeof n,o=!e&&b.isError(i),s=!e&&i&&!r;if((o&&a&&v(i,r)||s)&&l(i,r,"Got unwanted exception"+n),e&&i&&r&&!v(i,r)||!e&&i)throw i}var b=e("util/"),y=Object.prototype.hasOwnProperty,x=Array.prototype.slice,k=function(){return"foo"===function(){}.name}(),E=t.exports=h,S=/\s*function\s+([^\(\s]*)\s*/;E.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=c(this),this.generatedMessage=!0);var t=e.stackStartFunction||l;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=s(t),a=n.indexOf("\n"+i);if(a>=0){var o=n.indexOf("\n",a+1);n=n.substring(o+1)}this.stack=n}}},b.inherits(E.AssertionError,Error),E.fail=l,E.ok=h,E.equal=function(e,t,r){e!=t&&l(e,t,r,"==",E.equal)},E.notEqual=function(e,t,r){e==t&&l(e,t,r,"!=",E.notEqual)},E.deepEqual=function(e,t,r){d(e,t,!1)||l(e,t,r,"deepEqual",E.deepEqual)},E.deepStrictEqual=function(e,t,r){d(e,t,!0)||l(e,t,r,"deepStrictEqual",E.deepStrictEqual)},E.notDeepEqual=function(e,t,r){d(e,t,!1)&&l(e,t,r,"notDeepEqual",E.notDeepEqual)},E.notDeepStrictEqual=m,E.strictEqual=function(e,t,r){e!==t&&l(e,t,r,"===",E.strictEqual)},E.notStrictEqual=function(e,t,r){e===t&&l(e,t,r,"!==",E.notStrictEqual)},E.throws=function(e,t,r){w(!0,e,t,r)},E.doesNotThrow=function(e,t,r){w(!1,e,t,r)},E.ifError=function(e){if(e)throw e};var A=Object.keys||function(e){var t=[];for(var r in e)y.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":53}],17:[function(e,t,r){"use strict";function n(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function i(e){return 3*e.length/4-n(e)}function a(e){var t,r,i,a,o,s,u=e.length;o=n(e),s=new l(3*u/4-o),i=o>0?u-4:u;var f=0;for(t=0,r=0;t>16&255,s[f++]=a>>8&255,s[f++]=255&a;return 2===o?(a=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,s[f++]=255&a):1===o&&(a=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,s[f++]=a>>8&255,s[f++]=255&a),s}function o(e){return f[e>>18&63]+f[e>>12&63]+f[e>>6&63]+f[63&e]}function s(e,t,r){for(var n,i=[],a=t;ac?c:u+o));return 1===n?(t=e[r-1],i+=f[t>>2],i+=f[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=f[t>>10],i+=f[t>>4&63],i+=f[t<<2&63],i+="="),a.push(i),a.join("")}r.byteLength=i,r.toByteArray=a,r.fromByteArray=u;for(var f=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,p=h.length;dr.UNZIP)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function a(e,t){for(var r=0;rr.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBitsr.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.levelr.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevelr.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=r.Z_FILTERED&&e.strategy!=r.Z_HUFFMAN_ONLY&&e.strategy!=r.Z_RLE&&e.strategy!=r.Z_FIXED&&e.strategy!=r.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!n.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new g.Zlib(t);var i=this;this._hadError=!1,this._binding.onerror=function(e,t){i._binding=null,i._hadError=!0;var n=new Error(e);n.errno=t,n.code=r.codes[t],i.emit("error",n)};var a=r.Z_DEFAULT_COMPRESSION;"number"==typeof e.level&&(a=e.level);var o=r.Z_DEFAULT_STRATEGY;"number"==typeof e.strategy&&(o=e.strategy),this._binding.init(e.windowBits||r.Z_DEFAULT_WINDOWBITS,a,e.memLevel||r.Z_DEFAULT_MEMLEVEL,o,e.dictionary),this._buffer=new n(this._chunkSize),this._offset=0,this._closed=!1,this._level=a,this._strategy=o,this.once("end",this.close)}var p=e("_stream_transform"),g=e("./binding"),m=e("util"),v=e("assert").ok;g.Z_MIN_WINDOWBITS=8,g.Z_MAX_WINDOWBITS=15,g.Z_DEFAULT_WINDOWBITS=15,g.Z_MIN_CHUNK=64,g.Z_MAX_CHUNK=1/0,g.Z_DEFAULT_CHUNK=16384,g.Z_MIN_MEMLEVEL=1,g.Z_MAX_MEMLEVEL=9,g.Z_DEFAULT_MEMLEVEL=8,g.Z_MIN_LEVEL=-1,g.Z_MAX_LEVEL=9,g.Z_DEFAULT_LEVEL=g.Z_DEFAULT_COMPRESSION,Object.keys(g).forEach(function(e){e.match(/^Z/)&&(r[e]=g[e])}),r.codes={Z_OK:g.Z_OK,Z_STREAM_END:g.Z_STREAM_END,Z_NEED_DICT:g.Z_NEED_DICT,Z_ERRNO:g.Z_ERRNO,Z_STREAM_ERROR:g.Z_STREAM_ERROR,Z_DATA_ERROR:g.Z_DATA_ERROR,Z_MEM_ERROR:g.Z_MEM_ERROR,Z_BUF_ERROR:g.Z_BUF_ERROR,Z_VERSION_ERROR:g.Z_VERSION_ERROR},Object.keys(r.codes).forEach(function(e){r.codes[r.codes[e]]=e}),r.Deflate=o,r.Inflate=s,r.Gzip=u,r.Gunzip=f,r.DeflateRaw=c,r.InflateRaw=l,r.Unzip=h,r.createDeflate=function(e){return new o(e)},r.createInflate=function(e){return new s(e)},r.createDeflateRaw=function(e){return new c(e)},r.createInflateRaw=function(e){return new l(e)},r.createGzip=function(e){return new u(e)},r.createGunzip=function(e){return new f(e)},r.createUnzip=function(e){return new h(e)},r.deflate=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new o(t),e,r)},r.deflateSync=function(e,t){return a(new o(t),e)},r.gzip=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new u(t),e,r)},r.gzipSync=function(e,t){return a(new u(t),e)},r.deflateRaw=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new c(t),e,r)},r.deflateRawSync=function(e,t){return a(new c(t),e)},r.unzip=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new h(t),e,r)},r.unzipSync=function(e,t){return a(new h(t),e)},r.inflate=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new s(t),e,r)},r.inflateSync=function(e,t){return a(new s(t),e)},r.gunzip=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new f(t),e,r)},r.gunzipSync=function(e,t){return a(new f(t),e)},r.inflateRaw=function(e,t,r){return"function"==typeof t&&(r=t,t={}),i(new l(t),e,r)},r.inflateRawSync=function(e,t){return a(new l(t),e)},m.inherits(d,p),d.prototype.params=function(e,n,i){if(er.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(n!=r.Z_FILTERED&&n!=r.Z_HUFFMAN_ONLY&&n!=r.Z_RLE&&n!=r.Z_FIXED&&n!=r.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+n);if(this._level!==e||this._strategy!==n){var a=this;this.flush(g.Z_SYNC_FLUSH,function(){a._binding.params(e,n),a._hadError||(a._level=e,a._strategy=n,i&&i())})}else t.nextTick(i)},d.prototype.reset=function(){return this._binding.reset()},d.prototype._flush=function(e){this._transform(new n(0),"",e)},d.prototype.flush=function(e,r){var i=this._writableState;if(("function"==typeof e||void 0===e&&!r)&&(r=e,e=g.Z_FULL_FLUSH),i.ended)r&&t.nextTick(r);else if(i.ending)r&&this.once("end",r);else if(i.needDrain){var a=this;this.once("drain",function(){a.flush(r)})}else this._flushFlag=e,this.write(new n(0),"",r)},d.prototype.close=function(e){if(e&&t.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var r=this;t.nextTick(function(){r.emit("close")})}},d.prototype._transform=function(e,t,r){var i,a=this._writableState,o=a.ending||a.ended,s=o&&(!e||a.length===e.length);if(null===!e&&!n.isBuffer(e))return r(new Error("invalid input"));s?i=g.Z_FINISH:(i=this._flushFlag,e.length>=a.length&&(this._flushFlag=this._opts.flush||g.Z_NO_FLUSH));this._processChunk(e,i,r)},d.prototype._processChunk=function(e,t,r){function i(c,d){if(!u._hadError){var p=o-d;if(v(p>=0,"have should not go down"),p>0){var g=u._buffer.slice(u._offset,u._offset+p);u._offset+=p,f?u.push(g):(l.push(g),h+=g.length)}if((0===d||u._offset>=u._chunkSize)&&(o=u._chunkSize,u._offset=0,u._buffer=new n(u._chunkSize)),0===d){if(s+=a-c,a=c,!f)return!0;var m=u._binding.write(t,e,s,a,u._buffer,u._offset,u._chunkSize);return m.callback=i,void(m.buffer=e)}return!!f&&void r()}}var a=e&&e.length,o=this._chunkSize-this._offset,s=0,u=this,f="function"==typeof r;if(!f){var c,l=[],h=0;this.on("error",function(e){c=e});do var d=this._binding.writeSync(t,e,s,a,this._buffer,this._offset,o);while(!this._hadError&&i(d[0],d[1]));if(this._hadError)throw c;var p=n.concat(l,h);return this.close(),p}var g=this._binding.write(t,e,s,a,this._buffer,this._offset,o);g.buffer=e,g.callback=i},m.inherits(o,d),m.inherits(s,d),m.inherits(u,d),m.inherits(f,d),m.inherits(c,d),m.inherits(l,d),m.inherits(h,d)}).call(this,e("_process"),e("buffer").Buffer)},{"./binding":19,_process:42,_stream_transform:48,assert:16,buffer:22,util:53}],21:[function(e,t,r){(function(t){"use strict";var n=e("buffer"),i=n.Buffer,a=n.SlowBuffer,o=n.kMaxLength||2147483647;r.alloc=function(e,t,r){if("function"==typeof i.alloc)return i.alloc(e,t,r);if("number"==typeof r)throw new TypeError("encoding must not be number");if("number"!=typeof e)throw new TypeError("size must be a number");if(e>o)throw new RangeError("size is too large");var n=r,a=t;void 0===a&&(n=void 0,a=0);var s=new i(e);if("string"==typeof a)for(var u=new i(a,n),f=u.length,c=-1;++co)throw new RangeError("size is too large");return new i(e)},r.from=function(e,r,n){if("function"==typeof i.from&&(!t.Uint8Array||Uint8Array.from!==i.from))return i.from(e,r,n);if("number"==typeof e)throw new TypeError('"value" argument must not be a number');if("string"==typeof e)return new i(e,r);if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var a=r;if(1===arguments.length)return new i(e);"undefined"==typeof a&&(a=0);var o=n;if("undefined"==typeof o&&(o=e.byteLength-a),a>=e.byteLength)throw new RangeError("'offset' is out of bounds");if(o>e.byteLength-a)throw new RangeError("'length' is out of bounds");return new i(e.slice(a,a+o))}if(i.isBuffer(e)){var s=new i(e.length);return e.copy(s,0,0,e.length),s}if(e){if(Array.isArray(e)||"undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return new i(e);if("Buffer"===e.type&&Array.isArray(e.data))return new i(e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},r.allocUnsafeSlow=function(e){if("function"==typeof i.allocUnsafeSlow)return i.allocUnsafeSlow(e);if("number"!=typeof e)throw new TypeError("size must be a number");if(e>=o)throw new RangeError("size is too large");return new a(e)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{buffer:22}],22:[function(e,t,r){"use strict";function n(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function i(e){if(e>J)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(e)}return o(e,t,r)}function o(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return e instanceof ArrayBuffer?h(e,t,r):"string"==typeof e?c(e,t):d(e)}function s(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function u(e,t,r){return s(e),e<=0?i(e):void 0!==t?"string"==typeof r?i(e).fill(t,r):i(e).fill(t):i(e)}function f(e){return s(e),i(e<0?0:0|p(e))}function c(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!a.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var r=0|m(e,t),n=i(r),o=n.write(e,t);return o!==r&&(n=n.slice(0,o)),n}function l(e){for(var t=e.length<0?0:0|p(e.length),r=i(t),n=0;n=J)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+J.toString(16)+" bytes");return 0|e}function g(e){return+e!=e&&(e=0),a.alloc(+e)}function m(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(e).length;default:if(n)return Z(e).length;t=(""+t).toLowerCase(),n=!0}}function v(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,t>>>=0,r<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return M(this,t,r);case"latin1":case"binary":return R(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function _(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function w(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=a.from(t,n)),a.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){function a(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,s=e.length,u=t.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,s/=2,u/=2,r/=2}var f;if(i){var c=-1;for(f=r;fs&&(r=s-u),f=r;f>=0;f--){for(var l=!0,h=0;hi&&(n=i)):n=i;var a=t.length;if(a%2!==0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;o239?4:a>223?3:a>191?2:1;if(i+s<=r){var u,f,c,l;switch(s){case 1:a<128&&(o=a);break;case 2:u=e[i+1],128===(192&u)&&(l=(31&a)<<6|63&u,l>127&&(o=l));break;case 3:u=e[i+1],f=e[i+2],128===(192&u)&&128===(192&f)&&(l=(15&a)<<12|(63&u)<<6|63&f,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:u=e[i+1],f=e[i+2],c=e[i+3],128===(192&u)&&128===(192&f)&&128===(192&c)&&(l=(15&a)<<18|(63&u)<<12|(63&f)<<6|63&c,l>65535&&l<1114112&&(o=l))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return L(n)}function L(e){var t=e.length;if(t<=K)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var i="",a=t;ar)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,r,n,i,o){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function U(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function z(e,t,r,n,i){return t=+t,r>>>=0,i||U(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),Y.write(e,t,r,n,23,4),r+4}function O(e,t,r,n,i){return t=+t,r>>>=0,i||U(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),Y.write(e,t,r,n,52,8),r+8}function F(e){if(e=N(e).replace(Q,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function N(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function j(e){return e<16?"0"+e.toString(16):e.toString(16)}function Z(e,t){t=t||1/0;for(var r,n=e.length,i=null,a=[],o=0;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function q(e){for(var t=[],r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function H(e){return X.toByteArray(F(e))}function W(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function V(e){return e!==e}var X=e("base64-js"),Y=e("ieee754");r.Buffer=a,r.SlowBuffer=g,r.INSPECT_MAX_BYTES=50;var J=2147483647;r.kMaxLength=J,a.TYPED_ARRAY_SUPPORT=n(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(e,t,r){return o(e,t,r)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(e,t,r){return u(e,t,r)},a.allocUnsafe=function(e){return f(e)},a.allocUnsafeSlow=function(e){return f(e)},a.isBuffer=function(e){return null!=e&&e._isBuffer===!0},a.compare=function(e,t){if(!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},a.prototype.compare=function(e,t,r,n,i){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,s=r-t,u=Math.min(o,s),f=this.slice(n,i),c=e.slice(t,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return y(this,e,t,r);case"utf8":case"utf-8":return x(this,e,t,r);case"ascii":return k(this,e,t,r);case"latin1":case"binary":return E(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var K=4096;a.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),t>>=0,t>>>=0,r||B(e,t,this.length);for(var n=this[e],i=1,a=0;++a>>=0,t>>>=0,r||B(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},a.prototype.readUInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);for(var n=this[e],i=1,a=0;++a=i&&(n-=Math.pow(2,8*t)),n},a.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);for(var n=t,i=1,a=this[e+--n];n>0&&(i*=256);)a+=this[e+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*t)),a},a.prototype.readInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),128&this[e]?(255-this[e]+1)*-1:this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||B(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){e>>>=0,t||B(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||B(e,4,this.length),Y.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||B(e,4,this.length),Y.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||B(e,8,this.length),Y.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||B(e,8,this.length),Y.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){var i=Math.pow(2,8*r)-1;D(this,e,t,r,i,0)}var a=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,!n){var i=Math.pow(2,8*r)-1;D(this,e,t,r,i,0)}var a=r-1,o=1;for(this[t+a]=255&e;--a>=0&&(o*=256);)this[t+a]=e/o&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);D(this,e,t,r,i-1,-i)}var a=0,o=1,s=0;for(this[t]=255&e;++a>0)-s&255;return t+r},a.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);D(this,e,t,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[t+a]=255&e;--a>=0&&(o*=256);)e<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(e/o>>0)-s&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeFloatLE=function(e,t,r){return z(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return z(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return O(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return O(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(a<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var o;if("number"==typeof e)for(o=t;o0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){ +function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var n=!1;return r.listener=t,this.on(e,r),this},n.prototype.removeListener=function(e,t){var r,n,a,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],a=r.length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],i(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],25:[function(e,t,r){r.read=function(e,t,r,n,i){var a,o,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];for(l+=h,a=d&(1<<-c)-1,d>>=-c,c+=s;c>0;a=256*a+e[t+l],l+=h,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=n;c>0;o=256*o+e[t+l],l+=h,c-=8);if(0===a)a=1-f;else{if(a===u)return o?NaN:(d?-1:1)*(1/0);o+=Math.pow(2,n),a-=f}return(d?-1:1)*o*Math.pow(2,a-n)},r.write=function(e,t,r,n,i,a){var o,s,u,f=8*a-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:a-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),t+=o+l>=1?h/u:h*Math.pow(2,1-l),t*u>=2&&(o++,u/=2),o+l>=c?(s=0,o=c):o+l>=1?(s=(t*u-1)*Math.pow(2,i),o+=l):(s=t*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(o=o<0;e[r+d]=255&o,d+=p,o/=256,f-=8);e[r+d-p]|=128*g}},{}],26:[function(e,t,r){(function(r){function n(e,t,r){if(e.readUInt32)return e.readUInt32(t,r);var n;if(r){if(e.readUInt32BE)return e.readUInt32BE(t);n=(e[t]<<24)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]}else{if(e.readUInt32LE)return e.readUInt32LE(t);n=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24)}return n}function i(e,t,r){if(e.readUInt16)return e.readUInt16(t,r);var n;if(r){if(e.readUInt16BE)return e.readUInt16BE(t);n=(e[t]<<8)+e[t+1]}else{if(e.readUInt16LE)return e.readUInt16LE(t);n=e[t]+(e[t+1]<<8)}return n}function a(e,t,r){r>7&&(t+=Math.floor(r/8),r%=8);var n=e[t];r<7&&(n>>>=7-r);var i=1&n;return i}function o(e,t,n,i,o){var s=0,u=!1;o&&(a(e,t,n)>0&&(u=!0),i--,n++);for(var f=[],c=0;c0&&(i-c)%8==0&&(f.push(s),s=0),s<<=1,s|=l}return f.push(s),s=new r(f),s.negative=!!u,s}function s(e){var t=[73,72,68,82],r=12;return!!l(e,r,t)&&(r+=4,{type:"image",format:"PNG",mimeType:"image/png",width:n(e,r,!0),height:n(e,r+4,!0)})}function u(e){for(var t=2,r=e.length,n=[255,[192,194]];t9?i(r,0,!0):r[0])*(r.negative?-1:1);a+=s,r=o(t,n,a,s,!0);var f=(s>9?i(r,0,!0):r[0])*(r.negative?-1:1);a+=s,r=o(t,n,a,s,!0);var c=(s>9?i(r,0,!0):r[0])*(r.negative?-1:1);a+=s,r=o(t,n,a,s,!0);var l=(s>9?i(r,0,!0):r[0])*(r.negative?-1:1);return{type:"flash",format:"SWF",mimeType:"application/x-shockwave-flash",width:Math.ceil((f-u)/20),height:Math.ceil((l-c)/20)}}function l(e,t,r){for(var n=r.length,i=0;i>>16&65535|0,o=0;0!==r;){o=r>2e3?2e3:r,r-=o;do i=i+t[n++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0}t.exports=n},{}],32:[function(e,t,r){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],33:[function(e,t,r){"use strict";function n(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}function i(e,t,r,n){var i=a,o=n+r;e^=-1;for(var s=n;s>>8^i[255&(e^t[s])];return e^-1}var a=n();t.exports=i},{}],34:[function(e,t,r){"use strict";function n(e,t){return e.msg=B[t],t}function i(e){return(e<<1)-(e>4?9:0)}function a(e){for(var t=e.length;--t>=0;)e[t]=0}function o(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(M.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function s(e,t){R._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,o(e.strm)}function u(e,t){e.pending_buf[e.pending++]=t}function f(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function c(e,t,r,n){var i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,M.arraySet(t,e.input,e.next_in,i,r),1===e.state.wrap?e.adler=C(e.adler,t,i,r):2===e.state.wrap&&(e.adler=P(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)}function l(e,t){var r,n,i=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match,u=e.strstart>e.w_size-le?e.strstart-(e.w_size-le):0,f=e.window,c=e.w_mask,l=e.prev,h=e.strstart+ce,d=f[a+o-1],p=f[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do if(r=t,f[r+o]===p&&f[r+o-1]===d&&f[r]===f[a]&&f[++r]===f[a+1]){a+=2,r++;do;while(f[++a]===f[++r]&&f[++a]===f[++r]&&f[++a]===f[++r]&&f[++a]===f[++r]&&f[++a]===f[++r]&&f[++a]===f[++r]&&f[++a]===f[++r]&&f[++a]===f[++r]&&ao){if(e.match_start=t,o=n,n>=s)break;d=f[a+o-1],p=f[a+o]}}while((t=l[t&c])>u&&0!==--i);return o<=e.lookahead?o:e.lookahead}function h(e){var t,r,n,i,a,o=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=o+(o-le)){M.arraySet(e.window,e.window,o,o,0),e.match_start-=o,e.strstart-=o,e.block_start-=o,r=e.hash_size,t=r;do n=e.head[--t],e.head[t]=n>=o?n-o:0;while(--r);r=o,t=r;do n=e.prev[--t],e.prev[t]=n>=o?n-o:0;while(--r);i+=o}if(0===e.strm.avail_in)break;if(r=c(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=fe)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(h(e),0===e.lookahead&&t===D)return be;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,s(e,!1),0===e.strm.avail_out))return be;if(e.strstart-e.block_start>=e.w_size-le&&(s(e,!1),0===e.strm.avail_out))return be}return e.insert=0,t===O?(s(e,!0),0===e.strm.avail_out?xe:ke):e.strstart>e.block_start&&(s(e,!1),0===e.strm.avail_out)?be:be}function p(e,t){for(var r,n;;){if(e.lookahead=fe&&(e.ins_h=(e.ins_h<=fe)if(n=R._tr_tally(e,e.strstart-e.match_start,e.match_length-fe),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=fe){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=fe&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=fe-1)),e.prev_length>=fe&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-fe,n=R._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-fe),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=(e.ins_h<=fe&&e.strstart>0&&(i=e.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){a=e.strstart+ce;do;while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=fe?(r=R._tr_tally(e,1,e.match_length-fe),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=R._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(s(e,!1),0===e.strm.avail_out))return be}return e.insert=0,t===O?(s(e,!0),0===e.strm.avail_out?xe:ke):e.last_lit&&(s(e,!1),0===e.strm.avail_out)?be:ye}function v(e,t){for(var r;;){if(0===e.lookahead&&(h(e),0===e.lookahead)){if(t===D)return be;break}if(e.match_length=0,r=R._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(s(e,!1),0===e.strm.avail_out))return be}return e.insert=0,t===O?(s(e,!0),0===e.strm.avail_out?xe:ke):e.last_lit&&(s(e,!1),0===e.strm.avail_out)?be:ye}function _(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function w(e){e.window_size=2*e.w_size,a(e.head),e.max_lazy_match=L[e.level].max_lazy,e.good_match=L[e.level].good_length,e.nice_match=L[e.level].nice_length,e.max_chain_length=L[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=fe-1,e.match_available=0,e.ins_h=0}function b(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Q,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new M.Buf16(2*se),this.dyn_dtree=new M.Buf16(2*(2*ae+1)),this.bl_tree=new M.Buf16(2*(2*oe+1)),a(this.dyn_ltree),a(this.dyn_dtree),a(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new M.Buf16(ue+1),this.heap=new M.Buf16(2*ie+1),a(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new M.Buf16(2*ie+1),a(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function y(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=K,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?de:_e,e.adler=2===t.wrap?0:1,t.last_flush=D,R._tr_init(t),N):n(e,Z)}function x(e){var t=y(e);return t===N&&w(e.state),t}function k(e,t){return e&&e.state?2!==e.state.wrap?Z:(e.state.gzhead=t,N):Z}function E(e,t,r,i,a,o){if(!e)return Z;var s=1;if(t===H&&(t=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),a<1||a>$||r!==Q||i<8||i>15||t<0||t>9||o<0||o>Y)return n(e,Z);8===i&&(i=9);var u=new b;return e.state=u,u.strm=e,u.wrap=s,u.gzhead=null,u.w_bits=i,u.w_size=1<F||t<0)return e?n(e,Z):Z;if(s=e.state,!e.output||!e.input&&0!==e.avail_in||s.status===we&&t!==O)return n(e,0===e.avail_out?G:Z);if(s.strm=e,r=s.last_flush,s.last_flush=t,s.status===de)if(2===s.wrap)e.adler=0,u(s,31),u(s,139),u(s,8),s.gzhead?(u(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),u(s,255&s.gzhead.time),u(s,s.gzhead.time>>8&255),u(s,s.gzhead.time>>16&255),u(s,s.gzhead.time>>24&255),u(s,9===s.level?2:s.strategy>=V||s.level<2?4:0),u(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(u(s,255&s.gzhead.extra.length),u(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=P(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=pe):(u(s,0),u(s,0),u(s,0),u(s,0),u(s,0),u(s,9===s.level?2:s.strategy>=V||s.level<2?4:0),u(s,Ee),s.status=_e);else{var h=Q+(s.w_bits-8<<4)<<8,d=-1;d=s.strategy>=V||s.level<2?0:s.level<6?1:6===s.level?2:3,h|=d<<6,0!==s.strstart&&(h|=he),h+=31-h%31,s.status=_e,f(s,h),0!==s.strstart&&(f(s,e.adler>>>16),f(s,65535&e.adler)),e.adler=1}if(s.status===pe)if(s.gzhead.extra){for(c=s.pending;s.gzindex<(65535&s.gzhead.extra.length)&&(s.pending!==s.pending_buf_size||(s.gzhead.hcrc&&s.pending>c&&(e.adler=P(e.adler,s.pending_buf,s.pending-c,c)),o(e),c=s.pending,s.pending!==s.pending_buf_size));)u(s,255&s.gzhead.extra[s.gzindex]),s.gzindex++;s.gzhead.hcrc&&s.pending>c&&(e.adler=P(e.adler,s.pending_buf,s.pending-c,c)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=ge)}else s.status=ge;if(s.status===ge)if(s.gzhead.name){c=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>c&&(e.adler=P(e.adler,s.pending_buf,s.pending-c,c)),o(e),c=s.pending,s.pending===s.pending_buf_size)){l=1;break}l=s.gzindexc&&(e.adler=P(e.adler,s.pending_buf,s.pending-c,c)),0===l&&(s.gzindex=0,s.status=me)}else s.status=me;if(s.status===me)if(s.gzhead.comment){c=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>c&&(e.adler=P(e.adler,s.pending_buf,s.pending-c,c)),o(e),c=s.pending,s.pending===s.pending_buf_size)){l=1;break}l=s.gzindexc&&(e.adler=P(e.adler,s.pending_buf,s.pending-c,c)),0===l&&(s.status=ve)}else s.status=ve;if(s.status===ve&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&o(e),s.pending+2<=s.pending_buf_size&&(u(s,255&e.adler),u(s,e.adler>>8&255),e.adler=0,s.status=_e)):s.status=_e),0!==s.pending){if(o(e),0===e.avail_out)return s.last_flush=-1,N}else if(0===e.avail_in&&i(t)<=i(r)&&t!==O)return n(e,G);if(s.status===we&&0!==e.avail_in)return n(e,G);if(0!==e.avail_in||0!==s.lookahead||t!==D&&s.status!==we){var p=s.strategy===V?v(s,t):s.strategy===X?m(s,t):L[s.level].func(s,t);if(p!==xe&&p!==ke||(s.status=we),p===be||p===xe)return 0===e.avail_out&&(s.last_flush=-1),N;if(p===ye&&(t===U?R._tr_align(s):t!==F&&(R._tr_stored_block(s,0,0,!1),t===z&&(a(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),o(e),0===e.avail_out))return s.last_flush=-1,N}return t!==O?N:s.wrap<=0?j:(2===s.wrap?(u(s,255&e.adler),u(s,e.adler>>8&255),u(s,e.adler>>16&255),u(s,e.adler>>24&255),u(s,255&e.total_in),u(s,e.total_in>>8&255),u(s,e.total_in>>16&255),u(s,e.total_in>>24&255)):(f(s,e.adler>>>16),f(s,65535&e.adler)),o(e),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?N:j)}function I(e){var t;return e&&e.state?(t=e.state.status,t!==de&&t!==pe&&t!==ge&&t!==me&&t!==ve&&t!==_e&&t!==we?n(e,Z):(e.state=null,t===_e?n(e,q):N)):Z}function T(e,t){var r,n,i,o,s,u,f,c,l=t.length;if(!e||!e.state)return Z;if(r=e.state,o=r.wrap,2===o||1===o&&r.status!==de||r.lookahead)return Z;for(1===o&&(e.adler=C(e.adler,t,l,0)),r.wrap=0,l>=r.w_size&&(0===o&&(a(r.head),r.strstart=0,r.block_start=0,r.insert=0),c=new M.Buf8(r.w_size),M.arraySet(c,t,l-r.w_size,r.w_size,0),t=c,l=r.w_size),s=e.avail_in,u=e.next_in,f=e.input,e.avail_in=l,e.next_in=0,e.input=t,h(r);r.lookahead>=fe;){n=r.strstart,i=r.lookahead-(fe-1);do r.ins_h=(r.ins_h<>>24,g>>>=x,m-=x,x=y>>>16&255,0===x)T[s++]=65535&y;else{if(!(16&x)){if(0===(64&x)){y=v[(65535&y)+(g&(1<>>=x,m-=x),m<15&&(g+=I[a++]<>>24,g>>>=x,m-=x,x=y>>>16&255,!(16&x)){if(0===(64&x)){y=_[(65535&y)+(g&(1<c){e.msg="invalid distance too far back",r.mode=n;break e}if(g>>>=x,m-=x,x=s-u,E>x){if(x=E-x,x>h&&r.sane){e.msg="invalid distance too far back",r.mode=n;break e}if(S=0,A=p,0===d){if(S+=l-x,x2;)T[s++]=A[S++],T[s++]=A[S++],T[s++]=A[S++],k-=3;k&&(T[s++]=A[S++],k>1&&(T[s++]=A[S++]))}else{S=s-E;do T[s++]=T[S++],T[s++]=T[S++],T[s++]=T[S++],k-=3;while(k>2);k&&(T[s++]=T[S++],k>1&&(T[s++]=T[S++]))}break}}break}}while(a>3,a-=k,m-=k<<3,g&=(1<>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function i(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new _.Buf16(320),this.work=new _.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=z,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new _.Buf32(ge),t.distcode=t.distdyn=new _.Buf32(me),t.sane=1,t.back=-1,L):C}function o(e){var t;return e&&e.state?(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,a(e)):C}function s(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15)?C:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,o(e))):C}function u(e,t){var r,n;return e?(n=new i,e.state=n,n.window=null,r=s(e,t),r!==L&&(e.state=null),r):C}function f(e){return u(e,_e)}function c(e){if(we){var t;for(m=new _.Buf32(512),v=new _.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(x(E,e.lens,0,288,m,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;x(S,e.lens,0,32,v,0,e.work,{bits:5}),we=!1}e.lencode=m,e.lenbits=9,e.distcode=v,e.distbits=5}function l(e,t,r,n){var i,a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(_.arraySet(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),_.arraySet(a.window,t,r-n,i,a.wnext),n-=i,n?(_.arraySet(a.window,t,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,r.check=b(r.check,Ie,2,0),h=0,d=0,r.mode=O;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&h)<<8)+(h>>8))%31){e.msg="incorrect header check",r.mode=he;break}if((15&h)!==U){e.msg="unknown compression method",r.mode=he;break}if(h>>>=4,d-=4,xe=(15&h)+8,0===r.wbits)r.wbits=xe;else if(xe>r.wbits){e.msg="invalid window size",r.mode=he;break}r.dmax=1<>8&1),512&r.flags&&(Ie[0]=255&h,Ie[1]=h>>>8&255,r.check=b(r.check,Ie,2,0)),h=0,d=0,r.mode=F;case F:for(;d<32;){if(0===u)break e;u--,h+=i[o++]<>>8&255,Ie[2]=h>>>16&255,Ie[3]=h>>>24&255,r.check=b(r.check,Ie,4,0)),h=0,d=0,r.mode=N;case N:for(;d<16;){if(0===u)break e;u--,h+=i[o++]<>8),512&r.flags&&(Ie[0]=255&h,Ie[1]=h>>>8&255,r.check=b(r.check,Ie,2,0)),h=0,d=0,r.mode=j;case j:if(1024&r.flags){for(;d<16;){if(0===u)break e;u--,h+=i[o++]<>>8&255,r.check=b(r.check,Ie,2,0)),h=0,d=0}else r.head&&(r.head.extra=null);r.mode=Z;case Z:if(1024&r.flags&&(m=r.length,m>u&&(m=u),m&&(r.head&&(xe=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),_.arraySet(r.head.extra,i,o,m,xe)),512&r.flags&&(r.check=b(r.check,i,m,o)),u-=m,o+=m,r.length-=m),r.length))break e;r.length=0,r.mode=q;case q:if(2048&r.flags){if(0===u)break e;m=0;do xe=i[o+m++],r.head&&xe&&r.length<65536&&(r.head.name+=String.fromCharCode(xe));while(xe&&m>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=X;break;case W:for(;d<32;){if(0===u)break e;u--,h+=i[o++]<>>=7&d,d-=7&d,r.mode=fe;break}for(;d<3;){if(0===u)break e;u--,h+=i[o++]<>>=1,d-=1,3&h){case 0:r.mode=J;break;case 1:if(c(r),r.mode=re,t===T){h>>>=2,d-=2;break e}break;case 2:r.mode=$;break;case 3:e.msg="invalid block type",r.mode=he}h>>>=2,d-=2;break;case J:for(h>>>=7&d,d-=7&d;d<32;){if(0===u)break e;u--,h+=i[o++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=he;break}if(r.length=65535&h,h=0,d=0,r.mode=K,t===T)break e;case K:r.mode=Q;case Q:if(m=r.length){if(m>u&&(m=u),m>f&&(m=f),0===m)break e;_.arraySet(a,i,o,m,s),u-=m,o+=m,f-=m,s+=m,r.length-=m;break}r.mode=X;break;case $:for(;d<14;){if(0===u)break e;u--,h+=i[o++]<>>=5,d-=5,r.ndist=(31&h)+1,h>>>=5,d-=5,r.ncode=(15&h)+4,h>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=he;break}r.have=0,r.mode=ee;case ee:for(;r.have>>=3,d-=3}for(;r.have<19;)r.lens[Te[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,Ee={bits:r.lenbits},ke=x(k,r.lens,0,19,r.lencode,0,r.work,Ee),r.lenbits=Ee.bits,ke){e.msg="invalid code lengths set",r.mode=he;break}r.have=0,r.mode=te;case te:for(;r.have>>24,ve=Ae>>>16&255,_e=65535&Ae,!(me<=d);){if(0===u)break e;u--,h+=i[o++]<>>=me,d-=me,r.lens[r.have++]=_e;else{if(16===_e){for(Se=me+2;d>>=me,d-=me,0===r.have){e.msg="invalid bit length repeat",r.mode=he;break}xe=r.lens[r.have-1],m=3+(3&h),h>>>=2,d-=2}else if(17===_e){for(Se=me+3;d>>=me,d-=me,xe=0,m=3+(7&h),h>>>=3,d-=3}else{for(Se=me+7;d>>=me,d-=me,xe=0,m=11+(127&h),h>>>=7,d-=7}if(r.have+m>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=he;break}for(;m--;)r.lens[r.have++]=xe}}if(r.mode===he)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=he;break}if(r.lenbits=9,Ee={bits:r.lenbits},ke=x(E,r.lens,0,r.nlen,r.lencode,0,r.work,Ee),r.lenbits=Ee.bits,ke){e.msg="invalid literal/lengths set",r.mode=he;break}if(r.distbits=6,r.distcode=r.distdyn,Ee={bits:r.distbits},ke=x(S,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,Ee),r.distbits=Ee.bits,ke){e.msg="invalid distances set",r.mode=he;break}if(r.mode=re,t===T)break e;case re:r.mode=ne;case ne:if(u>=6&&f>=258){e.next_out=s,e.avail_out=f,e.next_in=o,e.avail_in=u,r.hold=h,r.bits=d,y(e,g),s=e.next_out,a=e.output,f=e.avail_out,o=e.next_in,i=e.input,u=e.avail_in,h=r.hold,d=r.bits,r.mode===X&&(r.back=-1);break}for(r.back=0;Ae=r.lencode[h&(1<>>24,ve=Ae>>>16&255,_e=65535&Ae,!(me<=d);){if(0===u)break e;u--,h+=i[o++]<>we)],me=Ae>>>24,ve=Ae>>>16&255, +_e=65535&Ae,!(we+me<=d);){if(0===u)break e;u--,h+=i[o++]<>>=we,d-=we,r.back+=we}if(h>>>=me,d-=me,r.back+=me,r.length=_e,0===ve){r.mode=ue;break}if(32&ve){r.back=-1,r.mode=X;break}if(64&ve){e.msg="invalid literal/length code",r.mode=he;break}r.extra=15&ve,r.mode=ie;case ie:if(r.extra){for(Se=r.extra;d>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=ae;case ae:for(;Ae=r.distcode[h&(1<>>24,ve=Ae>>>16&255,_e=65535&Ae,!(me<=d);){if(0===u)break e;u--,h+=i[o++]<>we)],me=Ae>>>24,ve=Ae>>>16&255,_e=65535&Ae,!(we+me<=d);){if(0===u)break e;u--,h+=i[o++]<>>=we,d-=we,r.back+=we}if(h>>>=me,d-=me,r.back+=me,64&ve){e.msg="invalid distance code",r.mode=he;break}r.offset=_e,r.extra=15&ve,r.mode=oe;case oe:if(r.extra){for(Se=r.extra;d>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=he;break}r.mode=se;case se:if(0===f)break e;if(m=g-f,r.offset>m){if(m=r.offset-m,m>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=he;break}m>r.wnext?(m-=r.wnext,v=r.wsize-m):v=r.wnext-m,m>r.length&&(m=r.length),ge=r.window}else ge=a,v=s-r.offset,m=r.length;m>f&&(m=f),f-=m,r.length-=m;do a[s++]=ge[v++];while(--m);0===r.length&&(r.mode=ne);break;case ue:if(0===f)break e;a[s++]=r.length,f--,r.mode=ne;break;case fe:if(r.wrap){for(;d<32;){if(0===u)break e;u--,h|=i[o++]<=1&&0===j[C];C--);if(P>C&&(P=C),0===C)return g[m++]=20971520,g[m++]=20971520,_.bits=1,0;for(R=1;R0&&(e===s||1!==C))return-1;for(Z[1]=0,L=1;La||e===f&&z>o)return 1;for(var H=0;;){H++,S=L-D,v[M]E?(A=q[G+v[M]],I=F[N+v[M]]):(A=96,I=0),w=1<>D)+b]=S<<24|A<<16|I|0;while(0!==b);for(w=1<>=1;if(0!==w?(O&=w-1,O+=w):O=0,M++,0===--j[L]){if(L===C)break;L=t[r+v[M]]}if(L>P&&(O&x)!==y){for(0===D&&(D=P),k+=R,B=L-D,U=1<a||e===f&&z>o)return 1;y=O&x,g[y]=P<<24|B<<16|k-m|0}}return 0!==O&&(g[k+O]=L-D<<24|64<<16|0),_.bits=P,0}},{"../utils/common":30}],38:[function(e,t,r){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],39:[function(e,t,r){"use strict";function n(e){for(var t=e.length;--t>=0;)e[t]=0}function i(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function a(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function o(e){return e<256?ue[e]:ue[256+(e>>>7)]}function s(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function u(e,t,r){e.bi_valid>Y-r?(e.bi_buf|=t<>Y-e.bi_valid,e.bi_valid+=r-Y):(e.bi_buf|=t<>>=1,r<<=1;while(--t>0);return r>>>1}function l(e){16===e.bi_valid?(s(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}function h(e,t){var r,n,i,a,o,s,u=t.dyn_tree,f=t.max_code,c=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,g=0;for(a=0;a<=X;a++)e.bl_count[a]=0;for(u[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;rp&&(a=p,g++),u[2*n+1]=a,n>f||(e.bl_count[a]++,o=0,n>=d&&(o=h[n-d]),s=u[2*n],e.opt_len+=s*(a+o),l&&(e.static_len+=s*(c[2*n+1]+o)));if(0!==g){do{for(a=p-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[p]--,g-=2}while(g>0);for(a=p;0!==a;a--)for(n=e.bl_count[a];0!==n;)i=e.heap[--r],i>f||(u[2*i+1]!==a&&(e.opt_len+=(a-u[2*i+1])*u[2*i],u[2*i+1]=a),n--)}}function d(e,t,r){var n,i,a=new Array(X+1),o=0;for(n=1;n<=X;n++)a[n]=o=o+r[n-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=c(a[s]++,s))}}function p(){var e,t,r,n,a,o=new Array(X+1);for(r=0,n=0;n>=7;n8?s(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function v(e,t,r,n){m(e),n&&(s(e,r),s(e,~r)),C.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}function _(e,t,r,n){var i=2*t,a=2*r;return e[i]>1;r>=1;r--)w(e,a,r);i=u;do r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],w(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,a[2*i]=a[2*r]+a[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,a[2*r+1]=a[2*n+1]=i,e.heap[1]=i++,w(e,a,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],h(e,t),d(a,f,e.bl_count)}function x(e,t,r){var n,i,a=-1,o=t[1],s=0,u=7,f=4;for(0===o&&(u=138,f=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=t[2*(n+1)+1],++s=3&&0===e.bl_tree[2*ie[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}function S(e,t,r,n){var i;for(u(e,t-257,5),u(e,r-1,5),u(e,n-4,4),i=0;i>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return B;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return D;for(t=32;t0?(e.strm.data_type===U&&(e.strm.data_type=A(e)),y(e,e.l_desc),y(e,e.d_desc),o=E(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=r+5,r+4<=i&&t!==-1?T(e,t,r,n):e.strategy===P||a===i?(u(e,(O<<1)+(n?1:0),3),b(e,oe,se)):(u(e,(F<<1)+(n?1:0),3),S(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),b(e,e.dyn_ltree,e.dyn_dtree)),g(e),n&&m(e)}function R(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(fe[r]+q+1)]++,e.dyn_dtree[2*o(t)]++),e.last_lit===e.lit_bufsize-1}var C=e("../utils/common"),P=4,B=0,D=1,U=2,z=0,O=1,F=2,N=3,j=258,Z=29,q=256,G=q+1+Z,H=30,W=19,V=2*G+1,X=15,Y=16,J=7,K=256,Q=16,$=17,ee=18,te=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],re=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],ne=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],ie=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],ae=512,oe=new Array(2*(G+2));n(oe);var se=new Array(2*H);n(se);var ue=new Array(ae);n(ue);var fe=new Array(j-N+1);n(fe);var ce=new Array(Z);n(ce);var le=new Array(H);n(le);var he,de,pe,ge=!1;r._tr_init=I,r._tr_stored_block=T,r._tr_flush_block=M,r._tr_tally=R,r._tr_align=L},{"../utils/common":30}],40:[function(e,t,r){"use strict";function n(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}t.exports=n},{}],41:[function(e,t,r){(function(e){"use strict";function r(t,r,n,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var a,o,s=arguments.length;switch(s){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,r)});case 3:return e.nextTick(function(){t.call(null,r,n)});case 4:return e.nextTick(function(){t.call(null,r,n,i)});default:for(a=new Array(s-1),o=0;o1)for(var r=1;r0)if(t.ended&&!i){var o=new Error("stream.push() after EOF");e.emit("error",o)}else if(t.endEmitted&&i){var u=new Error("stream.unshift() after end event");e.emit("error",u)}else{var f;!t.decoder||i||n||(r=t.decoder.write(r),f=!t.objectMode&&0===r.length),i||(t.reading=!1),f||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&h(e))),p(e,t)}else i||(t.reading=!1);return s(t)}function s(e){return!e.ended&&(e.needReadable||e.length=j?e=j:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function f(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=u(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function c(e,t){var r=null;return B.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function l(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,h(e)}}function h(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(O("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?M(d,e):d(e))}function d(e){O("emit readable"),e.emit("readable"),b(e)}function p(e,t){t.readingMore||(t.readingMore=!0,M(g,e,t))}function g(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=x(e,t.buffer,t.decoder),r}function x(e,t,r){var n;return ea.length?a.length:e;if(i+=o===a.length?a:a.slice(0,e),e-=o,0===e){o===a.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(o));break}++n}return t.length-=n,i}function E(e,t){var r=D.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var a=n.data,o=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,o),e-=o,0===e){o===a.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=a.slice(o));break}++i}return t.length-=i,r}function S(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,M(A,t,e))}function A(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function I(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return O("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?S(this):h(this),null;if(e=f(e,t),0===e&&t.ended)return 0===t.length&&S(this),null;var n=t.needReadable;O("need readable",n),(0===t.length||t.length-e0?y(e,t):null,null===i?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&S(this)),null!==i&&this.emit("data",i),i},a.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},a.prototype.pipe=function(e,t){function i(e){O("onunpipe"),e===h&&o()}function a(){O("onend"),e.end()}function o(){O("cleanup"),e.removeListener("close",f),e.removeListener("finish",c),e.removeListener("drain",v),e.removeListener("error",u),e.removeListener("unpipe",i),h.removeListener("end",a),h.removeListener("end",o),h.removeListener("data",s),_=!0,!d.awaitDrain||e._writableState&&!e._writableState.needDrain||v()}function s(t){O("ondata"),w=!1;var r=e.write(t);!1!==r||w||((1===d.pipesCount&&d.pipes===e||d.pipesCount>1&&T(d.pipes,e)!==-1)&&!_&&(O("false write response, pause",h._readableState.awaitDrain),h._readableState.awaitDrain++,w=!0),h.pause())}function u(t){O("onerror",t),l(),e.removeListener("error",u),0===P(e,"error")&&e.emit("error",t)}function f(){e.removeListener("finish",c),l()}function c(){O("onfinish"),e.removeListener("close",f),l()}function l(){O("unpipe"),h.unpipe(e)}var h=this,d=this._readableState;switch(d.pipesCount){case 0:d.pipes=e;break;case 1:d.pipes=[d.pipes,e];break;default:d.pipes.push(e)}d.pipesCount+=1,O("pipe count=%d opts=%j",d.pipesCount,t);var p=(!t||t.end!==!1)&&e!==r.stdout&&e!==r.stderr,g=p?a:o;d.endEmitted?M(g):h.once("end",g),e.on("unpipe",i);var v=m(h);e.on("drain",v);var _=!1,w=!1;return h.on("data",s),n(e,"error",u),e.once("close",f),e.once("finish",c),e.emit("pipe",h),d.flowing||(O("pipe resume"),h.resume()),e},a.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1?setImmediate:E;o.WritableState=a;var A=e("core-util-is");A.inherits=e("inherits");var I,T={deprecate:e("util-deprecate")};!function(){try{I=e("stream")}catch(e){}finally{I||(I=e("events").EventEmitter)}}();var L=e("buffer").Buffer,M=e("buffer-shims");A.inherits(o,I),a.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e), +e=e.next;return t},function(){try{Object.defineProperty(a.prototype,"buffer",{get:T.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var R;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(R=Function.prototype[Symbol.hasInstance],Object.defineProperty(o,Symbol.hasInstance,{value:function(e){return!!R.call(this,e)||e&&e._writableState instanceof a}})):R=function(e){return e instanceof this},o.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},o.prototype.write=function(e,t,r){var i=this._writableState,a=!1;return"function"==typeof t&&(r=t,t=null),L.isBuffer(e)?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=n),i.ended?s(this,r):u(this,i,e,r)&&(i.pendingcb++,a=c(this,i,e,t,r)),a},o.prototype.cork=function(){var e=this._writableState;e.corked++},o.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||v(this,e))},o.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},o.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},o.prototype._writev=null,o.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||y(this,n,r)}}).call(this,e("_process"))},{"./_stream_duplex":43,_process:42,buffer:22,"buffer-shims":21,"core-util-is":23,events:24,inherits:27,"process-nextick-args":41,"util-deprecate":50}],47:[function(e,t,r){"use strict";function n(){this.head=null,this.tail=null,this.length=0}var i=(e("buffer").Buffer,e("buffer-shims"));t.exports=n,n.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},n.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},n.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},n.prototype.clear=function(){this.head=this.tail=null,this.length=0},n.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},n.prototype.concat=function(e){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var t=i.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t}},{buffer:22,"buffer-shims":21}],48:[function(e,t,r){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":45}],49:[function(e,t,r){function n(e){if(e&&!u(e))throw new Error("Unknown encoding: "+e)}function i(e){return e.toString(this.encoding)}function a(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function o(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var s=e("buffer").Buffer,u=s.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},f=r.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),n(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=a;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=o;break;default:return void(this.write=i)}this.charBuffer=new s(6),this.charReceived=0,this.charLength=0};f.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i);var i=t.length-1,n=t.charCodeAt(i);if(n>=55296&&n<=56319){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),e.copy(this.charBuffer,0,0,a),t.substring(0,i)}return t},f.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},f.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t}},{buffer:22}],50:[function(e,t,r){(function(e){function r(e,t){function r(){if(!i){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}if(n("noDeprecation"))return e;var i=!1;return r}function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],51:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],52:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],53:[function(e,t,r){(function(t,n){function i(e,t){var n={seen:[],stylize:o};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(t)?n.showHidden=t:t&&r._extend(n,t),y(n.showHidden)&&(n.showHidden=!1),y(n.depth)&&(n.depth=2),y(n.colors)&&(n.colors=!1),y(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=a),u(n,e,n.depth)}function a(e,t){var r=i.styles[t];return r?"["+i.colors[r][0]+"m"+e+"["+i.colors[r][1]+"m":e}function o(e,t){return e}function s(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}function u(e,t,n){if(e.customInspect&&t&&A(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return w(i)||(i=u(e,i,n)),i}var a=f(e,t);if(a)return a;var o=Object.keys(t),g=s(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),S(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return c(t);if(0===o.length){if(A(t)){var m=t.name?": "+t.name:"";return e.stylize("[Function"+m+"]","special")}if(x(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(E(t))return e.stylize(Date.prototype.toString.call(t),"date");if(S(t))return c(t)}var v="",_=!1,b=["{","}"];if(p(t)&&(_=!0,b=["[","]"]),A(t)){var y=t.name?": "+t.name:"";v=" [Function"+y+"]"}if(x(t)&&(v=" "+RegExp.prototype.toString.call(t)),E(t)&&(v=" "+Date.prototype.toUTCString.call(t)),S(t)&&(v=" "+c(t)),0===o.length&&(!_||0==t.length))return b[0]+v+b[1];if(n<0)return x(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var k;return k=_?l(e,t,n,g,o):o.map(function(r){return h(e,t,n,g,r,_)}),e.seen.pop(),d(k,v,b)}function f(e,t){if(y(t))return e.stylize("undefined","undefined");if(w(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return _(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}function c(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i){for(var a=[],o=0,s=t.length;o-1&&(s=a?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n"))):s=e.stylize("[Circular]","special")),y(o)){if(a&&i.match(/^\d+$/))return s;o=JSON.stringify(""+i),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+s}function d(e,t,r){var n=0,i=e.reduce(function(e,t){return n++,t.indexOf("\n")>=0&&n++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function p(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function m(e){return null===e}function v(e){return null==e}function _(e){return"number"==typeof e}function w(e){return"string"==typeof e}function b(e){return"symbol"==typeof e}function y(e){return void 0===e}function x(e){return k(e)&&"[object RegExp]"===T(e)}function k(e){return"object"==typeof e&&null!==e}function E(e){return k(e)&&"[object Date]"===T(e)}function S(e){return k(e)&&("[object Error]"===T(e)||e instanceof Error)}function A(e){return"function"==typeof e}function I(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function T(e){return Object.prototype.toString.call(e)}function L(e){return e<10?"0"+e.toString(10):e.toString(10)}function M(){var e=new Date,t=[L(e.getHours()),L(e.getMinutes()),L(e.getSeconds())].join(":");return[e.getDate(),D[e.getMonth()],t].join(" ")}function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var C=/%[sdj%]/g;r.format=function(e){if(!w(e)){for(var t=[],r=0;r=a)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),s=n[r];r - <%= pkg.description %>', - ' * @version v<%= pkg.version %>', - ' * @author <%= pkg.author %>', - ' * @link <%= pkg.homepage %>', - ' * @license <%= pkg.license %>', - ' */', - ''].join('\n'); - -gulp.task('script', function() { - var bundleStream = browserify({ - entries: './index.js', - insertGlobals: false, - detectGlobals: true, - standalone: 'inkjet', - fullPaths: false - }) - .bundle(); - - return bundleStream - .pipe(source('inkjet.js')) - .pipe($.header(banner, {pkg: pkg})) - .pipe(gulp.dest('./dist')) - .pipe($.uglify()) - .pipe($.header(banner, {pkg: pkg})) - .pipe($.rename('inkjet.min.js')) - .pipe(gulp.dest('./dist')); -}); +requireDir('./build', { recurse: true }); diff --git a/index.js b/index.js index 9f2482c..ca905f3 100644 --- a/index.js +++ b/index.js @@ -1,26 +1,16 @@ -'use strict'; +import { hasWorker } from './lib/has-worker'; -var hasWorker = require('./lib/has-worker').HAS_WORKER; +import * as bufferUtils from './lib/buffer-utils'; -var bufferUtils = require('./lib/buffer-utils'); - -var exif = require('./lib/exif'); -var decode = require('./lib/decode'); -var encode = require('./lib/encode'); -var magic = require('./lib/magic'); -var info = require('./lib/info'); - -var exifWorker = require('./lib/exif-worker'); -var decodeWorker = require('./lib/decode-worker'); -var encodeWorker = require('./lib/encode-worker'); - - -module.exports.decode = decodeBuffer; -module.exports.encode = encodeBuffer; -module.exports.exif = exifBuffer; -module.exports.magic = magicBuffer; -module.exports.info = infoBuffer; +import exif from './lib/exif'; +import decode from './lib/decode'; +import encode from './lib/encode'; +import magic from './lib/magic'; +import info from './lib/info'; +import exifWorker from './lib/exif-worker'; +import decodeWorker from './lib/decode-worker'; +import encodeWorker from './lib/encode-worker'; /** * Decode @@ -41,15 +31,14 @@ function decodeBuffer(buf, options, cb) { buf = bufferUtils.toUint8Array(buf); if(hasWorker) { - var wr = require('webworkify')(decodeWorker); + const wr = require('webworkify')(decodeWorker); - wr.onmessage = function(ev) { - var msg = ev.data; - var err = msg.err ? new Error(msg.err) : undefined; + wr.onmessage = ({ data: msg }) => { + const err = msg.err ? new Error(msg.err) : undefined; cb(err, msg.result); }; - var msg = { + const msg = { buf: buf, options: options }; @@ -90,15 +79,14 @@ function encodeBuffer(buf, options, cb) { } if(hasWorker) { - var wr = require('webworkify')(encodeWorker); + const wr = require('webworkify')(encodeWorker); - wr.onmessage = function(ev) { - var msg = ev.data; - var err = msg.err ? new Error(msg.err) : undefined; + wr.onmessage = ({ data: msg }) => { + const err = msg.err ? new Error(msg.err) : undefined; cb(err, msg.result); }; - var msg = { + const msg = { buf: buf, options: options }; @@ -135,15 +123,14 @@ function exifBuffer(buf, options, cb) { buf = bufferUtils.toArrayBuffer(buf); if(hasWorker) { - var wr = require('webworkify')(exifWorker); + const wr = require('webworkify')(exifWorker); - wr.onmessage = function(ev) { - var msg = ev.data; - var err = msg.err ? new Error(msg.err) : undefined; + wr.onmessage = ({ data: msg }) => { + const err = msg.err ? new Error(msg.err) : undefined; cb(err, msg.result); }; - var msg = { + const msg = { buf: buf }; @@ -168,7 +155,7 @@ function exifBuffer(buf, options, cb) { function magicBuffer(buf, cb) { try { buf = bufferUtils.toBuffer(buf); - magic.lookup(buf, cb); + magic(buf, cb); } catch(err) { cb(err); } @@ -182,8 +169,17 @@ function magicBuffer(buf, cb) { function infoBuffer(buf, cb) { try { buf = bufferUtils.toBuffer(buf); - info.collect(buf, cb); + info(buf, cb); } catch(err) { cb(err); } } + + +export default { + decode: decodeBuffer, + encode: encodeBuffer, + exif: exifBuffer, + magic: magicBuffer, + info: infoBuffer, +} diff --git a/lib/buffer-utils.js b/lib/buffer-utils.js index 353df7d..180a895 100644 --- a/lib/buffer-utils.js +++ b/lib/buffer-utils.js @@ -1,19 +1,10 @@ -'use strict'; - -module.exports.toBuffer = toBuffer; -module.exports.toArrayBuffer = toArrayBuffer; -module.exports.toUint8Array = toUint8Array; -module.exports.toArrayLike = toArrayLike; - -module.exports.bufferToArrayBuffer = bufferToArrayBuffer; -module.exports.arrayBufferToBuffer = arrayBufferToBuffer; /** * Converts the buffer to Buffer * @param {Buffer|ArrayBuffer|Uint8Array} buf Input buffer * @returns {Buffer} */ -function toBuffer(buf) { +export function toBuffer(buf) { if(buf instanceof ArrayBuffer) { return arrayBufferToBuffer(buf); } else if(Buffer.isBuffer(buf)) { @@ -30,7 +21,7 @@ function toBuffer(buf) { * @param {Buffer|ArrayBuffer|Uint8Array} buf Input buffer * @returns {ArrayBuffer} */ -function toArrayBuffer(buf) { +export function toArrayBuffer(buf) { if(buf instanceof ArrayBuffer) { return buf; } else if(Buffer.isBuffer(buf)) { @@ -47,7 +38,7 @@ function toArrayBuffer(buf) { * @param {Buffer|ArrayBuffer|Uint8Array} buf Input buffer * @returns {Uint8Array} */ -function toUint8Array(buf) { +export function toUint8Array(buf) { if(buf instanceof Uint8Array) { return buf; } else if(buf instanceof ArrayBuffer) { @@ -64,7 +55,7 @@ function toUint8Array(buf) { * @param {Buffer|ArrayBuffer|Uint8Array} buf * @returns {Buffer|Uint8Array} */ -function toArrayLike(buf) { +export function toArrayLike(buf) { if(buf instanceof Uint8Array) { return buf; } else if(buf instanceof ArrayBuffer) { @@ -81,10 +72,10 @@ function toArrayLike(buf) { * @param {Buffer|Uint8Array} buf * @returns {ArrayBuffer} */ -function bufferToArrayBuffer(buf) { - var arr = new ArrayBuffer(buf.length); - var view = new Uint8Array(arr); - for (var i = 0; i < buf.length; ++i) { +export function bufferToArrayBuffer(buf) { + const arr = new ArrayBuffer(buf.length); + const view = new Uint8Array(arr); + for (let i = 0; i < buf.length; ++i) { view[i] = buf[i]; } return arr; @@ -95,6 +86,6 @@ function bufferToArrayBuffer(buf) { * @param {ArrayBuffer} arr * @returns {Buffer} */ -function arrayBufferToBuffer(arr) { +export function arrayBufferToBuffer(arr) { return new Buffer(new Uint8Array(arr)); } diff --git a/lib/decode-worker.js b/lib/decode-worker.js index 02acf71..e8fe5be 100644 --- a/lib/decode-worker.js +++ b/lib/decode-worker.js @@ -1,13 +1,10 @@ -'use strict'; -module.exports = function(self) { - var decode = require('./decode'); - - self.onmessage = function (ev) { - var msg = ev.data; - decode(msg.buf, msg.options, function(err, result) { +export default function(self) { + const decode = require('./decode'); + self.onmessage = ({ data: msg }) => { + decode(msg.buf, msg.options, (err, result) => { if (err) { - var errValue = err instanceof Error ? err.message : err; // Error is not clonable + const errValue = err instanceof Error ? err.message : err; // Error is not clonable self.postMessage({ err: errValue }); } else { self.postMessage({ result: result }); diff --git a/lib/decode.js b/lib/decode.js index 7ab776d..78e4760 100644 --- a/lib/decode.js +++ b/lib/decode.js @@ -1,9 +1,4 @@ -'use strict'; - -var JpegImage = require('./backend/jpg').JpegImage; - -module.exports = decode; - +import { JpegImage } from './backend/jpg'; /** * Decode the JPEG data @@ -14,9 +9,9 @@ module.exports = decode; * * @callback { width: number, height: number, data: Uint8Array } */ -function decode(buf, options, cb) { +export default function decode(buf, options, cb) { function getData(j, width, height) { - var dest = { + const dest = { width: width, height: height, data: new Uint8Array(width * height * 4) @@ -26,14 +21,14 @@ function decode(buf, options, cb) { } try { - var j = new JpegImage(); + const j = new JpegImage(); j.parse(buf); - var width = options.width || j.width; - var height = options.height || j.height; - var data = getData(j, width, height); + const width = options.width || j.width; + const height = options.height || j.height; + const data = getData(j, width, height); - var result = { + const result = { width: width, height: height, data: data diff --git a/lib/encode-worker.js b/lib/encode-worker.js index 856fef3..c4b128b 100644 --- a/lib/encode-worker.js +++ b/lib/encode-worker.js @@ -1,13 +1,10 @@ -'use strict'; -module.exports = function(self) { - var encode = require('./encode'); - - self.onmessage = function (ev) { - var msg = ev.data; - encode(msg.buf, msg.options, function(err, result) { +export default function(self) { + const encode = require('./encode'); + self.onmessage = function ({ data: msg }) { + encode(msg.buf, msg.options, (err, result) => { if (err) { - var errValue = err instanceof Error ? err.message : err; // Error is not clonable + const errValue = err instanceof Error ? err.message : err; // Error is not clonable self.postMessage({ err: errValue }); } else { self.postMessage({ result: result }); diff --git a/lib/encode.js b/lib/encode.js index d261954..585da3c 100644 --- a/lib/encode.js +++ b/lib/encode.js @@ -1,8 +1,4 @@ -'use strict'; - -var encoder = require('./backend/encoder'); - -module.exports = encode; +import encoder from './backend/encoder'; /** * Encode the data to JPEG format @@ -13,14 +9,14 @@ module.exports = encode; * * @callback { width: number, height: number, data: Uint8Array } */ -function encode(buf, options, cb) { +export default function encode(buf, options, cb) { try { - var imageData = { + const imageData = { data: buf, width: options.width, height: options.height }; - var data = encoder(imageData, options.quality); + const data = encoder(imageData, options.quality); cb(null, data); } catch(err) { cb(err); diff --git a/lib/exif-worker.js b/lib/exif-worker.js index eefb1fa..1d78568 100644 --- a/lib/exif-worker.js +++ b/lib/exif-worker.js @@ -1,13 +1,10 @@ -'use strict'; -module.exports = function(self) { - var exif = require('./exif'); - - self.onmessage = function (ev) { - var msg = ev.data; - exif(msg.buf, {}, function(err, result) { +export default function(self) { + const exif = require('./exif'); + self.onmessage = ({ data: msg }) => { + exif(msg.buf, {}, (err, result) => { if (err) { - var errValue = err instanceof Error ? err.message : err; // Error is not clonable + const errValue = err instanceof Error ? err.message : err; // Error is not clonable self.postMessage({ err: errValue }); } else { self.postMessage({ result: result }); diff --git a/lib/exif.js b/lib/exif.js index 574708e..ace973a 100644 --- a/lib/exif.js +++ b/lib/exif.js @@ -1,9 +1,4 @@ -'use strict'; - -var ExifReader = require('./backend/ExifReader').ExifReader; - -module.exports = exif; - +import { ExifReader } from './backend/ExifReader'; /** * Read EXIF data from the provided buffer @@ -14,9 +9,9 @@ module.exports = exif; * * @callback Object { name: value, ... } */ -function exif(buf, options, cb) { +export default function exif(buf, options, cb) { try { - var exif = new ExifReader(); + const exif = new ExifReader(); exif.load(buf); // The MakerNote tag can be really large. Remove it to lower memory usage. @@ -24,7 +19,7 @@ function exif(buf, options, cb) { exif.deleteTag('MakerNote'); } - var metadata = exif.getAllTags(); + const metadata = exif.getAllTags(); cb(null, metadata); } catch(err) { diff --git a/lib/has-worker.js b/lib/has-worker.js index 593458b..f8d1e9b 100644 --- a/lib/has-worker.js +++ b/lib/has-worker.js @@ -1,13 +1,14 @@ -'use strict'; +let hasWorker = (typeof window !== 'undefined') && ('Worker' in window); -var hasWorker = (typeof window !== 'undefined') && ('Worker' in window); if (hasWorker) { try { - var w = require('webworkify')(function () {}); + const w = require('webworkify')(() => {}); w.terminate(); } catch (e) { hasWorker = false; } } -module.exports.HAS_WORKER = hasWorker; +export { + hasWorker +} diff --git a/lib/info.js b/lib/info.js index 0dd2ba6..7823395 100644 --- a/lib/info.js +++ b/lib/info.js @@ -1,17 +1,13 @@ -'use strict'; - -var imageinfo = require('imageinfo'); - -module.exports.collect = collect; +import imageinfo from 'imageinfo'; /** * Get image information * @param {Buffer} buf Image or image part that contains image parameters * @param {function} cb Callback to invoke on completion */ -function collect(buf, cb) { - setTimeout(function() { - var info = imageinfo(buf); +export default function info(buf, cb) { + setTimeout(() => { + const info = imageinfo(buf); if(!info) { cb(new Error('Cannot get image info')); } else { @@ -24,4 +20,4 @@ function collect(buf, cb) { }); } }, 0); -} \ No newline at end of file +} diff --git a/lib/magic.js b/lib/magic.js index 9b77156..e071f20 100644 --- a/lib/magic.js +++ b/lib/magic.js @@ -1,26 +1,16 @@ -'use strict'; - -var find = require('lodash.find'); -var db = require('./magic-db'); -var debug = require('debug')('inkjet:magic'); - -module.exports.lookup = lookup; +import db from './magic-db'; /** * Lookup the magic number in magic-number DB * @param {Buffer} buf Data buffer * @param {function} cb Callback to invoke on completion */ -function lookup(buf, cb) { - setTimeout(function() { - var sampleLength = 24; - var sample = buf.slice(0, sampleLength).toString('hex'); // lookup data +export default function magic(buf, cb) { + setTimeout(() => { + const sampleLength = 24; + const sample = buf.slice(0, sampleLength).toString('hex'); // lookup data - var keys = Object.keys(db); - var found = find(keys, function(it) { - debug('%s <---- %s', sample, it); - return (sample.indexOf(it) != -1); - }); + const found = Object.keys(db).find((it) => { return (sample.indexOf(it) != -1); }); if(found) { cb(null, db[found]); diff --git a/package.json b/package.json index 8cc463c..b48fc71 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,15 @@ { "name": "inkjet", - "version": "2.0.2", + "version": "2.1.0", "description": "JPEG-image decoding, encoding & EXIF reading library for browser and node.js", "main": "index.js", "scripts": { - "test": "mocha", + "test": "mocha --require register --recursive", "browser": "gulp script", + "browser:production": "NODE_ENV=production gulp script", "zuul": "zuul --no-coverage --sauce-connect -- ./test/*.spec.js", "zuul:local": "zuul --local 8080 --ui mocha-bdd -- ./test/*.spec.js", - "istanbul:local": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && rm -rf ./coverage" + "istanbul:local": "istanbul cover ./node_modules/mocha/bin/_mocha --require register --report lcovonly -- -R spec && rm -rf ./coverage" }, "repository": { "type": "git", @@ -30,24 +31,32 @@ }, "homepage": "https://github.com/gchudnov/inkjet", "dependencies": { - "debug": "^2.2.0", "imageinfo": "^1.0.4", - "lodash.find": "^4.3.0", - "webworkify": "^1.1.0" + "webworkify": "^1.4.0" }, "devDependencies": { + "babel-cli": "^6.23.0", + "babel-core": "^6.23.1", + "babel-plugin-add-module-exports": "^0.2.1", + "babel-plugin-transform-es2015-modules-commonjs": "^6.23.0", + "babel-plugin-transform-object-rest-spread": "^6.23.0", + "babel-polyfill": "^6.23.0", + "babel-preset-latest": "^6.22.0", + "babel-preset-stage-2": "^6.22.0", + "babel-register": "^6.23.0", + "babelify": "^7.3.0", "brfs": "^1.4.3", - "browserify": "^13.0.0", + "browserify": "^14.1.0", "gulp": "^3.9.1", - "gulp-header": "^1.7.1", - "gulp-load-plugins": "^1.2.2", - "gulp-rename": "^1.2.2", - "gulp-uglify": "^1.5.3", - "gulp-util": "^3.0.7", - "istanbul": "^0.4.3", - "mocha": "^2.4.5", - "should": "^8.3.1", + "gulp-header": "^1.8.8", + "gulp-if": "^2.0.2", + "gulp-uglify": "^2.0.1", + "gulp-util": "^3.0.8", + "istanbul": "^0.4.5", + "mocha": "^3.2.0", + "require-dir": "^0.3.1", + "should": "^11.2.0", "vinyl-source-stream2": "^0.1.1", - "zuul": "^3.10.1" + "zuul": "^3.11.1" } } diff --git a/register.js b/register.js new file mode 100644 index 0000000..97cbbc0 --- /dev/null +++ b/register.js @@ -0,0 +1,4 @@ +'use strict'; + +const babelSettings = require('./babel-settings.json'); +require('babel-register')(babelSettings); diff --git a/test/constants.js b/test/constants.js index f6b912e..2ba5c40 100644 --- a/test/constants.js +++ b/test/constants.js @@ -1,28 +1,28 @@ -'use strict'; +import fs from 'fs'; +import path from 'path'; -var fs = require('fs'); -var path = require('path'); +const namePng = 'js_logo.png'; +const name420 = 'js_logo-4-2-0.jpg'; +const name422h = 'js_logo-4-2-2-horz.jpg'; +const name422v = 'js_logo-4-2-2-vert.jpg'; +const name444 = 'js_logo-4-4-4.jpg'; +const nameExif = 'js_logo-exif.jpg'; +const nameBroken = 'js_broken.jpg'; -var namePng = 'js_logo.png'; -var name420 = 'js_logo-4-2-0.jpg'; -var name422h = 'js_logo-4-2-2-horz.jpg'; -var name422v = 'js_logo-4-2-2-vert.jpg'; -var name444 = 'js_logo-4-4-4.jpg'; -var nameExif = 'js_logo-exif.jpg'; -var nameBroken = 'js_broken.jpg'; +export default { + namePng: namePng, + name420: name420, + name422h: name422h, + name422v: name422v, + name444: name444, + nameExif: nameExif, + nameBroken: nameBroken, -module.exports.namePng = namePng; -module.exports.name420 = name420; -module.exports.name422h = name422h; -module.exports.name422v = name422v; -module.exports.name444 = name444; -module.exports.nameExif = nameExif; -module.exports.nameBroken = nameBroken; - -module.exports.bufPng = fs.readFileSync(path.join(__dirname, '../images/', 'js_logo.png')); -module.exports.buf420 = fs.readFileSync(path.join(__dirname, '../images/', 'js_logo-4-2-0.jpg')); -module.exports.buf422h = fs.readFileSync(path.join(__dirname, '../images/', 'js_logo-4-2-2-horz.jpg')); -module.exports.buf422v = fs.readFileSync(path.join(__dirname, '../images/', 'js_logo-4-2-2-vert.jpg')); -module.exports.buf444 = fs.readFileSync(path.join(__dirname, '../images/', 'js_logo-4-4-4.jpg')); -module.exports.bufExif = fs.readFileSync(path.join(__dirname, '../images/', 'js_logo-exif.jpg')); -module.exports.bufBroken = fs.readFileSync(path.join(__dirname, '../images/', 'js_broken.jpg')); + bufPng: fs.readFileSync(path.join(__dirname, '../images/', 'js_logo.png')), + buf420: fs.readFileSync(path.join(__dirname, '../images/', 'js_logo-4-2-0.jpg')), + buf422h: fs.readFileSync(path.join(__dirname, '../images/', 'js_logo-4-2-2-horz.jpg')), + buf422v: fs.readFileSync(path.join(__dirname, '../images/', 'js_logo-4-2-2-vert.jpg')), + buf444: fs.readFileSync(path.join(__dirname, '../images/', 'js_logo-4-4-4.jpg')), + bufExif: fs.readFileSync(path.join(__dirname, '../images/', 'js_logo-exif.jpg')), + bufBroken: fs.readFileSync(path.join(__dirname, '../images/', 'js_broken.jpg')), +} diff --git a/test/decode.spec.js b/test/decode.spec.js index caabe59..4bd1240 100644 --- a/test/decode.spec.js +++ b/test/decode.spec.js @@ -1,15 +1,12 @@ -'use strict'; +import should from 'should'; +import lib from '../index'; +import constants from './constants'; -var should = require('should'); -var lib = require('../index'); -var constants = require('./constants'); +describe('Decode', () => { -describe('Decode', function() { - this.timeout(60000); - - it('can be used to process ' + constants.name420, function(done) { - var jpegData = constants.buf420; - lib.decode(jpegData, function(err, decoded) { + it('can be used to process ' + constants.name420, (done) => { + const jpegData = constants.buf420; + lib.decode(jpegData, (err, decoded) => { should.not.exist(err); should.exist(decoded); @@ -20,9 +17,9 @@ describe('Decode', function() { }); }); - it('can be used to process ' + constants.name422h, function(done) { - var jpegData = constants.buf422h; - lib.decode(jpegData, function(err, decoded) { + it('can be used to process ' + constants.name422h, (done) => { + const jpegData = constants.buf422h; + lib.decode(jpegData, (err, decoded) => { should.not.exist(err); should.exist(decoded); (decoded.width).should.be.eql(1052); @@ -32,9 +29,9 @@ describe('Decode', function() { }); }); - it('can be used to process ' + constants.name422v, function(done) { - var jpegData = constants.buf422v; - lib.decode(jpegData, function(err, decoded) { + it('can be used to process ' + constants.name422v, (done) => { + const jpegData = constants.buf422v; + lib.decode(jpegData, (err, decoded) => { should.not.exist(err); should.exist(decoded); (decoded.width).should.be.eql(1052); @@ -44,9 +41,9 @@ describe('Decode', function() { }) }); - it('can be used to process ' + constants.name444, function(done) { - var jpegData = constants.buf444; - lib.decode(jpegData, function(err, decoded) { + it('can be used to process ' + constants.name444, (done) => { + const jpegData = constants.buf444; + lib.decode(jpegData, (err, decoded) => { should.not.exist(err); should.exist(decoded); (decoded.width).should.be.eql(1052); @@ -56,9 +53,9 @@ describe('Decode', function() { }); }); - it('can be used to process ' + constants.nameExif, function(done) { - var jpegData = constants.bufExif; - lib.decode(jpegData, function(err, decoded) { + it('can be used to process ' + constants.nameExif, (done) => { + const jpegData = constants.bufExif; + lib.decode(jpegData, (err, decoded) => { should.not.exist(err); should.exist(decoded); (decoded.width).should.be.eql(1052); @@ -68,9 +65,9 @@ describe('Decode', function() { }); }); - it('fails to decode a broken JPEG image', function(done) { - var jpegData = constants.bufBroken; - lib.decode(jpegData, function(err, decoded) { + it('fails to decode a broken JPEG image', (done) => { + const jpegData = constants.bufBroken; + lib.decode(jpegData, (err, decoded) => { should.exist(err); should.not.exist(decoded); err.should.be.an.instanceOf(Error); @@ -78,4 +75,4 @@ describe('Decode', function() { }); }); -}); +}).timeout(60000); diff --git a/test/encode.spec.js b/test/encode.spec.js index a930691..e9adb3e 100644 --- a/test/encode.spec.js +++ b/test/encode.spec.js @@ -1,15 +1,13 @@ -'use strict'; - -var path = require('path'); -var should = require('should'); -var lib = require('../index'); -var writer = require('./util/file-writer'); +import path from 'path'; +import should from 'should'; +import lib from '../index'; +import writer from './util/file-writer'; function makeRgbBitmap(BufferType, r, g, b) { - var width = 320; - var height = 180; - var frameData = new Buffer(width * height * 4); - var i = 0; + const width = 320; + const height = 180; + const frameData = new Buffer(width * height * 4); + let i = 0; while (i < frameData.length) { frameData[i++] = 0xFF; // red @@ -25,23 +23,18 @@ function makeRgbBitmap(BufferType, r, g, b) { } } -describe('Encode', function() { - this.timeout(60000); - - it('can be used to create a JPEG image (Buffer)', function(done) { - var bmp = makeRgbBitmap(Buffer, 0xFF, 0, 0); +describe('Encode', () => { - var width = bmp.width; - var height = bmp.height; - var buf = bmp.data; + it('can be used to create a JPEG image (Buffer)', (done) => { + const { width, height, data } = makeRgbBitmap(Buffer, 0xFF, 0, 0); - var options = { + const options = { width: width, height: height, quality: 80 }; - lib.encode(buf, options, function(err, encoded) { + lib.encode(data, options, (err, encoded) => { should.not.exist(err); should.exist(encoded); (encoded.width).should.be.eql(320); @@ -57,20 +50,16 @@ describe('Encode', function() { }); - it('can be used to create a JPEG image (ArrayBuffer)', function(done) { - var bmp = makeRgbBitmap(ArrayBuffer, 0, 0xFF, 0); + it('can be used to create a JPEG image (ArrayBuffer)', (done) => { + const { width, height, data } = makeRgbBitmap(ArrayBuffer, 0, 0xFF, 0); - var width = bmp.width; - var height = bmp.height; - var buf = bmp.data; - - var options = { + const options = { width: width, height: height, quality: 80 }; - lib.encode(buf, options, function(err, encoded) { + lib.encode(data, options, (err, encoded) => { should.not.exist(err); should.exist(encoded); (encoded.width).should.be.eql(320); @@ -86,20 +75,16 @@ describe('Encode', function() { }); - it('can be used to create a JPEG image (Uint8Array)', function(done) { - var bmp = makeRgbBitmap(Uint8Array, 0, 0, 0xFF); - - var width = bmp.width; - var height = bmp.height; - var buf = bmp.data; + it('can be used to create a JPEG image (Uint8Array)', (done) => { + const { width, height, data } = makeRgbBitmap(Uint8Array, 0, 0, 0xFF); - var options = { + const options = { width: width, height: height, quality: 80 }; - lib.encode(buf, options, function(err, encoded) { + lib.encode(data, options, (err, encoded) => { should.not.exist(err); should.exist(encoded); (encoded.width).should.be.eql(320); @@ -115,4 +100,4 @@ describe('Encode', function() { }); -}); +}).timeout(60000); diff --git a/test/exif.spec.js b/test/exif.spec.js index 9143899..d9155ab 100644 --- a/test/exif.spec.js +++ b/test/exif.spec.js @@ -1,15 +1,12 @@ -'use strict'; +import should from 'should'; +import lib from '../index'; +import constants from './constants'; -var should = require('should'); -var lib = require('../index'); -var constants = require('./constants'); +describe('Exif', () => { -describe('Exif', function() { - this.timeout(60000); - - it('should be detected for ' + constants.nameExif, function(done) { - var jpegData = constants.bufExif; - lib.exif(jpegData, function(err, data) { + it('should be detected for ' + constants.nameExif, (done) => { + const jpegData = constants.bufExif; + lib.exif(jpegData, (err, data) => { should.not.exist(err); should.exist(data); data.should.have.properties('ImageDescription'); @@ -17,10 +14,10 @@ describe('Exif', function() { }); }); - it('should be detected for ' + constants.nameExif + ' (take 128Kb)', function(done) { - var jpegData = constants.bufExif; + it('should be detected for ' + constants.nameExif + ' (take 128Kb)', (done) => { + let jpegData = constants.bufExif; jpegData = jpegData.slice(0, 128 * 1024); - lib.exif(jpegData, function(err, data) { + lib.exif(jpegData, (err, data) => { should.not.exist(err); should.exist(data); data.should.have.properties('ImageDescription'); @@ -28,21 +25,21 @@ describe('Exif', function() { }); }); - it('should NOT be detected for ' + constants.name420, function(done) { - var jpegData = constants.buf420; - lib.exif(jpegData, function(err, data) { + it('should NOT be detected for ' + constants.name420, (done) => { + const jpegData = constants.buf420; + lib.exif(jpegData, (err, data) => { should.not.exist(err); should.exist(data); done(); }); }); - it('should return an error for ' + constants.nameBroken, function(done) { - var jpegData = constants.bufBroken; - lib.exif(jpegData, function(err, data) { + it('should return an error for ' + constants.nameBroken, (done) => { + const jpegData = constants.bufBroken; + lib.exif(jpegData, (err, data) => { should.exist(err); should.not.exist(data); done(); }); }); -}); \ No newline at end of file +}).timeout(60000); diff --git a/test/info.spec.js b/test/info.spec.js index 40da708..d24eb3c 100644 --- a/test/info.spec.js +++ b/test/info.spec.js @@ -1,14 +1,12 @@ -'use strict'; +import should from 'should'; +import lib from '../index'; +import constants from './constants'; -var should = require('should'); -var lib = require('../index'); -var constants = require('./constants'); +describe('Info', () => { -describe('Info', function() { - - it('can be fetched for a JPEG file', function(done) { - var buf = constants.buf420; - lib.info(buf, function(err, data) { + it('can be fetched for a JPEG file', (done) => { + const buf = constants.buf420; + lib.info(buf, (err, data) => { should.not.exist(err); should.exist(data); @@ -22,9 +20,9 @@ describe('Info', function() { }); }); - it('can be fetched for a PNG file', function(done) { - var buf = constants.bufPng; - lib.info(buf, function(err, data) { + it('can be fetched for a PNG file', (done) => { + const buf = constants.bufPng; + lib.info(buf, (err, data) => { should.not.exist(err); should.exist(data); @@ -38,9 +36,9 @@ describe('Info', function() { }); }); - it('cannot be fetched for a broken JPEG file', function(done) { - var buf = constants.bufBroken; - lib.info(buf, function(err, data) { + it('cannot be fetched for a broken JPEG file', (done) => { + const buf = constants.bufBroken; + lib.info(buf, (err, data) => { should.exist(err); should.not.exist(data); err.should.be.an.instanceOf(Error); diff --git a/test/magic.spec.js b/test/magic.spec.js index 672f01a..04e17ac 100644 --- a/test/magic.spec.js +++ b/test/magic.spec.js @@ -1,15 +1,13 @@ -'use strict'; +import should from 'should'; +import lib from '../index'; +import constants from './constants'; -var should = require('should'); -var lib = require('../index'); -var constants = require('./constants'); +describe('Magic number', () => { -describe('Magic number', function() { + it('can be detected for a JPEG Buffer', (done) => { + const buf = new Buffer([0xFF, 0xD8, 0xFF]); - it('can be detected for a JPEG Buffer', function(done) { - var buf = new Buffer([0xFF, 0xD8, 0xFF]); - - lib.magic(buf, function(err, result) { + lib.magic(buf, (err, result) => { should.not.exist(err); should.exist(result); @@ -20,14 +18,14 @@ describe('Magic number', function() { }); }); - it('can be detected for a JPEG ArrayBuffer', function(done) { - var buf = new ArrayBuffer(3); - var view = new Uint8Array(buf); + it('can be detected for a JPEG ArrayBuffer', (done) => { + const buf = new ArrayBuffer(3); + const view = new Uint8Array(buf); view[0] = 0xFF; view[1] = 0xD8; view[2] = 0xFF; - lib.magic(buf, function(err, result) { + lib.magic(buf, (err, result) => { should.not.exist(err); should.exist(result); @@ -38,14 +36,14 @@ describe('Magic number', function() { }); }); - it('can be detected for a JPEG Uint8Array', function(done) { - var buf = new ArrayBuffer(3); - var view = new Uint8Array(buf); + it('can be detected for a JPEG Uint8Array', (done) => { + const buf = new ArrayBuffer(3); + const view = new Uint8Array(buf); view[0] = 0xFF; view[1] = 0xD8; view[2] = 0xFF; - lib.magic(view, function(err, result) { + lib.magic(view, (err, result) => { should.not.exist(err); should.exist(result); @@ -56,10 +54,10 @@ describe('Magic number', function() { }); }); - it('can be detected for a JPEG file', function(done) { - var buf = constants.buf420; + it('can be detected for a JPEG file', (done) => { + const buf = constants.buf420; - lib.magic(buf, function(err, result) { + lib.magic(buf, (err, result) => { should.not.exist(err); should.exist(result); @@ -70,10 +68,10 @@ describe('Magic number', function() { }); }); - it('can be detected for a PNG file', function(done) { - var buf = constants.bufPng; + it('can be detected for a PNG file', (done) => { + const buf = constants.bufPng; - lib.magic(buf, function(err, result) { + lib.magic(buf, (err, result) => { should.not.exist(err); should.exist(result); @@ -84,10 +82,10 @@ describe('Magic number', function() { }); }); - it('cannot be detected for a broken JPEG file', function(done) { - var buf = constants.bufBroken; + it('cannot be detected for a broken JPEG file', (done) => { + const buf = constants.bufBroken; - lib.magic(buf, function(err, result) { + lib.magic(buf, (err, result) => { should.exist(err); should.not.exist(result); err.should.be.an.instanceOf(Error); diff --git a/test/re-encode.spec.js b/test/re-encode.spec.js index ec06a4d..b8a13b9 100644 --- a/test/re-encode.spec.js +++ b/test/re-encode.spec.js @@ -1,32 +1,28 @@ -'use strict'; +import should from 'should'; +import path from 'path'; +import lib from '../index'; +import constants from './constants'; +import writer from './util/file-writer'; -var path = require('path'); -var should = require('should'); -var lib = require('../index'); -var constants = require('./constants'); -var writer = require('./util/file-writer'); +describe('Re-Encode', () => { - -describe('Re-Encode', function() { - this.timeout(60000); - - it('can be used to process ' + constants.name420, function(done) { - var jpegData = constants.buf420; - lib.decode(jpegData, function(err, decoded) { + it('can be used to process ' + constants.name420, (done) => { + const jpegData = constants.buf420; + lib.decode(jpegData, (err, decoded) => { should.not.exist(err); should.exist(decoded); (decoded.width).should.be.eql(1052); (decoded.height).should.be.eql(1052); (decoded.data).should.be.instanceOf(Uint8Array); - var buf = decoded.data; - var options = { + const buf = decoded.data; + const options = { width: decoded.width, height: decoded.height, quality: 80 }; - lib.encode(buf, options, function(err, encoded) { + lib.encode(buf, options, (err, encoded) => { should.not.exist(err); should.exist(encoded); (encoded.width).should.be.eql(1052); @@ -42,23 +38,23 @@ describe('Re-Encode', function() { }); }); - it('can be used to process ' + constants.name422h, function(done) { - var jpegData = constants.buf422h; - lib.decode(jpegData, { width: 1052, height: 1052 }, function(err, decoded) { + it('can be used to process ' + constants.name422h, (done) => { + const jpegData = constants.buf422h; + lib.decode(jpegData, { width: 1052, height: 1052 }, (err, decoded) => { should.not.exist(err); should.exist(decoded); (decoded.width).should.be.eql(1052); (decoded.height).should.be.eql(1052); (decoded.data).should.be.instanceOf(Uint8Array); - var buf = decoded.data; - var options = { + const buf = decoded.data; + const options = { width: decoded.width, height: decoded.height, quality: 80 }; - lib.encode(buf, options, function(err, encoded) { + lib.encode(buf, options, (err, encoded) => { should.not.exist(err); should.exist(encoded); (encoded.width).should.be.eql(1052); @@ -74,23 +70,23 @@ describe('Re-Encode', function() { }); }); - it('can be used to process ' + constants.name422v, function(done) { - var jpegData = constants.buf422v; - lib.decode(jpegData, function(err, decoded) { + it('can be used to process ' + constants.name422v, (done) => { + const jpegData = constants.buf422v; + lib.decode(jpegData, (err, decoded) => { should.not.exist(err); should.exist(decoded); (decoded.width).should.be.eql(1052); (decoded.height).should.be.eql(1052); (decoded.data).should.be.instanceOf(Uint8Array); - var buf = decoded.data; - var options = { + const buf = decoded.data; + const options = { width: decoded.width, height: decoded.height, quality: 80 }; - lib.encode(buf, options, function(err, encoded) { + lib.encode(buf, options, (err, encoded) => { should.not.exist(err); should.exist(encoded); (encoded.width).should.be.eql(1052); @@ -106,23 +102,23 @@ describe('Re-Encode', function() { }); }); - it('can be used to process ' + constants.nameExif, function(done) { - var jpegData = constants.bufExif; - lib.decode(jpegData, function(err, decoded) { + it('can be used to process ' + constants.nameExif, (done) => { + const jpegData = constants.bufExif; + lib.decode(jpegData, (err, decoded) => { should.not.exist(err); should.exist(decoded); (decoded.width).should.be.eql(1052); (decoded.height).should.be.eql(1052); (decoded.data).should.be.instanceOf(Uint8Array); - var buf = decoded.data; - var options = { + const buf = decoded.data; + const options = { width: decoded.width, height: decoded.height, quality: 80 }; - lib.encode(buf, options, function(err, encoded) { + lib.encode(buf, options, (err, encoded) => { should.not.exist(err); should.exist(encoded); (encoded.width).should.be.eql(1052); @@ -138,4 +134,4 @@ describe('Re-Encode', function() { }); }); -}); +}).timeout(60000); diff --git a/test/util/file-writer.js b/test/util/file-writer.js index bad9718..a127074 100644 --- a/test/util/file-writer.js +++ b/test/util/file-writer.js @@ -1,18 +1,16 @@ -'use strict'; - -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); module.exports.writeFileSync = writeFileSync; /** * Write file to the `out` directory * NOTE: this method is used for test in node.js and disabled in browserify - * @param filepath - * @param arr + * @param filepath {string} + * @param arr {Buffer} */ function writeFileSync(filepath, arr) { - var outDir = path.join(__dirname, '../out'); + const outDir = path.join(__dirname, '../out'); if(!fs.existsSync(outDir)) { fs.mkdirSync(outDir);