├── .gitignore ├── .npmignore ├── LICENSE.md ├── README.md ├── package-lock.json ├── package.json ├── public ├── assets │ └── fonts │ │ ├── SpaceGrotesk-Bold.woff │ │ ├── SpaceGrotesk-Bold.woff2 │ │ ├── SpaceGrotesk-Light.woff │ │ ├── SpaceGrotesk-Light.woff2 │ │ ├── SpaceGrotesk-Medium.woff │ │ ├── SpaceGrotesk-Medium.woff2 │ │ ├── SpaceGrotesk-Regular.woff │ │ ├── SpaceGrotesk-Regular.woff2 │ │ ├── SpaceGrotesk-SemiBold.woff │ │ └── SpaceGrotesk-SemiBold.woff2 ├── index.html ├── index.js └── main.css └── src ├── Encoder.js ├── EncoderProgress.js ├── createEncoder.js ├── index.html ├── index.js └── test.js /.gitignore: -------------------------------------------------------------------------------- 1 | bower_components 2 | node_modules 3 | *.log 4 | .DS_Store 5 | bundle.js 6 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | bower_components 2 | node_modules 3 | *.log 4 | .DS_Store 5 | bundle.js 6 | test 7 | test.js 8 | demo/ 9 | .npmignore 10 | LICENSE.md -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2017 Matt DesLauriers 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # giftool 2 | 3 | A simple, open-source GIF encoding website from a sequence of frames. 4 | 5 | Drag and drop files onto the site and it will encode them into a GIF. For best results, use numbered and zero-padded files, like `000.png`, `001.png`, `002.png`, etc. 6 | 7 | ## Clone & Run 8 | 9 | Clone this repo and use [npm](https://npmjs.com/) to install. 10 | 11 | ```sh 12 | npm install 13 | ``` 14 | 15 | To build, `npm run build` and look in the `public/` folder. To run locally, use `npm run start` and open [http://localhost:9966/](http://localhost:9966/). 16 | 17 | ## License 18 | 19 | MIT, see [LICENSE.md](http://github.com/mattdesl/giftool/blob/master/LICENSE.md) for details. 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "giftool", 3 | "version": "1.0.0", 4 | "description": "A website to encode a GIF from image frames", 5 | "main": "index.js", 6 | "license": "MIT", 7 | "author": { 8 | "name": "Matt DesLauriers", 9 | "email": "dave.des@gmail.com", 10 | "url": "https://github.com/mattdesl" 11 | }, 12 | "dependencies": { 13 | "drag-drop": "^4.2.0", 14 | "gif-encoder": "^0.7.1", 15 | "javascript-natural-sort": "^0.7.1", 16 | "load-img": "^1.0.0", 17 | "map-limit": "0.0.1", 18 | "preact": "^8.3.1", 19 | "stream-buffers": "^3.0.2" 20 | }, 21 | "devDependencies": { 22 | "bubleify": "^1.2.0", 23 | "canvas-sketch-cli": "^1.0.19", 24 | "surge": "^0.20.1" 25 | }, 26 | "browserify": { 27 | "transform": [ 28 | [ 29 | "bubleify", 30 | { 31 | "objectAssign": "Object.assign" 32 | } 33 | ] 34 | ] 35 | }, 36 | "scripts": { 37 | "upload": "surge -p public -d giftool.surge.sh", 38 | "deploy": "npm run build && npm run upload", 39 | "start": "canvas-sketch src/index.js --dir public --html src/index.html", 40 | "build": "canvas-sketch src/index.js --dir public --html src/index.html --build" 41 | }, 42 | "keywords": [ 43 | "gif", 44 | "make", 45 | "png", 46 | "frames", 47 | "video" 48 | ], 49 | "repository": { 50 | "type": "git", 51 | "url": "git://github.com/mattdesl/giftool.git" 52 | }, 53 | "homepage": "https://github.com/mattdesl/giftool", 54 | "bugs": { 55 | "url": "https://github.com/mattdesl/giftool/issues" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /public/assets/fonts/SpaceGrotesk-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/giftool/d378b5ee35a094fa971c55b105a0becc8510a7d6/public/assets/fonts/SpaceGrotesk-Bold.woff -------------------------------------------------------------------------------- /public/assets/fonts/SpaceGrotesk-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/giftool/d378b5ee35a094fa971c55b105a0becc8510a7d6/public/assets/fonts/SpaceGrotesk-Bold.woff2 -------------------------------------------------------------------------------- /public/assets/fonts/SpaceGrotesk-Light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/giftool/d378b5ee35a094fa971c55b105a0becc8510a7d6/public/assets/fonts/SpaceGrotesk-Light.woff -------------------------------------------------------------------------------- /public/assets/fonts/SpaceGrotesk-Light.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/giftool/d378b5ee35a094fa971c55b105a0becc8510a7d6/public/assets/fonts/SpaceGrotesk-Light.woff2 -------------------------------------------------------------------------------- /public/assets/fonts/SpaceGrotesk-Medium.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/giftool/d378b5ee35a094fa971c55b105a0becc8510a7d6/public/assets/fonts/SpaceGrotesk-Medium.woff -------------------------------------------------------------------------------- /public/assets/fonts/SpaceGrotesk-Medium.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/giftool/d378b5ee35a094fa971c55b105a0becc8510a7d6/public/assets/fonts/SpaceGrotesk-Medium.woff2 -------------------------------------------------------------------------------- /public/assets/fonts/SpaceGrotesk-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/giftool/d378b5ee35a094fa971c55b105a0becc8510a7d6/public/assets/fonts/SpaceGrotesk-Regular.woff -------------------------------------------------------------------------------- /public/assets/fonts/SpaceGrotesk-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/giftool/d378b5ee35a094fa971c55b105a0becc8510a7d6/public/assets/fonts/SpaceGrotesk-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/fonts/SpaceGrotesk-SemiBold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/giftool/d378b5ee35a094fa971c55b105a0becc8510a7d6/public/assets/fonts/SpaceGrotesk-SemiBold.woff -------------------------------------------------------------------------------- /public/assets/fonts/SpaceGrotesk-SemiBold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdesl/giftool/d378b5ee35a094fa971c55b105a0becc8510a7d6/public/assets/fonts/SpaceGrotesk-SemiBold.woff2 -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | giftool
-------------------------------------------------------------------------------- /public/index.js: -------------------------------------------------------------------------------- 1 | !function(){return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var l=r[s]={exports:{}};t[s][0].call(l.exports,function(e){return i(t[s][1][e]||e)},l,l.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s=0;f--)if(l[f]!==c[f])return!1;for(f=l.length-1;f>=0;f--)if(!b(e[u=l[f]],t[u],r,n))return!1;return!0}(e,t,r,s))}return r?e===t:e==t}function v(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function w(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&y(i,r,"Missing expected exception"+n);var s="string"==typeof n,a=!e&&i&&!r;if((!e&&o.isError(i)&&s&&w(i,r)||a)&&y(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(i,r)||!e&&i)throw i}c.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=p(g((t=this).actual),128)+" "+t.operator+" "+p(g(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=d(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},o.inherits(c.AssertionError,Error),c.fail=y,c.ok=m,c.equal=function(e,t,r){e!=t&&y(e,t,r,"==",c.equal)},c.notEqual=function(e,t,r){e==t&&y(e,t,r,"!=",c.notEqual)},c.deepEqual=function(e,t,r){b(e,t,!1)||y(e,t,r,"deepEqual",c.deepEqual)},c.deepStrictEqual=function(e,t,r){b(e,t,!0)||y(e,t,r,"deepStrictEqual",c.deepStrictEqual)},c.notDeepEqual=function(e,t,r){b(e,t,!1)&&y(e,t,r,"notDeepEqual",c.notDeepEqual)},c.notDeepStrictEqual=function e(t,r,n){b(t,r,!0)&&y(t,r,n,"notDeepStrictEqual",e)},c.strictEqual=function(e,t,r){e!==t&&y(e,t,r,"===",c.strictEqual)},c.notStrictEqual=function(e,t,r){e===t&&y(e,t,r,"!==",c.notStrictEqual)},c.throws=function(e,t,r){_(!0,e,t,r)},c.doesNotThrow=function(e,t,r){_(!1,e,t,r)},c.ifError=function(e){if(e)throw e};var S=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":4}],2:[function(e,t,r){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],3:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],4:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!m(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),b(n.showHidden)&&(n.showHidden=!1),b(n.depth)&&(n.depth=2),b(n.colors)&&(n.colors=!1),b(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),l(n,e,n.depth)}function u(e,t){var r=a.styles[t];return r?"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m":e}function f(e,t){return e}function l(e,t,n){if(e.customInspect&&t&&x(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return m(i)||(i=l(e,i,n)),i}var o=function(e,t){if(b(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(g(t))return e.stylize("null","null")}(e,t);if(o)return o;var s=Object.keys(t),a=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),S(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return c(t);if(0===s.length){if(x(t))return e.stylize("[Function"+(t.name?": "+t.name:"")+"]","special");if(v(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(S(t))return c(t)}var u,f="",w=!1,E=["{","}"];(d(t)&&(w=!0,E=["[","]"]),x(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return v(t)&&(f=" "+RegExp.prototype.toString.call(t)),_(t)&&(f=" "+Date.prototype.toUTCString.call(t)),S(t)&&(f=" "+c(t)),0!==s.length||w&&0!=t.length?n<0?v(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=w?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(u,f,E)):E[0]+f+E[1]}function c(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=e.stylize(u.set?"[Getter/Setter]":"[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),C(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=g(r)?l(e,u.value,null):l(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),b(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function g(e){return null===e}function y(e){return"number"==typeof e}function m(e){return"string"==typeof e}function b(e){return void 0===e}function v(e){return w(e)&&"[object RegExp]"===E(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===E(e)}function S(e){return w(e)&&("[object Error]"===E(e)||e instanceof Error)}function x(e){return"function"==typeof e}function E(e){return Object.prototype.toString.call(e)}function k(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(b(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;s[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else s[e]=function(){};return s[e]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=g,r.isNullOrUndefined=function(e){return null==e},r.isNumber=y,r.isString=m,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=b,r.isRegExp=v,r.isObject=w,r.isDate=_,r.isError=S,r.isFunction=x,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var T=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function C(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[k(e.getHours()),k(e.getMinutes()),k(e.getSeconds())].join(":"),[e.getDate(),T[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":3,_process:33,inherits:2}],5:[function(e,t,r){"use strict";r.byteLength=function(e){var t=f(e),r=t[1];return 3*(t[0]+r)/4-r},r.toByteArray=function(e){for(var t,r=f(e),n=r[0],s=r[1],a=new o(function(e,t,r){return 3*(t+r)/4-r}(0,n,s)),u=0,l=s>0?n-4:n,c=0;c>16&255,a[u++]=t>>8&255,a[u++]=255&t;2===s&&(t=i[e.charCodeAt(c)]<<2|i[e.charCodeAt(c+1)]>>4,a[u++]=255&t);1===s&&(t=i[e.charCodeAt(c)]<<10|i[e.charCodeAt(c+1)]<<4|i[e.charCodeAt(c+2)]>>2,a[u++]=t>>8&255,a[u++]=255&t);return a},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?o.push(n[(t=e[r-1])>>2]+n[t<<4&63]+"=="):2===i&&o.push(n[(t=(e[r-2]<<8)+e[r-1])>>10]+n[t>>4&63]+n[t<<2&63]+"=");return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,r){for(var i,o=[],s=t;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],6:[function(e,t,r){},{}],7:[function(e,t,r){"use strict";var n=e("base64-js"),i=e("ieee754");r.Buffer=a,r.SlowBuffer=function(e){+e!=e&&(e=0);return a.alloc(+e)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return l(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|d(e,t),n=s(r),i=n.write(e,t);i!==r&&(n=n.slice(0,i));return n}(e,t);if(ArrayBuffer.isView(e))return c(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(F(e,ArrayBuffer)||e&&F(e.buffer,ArrayBuffer))return function(e,t,r){if(t<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function d(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||F(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return U(e).length;default:if(i)return n?-1:N(e).length;t=(""+t).toLowerCase(),i=!0}}function p(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=a.from(t,n)),a.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var c=!0,h=0;hi&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var s=0;s>8,i.push(r%256),i.push(n);return i}(t,e.length-r),e,r,n)}function x(e,t,r){return n.fromByteArray(0===t&&r===e.length?e:e.slice(t,r))}function E(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+c<=r)switch(c){case 1:f<128&&(l=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(l=u);break;case 3:s=e[i+2],128==(192&(o=e[i+1]))&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:s=e[i+2],a=e[i+3],128==(192&(o=e[i+1]))&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,c=1):l>65535&&(n.push((l-=65536)>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=c}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return L(this,t,r);case"utf8":case"utf-8":return E(this,t,r);case"ascii":return T(this,t,r);case"latin1":case"binary":return C(this,t,r);case"base64":return x(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),""},a.prototype.compare=function(e,t,r,n,i){if(F(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),u=Math.min(o,s),f=this.slice(n,i),l=e.slice(t,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return v(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function T(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function A(e,t,r,n,i,o){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function B(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function D(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,8),i.write(e,t,r,n,52,8),r+8}a.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||j(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||j(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},a.prototype.readUInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},a.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},a.prototype.readInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||j(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){e>>>=0,t||j(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||j(e,4,this.length),i.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||j(e,4,this.length),i.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||j(e,8,this.length),i.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||j(e,8,this.length),i.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||A(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||A(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||A(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||A(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||A(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||A(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||A(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);A(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},a.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);A(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||A(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||A(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||A(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||A(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||A(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeFloatLE=function(e,t,r){return R(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return R(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return D(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return D(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,n){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return i},a.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i)}}else"number"==typeof e&&(e&=255);if(t<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function U(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(O,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function P(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function F(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function W(e){return e!=e}},{"base64-js":5,ieee754:23}],8:[function(e,t,r){(function(e){function t(e){return Object.prototype.toString.call(e)}r.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===t(e)},r.isBoolean=function(e){return"boolean"==typeof e},r.isNull=function(e){return null===e},r.isNullOrUndefined=function(e){return null==e},r.isNumber=function(e){return"number"==typeof e},r.isString=function(e){return"string"==typeof e},r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=function(e){return void 0===e},r.isRegExp=function(e){return"[object RegExp]"===t(e)},r.isObject=function(e){return"object"==typeof e&&null!==e},r.isDate=function(e){return"[object Date]"===t(e)},r.isError=function(e){return"[object Error]"===t(e)||e instanceof Error},r.isFunction=function(e){return"function"==typeof e},r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":25}],9:[function(e,t,r){t.exports=function(e,t){if("string"==typeof e){var r=e;if(!(e=window.document.querySelector(e)))throw new Error('"'+r+'" does not match any HTML elements')}if(!e)throw new Error('"'+e+'" is not a valid HTML element');"function"==typeof t&&(t={onDrop:t});var s;return e.addEventListener("dragenter",a,!1),e.addEventListener("dragover",u,!1),e.addEventListener("dragleave",f,!1),e.addEventListener("drop",l,!1),function(){c(),e.removeEventListener("dragenter",a,!1),e.removeEventListener("dragover",u,!1),e.removeEventListener("dragleave",f,!1),e.removeEventListener("drop",l,!1)};function a(e){return t.onDragEnter&&t.onDragEnter(e),e.stopPropagation(),e.preventDefault(),!1}function u(r){if(r.stopPropagation(),r.preventDefault(),t.onDragOver&&t.onDragOver(r),r.dataTransfer.items){var n=Array.from(r.dataTransfer.items),i=n.filter(function(e){return"file"===e.kind}),o=n.filter(function(e){return"string"===e.kind});if(0===i.length&&!t.onDropText)return;if(0===o.length&&!t.onDrop)return;if(0===i.length&&0===o.length)return}return e.classList.add("drag"),clearTimeout(s),r.dataTransfer.dropEffect="copy",!1}function f(e){return e.stopPropagation(),e.preventDefault(),t.onDragLeave&&t.onDragLeave(e),clearTimeout(s),s=setTimeout(c,50),!1}function l(e){e.stopPropagation(),e.preventDefault(),t.onDragLeave&&t.onDragLeave(e),clearTimeout(s),c();var r={x:e.clientX,y:e.clientY},a=e.dataTransfer.getData("text");if(a&&t.onDropText&&t.onDropText(a,r),t.onDrop&&e.dataTransfer.items){var u=e.dataTransfer.files,f=Array.from(e.dataTransfer.items).filter(function(e){return"file"===e.kind});if(0===f.length)return;i(f.map(function(e){return function(t){!function(e,t){var r=[];if(e.isFile)e.file(function(r){r.fullPath=e.fullPath,r.isFile=!0,r.isDirectory=!1,t(null,r)},function(e){t(e)});else if(e.isDirectory){var n=e.createReader();!function s(){n.readEntries(function(n){n.length>0?(r=r.concat(Array.from(n)),s()):i(r.map(function(e){return function(t){o(e,t)}}),function(r,n){r?t(r):(n.push({fullPath:e.fullPath,name:e.name,isFile:!1,isDirectory:!0}),t(null,n))})})}()}}(e.webkitGetAsEntry(),t)}}),function(e,i){if(e)throw e;var o=n(i),s=o.filter(function(e){return e.isFile}),a=o.filter(function(e){return e.isDirectory});t.onDrop(s,r,u,a)})}return!1}function c(){e.classList.remove("drag")}};var n=e("flatten"),i=e("run-parallel");function o(e,t){var r=[];if(e.isFile){e.file(function(r){r.fullPath=e.fullPath;r.isFile=true;r.isDirectory=false;t(null,r)},function(e){t(e)})}else if(e.isDirectory){var n=e.createReader();s()}function s(){n.readEntries(function(e){if(e.length>0){r=r.concat(Array.from(e));s()}else{a()}})}function a(){i(r.map(function(e){return function(t){o(e,t)}}),function(r,n){if(r){t(r)}else{n.push({fullPath:e.fullPath,name:e.name,isFile:false,isDirectory:true});t(null,n)}})}}},{flatten:11,"run-parallel":47}],10:[function(e,t,r){var n=Object.create||function(e){var t=function(){};return t.prototype=e,new t},i=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return r},o=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=n(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var a,u=10;try{var f={};Object.defineProperty&&Object.defineProperty(f,"x",{value:0}),a=0===f.x}catch(e){a=!1}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function c(e,t,r,i){var o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),a=s[t]):(s=e._events=n(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=i?[r,a]:[a,r]:i?a.unshift(r):a.push(r),!a.warned&&(o=l(e))&&o>0&&a.length>o){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",u.name,u.message)}}else a=s[t]=r,++e._eventsCount;return e}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t1&&(t=arguments[1]),t instanceof Error)throw t;var u=new Error('Unhandled "error" event. ('+t+")");throw u.context=t,u}if(!(r=s[e]))return!1;var f="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=y(e,n),o=0;o=0;s--)if(r[s]===t||r[s].listener===t){a=r[s].listener,o=s;break}if(o<0)return this;0===o?r.shift():function(e,t){for(var r=t,n=r+1,i=e.length;n=0;o--)this.removeListener(e,t[o]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},s.prototype.listenerCount=g,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],11:[function(e,t,r){t.exports=function(e,t){return(t="number"==typeof t?t:Infinity)?function e(r,n){return r.reduce(function(r,i){return Array.isArray(i)&&n=0&&(this.dispose=e)},f.prototype.setRepeat=function(e){this.repeat=e},f.prototype.setTransparent=function(e){this.transparent=e},f.prototype.analyzeImage=function(e,t){t&&t.palette&&this.setImagePalette(this.removeAlphaChannel(t.palette)),t&&!0===t.indexedPixels?(n(t.palette,"`options.indexedPixels` requires `options.palette` to load from. Please include one`"),this.setImagePixels(e)):this.setImagePixels(this.removeAlphaChannel(e)),this.analyzePixels(t),t&&t.palette&&(this.userPalette=null)},f.prototype.writeImageInfo=function(){this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.writePalette(),this.firstFrame=!1},f.prototype.outputImage=function(){this.writePixels()},f.prototype.addFrame=function(e,t){this.emit("frame#start"),this.analyzeImage(e,t),this.writeImageInfo(),this.outputImage(),this.emit("frame#stop")},f.prototype.finish=function(){this.emit("finish#start"),this.writeByte(59),this.emit("finish#stop")},f.prototype.setQuality=function(e){e<1&&(e=1),this.sample=e},f.prototype.writeHeader=function(){this.emit("writeHeader#start"),this.writeUTFBytes("GIF89a"),this.emit("writeHeader#stop")},f.prototype.analyzePixels=function(e){var t,r,i;if(null!==this.userPalette){n(e&&!0===e.indexedPixels,"`palette` can only be used with `options.indexedPixels` at the moment. Please add `{indexedPixels: true}` to `addFrame()`"),t=this.pixels.length,this.indexedPixels=new Uint8Array(t),this.colorTab=this.userPalette;for(var o=0;o>16,(65280&this.transparent)>>8,255&this.transparent):0},f.prototype.removeAlphaChannel=function(e){for(var t=this.width,r=this.height,n=new Uint8Array(t*r*3),i=0,o=0;o=0&&(t=7&this.dispose),this.writeByte(0|(t<<=2)|e),this.writeShort(this.delay),this.writeByte(this.transIndex),this.writeByte(0)},f.prototype.writeImageDesc=function(){this.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.writeByte(this.firstFrame?0:128|this.palSize)},f.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.writeByte(240|this.palSize),this.writeByte(0),this.writeByte(0)},f.prototype.writeNetscapeExt=function(){this.writeByte(33),this.writeByte(255),this.writeByte(11),this.writeUTFBytes("NETSCAPE2.0"),this.writeByte(3),this.writeByte(1),this.writeShort(this.repeat),this.writeByte(0)},f.prototype.writePalette=function(){this.writeBytes(this.colorTab);for(var e=768-this.colorTab.length,t=0;t>8&255)},f.prototype.writePixels=function(){new a(this.width,this.height,this.indexedPixels,this.colorDepth).encode(this)},f.prototype.stream=function(){return this},f.ByteCapacitor=u,t.exports=f}).call(this,e("buffer").Buffer)},{"./LZWEncoder.js":13,"./TypedNeuQuant.js":14,assert:1,buffer:7,events:10,"readable-stream":21,util:58}],13:[function(e,t,r){var n=-1,i=12,o=5003,s=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];t.exports=function(e,t,r,a){var u,f,l,c,h,d,p,g,y,m=Math.max(2,a),b=new Uint8Array(256),v=new Int32Array(o),w=new Int32Array(o),_=0,S=0,x=!1;function E(e,t){b[f++]=e,f>=254&&C(t)}function k(e){T(o),S=g+2,x=!0,j(g,e)}function T(e){for(var t=0;t0&&(e.writeByte(f),e.writeBytes(b,0,f),f=0)}function L(e){return(1<0?u|=e<<_:u=e,_+=d;_>=8;)E(255&u,t),u>>=8,_-=8;if((S>l||x)&&(x?(l=L(d=p),x=!1):l=++d==i?1<0;)E(255&u,t),u>>=8,_-=8;C(t)}}this.encode=function(r){r.writeByte(m),c=e*t,h=0,function(e,t){var r,s,a,u,c,h,m;for(x=!1,l=L(d=p=e),y=1+(g=1<=0){c=h-a,0===a&&(c=1);do{if((a-=c)<0&&(a+=h),v[a]===r){u=w[a];continue e}}while(v[a]>=0)}j(u,t),u=s,S<1<>l,h=u<>3)*(1<f;)u=C[d++],cf&&((a=r[h--])[0]-=u*(a[0]-n)/b,a[1]-=u*(a[1]-o)/b,a[2]-=u*(a[2]-s)/b)}function j(e,t,n){var o,u,d,p,g,y=~(1<<31),m=y,b=-1,v=b;for(o=0;o>a-s))>l,k[o]+=g<>3),e=0;e>d;for(T<=1&&(T=0),r=0;r=l&&(A-=l),0===b&&(b=1),++r%b==0)for(E-=E/c,(T=(k-=k/g)>>d)<=1&&(T=0),f=0;f>=s,r[e][1]>>=s,r[e][2]>>=s,r[e][3]=e}(),function(){var e,t,n,s,a,u,f=0,l=0;for(e=0;e>1,t=f+1;t>1,t=f+1;t<256;t++)E[t]=o}()},this.getColormap=function(){for(var e=[],t=[],n=0;n=0;)l=u?l=i:(l++,a<0&&(a=-a),(o=s[0]-e)<0&&(o=-o),(a+=o)=0&&((a=t-(s=r[c])[1])>=u?c=-1:(c--,a<0&&(a=-a),(o=s[0]-e)<0&&(o=-o),(a+=o)0)if(t.ended&&!o){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&o){a=new Error("stream.unshift() after end event");e.emit("error",a)}else!t.decoder||o||i||(n=t.decoder.write(n)),o||(t.reading=!1),t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,o?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&g(e)),function(e,t){t.readingMore||(t.readingMore=!0,r.nextTick(function(){!function(e,t){var r=t.length;for(;!t.reading&&!t.flowing&&!t.ended&&t.lengtht.highWaterMark&&(t.highWaterMark=function(e){if(e>=d)e=d;else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function g(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(f("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?r.nextTick(function(){y(e)}):y(e))}function y(e){f("emit readable"),e.emit("readable"),m(e)}function m(e){var t=e._readableState;if(f("flow",t.flowing),t.flowing)do{var r=e.read()}while(null!==r&&t.flowing)}function b(e,t){var r,n=t.buffer,o=t.length,s=!!t.decoder;if(0===n.length)return null;if(0===o)r=null;else if(!!t.objectMode)r=n.shift();else if(!e||e>=o)r=s?n.join(""):i.concat(n,o),n.length=0;else{if(e0)throw new Error("endReadable called on non-empty stream");t.endEmitted||(t.ended=!0,r.nextTick(function(){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}))}c.prototype.read=function(e){f("read",e);var t=this._readableState,r=e;if((!u.isNumber(e)||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return f("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?v(this):g(this),null;if(0===(e=p(e,t))&&t.ended)return 0===t.length&&v(this),null;var n,i=t.needReadable;return f("need readable",i),(0===t.length||t.length-e0?b(e,t):null,u.isNull(n)&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),r!==e&&t.ended&&0===t.length&&v(this),u.isNull(n)||this.emit("data",n),n},c.prototype._read=function(e){this.emit("error",new Error("not implemented"))},c.prototype.pipe=function(e,t){var i=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=e;break;case 1:s.pipes=[s.pipes,e];break;default:s.pipes.push(e)}s.pipesCount+=1,f("pipe count=%d opts=%j",s.pipesCount,t);var a=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?l:h;function u(e){f("onunpipe"),e===i&&h()}function l(){f("onend"),e.end()}s.endEmitted?r.nextTick(a):i.once("end",a),e.on("unpipe",u);var c=function(e){return function(){var t=e._readableState;f("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o.listenerCount(e,"data")&&(t.flowing=!0,m(e))}}(i);function h(){f("cleanup"),e.removeListener("close",g),e.removeListener("finish",y),e.removeListener("drain",c),e.removeListener("error",p),e.removeListener("unpipe",u),i.removeListener("end",l),i.removeListener("end",h),i.removeListener("data",d),!s.awaitDrain||e._writableState&&!e._writableState.needDrain||c()}function d(t){f("ondata"),!1===e.write(t)&&(f("false write response, pause",i._readableState.awaitDrain),i._readableState.awaitDrain++,i.pause())}function p(t){f("onerror",t),b(),e.removeListener("error",p),0===o.listenerCount(e,"error")&&e.emit("error",t)}function g(){e.removeListener("finish",y),b()}function y(){f("onfinish"),e.removeListener("close",g),b()}function b(){f("unpipe"),i.unpipe(e)}return e.on("drain",c),i.on("data",d),e._events&&e._events.error?n(e._events.error)?e._events.error.unshift(p):e._events.error=[p,e._events.error]:e.on("error",p),e.once("close",g),e.once("finish",y),e.emit("pipe",i),s.flowing||(f("pipe resume"),i.resume()),e},c.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i1){for(var r=[],n=0;n=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n,i=e.length;if(this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),(n=(t+=e.toString(this.encoding,0,i)).charCodeAt(i=t.length-1))>=55296&&n<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},o.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},o.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.encoding;t+=this.charBuffer.slice(0,this.charReceived).toString(r)}return t}},{buffer:7}],23:[function(e,t,r){r.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,l=-7,c=r?i-1:0,h=r?-1:1,d=e[t+c];for(c+=h,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+e[t+c],c+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+c],c+=h,l-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:Infinity*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,l=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||Infinity===t?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+c>=1?h/u:h*Math.pow(2,1-c))*u>=2&&(s++,u/=2),s+c>=l?(a=0,s=l):s+c>=1?(a=(t*u-1)*Math.pow(2,i),s+=c):(a=t*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}},{}],24:[function(e,t,r){arguments[4][2][0].apply(r,arguments)},{dup:2}],25:[function(e,t,r){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}t.exports=function(e){return null!=e&&(n(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}(e)||!!e._isBuffer)}},{}],26:[function(e,t,r){var n={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],27:[function(e,t,r){t.exports=function e(t,r){"use strict";var n,i,o=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,s=/(^[ ]*|[ ]*$)/g,a=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,f=/^0/,l=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},c=l(t).replace(s,"")||"",h=l(r).replace(s,"")||"",d=c.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=h.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),g=parseInt(c.match(u),16)||1!==d.length&&c.match(a)&&Date.parse(c),y=parseInt(h.match(u),16)||g&&h.match(a)&&Date.parse(h)||null;if(y){if(gy)return 1}for(var m=0,b=Math.max(d.length,p.length);mi)return 1}return 0}},{}],28:[function(e,t,r){t.exports=function(e,t,r){"function"==typeof t&&(r=t,t=null);var n,i=document.createElement("img");i.onload=function(){n||(n=!0,r&&r(void 0,i))},i.onerror=function(){n||(n=!0,r&&r(new Error('Unable to load "'+e+'"'),i))},t&&t.crossOrigin&&(i.crossOrigin=t.crossOrigin);return i.src=e,i}},{}],29:[function(e,t,r){var n=e("once"),i=function(){};t.exports=function(e,t,r,o){var s=0,a=!1,u=[],f=0,l=e.length,c=0;if(o=n(o||i),"function"!=typeof r)throw new Error("Iterator function must be passed as the third argument");for(var h=0;h2;)x.push(arguments[o]);for(t&&null!=t.children&&(x.length||x.push(t.children),delete t.children);x.length;)if((n=x.pop())&&void 0!==n.pop)for(o=n.length;o--;)x.push(n[o]);else"boolean"==typeof n&&(n=null),(i="function"!=typeof e)&&(null==n?n="":"number"==typeof n?n=String(n):"string"!=typeof n&&(i=!1)),i&&r?s[s.length-1]+=n:s===E?s=[n]:s.push(n),r=i;var a=new _;return a.nodeName=e,a.children=s,a.attributes=null==t?void 0:t,a.key=null==t?void 0:t.key,void 0!==S.vnode&&S.vnode(a),a}function r(e,t){for(var r in t)e[r]=t[r];return e}function n(e){!e.__d&&(e.__d=!0)&&1==C.push(e)&&(S.debounceRendering||k)(i)}function i(){var e,t=C;for(C=[];e=t.pop();)e.__d&&b(e)}function o(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function s(e){var t=r({},e.attributes);t.children=e.children;var n=e.nodeName.defaultProps;if(void 0!==n)for(var i in n)void 0===t[i]&&(t[i]=n[i]);return t}function a(e){var t=e.parentNode;t&&t.removeChild(e)}function u(e,t,r,n,i){if("className"===t&&(t="class"),"key"===t);else if("ref"===t)r&&r(null),n&&n(e);else if("class"!==t||i)if("style"===t){if(n&&"string"!=typeof n&&"string"!=typeof r||(e.style.cssText=n||""),n&&"object"==typeof n){if("string"!=typeof r)for(var o in r)o in n||(e.style[o]="");for(var o in n)e.style[o]="number"==typeof n[o]&&!1===T.test(o)?n[o]+"px":n[o]}}else if("dangerouslySetInnerHTML"===t)n&&(e.innerHTML=n.__html||"");else if("o"==t[0]&&"n"==t[1]){var s=t!==(t=t.replace(/Capture$/,""));t=t.toLowerCase().substring(2),n?r||e.addEventListener(t,f,s):e.removeEventListener(t,f,s),(e.__l||(e.__l={}))[t]=n}else if("list"!==t&&"type"!==t&&!i&&t in e){try{e[t]=null==n?"":n}catch(e){}null!=n&&!1!==n||"spellcheck"==t||e.removeAttribute(t)}else{var a=i&&t!==(t=t.replace(/^xlink:?/,""));null==n||!1===n?a?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.removeAttribute(t):"function"!=typeof n&&(a?e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),n):e.setAttribute(t,n))}else e.className=n||""}function f(e){return this.__l[e.type](S.event&&S.event(e)||e)}function l(){for(var e;e=L.pop();)S.afterMount&&S.afterMount(e),e.componentDidMount&&e.componentDidMount()}function c(e,t,r,n,i,o){M++||(j=null!=i&&void 0!==i.ownerSVGElement,A=null!=e&&!("__preactattr_"in e));var s=h(e,t,r,n,o);return i&&s.parentNode!==i&&i.appendChild(s),--M||(A=!1,o||l()),s}function h(e,t,r,n,i){var f=e,l=j;if(null!=t&&"boolean"!=typeof t||(t=""),"string"==typeof t||"number"==typeof t)return e&&void 0!==e.splitText&&e.parentNode&&(!e._component||i)?e.nodeValue!=t&&(e.nodeValue=t):(f=document.createTextNode(t),e&&(e.parentNode&&e.parentNode.replaceChild(f,e),d(e,!0))),f.__preactattr_=!0,f;var c,p,y=t.nodeName;if("function"==typeof y)return function(e,t,r,n){var i=e&&e._component,o=i,a=e,u=i&&e._componentConstructor===t.nodeName,f=u,l=s(t);for(;i&&!f&&(i=i.__u);)f=i.constructor===t.nodeName;i&&f&&(!n||i._component)?(m(i,l,3,r,n),e=i.base):(o&&!u&&(v(o),e=a=null),i=g(t.nodeName,l,r),e&&!i.__b&&(i.__b=e,a=null),m(i,l,1,r,n),e=i.base,a&&e!==a&&(a._component=null,d(a,!1)));return e}(e,t,r,n);if(j="svg"===y||"foreignObject"!==y&&j,y=String(y),(!e||!o(e,y))&&(c=y,(p=j?document.createElementNS("http://www.w3.org/2000/svg",c):document.createElement(c)).__n=c,f=p,e)){for(;e.firstChild;)f.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(f,e),d(e,!0)}var b=f.firstChild,w=f.__preactattr_,_=t.children;if(null==w){w=f.__preactattr_={};for(var S=f.attributes,x=S.length;x--;)w[S[x].name]=S[x].value}return!A&&_&&1===_.length&&"string"==typeof _[0]&&null!=b&&void 0!==b.splitText&&null==b.nextSibling?b.nodeValue!=_[0]&&(b.nodeValue=_[0]):(_&&_.length||null!=b)&&function(e,t,r,n,i){var s,u,f,l,c,p=e.childNodes,g=[],y={},m=0,b=0,v=p.length,w=0,_=t?t.length:0;if(0!==v)for(var S=0;S2?[].slice.call(arguments,2):t.children)},Component:w,render:function(e,t,r){return c(r,e,{},!1,t,!1)},rerender:i,options:S};void 0!==t?t.exports=R:self.preact=R}()},{}],32:[function(e,t,r){(function(e){"use strict";t.exports=!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?{nextTick:function(t,r,n,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,r)});case 3:return e.nextTick(function(){t.call(null,r,n)});case 4:return e.nextTick(function(){t.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===f.prototype||(t=function(e){return f.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):_(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?_(e,s,t,!1):T(e,s)):_(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=S?e=S:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function E(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(k,e):k(e))}function k(e){d("emit readable"),e.emit("readable"),j(e)}function T(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(C,e,t))}function C(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(i+=s===o.length?o:o.slice(0,e),0===(e-=s)){s===o.length?(++n,t.head=r.next?r.next:t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=f.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,t.head=n.next?n.next:t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function B(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(R,t,e))}function R(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function D(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):E(this),null;if(0===(e=x(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return d("need readable",i),(0===t.length||t.length-e0?A(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},v.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?l:v;function f(t,r){d("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),e.removeListener("close",m),e.removeListener("finish",b),e.removeListener("drain",c),e.removeListener("error",y),e.removeListener("unpipe",f),n.removeListener("end",l),n.removeListener("end",v),n.removeListener("data",g),h=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}function l(){d("onend"),e.end()}o.endEmitted?i.nextTick(u):n.once("end",u),e.on("unpipe",f);var c=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,j(e))}}(n);e.on("drain",c);var h=!1;var p=!1;function g(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==D(o.pipes,e))&&!h&&(d("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(t){d("onerror",t),v(),e.removeListener("error",y),0===a(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",b),v()}function b(){d("onfinish"),e.removeListener("close",m),v()}function v(){d("unpipe"),n.unpipe(e)}return n.on("data",g),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",y),e.once("close",m),e.once("finish",b),e.emit("pipe",n),o.flowing||(d("pipe resume"),n.resume()),e},v.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?i:o.nextTick;b.WritableState=m;var f=e("core-util-is");f.inherits=e("inherits");var l={deprecate:e("util-deprecate")},c=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,d=n.Uint8Array||function(){};var p,g=e("./internal/streams/destroy");function y(){}function m(t,r){a=a||e("./_stream_duplex");var n=r instanceof a;this.objectMode=!!(t=t||{}).objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,f=t.writableHighWaterMark;this.highWaterMark=i||0===i?i:n&&(f||0===f)?f:this.objectMode?16:16384,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1,this.decodeStrings=!(!1===t.decodeStrings),this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(o.nextTick(i,n),o.nextTick(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),E(e,t))}(e,r,n,t,i);else{var s=S(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||_(e,r),n?u(w,e,r,s,i):w(e,r,s,i)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function b(t){if(a=a||e("./_stream_duplex"),!(p.call(b,this)||this instanceof a))return new b(t);this._writableState=new m(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),c.call(this)}function v(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function w(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),E(e,t)}function _(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=new Array(t.bufferedRequestCount),i=t.corkedRequestsFree;i.entry=r;for(var o=0,a=!0;r;)n[o]=r,r.isBuf||(a=!1),r=r.next,o+=1;n.allBuffers=a,v(e,t,!0,t.length,n,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk;if(v(e,t,!1,t.objectMode?1:u.length,u,r.encoding,r.callback),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function S(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function x(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),E(e,t)})}function E(e,t){var r=S(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(x,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}f.inherits(b,c),m.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(m.prototype,"buffer",{get:l.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(b,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===b&&(e&&e._writableState instanceof m)}})):p=function(e){return e instanceof this},b.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},b.prototype.write=function(e,t,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(h.isBuffer(n=e)||n instanceof d);return a&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=y),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),o.nextTick(t,r)}(this,r):(a||function(e,t,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,e,r))&&(i.pendingcb++,s=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(b.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),b.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},b.prototype._writev=null,b.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,E(e,t),r&&(t.finished?o.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),b.prototype.destroy=g.destroy,b.prototype._undestroy=g.undestroy,b.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("timers").setImmediate)},{"./_stream_duplex":35,"./internal/streams/destroy":41,"./internal/streams/stream":42,_process:33,"core-util-is":8,inherits:24,"process-nextick-args":32,"safe-buffer":48,timers:55,"util-deprecate":56}],40:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return this.head=1===this.length?this.tail=null:this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t=n.allocUnsafe(e>>>0),r=this.head,i=0;r;)r.data.copy(t,i),i+=r.data.length,r=r.next;return t},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":48,util:6}],41:[function(e,t,r){"use strict";var n=e("process-nextick-args");function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this;return this._readableState&&this._readableState.destroyed||this._writableState&&this._writableState.destroyed?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n.nextTick(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":32}],42:[function(e,t,r){t.exports=e("events").EventEmitter},{events:10}],43:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":44}],44:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":35,"./lib/_stream_passthrough.js":36,"./lib/_stream_readable.js":37,"./lib/_stream_transform.js":38,"./lib/_stream_writable.js":39}],45:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":44}],46:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":39}],47:[function(e,t,r){(function(e){t.exports=function(t,r){var n,i,o,s=!0;Array.isArray(t)?(n=[],i=t.length):(o=Object.keys(t),n={},i=o.length);function a(t){function i(){r&&r(t,n),r=null}s?e.nextTick(i):i()}function u(e,t,r){n[e]=r,(0==--i||t)&&a(t)}i?o?o.forEach(function(e){t[e](function(t,r){u(e,t,r)})}):t.forEach(function(e,t){e(function(e,r){u(t,e,r)})}):a(null);s=!1}}).call(this,e("_process"))},{_process:33}],48:[function(e,t,r){var n=e("buffer"),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,r),r.Buffer=s),o(i,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:7}],49:[function(e,t,r){t.exports=i;var n=e("events").EventEmitter;function i(){n.call(this)}e("inherits")(i,n),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,e.end())}function u(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function f(e){if(l(),0===n.listenerCount(this,"error"))throw e}function l(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",f),e.removeListener("error",f),r.removeListener("end",l),r.removeListener("close",l),e.removeListener("close",l)}return r.on("error",f),e.on("error",f),r.on("end",l),r.on("close",l),e.on("close",l),e.emit("pipe",r),e}},{events:10,inherits:24,"readable-stream/duplex.js":34,"readable-stream/passthrough.js":43,"readable-stream/readable.js":44,"readable-stream/transform.js":45,"readable-stream/writable.js":46}],50:[function(e,t,r){"use strict";t.exports={DEFAULT_INITIAL_SIZE:8192,DEFAULT_INCREMENT_AMOUNT:8192,DEFAULT_FREQUENCY:1,DEFAULT_CHUNK_SIZE:1024}},{}],51:[function(e,t,r){(function(r){"use strict";var n=e("stream"),i=e("./constants"),o=e("util"),s=t.exports=function(e){var t=this;n.Readable.call(this,e=e||{}),this.stopped=!1;var o=e.hasOwnProperty("frequency")?e.frequency:i.DEFAULT_FREQUENCY,s=e.chunkSize||i.DEFAULT_CHUNK_SIZE,a=e.incrementAmount||i.DEFAULT_INCREMENT_AMOUNT,u=0,f=new r(e.initialSize||i.DEFAULT_INITIAL_SIZE),l=!1,c=function(){var e=Math.min(s,u),n=!1;if(e>0){var i;i=new r(e),f.copy(i,0,0,e),n=!1!==t.push(i),l=n,f.copy(f,0,e,u),u-=e}0===u&&t.stopped&&t.push(null),c.timeout=n?setTimeout(c,o):null};this.stop=function(){if(this.stopped)throw new Error("stop() called on already stopped ReadableStreamBuffer");this.stopped=!0,0===u&&this.push(null)},this.size=function(){return u},this.maxSize=function(){return f.length};var h=function(e){if(f.length-u>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("utf16le",0,this.lastTotal-this.lastNeed):t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function c(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":48}],55:[function(e,t,r){(function(t,n){var i=e("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},u=0;function f(e,t){this._id=e,this._clearFn=t}r.setTimeout=function(){return new f(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new f(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(e){e.close()},f.prototype.unref=f.prototype.ref=function(){},f.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},r.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},r._unrefActive=r.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r.setImmediate="function"==typeof t?t:function(e){var t=u++,n=!(arguments.length<2)&&s.call(arguments,1);return a[t]=!0,i(function(){a[t]&&(n?e.apply(null,n):e.call(null),r.clearImmediate(t))}),t},r.clearImmediate="function"==typeof n?n:function(e){delete a[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":33,timers:55}],56:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],57:[function(e,t,r){arguments[4][3][0].apply(r,arguments)},{dup:3}],58:[function(e,t,r){arguments[4][4][0].apply(r,arguments)},{"./support/isBuffer":57,_process:33,dup:4,inherits:24}],59:[function(e,t,r){t.exports=function e(t,r){if(t&&r)return e(t)(r);if("function"!=typeof t)throw new TypeError("need wrapper function");Object.keys(t).forEach(function(e){n[e]=t[e]});return n;function n(){for(var e=new Array(arguments.length),r=0;r0){var e=b.getContents(),t=new window.Blob([e],{type:"image/gif"});!function(e,t,r){var n=document.createElement("a");n.style.visibility="hidden",n.target="_blank",n.download=e,n.href=window.URL.createObjectURL(t),document.body.appendChild(n),n.onclick=function(){n.onclick=a,setTimeout(function(){window.URL.revokeObjectURL(t),document.body.removeChild(n),n.removeAttribute("href"),r(null)})},n.click()}("image.gif",t,function(){f(null)})}else f(null)})}}}},{"drag-drop":9,"gif-encoder":12,"javascript-natural-sort":27,"load-img":28,"map-limit":29,"stream-buffers":52}],63:[function(e,t,r){var n=e("preact"),i=n.render,o=n.h,s=e("./Encoder");i(o(function(){return o("main",null,o("div",{class:"top"},o("header",null,"giftool"),o("caption",null,"Drag and drop a folder or set of image frames to create a new GIF.")),o(s,null))},null),document.querySelector("#app"))},{"./Encoder":60,preact:31}]},{},[63]); -------------------------------------------------------------------------------- /public/main.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'SpaceGrotesk'; 3 | src: url('assets/fonts/SpaceGrotesk-Light.woff2') format('woff2'), 4 | url('assets/fonts/SpaceGrotesk-Light.woff') format('woff'); 5 | font-weight: 300; 6 | font-style: normal; 7 | } 8 | @font-face { 9 | font-family: 'SpaceGrotesk'; 10 | src: url('assets/fonts/SpaceGrotesk-Regular.woff2') format('woff2'), 11 | url('assets/fonts/SpaceGrotesk-Regular.woff') format('woff'); 12 | font-weight: 400; 13 | font-style: normal; 14 | } 15 | @font-face { 16 | font-family: 'SpaceGrotesk'; 17 | src: url('assets/fonts/SpaceGrotesk-Medium.woff2') format('woff2'), 18 | url('assets/fonts/SpaceGrotesk-Medium.woff') format('woff'); 19 | font-weight: 500; 20 | font-style: normal; 21 | } 22 | @font-face { 23 | font-family: 'SpaceGrotesk'; 24 | src: url('assets/fonts/SpaceGrotesk-Bold.woff2') format('woff2'), 25 | url('assets/fonts/SpaceGrotesk-Bold.woff') format('woff'); 26 | font-weight: 700; 27 | font-style: normal; 28 | } 29 | @font-face { 30 | font-family: 'SpaceGrotesk'; 31 | src: url('assets/fonts/SpaceGrotesk-SemiBold.woff2') format('woff2'), 32 | url('assets/fonts/SpaceGrotesk-SemiBold.woff') format('woff'); 33 | font-weight: 600; 34 | font-style: normal; 35 | } 36 | 37 | body, input { 38 | font-family: 'SpaceGrotesk'; 39 | font-size: 16px; 40 | } 41 | 42 | body { 43 | margin: 0; 44 | } 45 | 46 | body, html, main, #app { 47 | width: 100%; 48 | height: 100%; 49 | display: flex; 50 | justify-content: center; 51 | align-items: center; 52 | flex-direction: column; 53 | } 54 | 55 | .top { 56 | display: flex; 57 | justify-content: center; 58 | align-items: center; 59 | flex-direction: column; 60 | margin-bottom: 40px; 61 | } 62 | 63 | .top > header { 64 | font-size: 32px; 65 | font-weight: 400; 66 | letter-spacing: 2px; 67 | margin-top: 0px; 68 | } 69 | 70 | .top > caption { 71 | margin-top: 20px; 72 | max-width: 300px; 73 | line-height: 1.5; 74 | font-size: 16px; 75 | } 76 | 77 | .settings, .encoder-progress { 78 | border-radius: 5px; 79 | overflow: hidden; 80 | display: flex; 81 | justify-content: center; 82 | flex-direction: column; 83 | padding: 10px 20px; 84 | /* border: 1px solid hsl(0, 0%, 90%); */ 85 | box-shadow: 0px 2px 12px -2px rgba(0, 0, 0, 0.15); 86 | } 87 | 88 | .encoder-container { 89 | display: flex; 90 | justify-content: center; 91 | align-items: center; 92 | flex-direction: column; 93 | width: 100%; 94 | } 95 | 96 | .encoder { 97 | display: flex; 98 | padding: 20px; 99 | box-sizing: border-box; 100 | } 101 | 102 | .settings-row { 103 | display: flex; 104 | align-items: center; 105 | justify-content: center; 106 | flex-direction: row; 107 | height: 60px; 108 | 109 | padding-top: 0px; 110 | padding-bottom: 0px; 111 | border-bottom: 1px solid hsl(0, 0%, 95%); 112 | } 113 | .settings-row:first-child { 114 | padding-top: 0; 115 | } 116 | .settings-row:last-child { 117 | border-bottom: none; 118 | padding-bottom: 0; 119 | } 120 | 121 | .settings-row > label { 122 | display: flex; 123 | align-items: center; 124 | justify-content: flex-start; 125 | height: 100%; 126 | min-width: 100px; 127 | text-align: left; 128 | /* border-right: 1px solid hsl(0, 0%, 90%); */ 129 | padding: 0px; 130 | padding-right: 20px; 131 | font-weight: 500; 132 | /* background: hsl(0, 0%, 97%); */ 133 | } 134 | .settings-row:hover { 135 | /* background: hsl(0, 0%, 95%); */ 136 | } 137 | 138 | .settings-cell { 139 | font-weight: 300; 140 | width: 100%; 141 | min-width: 100px; 142 | padding: 0px; 143 | 144 | display: flex; 145 | align-items: flex-start; 146 | justify-content: flex-start; 147 | flex-direction: column; 148 | } 149 | 150 | .fps-picker, .fps-defaults, 151 | .fps-defaults > div, .size-picker, 152 | .encoder-progress { 153 | display: flex; 154 | align-items: center; 155 | justify-content: center; 156 | flex-direction: row; 157 | } 158 | .fps-defaults { 159 | 160 | margin-left: 0px; 161 | } 162 | .fps-defaults > div { 163 | margin-left: 20px; 164 | font-weight: 500; 165 | cursor: pointer; 166 | background: hsl(0, 0%, 90%); 167 | color: hsl(0, 0%, 45%); 168 | border-radius: 5px; 169 | padding: 5px; 170 | width: 20px; 171 | height: 20px; 172 | font-size: 12px; 173 | line-height: 60px; 174 | } 175 | .fps-defaults > div:hover { 176 | background: hsl(0, 0%, 85%); 177 | } 178 | 179 | .size-separator { 180 | margin: 10px; 181 | } 182 | 183 | input { 184 | min-width: 10px; 185 | width: 100%; 186 | box-sizing: border-box; 187 | margin: 0; 188 | outline: 0; 189 | padding: 0px; 190 | } 191 | 192 | input[type='range'] { 193 | cursor: pointer; 194 | } 195 | 196 | input[type='number'] { 197 | width: initial; 198 | width: 90px; 199 | padding: 5px 10px; 200 | } 201 | 202 | .slider { 203 | display: flex; 204 | flex-direction: row; 205 | } 206 | 207 | .quality-label { 208 | display: flex; 209 | min-width: 30px; 210 | align-items: center; 211 | justify-content: center; 212 | flex-direction: row; 213 | font-size: 12px; 214 | margin-left: 10px; 215 | } 216 | 217 | .quality-info { 218 | font-size: 12px; 219 | margin-top: 10px; 220 | opacity: 0.5; 221 | } 222 | 223 | .encoder-progress { 224 | display: flex; 225 | align-items: center; 226 | justify-content: center; 227 | flex-direction: column; 228 | } 229 | 230 | .encoder-progress > header { 231 | margin-bottom: 10px; 232 | } 233 | 234 | .canvas-container { 235 | width: 100%; 236 | } 237 | .canvas-container > canvas { 238 | width: 100%; 239 | height: auto; 240 | } -------------------------------------------------------------------------------- /src/Encoder.js: -------------------------------------------------------------------------------- 1 | /** @jsx h */ 2 | const { render, h, Component } = require('preact'); 3 | const dragDrop = require('drag-drop'); 4 | const EncoderProgress = require('./EncoderProgress'); 5 | 6 | class Encoder extends Component{ 7 | 8 | constructor () { 9 | super(); 10 | 11 | let prevSettings; 12 | let stored = window.localStorage.getItem('settings'); 13 | if (stored) { 14 | try { 15 | prevSettings = JSON.parse(stored); 16 | } catch (_) { 17 | // Skip err 18 | } 19 | } 20 | 21 | if (!prevSettings) { 22 | prevSettings = { 23 | dimensions: { 24 | mode: 'size', 25 | value: [ 512, 512 ] 26 | }, 27 | time: { 28 | mode: 'fps', 29 | value: 24 30 | }, 31 | quality: 10 32 | }; 33 | } 34 | this.state = { 35 | encoding: false, 36 | files: [], 37 | settings: prevSettings 38 | }; 39 | } 40 | 41 | onChangeQuality (ev) { 42 | this.setState({ 43 | settings: { 44 | ...this.state.settings, 45 | quality: ev.currentTarget.valueAsNumber 46 | } 47 | }); 48 | } 49 | 50 | onChangeFPS (ev) { 51 | this.setToFPS(ev.currentTarget.valueAsNumber) 52 | } 53 | 54 | setToFPS (value) { 55 | this.setState({ 56 | settings: { 57 | ...this.state.settings, 58 | time: { 59 | mode: 'fps', 60 | value 61 | } 62 | } 63 | }); 64 | } 65 | 66 | onChangeDimensions (index, ev) { 67 | const prevDimensions = this.state.settings.dimensions.value.slice(); 68 | prevDimensions[index] = ev.currentTarget.valueAsNumber; 69 | this.setState({ 70 | settings: { 71 | ...this.state.settings, 72 | dimensions: { 73 | mode: 'size', 74 | value: prevDimensions 75 | } 76 | } 77 | }); 78 | } 79 | 80 | componentDidMount () { 81 | this.store(this.state); 82 | 83 | dragDrop('#app', (files, pos, fileList, directories) => { 84 | this.encode(files); 85 | }); 86 | } 87 | 88 | componentWillUpdate (props, state) { 89 | this.store(state); 90 | } 91 | 92 | store (state) { 93 | window.localStorage.setItem('settings', JSON.stringify(state.settings)); 94 | } 95 | 96 | encode (files) { 97 | console.log('Encoding', files); 98 | this.setState({ 99 | files, 100 | encoding: true 101 | }); 102 | } 103 | 104 | onEncodeCancel () { 105 | this.setState({ 106 | encoding: false 107 | }); 108 | } 109 | 110 | onEncodeFinish () { 111 | this.setState({ 112 | encoding: false 113 | }); 114 | } 115 | 116 | renderSettings () { 117 | const { settings } = this.state; 118 | return
119 |
120 | 121 |
122 |
123 | 129 |
x
130 | 136 |
137 |
138 |
139 |
140 | 141 |
142 |
143 | 149 |
150 |
this.setToFPS(24)}>24
151 |
this.setToFPS(25)}>25
152 |
this.setToFPS(30)}>30
153 |
154 |
155 |
156 |
157 |
158 | 159 |
160 |
161 | 167 |
{settings.quality}
168 |
169 |
Lower number results in better visual quality.
170 |
171 |
172 |
173 | } 174 | 175 | render () { 176 | return
177 |
178 | {this.state.encoding 179 | ? 184 | : this.renderSettings()} 185 |
186 |
187 | } 188 | } 189 | 190 | module.exports = Encoder; -------------------------------------------------------------------------------- /src/EncoderProgress.js: -------------------------------------------------------------------------------- 1 | /** @jsx h */ 2 | const { render, h, Component } = require('preact'); 3 | const createEncoder = require('./createEncoder'); 4 | 5 | class EncoderProgress extends Component{ 6 | 7 | constructor (props) { 8 | super(props); 9 | this.state = { 10 | frame: 0, 11 | totalFrames: props.files.length, 12 | file: null 13 | }; 14 | } 15 | 16 | componentDidMount () { 17 | this.encoder = createEncoder(this.props.settings); 18 | this.canvasContainer.appendChild(this.encoder.canvas); 19 | this.encoder.encode( 20 | this.props.files, 21 | this.onFinish.bind(this), 22 | this.onProgress.bind(this) 23 | ) 24 | } 25 | 26 | onFinish () { 27 | this.props.onFinish(); 28 | } 29 | 30 | onProgress (ev) { 31 | this.setState({ 32 | frame: (1 + ev.frame), 33 | totalFrames: ev.totalFrames, 34 | file: ev.file 35 | }) 36 | } 37 | 38 | render () { 39 | return
40 |
41 | Encoding {this.state.frame} of {this.state.totalFrames} frames... 42 |
43 |
{ this.canvasContainer = c; }}> 44 |
45 |
46 | } 47 | } 48 | 49 | module.exports = EncoderProgress; -------------------------------------------------------------------------------- /src/createEncoder.js: -------------------------------------------------------------------------------- 1 | const GifEncoder = require('gif-encoder'); 2 | const dragDrop = require('drag-drop'); 3 | const mapLimit = require('map-limit'); 4 | const loadImg = require('load-img'); 5 | const sort = require('javascript-natural-sort'); 6 | const { WritableStreamBuffer } = require('stream-buffers'); 7 | const noop = () => {}; 8 | 9 | module.exports = (opt = {}) => { 10 | const tempCanvas = document.createElement('canvas'); 11 | const tempContext = tempCanvas.getContext('2d'); 12 | 13 | return { 14 | canvas: tempCanvas, 15 | context: tempContext, 16 | encode 17 | }; 18 | 19 | function encode (files, finished, onProgress) { 20 | const imageList = files.filter(file => /image/i.test(file.type)).map(file => { 21 | const numberMatch = /(\d+)(?!.*\d)/.exec(file.name); 22 | const index = numberMatch ? numberMatch[1] : file.name; 23 | return { 24 | file, 25 | index 26 | }; 27 | }); 28 | 29 | imageList.sort((a, b) => a.index - b.index); 30 | 31 | const images = imageList.map(e => e.file); 32 | const totalFrames = files.length; 33 | let frame = 0; 34 | 35 | const width = opt.dimensions.value[0]; 36 | const height = opt.dimensions.value[1]; 37 | 38 | const gif = new GifEncoder(width, height); 39 | gif.setFrameRate(opt.time.value); 40 | gif.setRepeat(0); 41 | gif.setQuality(opt.quality); 42 | 43 | tempCanvas.width = width; 44 | tempCanvas.height = height; 45 | 46 | const outStream = new WritableStreamBuffer({ 47 | initialSize: (20 * 1024), 48 | incrementAmount: (10 * 1024) 49 | }); 50 | 51 | // Start writing to output 52 | gif.pipe(outStream); 53 | gif.writeHeader(); 54 | 55 | const loadFile = (file, cb) => { 56 | const reader = new window.FileReader(); 57 | reader.onload = (ev) => { 58 | reader.onload = noop; 59 | loadImg(ev.target.result, cb); 60 | }; 61 | reader.onerror = () => { 62 | reader.onload = noop; 63 | cb(new Error(`Could not load ${file.name}`)); 64 | }; 65 | reader.readAsDataURL(file); 66 | }; 67 | 68 | const getPixels = (image, cb) => { 69 | tempContext.clearRect(0, 0, width, height); 70 | tempContext.drawImage(image, 0, 0, width, height); 71 | return tempContext.getImageData(0, 0, width, height).data; 72 | }; 73 | 74 | const encodeFrame = (file, cb) => { 75 | onProgress({ 76 | frame, 77 | totalFrames, 78 | name: file.name 79 | }); 80 | loadFile(file, (err, image) => { 81 | if (err) return cb(err); 82 | const pixels = getPixels(image); 83 | gif.addFrame(pixels); 84 | frame++; 85 | cb(null); 86 | }); 87 | }; 88 | 89 | const save = (filename, blob, cb) => { 90 | // force download 91 | const link = document.createElement('a'); 92 | link.style.visibility = 'hidden'; 93 | link.target = '_blank'; 94 | link.download = filename; 95 | link.href = window.URL.createObjectURL(blob); 96 | document.body.appendChild(link); 97 | link.onclick = () => { 98 | link.onclick = noop; 99 | setTimeout(() => { 100 | window.URL.revokeObjectURL(blob); 101 | document.body.removeChild(link); 102 | link.removeAttribute('href'); 103 | cb(null); 104 | }); 105 | }; 106 | link.click(); 107 | }; 108 | 109 | // Load each file 110 | mapLimit(images, 1, encodeFrame, () => { 111 | gif.finish(); 112 | if (images.length > 0) { 113 | const contents = outStream.getContents(); 114 | const type = 'image/gif'; 115 | const blob = new window.Blob([ contents ], { type }); 116 | save('image.gif', blob, () => { 117 | finished(null); 118 | }); 119 | } else { 120 | finished(null); 121 | } 122 | }); 123 | } 124 | }; 125 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | giftool 7 | 8 | 17 | 18 | 19 |
20 |
21 | {{entry}} 22 | 23 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | /** @jsx h */ 2 | const { render, h, Component } = require('preact'); 3 | const Encoder = require('./Encoder'); 4 | 5 | const App = () => { 6 | return
7 |
8 |
giftool
9 | Drag and drop a folder or set of image frames to create a new GIF. 10 |
11 | 12 |
; 13 | }; 14 | 15 | render(, document.querySelector('#app')) -------------------------------------------------------------------------------- /src/test.js: -------------------------------------------------------------------------------- 1 | /** @jsx h */ 2 | const { render, h } = require('preact'); 3 | const GifEncoder = require('gif-encoder'); 4 | const dragDrop = require('drag-drop'); 5 | const mapLimit = require('map-limit'); 6 | const loadImg = require('load-img'); 7 | const sort = require('javascript-natural-sort'); 8 | const { WritableStreamBuffer } = require('stream-buffers'); 9 | const noop = () => {}; 10 | 11 | const tempCanvas = document.createElement('canvas'); 12 | // document.body.appendChild(tempCanvas); 13 | const tempContext = tempCanvas.getContext('2d'); 14 | 15 | // You can pass in a DOM node or a selector string! 16 | dragDrop('#drop', function (files, pos, fileList, directories) { 17 | encode(files) 18 | 19 | // console.log('Dropped at coordinates', pos.x, pos.y) 20 | // console.log('Here is the raw FileList object if you need it:', fileList) 21 | // console.log('Here is the list of directories:', directories) 22 | 23 | // `files` is an Array! 24 | // files.forEach(function (file) { 25 | // console.log(file.name) 26 | // console.log(file.size) 27 | // console.log(file.type) 28 | // console.log(file.lastModifiedData) 29 | // console.log(file.fullPath) // not real full path due to browser security restrictions 30 | // console.log(file.path) // in Electron, this contains the actual full path 31 | 32 | // // convert the file to a Buffer that we can use! 33 | // var reader = new FileReader() 34 | // reader.addEventListener('load', function (e) { 35 | // // e.target.result is an ArrayBuffer 36 | // var arr = new Uint8Array(e.target.result) 37 | // var buffer = new Buffer(arr) 38 | 39 | // // do something with the buffer! 40 | // }) 41 | // reader.addEventListener('error', function (err) { 42 | // console.error('FileReader error' + err) 43 | // }) 44 | // reader.readAsArrayBuffer(file) 45 | // }) 46 | }) 47 | 48 | function encode (files) { 49 | const imageList = files.filter(file => /image/i.test(file.type)).map(file => { 50 | const numberMatch = /(\d+)(?!.*\d)/.exec(file.name); 51 | const index = numberMatch ? numberMatch[1] : file.name; 52 | return { 53 | file, 54 | index 55 | }; 56 | }); 57 | 58 | imageList.sort((a, b) => a.index - b.index); 59 | 60 | const images = imageList.map(e => e.file); 61 | const totalFrames = files.length; 62 | let frame = 0; 63 | 64 | const width = 256; 65 | const height = 256; 66 | 67 | const gif = new GifEncoder(width, height); 68 | gif.setFrameRate(24); 69 | gif.setRepeat(0); 70 | gif.setQuality(1); 71 | 72 | tempCanvas.width = width; 73 | tempCanvas.height = height; 74 | 75 | const outStream = new WritableStreamBuffer({ 76 | initialSize: (20 * 1024), 77 | incrementAmount: (10 * 1024) 78 | }); 79 | 80 | // Start writing to output 81 | gif.pipe(outStream); 82 | gif.writeHeader(); 83 | 84 | const loadFile = (file, cb) => { 85 | const reader = new window.FileReader(); 86 | reader.onload = (ev) => { 87 | reader.onload = noop; 88 | loadImg(ev.target.result, cb); 89 | }; 90 | reader.onerror = () => { 91 | reader.onload = noop; 92 | cb(new Error(`Could not load ${file.name}`)); 93 | }; 94 | reader.readAsDataURL(file); 95 | }; 96 | 97 | const getPixels = (image, cb) => { 98 | tempContext.clearRect(0, 0, width, height); 99 | tempContext.drawImage(image, 0, 0, width, height); 100 | return tempContext.getImageData(0, 0, width, height).data; 101 | }; 102 | 103 | const encodeFrame = (file, cb) => { 104 | console.log(`Encoding ${frame} of ${totalFrames} (${file.name})`); 105 | loadFile(file, (err, image) => { 106 | if (err) return cb(err); 107 | const pixels = getPixels(image); 108 | gif.addFrame(pixels); 109 | frame++; 110 | cb(null); 111 | }); 112 | }; 113 | 114 | const save = (filename, blob, cb) => { 115 | // force download 116 | const link = document.createElement('a'); 117 | link.style.visibility = 'hidden'; 118 | link.target = '_blank'; 119 | link.download = filename; 120 | link.href = window.URL.createObjectURL(blob); 121 | document.body.appendChild(link); 122 | link.onclick = () => { 123 | link.onclick = noop; 124 | setTimeout(() => { 125 | window.URL.revokeObjectURL(blob); 126 | document.body.removeChild(link); 127 | link.removeAttribute('href'); 128 | cb(null); 129 | }); 130 | }; 131 | link.click(); 132 | }; 133 | 134 | // Load each file 135 | mapLimit(images, 1, encodeFrame, () => { 136 | console.log('Done!'); 137 | gif.finish(); 138 | const contents = outStream.getContents(); 139 | const type = 'image/gif'; 140 | const blob = new window.Blob([ contents ], { type }); 141 | save('image.gif', blob, () => { 142 | console.log('Exported'); 143 | }); 144 | }); 145 | } 146 | --------------------------------------------------------------------------------