From 73eb30a4dc328eb71fbf2d3afe8ce3aaa91b591d Mon Sep 17 00:00:00 2001 From: Gregor Herdmann Date: Thu, 8 Sep 2016 18:23:45 +0200 Subject: [PATCH 01/21] Device not found handling (#193) --- app/script/calling/handler/MediaDevicesHandler.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/script/calling/handler/MediaDevicesHandler.coffee b/app/script/calling/handler/MediaDevicesHandler.coffee index 11d9baf22ed..c849fec099e 100644 --- a/app/script/calling/handler/MediaDevicesHandler.coffee +++ b/app/script/calling/handler/MediaDevicesHandler.coffee @@ -182,9 +182,9 @@ class z.calling.handler.MediaDevicesHandler [media_device, media_device_index] = @_get_current_device media_devices, device_id_observable() if not media_device.deviceId if updated_device = @available_devices["#{device_type}"]()[0] - @logger.log @logger.levels.WARN, - "Current '#{media_type}' device '#{device_id_observable()}' not found and replaced by '#{updated_device.name}'", media_devices device_id_observable updated_device.deviceId + @logger.log @logger.levels.WARN, + "Current '#{media_type}' device '#{device_id_observable()}' not found and replaced by '#{updated_device.label or updated_device.deviceId}'", media_devices else @logger.log @logger.levels.WARN, "Current '#{media_type}' device '#{device_id_observable()}' not found and reset'", media_devices device_id_observable '' From d9da6569ff34259b77f784406ecc2e8a2fea8806 Mon Sep 17 00:00:00 2001 From: Gregor Herdmann Date: Fri, 9 Sep 2016 15:18:27 +0200 Subject: [PATCH 02/21] Update all edited messages in database (#197) --- app/script/conversation/ConversationRepository.coffee | 8 ++++---- app/script/conversation/EventMapper.coffee | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/script/conversation/ConversationRepository.coffee b/app/script/conversation/ConversationRepository.coffee index 4c798b3fd3c..85c7d383756 100644 --- a/app/script/conversation/ConversationRepository.coffee +++ b/app/script/conversation/ConversationRepository.coffee @@ -1996,10 +1996,10 @@ class z.conversation.ConversationRepository if not original_message_et.timestamp throw new TypeError 'Missing timestamp' - event_json.time = new Date(original_message_et.timestamp).toISOString() - - return @conversation_service.update_message_in_db event_json, {time: event_json.time} - .then => + time = new Date(original_message_et.timestamp).toISOString() + @conversation_service.update_message_in_db event_json, {edited_time: event_json.time, time: time} + event_json.edited_time = event_json.time + event_json.time = time @_delete_message_by_id conversation_et, event_json.data.replacing_message_id return event_json diff --git a/app/script/conversation/EventMapper.coffee b/app/script/conversation/EventMapper.coffee index b13eeba0dc4..974892d3c3e 100644 --- a/app/script/conversation/EventMapper.coffee +++ b/app/script/conversation/EventMapper.coffee @@ -234,7 +234,7 @@ class z.conversation.EventMapper message_et.assets.push @_map_asset_text event.data message_et.nonce = event.data.nonce message_et.replacing_message_id = event.data.replacing_message_id - message_et.edited_timestamp = new Date(event.data.edited_time).getTime() + message_et.edited_timestamp = new Date(event.edited_time or event.data.edited_time).getTime() return message_et ### From c802c4d4c9e71a4aef28d358b740f9b5f61495bd Mon Sep 17 00:00:00 2001 From: Gregor Herdmann Date: Mon, 12 Sep 2016 12:06:32 +0200 Subject: [PATCH 03/21] Handle incoming delivery confirmation events (#150) --- .../ConversationRepository.coffee | 24 +++++++++++++++++++ .../conversation/ConversationService.coffee | 12 ++++------ app/script/conversation/EventMapper.coffee | 1 + .../cryptography/CryptographyMapper.coffee | 14 +++++++++++ .../entity/message/ContentMessage.coffee | 9 +++++++ app/script/event/Client.coffee | 1 + app/script/message/StatusType.coffee | 6 ++--- 7 files changed, 56 insertions(+), 11 deletions(-) diff --git a/app/script/conversation/ConversationRepository.coffee b/app/script/conversation/ConversationRepository.coffee index 85c7d383756..4cbdd8deaa5 100644 --- a/app/script/conversation/ConversationRepository.coffee +++ b/app/script/conversation/ConversationRepository.coffee @@ -1437,6 +1437,8 @@ class z.conversation.ConversationRepository @_on_asset_upload_failed conversation_et, event when z.event.Client.CONVERSATION.ASSET_PREVIEW @_on_asset_preview conversation_et, event + when z.event.Client.CONVERSATION.CONFIRMATION + @_on_confirmation conversation_et, event when z.event.Client.CONVERSATION.MESSAGE_DELETE @_on_message_deleted conversation_et, event when z.event.Client.CONVERSATION.MESSAGE_HIDDEN @@ -1507,6 +1509,23 @@ class z.conversation.ConversationRepository else @update_message_as_upload_failed message_et + ### + Confirmation for to message received. + @private + @param conversation_et [z.entity.Conversation] Conversation entity that a message was reacted upon in + @param event_json [Object] JSON data of 'conversation.confirmation' event + ### + _on_confirmation: (conversation_et, event_json) -> + @get_message_in_conversation_by_id conversation_et, event_json.data.message_id + .then (message_et) => + was_updated = message_et.update_status event_json.data.status + if was_updated + return @conversation_service.update_message_in_db message_et, {status: message_et.status()} + .catch (error) => + if error.type isnt z.conversation.ConversationError::TYPE.MESSAGE_NOT_FOUND + @logger.log "Failed to handle status update of a message in conversation '#{conversation_et.id}'", error + throw error + ### A conversation was created. @private @@ -1939,6 +1958,11 @@ class z.conversation.ConversationRepository from: message_to_delete_et.from time: message_to_delete_et.timestamp + + ############################################################################### + # Message updates + ############################################################################### + ### Update asset in UI and DB as failed @param message_et [z.entity.Message] Message to update diff --git a/app/script/conversation/ConversationService.coffee b/app/script/conversation/ConversationService.coffee index 2821904dfea..ee9888fc181 100644 --- a/app/script/conversation/ConversationService.coffee +++ b/app/script/conversation/ConversationService.coffee @@ -229,7 +229,7 @@ class z.conversation.ConversationService .delete() ### - Update events reactions. + Update a message in the database. @param message_et [z.entity.Message] Message event to update in the database @param changes [Object] Changes to update message with ### @@ -241,8 +241,7 @@ class z.conversation.ConversationService throw new z.conversation.ConversationError z.conversation.ConversationError::TYPE.NO_CHANGES ### - Delete events from a conversation. - + Update asset as uploaded in database. @param primary_key [String] Primary key used to find an event in the database ### update_asset_as_uploaded_in_db: (primary_key, asset_data) -> @@ -257,8 +256,7 @@ class z.conversation.ConversationService @logger.log 'Updated asset message_et (uploaded)', primary_key ### - Delete events from a conversation. - + Update asset with preview in database. @param primary_key [String] Primary key used to find an event in the database ### update_asset_preview_in_db: (primary_key, asset_data) -> @@ -272,8 +270,7 @@ class z.conversation.ConversationService @logger.log 'Updated asset message_et (preview)', primary_key ### - Delete events from a conversation. - + Update asset as failed in database. @param primary_key [String] Primary key used to find an event in the database ### update_asset_as_failed_in_db: (primary_key, reason) -> @@ -301,7 +298,6 @@ class z.conversation.ConversationService ### Load conversation event. - @param conversation_id [String] ID of conversation @param message_id [String] ### diff --git a/app/script/conversation/EventMapper.coffee b/app/script/conversation/EventMapper.coffee index 974892d3c3e..d42773f2242 100644 --- a/app/script/conversation/EventMapper.coffee +++ b/app/script/conversation/EventMapper.coffee @@ -95,6 +95,7 @@ class z.conversation.EventMapper if message_et.is_reactable() message_et.reactions event.reactions or {} + message_et.status event.status if event.status if window.isNaN message_et.timestamp @logger.log @logger.levels.WARN, "Could not get timestamp for message '#{message_et.id}'. Skipping it.", event diff --git a/app/script/cryptography/CryptographyMapper.coffee b/app/script/cryptography/CryptographyMapper.coffee index 9eca0f862d9..c8296c4753a 100644 --- a/app/script/cryptography/CryptographyMapper.coffee +++ b/app/script/cryptography/CryptographyMapper.coffee @@ -51,6 +51,8 @@ class z.cryptography.CryptographyMapper return @_map_asset generic_message.asset, generic_message.message_id, event.data?.id when 'cleared' return @_map_cleared generic_message.cleared + when 'confirmation' + return @_map_confirmation generic_message.confirmation when 'deleted' return @_map_deleted generic_message.deleted when 'edited' @@ -141,6 +143,18 @@ class z.cryptography.CryptographyMapper type: z.event.Backend.CONVERSATION.MEMBER_UPDATE } + _map_confirmation: (confirmation) -> + return { + data: + message_id: confirmation.message_id + status: switch confirmation.type + when z.proto.Confirmation.Type.DELIVERED + z.message.StatusType.DELIVERED + when z.proto.Confirmation.Type.READ + z.message.StatusType.SEEN + type: z.event.Client.CONVERSATION.CONFIRMATION + } + _map_deleted: (deleted) -> return { data: diff --git a/app/script/entity/message/ContentMessage.coffee b/app/script/entity/message/ContentMessage.coffee index 462651f6374..5bcb057e7aa 100644 --- a/app/script/entity/message/ContentMessage.coffee +++ b/app/script/entity/message/ContentMessage.coffee @@ -34,6 +34,7 @@ class z.entity.ContentMessage extends z.entity.Message @reactions = ko.observable {} @reactions_user_ets = ko.observableArray() @reactions_user_ids = ko.pureComputed => (@reactions_user_ets().map (user_et) -> user_et.first_name()).join ', ' + @status = ko.observable z.message.StatusType.SENT @display_edited_timestamp = => return z.localization.Localizer.get_text { @@ -90,6 +91,14 @@ class z.entity.ContentMessage extends z.entity.Message delete reactions[event_json.from] @reactions reactions + update_status: (updated_status) -> + if @status() >= z.message.StatusType.SENT + if updated_status > @status() + return @status updated_status + else if @stats() isnt updated_status + return @status updated_status + return false + ### Check whether the message was edited. diff --git a/app/script/event/Client.coffee b/app/script/event/Client.coffee index b5c8d4fd049..bf445bd3dbe 100644 --- a/app/script/event/Client.coffee +++ b/app/script/event/Client.coffee @@ -25,6 +25,7 @@ z.event.Client = ASSET_PREVIEW: 'conversation.asset-preview' ASSET_UPLOAD_COMPLETE: 'conversation.asset-upload-complete' ASSET_UPLOAD_FAILED: 'conversation.asset-upload-failed' + CONFIRMATION: 'conversation.confirmation' DELETE_EVERYWHERE: 'conversation.delete-everywhere' LOCATION: 'conversation.location' MESSAGE_DELETE: 'conversation.message-delete' diff --git a/app/script/message/StatusType.coffee b/app/script/message/StatusType.coffee index b0adb04c5b9..d50b494f5a6 100644 --- a/app/script/message/StatusType.coffee +++ b/app/script/message/StatusType.coffee @@ -20,9 +20,9 @@ window.z ?= {} z.message ?= {} # Enum for different confirmation types. -z.message.SendingStatus = +z.message.StatusType = + DELIVERED: 3 FAILED: 0 + SEEN: 4 SENDING: 1 SENT: 2 - DELIVERED: 3 - READ: 4 From efd50e27d59f50976a4e3e665d6abd201731a961 Mon Sep 17 00:00:00 2001 From: Gregor Herdmann Date: Mon, 12 Sep 2016 12:08:17 +0200 Subject: [PATCH 04/21] Experimental ring tone for incoming calls --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 63b44db9734..9270e405858 100644 --- a/bower.json +++ b/bower.json @@ -24,7 +24,7 @@ "uint32": "https://github.com/fxa/uint32.js.git#0.2.1", "underscore": "https://github.com/jashkenas/underscore.git#1.8.3", "uuid": "https://github.com/LiosK/UUID.js.git#v3.3.0", - "wire-audio-files": "https://github.com/wireapp/wire-audio-files.git#1.0.0", + "wire-audio-files": "https://github.com/wireapp/wire-audio-files.git#4689e60", "webapp-module-bubble": "https://github.com/wireapp/webapp-module-bubble.git#1.0.0", "webapp-module-external": "https://github.com/wireapp/webapp-module-external.git#1.0.1", "webapp-module-image-compressor": "https://github.com/wireapp/webapp-module-image-compressor.git#1.0.0", From 7ccb9a015544e9265d4b378d54b40bc9ee0cc4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Herrmann?= Date: Mon, 12 Sep 2016 16:03:50 +0200 Subject: [PATCH 05/21] Improvement/image compression (#194) * include jimp Load image without compression Load jimp into vendors folder for testing * Move image compression into worker remove image rotation dont load original image Fix linting * Use Promise * Remove fat arrow --- app/page/template/_dist/app.htm | 1 + app/script/assets/AssetService.coffee | 113 +++++++++++--------------- app/script/util/util.coffee | 11 +++ app/script/util/worker.coffee | 30 +++++++ app/worker/image-worker.coffee | 19 +++++ app/worker/jimp.min.js | 40 +++++++++ aws/main.py | 2 +- grunt/config/copy.coffee | 2 + grunt/config/karma.coffee | 2 + 9 files changed, 153 insertions(+), 67 deletions(-) create mode 100644 app/script/util/worker.coffee create mode 100644 app/worker/image-worker.coffee create mode 100644 app/worker/jimp.min.js diff --git a/app/page/template/_dist/app.htm b/app/page/template/_dist/app.htm index d6bc1323af1..093b2d83ba0 100644 --- a/app/page/template/_dist/app.htm +++ b/app/page/template/_dist/app.htm @@ -18,6 +18,7 @@ + diff --git a/app/script/assets/AssetService.coffee b/app/script/assets/AssetService.coffee index d9fa58319ef..57f7bef64f6 100644 --- a/app/script/assets/AssetService.coffee +++ b/app/script/assets/AssetService.coffee @@ -33,13 +33,6 @@ class z.assets.AssetService @BOUNDARY = 'frontier' - @PREVIEW_CONFIG = - squared: false - max_image_size: 30 - max_byte_size: 1024 - lossy_scaling: true - compression: 0 - @SMALL_PROFILE_CONFIG = squared: true max_image_size: 280 @@ -121,16 +114,11 @@ class z.assets.AssetService @option retention [z.assets.AssetRetentionPolicy] ### _upload_asset: (bytes, options) -> - key_bytes = null - sha256 = null - z.assets.AssetCrypto.encrypt_aes_asset bytes - .then (data) => - [key_bytes, sha256, ciphertext] = data + .then ([key_bytes, sha256, ciphertext]) => return @post_asset_v3 ciphertext, options - .then (data) -> - {key, token} = data - return [key_bytes, sha256, key, token] + .then ({key, token}) -> + return [key_bytes, sha256, key, token] ### Upload image the new asset api v3. Promise will resolve with z.proto.Asset instance. @@ -143,23 +131,16 @@ class z.assets.AssetService @option retention [z.assets.AssetRetentionPolicy] ### upload_image_asset: (file, options) -> - compressed_image = null - image_bytes = null - - @compress_image file - .then (data) -> - [original_image, compressed_image] = data - return z.util.base64_to_array compressed_image.src - .then (bytes) => - image_bytes = bytes - @_upload_asset image_bytes, options - .then (data) -> - [key_bytes, sha256, key, token] = data - image_meta_data = new z.proto.Asset.ImageMetaData compressed_image.width, compressed_image.height - asset = new z.proto.Asset() - asset.set 'original', new z.proto.Asset.Original file.type, image_bytes.length, null, image_meta_data - asset.set 'uploaded', new z.proto.Asset.RemoteData key_bytes, sha256, key, token - return asset + @_compress_image image + .then ([compressed_image, compressed_bytes]) -> + @_upload_asset compressed_bytes, options + .then (data) -> + [key_bytes, sha256, key, token] = data + image_meta_data = new z.proto.Asset.ImageMetaData compressed_image.width, compressed_image.height + asset = new z.proto.Asset() + asset.set 'original', new z.proto.Asset.Original file.type, compressed_bytes.length, null, image_meta_data + asset.set 'uploaded', new z.proto.Asset.RemoteData key_bytes, sha256, key, token + return asset .catch (error) => @logger.log @logger.levels.ERROR, error asset = new z.proto.Asset() @@ -207,17 +188,6 @@ class z.assets.AssetService # Private ############################################################################### - ### - Compress image before uploading. - - @param file [File, Blob] Image - ### - compress_image: (file) -> - return new Promise (resolve) => - @_convert_image file, (image) => - @compressor.transform_image image, (compressed_image) -> - resolve [image, compressed_image] - ### Convert an image before uploading it. @@ -392,29 +362,21 @@ class z.assets.AssetService @param image [File, Blob] ### create_image_proto: (image) -> - original_image = null - compressed_image = null - image_bytes = null - - @compress_image image - .then (data) -> - [original_image, compressed_image] = data - return z.util.base64_to_array compressed_image.src - .then (data) -> - image_bytes = data - z.assets.AssetCrypto.encrypt_aes_asset image_bytes - .then ([key_bytes, sha256, ciphertext]) -> - image_asset = new z.proto.ImageAsset() - image_asset.set_tag z.assets.ImageSizeType.MEDIUM - image_asset.set_width compressed_image.width - image_asset.set_height compressed_image.height - image_asset.set_original_width original_image.width - image_asset.set_original_height original_image.height - image_asset.set_mime_type image.type - image_asset.set_size image_bytes.length - image_asset.set_otr_key key_bytes - image_asset.set_sha256 sha256 - return [image_asset, new Uint8Array ciphertext] + @_compress_image image + .then ([compressed_image, compressed_bytes]) -> + return z.assets.AssetCrypto.encrypt_aes_asset compressed_bytes + .then ([key_bytes, sha256, ciphertext]) -> + image_asset = new z.proto.ImageAsset() + image_asset.set_tag z.assets.ImageSizeType.MEDIUM + image_asset.set_width compressed_image.width + image_asset.set_height compressed_image.height + image_asset.set_original_width compressed_image.width + image_asset.set_original_height compressed_image.height + image_asset.set_mime_type image.type + image_asset.set_size compressed_bytes.length + image_asset.set_otr_key key_bytes + image_asset.set_sha256 sha256 + return [image_asset, new Uint8Array ciphertext] ### Create asset proto message. @@ -428,3 +390,22 @@ class z.assets.AssetService asset = new z.proto.Asset() asset.set 'uploaded', new z.proto.Asset.RemoteData key_bytes, sha256 return [asset, ciphertext] + + ############################################################################### + # Image processing + ############################################################################### + + ### + Compress image. + @param asset [File, Blob] + ### + _compress_image: (blob) -> + z.util.load_file_buffer blob + .then (buffer) -> + if blob.type is 'image/gif' + return z.util.load_file_buffer blob + return new z.util.Worker 'worker/image-worker.js'.post buffer + .then (compressed_bytes) -> + return z.util.load_image new Blob [new Uint8Array compressed_bytes], 'type': blob.type + .then (compressed_image) -> + return [compressed_image, new Uint8Array compressed_bytes] diff --git a/app/script/util/util.coffee b/app/script/util/util.coffee index f897b772258..d12254fd981 100644 --- a/app/script/util/util.coffee +++ b/app/script/util/util.coffee @@ -67,6 +67,17 @@ z.util.iterate_array_index = (array, current_index) -> return (current_index + 1) % array.length +z.util.load_image = (blob) -> + return new Promise (resolve, reject) -> + object_url = window.URL.createObjectURL blob + img = new Image() + img.onload = -> + resolve @ + window.URL.revokeObjectURL object_url + img.onerror = reject + img.src = object_url + + z.util.load_file_buffer = (file) -> return new Promise (resolve, reject) -> reader = new FileReader() diff --git a/app/script/util/worker.coffee b/app/script/util/worker.coffee new file mode 100644 index 00000000000..dd37a62b09d --- /dev/null +++ b/app/script/util/worker.coffee @@ -0,0 +1,30 @@ +# +# Wire +# Copyright (C) 2016 Wire Swiss GmbH +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# + +window.z ?= {} +z.util ?= {} + +class z.util.Worker + constructor: (uri) -> + + @post = (data) -> + return new Promise (resolve, reject) -> + worker = new window.Worker uri + worker.onmessage = (event) -> resolve event.data + worker.onerror = (error) -> reject error + worker.postMessage data diff --git a/app/worker/image-worker.coffee b/app/worker/image-worker.coffee new file mode 100644 index 00000000000..2494f0a062d --- /dev/null +++ b/app/worker/image-worker.coffee @@ -0,0 +1,19 @@ +importScripts 'jimp.min.js' + +MAX_SIZE = 1448 +MAX_FILE_SIZE = 5 * 1024 +COMPRESSION = 75 + +self.addEventListener 'message', (event) -> + + Jimp.read(event.data).then (image) -> + + if image.bitmap.width > MAX_SIZE or image.bitmap.height > MAX_SIZE + image.scaleToFit MAX_SIZE, MAX_SIZE + + if image.bitmap.data.length > MAX_FILE_SIZE + image.quality COMPRESSION + + image.getBuffer Jimp.AUTO, (err, src) -> + self.postMessage src + self.close() diff --git a/app/worker/jimp.min.js b/app/worker/jimp.min.js new file mode 100644 index 00000000000..dc22ee78591 --- /dev/null +++ b/app/worker/jimp.min.js @@ -0,0 +1,40 @@ +/* +Jimp v0.2.27 +https://github.com/oliver-moran/jimp +Ported for the Web by Phil Seaton + +The MIT License (MIT) + +Copyright (c) 2014 Oliver Moran + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +var window = window || self; +var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t};if(function t(e,i,n){function r(o,s){if(!i[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var h=new Error("Cannot find module '"+o+"'");throw h.code="MODULE_NOT_FOUND",h}var f=i[o]={exports:{}};e[o][0].call(f.exports,function(t){var i=e[o][1][t];return r(i?i:t)},f,f.exports,t,e,i,n)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o0;)e.stdout.write("\b")}function u(){}function p(t){if("undefined"==typeof t)return!1;if("function"!=typeof t)throw new Error("Callback must be a function");return!0}function d(t,e){if("string"==typeof t&&(t=new Error(t)),"function"==typeof e)return e.call(this,t);throw t}function m(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1],i=arguments[2];if("number"==typeof arguments[2]){this._background=arguments[2];var i=arguments[3]}if("undefined"==typeof i&&(i=u),"function"!=typeof i)return d.call(this,"cb must be a function",i);this.bitmap={data:new n(t*e*4),width:t,height:e};for(var r=0;r (HTTP: "+e.statusCode+")",i);var a=g(r);return"string"!=typeof a?d.call(l,"Could not find MIME for Buffer <"+s+"> (HTTP: "+e.statusCode+")",i):void v.call(l,r,a,i)})}else if("string"==typeof arguments[0]){var h=arguments[0],i=arguments[1];if("undefined"==typeof i&&(i=u),"function"!=typeof i)return d.call(this,"cb must be a function",i);var l=this;b(h,function(t,e){A.readFile(h,function(t,n){return t?d.call(l,t,i):void v.call(l,n,e,i)})})}else{if("object"!=_typeof(arguments[0]))return d.call(this,"No matching constructor overloading was found. Please see the docs for how to call the Jimp constructor.",i);var f=arguments[0],c=g(f),i=arguments[1];if(!n.isBuffer(f))return d.call(this,"data must be a Buffer",i);if("string"!=typeof c)return d.call(this,"mime must be a string",i);if("function"!=typeof i)return d.call(this,"cb must be a function",i);v.call(this,f,c,i)}}function g(t,e){var i=N(t);return i?i.mime:e?C.lookup(e):null}function b(t,e){U(t,0,262,function(t,i){if(!t){var n=N(i);return e&&e(null,n&&n.mime||"")}e(null,"")})}function v(t,e,i){var r=this;switch(this._originalMime=e.toLowerCase(),this.getMIME()){case m.MIME_PNG:var a=new R;a.parse(t,function(t,e){return t?d.call(r,t,i):(r.bitmap={data:new n(e.data),width:e.width,height:e.height},i.call(r,null,r))});break;case m.MIME_JPEG:try{return this.bitmap=L.decode(t),w(this,t),i.call(this,null,this)}catch(t){return i.call(this,t,this)}case m.MIME_BMP:return this.bitmap=P.decode(t),i.call(this,null,this);default:return d.call(this,"Unsupported MIME type: "+e,i)}}function w(t,e){var i;try{i=j.create(e).parse()}catch(t){return}if(i&&i.tags&&i.tags.Orientation)switch(i.tags.Orientation){case 1:break;case 2:t.mirror(!0,!1);break;case 3:t.rotate(180);break;case 4:t.mirror(!1,!0);break;case 5:t.mirror(!0,!1).rotate(270);break;case 6:t.rotate(90);break;case 7:t.mirror(!0,!1).rotate(90);break;case 8:t.rotate(270)}}function _(){var t={r:new Array(256).fill(0),g:new Array(256).fill(0),b:new Array(256).fill(0)};return this.scan(0,0,this.bitmap.width,this.bitmap.height,function(e,i,n){t.r[this.bitmap.data[n+0]]++,t.g[this.bitmap.data[n+1]]++,t.b[this.bitmap.data[n+2]]++}),t}function y(t){for(var e=Math.round(t/90)%4;e<0;)e+=4;for(;e>0;){for(var i=new n(this.bitmap.data.length),r=0,a=0;a=0;o--){var s=this.bitmap.width*o+a<<2,l=this.bitmap.data.readUInt32BE(s,!0);i.writeUInt32BE(l,r,!0),r+=4}this.bitmap.data=new n(i);var h=this.bitmap.width;this.bitmap.width=this.bitmap.height,this.bitmap.height=h,e--}}function x(t,e){function i(t,e){return function(i,n){return{x:i+t,y:n+e}}}var r,a,o=t%360*Math.PI/180,s=Math.cos(o),l=Math.sin(o);if(1==e||"string"==typeof e){r=Math.round(Math.abs(this.bitmap.width*s)+Math.abs(this.bitmap.height*l)),a=Math.round(Math.abs(this.bitmap.width*l)+Math.abs(this.bitmap.height*s));var h=this.clone();this.scan(0,0,this.bitmap.width,this.bitmap.height,function(t,e,i){this.bitmap.data.writeUInt32BE(this._background,i)});var f=Math.max(r,a,this.bitmap.width,this.bitmap.height);this.resize(f,f,e),this.blit(h,this.bitmap.width/2-h.bitmap.width/2,this.bitmap.height/2-h.bitmap.height/2)}for(var c=new n(this.bitmap.data.length),u=i(-(this.bitmap.width/2),-(this.bitmap.height/2)),p=i(this.bitmap.width/2,this.bitmap.height/2),d=0;d=0&&b.x=0&&b.y0&&r.height>0){var a=e.pages[r.page].clone().crop(r.x,r.y,r.width,r.height);return t.composite(a,i+r.xoffset,n+r.yoffset)}return t}function M(t,e){for(var i=0,n=0;n255)return d.call(this,"r must be between 0 and 255",r);if((e<0||e>255)&&d.call(this,"g must be between 0 and 255",r),i<0||i>255)return d.call(this,"b must be between 0 and 255",r);if(n<0||n>255)return d.call(this,"a must be between 0 and 255",r);var a=t*Math.pow(256,3)+e*Math.pow(256,2)+i*Math.pow(256,1)+n*Math.pow(256,0);return p(r)?r.call(this,null,a):a},m.intToRGBA=function(t,e){if("number"!=typeof t)return d.call(this,"i must be a number",e);var i={};return i.r=Math.floor(t/Math.pow(256,3)),i.g=Math.floor((t-i.r*Math.pow(256,3))/Math.pow(256,2)),i.b=Math.floor((t-i.r*Math.pow(256,3)-i.g*Math.pow(256,2))/Math.pow(256,1)),i.a=Math.floor((t-i.r*Math.pow(256,3)-i.g*Math.pow(256,2)-i.b*Math.pow(256,1))/Math.pow(256,0)),p(e)?e.call(this,null,i):i},m.limit255=function(t){return t=Math.max(t,0),t=Math.min(t,255)},m.diff=function(t,e,i){if("object"!=("undefined"==typeof t?"undefined":_typeof(t))||t.constructor!=m||"object"!=("undefined"==typeof e?"undefined":_typeof(e))||e.constructor!=m)return d.call(this,"img1 and img2 must be an Jimp images");if(t.bitmap.width!=e.bitmap.width||t.bitmap.height!=e.bitmap.height)switch(t.bitmap.width*t.bitmap.height>e.bitmap.width*e.bitmap.height){case!0:t=t.clone().resize(e.bitmap.width,e.bitmap.height);break;default:e=e.clone().resize(t.bitmap.width,t.bitmap.height)}if(i=i||.1,"number"!=typeof i||i<0||i>1)return d.call(this,"threshold must be a number between 0 and 1");var n=new m(t.bitmap.width,t.bitmap.height,4294967295),r=F(t.bitmap.data,e.bitmap.data,n.bitmap.data,n.bitmap.width,n.bitmap.height,{threshold:i});return{percent:r/(n.bitmap.width*n.bitmap.height),image:n}},m.distance=function(t,e){var i=new H,n=i.getHash(t),r=i.getHash(e);return i.distance(n,r)},m.prototype.bitmap={data:null,width:null,height:null},m.prototype._quality=100,m.prototype._deflateLevel=9,m.prototype._deflateStrategy=3,m.prototype._filterType=m.PNG_FILTER_AUTO,m.prototype._rgba=!0,m.prototype._background=0,m.prototype._originalMime=m.MIME_PNG,m.prototype.clone=function(t){var e=new m(this);return p(t)?t.call(e,null,e):e},m.prototype.quality=function(t,e){return"number"!=typeof t?d.call(this,"n must be a number",e):t<0||t>100?d.call(this,"n must be a number 0 - 100",e):(this._quality=Math.round(t),p(e)?e.call(this,null,this):this)},m.prototype.deflateLevel=function(t,e){return"number"!=typeof t?d.call(this,"l must be a number",e):t<0||t>9?d.call(this,"l must be a number 0 - 9",e):(this._deflateLevel=Math.round(t),p(e)?e.call(this,null,this):this)},m.prototype.deflateStrategy=function(t,e){return"number"!=typeof t?d.call(this,"s must be a number",e):t<0||t>3?d.call(this,"s must be a number 0 - 3",e):(this._deflateStrategy=Math.round(t),p(e)?e.call(this,null,this):this)},m.prototype.filterType=function(t,e){return"number"!=typeof t?d.call(this,"n must be a number",e):t<-1||t>4?d.call(this,"n must be -1 (auto) or a number 0 - 4",e):(this._filterType=Math.round(t),p(e)?e.call(this,null,this):this)},m.prototype.rgba=function(t,e){return"boolean"!=typeof t?d.call(this,"bool must be a boolean, true for RGBA or false for RGB",e):(this._rgba=t,p(e)?e.call(this,null,this):this)},m.prototype.background=function(t,e){return"number"!=typeof t?d.call(this,"hex must be a hexadecimal rgba value",e):(this._background=t,p(e)?e.call(this,null,this):this)},m.prototype.scan=function(t,e,i,n,r,a){if("number"!=typeof t||"number"!=typeof e)return d.call(this,"x and y must be numbers",a);if("number"!=typeof i||"number"!=typeof n)return d.call(this,"w and h must be numbers",a);if("function"!=typeof r)return d.call(this,"f must be a function",a);t=Math.round(t),e=Math.round(e),i=Math.round(i),n=Math.round(n);for(var o=e;othis.bitmap.width)&&(n=-1),(e<0||e>this.bitmap.height)&&(n=-1),p(i)?i.call(this,null,n):n},m.prototype.getPixelColor=m.prototype.getPixelColour=function(t,e,i){if("number"!=typeof t||"number"!=typeof e)return d.call(this,"x and y must be numbers",i);t=Math.round(t),e=Math.round(e);var n=this.getPixelIndex(t,e),r=this.bitmap.data.readUInt32BE(n);return p(i)?i.call(this,null,r):r},m.prototype.setPixelColor=m.prototype.setPixelColour=function(t,e,i,n){if("number"!=typeof t||"number"!=typeof e||"number"!=typeof i)return d.call(this,"hex, x and y must be numbers",n);e=Math.round(e),i=Math.round(i);var r=this.getPixelIndex(e,i);return this.bitmap.data.writeUInt32BE(t,r,!0),p(n)?n.call(this,null,this):this};for(var V=[],J=0;J<65;J++){var $=J>1?new G(Array(65).join("1"),2).toString(J):NaN;V.push($.length)}m.prototype.hash=function(t,e){if(t=t||64,"function"==typeof t&&(e=t,t=64),"number"!=typeof t)return d.call(this,"base must be a number",e);if(t<2||t>64)return d.call(this,"base must be a number between 2 and 64",e);var i=(new H).getHash(this);for(i=new G(i,2).toString(t);i.lengthr)break t}h++}t:for(var b=0;br)break t}f++}l=this.getPixelColor(e-1,i-1);t:for(var g=i-1;g>=0+h+n;g--){for(var b=e-f-1;b>=0;b--){var v=this.getPixelColor(b,g),w=m.intToRGBA(v),_=Math.abs(Math.max(d.r-w.r^2,d.r-w.r-d.a+w.a^2)+Math.max(d.g-w.g^2,d.g-w.g-d.a+w.a^2)+Math.max(d.b-w.b^2,d.b-w.b-d.a+w.a^2))/196608;if(_>r)break t}c++}t:for(var b=e-1;b>=0+f+n;b--){for(var g=i-1;g>=0+h;g--){var v=this.getPixelColor(b,g),w=m.intToRGBA(v),_=Math.abs(Math.max(d.r-w.r^2,d.r-w.r-d.a+w.a^2)+Math.max(d.g-w.g^2,d.g-w.g-d.a+w.a^2)+Math.max(d.b-w.b^2,d.b-w.b-d.a+w.a^2))/196608;if(_>r)break t}u++}var y=e-(u+f),x=i-(c+h),k=!1;return k=a?0!==f&&0!==h&&0!==u&&0!==c:0!==f||0!==h||0!==u||0!==c,k&&this.crop(f,h,y,x),p(t)?t.call(this,null,this):this},m.prototype.blit=function(t,e,i,n,r,a,o,s){if("object"!=("undefined"==typeof t?"undefined":_typeof(t))||t.constructor!=m)return d.call(this,"The source must be a Jimp image",s);if("number"!=typeof e||"number"!=typeof i)return d.call(this,"x and y must be numbers",s);if("function"==typeof n)s=n,n=0,r=0,a=t.bitmap.width,o=t.bitmap.height;else{if(("undefined"==typeof n?"undefined":_typeof(n))!=("undefined"==typeof r?"undefined":_typeof(r))||("undefined"==typeof r?"undefined":_typeof(r))!=("undefined"==typeof a?"undefined":_typeof(a))||("undefined"==typeof a?"undefined":_typeof(a))!=("undefined"==typeof o?"undefined":_typeof(o)))return d.call(this,"srcx, srcy, srcw, srch must be numbers",s);n=n||0,r=r||0,a=a||t.bitmap.width,o=o||t.bitmap.height}e=Math.round(e),i=Math.round(i),n=Math.round(n),r=Math.round(r),a=Math.round(a),o=Math.round(o);var l=this;return t.scan(n,r,a,o,function(t,a,o){var s=l.getPixelIndex(e+t-n,i+a-r);l.bitmap.data[s]=this.bitmap.data[o],l.bitmap.data[s+1]=this.bitmap.data[o+1],l.bitmap.data[s+2]=this.bitmap.data[o+2],l.bitmap.data[s+3]=this.bitmap.data[o+3]}),p(s)?s.call(this,null,this):this},m.prototype.mask=function(t,e,i,n){if("object"!=("undefined"==typeof t?"undefined":_typeof(t))||t.constructor!=m)return d.call(this,"The source must be a Jimp image",n);if("number"!=typeof e||"number"!=typeof i)return d.call(this,"x and y must be numbers",n);e=Math.round(e),i=Math.round(i);var r=this;return t.scan(0,0,t.bitmap.width,t.bitmap.height,function(t,n,a){var o=r.getPixelIndex(e+t,i+n),s=(this.bitmap.data[a+0]+this.bitmap.data[a+1]+this.bitmap.data[a+2])/3;r.bitmap.data[o+3]*=s/255}),p(n)?n.call(this,null,this):this},m.prototype.composite=function(t,e,i,n){if("object"!=("undefined"==typeof t?"undefined":_typeof(t))||t.constructor!=m)return d.call(this,"The source must be a Jimp image",n);if("number"!=typeof e||"number"!=typeof i)return d.call(this,"x and y must be numbers",n);e=Math.round(e),i=Math.round(i);var r=this;return t.scan(0,0,t.bitmap.width,t.bitmap.height,function(t,n,a){var o=r.getPixelIndex(e+t,i+n),s={r:this.bitmap.data[a+0]/255,g:this.bitmap.data[a+1]/255,b:this.bitmap.data[a+2]/255,a:this.bitmap.data[a+3]/255},l={r:r.bitmap.data[o+0]/255,g:r.bitmap.data[o+1]/255,b:r.bitmap.data[o+2]/255,a:r.bitmap.data[o+3]/255},h=l.a+s.a-l.a*s.a,f=(s.r*s.a+l.r*l.a*(1-s.a))/h,c=(s.g*s.a+l.g*l.a*(1-s.a))/h,u=(s.b*s.a+l.b*l.a*(1-s.a))/h;r.bitmap.data[o+0]=m.limit255(255*f),r.bitmap.data[o+1]=m.limit255(255*c),r.bitmap.data[o+2]=m.limit255(255*u),r.bitmap.data[o+3]=m.limit255(255*h)}),p(n)?n.call(this,null,this):this},m.prototype.brightness=function(t,e){return"number"!=typeof t?d.call(this,"val must be numbers",e):t<-1||t>1?d.call(this,"val must be a number between -1 and +1",e):(this.scan(0,0,this.bitmap.width,this.bitmap.height,function(e,i,n){t<0?(this.bitmap.data[n]=this.bitmap.data[n]*(1+t),this.bitmap.data[n+1]=this.bitmap.data[n+1]*(1+t),this.bitmap.data[n+2]=this.bitmap.data[n+2]*(1+t)):(this.bitmap.data[n]=this.bitmap.data[n]+(255-this.bitmap.data[n])*t,this.bitmap.data[n+1]=this.bitmap.data[n+1]+(255-this.bitmap.data[n+1])*t,this.bitmap.data[n+2]=this.bitmap.data[n+2]+(255-this.bitmap.data[n+2])*t)}),p(e)?e.call(this,null,this):this)},m.prototype.contrast=function(t,e){function i(e){if(t<0){var i=e>127?1-e/255:e/255;return i<0&&(i=0),i=.5*Math.pow(2*i,1+t),e>127?255*(1-i):255*i}var i=e>127?1-e/255:e/255;return i<0&&(i=0),i=.5*Math.pow(2*i,1==t?127:1/(1-t)),e>127?255*(1-i):255*i}return"number"!=typeof t?d.call(this,"val must be numbers",e):t<-1||t>1?d.call(this,"val must be a number between -1 and +1",e):(this.scan(0,0,this.bitmap.width,this.bitmap.height,function(t,e,n){this.bitmap.data[n]=i(this.bitmap.data[n]),this.bitmap.data[n+1]=i(this.bitmap.data[n+1]),this.bitmap.data[n+2]=i(this.bitmap.data[n+2])}),p(e)?e.call(this,null,this):this)},m.prototype.posterize=function(t,e){return"number"!=typeof t?d.call(this,"n must be numbers",e):(t<2&&(t=2),this.scan(0,0,this.bitmap.width,this.bitmap.height,function(e,i,n){this.bitmap.data[n]=Math.floor(this.bitmap.data[n]/255*(t-1))/(t-1)*255,this.bitmap.data[n+1]=Math.floor(this.bitmap.data[n+1]/255*(t-1))/(t-1)*255,this.bitmap.data[n+2]=Math.floor(this.bitmap.data[n+2]/255*(t-1))/(t-1)*255}),p(e)?e.call(this,null,this):this)},m.prototype.normalize=function(t){var e=_.call(this),i=function(t,e,i){return 255*(t-e)/(i-e)},n=function(t){return[t.findIndex(function(t){return t>0}),255-t.slice().reverse().findIndex(function(t){return t>0})]},r={r:n(e.r),g:n(e.g),b:n(e.b)};return this.scan(0,0,this.bitmap.width,this.bitmap.height,function(t,e,n){var a=this.bitmap.data[n+0],o=this.bitmap.data[n+1],s=this.bitmap.data[n+2];this.bitmap.data[n+0]=i(a,r.r[0],r.r[1]),this.bitmap.data[n+1]=i(o,r.g[0],r.g[1]),this.bitmap.data[n+2]=i(s,r.b[0],r.b[1])}),p(t)?t.call(this,null,this):this},m.prototype.invert=function(t){return this.scan(0,0,this.bitmap.width,this.bitmap.height,function(t,e,i){this.bitmap.data[i]=255-this.bitmap.data[i],this.bitmap.data[i+1]=255-this.bitmap.data[i+1],this.bitmap.data[i+2]=255-this.bitmap.data[i+2]}),p(t)?t.call(this,null,this):this},m.prototype.mirror=m.prototype.flip=function(t,e,i){if("boolean"!=typeof t||"boolean"!=typeof e)return d.call(this,"horizontal and vertical must be Booleans",i);var r=new n(this.bitmap.data.length);return this.scan(0,0,this.bitmap.width,this.bitmap.height,function(i,n,a){var o=t?this.bitmap.width-1-i:i,s=e?this.bitmap.height-1-n:n,l=this.bitmap.width*s+o<<2,h=this.bitmap.data.readUInt32BE(a,!0);r.writeUInt32BE(h,l,!0)}),this.bitmap.data=new n(r),p(i)?i.call(this,null,this):this},m.prototype.gaussian=function(t,e){if("number"!=typeof t)return d.call(this,"r must be a number",e);if(t<1)return d.call(this,"r must be greater than 0",e);for(var i=Math.ceil(2.57*t),n=0;n0;){for(g=m=0,s=0;sv?v:l)<<2),i+=this.bitmap.data[h++],n+=this.bitmap.data[h++],r+=this.bitmap.data[h++],a+=this.bitmap.data[h];for(o=0;o0?h<<2:0),f=g+M[o],c=g+A[o],i+=this.bitmap.data[f++]-this.bitmap.data[c++],n+=this.bitmap.data[f++]-this.bitmap.data[c++],r+=this.bitmap.data[f++]-this.bitmap.data[c++],a+=this.bitmap.data[f]-this.bitmap.data[c],m++;g+=this.bitmap.width<<2}for(o=0;ow?0:this.bitmap.width,i+=k[u],n+=E[u],r+=S[u],a+=I[u];for(m=o<<2,s=0;s>>x,b>255&&(this.bitmap.data[m+3]=255),b>0?(b=255/b,this.bitmap.data[m]=(i*y>>>x)*b,this.bitmap.data[m+1]=(n*y>>>x)*b,this.bitmap.data[m+2]=(r*y>>>x)*b):this.bitmap.data[m]=this.bitmap.data[m+1]=this.bitmap.data[m+2]=0,0==o&&(M[s]=((h=s+_)0?h*this.bitmap.width:0),f=o+M[s],c=o+A[s],i+=k[f]-k[c],n+=E[f]-E[c],r+=S[f]-S[c],a+=I[f]-I[c],m+=this.bitmap.width<<2}}return p(e)?e.call(this,null,this):this},m.prototype.greyscale=function(t){return this.scan(0,0,this.bitmap.width,this.bitmap.height,function(t,e,i){var n=parseInt(.2126*this.bitmap.data[i]+.7152*this.bitmap.data[i+1]+.0722*this.bitmap.data[i+2],10);this.bitmap.data[i]=n,this.bitmap.data[i+1]=n,this.bitmap.data[i+2]=n}),p(t)?t.call(this,null,this):this},m.prototype.grayscale=m.prototype.greyscale,m.prototype.sepia=function(t){return this.scan(0,0,this.bitmap.width,this.bitmap.height,function(t,e,i){var n=this.bitmap.data[i],r=this.bitmap.data[i+1],a=this.bitmap.data[i+2];n=.393*n+.769*r+.189*a,r=.349*n+.686*r+.168*a,a=.272*n+.534*r+.131*a,this.bitmap.data[i]=n<255?n:255,this.bitmap.data[i+1]=r<255?r:255,this.bitmap.data[i+2]=a<255?a:255}),p(t)?t.call(this,null,this):this},m.prototype.opacity=function(t,e){return"number"!=typeof t?d.call(this,"f must be a number",e):t<0||t>1?d.call(this,"f must be a number from 0 to 1",e):(this.scan(0,0,this.bitmap.width,this.bitmap.height,function(e,i,n){var r=this.bitmap.data[n+3]*t;this.bitmap.data[n+3]=r}),p(e)?e.call(this,null,this):this)},m.prototype.fade=function(t,e){return"number"!=typeof t?d.call(this,"f must be a number",e):t<0||t>1?d.call(this,"f must be a number from 0 to 1",e):(this.opacity(1-t),p(e)?e.call(this,null,this):this)},m.prototype.opaque=function(t){return this.scan(0,0,this.bitmap.width,this.bitmap.height,function(t,e,i){this.bitmap.data[i+3]=255}),p(t)?t.call(this,null,this):this},m.prototype.resize=function(t,e,i,r){if("number"!=typeof t||"number"!=typeof e)return d.call(this,"w and h must be numbers",r);if("function"==typeof i&&"undefined"==typeof r&&(r=i,i=null),t==m.AUTO&&e==m.AUTO)return d.call(this,"w and h cannot both the set to auto",r);if(t==m.AUTO&&(t=this.bitmap.width*(e/this.bitmap.height)),e==m.AUTO&&(e=this.bitmap.height*(t/this.bitmap.width)),t=Math.round(t),e=Math.round(e),"function"==typeof O[i]){var a={data:new n(t*e*4),width:t,height:e};O[i](this.bitmap,a),this.bitmap=a}else{var o=this,s=new z(this.bitmap.width,this.bitmap.height,t,e,(!0),(!0),function(i){o.bitmap.data=new n(i),o.bitmap.width=t,o.bitmap.height=e});s.resize(this.bitmap.data)}return p(r)?r.call(this,null,this):this},m.prototype.cover=function(t,e,i,n,r){if("number"!=typeof t||"number"!=typeof e)return d.call(this,"w and h must be numbers",r);i&&"function"==typeof i&&"undefined"==typeof r?(r=i,i=null,n=null):"function"==typeof n&&"undefined"==typeof r&&(r=n,n=null),i=i||m.HORIZONTAL_ALIGN_CENTER|m.VERTICAL_ALIGN_MIDDLE;var a=7&i,o=i>>3;if((0==a||a&a-1)&&(0==o||o&o-1))return d.call(this,"only use one flag per alignment direction",r);var s=a>>1,l=o>>1,h=t/e>this.bitmap.width/this.bitmap.height?t/this.bitmap.width:e/this.bitmap.height;return this.scale(h,n),this.crop((this.bitmap.width-t)/2*s,(this.bitmap.height-e)/2*l,t,e),p(r)?r.call(this,null,this):this},m.prototype.contain=function(t,e,i,n,r){if("number"!=typeof t||"number"!=typeof e)return d.call(this,"w and h must be numbers",r);switch("undefined"==typeof i?"undefined":_typeof(i)){case"string":"function"==typeof n&&"undefined"==typeof r&&(r=n),n=i,i=null;case"function":"undefined"==typeof r&&(r=i),n=null,i=null;default:"function"==typeof n&&"undefined"==typeof r&&(r=n,n=null)}i=i||m.HORIZONTAL_ALIGN_CENTER|m.VERTICAL_ALIGN_MIDDLE;var a=7&i,o=i>>3;if((0==a||a&a-1)&&(0==o||o&o-1))return d.call(this,"only use one flag per alignment direction",r);var s=a>>1,l=o>>1,h=t/e>this.bitmap.width/this.bitmap.height?e/this.bitmap.height:t/this.bitmap.width,f=this.clone().scale(h,n);return this.resize(t,e,n),this.scan(0,0,this.bitmap.width,this.bitmap.height,function(t,e,i){this.bitmap.data.writeUInt32BE(this._background,i)}),this.blit(f,(this.bitmap.width-f.bitmap.width)/2*s,(this.bitmap.height-f.bitmap.height)/2*l),p(r)?r.call(this,null,this):this},m.prototype.scale=function(t,e,i){if("number"!=typeof t)return d.call(this,"f must be a number",i);if(t<0)return d.call(this,"f must be a positive number",i);"function"==typeof e&&"undefined"==typeof i&&(i=e,e=null);var n=this.bitmap.width*t,r=this.bitmap.height*t;return this.resize(n,r,e),p(i)?i.call(this,null,this):this},m.prototype.scaleToFit=function(t,e,i,n){if("number"!=typeof t||"number"!=typeof e)return d.call(this,"w and h must be numbers",n);"function"==typeof i&&"undefined"==typeof n&&(n=i,i=null);var r=t/e>this.bitmap.width/this.bitmap.height?e/this.bitmap.height:t/this.bitmap.width;return this.scale(r,i),p(n)?n.call(this,null,this):this},m.prototype.rotate=function(t,e,i){return"undefined"!=typeof e&&null!==e||(e=!0),"function"==typeof e&&"undefined"==typeof i&&(i=e,e=!0),"number"!=typeof t?d.call(this,"deg must be a number",i):"boolean"!=typeof e&&"string"!=typeof e?d.call(this,"mode must be a boolean or a string",i):(t%90==0&&e!==!1?y.call(this,t,i):x.call(this,t,e,i),p(i)?i.call(this,null,this):this)},m.prototype.getBuffer=function(t,e){if(t==m.AUTO&&(t=this.getMIME()),"string"!=typeof t)return d.call(this,"mime must be a string",e);if("function"!=typeof e)return d.call(this,"cb must be a function",e);switch(t.toLowerCase()){case m.MIME_PNG:var i=this,r=new R({width:this.bitmap.width,height:this.bitmap.height,bitDepth:8,deflateLevel:this._deflateLevel,deflateStrategy:this._deflateStrategy,filterType:this._filterType,colorType:this._rgba?6:2,inputHasAlpha:!0});this._rgba?r.data=new n(this.bitmap.data):r.data=k(this).data,D(r.pack(),function(t,n){return e.call(i,null,n)});break;case m.MIME_JPEG:var a=L.encode(k(this),this._quality);return e.call(this,null,a.data);case m.MIME_BMP:var o=P.encode(k(this)); +return e.call(this,null,o.data);default:return e.call(this,"Unsupported MIME type: "+t)}return this},m.prototype.getBase64=function(t,e){return t==m.AUTO&&(t=this.getMIME()),"string"!=typeof t?d.call(this,"mime must be a string",e):"function"!=typeof e?d.call(this,"cb must be a function",e):(this.getBuffer(t,function(i,n){var r="data:"+t+";base64,"+n.toString("base64");return e.call(this,null,r)}),this)},m.prototype.dither565=function(t){var e=[1,9,3,11,13,5,15,7,4,12,2,10,16,8,14,6];return this.scan(0,0,this.bitmap.width,this.bitmap.height,function(t,i,n){var r=((3&i)<<2)+t%4,a=e[r];this.bitmap.data[n]=Math.min(this.bitmap.data[n]+a,255),this.bitmap.data[n+1]=Math.min(this.bitmap.data[n+1]+a,255),this.bitmap.data[n+2]=Math.min(this.bitmap.data[n+2]+a,255)}),p(t)?t.call(this,null,this):this},m.prototype.dither16=m.prototype.dither565,m.prototype.color=m.prototype.colour=function(t,e){if(!t||!Array.isArray(t))return d.call(this,"actions must be an array",e);var i=this;return this.scan(0,0,this.bitmap.width,this.bitmap.height,function(n,r,a){var o=B({r:this.bitmap.data[a],g:this.bitmap.data[a+1],b:this.bitmap.data[a+2]}),s=function(t,e){return c=o.toRgb(),c[t]=Math.max(0,Math.min(c[t]+e,255)),B(c)};t.forEach(function(t){if("mix"===t.apply)o=B.mix(o,t.params[0],t.params[1]);else if("tint"===t.apply)o=B.mix(o,"white",t.params[0]);else if("shade"===t.apply)o=B.mix(o,"black",t.params[0]);else if("xor"===t.apply){var n=B(t.params[0]).toRgb();o=o.toRgb(),o=B({r:o.r^n.r,g:o.g^n.g,b:o.b^n.b})}else if("red"===t.apply)o=s("r",t.params[0]);else if("green"===t.apply)o=s("g",t.params[0]);else if("blue"===t.apply)o=s("b",t.params[0]);else{"hue"===t.apply&&(t.apply="spin");var r=o[t.apply];if(!r)return d.call(i,"action "+t.apply+" not supported",e);o=r.apply(o,t.params)}}),o=o.toRgb(),this.bitmap.data[a]=o.r,this.bitmap.data[a+1]=o.g,this.bitmap.data[a+2]=o.b}),p(e)?e.call(this,null,this):this},m.loadFont=function(t,e){if("string"!=typeof t)return d.call(this,"file must be a string",e);var i=this;return new Y(function(n,r){e=e||function(t,e){t?r(t):n(e)},q(t,function(n,r){var a={},o={};if(n)return d.call(i,n,e);for(var s=0;sr&&h>0?(o=o.print(t,e,i,l),l=s[h]+" ",i+=t.common.lineHeight):l=f}return S.call(this,t,e,i,l),p(a)?a.call(this,null,o):o},m.prototype.write=function(t,e){if("string"!=typeof t)return d.call(this,"path must be a string",e);if("undefined"==typeof e&&(e=function(){}),"function"!=typeof e)return d.call(this,"cb must be a function",e);var i=this,n=C.lookup(t);return this.getBuffer(n,function(n,r){if(n)return d.call(i,n,e);var a=A.createWriteStream(t);a.on("open",function(t){a.write(r),a.end()}).on("error",function(t){return d.call(i,t,e)}),a.on("finish",function(t){return e.call(i,null,i)})}),this};var tt;"object"==("undefined"==typeof window?"undefined":_typeof(window))&&(tt=window),"object"==("undefined"==typeof self?"undefined":_typeof(self))&&(tt=self),tt.Jimp=m,tt.Buffer=n}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/..")},{"./phash.js":107,"./resize.js":108,"./resize2.js":109,_process:12,"bignumber.js":4,"bmp-js":5,buffer:14,"es6-promise":16,"exif-parser":18,"file-type":27,"jpeg-js":36,"load-bmfont":39,mime:41,path:59,pixelmatch:60,pngjs:80,"read-chunk":83,"stream-to-buffer":95,tinycolor2:98,"url-regex":100}],2:[function(t,e,i){function n(t,e){return p.isUndefined(e)?""+e:p.isNumber(e)&&!isFinite(e)?e.toString():p.isFunction(e)||p.isRegExp(e)?e.toString():e}function r(t,e){return p.isString(t)?t.length=0;a--)if(o[a]!=s[a])return!1;for(a=o.length-1;a>=0;a--)if(r=o[a],!l(t[r],e[r]))return!1;return!0}function c(t,e){return!(!t||!e)&&("[object RegExp]"==Object.prototype.toString.call(e)?e.test(t):t instanceof e||e.call({},t)===!0)}function u(t,e,i,n){var r;p.isString(i)&&(n=i,i=null);try{e()}catch(t){r=t}if(n=(i&&i.name?" ("+i.name+").":".")+(n?" "+n:"."),t&&!r&&o(r,i,"Missing expected exception"+n),!t&&c(r,i)&&o(r,i,"Got unwanted exception"+n),t&&r&&i&&!c(r,i)||!t&&r)throw r}var p=t("util/"),d=Array.prototype.slice,m=Object.prototype.hasOwnProperty,g=e.exports=s;g.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=a(this),this.generatedMessage=!0);var e=t.stackStartFunction||o;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var i=new Error;if(i.stack){var n=i.stack,r=e.name,s=n.indexOf("\n"+r);if(s>=0){var l=n.indexOf("\n",s+1);n=n.substring(l+1)}this.stack=n}}},p.inherits(g.AssertionError,Error),g.fail=o,g.ok=s,g.equal=function(t,e,i){t!=e&&o(t,e,i,"==",g.equal)},g.notEqual=function(t,e,i){t==e&&o(t,e,i,"!=",g.notEqual)},g.deepEqual=function(t,e,i){l(t,e)||o(t,e,i,"deepEqual",g.deepEqual)},g.notDeepEqual=function(t,e,i){l(t,e)&&o(t,e,i,"notDeepEqual",g.notDeepEqual)},g.strictEqual=function(t,e,i){t!==e&&o(t,e,i,"===",g.strictEqual)},g.notStrictEqual=function(t,e,i){t===e&&o(t,e,i,"!==",g.notStrictEqual)},g.throws=function(t,e,i){u.apply(this,[!0].concat(d.call(arguments)))},g.doesNotThrow=function(t,e){u.apply(this,[!1].concat(d.call(arguments)))},g.ifError=function(t){if(t)throw t};var b=Object.keys||function(t){var e=[];for(var i in t)m.call(t,i)&&e.push(i);return e}},{"util/":103}],3:[function(t,e,i){"use strict";function n(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,i=t.length;e0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===t[s-2]?2:"="===t[s-1]?1:0,o=new f(3*s/4-a),n=a>0?s-4:s;var l=0;for(e=0,i=0;e>16&255,o[l++]=r>>8&255,o[l++]=255&r;return 2===a?(r=h[t.charCodeAt(e)]<<2|h[t.charCodeAt(e+1)]>>4,o[l++]=255&r):1===a&&(r=h[t.charCodeAt(e)]<<10|h[t.charCodeAt(e+1)]<<4|h[t.charCodeAt(e+2)]>>2,o[l++]=r>>8&255,o[l++]=255&r),o}function a(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function o(t,e,i){for(var n,r=[],o=e;of?f:h+s));return 1===n?(e=t[i-1],r+=l[e>>2],r+=l[e<<4&63],r+="=="):2===n&&(e=(t[i-2]<<8)+t[i-1],r+=l[e>>10],r+=l[e>>4&63],r+=l[e<<2&63],r+="="),a.push(r),a.join("")}i.toByteArray=r,i.fromByteArray=s;var l=[],h=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],4:[function(t,e,i){!function(i){"use strict";function n(t){function e(t,n){var r,a,o,s,l,h,f=this;if(!(f instanceof e))return W&&P(26,"constructor call without new",t),new e(t,n);if(null!=n&&q(n,2,64,z,"base")){if(n=0|n,h=t+"",10==n)return f=new e(t instanceof e?t:h),C(f,U+f.e+1,N);if((s="number"==typeof t)&&0*t!=0||!new RegExp("^-?"+(r="["+x.slice(0,n)+"]+")+"(?:\\."+r+")?$",n<37?"i":"").test(h))return m(f,h,s,n);s?(f.s=1/t<0?(h=h.slice(1),-1):1,W&&h.replace(/^0\.0*|\./,"").length>15&&P(z,y,t),s=!1):f.s=45===h.charCodeAt(0)?(h=h.slice(1),-1):1,h=i(h,10,n,f.s)}else{if(t instanceof e)return f.s=t.s,f.e=t.e,f.c=(t=t.c)?t.slice():t,void(z=0);if((s="number"==typeof t)&&0*t==0){if(f.s=1/t<0?(t=-t,-1):1,t===~~t){for(a=0,o=t;o>=10;o/=10,a++);return f.e=a,f.c=[t],void(z=0)}h=t+""}else{if(!g.test(h=t+""))return m(f,h,s);f.s=45===h.charCodeAt(0)?(h=h.slice(1),-1):1}}for((a=h.indexOf("."))>-1&&(h=h.replace(".","")),(o=h.search(/e/i))>0?(a<0&&(a=o),a+=+h.slice(o+1),h=h.substring(0,o)):a<0&&(a=h.length),o=0;48===h.charCodeAt(o);o++);for(l=h.length;48===h.charCodeAt(--l););if(h=h.slice(o,l+1))if(l=h.length,s&&W&&l>15&&(t>S||t!==v(t))&&P(z,y,f.s*t),a=a-o-1,a>G)f.c=f.e=null;else if(a=0&&(l=X,X=0,t=t.replace(".",""),d=new e(n),u=d.pow(t.length-m),X=l,d.c=h(c(a(u.c),u.e),10,i),d.e=d.c.length),p=h(t,n,i),s=l=p.length;0==p[--l];p.pop());if(!p[0])return"0";if(m<0?--s:(u.c=p,u.e=s,u.s=r,u=B(u,d,g,b,i),p=u.c,f=u.r,s=u.e),o=s+g+1,m=p[o],l=i/2,f=f||o<0||null!=p[o+1],f=b<4?(null!=m||f)&&(0==b||b==(u.s<0?3:2)):m>l||m==l&&(4==b||f||6==b&&1&p[o-1]||b==(u.s<0?8:7)),o<1||!p[0])t=f?c("1",-g):"0";else{if(p.length=o,f)for(--i;++p[--o]>i;)p[o]=0,o||(++s,p.unshift(1));for(l=p.length;!p[--l];);for(m=0,t="";m<=l;t+=x.charAt(p[m++]));t=c(t,s)}return t}function p(t,i,n,r){var o,s,l,h,u;if(n=null!=n&&q(n,0,8,r,_)?0|n:N,!t.c)return t.toString();if(o=t.c[0],l=t.e,null==i)u=a(t.c),u=19==r||24==r&&l<=F?f(u,l):c(u,l);else if(t=C(new e(t),i,n),s=t.e,u=a(t.c),h=u.length,19==r||24==r&&(i<=s||s<=F)){for(;hh){if(--i>0)for(u+=".";i--;u+="0");}else if(i+=s-h,i>0)for(s+1==h&&(u+=".");i--;u+="0");return t.s<0&&o?"-"+u:u}function T(t,i){var n,r,a=0;for(l(t[0])&&(t=t[0]),n=new e(t[0]);++ai||t!=u(t))&&P(n,(r||"decimal places")+(ti?" out of range":" not an integer"),t),!0}function L(t,e,i){for(var n=1,r=e.length;!e[--r];e.pop());for(r=e[0];r>=10;r/=10,n++);return(i=n+i*E-1)>G?t.c=t.e=null:i=10;s/=10,r++);if(a=e-r,a<0)a+=E,o=e,l=c[h=0],f=l/u[r-o-1]%10|0;else if(h=b((a+1)/E),h>=c.length){if(!n)break t;for(;c.length<=h;c.push(0));l=f=0,r=1,a%=E,o=a-E+1}else{for(l=s=c[h],r=1;s>=10;s/=10,r++);a%=E,o=a-E+r,f=o<0?0:l/u[r-o-1]%10|0}if(n=n||e<0||null!=c[h+1]||(o<0?l:l%u[r-o-1]),n=i<4?(f||n)&&(0==i||i==(t.s<0?3:2)):f>5||5==f&&(4==i||n||6==i&&(a>0?o>0?l/u[r-o]:0:c[h-1])%10&1||i==(t.s<0?8:7)),e<1||!c[0])return c.length=0,n?(e-=t.e+1,c[0]=u[(E-e%E)%E],t.e=-e||0):c[0]=t.e=0,t;if(0==a?(c.length=h,s=1,h--):(c.length=h+1,s=u[E-a],c[h]=o>0?v(l/u[r-o]%u[o])*s:0),n)for(;;){if(0==h){for(a=1,o=c[0];o>=10;o/=10,a++);for(o=c[0]+=s,s=1;o>=10;o/=10,s++);a!=s&&(t.e++,c[0]==k&&(c[0]=1));break}if(c[h]+=s,c[h]!=k)break;c[h--]=0,s=1}for(a=c.length;0===c[--a];c.pop());}t.e>G?t.c=t.e=null:t.ei)return null!=(t=r[i++])};return o(e="DECIMAL_PLACES")&&q(t,0,A,2,e)&&(U=0|t),n[e]=U,o(e="ROUNDING_MODE")&&q(t,0,8,2,e)&&(N=0|t),n[e]=N,o(e="EXPONENTIAL_AT")&&(l(t)?q(t[0],-A,0,2,e)&&q(t[1],0,A,2,e)&&(F=0|t[0],j=0|t[1]):q(t,-A,A,2,e)&&(F=-(j=0|(t<0?-t:t)))),n[e]=[F,j],o(e="RANGE")&&(l(t)?q(t[0],-A,-1,2,e)&&q(t[1],1,A,2,e)&&(H=0|t[0],G=0|t[1]):q(t,-A,A,2,e)&&(0|t?H=-(G=0|(t<0?-t:t)):W&&P(2,e+" cannot be zero",t))),n[e]=[H,G],o(e="ERRORS")&&(t===!!t||1===t||0===t?(z=0,q=(W=!!t)?R:s):W&&P(2,e+w,t)),n[e]=W,o(e="CRYPTO")&&(t===!!t||1===t||0===t?(Z=!(!t||!d),t&&!Z&&W&&P(2,"crypto unavailable",d)):W&&P(2,e+w,t)),n[e]=Z,o(e="MODULO_MODE")&&q(t,0,9,2,e)&&(Y=0|t),n[e]=Y,o(e="POW_PRECISION")&&q(t,0,A,2,e)&&(X=0|t),n[e]=X,o(e="FORMAT")&&("object"==("undefined"==typeof t?"undefined":_typeof(t))?V=t:W&&P(2,e+" not an object",t)),n[e]=V,n},e.max=function(){return T(arguments,O.lt)},e.min=function(){return T(arguments,O.gt)},e.random=function(){var t=9007199254740992,i=Math.random()*t&2097151?function(){return v(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var n,r,a,o,s,l=0,h=[],f=new e(D);if(t=null!=t&&q(t,0,A,14)?0|t:U,o=b(t/E),Z)if(d&&d.getRandomValues){for(n=d.getRandomValues(new Uint32Array(o*=2));l>>11),s>=9e15?(r=d.getRandomValues(new Uint32Array(2)),n[l]=r[0],n[l+1]=r[1]):(h.push(s%1e14),l+=2);l=o/2}else if(d&&d.randomBytes){for(n=d.randomBytes(o*=7);l=9e15?d.randomBytes(7).copy(n,l):(h.push(s%1e14),l+=7);l=o/7}else W&&P(14,"crypto unavailable",d);if(!l)for(;l=10;s/=10,l++);ln?1:-1;else for(r=a=0;re[r]?1:-1;break}return a}function n(t,e,i,n){for(var r=0;i--;)t[i]-=r,r=t[i]1;t.shift());}return function(a,o,s,l,h){var f,c,u,p,d,m,g,b,w,_,y,x,S,I,M,A,T,R=a.s==o.s?1:-1,L=a.c,P=o.c;if(!(L&&L[0]&&P&&P[0]))return new e(a.s&&o.s&&(L?!P||L[0]!=P[0]:P)?L&&0==L[0]||!P?0*R:R/0:NaN);for(b=new e(R),w=b.c=[],c=a.e-o.e,R=s+c+1,h||(h=k,c=r(a.e/E)-r(o.e/E),R=R/E|0),u=0;P[u]==(L[u]||0);u++);if(P[u]>(L[u]||0)&&c--,R<0)w.push(1),p=!0;else{for(I=L.length,A=P.length,u=0,R+=2,d=v(h/(P[0]+1)),d>1&&(P=t(P,d,h),L=t(L,d,h),A=P.length,I=L.length),S=A,_=L.slice(0,A),y=_.length;y=h/2&&M++;do{if(d=0,f=i(P,_,A,y),f<0){if(x=_[0],A!=y&&(x=x*h+(_[1]||0)),d=v(x/M),d>1)for(d>=h&&(d=h-1),m=t(P,d,h),g=m.length,y=_.length;1==i(m,_,g,y);)d--,n(m,A=10;R/=10,u++);C(b,s+(b.e=u+c*E-1)+1,l,p)}else b.e=c,b.r=+p;return b}}(),m=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,i=/^([^.]+)\.$/,n=/^\.([^.]+)$/,r=/^-?(Infinity|NaN)$/,a=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(o,s,l,h){var f,c=l?s:s.replace(a,"");if(r.test(c))o.s=isNaN(c)?null:c<0?-1:1;else{if(!l&&(c=c.replace(t,function(t,e,i){return f="x"==(i=i.toLowerCase())?16:"b"==i?2:8,h&&h!=f?t:e}),h&&(f=h,c=c.replace(i,"$1").replace(n,"0.$1")),s!=c))return new e(c,f);W&&P(z,"not a"+(h?" base "+h:"")+" number",s),o.s=null}o.c=o.e=null,z=0}}(),O.absoluteValue=O.abs=function(){var t=new e(this);return t.s<0&&(t.s=1),t},O.ceil=function(){return C(new e(this),this.e+1,2)},O.comparedTo=O.cmp=function(t,i){return z=1,o(this,new e(t,i))},O.decimalPlaces=O.dp=function(){var t,e,i=this.c;if(!i)return null;if(t=((e=i.length-1)-r(this.e/E))*E,e=i[e])for(;e%10==0;e/=10,t--);return t<0&&(t=0),t},O.dividedBy=O.div=function(t,i){return z=3,B(this,new e(t,i),U,N)},O.dividedToIntegerBy=O.divToInt=function(t,i){return z=4,B(this,new e(t,i),0,1)},O.equals=O.eq=function(t,i){return z=5,0===o(this,new e(t,i))},O.floor=function(){return C(new e(this),this.e+1,3)},O.greaterThan=O.gt=function(t,i){return z=6,o(this,new e(t,i))>0},O.greaterThanOrEqualTo=O.gte=function(t,i){return z=7,1===(i=o(this,new e(t,i)))||0===i},O.isFinite=function(){return!!this.c},O.isInteger=O.isInt=function(){return!!this.c&&r(this.e/E)>this.c.length-2},O.isNaN=function(){return!this.s},O.isNegative=O.isNeg=function(){return this.s<0},O.isZero=function(){return!!this.c&&0==this.c[0]},O.lessThan=O.lt=function(t,i){return z=8,o(this,new e(t,i))<0},O.lessThanOrEqualTo=O.lte=function(t,i){return z=9,(i=o(this,new e(t,i)))===-1||0===i},O.minus=O.sub=function(t,i){var n,a,o,s,l=this,h=l.s;if(z=10,t=new e(t,i),i=t.s,!h||!i)return new e(NaN);if(h!=i)return t.s=-i,l.plus(t);var f=l.e/E,c=t.e/E,u=l.c,p=t.c;if(!f||!c){if(!u||!p)return u?(t.s=-i,t):new e(p?l:NaN);if(!u[0]||!p[0])return p[0]?(t.s=-i,t):new e(u[0]?l:3==N?-0:0)}if(f=r(f),c=r(c),u=u.slice(),h=f-c){for((s=h<0)?(h=-h,o=u):(c=f,o=p),o.reverse(),i=h;i--;o.push(0));o.reverse()}else for(a=(s=(h=u.length)<(i=p.length))?h:i,h=i=0;i0)for(;i--;u[n++]=0);for(i=k-1;a>h;){if(u[--a]0?(l=s,n=f):(o=-o,n=h),n.reverse();o--;n.push(0));n.reverse()}for(o=h.length,i=f.length,o-i<0&&(n=f,f=h,h=n,i=o),o=0;i;)o=(h[--i]=h[i]+f[i]+o)/k|0,h[i]%=k;return o&&(h.unshift(o),++l),L(t,h,l)},O.precision=O.sd=function(t){var e,i,n=this,r=n.c;if(null!=t&&t!==!!t&&1!==t&&0!==t&&(W&&P(13,"argument"+w,t),t!=!!t&&(t=null)),!r)return null;if(i=r.length-1,e=i*E+1,i=r[i]){for(;i%10==0;i/=10,e--);for(i=r[0];i>=10;i/=10,e++);}return t&&n.e+1>e&&(e=n.e+1),e},O.round=function(t,i){var n=new e(this);return(null==t||q(t,0,A,15))&&C(n,~~t+this.e+1,null!=i&&q(i,0,8,15,_)?0|i:N),n},O.shift=function(t){var i=this;return q(t,-S,S,16,"argument")?i.times("1e"+u(t)):new e(i.c&&i.c[0]&&(t<-S||t>S)?i.s*(t<0?0:1/0):i)},O.squareRoot=O.sqrt=function(){var t,i,n,o,s,l=this,h=l.c,f=l.s,c=l.e,u=U+4,p=new e("0.5");if(1!==f||!h||!h[0])return new e(!f||f<0&&(!h||h[0])?NaN:h?l:1/0);if(f=Math.sqrt(+l),0==f||f==1/0?(i=a(h),(i.length+c)%2==0&&(i+="0"),f=Math.sqrt(i),c=r((c+1)/2)-(c<0||c%2),f==1/0?i="1e"+c:(i=f.toExponential(),i=i.slice(0,i.indexOf("e")+1)+c),n=new e(i)):n=new e(f+""),n.c[0])for(c=n.e,f=c+u,f<3&&(f=0);;)if(s=n,n=p.times(s.plus(B(l,s,u,1))),a(s.c).slice(0,f)===(i=a(n.c)).slice(0,f)){if(n.e=0;){for(n=0,d=y[o]%v,m=y[o]/v|0,l=f,s=o+l;s>o;)c=_[--l]%v,u=_[l]/v|0,h=m*c+u*d,c=d*c+h%v*v+g[s]+n,n=(c/b|0)+(h/v|0)+m*u,g[s--]=c%b;g[s]=n}return n?++a:g.shift(),L(t,g,a)},O.toDigits=function(t,i){var n=new e(this);return t=null!=t&&q(t,1,A,18,"precision")?0|t:null,i=null!=i&&q(i,0,8,18,_)?0|i:N,t?C(n,t,i):n},O.toExponential=function(t,e){return p(this,null!=t&&q(t,0,A,19)?~~t+1:null,e,19)},O.toFixed=function(t,e){return p(this,null!=t&&q(t,0,A,20)?~~t+this.e+1:null,e,20)},O.toFormat=function(t,e){var i=p(this,null!=t&&q(t,0,A,21)?~~t+this.e+1:null,e,21);if(this.c){var n,r=i.split("."),a=+V.groupSize,o=+V.secondaryGroupSize,s=V.groupSeparator,l=r[0],h=r[1],f=this.s<0,c=f?l.slice(1):l,u=c.length;if(o&&(n=a,a=o,o=n,u-=n),a>0&&u>0){for(n=u%a||a,l=c.substr(0,n);n0&&(l+=s+c.slice(n)),f&&(l="-"+l)}i=h?l+V.decimalSeparator+((o=+V.fractionGroupSize)?h.replace(new RegExp("\\d{"+o+"}\\B","g"),"$&"+V.fractionGroupSeparator):h):l}return i},O.toFraction=function(t){var i,n,r,o,s,l,h,f,c,u=W,p=this,d=p.c,m=new e(D),g=n=new e(D),b=h=new e(D);if(null!=t&&(W=!1,l=new e(t),W=u,(u=l.isInt())&&!l.lt(D)||(W&&P(22,"max denominator "+(u?"out of range":"not an integer"),t),t=!u&&l.c&&C(l,l.e+1,1).gte(D)?l:null)),!d)return p.toString();for(c=a(d),o=m.e=c.length-p.e-1,m.c[0]=I[(s=o%E)<0?E+s:s],t=!t||l.cmp(m)>0?o>0?m:g:l,s=G,G=1/0,l=new e(c),h.c[0]=0;f=B(l,m,0,1),r=n.plus(f.times(b)),1!=r.cmp(t);)n=b,b=r,g=h.plus(f.times(r=g)),h=r,m=l.minus(f.times(r=m)),l=r;return r=B(t.minus(n),b,0,1),h=h.plus(r.times(g)),n=n.plus(r.times(b)),h.s=g.s=p.s,o*=2,i=B(g,b,o,N).minus(p).abs().cmp(B(h,n,o,N).minus(p).abs())<1?[g.toString(),b.toString()]:[h.toString(),n.toString()],G=s,i},O.toNumber=function(){return+this},O.toPower=O.pow=function(t,i){var n,r,a,o=v(t<0?-t:+t),s=this;if(null!=i&&(z=23,i=new e(i)),!q(t,-S,S,23,"exponent")&&(!isFinite(t)||o>S&&(t/=0)||parseFloat(t)!=t&&!(t=NaN))||0==t)return n=Math.pow(+s,t),new e(i?n%i:n);for(i?t>1&&s.gt(D)&&s.isInt()&&i.gt(D)&&i.isInt()?s=s.mod(i):(a=i,i=null):X&&(n=b(X/E+2)),r=new e(D);;){if(o%2){if(r=r.times(s),!r.c)break;n?r.c.length>n&&(r.c.length=n):i&&(r=r.mod(i))}if(o=v(o/2),!o)break;s=s.times(s),n?s.c&&s.c.length>n&&(s.c.length=n):i&&(s=s.mod(i))}return i?r:(t<0&&(r=D.div(r)),a?r.mod(a):n?C(r,X,N):r)},O.toPrecision=function(t,e){return p(this,null!=t&&q(t,1,A,24,"precision")?0|t:null,e,24)},O.toString=function(t){var e,n=this,r=n.s,o=n.e;return null===o?r?(e="Infinity",r<0&&(e="-"+e)):e="NaN":(e=a(n.c),e=null!=t&&q(t,2,64,25,"base")?i(c(e,o),0|t,10,r):o<=F||o>=j?f(e,o):c(e,o),r<0&&n.c[0]&&(e="-"+e)),e},O.truncated=O.trunc=function(){return C(new e(this),this.e+1,1)},O.valueOf=O.toJSON=function(){var t,e=this,i=e.e;return null===i?e.toString():(t=a(e.c),t=i<=F||i>=j?f(t,i):c(t,i),e.s<0?"-"+t:t)},null!=t&&e.config(t),e}function r(t){var e=0|t;return t>0||t===e?e:e-1}function a(t){for(var e,i,n=1,r=t.length,a=t[0]+"";nh^i?1:-1;for(s=(l=r.length)<(h=a.length)?l:h,o=0;oa[o]^i?1:-1;return l==h?0:l>h^i?1:-1}function s(t,e,i){return(t=u(t))>=e&&t<=i}function l(t){return"[object Array]"==Object.prototype.toString.call(t)}function h(t,e,i){for(var n,r,a=[0],o=0,s=t.length;oi-1&&(null==a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/i|0,a[n]%=i)}return a.reverse()}function f(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function c(t,e){var i,n;if(e<0){for(n="0.";++e;n+="0");t=n+t}else if(i=t.length,++e>i){for(n="0",e-=i;--e;n+="0");t+=n}else e=0;i--){for(var n=0;n>7-o&1];this.data[a+4*o]=s.blue,this.data[a+4*o+1]=s.green,this.data[a+4*o+2]=s.red,this.data[a+4*o+3]=255}0!=e&&(this.pos+=4-e)}},i.prototype.bit4=function(){for(var t=Math.ceil(this.width/2),e=t%4,i=this.height-1;i>=0;i--){for(var n=0;n>4,s=15&r,l=this.palette[o];if(this.data[a]=l.blue,this.data[a+1]=l.green,this.data[a+2]=l.red,this.data[a+3]=255,2*n+1>=this.width)break;l=this.palette[s],this.data[a+4]=l.blue,this.data[a+4+1]=l.green,this.data[a+4+2]=l.red,this.data[a+4+3]=255}0!=e&&(this.pos+=4-e)}},i.prototype.bit8=function(){for(var t=this.width%4,e=this.height-1;e>=0;e--){for(var i=0;i=0;t--){for(var e=0;e=0;r--){for(var a=0;a0){var s=this.pos+r*n+3*this.width;e.fill(0,s,s+this.extraBytes)}}return e},e.exports=encode=function(t,e){"undefined"==typeof e&&(e=100);var n=new i(t),r=n.encode();return{data:r,width:t.width,height:t.height}}}).call(this,t("buffer").Buffer)},{buffer:14}],8:[function(t,e,i){},{}],9:[function(t,e,i){(function(e,n){function r(t){if(ti.UNZIP)throw new TypeError("Bad argument");this.mode=t,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function a(t,e){for(var i=0;ii.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+t.chunkSize);if(t.windowBits&&(t.windowBitsi.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+t.windowBits);if(t.level&&(t.leveli.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+t.level);if(t.memLevel&&(t.memLeveli.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+t.memLevel);if(t.strategy&&t.strategy!=i.Z_FILTERED&&t.strategy!=i.Z_HUFFMAN_ONLY&&t.strategy!=i.Z_RLE&&t.strategy!=i.Z_FIXED&&t.strategy!=i.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+t.strategy);if(t.dictionary&&!n.isBuffer(t.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new m.Zlib(e);var r=this;this._hadError=!1,this._binding.onerror=function(t,e){r._binding=null,r._hadError=!0;var n=new Error(t);n.errno=e,n.code=i.codes[e],r.emit("error",n)};var a=i.Z_DEFAULT_COMPRESSION;"number"==typeof t.level&&(a=t.level);var o=i.Z_DEFAULT_STRATEGY;"number"==typeof t.strategy&&(o=t.strategy),this._binding.init(t.windowBits||i.Z_DEFAULT_WINDOWBITS,a,t.memLevel||i.Z_DEFAULT_MEMLEVEL,o,t.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 d=t("_stream_transform"),m=t("./binding"),g=t("util"),b=t("assert").ok;m.Z_MIN_WINDOWBITS=8,m.Z_MAX_WINDOWBITS=15,m.Z_DEFAULT_WINDOWBITS=15,m.Z_MIN_CHUNK=64,m.Z_MAX_CHUNK=1/0,m.Z_DEFAULT_CHUNK=16384,m.Z_MIN_MEMLEVEL=1,m.Z_MAX_MEMLEVEL=9,m.Z_DEFAULT_MEMLEVEL=8,m.Z_MIN_LEVEL=-1,m.Z_MAX_LEVEL=9,m.Z_DEFAULT_LEVEL=m.Z_DEFAULT_COMPRESSION,Object.keys(m).forEach(function(t){t.match(/^Z/)&&(i[t]=m[t])}),i.codes={Z_OK:m.Z_OK,Z_STREAM_END:m.Z_STREAM_END,Z_NEED_DICT:m.Z_NEED_DICT,Z_ERRNO:m.Z_ERRNO,Z_STREAM_ERROR:m.Z_STREAM_ERROR,Z_DATA_ERROR:m.Z_DATA_ERROR,Z_MEM_ERROR:m.Z_MEM_ERROR,Z_BUF_ERROR:m.Z_BUF_ERROR,Z_VERSION_ERROR:m.Z_VERSION_ERROR},Object.keys(i.codes).forEach(function(t){i.codes[i.codes[t]]=t}),i.Deflate=o,i.Inflate=s,i.Gzip=l,i.Gunzip=h,i.DeflateRaw=f,i.InflateRaw=c,i.Unzip=u,i.createDeflate=function(t){return new o(t)},i.createInflate=function(t){return new s(t)},i.createDeflateRaw=function(t){return new f(t)},i.createInflateRaw=function(t){return new c(t)},i.createGzip=function(t){return new l(t)},i.createGunzip=function(t){return new h(t)},i.createUnzip=function(t){return new u(t)},i.deflate=function(t,e,i){return"function"==typeof e&&(i=e,e={}),r(new o(e),t,i)},i.deflateSync=function(t,e){return a(new o(e),t)},i.gzip=function(t,e,i){return"function"==typeof e&&(i=e,e={}),r(new l(e),t,i)},i.gzipSync=function(t,e){return a(new l(e),t)},i.deflateRaw=function(t,e,i){return"function"==typeof e&&(i=e,e={}),r(new f(e),t,i)},i.deflateRawSync=function(t,e){return a(new f(e),t)},i.unzip=function(t,e,i){return"function"==typeof e&&(i=e,e={}),r(new u(e),t,i)},i.unzipSync=function(t,e){return a(new u(e),t)},i.inflate=function(t,e,i){return"function"==typeof e&&(i=e,e={}),r(new s(e),t,i)},i.inflateSync=function(t,e){return a(new s(e),t)},i.gunzip=function(t,e,i){return"function"==typeof e&&(i=e,e={}),r(new h(e),t,i)},i.gunzipSync=function(t,e){return a(new h(e),t)},i.inflateRaw=function(t,e,i){return"function"==typeof e&&(i=e,e={}),r(new c(e),t,i)},i.inflateRawSync=function(t,e){return a(new c(e),t)},g.inherits(p,d),p.prototype.params=function(t,n,r){if(ti.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+t);if(n!=i.Z_FILTERED&&n!=i.Z_HUFFMAN_ONLY&&n!=i.Z_RLE&&n!=i.Z_FIXED&&n!=i.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+n);if(this._level!==t||this._strategy!==n){var a=this;this.flush(m.Z_SYNC_FLUSH,function(){a._binding.params(t,n),a._hadError||(a._level=t,a._strategy=n,r&&r())})}else e.nextTick(r)},p.prototype.reset=function(){return this._binding.reset()},p.prototype._flush=function(t){this._transform(new n(0),"",t)},p.prototype.flush=function(t,i){var r=this._writableState;if(("function"==typeof t||void 0===t&&!i)&&(i=t,t=m.Z_FULL_FLUSH),r.ended)i&&e.nextTick(i);else if(r.ending)i&&this.once("end",i);else if(r.needDrain){var a=this;this.once("drain",function(){a.flush(i)})}else this._flushFlag=t,this.write(new n(0),"",i)},p.prototype.close=function(t){if(t&&e.nextTick(t),!this._closed){this._closed=!0,this._binding.close();var i=this;e.nextTick(function(){i.emit("close")})}},p.prototype._transform=function(t,e,i){var r,a=this._writableState,o=a.ending||a.ended,s=o&&(!t||a.length===t.length);if(null===!t&&!n.isBuffer(t))return i(new Error("invalid input"));s?r=m.Z_FINISH:(r=this._flushFlag,t.length>=a.length&&(this._flushFlag=this._opts.flush||m.Z_NO_FLUSH));this._processChunk(t,r,i)},p.prototype._processChunk=function(t,e,i){function r(f,p){if(!l._hadError){var d=o-p;if(b(d>=0,"have should not go down"),d>0){var m=l._buffer.slice(l._offset,l._offset+d);l._offset+=d,h?l.push(m):(c.push(m),u+=m.length)}if((0===p||l._offset>=l._chunkSize)&&(o=l._chunkSize,l._offset=0,l._buffer=new n(l._chunkSize)),0===p){if(s+=a-f,a=f,!h)return!0;var g=l._binding.write(e,t,s,a,l._buffer,l._offset,l._chunkSize);return g.callback=r,void(g.buffer=t)}return!!h&&void i()}}var a=t&&t.length,o=this._chunkSize-this._offset,s=0,l=this,h="function"==typeof i;if(!h){var f,c=[],u=0;this.on("error",function(t){f=t});do var p=this._binding.writeSync(e,t,s,a,this._buffer,this._offset,o);while(!this._hadError&&r(p[0],p[1]));if(this._hadError)throw f;var d=n.concat(c,u);return this.close(),d}var m=this._binding.write(e,t,s,a,this._buffer,this._offset,o);m.buffer=t,m.callback=r},g.inherits(o,p),g.inherits(s,p),g.inherits(l,p),g.inherits(h,p),g.inherits(f,p),g.inherits(c,p),g.inherits(u,p)}).call(this,t("_process"),t("buffer").Buffer)},{"./binding":9,_process:12,_stream_transform:92,assert:2,buffer:14,util:103}],11:[function(t,e,i){arguments[4][8][0].apply(i,arguments)},{dup:8}],12:[function(t,e,i){function n(t){if(h===setTimeout)return setTimeout(t,0);try{return h(t,0)}catch(e){try{return h.call(null,t,0)}catch(e){return h.call(this,t,0)}}}function r(t){if(f===clearTimeout)return clearTimeout(t);try{return f(t)}catch(e){try{return f.call(null,t)}catch(e){return f.call(this,t)}}}function a(){d&&u&&(d=!1,u.length?p=u.concat(p):m=-1,p.length&&o())}function o(){if(!d){var t=n(a);d=!0;for(var e=p.length;e;){for(u=p,p=[];++m1)for(var i=1;i=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|t}function g(t){return+t!=t&&(t=0),o.alloc(+t)}function b(t,e){if(o.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return X(t).length;default:if(n)return q(t).length;e=(""+e).toLowerCase(),n=!0}}function v(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if(i>>>=0,e>>>=0,i<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,i);case"utf8":case"utf-8":return T(this,e,i);case"ascii":return L(this,e,i);case"latin1":case"binary":return P(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function w(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function _(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=o.from(e,n)),o.isBuffer(e))return 0===e.length?-1:y(t,e,i,n,r);if("number"==typeof e)return e=255&e,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):y(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function y(t,e,i,n,r){function a(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}var o=1,s=t.length,l=e.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,s/=2,l/=2,i/=2}var h;if(r){var f=-1;for(h=i;hs&&(i=s-l),h=i;h>=0;h--){for(var c=!0,u=0;ur&&(n=r)):n=r;var a=e.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(r+s<=i){var l,h,f,c;switch(s){case 1:a<128&&(o=a);break;case 2:l=t[r+1],128===(192&l)&&(c=(31&a)<<6|63&l,c>127&&(o=c));break;case 3:l=t[r+1],h=t[r+2],128===(192&l)&&128===(192&h)&&(c=(15&a)<<12|(63&l)<<6|63&h,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:l=t[r+1],h=t[r+2],f=t[r+3],128===(192&l)&&128===(192&h)&&128===(192&f)&&(c=(15&a)<<18|(63&l)<<12|(63&h)<<6|63&f,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),r+=s}return R(n)}function R(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var i="",n=0;nn)&&(i=n);for(var r="",a=e;ai)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,i,n,r,a){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function D(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,a=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function U(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,a=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function N(t,e,i,n,r,a){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function F(t,e,i,n,r){return r||N(t,e,i,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,e,i,n,23,4),i+4}function j(t,e,i,n,r){return r||N(t,e,i,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,e,i,n,52,8),i+8}function H(t){if(t=G(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function G(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function W(t){return t<16?"0"+t.toString(16):t.toString(16)}function q(t,e){e=e||1/0;for(var i,n=t.length,r=null,a=[],o=0;o55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&a.push(239,191,189),r=i;continue}i=(r-55296<<10|i-56320)+65536}else r&&(e-=3)>-1&&a.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;a.push(i)}else if(i<2048){if((e-=2)<0)break;a.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;a.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return a}function Z(t){for(var e=[],i=0;i>8,r=i%256,a.push(r),a.push(n);return a}function X(t){return $.toByteArray(H(t))}function V(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}function J(t){return t!==t}var $=t("base64-js"),K=t("ieee754"),Q=t("isarray");i.Buffer=o,i.SlowBuffer=g,i.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),i.kMaxLength=r(),o.poolSize=8192,o._augment=function(t){return t.__proto__=o.prototype,t},o.from=function(t,e,i){return s(null,t,e,i)},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(t,e,i){return h(null,t,e,i)},o.allocUnsafe=function(t){return f(null,t)},o.allocUnsafeSlow=function(t){return f(null,t)},o.isBuffer=function(t){return!(null==t||!t._isBuffer)},o.compare=function(t,e){if(!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var i=t.length,n=e.length,r=0,a=Math.min(i,n);r0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},o.prototype.compare=function(t,e,i,n,r){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(e>>>=0,i>>>=0,n>>>=0,r>>>=0,this===t)return 0;for(var a=r-n,s=i-e,l=Math.min(a,s),h=this.slice(n,r),f=t.slice(e,i),c=0;cr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return x(this,t,e,i);case"utf8":case"utf-8":return k(this,t,e,i);case"ascii":return E(this,t,e,i);case"latin1":case"binary":return S(this,t,e,i);case"base64":return I(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,e,i);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 tt=4096;o.prototype.slice=function(t,e){var i=this.length;t=~~t,e=void 0===e?i:~~e,t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),e0&&(r*=256);)n+=this[t+--e]*r;return n},o.prototype.readUInt8=function(t,e){return e||z(t,1,this.length),this[t]},o.prototype.readUInt16LE=function(t,e){return e||z(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUInt16BE=function(t,e){return e||z(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUInt32LE=function(t,e){return e||z(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUInt32BE=function(t,e){return e||z(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,e,i){t=0|t,e=0|e,i||z(t,e,this.length);for(var n=this[t],r=1,a=0;++a=r&&(n-=Math.pow(2,8*e)),n},o.prototype.readIntBE=function(t,e,i){t=0|t,e=0|e,i||z(t,e,this.length);for(var n=e,r=1,a=this[t+--n];n>0&&(r*=256);)a+=this[t+--n]*r;return r*=128,a>=r&&(a-=Math.pow(2,8*e)),a},o.prototype.readInt8=function(t,e){return e||z(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,e){e||z(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},o.prototype.readInt16BE=function(t,e){e||z(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},o.prototype.readInt32LE=function(t,e){return e||z(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return e||z(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,e){return e||z(t,4,this.length),K.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return e||z(t,4,this.length),K.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return e||z(t,8,this.length),K.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return e||z(t,8,this.length),K.read(this,t,!1,52,8)},o.prototype.writeUIntLE=function(t,e,i,n){if(t=+t,e=0|e,i=0|i,!n){var r=Math.pow(2,8*i)-1;O(this,t,e,i,r,0)}var a=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+a]=t/o&255;return e+i},o.prototype.writeUInt8=function(t,e,i){return t=+t,e=0|e,i||O(this,t,e,1,255,0),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},o.prototype.writeUInt16LE=function(t,e,i){return t=+t,e=0|e,i||O(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):D(this,t,e,!0),e+2},o.prototype.writeUInt16BE=function(t,e,i){return t=+t,e=0|e,i||O(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):D(this,t,e,!1),e+2},o.prototype.writeUInt32LE=function(t,e,i){return t=+t,e=0|e,i||O(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):U(this,t,e,!0),e+4},o.prototype.writeUInt32BE=function(t,e,i){return t=+t,e=0|e,i||O(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):U(this,t,e,!1),e+4},o.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e=0|e,!n){var r=Math.pow(2,8*i-1);O(this,t,e,i,r-1,-r)}var a=0,o=1,s=0;for(this[e]=255&t;++a>0)-s&255;return e+i},o.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e=0|e,!n){var r=Math.pow(2,8*i-1);O(this,t,e,i,r-1,-r)}var a=i-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)t<0&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+i},o.prototype.writeInt8=function(t,e,i){return t=+t,e=0|e,i||O(this,t,e,1,127,-128),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,i){return t=+t,e=0|e,i||O(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):D(this,t,e,!0),e+2},o.prototype.writeInt16BE=function(t,e,i){return t=+t,e=0|e,i||O(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):D(this,t,e,!1),e+2},o.prototype.writeInt32LE=function(t,e,i){return t=+t,e=0|e,i||O(this,t,e,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):U(this,t,e,!0),e+4},o.prototype.writeInt32BE=function(t,e,i){return t=+t,e=0|e,i||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):U(this,t,e,!1),e+4},o.prototype.writeFloatLE=function(t,e,i){return F(this,t,e,!0,i)},o.prototype.writeFloatBE=function(t,e,i){return F(this,t,e,!1,i)},o.prototype.writeDoubleLE=function(t,e,i){return j(this,t,e,!0,i)},o.prototype.writeDoubleBE=function(t,e,i){return j(this,t,e,!1,i)},o.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=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),t.length-e=0;--r)t[r+e]=this[r+i];else if(a<1e3||!o.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0);var a;if("number"==typeof t)for(a=e;a0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function i(){this.removeListener(t,i),n||(n=!0,e.apply(this,arguments))}if(!r(e))throw TypeError("listener must be a function");var n=!1;return i.listener=e,this.on(t,i),this},n.prototype.removeListener=function(t,e){var i,n,a,s;if(!r(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(i=this._events[t],a=i.length,n=-1,i===e||r(i.listener)&&i.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(i)){for(s=a;s-- >0;)if(i[s]===e||i[s].listener&&i[s].listener===e){n=s;break}if(n<0)return this;1===i.length?(i.length=0,delete this._events[t]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[t],r(i))this.removeListener(t,i);else if(i)for(;i.length;)this.removeListener(t,i[i.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?r(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(r(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],18:[function(t,e,i){function n(){return this}var r=t("./lib/parser");e.exports={create:function(e,i){if(i=i||n(),e instanceof i.ArrayBuffer){var a=t("./lib/dom-bufferstream");return new r(new a(e,0,e.byteLength,(!0),i))}var o=t("./lib/bufferstream");return new r(new o(e,0,e.length,(!0)))}}},{"./lib/bufferstream":19,"./lib/dom-bufferstream":21,"./lib/parser":25}],19:[function(t,e,i){function n(t,e,i,n){this.buffer=t,this.offset=e||0,i="number"==typeof i?i:t.length,this.endPosition=this.offset+i,this.setBigEndian(n)}n.prototype={setBigEndian:function(t){this.bigEndian=!!t},nextUInt8:function(){var t=this.buffer.readUInt8(this.offset);return this.offset+=1,t},nextInt8:function(){var t=this.buffer.readInt8(this.offset);return this.offset+=1,t},nextUInt16:function(){var t=this.bigEndian?this.buffer.readUInt16BE(this.offset):this.buffer.readUInt16LE(this.offset);return this.offset+=2,t},nextUInt32:function(){var t=this.bigEndian?this.buffer.readUInt32BE(this.offset):this.buffer.readUInt32LE(this.offset);return this.offset+=4,t},nextInt16:function(){var t=this.bigEndian?this.buffer.readInt16BE(this.offset):this.buffer.readInt16LE(this.offset);return this.offset+=2,t},nextInt32:function(){var t=this.bigEndian?this.buffer.readInt32BE(this.offset):this.buffer.readInt32LE(this.offset);return this.offset+=4,t},nextFloat:function(){var t=this.bigEndian?this.buffer.readFloatBE(this.offset):this.buffer.readFloatLE(this.offset);return this.offset+=4,t},nextDouble:function(){var t=this.bigEndian?this.buffer.readDoubleBE(this.offset):this.buffer.readDoubleLE(this.offset);return this.offset+=8,t},nextBuffer:function(t){var e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e},remainingLength:function(){return this.endPosition-this.offset},nextString:function(t){var e=this.buffer.toString("ascii",this.offset,this.offset+t);return this.offset+=t,e},mark:function(){var t=this;return{openWithOffset:function(e){return e=(e||0)+this.offset,new n(t.buffer,e,t.endPosition-e,t.bigEndian)},offset:this.offset}},offsetFrom:function(t){return this.offset-t.offset},skip:function(t){this.offset+=t},branch:function(t,e){return e="number"==typeof e?e:this.endPosition-(this.offset+t),new n(this.buffer,this.offset+t,e,this.bigEndian)}},e.exports=n},{}],20:[function(t,e,i){function n(t){return parseInt(t,10)}function r(t,e){t=t.map(n),e=e.map(n);var i=new Date;i.setUTCFullYear(t[0]),i.setUTCMonth(t[1]-1),i.setUTCDate(t[2]),i.setUTCHours(e[0]),i.setUTCMinutes(e[1]),i.setUTCSeconds(e[2]),i.setUTCMilliseconds(0);var r=i.getTime()/1e3;return r}function a(t){var e=t.substr(0,10).split("-"),i=t.substr(11,8).split(":"),a=t.substr(19,6),o=a.split(":").map(n),s=o[0]*l+o[1]*h,f=r(e,i);if(f-=s,"number"==typeof f&&!isNaN(f))return f}function o(t){var e=t.split(" "),i=e[0].split(":"),n=e[1].split(":"),a=r(i,n);if("number"==typeof a&&!isNaN(a))return a}function s(t){var e=19===t.length&&":"===t.charAt(4),i=25===t.length&&"T"===t.charAt(10);return i?a(t):e?o(t):void 0}var l=3600,h=60;e.exports={parseDateWithSpecFormat:o,parseDateWithTimezoneFormat:a,parseExifDate:s}},{}],21:[function(t,e,i){function n(t,e,i,n,r,a){this.global=r,e=e||0,i=i||t.byteLength-e,this.arrayBuffer=t.slice(e,e+i),this.view=new r.DataView(this.arrayBuffer,0,this.arrayBuffer.byteLength),this.setBigEndian(n),this.offset=0,this.parentOffset=(a||0)+e}n.prototype={setBigEndian:function(t){this.littleEndian=!t},nextUInt8:function(){var t=this.view.getUint8(this.offset);return this.offset+=1,t},nextInt8:function(){var t=this.view.getInt8(this.offset);return this.offset+=1,t},nextUInt16:function(){var t=this.view.getUint16(this.offset,this.littleEndian);return this.offset+=2,t},nextUInt32:function(){var t=this.view.getUint32(this.offset,this.littleEndian);return this.offset+=4,t},nextInt16:function(){var t=this.view.getInt16(this.offset,this.littleEndian);return this.offset+=2,t},nextInt32:function(){var t=this.view.getInt32(this.offset,this.littleEndian);return this.offset+=4,t},nextFloat:function(){var t=this.view.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t},nextDouble:function(){var t=this.view.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t},nextBuffer:function(t){var e=this.arrayBuffer.slice(this.offset,this.offset+t);return this.offset+=t,e},remainingLength:function(){return this.arrayBuffer.byteLength-this.offset},nextString:function(t){var e=this.arrayBuffer.slice(this.offset,this.offset+t);return e=String.fromCharCode.apply(null,new this.global.Uint8Array(e)),this.offset+=t,e},mark:function(){var t=this;return{openWithOffset:function(e){return e=(e||0)+this.offset,new n(t.arrayBuffer,e,t.arrayBuffer.byteLength-e,(!t.littleEndian),t.global,t.parentOffset)},offset:this.offset,getParentOffset:function(){return t.parentOffset}}},offsetFrom:function(t){return this.parentOffset+this.offset-(t.offset+t.getParentOffset())},skip:function(t){this.offset+=t},branch:function(t,e){return e="number"==typeof e?e:this.arrayBuffer.byteLength-(this.offset+t),new n(this.arrayBuffer,this.offset+t,e,(!this.littleEndian),this.global,this.parentOffset)}},e.exports=n},{}],22:[function(t,e,i){e.exports={exif:{1:"InteropIndex",2:"InteropVersion",11:"ProcessingSoftware",254:"SubfileType",255:"OldSubfileType",256:"ImageWidth",257:"ImageHeight",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",263:"Thresholding",264:"CellWidth",265:"CellLength",266:"FillOrder",269:"DocumentName",270:"ImageDescription",271:"Make",272:"Model",273:"StripOffsets",274:"Orientation",277:"SamplesPerPixel",278:"RowsPerStrip",279:"StripByteCounts",280:"MinSampleValue",281:"MaxSampleValue",282:"XResolution",283:"YResolution",284:"PlanarConfiguration",285:"PageName",286:"XPosition",287:"YPosition",288:"FreeOffsets",289:"FreeByteCounts",290:"GrayResponseUnit",291:"GrayResponseCurve",292:"T4Options",293:"T6Options",296:"ResolutionUnit",297:"PageNumber",300:"ColorResponseUnit",301:"TransferFunction",305:"Software",306:"ModifyDate",315:"Artist",316:"HostComputer",317:"Predictor",318:"WhitePoint",319:"PrimaryChromaticities",320:"ColorMap",321:"HalftoneHints",322:"TileWidth",323:"TileLength",324:"TileOffsets",325:"TileByteCounts",326:"BadFaxLines",327:"CleanFaxData",328:"ConsecutiveBadFaxLines",330:"SubIFD",332:"InkSet",333:"InkNames",334:"NumberofInks",336:"DotRange",337:"TargetPrinter",338:"ExtraSamples",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",342:"TransferRange",343:"ClipPath",344:"XClipPathUnits",345:"YClipPathUnits",346:"Indexed",347:"JPEGTables",351:"OPIProxy",400:"GlobalParametersIFD",401:"ProfileType",402:"FaxProfile",403:"CodingMethods",404:"VersionYear",405:"ModeNumber",433:"Decode",434:"DefaultImageColor",435:"T82Options",437:"JPEGTables",512:"JPEGProc",513:"ThumbnailOffset",514:"ThumbnailLength",515:"JPEGRestartInterval",517:"JPEGLosslessPredictors",518:"JPEGPointTransforms",519:"JPEGQTables",520:"JPEGDCTables",521:"JPEGACTables",529:"YCbCrCoefficients",530:"YCbCrSubSampling",531:"YCbCrPositioning",532:"ReferenceBlackWhite",559:"StripRowCounts",700:"ApplicationNotes",999:"USPTOMiscellaneous",4096:"RelatedImageFileFormat",4097:"RelatedImageWidth",4098:"RelatedImageHeight",18246:"Rating",18247:"XP_DIP_XML",18248:"StitchInfo",18249:"RatingPercent",32781:"ImageID",32931:"WangTag1",32932:"WangAnnotation",32933:"WangTag3",32934:"WangTag4",32995:"Matteing",32996:"DataType",32997:"ImageDepth",32998:"TileDepth",33405:"Model2",33421:"CFARepeatPatternDim",33422:"CFAPattern2",33423:"BatteryLevel",33424:"KodakIFD",33432:"Copyright",33434:"ExposureTime",33437:"FNumber",33445:"MDFileTag",33446:"MDScalePixel",33447:"MDColorTable",33448:"MDLabName",33449:"MDSampleInfo",33450:"MDPrepDate",33451:"MDPrepTime",33452:"MDFileUnits",33550:"PixelScale",33589:"AdventScale",33590:"AdventRevision",33628:"UIC1Tag",33629:"UIC2Tag",33630:"UIC3Tag",33631:"UIC4Tag",33723:"IPTC-NAA",33918:"IntergraphPacketData",33919:"IntergraphFlagRegisters",33920:"IntergraphMatrix",33921:"INGRReserved",33922:"ModelTiePoint",34016:"Site",34017:"ColorSequence",34018:"IT8Header",34019:"RasterPadding",34020:"BitsPerRunLength",34021:"BitsPerExtendedRunLength",34022:"ColorTable",34023:"ImageColorIndicator",34024:"BackgroundColorIndicator",34025:"ImageColorValue",34026:"BackgroundColorValue",34027:"PixelIntensityRange",34028:"TransparencyIndicator",34029:"ColorCharacterization",34030:"HCUsage",34031:"TrapIndicator",34032:"CMYKEquivalent",34118:"SEMInfo",34152:"AFCP_IPTC",34232:"PixelMagicJBIGOptions",34264:"ModelTransform",34306:"WB_GRGBLevels",34310:"LeafData",34377:"PhotoshopSettings",34665:"ExifOffset",34675:"ICC_Profile",34687:"TIFF_FXExtensions",34688:"MultiProfiles",34689:"SharedData",34690:"T88Options",34732:"ImageLayer",34735:"GeoTiffDirectory",34736:"GeoTiffDoubleParams",34737:"GeoTiffAsciiParams",34850:"ExposureProgram",34852:"SpectralSensitivity",34853:"GPSInfo",34855:"ISO",34856:"Opto-ElectricConvFactor",34857:"Interlace",34858:"TimeZoneOffset",34859:"SelfTimerMode",34864:"SensitivityType",34865:"StandardOutputSensitivity",34866:"RecommendedExposureIndex",34867:"ISOSpeed",34868:"ISOSpeedLatitudeyyy",34869:"ISOSpeedLatitudezzz",34908:"FaxRecvParams",34909:"FaxSubAddress",34910:"FaxRecvTime",34954:"LeafSubIFD",36864:"ExifVersion",36867:"DateTimeOriginal",36868:"CreateDate",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureCompensation",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37386:"FocalLength",37387:"FlashEnergy",37388:"SpatialFrequencyResponse",37389:"Noise",37390:"FocalPlaneXResolution",37391:"FocalPlaneYResolution",37392:"FocalPlaneResolutionUnit",37393:"ImageNumber",37394:"SecurityClassification",37395:"ImageHistory",37396:"SubjectArea",37397:"ExposureIndex",37398:"TIFF-EPStandardID",37399:"SensingMethod",37434:"CIP3DataFile",37435:"CIP3Sheet",37436:"CIP3Side",37439:"StoNits",37500:"MakerNote",37510:"UserComment",37520:"SubSecTime",37521:"SubSecTimeOriginal",37522:"SubSecTimeDigitized",37679:"MSDocumentText",37680:"MSPropertySetStorage",37681:"MSDocumentTextPosition",37724:"ImageSourceData",40091:"XPTitle",40092:"XPComment",40093:"XPAuthor",40094:"XPKeywords",40095:"XPSubject",40960:"FlashpixVersion",40961:"ColorSpace",40962:"ExifImageWidth",40963:"ExifImageHeight",40964:"RelatedSoundFile",40965:"InteropOffset",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41485:"Noise",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41489:"ImageNumber",41490:"SecurityClassification",41491:"ImageHistory",41492:"SubjectLocation",41493:"ExposureIndex",41494:"TIFF-EPStandardID",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRatio",41989:"FocalLengthIn35mmFormat",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",42016:"ImageUniqueID",42032:"OwnerName",42033:"SerialNumber",42034:"LensInfo",42035:"LensMake",42036:"LensModel",42037:"LensSerialNumber",42112:"GDALMetadata",42113:"GDALNoData",42240:"Gamma",44992:"ExpandSoftware",44993:"ExpandLens",44994:"ExpandFilm",44995:"ExpandFilterLens",44996:"ExpandScanner",44997:"ExpandFlashLamp",48129:"PixelFormat",48130:"Transformation",48131:"Uncompressed",48132:"ImageType",48256:"ImageWidth",48257:"ImageHeight",48258:"WidthResolution",48259:"HeightResolution",48320:"ImageOffset",48321:"ImageByteCount",48322:"AlphaOffset",48323:"AlphaByteCount",48324:"ImageDataDiscard",48325:"AlphaDataDiscard",50215:"OceScanjobDesc",50216:"OceApplicationSelector",50217:"OceIDNumber",50218:"OceImageLogic",50255:"Annotations",50341:"PrintIM",50560:"USPTOOriginalContentType",50706:"DNGVersion",50707:"DNGBackwardVersion",50708:"UniqueCameraModel",50709:"LocalizedCameraModel",50710:"CFAPlaneColor",50711:"CFALayout",50712:"LinearizationTable",50713:"BlackLevelRepeatDim",50714:"BlackLevel",50715:"BlackLevelDeltaH",50716:"BlackLevelDeltaV",50717:"WhiteLevel",50718:"DefaultScale",50719:"DefaultCropOrigin",50720:"DefaultCropSize",50721:"ColorMatrix1",50722:"ColorMatrix2",50723:"CameraCalibration1",50724:"CameraCalibration2",50725:"ReductionMatrix1",50726:"ReductionMatrix2",50727:"AnalogBalance",50728:"AsShotNeutral",50729:"AsShotWhiteXY",50730:"BaselineExposure",50731:"BaselineNoise",50732:"BaselineSharpness",50733:"BayerGreenSplit",50734:"LinearResponseLimit",50735:"CameraSerialNumber",50736:"DNGLensInfo",50737:"ChromaBlurRadius",50738:"AntiAliasStrength",50739:"ShadowScale",50740:"DNGPrivateData",50741:"MakerNoteSafety",50752:"RawImageSegmentation",50778:"CalibrationIlluminant1",50779:"CalibrationIlluminant2",50780:"BestQualityScale",50781:"RawDataUniqueID",50784:"AliasLayerMetadata",50827:"OriginalRawFileName",50828:"OriginalRawFileData",50829:"ActiveArea",50830:"MaskedAreas",50831:"AsShotICCProfile",50832:"AsShotPreProfileMatrix",50833:"CurrentICCProfile",50834:"CurrentPreProfileMatrix",50879:"ColorimetricReference",50898:"PanasonicTitle",50899:"PanasonicTitle2",50931:"CameraCalibrationSig",50932:"ProfileCalibrationSig",50933:"ProfileIFD",50934:"AsShotProfileName",50935:"NoiseReductionApplied",50936:"ProfileName",50937:"ProfileHueSatMapDims",50938:"ProfileHueSatMapData1",50939:"ProfileHueSatMapData2",50940:"ProfileToneCurve",50941:"ProfileEmbedPolicy",50942:"ProfileCopyright",50964:"ForwardMatrix1",50965:"ForwardMatrix2",50966:"PreviewApplicationName",50967:"PreviewApplicationVersion",50968:"PreviewSettingsName",50969:"PreviewSettingsDigest",50970:"PreviewColorSpace",50971:"PreviewDateTime",50972:"RawImageDigest",50973:"OriginalRawFileDigest",50974:"SubTileBlockSize",50975:"RowInterleaveFactor",50981:"ProfileLookTableDims",50982:"ProfileLookTableData",51008:"OpcodeList1",51009:"OpcodeList2",51022:"OpcodeList3",51041:"NoiseProfile",51043:"TimeCodes",51044:"FrameRate",51058:"TStop",51081:"ReelName",51089:"OriginalDefaultFinalSize",51090:"OriginalBestQualitySize",51091:"OriginalDefaultCropSize",51105:"CameraLabel",51107:"ProfileHueSatMapEncoding",51108:"ProfileLookTableEncoding",51109:"BaselineExposureOffset",51110:"DefaultBlackRender",51111:"NewRawImageDigest",51112:"RawToPreviewGain",51125:"DefaultUserCrop",59932:"Padding",59933:"OffsetSchema",65e3:"OwnerName",65001:"SerialNumber",65002:"Lens",65024:"KDC_IFD",65100:"RawFile",65101:"Converter",65102:"WhiteBalance",65105:"Exposure",65106:"Shadows",65107:"Brightness",65108:"Contrast",65109:"Saturation",65110:"Sharpness",65111:"Smoothness",65112:"MoireFilter"},gps:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential",31:"GPSHPositioningError"}}},{}],23:[function(t,e,i){function n(t,e){switch(t){case 1:return e.nextUInt8();case 3:return e.nextUInt16();case 4:return e.nextUInt32();case 5:return[e.nextUInt32(),e.nextUInt32()];case 6:return e.nextInt8();case 8:return e.nextUInt16();case 9:return e.nextUInt32();case 10:return[e.nextInt32(),e.nextInt32()];case 11:return e.nextFloat();case 12:return e.nextDouble();default:throw new Error("Invalid format while decoding: "+t)}}function r(t){switch(t){case 1:case 2:case 6:case 7:return 1;case 3:case 8:return 2;case 4:case 9:case 11:return 4;case 5:case 10:case 12:return 8;default:throw new Error("Invalid format: "+t)}}function a(t,e){var i,a,o=e.nextUInt16(),s=e.nextUInt16(),l=r(s),h=e.nextUInt32(),f=l*h;if(f>4&&(e=t.openWithOffset(e.nextUInt32())),2===s){i=e.nextString(h);var c=i.indexOf("\0");c!==-1&&(i=i.substr(0,c))}else if(7===s)i=e.nextBuffer(h);else for(i=[],a=0;a0&&218!==n;){if(255!==t.nextUInt8())throw new Error("Invalid JPEG section offset");n=t.nextUInt8(),i=n>=208&&n<=217||218===n?0:t.nextUInt16()-2,e(n,t.branch(0,i)),t.skip(i)}},getSizeFromSOFSection:function(t){return t.skip(1),{height:t.nextUInt16(),width:t.nextUInt16()}},getSectionName:function(t){var e,i;switch(t){case 216:e="SOI";break;case 196:e="DHT";break;case 219:e="DQT";break;case 221:e="DRI";break;case 218:e="SOS";break;case 254:e="COM";break;case 217:e="EOI";break;default:t>=224&&t<=239?(e="APP",i=t-224):t>=192&&t<=207&&196!==t&&200!==t&&204!==t?(e="SOF",i=t-192):t>=208&&t<=215&&(e="RST",i=t-208)}var n={name:e};return"number"==typeof i&&(n.index=i),n}}},{}],25:[function(t,e,i){function n(t,e,i,n,r,a,o){this.startMarker=t,this.tags=e,this.imageSize=i,this.thumbnailOffset=n,this.thumbnailLength=r,this.thumbnailType=a,this.app1Offset=o}function r(t){this.stream=t,this.flags={readBinaryTags:!1,resolveTagNames:!0,simplifyValues:!0,imageSize:!0,hidePointers:!0,returnTags:!0}}var a=t("./jpeg"),o=t("./exif"),s=t("./simplify");n.prototype={hasThumbnail:function(t){return!(!this.thumbnailOffset||!this.thumbnailLength)&&("string"!=typeof t||("image/jpeg"===t.toLowerCase().trim()?6===this.thumbnailType:"image/tiff"===t.toLowerCase().trim()&&1===this.thumbnailType))},getThumbnailOffset:function(){return this.app1Offset+6+this.thumbnailOffset},getThumbnailLength:function(){return this.thumbnailLength},getThumbnailBuffer:function(){return this._getThumbnailStream().nextBuffer(this.thumbnailLength)},_getThumbnailStream:function(){return this.startMarker.openWithOffset(this.getThumbnailOffset())},getImageSize:function(){return this.imageSize},getThumbnailSize:function(){var t,e=this._getThumbnailStream();return a.parseSections(e,function(e,i){"SOF"===a.getSectionName(e).name&&(t=a.getSizeFromSOFSection(i))}),t}},r.prototype={enableBinaryFields:function(t){return this.flags.readBinaryTags=!!t,this},enablePointers:function(t){return this.flags.hidePointers=!t,this},enableTagNames:function(t){return this.flags.resolveTagNames=!!t,this},enableImageSize:function(t){return this.flags.imageSize=!!t,this},enableReturnTags:function(t){return this.flags.returnTags=!!t,this},enableSimpleValues:function(t){return this.flags.simplifyValues=!!t,this},parse:function(){var e,i,r,l,h,f,c,u,p,d=this.stream.mark(),m=d.openWithOffset(0),g=this.flags;return g.resolveTagNames&&(c=t("./exif-tags")),g.resolveTagNames?(e={},u=function(t){return e[t.name]},p=function(t,i){e[t.name]=i}):(e=[],u=function(t){var i;for(i=0;i1?255===t[0]&&216===t[1]&&255===t[2]?{ext:"jpg",mime:"image/jpeg"}:137===t[0]&&80===t[1]&&78===t[2]&&71===t[3]?{ext:"png",mime:"image/png"}:71===t[0]&&73===t[1]&&70===t[2]?{ext:"gif",mime:"image/gif"}:87===t[8]&&69===t[9]&&66===t[10]&&80===t[11]?{ext:"webp",mime:"image/webp"}:(73===t[0]&&73===t[1]&&42===t[2]&&0===t[3]||77===t[0]&&77===t[1]&&0===t[2]&&42===t[3])&&67===t[8]&&82===t[9]?{ext:"cr2",mime:"image/x-canon-cr2"}:73===t[0]&&73===t[1]&&42===t[2]&&0===t[3]||77===t[0]&&77===t[1]&&0===t[2]&&42===t[3]?{ext:"tif",mime:"image/tiff"}:66===t[0]&&77===t[1]?{ext:"bmp",mime:"image/bmp"}:73===t[0]&&73===t[1]&&188===t[2]?{ext:"jxr",mime:"image/vnd.ms-photo"}:56===t[0]&&66===t[1]&&80===t[2]&&83===t[3]?{ext:"psd",mime:"image/vnd.adobe.photoshop"}:80===t[0]&&75===t[1]&&3===t[2]&&4===t[3]&&109===t[30]&&105===t[31]&&109===t[32]&&101===t[33]&&116===t[34]&&121===t[35]&&112===t[36]&&101===t[37]&&97===t[38]&&112===t[39]&&112===t[40]&&108===t[41]&&105===t[42]&&99===t[43]&&97===t[44]&&116===t[45]&&105===t[46]&&111===t[47]&&110===t[48]&&47===t[49]&&101===t[50]&&112===t[51]&&117===t[52]&&98===t[53]&&43===t[54]&&122===t[55]&&105===t[56]&&112===t[57]?{ext:"epub",mime:"application/epub+zip"}:80===t[0]&&75===t[1]&&3===t[2]&&4===t[3]&&77===t[30]&&69===t[31]&&84===t[32]&&65===t[33]&&45===t[34]&&73===t[35]&&78===t[36]&&70===t[37]&&47===t[38]&&109===t[39]&&111===t[40]&&122===t[41]&&105===t[42]&&108===t[43]&&108===t[44]&&97===t[45]&&46===t[46]&&114===t[47]&&115===t[48]&&97===t[49]?{ext:"xpi",mime:"application/x-xpinstall"}:80!==t[0]||75!==t[1]||3!==t[2]&&5!==t[2]&&7!==t[2]||4!==t[3]&&6!==t[3]&&8!==t[3]?117===t[257]&&115===t[258]&&116===t[259]&&97===t[260]&&114===t[261]?{ext:"tar",mime:"application/x-tar"}:82!==t[0]||97!==t[1]||114!==t[2]||33!==t[3]||26!==t[4]||7!==t[5]||0!==t[6]&&1!==t[6]?31===t[0]&&139===t[1]&&8===t[2]?{ext:"gz",mime:"application/gzip"}:66===t[0]&&90===t[1]&&104===t[2]?{ext:"bz2",mime:"application/x-bzip2"}:55===t[0]&&122===t[1]&&188===t[2]&&175===t[3]&&39===t[4]&&28===t[5]?{ext:"7z",mime:"application/x-7z-compressed"}:120===t[0]&&1===t[1]?{ext:"dmg",mime:"application/x-apple-diskimage"}:0===t[0]&&0===t[1]&&0===t[2]&&(24===t[3]||32===t[3])&&102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]||51===t[0]&&103===t[1]&&112===t[2]&&53===t[3]||0===t[0]&&0===t[1]&&0===t[2]&&28===t[3]&&102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]&&109===t[8]&&112===t[9]&&52===t[10]&&50===t[11]&&109===t[16]&&112===t[17]&&52===t[18]&&49===t[19]&&109===t[20]&&112===t[21]&&52===t[22]&&50===t[23]&&105===t[24]&&115===t[25]&&111===t[26]&&109===t[27]||0===t[0]&&0===t[1]&&0===t[2]&&28===t[3]&&102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]&&105===t[8]&&115===t[9]&&111===t[10]&&109===t[11]||0===t[0]&&0===t[1]&&0===t[2]&&28===t[3]&&102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]&&109===t[8]&&112===t[9]&&52===t[10]&&50===t[11]&&0===t[12]&&0===t[13]&&0===t[14]&&0===t[15]?{ext:"mp4",mime:"video/mp4"}:0===t[0]&&0===t[1]&&0===t[2]&&28===t[3]&&102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]&&77===t[8]&&52===t[9]&&86===t[10]?{ext:"m4v",mime:"video/x-m4v"}:77===t[0]&&84===t[1]&&104===t[2]&&100===t[3]?{ext:"mid",mime:"audio/midi"}:109===t[31]&&97===t[32]&&116===t[33]&&114===t[34]&&111===t[35]&&115===t[36]&&107===t[37]&&97===t[38]?{ext:"mkv",mime:"video/x-matroska"}:26===t[0]&&69===t[1]&&223===t[2]&&163===t[3]?{ext:"webm",mime:"video/webm"}:0===t[0]&&0===t[1]&&0===t[2]&&20===t[3]&&102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]?{ext:"mov",mime:"video/quicktime"}:82===t[0]&&73===t[1]&&70===t[2]&&70===t[3]&&65===t[8]&&86===t[9]&&73===t[10]?{ext:"avi",mime:"video/x-msvideo"}:48===t[0]&&38===t[1]&&178===t[2]&&117===t[3]&&142===t[4]&&102===t[5]&&207===t[6]&&17===t[7]&&166===t[8]&&217===t[9]?{ext:"wmv",mime:"video/x-ms-wmv"}:0===t[0]&&0===t[1]&&1===t[2]&&"b"===t[3].toString(16)[0]?{ext:"mpg",mime:"video/mpeg"}:73===t[0]&&68===t[1]&&51===t[2]||255===t[0]&&251===t[1]?{ext:"mp3",mime:"audio/mpeg"}:102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]&&77===t[8]&&52===t[9]&&65===t[10]||77===t[0]&&52===t[1]&&65===t[2]&&32===t[3]?{ext:"m4a",mime:"audio/m4a"}:79===t[28]&&112===t[29]&&117===t[30]&&115===t[31]&&72===t[32]&&101===t[33]&&97===t[34]&&100===t[35]?{ext:"opus",mime:"audio/opus"}:79===t[0]&&103===t[1]&&103===t[2]&&83===t[3]?{ext:"ogg",mime:"audio/ogg"}:102===t[0]&&76===t[1]&&97===t[2]&&67===t[3]?{ext:"flac",mime:"audio/x-flac"}:82===t[0]&&73===t[1]&&70===t[2]&&70===t[3]&&87===t[8]&&65===t[9]&&86===t[10]&&69===t[11]?{ext:"wav",mime:"audio/x-wav"}:35===t[0]&&33===t[1]&&65===t[2]&&77===t[3]&&82===t[4]&&10===t[5]?{ext:"amr",mime:"audio/amr"}:37===t[0]&&80===t[1]&&68===t[2]&&70===t[3]?{ext:"pdf",mime:"application/pdf"}:77===t[0]&&90===t[1]?{ext:"exe",mime:"application/x-msdownload"}:67!==t[0]&&70!==t[0]||87!==t[1]||83!==t[2]?123===t[0]&&92===t[1]&&114===t[2]&&116===t[3]&&102===t[4]?{ext:"rtf",mime:"application/rtf"}:119===t[0]&&79===t[1]&&70===t[2]&&70===t[3]&&(0===t[4]&&1===t[5]&&0===t[6]&&0===t[7]||79===t[4]&&84===t[5]&&84===t[6]&&79===t[7])?{ext:"woff",mime:"application/font-woff"}:119===t[0]&&79===t[1]&&70===t[2]&&50===t[3]&&(0===t[4]&&1===t[5]&&0===t[6]&&0===t[7]||79===t[4]&&84===t[5]&&84===t[6]&&79===t[7])?{ext:"woff2",mime:"application/font-woff"}:76===t[34]&&80===t[35]&&(0===t[8]&&0===t[9]&&1===t[10]||1===t[8]&&0===t[9]&&2===t[10]||2===t[8]&&0===t[9]&&2===t[10])?{ext:"eot",mime:"application/octet-stream"}:0===t[0]&&1===t[1]&&0===t[2]&&0===t[3]&&0===t[4]?{ext:"ttf",mime:"application/font-sfnt"}:79===t[0]&&84===t[1]&&84===t[2]&&79===t[3]&&0===t[4]?{ext:"otf",mime:"application/font-sfnt"}:0===t[0]&&0===t[1]&&1===t[2]&&0===t[3]?{ext:"ico",mime:"image/x-icon"}:70===t[0]&&76===t[1]&&86===t[2]&&1===t[3]?{ext:"flv",mime:"video/x-flv"}:37===t[0]&&33===t[1]?{ext:"ps",mime:"application/postscript"}:253===t[0]&&55===t[1]&&122===t[2]&&88===t[3]&&90===t[4]&&0===t[5]?{ext:"xz",mime:"application/x-xz"}:83===t[0]&&81===t[1]&&76===t[2]&&105===t[3]?{ext:"sqlite",mime:"application/x-sqlite3"}:78===t[0]&&69===t[1]&&83===t[2]&&26===t[3]?{ext:"nes",mime:"application/x-nintendo-nes-rom"}:67===t[0]&&114===t[1]&&50===t[2]&&52===t[3]?{ext:"crx",mime:"application/x-google-chrome-extension"}:77===t[0]&&83===t[1]&&67===t[2]&&70===t[3]||73===t[0]&&83===t[1]&&99===t[2]&&40===t[3]?{ext:"cab",mime:"application/vnd.ms-cab-compressed"}:33===t[0]&&60===t[1]&&97===t[2]&&114===t[3]&&99===t[4]&&104===t[5]&&62===t[6]&&10===t[7]&&100===t[8]&&101===t[9]&&98===t[10]&&105===t[11]&&97===t[12]&&110===t[13]&&45===t[14]&&98===t[15]&&105===t[16]&&110===t[17]&&97===t[18]&&114===t[19]&&121===t[20]?{ext:"deb",mime:"application/x-deb"}:33===t[0]&&60===t[1]&&97===t[2]&&114===t[3]&&99===t[4]&&104===t[5]&&62===t[6]?{ext:"ar",mime:"application/x-unix-archive"}:237===t[0]&&171===t[1]&&238===t[2]&&219===t[3]?{ext:"rpm",mime:"application/x-rpm"}:31===t[0]&&160===t[1]||31===t[0]&&157===t[1]?{ext:"Z",mime:"application/x-compress"}:76===t[0]&&90===t[1]&&73===t[2]&&80===t[3]?{ext:"lz",mime:"application/x-lzip"}:208===t[0]&&207===t[1]&&17===t[2]&&224===t[3]&&161===t[4]&&177===t[5]&&26===t[6]&&225===t[7]?{ext:"msi",mime:"application/x-msi"}:null:{ext:"swf",mime:"application/x-shockwave-flash"}:{ext:"rar",mime:"application/x-rar-compressed"}:{ext:"zip",mime:"application/zip"}:null}},{}],28:[function(t,e,i){function n(t,e,i){if(!s(e))throw new TypeError("iterator must be a function");arguments.length<3&&(i=this),"[object Array]"===l.call(t)?r(t,e,i):"string"==typeof t?a(t,e,i):o(t,e,i)}function r(t,e,i){for(var n=0,r=t.length;n>1,f=-7,c=i?r-1:0,u=i?-1:1,p=t[e+c];for(c+=u,a=p&(1<<-f)-1,p>>=-f,f+=s;f>0;a=256*a+t[e+c],c+=u,f-=8);for(o=a&(1<<-f)-1,a>>=-f,f+=n;f>0;o=256*o+t[e+c],c+=u,f-=8);if(0===a)a=1-h;else{if(a===l)return o?NaN:(p?-1:1)*(1/0);o+=Math.pow(2,n),a-=h}return(p?-1:1)*o*Math.pow(2,a-n)},i.write=function(t,e,i,n,r,a){var o,s,l,h=8*a-r-1,f=(1<>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:a-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),e+=o+c>=1?u/l:u*Math.pow(2,1-c),e*l>=2&&(o++,l/=2),o+c>=f?(s=0,o=f):o+c>=1?(s=(e*l-1)*Math.pow(2,r),o+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,r),o=0));r>=8;t[i+p]=255&s,p+=d,s/=256,r-=8);for(o=o<0;t[i+p]=255&o,p+=d,o/=256,h-=8);t[i+p-d]|=128*m}},{}],31:[function(t,e,i){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}},{}],32:[function(t,e,i){"use strict";var n="(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(?:\\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}",r="(?:(?:[0-9a-fA-F:]){1,4}(?:(?::(?:[0-9a-fA-F]){1,4}|:)){2,7})+",a=e.exports=function(t){return t=t||{},t.exact?new RegExp("(?:^"+n+"$)|(?:^"+r+"$)"):new RegExp("(?:"+n+")|(?:"+r+")","g")};a.v4=function(t){return t=t||{},t.exact?new RegExp("^"+n+"$"):new RegExp(n,"g")},a.v6=function(t){return t=t||{},t.exact?new RegExp("^"+r+"$"):new RegExp(r,"g")}},{}],33:[function(t,e,i){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function r(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}e.exports=function(t){return null!=t&&(n(t)||r(t)||!!t._isBuffer)}},{}],34:[function(t,e,i){function n(t){var e=r.call(t);return"[object Function]"===e||"function"==typeof t&&"[object RegExp]"!==e||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)}e.exports=n;var r=Object.prototype.toString},{}],35:[function(t,e,i){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],36:[function(t,e,i){var n=t("./lib/encoder"),r=t("./lib/decoder");e.exports={encode:n,decode:r}},{"./lib/decoder":37,"./lib/encoder":38}],37:[function(t,e,i){(function(t){function i(e,i){var r=new Uint8Array(e),a=new n;a.parse(r);var o={width:a.width,height:a.height,data:i?new Uint8Array(a.width*a.height*4):new t(a.width*a.height*4)};return a.copyToImageData(o),o}var n=function(){"use strict";function t(){}function e(t,e){for(var i,n,r=0,a=[],o=16;o>0&&!t[o-1];)o--;a.push({children:[],index:0});var s,l=a[0];for(i=0;i0;)l=a.pop();for(l.index++,a.push(l);a.length<=i;)a.push(s={children:[],index:0}),l.children[l.index]=s.children,l=s;r++}i+10)return P--,L>>P&1;if(L=t[e++],255==L){var i=t[e++];if(i)throw"unexpected marker: "+(L<<8|i).toString(16)}return P=7,L>>>7}function c(t){for(var e,i=t;null!==(e=f());){if(i=i[e],"number"==typeof i)return i;if("object"!==("undefined"==typeof i?"undefined":_typeof(i)))throw"invalid huffman sequence"}return null}function u(t){for(var e=0;t>0;){var i=f();if(null===i)return;e=e<<1|i,t--}return e}function p(t){var e=u(t);return e>=1<>4;if(0!==s){r+=l;var h=a[r];e[h]=p(s),r++}else{if(l<15)break;r+=16}}}function m(t,e){var i=c(t.huffmanTableDC),n=0===i?0:p(i)<0)return void C--;for(var i=o,n=s;i<=n;){var r=c(t.huffmanTableAC),l=15&r,f=r>>4;if(0!==l){i+=f;var d=a[i];e[d]=p(l)*(1<>4;if(0===m)r<15?(C=u(r)+(1<=65488&&O<=65495))break;e+=2}return e-R}function n(t,e){function i(t,i,n){var r,a,d,m,g,b,v,w,_,y,x=e.quantizationTable,k=n;for(y=0;y<64;y++)k[y]=t[y]*x[y];for(y=0;y<8;++y){var E=8*y;0!=k[1+E]||0!=k[2+E]||0!=k[3+E]||0!=k[4+E]||0!=k[5+E]||0!=k[6+E]||0!=k[7+E]?(r=u*k[0+E]+128>>8,a=u*k[4+E]+128>>8,d=k[2+E],m=k[6+E],g=p*(k[1+E]-k[7+E])+128>>8,w=p*(k[1+E]+k[7+E])+128>>8,b=k[3+E]<<4,v=k[5+E]<<4,_=r-a+1>>1,r=r+a+1>>1,a=_,_=d*c+m*f+128>>8,d=d*f-m*c+128>>8,m=_,_=g-v+1>>1,g=g+v+1>>1,v=_,_=w+b+1>>1,b=w-b+1>>1,w=_,_=r-m+1>>1,r=r+m+1>>1,m=_,_=a-d+1>>1,a=a+d+1>>1,d=_,_=g*h+w*l+2048>>12,g=g*l-w*h+2048>>12,w=_,_=b*s+v*o+2048>>12,b=b*o-v*s+2048>>12,v=_,k[0+E]=r+w,k[7+E]=r-w,k[1+E]=a+v,k[6+E]=a-v,k[2+E]=d+b,k[5+E]=d-b,k[3+E]=m+g,k[4+E]=m-g):(_=u*k[0+E]+512>>10,k[0+E]=_,k[1+E]=_,k[2+E]=_,k[3+E]=_,k[4+E]=_,k[5+E]=_,k[6+E]=_,k[7+E]=_)}for(y=0;y<8;++y){var S=y;0!=k[8+S]||0!=k[16+S]||0!=k[24+S]||0!=k[32+S]||0!=k[40+S]||0!=k[48+S]||0!=k[56+S]?(r=u*k[0+S]+2048>>12,a=u*k[32+S]+2048>>12,d=k[16+S],m=k[48+S],g=p*(k[8+S]-k[56+S])+2048>>12,w=p*(k[8+S]+k[56+S])+2048>>12,b=k[24+S],v=k[40+S],_=r-a+1>>1,r=r+a+1>>1,a=_,_=d*c+m*f+2048>>12,d=d*f-m*c+2048>>12,m=_,_=g-v+1>>1,g=g+v+1>>1,v=_,_=w+b+1>>1,b=w-b+1>>1,w=_,_=r-m+1>>1,r=r+m+1>>1,m=_,_=a-d+1>>1,a=a+d+1>>1,d=_,_=g*h+w*l+2048>>12,g=g*l-w*h+2048>>12,w=_,_=b*s+v*o+2048>>12,b=b*o-v*s+2048>>12,v=_,k[0+S]=r+w,k[56+S]=r-w,k[8+S]=a+v,k[48+S]=a-v,k[16+S]=d+b,k[40+S]=d-b,k[24+S]=m+g,k[32+S]=m-g):(_=u*n[y+0]+8192>>14,k[0+S]=_,k[8+S]=_,k[16+S]=_,k[24+S]=_,k[32+S]=_,k[40+S]=_,k[48+S]=_,k[56+S]=_)}for(y=0;y<64;++y){var I=128+(k[y]+8>>4);i[y]=I<0?0:I>255?255:I}}for(var n,r,a=[],d=e.blocksPerLine,m=e.blocksPerColumn,g=d<<3,b=new Int32Array(64),v=new Uint8Array(64),w=0;w255?255:t}var a=new Int32Array([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]),o=4017,s=799,l=3406,h=2276,f=1567,c=3784,u=5793,p=2896;return t.prototype={load:function(t){var e=new XMLHttpRequest;e.open("GET",t,!0),e.responseType="arraybuffer",e.onload=function(){var t=new Uint8Array(e.response||e.mozResponseArrayBuffer);this.parse(t),this.onload&&this.onload()}.bind(this),e.send(null)},parse:function(t){function r(){var e=t[f]<<8|t[f+1];return f+=2,e}function o(){var e=r(),i=t.subarray(f,f+e-2);return f+=i.length,i}function s(t){var e,i,n=0,r=0;for(i in t.components)t.components.hasOwnProperty(i)&&(e=t.components[i],n>4===0)for(w=0;w<64;w++){var S=a[w];E[S]=t[f++]}else{if(k>>4!==1)throw"DQT: invalid table spec";for(w=0;w<64;w++){var S=a[w];E[S]=r()}}p[15&k]=E}break;case 65472:case 65473:case 65474:r(),l={},l.extended=65473===b,l.progressive=65474===b,l.precision=t[f++],l.scanLines=r(),l.samplesPerLine=r(),l.components={},l.componentsOrder=[];var I,M=t[f++];for(v=0;v>4,T=15&t[f+1],R=t[f+2];l.componentsOrder.push(I),l.components[I]={h:A,v:T,quantizationIdx:R},f+=3}s(l),d.push(l);break;case 65476:var L=r();for(v=2;v>4===0?g:m)[15&P]=e(C,z)}break;case 65501:r(),h=r();break;case 65498:var O,D=(r(),t[f++]),U=[];for(v=0;v>4],O.huffmanTableAC=m[15&N],U.push(O)}var F=t[f++],j=t[f++],H=t[f++],G=i(t,f,l,U,h,F,j,H>>4,15&H);f+=G;break;default:if(255==t[f-3]&&t[f-2]>=192&&t[f-2]<=254){f-=3;break}throw"unknown JPEG marker "+b.toString(16)}b=r()}if(1!=d.length)throw"only single frame JPEGs supported";for(var v=0;v255&&(n=255),I[H[i]]=n}for(var r=[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=S((r[a]*t+50)/100);o<1?o=1:o>255&&(o=255),M[H[a]]=o}for(var s=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],l=0,h=0;h<8;h++)for(var f=0;f<8;f++)A[l]=1/(I[H[l]]*s[h]*s[f]*8),T[l]=1/(M[H[l]]*s[h]*s[f]*8),l++}function n(t,e){for(var i=0,n=0,r=new Array,a=1;a<=16;a++){for(var o=1;o<=t[a];o++)r[e[n]]=[],r[e[n]][0]=i,r[e[n]][1]=a,n++,i++;i*=2}return r}function r(){_=n(G,W),y=n(Y,X),x=n(q,Z),k=n(V,J)}function a(){for(var t=1,e=2,i=1;i<=15;i++){for(var n=t;n>0]=38470*t,j[t+512>>0]=7471*t+32768,j[t+768>>0]=-11059*t,j[t+1024>>0]=-21709*t,j[t+1280>>0]=32768*t+8421375,j[t+1536>>0]=-27439*t,j[t+1792>>0]=-5329*t}function s(t){for(var e=t[0],i=t[1]-1;i>=0;)e&1<>8&255),l(255&t)}function f(t,e){var i,n,r,a,o,s,l,h,f,c=0,u=8,p=64;for(f=0;f0?Q+.5|0:Q-.5|0;return P}function c(){h(65504),h(16),l(74),l(70),l(73),l(70),l(0),l(1),l(1),l(0),h(1),h(1),l(0),l(0)}function u(t,e){h(65472),h(17),l(8),h(e),h(t),l(3),l(1),l(17),l(0),l(2),l(17),l(1),l(3),l(17),l(1)}function p(){h(65499),h(132),l(0);for(var t=0;t<64;t++)l(I[t]);l(1);for(var e=0;e<64;e++)l(M[e])}function d(){h(65476),h(418),l(0);for(var t=0;t<16;t++)l(G[t+1]);for(var e=0;e<=11;e++)l(W[e]);l(16);for(var i=0;i<16;i++)l(q[i+1]);for(var n=0;n<=161;n++)l(Z[n]);l(1);for(var r=0;r<16;r++)l(Y[r+1]);for(var a=0;a<=11;a++)l(X[a]);l(17);for(var o=0;o<16;o++)l(V[o+1]);for(var s=0;s<=161;s++)l(J[s])}function m(){h(65498),h(12),l(3),l(1),l(0),l(2),l(17),l(3),l(17),l(0),l(63),l(0)}function g(t,e,i,n,r){for(var a,o=r[0],l=r[240],h=16,c=63,u=64,p=f(t,e),d=0;d0&&0==C[g];g--);if(0==g)return s(o),i;for(var b,v=1;v<=g;){for(var w=v;0==C[v]&&v<=g;++v);var _=v-w;if(_>=h){b=_>>4;for(var y=1;y<=b;++y)s(l);_=15&_}a=32767+C[v],s(r[(_<<4)+L[a]]),s(R[a]),v++}return g!=c&&s(o),i}function b(){for(var t=String.fromCharCode,e=0;e<256;e++)F[e]=t(e)}function v(t){if(t<=0&&(t=1),t>100&&(t=100),E!=t){var e=0;e=t<50?Math.floor(5e3/t):Math.floor(200-2*t),i(e),E=t}}function w(){var t=(new Date).getTime();e||(e=50),b(),r(),a(),o(),v(e);(new Date).getTime()-t}var _,y,x,k,E,S=(Math.round,Math.floor),I=new Array(64),M=new Array(64),A=new Array(64),T=new Array(64),R=new Array(65535),L=new Array(65535),P=new Array(64),C=new Array(64),B=[],z=0,O=7,D=new Array(64),U=new Array(64),N=new Array(64),F=new Array(256),j=new Array(2048),H=[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],G=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],W=[0,1,2,3,4,5,6,7,8,9,10,11],q=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],Z=[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],X=[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],J=[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,i){(new Date).getTime();i&&v(i),B=new Array,z=0,O=7,h(65496),c(),p(),u(e.width,e.height),d(),m();var n=0,r=0,a=0;z=0,O=7,this.encode.displayName="_encode_";for(var o,l,f,b,w,E,S,I,M,R=e.data,L=e.width,P=e.height,C=4*L,F=0;F>3,S=4*(7&M),E=w+I*C+S,F+I>=P&&(E-=C*(F+1+I-P)),o+S>=C&&(E-=o+S-C+4),l=R[E++],f=R[E++],b=R[E++],D[M]=(j[l]+j[f+256>>0]+j[b+512>>0]>>16)-128,U[M]=(j[l+768>>0]+j[f+1024>>0]+j[b+1280>>0]>>16)-128,N[M]=(j[l+1280>>0]+j[f+1536>>0]+j[b+1792>>0]>>16)-128;n=g(D,A,n,_,x),r=g(U,T,r,y,k),a=g(N,T,a,y,k),o+=32}F+=8}if(O>=0){var H=[];H[1]=O+1,H[0]=(1<4&&n(t.slice(0,4),r)}}).call(this,t("buffer").Buffer)},{buffer:14,"buffer-equal":13}],41:[function(t,e,i){(function(i){function n(){this.types=Object.create(null),this.extensions=Object.create(null)}var r=(t("path"),t("fs"));n.prototype.define=function(t){for(var e in t){for(var n=t[e],r=0;r>>16&65535|0,o=0;0!==i;){o=i>2e3?2e3:i,i-=o;do r=r+e[n++]|0,a=a+r|0;while(--o);r%=65521,a%=65521}return r|a<<16|0}e.exports=n},{}],45:[function(t,e,i){"use strict";e.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}},{}],46:[function(t,e,i){"use strict";function n(){for(var t,e=[],i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}function r(t,e,i,n){var r=a,o=n+i;t^=-1;for(var s=n;s>>8^r[255&(t^e[s])];return t^-1}var a=n();e.exports=r},{}],47:[function(t,e,i){"use strict";function n(t,e){return t.msg=B[e],e}function r(t){return(t<<1)-(t>4?9:0)}function a(t){for(var e=t.length;--e>=0;)t[e]=0}function o(t){var e=t.state,i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(R.arraySet(t.output,e.pending_buf,e.pending_out,i,t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))}function s(t,e){L._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,o(t.strm)}function l(t,e){t.pending_buf[t.pending++]=e}function h(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function f(t,e,i,n){var r=t.avail_in;return r>n&&(r=n),0===r?0:(t.avail_in-=r,R.arraySet(e,t.input,t.next_in,r,i),1===t.state.wrap?t.adler=P(t.adler,e,r,i):2===t.state.wrap&&(t.adler=C(t.adler,e,r,i)), +t.next_in+=r,t.total_in+=r,r)}function c(t,e){var i,n,r=t.max_chain_length,a=t.strstart,o=t.prev_length,s=t.nice_match,l=t.strstart>t.w_size-ct?t.strstart-(t.w_size-ct):0,h=t.window,f=t.w_mask,c=t.prev,u=t.strstart+ft,p=h[a+o-1],d=h[a+o];t.prev_length>=t.good_match&&(r>>=2),s>t.lookahead&&(s=t.lookahead);do if(i=e,h[i+o]===d&&h[i+o-1]===p&&h[i]===h[a]&&h[++i]===h[a+1]){a+=2,i++;do;while(h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&ao){if(t.match_start=e,o=n,n>=s)break;p=h[a+o-1],d=h[a+o]}}while((e=c[e&f])>l&&0!==--r);return o<=t.lookahead?o:t.lookahead}function u(t){var e,i,n,r,a,o=t.w_size;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=o+(o-ct)){R.arraySet(t.window,t.window,o,o,0),t.match_start-=o,t.strstart-=o,t.block_start-=o,i=t.hash_size,e=i;do n=t.head[--e],t.head[e]=n>=o?n-o:0;while(--i);i=o,e=i;do n=t.prev[--e],t.prev[e]=n>=o?n-o:0;while(--i);r+=o}if(0===t.strm.avail_in)break;if(i=f(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=i,t.lookahead+t.insert>=ht)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=(t.ins_h<t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(u(t),0===t.lookahead&&e===z)return _t;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+i;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,s(t,!1),0===t.strm.avail_out))return _t;if(t.strstart-t.block_start>=t.w_size-ct&&(s(t,!1),0===t.strm.avail_out))return _t}return t.insert=0,e===U?(s(t,!0),0===t.strm.avail_out?xt:kt):t.strstart>t.block_start&&(s(t,!1),0===t.strm.avail_out)?_t:_t}function d(t,e){for(var i,n;;){if(t.lookahead=ht&&(t.ins_h=(t.ins_h<=ht)if(n=L._tr_tally(t,t.strstart-t.match_start,t.match_length-ht),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=ht){t.match_length--;do t.strstart++,t.ins_h=(t.ins_h<=ht&&(t.ins_h=(t.ins_h<4096)&&(t.match_length=ht-1)),t.prev_length>=ht&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-ht,n=L._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-ht),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=r&&(t.ins_h=(t.ins_h<=ht&&t.strstart>0&&(r=t.strstart-1,n=o[r],n===o[++r]&&n===o[++r]&&n===o[++r])){a=t.strstart+ft;do;while(n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&rt.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=ht?(i=L._tr_tally(t,1,t.match_length-ht),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=L._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(s(t,!1),0===t.strm.avail_out))return _t}return t.insert=0,e===U?(s(t,!0),0===t.strm.avail_out?xt:kt):t.last_lit&&(s(t,!1),0===t.strm.avail_out)?_t:yt}function b(t,e){for(var i;;){if(0===t.lookahead&&(u(t),0===t.lookahead)){if(e===z)return _t;break}if(t.match_length=0,i=L._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(s(t,!1),0===t.strm.avail_out))return _t}return t.insert=0,e===U?(s(t,!0),0===t.strm.avail_out?xt:kt):t.last_lit&&(s(t,!1),0===t.strm.avail_out)?_t:yt}function v(t,e,i,n,r){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=n,this.func=r}function w(t){t.window_size=2*t.w_size,a(t.head),t.max_lazy_match=T[t.level].max_lazy,t.good_match=T[t.level].good_length,t.nice_match=T[t.level].nice_length,t.max_chain_length=T[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=ht-1,t.match_available=0,t.ins_h=0}function _(){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=K,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*st),this.dyn_dtree=new R.Buf16(2*(2*at+1)),this.bl_tree=new R.Buf16(2*(2*ot+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(lt+1),this.heap=new R.Buf16(2*rt+1),a(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new R.Buf16(2*rt+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(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=$,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?pt:vt,t.adler=2===e.wrap?0:1,e.last_flush=z,L._tr_init(e),F):n(t,H)}function x(t){var e=y(t);return e===F&&w(t.state),e}function k(t,e){return t&&t.state?2!==t.state.wrap?H:(t.state.gzhead=e,F):H}function E(t,e,i,r,a,o){if(!t)return H;var s=1;if(e===q&&(e=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),a<1||a>Q||i!==K||r<8||r>15||e<0||e>9||o<0||o>V)return n(t,H);8===r&&(r=9);var l=new _;return t.state=l,l.strm=t,l.wrap=s,l.gzhead=null,l.w_bits=r,l.w_size=1<N||e<0)return t?n(t,H):H;if(s=t.state,!t.output||!t.input&&0!==t.avail_in||s.status===wt&&e!==U)return n(t,0===t.avail_out?W:H);if(s.strm=t,i=s.last_flush,s.last_flush=e,s.status===pt)if(2===s.wrap)t.adler=0,l(s,31),l(s,139),l(s,8),s.gzhead?(l(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)),l(s,255&s.gzhead.time),l(s,s.gzhead.time>>8&255),l(s,s.gzhead.time>>16&255),l(s,s.gzhead.time>>24&255),l(s,9===s.level?2:s.strategy>=Y||s.level<2?4:0),l(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(l(s,255&s.gzhead.extra.length),l(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(t.adler=C(t.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=dt):(l(s,0),l(s,0),l(s,0),l(s,0),l(s,0),l(s,9===s.level?2:s.strategy>=Y||s.level<2?4:0),l(s,Et),s.status=vt);else{var u=K+(s.w_bits-8<<4)<<8,p=-1;p=s.strategy>=Y||s.level<2?0:s.level<6?1:6===s.level?2:3,u|=p<<6,0!==s.strstart&&(u|=ut),u+=31-u%31,s.status=vt,h(s,u),0!==s.strstart&&(h(s,t.adler>>>16),h(s,65535&t.adler)),t.adler=1}if(s.status===dt)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&&(t.adler=C(t.adler,s.pending_buf,s.pending-f,f)),o(t),f=s.pending,s.pending!==s.pending_buf_size));)l(s,255&s.gzhead.extra[s.gzindex]),s.gzindex++;s.gzhead.hcrc&&s.pending>f&&(t.adler=C(t.adler,s.pending_buf,s.pending-f,f)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=mt)}else s.status=mt;if(s.status===mt)if(s.gzhead.name){f=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>f&&(t.adler=C(t.adler,s.pending_buf,s.pending-f,f)),o(t),f=s.pending,s.pending===s.pending_buf_size)){c=1;break}c=s.gzindexf&&(t.adler=C(t.adler,s.pending_buf,s.pending-f,f)),0===c&&(s.gzindex=0,s.status=gt)}else s.status=gt;if(s.status===gt)if(s.gzhead.comment){f=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>f&&(t.adler=C(t.adler,s.pending_buf,s.pending-f,f)),o(t),f=s.pending,s.pending===s.pending_buf_size)){c=1;break}c=s.gzindexf&&(t.adler=C(t.adler,s.pending_buf,s.pending-f,f)),0===c&&(s.status=bt)}else s.status=bt;if(s.status===bt&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&o(t),s.pending+2<=s.pending_buf_size&&(l(s,255&t.adler),l(s,t.adler>>8&255),t.adler=0,s.status=vt)):s.status=vt),0!==s.pending){if(o(t),0===t.avail_out)return s.last_flush=-1,F}else if(0===t.avail_in&&r(e)<=r(i)&&e!==U)return n(t,W);if(s.status===wt&&0!==t.avail_in)return n(t,W);if(0!==t.avail_in||0!==s.lookahead||e!==z&&s.status!==wt){var d=s.strategy===Y?b(s,e):s.strategy===X?g(s,e):T[s.level].func(s,e);if(d!==xt&&d!==kt||(s.status=wt),d===_t||d===xt)return 0===t.avail_out&&(s.last_flush=-1),F;if(d===yt&&(e===O?L._tr_align(s):e!==N&&(L._tr_stored_block(s,0,0,!1),e===D&&(a(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),o(t),0===t.avail_out))return s.last_flush=-1,F}return e!==U?F:s.wrap<=0?j:(2===s.wrap?(l(s,255&t.adler),l(s,t.adler>>8&255),l(s,t.adler>>16&255),l(s,t.adler>>24&255),l(s,255&t.total_in),l(s,t.total_in>>8&255),l(s,t.total_in>>16&255),l(s,t.total_in>>24&255)):(h(s,t.adler>>>16),h(s,65535&t.adler)),o(t),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?F:j)}function M(t){var e;return t&&t.state?(e=t.state.status,e!==pt&&e!==dt&&e!==mt&&e!==gt&&e!==bt&&e!==vt&&e!==wt?n(t,H):(t.state=null,e===vt?n(t,G):F)):H}function A(t,e){var i,n,r,o,s,l,h,f,c=e.length;if(!t||!t.state)return H;if(i=t.state,o=i.wrap,2===o||1===o&&i.status!==pt||i.lookahead)return H;for(1===o&&(t.adler=P(t.adler,e,c,0)),i.wrap=0,c>=i.w_size&&(0===o&&(a(i.head),i.strstart=0,i.block_start=0,i.insert=0),f=new R.Buf8(i.w_size),R.arraySet(f,e,c-i.w_size,i.w_size,0),e=f,c=i.w_size),s=t.avail_in,l=t.next_in,h=t.input,t.avail_in=c,t.next_in=0,t.input=e,u(i);i.lookahead>=ht;){n=i.strstart,r=i.lookahead-(ht-1);do i.ins_h=(i.ins_h<>>24,m>>>=x,g-=x,x=y>>>16&255,0===x)A[s++]=65535&y;else{if(!(16&x)){if(0===(64&x)){y=b[(65535&y)+(m&(1<>>=x,g-=x),g<15&&(m+=M[a++]<>>24,m>>>=x,g-=x,x=y>>>16&255,!(16&x)){if(0===(64&x)){y=v[(65535&y)+(m&(1<f){t.msg="invalid distance too far back",i.mode=n;break t}if(m>>>=x,g-=x,x=s-l,E>x){if(x=E-x,x>u&&i.sane){t.msg="invalid distance too far back",i.mode=n;break t}if(S=0,I=d,0===p){if(S+=c-x,x2;)A[s++]=I[S++],A[s++]=I[S++],A[s++]=I[S++],k-=3;k&&(A[s++]=I[S++],k>1&&(A[s++]=I[S++]))}else{S=s-E;do A[s++]=A[S++],A[s++]=A[S++],A[s++]=A[S++],k-=3;while(k>2);k&&(A[s++]=A[S++],k>1&&(A[s++]=A[S++]))}break}}break}}while(a>3,a-=k,g-=k<<3,m&=(1<>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function r(){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(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=O,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new v.Buf32(dt),e.distcode=e.distdyn=new v.Buf32(mt),e.sane=1,e.back=-1,T):P}function o(t){var e;return t&&t.state?(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,a(t)):P}function s(t,e){var i,n;return t&&t.state?(n=t.state,e<0?(i=0,e=-e):(i=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15)?P:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,o(t))):P}function l(t,e){var i,n;return t?(n=new r,t.state=n,n.window=null,i=s(t,e),i!==T&&(t.state=null),i):P}function h(t){return l(t,bt)}function f(t){if(vt){var e;for(g=new v.Buf32(512),b=new v.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(x(E,t.lens,0,288,g,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;x(S,t.lens,0,32,b,0,t.work,{bits:5}),vt=!1}t.lencode=g,t.lenbits=9,t.distcode=b,t.distbits=5}function c(t,e,i,n){var r,a=t.state;return null===a.window&&(a.wsize=1<=a.wsize?(v.arraySet(a.window,e,i-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(r=a.wsize-a.wnext,r>n&&(r=n),v.arraySet(a.window,e,i-n,r,a.wnext),n-=r,n?(v.arraySet(a.window,e,i-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=r,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,i.check=_(i.check,It,2,0),u=0,p=0,i.mode=D;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&u)<<8)+(u>>8))%31){t.msg="incorrect header check",i.mode=ct;break}if((15&u)!==z){t.msg="unknown compression method",i.mode=ct;break}if(u>>>=4,p-=4,yt=(15&u)+8,0===i.wbits)i.wbits=yt;else if(yt>i.wbits){t.msg="invalid window size",i.mode=ct;break}i.dmax=1<>8&1),512&i.flags&&(It[0]=255&u,It[1]=u>>>8&255,i.check=_(i.check,It,2,0)),u=0,p=0,i.mode=U;case U:for(;p<32;){if(0===l)break t;l--,u+=r[o++]<>>8&255,It[2]=u>>>16&255,It[3]=u>>>24&255,i.check=_(i.check,It,4,0)),u=0,p=0,i.mode=N;case N:for(;p<16;){if(0===l)break t;l--,u+=r[o++]<>8),512&i.flags&&(It[0]=255&u,It[1]=u>>>8&255,i.check=_(i.check,It,2,0)),u=0,p=0,i.mode=F;case F:if(1024&i.flags){for(;p<16;){if(0===l)break t;l--,u+=r[o++]<>>8&255,i.check=_(i.check,It,2,0)),u=0,p=0}else i.head&&(i.head.extra=null);i.mode=j;case j:if(1024&i.flags&&(g=i.length,g>l&&(g=l),g&&(i.head&&(yt=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),v.arraySet(i.head.extra,r,o,g,yt)),512&i.flags&&(i.check=_(i.check,r,g,o)),l-=g,o+=g,i.length-=g),i.length))break t;i.length=0,i.mode=H;case H:if(2048&i.flags){if(0===l)break t;g=0;do yt=r[o+g++],i.head&&yt&&i.length<65536&&(i.head.name+=String.fromCharCode(yt));while(yt&&g>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=Y;break;case q:for(;p<32;){if(0===l)break t;l--,u+=r[o++]<>>=7&p,p-=7&p,i.mode=lt;break}for(;p<3;){if(0===l)break t;l--,u+=r[o++]<>>=1,p-=1,3&u){case 0:i.mode=V;break;case 1:if(f(i),i.mode=et,e===A){u>>>=2,p-=2;break t}break;case 2:i.mode=K;break;case 3:t.msg="invalid block type",i.mode=ct}u>>>=2,p-=2;break;case V:for(u>>>=7&p,p-=7&p;p<32;){if(0===l)break t;l--,u+=r[o++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=ct;break}if(i.length=65535&u,u=0,p=0,i.mode=J,e===A)break t;case J:i.mode=$;case $:if(g=i.length){if(g>l&&(g=l),g>h&&(g=h),0===g)break t;v.arraySet(a,r,o,g,s),l-=g,o+=g,h-=g,s+=g,i.length-=g;break}i.mode=Y;break;case K:for(;p<14;){if(0===l)break t;l--,u+=r[o++]<>>=5,p-=5,i.ndist=(31&u)+1,u>>>=5,p-=5,i.ncode=(15&u)+4,u>>>=4,p-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=ct;break}i.have=0,i.mode=Q;case Q:for(;i.have>>=3,p-=3}for(;i.have<19;)i.lens[Mt[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,kt={bits:i.lenbits},xt=x(k,i.lens,0,19,i.lencode,0,i.work,kt),i.lenbits=kt.bits,xt){t.msg="invalid code lengths set",i.mode=ct;break}i.have=0,i.mode=tt;case tt:for(;i.have>>24,gt=St>>>16&255,bt=65535&St,!(mt<=p);){if(0===l)break t;l--,u+=r[o++]<>>=mt,p-=mt,i.lens[i.have++]=bt;else{if(16===bt){for(Et=mt+2;p>>=mt,p-=mt,0===i.have){t.msg="invalid bit length repeat",i.mode=ct;break}yt=i.lens[i.have-1],g=3+(3&u),u>>>=2,p-=2}else if(17===bt){for(Et=mt+3;p>>=mt,p-=mt,yt=0,g=3+(7&u),u>>>=3,p-=3}else{for(Et=mt+7;p>>=mt,p-=mt,yt=0,g=11+(127&u),u>>>=7,p-=7}if(i.have+g>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=ct;break}for(;g--;)i.lens[i.have++]=yt}}if(i.mode===ct)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=ct;break}if(i.lenbits=9,kt={bits:i.lenbits},xt=x(E,i.lens,0,i.nlen,i.lencode,0,i.work,kt),i.lenbits=kt.bits,xt){t.msg="invalid literal/lengths set",i.mode=ct;break}if(i.distbits=6,i.distcode=i.distdyn,kt={bits:i.distbits},xt=x(S,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,kt),i.distbits=kt.bits,xt){t.msg="invalid distances set",i.mode=ct;break}if(i.mode=et,e===A)break t;case et:i.mode=it;case it:if(l>=6&&h>=258){t.next_out=s,t.avail_out=h,t.next_in=o,t.avail_in=l,i.hold=u,i.bits=p,y(t,m),s=t.next_out,a=t.output,h=t.avail_out,o=t.next_in,r=t.input,l=t.avail_in,u=i.hold,p=i.bits,i.mode===Y&&(i.back=-1);break}for(i.back=0;St=i.lencode[u&(1<>>24,gt=St>>>16&255,bt=65535&St,!(mt<=p);){if(0===l)break t;l--,u+=r[o++]<>vt)],mt=St>>>24,gt=St>>>16&255,bt=65535&St,!(vt+mt<=p);){if(0===l)break t;l--,u+=r[o++]<>>=vt,p-=vt,i.back+=vt}if(u>>>=mt,p-=mt,i.back+=mt,i.length=bt,0===gt){i.mode=st;break}if(32>){i.back=-1,i.mode=Y;break}if(64>){t.msg="invalid literal/length code",i.mode=ct;break}i.extra=15>,i.mode=nt;case nt:if(i.extra){for(Et=i.extra;p>>=i.extra,p-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=rt;case rt:for(;St=i.distcode[u&(1<>>24,gt=St>>>16&255,bt=65535&St,!(mt<=p);){if(0===l)break t;l--,u+=r[o++]<>vt)],mt=St>>>24,gt=St>>>16&255,bt=65535&St,!(vt+mt<=p);){if(0===l)break t;l--,u+=r[o++]<>>=vt,p-=vt,i.back+=vt}if(u>>>=mt,p-=mt,i.back+=mt,64>){t.msg="invalid distance code",i.mode=ct;break}i.offset=bt,i.extra=15>,i.mode=at;case at:if(i.extra){for(Et=i.extra;p>>=i.extra,p-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=ct;break}i.mode=ot;case ot:if(0===h)break t;if(g=m-h,i.offset>g){if(g=i.offset-g,g>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=ct;break}g>i.wnext?(g-=i.wnext,b=i.wsize-g):b=i.wnext-g,g>i.length&&(g=i.length),dt=i.window}else dt=a,b=s-i.offset,g=i.length;g>h&&(g=h),h-=g,i.length-=g;do a[s++]=dt[b++];while(--g);0===i.length&&(i.mode=it);break;case st:if(0===h)break t;a[s++]=i.length,h--,i.mode=it;break;case lt:if(i.wrap){for(;p<32;){if(0===l)break t;l--,u|=r[o++]<=1&&0===j[P];P--);if(C>P&&(C=P),0===P)return m[g++]=20971520,m[g++]=20971520,v.bits=1,0;for(L=1;L0&&(t===s||1!==P))return-1;for(H[1]=0,T=1;Ta||t===h&&D>o)return 1;for(var q=0;;){q++,S=T-z,b[R]E?(I=G[W+b[R]],M=N[F+b[R]]):(I=96,M=0),w=1<>z)+_]=S<<24|I<<16|M|0;while(0!==_);for(w=1<>=1;if(0!==w?(U&=w-1,U+=w):U=0,R++,0===--j[T]){if(T===P)break;T=e[i+b[R]]}if(T>C&&(U&x)!==y){for(0===z&&(z=C),k+=L,B=T-z,O=1<a||t===h&&D>o)return 1;y=U&x,m[y]=C<<24|B<<16|k-g|0}}return 0!==U&&(m[k+U]=T-z<<24|64<<16|0),v.bits=C,0}},{"../utils/common":43}],51:[function(t,e,i){"use strict";e.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"}},{}],52:[function(t,e,i){"use strict";function n(t){for(var e=t.length;--e>=0;)t[e]=0}function r(t,e,i,n,r){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=t&&t.length}function a(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function o(t){return t<256?lt[t]:lt[256+(t>>>7)]}function s(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function l(t,e,i){t.bi_valid>V-i?(t.bi_buf|=e<>V-t.bi_valid,t.bi_valid+=i-V):(t.bi_buf|=e<>>=1,i<<=1;while(--e>0);return i>>>1}function c(t){16===t.bi_valid?(s(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}function u(t,e){var i,n,r,a,o,s,l=e.dyn_tree,h=e.max_code,f=e.stat_desc.static_tree,c=e.stat_desc.has_stree,u=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,d=e.stat_desc.max_length,m=0;for(a=0;a<=X;a++)t.bl_count[a]=0;for(l[2*t.heap[t.heap_max]+1]=0,i=t.heap_max+1;id&&(a=d,m++),l[2*n+1]=a,n>h||(t.bl_count[a]++,o=0,n>=p&&(o=u[n-p]),s=l[2*n],t.opt_len+=s*(a+o),c&&(t.static_len+=s*(f[2*n+1]+o)));if(0!==m){do{for(a=d-1;0===t.bl_count[a];)a--;t.bl_count[a]--,t.bl_count[a+1]+=2,t.bl_count[d]--,m-=2}while(m>0);for(a=d;0!==a;a--)for(n=t.bl_count[a];0!==n;)r=t.heap[--i],r>h||(l[2*r+1]!==a&&(t.opt_len+=(a-l[2*r+1])*l[2*r],l[2*r+1]=a),n--)}}function p(t,e,i){var n,r,a=new Array(X+1),o=0;for(n=1;n<=X;n++)a[n]=o=o+i[n-1]<<1;for(r=0;r<=e;r++){var s=t[2*r+1];0!==s&&(t[2*r]=f(a[s]++,s))}}function d(){var t,e,i,n,a,o=new Array(X+1);for(i=0,n=0;n>=7;n8?s(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function b(t,e,i,n){g(t),n&&(s(t,i),s(t,~i)),P.arraySet(t.pending_buf,t.window,e,i,t.pending),t.pending+=i}function v(t,e,i,n){var r=2*e,a=2*i;return t[r]>1;i>=1;i--)w(t,a,i);r=l;do i=t.heap[1],t.heap[1]=t.heap[t.heap_len--],w(t,a,1),n=t.heap[1],t.heap[--t.heap_max]=i,t.heap[--t.heap_max]=n,a[2*r]=a[2*i]+a[2*n],t.depth[r]=(t.depth[i]>=t.depth[n]?t.depth[i]:t.depth[n])+1,a[2*i+1]=a[2*n+1]=r,t.heap[1]=r++,w(t,a,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],u(t,e),p(a,h,t.bl_count)}function x(t,e,i){var n,r,a=-1,o=e[1],s=0,l=7,h=4;for(0===o&&(l=138,h=3),e[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=e[2*(n+1)+1],++s=3&&0===t.bl_tree[2*rt[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}function S(t,e,i,n){var r;for(l(t,e-257,5),l(t,i-1,5),l(t,n-4,4),r=0;r>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return B;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return z;for(e=32;e0?(t.strm.data_type===O&&(t.strm.data_type=I(t)),y(t,t.l_desc),y(t,t.d_desc),o=E(t),r=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,a<=r&&(r=a)):r=a=i+5,i+4<=r&&e!==-1?A(t,e,i,n):t.strategy===C||a===r?(l(t,(U<<1)+(n?1:0),3),_(t,ot,st)):(l(t,(N<<1)+(n?1:0),3),S(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),_(t,t.dyn_ltree,t.dyn_dtree)),m(t),n&&g(t)}function L(t,e,i){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(ht[i]+G+1)]++,t.dyn_dtree[2*o(e)]++),t.last_lit===t.lit_bufsize-1}var P=t("../utils/common"),C=4,B=0,z=1,O=2,D=0,U=1,N=2,F=3,j=258,H=29,G=256,W=G+1+H,q=30,Z=19,Y=2*W+1,X=15,V=16,J=7,$=256,K=16,Q=17,tt=18,et=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],it=[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],nt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],rt=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],at=512,ot=new Array(2*(W+2));n(ot);var st=new Array(2*q);n(st);var lt=new Array(at);n(lt);var ht=new Array(j-F+1);n(ht);var ft=new Array(H);n(ft);var ct=new Array(q);n(ct);var ut,pt,dt,mt=!1;i._tr_init=M,i._tr_stored_block=A,i._tr_flush_block=R,i._tr_tally=L,i._tr_align=T},{"../utils/common":43}],53:[function(t,e,i){"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}e.exports=n},{}],54:[function(t,e,i){function n(t,e){if(t=t.replace(/\t+/g," ").trim(),!t)return null;var i=t.indexOf(" ");if(i===-1)throw new Error("no named row at line "+e);var n=t.substring(0,i);t=t.substring(i+1),t=t.replace(/letter=[\'\"]\S+[\'\"]/gi,""),t=t.split("="),t=t.map(function(t){return t.trim().match(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g)});for(var a=[],o=0;oe.length-1)return 0;var n=e.readUInt8(i++),h=e.readInt32LE(i);switch(i+=4,n){case 1:t.info=r(e,i);break;case 2:t.common=a(e,i);break;case 3:t.pages=o(e,i,h);break;case 4:t.chars=s(e,i,h);break;case 5:t.kernings=l(e,i,h)}return 5+h}function r(t,e){var i={};i.size=t.readInt16LE(e);var n=t.readUInt8(e+2);return i.smooth=n>>7&1,i.unicode=n>>6&1,i.italic=n>>5&1,i.bold=n>>4&1,n>>3&1&&(i.fixedHeight=1),i.charset=t.readUInt8(e+3)||"",i.stretchH=t.readUInt16LE(e+4),i.aa=t.readUInt8(e+6),i.padding=[t.readInt8(e+7),t.readInt8(e+8),t.readInt8(e+9),t.readInt8(e+10)],i.spacing=[t.readInt8(e+11),t.readInt8(e+12)],i.outline=t.readUInt8(e+13),i.face=f(t,e+14),i}function a(t,e){var i={};i.lineHeight=t.readUInt16LE(e),i.base=t.readUInt16LE(e+2),i.scaleW=t.readUInt16LE(e+4),i.scaleH=t.readUInt16LE(e+6),i.pages=t.readUInt16LE(e+8);t.readUInt8(e+10);return i.packed=0,i.alphaChnl=t.readUInt8(e+11),i.redChnl=t.readUInt8(e+12),i.greenChnl=t.readUInt8(e+13),i.blueChnl=t.readUInt8(e+14),i}function o(t,e,i){for(var n=[],r=h(t,e),a=r.length+1,o=i/a,s=0;s3)throw new Error("Only supports BMFont Binary v3 (BMFont App v1.10)");for(var a={kernings:[],chars:[]},o=0;o<5;o++)i+=n(a,t,i);return a}},{}],56:[function(t,e,i){function n(t){var e=r(t);return e.reduce(function(t,e){var i=a(e.nodeName);return t[i]=e.nodeValue,t},{})}function r(t){for(var e=[],i=0;i element");for(var a=r.getElementsByTagName("page"),l=0;l=0;n--){var r=t[n];"."===r?t.splice(n,1):".."===r?(t.splice(n,1),i++):i&&(t.splice(n,1),i--)}if(e)for(;i--;i)t.unshift("..");return t}function n(t,e){if(t.filter)return t.filter(e);for(var i=[],n=0;n=-1&&!r;a--){var o=a>=0?arguments[a]:t.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(i=o+"/"+i,r="/"===o.charAt(0))}return i=e(n(i.split("/"),function(t){return!!t}),!r).join("/"),(r?"/":"")+i||"."},i.normalize=function(t){var r=i.isAbsolute(t),a="/"===o(t,-1);return t=e(n(t.split("/"),function(t){return!!t}),!r).join("/"),t||r||(t="."),t&&a&&(t+="/"),(r?"/":"")+t},i.isAbsolute=function(t){return"/"===t.charAt(0)},i.join=function(){var t=Array.prototype.slice.call(arguments,0);return i.normalize(n(t,function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},i.relative=function(t,e){function n(t){for(var e=0;e=0&&""===t[i];i--);return e>i?[]:t.slice(e,i-e+1)}t=i.resolve(t).substr(1),e=i.resolve(e).substr(1);for(var r=n(t.split("/")),a=n(e.split("/")),o=Math.min(r.length,a.length),s=o,l=0;lu)s.includeAA||!r(t,m,d,n,o,e)&&!r(e,m,d,n,o,t)?(i&&f(i,g,255,0,0),p++):i&&f(i,g,255,255,0);else if(i){var v=h(c(t,g),.1);f(i,g,v,v,v)}}return p}function r(t,e,i,n,o,s){for(var l,h,f,c,u=Math.max(e-1,0),p=Math.max(i-1,0),d=Math.min(e+1,n-1),m=Math.min(i+1,o-1),g=4*(i*n+e),b=0,v=0,w=0,_=0,y=0,x=u;x<=d;x++)for(var k=p;k<=m;k++)if(x!==e||k!==i){var E=a(t,t,g,4*(k*n+x),!0);if(0===E?b++:E<0?w++:E>0&&v++,b>2)return!1;s&&(E<_&&(_=E,l=x,h=k),E>y&&(y=E,f=x,c=k))}return!s||0!==w&&0!==v&&(!r(t,l,h,n,o)&&!r(s,l,h,n,o)||!r(t,f,c,n,o)&&!r(s,f,c,n,o))}function a(t,e,i,n,r){var a=t[i+3]/255,f=e[n+3]/255,c=h(t[i+0],a),u=h(t[i+1],a),p=h(t[i+2],a),d=h(e[n+0],f),m=h(e[n+1],f),g=h(e[n+2],f),b=o(c,u,p)-o(d,m,g);if(r)return b;var v=s(c,u,p)-s(d,m,g),w=l(c,u,p)-l(d,m,g);return.5053*b*b+.299*v*v+.1957*w*w}function o(t,e,i){return.29889531*t+.58662247*e+.11448223*i}function s(t,e,i){return.59597799*t-.2741761*e-.32180189*i}function l(t,e,i){return.21147017*t-.52261711*e+.31114694*i}function h(t,e){return 255+(t-255)*e}function f(t,e,i,n,r){t[e+0]=i,t[e+1]=n,t[e+2]=r,t[e+3]=255}function c(t,e){var i=t[e+3]/255,n=h(t[e+0],i),r=h(t[e+1],i),a=h(t[e+2],i);return o(n,r,a)}e.exports=n},{}],61:[function(t,e,i){(function(e){"use strict";function n(t,e){function i(){if(r===t.length)throw new Error("Ran out of data");var i=t[r];r++;var a,o,s,l,h,f,c,u;switch(e){default:throw new Error("unrecognised depth");case 16:c=t[r],r++,n.push((i<<8)+c);break;case 4:c=15&i,u=i>>4,n.push(u,c);break;case 2:h=3&i,f=i>>2&3,c=i>>4&3,u=i>>6&3,n.push(u,c,f,h);break;case 1:a=1&i,o=i>>1&1,s=i>>2&1,l=i>>3&1,h=i>>4&1,f=i>>5&1,c=i>>6&1,u=i>>7&1,n.push(u,c,f,h,l,s,o,a)}}var n=[],r=0;return{get:function(t){for(;n.length0&&(this._paused=!1,this.emit("drain"))}.bind(this))},o.prototype.write=function(t,e){if(!this.writable)return this.emit("error",new Error("Stream not writable")),!1;var i;return i=n.isBuffer(t)?t:new n(t,e||this._encoding),this._buffers.push(i),this._buffered+=i.length,this._process(),this._reads&&0===this._reads.length&&(this._paused=!0),this.writable&&!this._paused},o.prototype.end=function(t,e){t&&this.write(t,e),this.writable=!1,this._buffers&&(0===this._buffers.length?this._end():(this._buffers.push(null),this._process()))},o.prototype.destroySoon=o.prototype.end,o.prototype._end=function(){this._reads.length>0&&this.emit("error",new Error("There are some read requests waiting on finished stream")),this.destroy()},o.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},o.prototype._processReadAllowingLess=function(t){this._reads.shift();var e=this._buffers[0];e.length>t.length?(this._buffered-=t.length,this._buffers[0]=e.slice(t.length),t.func.call(this,e.slice(0,t.length))):(this._buffered-=e.length,this._buffers.shift(),t.func.call(this,e))},o.prototype._processRead=function(t){this._reads.shift();for(var e=0,i=0,r=new n(t.length);e0&&this._buffers.splice(0,i),this._buffered-=t.length,t.func.call(this,r)},o.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){var t=this._reads[0];if(t.allowLess)this._processReadAllowingLess(t);else{if(!(this._buffered>=t.length))break;this._processRead(t)}}this._buffers&&this._buffers.length>0&&null===this._buffers[0]&&this._end()}catch(t){this.emit("error",t)}}}).call(this,t("_process"),t("buffer").Buffer)},{_process:12,buffer:14,stream:94,util:103}],64:[function(t,e,i){"use strict";e.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}},{}],65:[function(t,e,i){"use strict";var n=[];!function(){for(var t=0;t<256;t++){for(var e=t,i=0;i<8;i++)1&e?e=3988292384^e>>>1:e>>>=1;n[t]=e}}();var r=e.exports=function(){this._crc=-1};r.prototype.write=function(t){for(var e=0;e>>8;return!0},r.prototype.crc32=function(){return this._crc^-1},r.crc32=function(t){for(var e=-1,i=0;i>>8;return e^-1}},{}],66:[function(t,e,i){(function(i){"use strict";function n(t,e,i,n,r){t.copy(n,r,e,e+i)}function r(t,e,i){for(var n=0,r=e+i,a=e;a=a?t[e+o-a]:0,l=t[e+o]-s;n[r+o]=l}}function o(t,e,i,n){for(var r=0,a=0;a=n?t[e+a-n]:0,s=t[e+a]-o;r+=Math.abs(s)}return r}function s(t,e,i,n,r){for(var a=0;a0?t[e+a-i]:0,s=t[e+a]-o;n[r+a]=s}}function l(t,e,i){for(var n=0,r=e+i,a=e;a0?t[a-i]:0,s=t[a]-o;n+=Math.abs(s)}return n}function h(t,e,i,n,r,a){for(var o=0;o=a?t[e+o-a]:0,l=e>0?t[e+o-i]:0,h=t[e+o]-(s+l>>1);n[r+o]=h}}function f(t,e,i,n){for(var r=0,a=0;a=n?t[e+a-n]:0,s=e>0?t[e+a-i]:0,l=t[e+a]-(o+s>>1);r+=Math.abs(l)}return r}function c(t,e,i,n,r,a){for(var o=0;o=a?t[e+o-a]:0,l=e>0?t[e+o-i]:0,h=e>0&&o>=a?t[e+o-(i+a)]:0,f=t[e+o]-p(s,l,h);n[r+o]=f}}function u(t,e,i,n){for(var r=0,a=0;a=n?t[e+a-n]:0,s=e>0?t[e+a-i]:0,l=e>0&&a>=n?t[e+a-(i+n)]:0,h=t[e+a]-p(o,s,l);r+=Math.abs(h)}return r}var p=t("./paeth-predictor"),d={0:n,1:a,2:s,3:h,4:c},m={0:r,1:o,2:l,3:f,4:u};e.exports=function(t,e,n,r,a){var o;if("filterType"in r&&r.filterType!==-1){if("number"!=typeof r.filterType)throw new Error("unrecognised filter types");o=[r.filterType]}else o=[0,1,2,3,4];for(var s=e*a,l=0,h=0,f=new i((s+1)*n),c=o[0],u=0;u1)for(var p=1/0,g=0;gr?e[a-n]:0;e[a]=o+s}},o.prototype._unFilterType2=function(t,e,i){for(var n=this._lastLine,r=0;rr?e[o-n]:0,f=Math.floor((h+l)/2);e[o]=s+f}},o.prototype._unFilterType4=function(t,e,i){for(var n=this._xComparison,r=n-1,o=this._lastLine,s=0;sr?e[s-n]:0,c=s>r&&o?o[s-n]:0,u=a(f,h,c);e[s]=l+u}},o.prototype._reverseFilterLine=function(t){var e,n=t[0],r=this._images[this._imageIndex],a=r.byteWidth;if(0===n)e=t.slice(1,a+1);else switch(e=new i(a),n){case 1:this._unFilterType1(t,e,a);break;case 2:this._unFilterType2(t,e,a);break;case 3:this._unFilterType3(t,e,a);break;case 4:this._unFilterType4(t,e,a);break;default:throw new Error("Unrecognised filter type - "+n)}this.write(e),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=e,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}}).call(this,t("buffer").Buffer)},{"./interlace":71,"./paeth-predictor":75,buffer:14}],70:[function(t,e,i){(function(t){"use strict";function i(t,e,i,n,r){for(var a=0,o=0;o0&&c>0&&i.push({width:f,height:c,index:l})}return i},i.getInterlaceIterator=function(t){return function(e,i,r){var a=e%n[r].x.length,o=(e-a)/n[r].x.length*8+n[r].x[a],s=i%n[r].y.length,l=(i-s)/n[r].y.length*8+n[r].y[s];return 4*o+l*t*4}}},{}],72:[function(t,e,i){(function(i){"use strict";var n=t("util"),r=t("stream"),a=t("./constants"),o=t("./packer"),s=e.exports=function(t){r.call(this);var e=t||{};this._packer=new o(e),this._deflate=this._packer.createDeflate(),this.readable=!0};n.inherits(s,r),s.prototype.pack=function(t,e,n,r){this.emit("data",new i(a.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(e,n)),r&&this.emit("data",this._packer.packGAMA(r));var o=this._packer.filterData(t,e,n);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(t){this.emit("data",this._packer.packIDAT(t))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(o)}}).call(this,t("buffer").Buffer)},{"./constants":64,"./packer":74,buffer:14,stream:94,util:103}],73:[function(t,e,i){(function(i){"use strict";var n=!0,r=t("zlib"),a=t("./constants"),o=t("./packer");e.exports=function(t,e){if(!n)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");var s=e||{},l=new o(s),h=[];h.push(new i(a.PNG_SIGNATURE)),h.push(l.packIHDR(t.width,t.height)),t.gamma&&h.push(l.packGAMA(t.gamma));var f=l.filterData(t.data,t.width,t.height),c=r.deflateSync(f,l.getDeflateOptions());if(f=null,!c||!c.length)throw new Error("bad png - invalid compressed data response");return h.push(l.packIDAT(c)),h.push(l.packIEND()),i.concat(h)}}).call(this,t("buffer").Buffer)},{"./constants":64,"./packer":74,buffer:14,zlib:10}],74:[function(t,e,i){(function(i){"use strict";var n=t("./constants"),r=t("./crc"),a=t("./bitpacker"),o=t("./filter-pack"),s=t("zlib"),l=e.exports=function(t){if(this._options=t,t.deflateChunkSize=t.deflateChunkSize||32768,t.deflateLevel=null!=t.deflateLevel?t.deflateLevel:9,t.deflateStrategy=null!=t.deflateStrategy?t.deflateStrategy:3,t.inputHasAlpha=null==t.inputHasAlpha||t.inputHasAlpha,t.deflateFactory=t.deflateFactory||s.createDeflate,t.bitDepth=t.bitDepth||8,t.colorType="number"==typeof t.colorType?t.colorType:n.COLORTYPE_COLOR_ALPHA,t.colorType!==n.COLORTYPE_COLOR&&t.colorType!==n.COLORTYPE_COLOR_ALPHA)throw new Error("option color type:"+t.colorType+" is not supported at present");if(8!==t.bitDepth)throw new Error("option bit depth:"+t.bitDepth+" is not supported at present")};l.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},l.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},l.prototype.filterData=function(t,e,i){var r=a(t,e,i,this._options),s=n.COLORTYPE_TO_BPP_MAP[this._options.colorType],l=o(r,e,i,this._options,s);return l},l.prototype._packChunk=function(t,e){var n=e?e.length:0,a=new i(n+12);return a.writeUInt32BE(n,0),a.writeUInt32BE(t,4),e&&e.copy(a,8),a.writeInt32BE(r.crc32(a.slice(4,a.length-4)),a.length-4),a},l.prototype.packGAMA=function(t){var e=new i(4);return e.writeUInt32BE(Math.floor(t*n.GAMMA_DIVISION),0),this._packChunk(n.TYPE_gAMA,e)},l.prototype.packIHDR=function(t,e){var r=new i(13);return r.writeUInt32BE(t,0),r.writeUInt32BE(e,4),r[8]=this._options.bitDepth,r[9]=this._options.colorType,r[10]=0,r[11]=0,r[12]=0,this._packChunk(n.TYPE_IHDR,r)},l.prototype.packIDAT=function(t){return this._packChunk(n.TYPE_IDAT,t)},l.prototype.packIEND=function(){return this._packChunk(n.TYPE_IEND,null)}}).call(this,t("buffer").Buffer)},{"./bitpacker":62,"./constants":64,"./crc":65,"./filter-pack":66,buffer:14,zlib:10}],75:[function(t,e,i){"use strict";e.exports=function(t,e,i){var n=t+e-i,r=Math.abs(n-t),a=Math.abs(n-e),o=Math.abs(n-i);return r<=a&&r<=o?t:a<=o?e:i}},{}],76:[function(t,e,i){"use strict";var n=t("util"),r=t("zlib"),a=t("./chunkstream"),o=t("./filter-parse-async"),s=t("./parser"),l=t("./bitmapper"),h=t("./format-normaliser"),f=e.exports=function(t){a.call(this),this._parser=new s(t,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this)}),this._options=t,this.writable=!0,this._parser.start()};n.inherits(f,a),f.prototype._handleError=function(t){this.emit("error",t),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this.errord=!0},f.prototype._inflateData=function(t){this._inflate||(this._inflate=r.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter)),this._inflate.write(t)},f.prototype._handleMetaData=function(t){this.emit("metadata",t),this._bitmapInfo=Object.create(t),this._filter=new o(this._bitmapInfo)},f.prototype._handleTransColor=function(t){this._bitmapInfo.transColor=t},f.prototype._handlePalette=function(t){this._bitmapInfo.palette=t},f.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"),this.destroySoon())},f.prototype._complete=function(t){if(!this.errord){try{var e=l.dataToBitMap(t,this._bitmapInfo),i=h(e,this._bitmapInfo);e=null}catch(t){return void this._handleError(t)}this.emit("parsed",i)}}},{"./bitmapper":61,"./chunkstream":63,"./filter-parse-async":67,"./format-normaliser":70,"./parser":78,util:103,zlib:10}],77:[function(t,e,i){(function(i){"use strict";var n=!0,r=t("zlib"),a=t("./sync-reader"),o=t("./filter-parse-sync"),s=t("./parser"),l=t("./bitmapper"),h=t("./format-normaliser");e.exports=function(t,e){function f(t){g=t}function c(t){b=t}function u(t){b.transColor=t}function p(t){b.palette=t}function d(t){v=t}function m(t){w.push(t)}if(!n)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");var g,b,v,w=[],_=new a(t),y=new s(e,{read:_.read.bind(_),error:f,metadata:c,gamma:d,palette:p,transColor:u,inflateData:m});if(y.start(),_.process(),g)throw g;var x=i.concat(w);w.length=0;var k=r.inflateSync(x);if(x=null,!k||!k.length)throw new Error("bad png - invalid inflate data response");var E=o.process(k,b);x=null;var S=l.dataToBitMap(E,b);E=null;var I=h(S,b);return b.data=I,b.gamma=v||0,b}}).call(this,t("buffer").Buffer)},{"./bitmapper":61,"./filter-parse-sync":68,"./format-normaliser":70,"./parser":78,"./sync-reader":81,buffer:14,zlib:10}],78:[function(t,e,i){(function(i){"use strict";var n=t("./constants"),r=t("./crc"),a=e.exports=function(t,e){this._options=t,t.checkCRC=t.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[n.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[n.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[n.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[n.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[n.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[n.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=e.read,this.error=e.error,this.metadata=e.metadata,this.gamma=e.gamma,this.transColor=e.transColor,this.palette=e.palette,this.parsed=e.parsed,this.inflateData=e.inflateData,this.inflateData=e.inflateData,this.finished=e.finished};a.prototype.start=function(){this.read(n.PNG_SIGNATURE.length,this._parseSignature.bind(this))},a.prototype._parseSignature=function(t){ +for(var e=n.PNG_SIGNATURE,i=0;ithis._palette.length)return void this.error(new Error("More transparent colors than palette size"));for(var e=0;e0?this._handleIDAT(i):this._handleChunkEnd()},a.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))},a.prototype._parseIEND=function(t){this._crc.write(t),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}}).call(this,t("buffer").Buffer)},{"./constants":64,"./crc":65,buffer:14}],79:[function(t,e,i){"use strict";var n=t("./parser-sync"),r=t("./packer-sync");i.read=function(t,e){return n(t,e||{})},i.write=function(t){return r(t)}},{"./packer-sync":73,"./parser-sync":77}],80:[function(t,e,i){(function(e,n){"use strict";var r=t("util"),a=t("stream"),o=t("./parser-async"),s=t("./packer-async"),l=t("./png-sync"),h=i.PNG=function(t){a.call(this),t=t||{},this.width=t.width||0,this.height=t.height||0,this.data=this.width>0&&this.height>0?new n(4*this.width*this.height):null,t.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new o(t),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(t){this.data=t,this.emit("parsed",t)}.bind(this)),this._packer=new s(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};r.inherits(h,a),h.sync=l,h.prototype.pack=function(){return this.data&&this.data.length?(e.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this):(this.emit("error","No data provided"),this)},h.prototype.parse=function(t,e){if(e){var i,n;i=function(t){this.removeListener("error",n),this.data=t,e(null,this)}.bind(this),n=function(t){this.removeListener("parsed",i),e(t,null)}.bind(this),this.once("parsed",i),this.once("error",n)}return this.end(t),this},h.prototype.write=function(t){return this._parser.write(t),!0},h.prototype.end=function(t){this._parser.end(t)},h.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.emit("metadata",t)},h.prototype._gamma=function(t){this.gamma=t},h.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},h.bitblt=function(t,e,i,n,r,a,o,s){if(i>t.width||n>t.height||i+r>t.width||n+a>t.height)throw new Error("bitblt reading outside image");if(o>e.width||s>e.height||o+r>e.width||s+a>e.height)throw new Error("bitblt writing outside image");for(var l=0;l0&&this._buffer.length;){var t=this._reads[0];if(!this._buffer.length||!(this._buffer.length>=t.length||t.allowLess))break;this._reads.shift();var e=this._buffer;this._buffer=e.slice(t.length),t.func.call(this,e.slice(0,t.length))}return this._reads.length>0?new Error("There are some read requests waitng on finished stream"):this._buffer.length>0?new Error("unrecognised content at end of stream"):void 0}},{}],82:[function(t,e,i){(function(t){"use strict";function i(e,i,n,r){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var a,o,s=arguments.length;switch(s){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,i)});case 3:return t.nextTick(function(){e.call(null,i,n)});case 4:return t.nextTick(function(){e.call(null,i,n,r)});default:for(a=new Array(s-1),o=0;o0)if(e.ended&&!r){var s=new Error("stream.push() after EOF");t.emit("error",s)}else if(e.endEmitted&&r){var s=new Error("stream.unshift() after end event");t.emit("error",s)}else{var l;!e.decoder||r||n||(i=e.decoder.write(i),l=!e.objectMode&&0===i.length),r||(e.reading=!1),l||(e.flowing&&0===e.length&&!e.sync?(t.emit("data",i),t.read(0)):(e.length+=e.objectMode?1:i.length,r?e.buffer.unshift(i):e.buffer.push(i),e.needReadable&&c(t))),p(t,e)}else r||(e.reading=!1);return o(e)}function o(t){return!t.ended&&(t.needReadable||t.length=z?t=z:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function l(t,e){return 0===e.length&&e.ended?0:e.objectMode?0===t?0:1:null===t||isNaN(t)?e.flowing&&e.buffer.length?e.buffer[0].length:e.length:t<=0?0:(t>e.highWaterMark&&(e.highWaterMark=s(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function h(t,e){var i=null;return M.isBuffer(e)||"string"==typeof e||null===e||void 0===e||t.objectMode||(i=new TypeError("Invalid non-string/buffer chunk")),i}function f(t,e){if(!e.ended){if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,c(t)}}function c(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(P("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?S(u,t):u(t))}function u(t){P("emit readable"),t.emit("readable"),w(t)}function p(t,e){e.readingMore||(e.readingMore=!0,S(d,t,e))}function d(t,e){for(var i=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=r)i=a?n.join(""):1===n.length?n[0]:M.concat(n,r),n.length=0;else if(t0)throw new Error("endReadable called on non-empty stream");e.endEmitted||(e.ended=!0,S(x,e,t))}function x(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function k(t,e){for(var i=0,n=t.length;i0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return P("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?y(this):c(this),null;if(t=l(t,e),0===t&&e.ended)return 0===e.length&&y(this),null;var n=e.needReadable;P("need readable",n),(0===e.length||e.length-t0?_(t,e):null,null===r&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),i!==t&&e.ended&&0===e.length&&y(this),null!==r&&this.emit("data",r),r},r.prototype._read=function(t){this.emit("error",new Error("not implemented"))},r.prototype.pipe=function(t,e){function n(t){P("onunpipe"),t===c&&a()}function r(){P("onend"),t.end()}function a(){P("cleanup"),t.removeListener("close",l),t.removeListener("finish",h),t.removeListener("drain",g),t.removeListener("error",s),t.removeListener("unpipe",n),c.removeListener("end",r),c.removeListener("end",a),c.removeListener("data",o),b=!0,!u.awaitDrain||t._writableState&&!t._writableState.needDrain||g()}function o(e){P("ondata");var i=t.write(e);!1===i&&(1!==u.pipesCount||u.pipes[0]!==t||1!==c.listenerCount("data")||b||(P("false write response, pause",c._readableState.awaitDrain),c._readableState.awaitDrain++),c.pause())}function s(e){P("onerror",e),f(),t.removeListener("error",s),0===T(t,"error")&&t.emit("error",e)}function l(){t.removeListener("finish",h),f()}function h(){P("onfinish"),t.removeListener("close",l),f()}function f(){P("unpipe"),c.unpipe(t)}var c=this,u=this._readableState;switch(u.pipesCount){case 0:u.pipes=t;break;case 1:u.pipes=[u.pipes,t];break;default:u.pipes.push(t)}u.pipesCount+=1,P("pipe count=%d opts=%j",u.pipesCount,e);var p=(!e||e.end!==!1)&&t!==i.stdout&&t!==i.stderr,d=p?r:a;u.endEmitted?S(d):c.once("end",d),t.on("unpipe",n);var g=m(c);t.on("drain",g);var b=!1;return c.on("data",o),t._events&&t._events.error?I(t._events.error)?t._events.error.unshift(s):t._events.error=[s,t._events.error]:t.on("error",s),t.once("close",l),t.once("finish",h),t.emit("pipe",c),u.flowing||(P("pipe resume"),c.resume()),t},r.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var i=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var r=0;r-1?setImmediate:k,S=t("buffer").Buffer;o.WritableState=a;var I=t("core-util-is");I.inherits=t("inherits");var M,A={deprecate:t("util-deprecate")};!function(){try{M=t("stream")}catch(t){}finally{M||(M=t("events").EventEmitter)}}();var S=t("buffer").Buffer;I.inherits(o,M);var T;a.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(a.prototype,"buffer",{get:A.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(t){}}();var T;o.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},o.prototype.write=function(t,e,i){var r=this._writableState,a=!1;return"function"==typeof e&&(i=e,e=null),S.isBuffer(t)?e="buffer":e||(e=r.defaultEncoding),"function"!=typeof i&&(i=n),r.ended?s(this,i):l(this,r,t,i)&&(r.pendingcb++,a=f(this,r,t,e,i)),a},o.prototype.cork=function(){var t=this._writableState;t.corked++},o.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.finished||t.bufferProcessing||!t.bufferedRequest||b(this,t))},o.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);this._writableState.defaultEncoding=t},o.prototype._write=function(t,e,i){i(new Error("not implemented"))},o.prototype._writev=null,o.prototype.end=function(t,e,i){var n=this._writableState;"function"==typeof t?(i=t,t=null,e=null):"function"==typeof e&&(i=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||y(this,n,i)}}).call(this,t("_process"))},{"./_stream_duplex":85,_process:12,buffer:14,"core-util-is":15,events:17,inherits:31,"process-nextick-args":82,"util-deprecate":101}],90:[function(t,e,i){e.exports=t("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":86}],91:[function(t,e,i){var n=function(){try{return t("stream")}catch(t){}}();i=e.exports=t("./lib/_stream_readable.js"),i.Stream=n||i,i.Readable=i,i.Writable=t("./lib/_stream_writable.js"),i.Duplex=t("./lib/_stream_duplex.js"),i.Transform=t("./lib/_stream_transform.js"),i.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":85,"./lib/_stream_passthrough.js":86,"./lib/_stream_readable.js":87,"./lib/_stream_transform.js":88,"./lib/_stream_writable.js":89}],92:[function(t,e,i){e.exports=t("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":88}],93:[function(t,e,i){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":89}],94:[function(t,e,i){function n(){r.call(this)}e.exports=n;var r=t("events").EventEmitter,a=t("inherits");a(n,r),n.Readable=t("readable-stream/readable.js"),n.Writable=t("readable-stream/writable.js"),n.Duplex=t("readable-stream/duplex.js"),n.Transform=t("readable-stream/transform.js"),n.PassThrough=t("readable-stream/passthrough.js"),n.Stream=n,n.prototype.pipe=function(t,e){function i(e){t.writable&&!1===t.write(e)&&h.pause&&h.pause()}function n(){h.readable&&h.resume&&h.resume()}function a(){f||(f=!0,t.end())}function o(){f||(f=!0,"function"==typeof t.destroy&&t.destroy())}function s(t){if(l(),0===r.listenerCount(this,"error"))throw t}function l(){h.removeListener("data",i),t.removeListener("drain",n),h.removeListener("end",a),h.removeListener("close",o),h.removeListener("error",s),t.removeListener("error",s),h.removeListener("end",l),h.removeListener("close",l),t.removeListener("close",l)}var h=this;h.on("data",i),t.on("drain",n),t._isStdio||e&&e.end===!1||(h.on("end",a),h.on("close",o));var f=!1;return h.on("error",s),t.on("error",s),h.on("end",l),h.on("close",l),t.on("close",l),t.emit("pipe",h),t}},{events:17,inherits:31,"readable-stream/duplex.js":84,"readable-stream/passthrough.js":90,"readable-stream/readable.js":91,"readable-stream/transform.js":92,"readable-stream/writable.js":93}],95:[function(t,e,i){e.exports=t("stream-to").buffer},{"stream-to":96}],96:[function(t,e,i){(function(t){function e(t,e){function i(t){a.push(t)}function n(){e(null,a),r()}function r(){a=null,t.removeListener("data",i),t.removeListener("end",n),t.removeListener("error",e),t.removeListener("error",r),t.removeListener("close",r)}var a=[];return t.on("data",i),t.once("end",n),t.once("error",e),t.once("error",r),t.once("close",r),t}function n(i,n){return e(i,function(e,i){e||!i?n(e):n(null,t.concat(i))}),i}i.array=e,i.buffer=n}).call(this,t("buffer").Buffer)},{buffer:14}],97:[function(t,e,i){function n(t){if(t&&!l(t))throw new Error("Unknown encoding: "+t)}function r(t){return t.toString(this.encoding)}function a(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function o(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}var s=t("buffer").Buffer,l=s.isEncoding||function(t){switch(t&&t.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}},h=i.StringDecoder=function(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),n(t),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=r)}this.charBuffer=new s(6),this.charReceived=0,this.charLength=0};h.prototype.write=function(t){for(var e="";this.charLength;){var i=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,i),this.charReceived+=i,this.charReceived=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var r=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,r),r-=this.charReceived),e+=t.toString(this.encoding,0,r);var r=e.length-1,n=e.charCodeAt(r);if(n>=55296&&n<=56319){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),t.copy(this.charBuffer,0,0,a),e.substring(0,r)}return e},h.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var i=t[t.length-e];if(1==e&&i>>5==6){this.charLength=2;break}if(e<=2&&i>>4==14){this.charLength=3;break}if(e<=3&&i>>3==30){this.charLength=4;break}}this.charReceived=e},h.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var i=this.charReceived,n=this.charBuffer,r=this.encoding;e+=n.slice(0,i).toString(r)}return e}},{buffer:14}],98:[function(t,e,i){!function(t){function i(t,e){if(t=t?t:"",e=e||{},t instanceof i)return t; +if(!(this instanceof i))return new i(t,e);var r=n(t);this._originalInput=t,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=H(100*this._a)/100,this._format=e.format||r.format,this._gradientType=e.gradientType,this._r<1&&(this._r=H(this._r)),this._g<1&&(this._g=H(this._g)),this._b<1&&(this._b=H(this._b)),this._ok=r.ok,this._tc_id=j++}function n(t){var e={r:0,g:0,b:0},i=1,n=null,a=null,s=null,h=!1,f=!1;return"string"==typeof t&&(t=D(t)),"object"==("undefined"==typeof t?"undefined":_typeof(t))&&(O(t.r)&&O(t.g)&&O(t.b)?(e=r(t.r,t.g,t.b),h=!0,f="%"===String(t.r).substr(-1)?"prgb":"rgb"):O(t.h)&&O(t.s)&&O(t.v)?(n=C(t.s),a=C(t.v),e=l(t.h,n,a),h=!0,f="hsv"):O(t.h)&&O(t.s)&&O(t.l)&&(n=C(t.s),s=C(t.l),e=o(t.h,n,s),h=!0,f="hsl"),t.hasOwnProperty("a")&&(i=t.a)),i=I(i),{ok:h,format:t.format||f,r:G(255,W(e.r,0)),g:G(255,W(e.g,0)),b:G(255,W(e.b,0)),a:i}}function r(t,e,i){return{r:255*M(t,255),g:255*M(e,255),b:255*M(i,255)}}function a(t,e,i){t=M(t,255),e=M(e,255),i=M(i,255);var n,r,a=W(t,e,i),o=G(t,e,i),s=(a+o)/2;if(a==o)n=r=0;else{var l=a-o;switch(r=s>.5?l/(2-a-o):l/(a+o),a){case t:n=(e-i)/l+(e1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}var r,a,o;if(t=M(t,360),e=M(e,100),i=M(i,100),0===e)r=a=o=i;else{var s=i<.5?i*(1+e):i+e-i*e,l=2*i-s;r=n(l,s,t+1/3),a=n(l,s,t),o=n(l,s,t-1/3)}return{r:255*r,g:255*a,b:255*o}}function s(t,e,i){t=M(t,255),e=M(e,255),i=M(i,255);var n,r,a=W(t,e,i),o=G(t,e,i),s=a,l=a-o;if(r=0===a?0:l/a,a==o)n=0;else{switch(a){case t:n=(e-i)/l+(e>1)+720)%360;--e;)r.h=(r.h+a)%360,o.push(i(r));return o}function E(t,e){e=e||6;for(var n=i(t).toHsv(),r=n.h,a=n.s,o=n.v,s=[],l=1/e;e--;)s.push(i({h:r,s:a,v:o})),o=(o+l)%1;return s}function S(t){var e={};for(var i in t)t.hasOwnProperty(i)&&(e[t[i]]=i);return e}function I(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function M(e,i){R(e)&&(e="100%");var n=L(e);return e=G(i,W(0,parseFloat(e))),n&&(e=parseInt(e*i,10)/100),t.abs(e-i)<1e-6?1:e%i/parseFloat(i)}function A(t){return G(1,W(0,t))}function T(t){return parseInt(t,16)}function R(t){return"string"==typeof t&&t.indexOf(".")!=-1&&1===parseFloat(t)}function L(t){return"string"==typeof t&&t.indexOf("%")!=-1}function P(t){return 1==t.length?"0"+t:""+t}function C(t){return t<=1&&(t=100*t+"%"),t}function B(e){return t.round(255*parseFloat(e)).toString(16)}function z(t){return T(t)/255}function O(t){return!!X.CSS_UNIT.exec(t)}function D(t){t=t.replace(N,"").replace(F,"").toLowerCase();var e=!1;if(Z[t])t=Z[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var i;return(i=X.rgb.exec(t))?{r:i[1],g:i[2],b:i[3]}:(i=X.rgba.exec(t))?{r:i[1],g:i[2],b:i[3],a:i[4]}:(i=X.hsl.exec(t))?{h:i[1],s:i[2],l:i[3]}:(i=X.hsla.exec(t))?{h:i[1],s:i[2],l:i[3],a:i[4]}:(i=X.hsv.exec(t))?{h:i[1],s:i[2],v:i[3]}:(i=X.hsva.exec(t))?{h:i[1],s:i[2],v:i[3],a:i[4]}:(i=X.hex8.exec(t))?{r:T(i[1]),g:T(i[2]),b:T(i[3]),a:z(i[4]),format:e?"name":"hex8"}:(i=X.hex6.exec(t))?{r:T(i[1]),g:T(i[2]),b:T(i[3]),format:e?"name":"hex"}:(i=X.hex4.exec(t))?{r:T(i[1]+""+i[1]),g:T(i[2]+""+i[2]),b:T(i[3]+""+i[3]),a:z(i[4]+""+i[4]),format:e?"name":"hex8"}:!!(i=X.hex3.exec(t))&&{r:T(i[1]+""+i[1]),g:T(i[2]+""+i[2]),b:T(i[3]+""+i[3]),format:e?"name":"hex"}}function U(t){var e,i;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),i=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==i&&"large"!==i&&(i="small"),{level:e,size:i}}var N=/^\s+/,F=/\s+$/,j=0,H=t.round,G=t.min,W=t.max,q=t.random;i.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,i,n,r,a,o,s=this.toRgb();return e=s.r/255,i=s.g/255,n=s.b/255,r=e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4),a=i<=.03928?i/12.92:t.pow((i+.055)/1.055,2.4),o=n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4),.2126*r+.7152*a+.0722*o},setAlpha:function(t){return this._a=I(t),this._roundA=H(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=H(360*t.h),i=H(100*t.s),n=H(100*t.v);return 1==this._a?"hsv("+e+", "+i+"%, "+n+"%)":"hsva("+e+", "+i+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=a(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=a(this._r,this._g,this._b),e=H(360*t.h),i=H(100*t.s),n=H(100*t.l);return 1==this._a?"hsl("+e+", "+i+"%, "+n+"%)":"hsla("+e+", "+i+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return h(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return f(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:H(this._r),g:H(this._g),b:H(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+H(this._r)+", "+H(this._g)+", "+H(this._b)+")":"rgba("+H(this._r)+", "+H(this._g)+", "+H(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:H(100*M(this._r,255))+"%",g:H(100*M(this._g,255))+"%",b:H(100*M(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+H(100*M(this._r,255))+"%, "+H(100*M(this._g,255))+"%, "+H(100*M(this._b,255))+"%)":"rgba("+H(100*M(this._r,255))+"%, "+H(100*M(this._g,255))+"%, "+H(100*M(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(Y[h(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+c(this._r,this._g,this._b,this._a),n=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var a=i(t);n="#"+c(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var i=!1,n=this._a<1&&this._a>=0,r=!e&&n&&("hex"===t||"hex6"===t||"hex3"===t||"hex4"===t||"hex8"===t||"name"===t);return r?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(i=this.toRgbString()),"prgb"===t&&(i=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(i=this.toHexString()),"hex3"===t&&(i=this.toHexString(!0)),"hex4"===t&&(i=this.toHex8String(!0)),"hex8"===t&&(i=this.toHex8String()),"name"===t&&(i=this.toName()),"hsl"===t&&(i=this.toHslString()),"hsv"===t&&(i=this.toHsvString()),i||this.toHexString())},clone:function(){return i(this.toString())},_applyModification:function(t,e){var i=t.apply(null,[this].concat([].slice.call(e)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(m,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(b,arguments)},desaturate:function(){return this._applyModification(u,arguments)},saturate:function(){return this._applyModification(p,arguments)},greyscale:function(){return this._applyModification(d,arguments)},spin:function(){return this._applyModification(v,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(k,arguments)},complement:function(){return this._applyCombination(w,arguments)},monochromatic:function(){return this._applyCombination(E,arguments)},splitcomplement:function(){return this._applyCombination(x,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(y,arguments)}},i.fromRatio=function(t,e){if("object"==("undefined"==typeof t?"undefined":_typeof(t))){var n={};for(var r in t)t.hasOwnProperty(r)&&("a"===r?n[r]=t[r]:n[r]=C(t[r]));t=n}return i(t,e)},i.equals=function(t,e){return!(!t||!e)&&i(t).toRgbString()==i(e).toRgbString()},i.random=function(){return i.fromRatio({r:q(),g:q(),b:q()})},i.mix=function(t,e,n){n=0===n?0:n||50;var r=i(t).toRgb(),a=i(e).toRgb(),o=n/100,s={r:(a.r-r.r)*o+r.r,g:(a.g-r.g)*o+r.g,b:(a.b-r.b)*o+r.b,a:(a.a-r.a)*o+r.a};return i(s)},i.readability=function(e,n){var r=i(e),a=i(n);return(t.max(r.getLuminance(),a.getLuminance())+.05)/(t.min(r.getLuminance(),a.getLuminance())+.05)},i.isReadable=function(t,e,n){var r,a,o=i.readability(t,e);switch(a=!1,r=U(n),r.level+r.size){case"AAsmall":case"AAAlarge":a=o>=4.5;break;case"AAlarge":a=o>=3;break;case"AAAsmall":a=o>=7}return a},i.mostReadable=function(t,e,n){var r,a,o,s,l=null,h=0;n=n||{},a=n.includeFallbackColors,o=n.level,s=n.size;for(var f=0;fh&&(h=r,l=i(e[f]));return i.isReadable(t,l,{level:o,size:s})||!a?l:(n.includeFallbackColors=!1,i.mostReadable(t,["#fff","#000"],n))};var Z=i.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Y=i.hexNames=S(Z),X=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",i="(?:"+e+")|(?:"+t+")",n="[\\s|\\(]+("+i+")[,|\\s]+("+i+")[,|\\s]+("+i+")\\s*\\)?",r="[\\s|\\(]+("+i+")[,|\\s]+("+i+")[,|\\s]+("+i+")[,|\\s]+("+i+")\\s*\\)?";return{CSS_UNIT:new RegExp(i),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof e&&e.exports?e.exports=i:"function"==typeof define&&define.amd?define(function(){return i}):window.tinycolor=i}(Math)},{}],99:[function(t,e,i){function n(t){return t.replace(/^\s*|\s*$/g,"")}i=e.exports=n,i.left=function(t){return t.replace(/^\s*/,"")},i.right=function(t){return t.replace(/\s*$/,"")}},{}],100:[function(t,e,i){"use strict";var n=t("ip-regex");e.exports=function(t){t=t||{};var e="(?:(?:[a-z]+:)?//)",i="(?:\\S+(?::\\S*)?@)?",r=n.v4().source,a="(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)",o="(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*",s="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))",l="(?::\\d{2,5})?",h='(?:[/?#][^\\s"]*)?',f=["(?:"+e+"|www\\.)"+i,"(?:localhost|"+r+"|"+a+o+s+")",l,h].join("");return t.exact?new RegExp("(?:^"+f+"$)","i"):new RegExp(f,"ig")}},{"ip-regex":32}],101:[function(t,e,i){(function(t){function i(t,e){function i(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}if(n("noDeprecation"))return t;var r=!1;return i}function n(e){try{if(!t.localStorage)return!1}catch(t){return!1}var i=t.localStorage[e];return null!=i&&"true"===String(i).toLowerCase()}e.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],102:[function(t,e,i){e.exports=function(t){return t&&"object"===("undefined"==typeof t?"undefined":_typeof(t))&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],103:[function(t,e,i){(function(e,n){function r(t,e){var n={seen:[],stylize:o};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),m(e)?n.showHidden=e:e&&i._extend(n,e),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),l(n,t,n.depth)}function a(t,e){var i=r.styles[e];return i?"["+r.colors[i][0]+"m"+t+"["+r.colors[i][1]+"m":t}function o(t,e){return t}function s(t){var e={};return t.forEach(function(t,i){e[t]=!0}),e}function l(t,e,n){if(t.customInspect&&e&&I(e.inspect)&&e.inspect!==i.inspect&&(!e.constructor||e.constructor.prototype!==e)){var r=e.inspect(n,t);return w(r)||(r=l(t,r,n)),r}var a=h(t,e);if(a)return a;var o=Object.keys(e),m=s(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),S(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(e);if(0===o.length){if(I(e)){var g=e.name?": "+e.name:"";return t.stylize("[Function"+g+"]","special")}if(x(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(E(e))return t.stylize(Date.prototype.toString.call(e),"date");if(S(e))return f(e)}var b="",v=!1,_=["{","}"];if(d(e)&&(v=!0,_=["[","]"]),I(e)){var y=e.name?": "+e.name:"";b=" [Function"+y+"]"}if(x(e)&&(b=" "+RegExp.prototype.toString.call(e)),E(e)&&(b=" "+Date.prototype.toUTCString.call(e)),S(e)&&(b=" "+f(e)),0===o.length&&(!v||0==e.length))return _[0]+b+_[1];if(n<0)return x(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var k;return k=v?c(t,e,n,m,o):o.map(function(i){return u(t,e,n,m,i,v)}),t.seen.pop(),p(k,b,_)}function h(t,e){if(y(e))return t.stylize("undefined","undefined");if(w(e)){var i="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(i,"string")}return v(e)?t.stylize(""+e,"number"):m(e)?t.stylize(""+e,"boolean"):g(e)?t.stylize("null","null"):void 0}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function c(t,e,i,n,r){for(var a=[],o=0,s=e.length;o-1&&(s=a?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n"))):s=t.stylize("[Circular]","special")),y(o)){if(a&&r.match(/^\d+$/))return s;o=JSON.stringify(""+r),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+s}function p(t,e,i){var n=0,r=t.reduce(function(t,e){return n++,e.indexOf("\n")>=0&&n++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return r>60?i[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+i[1]:i[0]+e+" "+t.join(", ")+" "+i[1]}function d(t){return Array.isArray(t)}function m(t){return"boolean"==typeof t}function g(t){return null===t}function b(t){return null==t}function v(t){return"number"==typeof t}function w(t){return"string"==typeof t}function _(t){return"symbol"===("undefined"==typeof t?"undefined":_typeof(t))}function y(t){return void 0===t}function x(t){return k(t)&&"[object RegExp]"===A(t)}function k(t){return"object"===("undefined"==typeof t?"undefined":_typeof(t))&&null!==t}function E(t){return k(t)&&"[object Date]"===A(t)}function S(t){return k(t)&&("[object Error]"===A(t)||t instanceof Error)}function I(t){return"function"==typeof t}function M(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"===("undefined"==typeof t?"undefined":_typeof(t))||"undefined"==typeof t}function A(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}function R(){var t=new Date,e=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":");return[t.getDate(),z[t.getMonth()],e].join(" ")}function L(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var P=/%[sdj%]/g;i.format=function(t){if(!w(t)){for(var e=[],i=0;i=a)return t;switch(t){case"%s":return String(n[i++]);case"%d":return Number(n[i++]);case"%j":try{return JSON.stringify(n[i++])}catch(t){return"[Circular]"}default:return t}}),s=n[i];i0&&(m=setTimeout(function(){d=!0,c.abort("timeout");var t=new Error("XMLHttpRequest timeout");t.code="ETIMEDOUT",n(t)},t.timeout)),c.setRequestHeader)for(p in w)w.hasOwnProperty(p)&&c.setRequestHeader(p,w[p]);else if(t.headers&&!r(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(c.responseType=t.responseType),"beforeSend"in t&&"function"==typeof t.beforeSend&&t.beforeSend(c),c.send(v),c}function l(t){if("document"===t.responseType)return t.responseXML;var e=204===t.status&&t.responseXML&&"parsererror"===t.responseXML.documentElement.nodeName;return""!==t.responseType||e?null:t.responseXML}function h(){}var f=t("global/window"),c=t("is-function"),u=t("parse-headers"),p=t("xtend");e.exports=o,o.XMLHttpRequest=f.XMLHttpRequest||h,o.XDomainRequest="withCredentials"in new o.XMLHttpRequest?o.XMLHttpRequest:f.XDomainRequest,n(["get","put","post","patch","head","delete"],function(t){o["delete"===t?"del":t]=function(e,i,n){return i=a(e,i,n),i.method=t.toUpperCase(),s(i)}})},{"global/window":29,"is-function":34,"parse-headers":58,xtend:106}],105:[function(t,e,i){e.exports=function(){return"undefined"!=typeof window.DOMParser?function(t){var e=new window.DOMParser;return e.parseFromString(t,"application/xml")}:"undefined"!=typeof window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")?function(t){var e=new window.ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e}:function(t){var e=document.createElement("div");return e.innerHTML=t,e}}()},{}],106:[function(t,e,i){function n(){for(var t={},e=0;el?"1":"0";return h};var s=[];e.exports=n},{}],108:[function(t,e,i){function n(t,e,i,n,r,a,o){this.widthOriginal=Math.abs(parseInt(t)||0),this.heightOriginal=Math.abs(parseInt(e)||0),this.targetWidth=Math.abs(parseInt(i)||0),this.targetHeight=Math.abs(parseInt(n)||0),this.colorChannels=r?4:3,this.interpolationPass=!!a,this.resizeCallback="function"==typeof o?o:function(t){},this.targetWidthMultipliedByChannels=this.targetWidth*this.colorChannels,this.originalWidthMultipliedByChannels=this.widthOriginal*this.colorChannels,this.originalHeightMultipliedByChannels=this.heightOriginal*this.colorChannels,this.widthPassResultSize=this.targetWidthMultipliedByChannels*this.heightOriginal,this.finalResultSize=this.targetWidthMultipliedByChannels*this.targetHeight,this.initialize()}n.prototype.initialize=function(){if(!(this.widthOriginal>0&&this.heightOriginal>0&&this.targetWidth>0&&this.targetHeight>0))throw new Error("Invalid settings specified for the resizer.");this.configurePasses()},n.prototype.configurePasses=function(){this.widthOriginal==this.targetWidth?this.resizeWidth=this.bypassResizer:(this.ratioWeightWidthPass=this.widthOriginal/this.targetWidth,this.ratioWeightWidthPass<1&&this.interpolationPass?(this.initializeFirstPassBuffers(!0),this.resizeWidth=4==this.colorChannels?this.resizeWidthInterpolatedRGBA:this.resizeWidthInterpolatedRGB):(this.initializeFirstPassBuffers(!1),this.resizeWidth=4==this.colorChannels?this.resizeWidthRGBA:this.resizeWidthRGB)),this.heightOriginal==this.targetHeight?this.resizeHeight=this.bypassResizer:(this.ratioWeightHeightPass=this.heightOriginal/this.targetHeight,this.ratioWeightHeightPass<1&&this.interpolationPass?(this.initializeSecondPassBuffers(!0),this.resizeHeight=this.resizeHeightInterpolated):(this.initializeSecondPassBuffers(!1),this.resizeHeight=4==this.colorChannels?this.resizeHeightRGBA:this.resizeHeightRGB))},n.prototype.resizeWidthRGB=function(t){var e=this.ratioWeightWidthPass,i=1/e,n=0,r=0,a=0,o=0,s=0,l=0,h=0,f=this.originalWidthMultipliedByChannels-2,c=this.targetWidthMultipliedByChannels-2,u=this.outputWidthWorkBench,p=this.widthBuffer;do{for(s=0;s=r)){for(s=0,l=a;s0&&a=r)){for(s=0,l=a;s0&&a=r)){for(s=0,r=a;s0&&a=r)){for(s=0,r=a;s0&&a0?a[E-4]:2*a[E]-a[E+4],I=a[E],M=a[E+4],A=w0?m[E-4*u]:2*m[E]-m[E+4*u],B=m[E],z=m[E+4*u],O=L1)for(var g=0;g-1}delete Jimp.prototype.write,delete Jimp.read,Jimp.read=function(n,r){return new Promise(function(a,o){r=r||function(t,e){t?o(t):a(e)},"string"==typeof n?t(n,function(t,a){t?i(t)?new Jimp(e(t),r):r(new Error("Unrecognized data received for "+n)):a&&r(a)}):i(n)?new Jimp(e(n),r):r(new Error("Jimp expects a single ArrayBuffer or image URL"))})}}(); \ No newline at end of file diff --git a/aws/main.py b/aws/main.py index c6f3fc65e59..c4fc199f61b 100644 --- a/aws/main.py +++ b/aws/main.py @@ -93,7 +93,7 @@ def update_headers(response): csp_values = ';'.join([ # Firefox <35 need this data: attribute for the grayscale filter based on SVG to work https://bugzilla.mozilla.org/show_bug.cgi?id=878608; in newer FF versions we use the new grayscale filter - "default-src data:", + "default-src 'self' data:", "connect-src 'self' blob: https://*.unsplash.com https://maps.googleapis.com https://*.giphy.com https://api.raygun.io https://www.google.com https://*.wire.com https://wire.com wss://prod-nginz-ssl.wire.com https://*.zinfra.io wss://*.zinfra.io", "font-src 'self' data:", "frame-src 'self' https://accounts.google.com https://*.youtube.com https://*.soundcloud.com https://*.vimeo.com https://*.spotify.com", diff --git a/grunt/config/copy.coffee b/grunt/config/copy.coffee index 3f96c0a1aff..4990fc54e6f 100644 --- a/grunt/config/copy.coffee +++ b/grunt/config/copy.coffee @@ -34,6 +34,7 @@ module.exports = 'image/**/*' 'font/**/*' 'style/*.css' + 'worker/*' ] dist_audio: @@ -63,6 +64,7 @@ module.exports = 'image/**/*' 'font/**/*' 'style/*.css' + 'worker/*' ] deploy_audio: diff --git a/grunt/config/karma.coffee b/grunt/config/karma.coffee index 291a91f57ba..f415969051a 100644 --- a/grunt/config/karma.coffee +++ b/grunt/config/karma.coffee @@ -24,6 +24,7 @@ module.exports = files: [ {pattern: 'ext/proto/generic-message-proto/messages.proto', included: false, served: true, nocache: true} {pattern: 'audio/*.mp3', included: false, served: true, nocache: false} + {pattern: 'worker/*.js', included: false, served: true, nocache: true} # helper files '../node_modules/jasmine-ajax/lib/mock-ajax.js' '../node_modules/sinon/pkg/sinon-1.17.5.js' @@ -37,5 +38,6 @@ module.exports = proxies: '/audio/': '/base/audio/' '/ext/': '/base/ext/' + '/worker/': '/base/worker/' test: colors: false From d825b1725e8cc09623659381f30e5ed995e76f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Herrmann?= Date: Mon, 12 Sep 2016 16:13:46 +0200 Subject: [PATCH 06/21] move external message check to send_generic_message (#203) * move external message check to send_generic_message * Pass user_ids to external message --- .../ConversationRepository.coffee | 53 +++++++++++-------- .../ConversationRepositorySpec.coffee | 23 +++++--- 2 files changed, 47 insertions(+), 29 deletions(-) diff --git a/app/script/conversation/ConversationRepository.coffee b/app/script/conversation/ConversationRepository.coffee index 4cbdd8deaa5..c93b7459768 100644 --- a/app/script/conversation/ConversationRepository.coffee +++ b/app/script/conversation/ConversationRepository.coffee @@ -1108,14 +1108,7 @@ class z.conversation.ConversationRepository .then => if conversation_et.removed_from_conversation() throw new Error 'Cannot send message to conversation you are not part of' - if @_send_as_external_message conversation_et, generic_message - @_send_external_generic_message conversation_et.id, generic_message - else - @_add_to_sending_queue conversation_et.id, generic_message - .catch (error) => - if error.code is z.service.BackendClientError::STATUS_CODE.REQUEST_TOO_LARGE - return @_send_external_generic_message conversation_et.id, generic_message - throw error + @_add_to_sending_queue conversation_et.id, generic_message .then (response) => event = @_construct_otr_message_event response, conversation_et.id return @cryptography_repository.save_encrypted_event generic_message, event @@ -1139,9 +1132,10 @@ class z.conversation.ConversationRepository @param conversation_id [String] Conversation ID @param generic_message [z.protobuf.GenericMessage] Generic message to be sent as external message + @param user_ids [Array] Optional array of user IDs to limit sending to @return [Promise] Promise that resolves after sending the external message ### - _send_external_generic_message: (conversation_id, generic_message) => + _send_external_generic_message: (conversation_id, generic_message, user_ids) => @logger.log @logger.levels.INFO, "Sending external message of type '#{generic_message.content}'", generic_message key_bytes = null @@ -1153,13 +1147,15 @@ class z.conversation.ConversationRepository [key_bytes, sha256, ciphertext] = data return @_create_user_client_map conversation_id .then (user_client_map) => + if user_ids + delete user_client_map[user_id] for user_id of user_client_map when user_id not in user_ids generic_message_external = new z.proto.GenericMessage z.util.create_random_uuid() generic_message_external.set 'external', new z.proto.External new Uint8Array(key_bytes), new Uint8Array(sha256) return @cryptography_repository.encrypt_generic_message user_client_map, generic_message_external .then (payload) => payload.data = z.util.array_to_base64 ciphertext payload.native_push = true - @_send_encrypted_message conversation_id, generic_message, payload + @_send_encrypted_message conversation_id, generic_message, payload, user_ids .catch (error) => @logger.log @logger.levels.INFO, 'Failed sending external message', error throw error @@ -1174,13 +1170,22 @@ class z.conversation.ConversationRepository @return [Promise] Promise that resolves when the message was sent ### _send_generic_message: (conversation_id, generic_message, user_ids) => - @_create_user_client_map conversation_id - .then (user_client_map) => - if user_ids - delete user_client_map[user_id] for user_id of user_client_map when user_id not in user_ids - return @cryptography_repository.encrypt_generic_message user_client_map, generic_message - .then (payload) => - @_send_encrypted_message conversation_id, generic_message, payload, user_ids + Promise.resolve @_send_as_external_message conversation_id, generic_message + .then (send_as_external) => + if send_as_external + @_send_external_generic_message conversation_id, generic_message + else + @_create_user_client_map conversation_id + .then (user_client_map) => + if user_ids + delete user_client_map[user_id] for user_id of user_client_map when user_id not in user_ids + return @cryptography_repository.encrypt_generic_message user_client_map, generic_message + .then (payload) => + @_send_encrypted_message conversation_id, generic_message, payload, user_ids + .catch (error) => + if error.code is z.service.BackendClientError::STATUS_CODE.REQUEST_TOO_LARGE + return @_send_external_generic_message conversation_id, generic_message + throw error ### Sends otr message to a conversation. @@ -1232,15 +1237,17 @@ class z.conversation.ConversationRepository Estimate whether message should be send as type external. @private - @param conversation_et [z.entitity.Conversation] Conversation entity + @param conversation_id [String] @param generic_message [z.protobuf.GenericMessage] Generic message that will be send @return [Boolean] Is payload likely to be too big so that we switch to type external? ### - _send_as_external_message: (conversation_et, generic_message) -> - estimated_number_of_clients = conversation_et.number_of_participants() * 4 - message_in_bytes = new Uint8Array(generic_message.toArrayBuffer()).length - estimated_payload_in_bytes = estimated_number_of_clients * message_in_bytes - return estimated_payload_in_bytes / 1024 > 200 + _send_as_external_message: (conversation_id, generic_message) -> + return new Promise (resolve) => + @get_conversation_by_id conversation_id, (conversation_et) -> + estimated_number_of_clients = conversation_et.number_of_participants() * 4 + message_in_bytes = new Uint8Array(generic_message.toArrayBuffer()).length + estimated_payload_in_bytes = estimated_number_of_clients * message_in_bytes + resolve estimated_payload_in_bytes / 1024 > 200 ### Post images to a conversation. diff --git a/test/unit_tests/conversation/ConversationRepositorySpec.coffee b/test/unit_tests/conversation/ConversationRepositorySpec.coffee index b7bf431d055..a7f8324cbee 100644 --- a/test/unit_tests/conversation/ConversationRepositorySpec.coffee +++ b/test/unit_tests/conversation/ConversationRepositorySpec.coffee @@ -690,23 +690,34 @@ describe 'z.conversation.ConversationRepository', -> .catch done.fail describe '_send_as_external_message', -> - it 'should return true for big payload', -> + + it 'should return true for big payload', (done) -> external_conversation_et = _generate_conversation() external_conversation_et.participating_user_ids [0..128] + conversation_repository.save_conversation external_conversation_et + generic_message = new z.proto.GenericMessage z.util.create_random_uuid() generic_message.set 'text', new z.proto.Text 'massive external message massive external message massive external message massive external message massive external message massive external message massive external message massive external message massive external messagemassive external message massive external message massive external message massive external message massive external message massive external message massive external message massive external message massive external messagemassive external message massive external message massive external message massive external message massive external message massive external message massive external message massive external message massive external messagemassive external message massive external message massive external message massive external message massive external message massive external message massive external message massive external message massive external message' - should_send_as_external = conversation_repository._send_as_external_message conversation_et, generic_message - expect(should_send_as_external).toBeTruthy() + conversation_repository._send_as_external_message conversation_et.id, generic_message + .then (should_send_as_external) -> + expect(should_send_as_external).toBeTruthy() + done() + .catch done.fail - it 'should return false for small payload', -> + it 'should return false for small payload', (done) -> external_conversation_et = _generate_conversation() external_conversation_et.participating_user_ids [0..1] + conversation_repository.save_conversation external_conversation_et + generic_message = new z.proto.GenericMessage z.util.create_random_uuid() generic_message.set 'text', new z.proto.Text 'Test' - should_send_as_external = conversation_repository._send_as_external_message conversation_et, generic_message - expect(should_send_as_external).toBeFalsy() + conversation_repository._send_as_external_message conversation_et.id, generic_message + .then (should_send_as_external) -> + expect(should_send_as_external).toBeFalsy() + done() + .catch done.fail describe 'get_events', -> it 'gets messages which are not broken by design', (done) -> From dbb7df46829b52b5b3e16cbd65d9a1f48f9925fd Mon Sep 17 00:00:00 2001 From: rehez Date: Mon, 12 Sep 2016 16:32:56 +0200 Subject: [PATCH 07/21] Fix post error --- app/script/assets/AssetService.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/script/assets/AssetService.coffee b/app/script/assets/AssetService.coffee index 57f7bef64f6..b308e9a92fe 100644 --- a/app/script/assets/AssetService.coffee +++ b/app/script/assets/AssetService.coffee @@ -404,7 +404,7 @@ class z.assets.AssetService .then (buffer) -> if blob.type is 'image/gif' return z.util.load_file_buffer blob - return new z.util.Worker 'worker/image-worker.js'.post buffer + return new z.util.Worker('worker/image-worker.js').post buffer .then (compressed_bytes) -> return z.util.load_image new Blob [new Uint8Array compressed_bytes], 'type': blob.type .then (compressed_image) -> From b0d4f8b733d9e0a39c9a355d7793fd7973c097bb Mon Sep 17 00:00:00 2001 From: rehez Date: Mon, 12 Sep 2016 17:27:14 +0200 Subject: [PATCH 08/21] split worker init and post --- app/script/assets/AssetService.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/script/assets/AssetService.coffee b/app/script/assets/AssetService.coffee index b308e9a92fe..1d947746a8e 100644 --- a/app/script/assets/AssetService.coffee +++ b/app/script/assets/AssetService.coffee @@ -404,7 +404,8 @@ class z.assets.AssetService .then (buffer) -> if blob.type is 'image/gif' return z.util.load_file_buffer blob - return new z.util.Worker('worker/image-worker.js').post buffer + image_worker = new z.util.Worker 'worker/image-worker.js' + return image_worker.post buffer .then (compressed_bytes) -> return z.util.load_image new Blob [new Uint8Array compressed_bytes], 'type': blob.type .then (compressed_image) -> From 596a5332c4828fa0dd5c4861e6c5c2651215f8fb Mon Sep 17 00:00:00 2001 From: rehez Date: Mon, 12 Sep 2016 18:04:29 +0200 Subject: [PATCH 09/21] lowercase import --- app/page/template/_dist/app.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/page/template/_dist/app.htm b/app/page/template/_dist/app.htm index 093b2d83ba0..b9aed7d78c9 100644 --- a/app/page/template/_dist/app.htm +++ b/app/page/template/_dist/app.htm @@ -18,7 +18,7 @@ - + From 6a4c8ead28a3fef37a9aeffcb369598d4f3546c8 Mon Sep 17 00:00:00 2001 From: Gregor Herdmann Date: Thu, 15 Sep 2016 13:32:56 +0200 Subject: [PATCH 10/21] Re-enable phone login (#199) --- app/page/auth.html | 135 +++-- app/page/template/_dist/app.htm | 1 - app/script/auth/AuthView.coffee | 5 +- app/script/components/deviceRemove.coffee | 2 +- app/script/localization/strings-de.coffee | 12 +- app/script/localization/strings.coffee | 10 +- .../tracking/event/PhoneVerification.coffee | 36 -- app/script/view_model/AuthViewModel.coffee | 541 +++++++++--------- app/style/auth/account.less | 22 +- app/style/auth/base.less | 1 + app/style/auth/posted.less | 2 +- app/style/auth/verify.less | 7 +- 12 files changed, 402 insertions(+), 372 deletions(-) delete mode 100644 app/script/tracking/event/PhoneVerification.coffee diff --git a/app/page/auth.html b/app/page/auth.html index 68c0a70a507..af193c95652 100644 --- a/app/page/auth.html +++ b/app/page/auth.html @@ -39,21 +39,21 @@
-
-
-
+
-
-
- +
+
@@ -69,16 +69,16 @@
-
-
- - +
+
+ +
-
+
+ +