!function t(e,i,r){function s(n,a){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!a&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var u=i[n]={exports:{}};e[n][0].call(u.exports,function(t){return s(e[n][1][t]||t)},u,u.exports,t,e,i,r)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=o.pageSize&&this.newPage(),this.pages[this.page][this.cursor++]=t},o.prototype.writeUTFBytes=function(t){for(var e=t.length,i=0;i=0&&(this.dispose=t)},a.prototype.setRepeat=function(t){this.repeat=t},a.prototype.setTransparent=function(t){this.transparent=t},a.prototype.addFrame=function(t){this.image=t,this.colorTab=this.globalPalette&&this.globalPalette.slice?this.globalPalette:null,this.getImagePixels(),this.analyzePixels(),!0===this.globalPalette&&(this.globalPalette=this.colorTab),this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.globalPalette||this.writePalette(),this.writePixels(),this.firstFrame=!1},a.prototype.finish=function(){this.out.writeByte(59)},a.prototype.setQuality=function(t){t<1&&(t=1),this.sample=t},a.prototype.setDither=function(t){!0===t&&(t="FloydSteinberg"),this.dither=t},a.prototype.setGlobalPalette=function(t){this.globalPalette=t},a.prototype.getGlobalPalette=function(){return this.globalPalette&&this.globalPalette.slice&&this.globalPalette.slice(0)||this.globalPalette},a.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")},a.prototype.analyzePixels=function(){this.colorTab||(this.neuQuant=new r(this.pixels,this.sample),this.neuQuant.buildColormap(),this.colorTab=this.neuQuant.getColormap()),this.dither?this.ditherPixels(this.dither.replace("-serpentine",""),null!==this.dither.match(/-serpentine/)):this.indexPixels(),this.pixels=null,this.colorDepth=8,this.palSize=7,null!==this.transparent&&(this.transIndex=this.findClosest(this.transparent,!0))},a.prototype.indexPixels=function(t){var e=this.pixels.length/3;this.indexedPixels=new Uint8Array(e);for(var i=0,r=0;r=0&&P+u=0&&m+l>16,(65280&t)>>8,255&t,e)},a.prototype.findClosestRGB=function(t,e,i,r){if(null===this.colorTab)return-1;if(this.neuQuant&&!r)return this.neuQuant.lookupRGB(t,e,i);for(var s=0,o=16777216,n=this.colorTab.length,a=0,h=0;a=0&&(e=7&dispose),e<<=2,this.out.writeByte(0|e|t),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)},a.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame||this.globalPalette?this.out.writeByte(0):this.out.writeByte(128|this.palSize)},a.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)},a.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)},a.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var t=768-this.colorTab.length,e=0;e>8&255)},a.prototype.writePixels=function(){new s(this.width,this.height,this.indexedPixels,this.colorDepth).encode(this.out)},a.prototype.stream=function(){return this.out},e.exports=a},{"./LZWEncoder.js":2,"./TypedNeuQuant.js":3}],2:[function(t,e,i){var r=-1,s=12,o=5003,n=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];e.exports=function(t,e,i,a){var h,l,u,p,f,c,y=Math.max(2,a),w=new Uint8Array(256),d=new Int32Array(o),g=new Int32Array(o),x=0,b=0,v=!1;function P(t,e){w[l++]=t,l>=254&&S(e)}function m(t){B(o),b=f+2,v=!0,M(f,t)}function B(t){for(var e=0;e0&&(t.writeByte(l),t.writeBytes(w,0,l),l=0)}function T(t){return(1<0?h|=t<=8;)P(255&h,e),h>>=8,x-=8;if((b>u||v)&&(v?(u=T(n_bits=p),v=!1):(++n_bits,u=n_bits==s?1<0;)P(255&h,e),h>>=8,x-=8;S(e)}}this.encode=function(i){i.writeByte(y),remaining=t*e,curPixel=0,function(t,e){var i,n,a,h,y,w,x;for(p=t,v=!1,n_bits=p,u=T(n_bits),c=1+(f=1<=0){y=w-a,0===a&&(y=1);do{if((a-=y)<0&&(a+=w),d[a]===i){h=g[a];continue t}}while(d[a]>=0)}M(h,e),h=n,b<1<>l,p=a<>3),c=1024,y=1<<18;e.exports=function(t,e){var i,w,d,g,x;function b(t,e,r,s,o){i[e][0]-=t*(i[e][0]-r)/c,i[e][1]-=t*(i[e][1]-s)/c,i[e][2]-=t*(i[e][2]-o)/c}function v(t,e,s,o,n){for(var a,h,l=Math.abs(e-t),u=Math.min(e+t,r),p=e+1,f=e-1,c=1;pl;)h=x[c++],pl&&((a=i[f--])[0]-=h*(a[0]-s)/y,a[1]-=h*(a[1]-o)/y,a[2]-=h*(a[2]-n)/y)}function P(t,e,s){var a,f,c,y,w,x=~(1<<31),b=x,v=-1,P=v;for(a=0;a>n-o))>l,g[a]-=w,d[a]+=w<>3),t=0;t>6;for(g<=1&&(g=0),i=0;i=l&&(m-=l),i++,0===y&&(y=1),i%y==0)for(w-=w/u,(g=(d-=d/30)>>6)<=1&&(g=0),h=0;h>=o,i[t][1]>>=o,i[t][2]>>=o,i[t][3]=t}(),function(){var t,e,o,n,a,h,l=0,u=0;for(t=0;t>1,e=l+1;e>1,e=l+1;e<256;e++)w[e]=s}()},this.getColormap=function(){for(var t=[],e=[],s=0;s=0;)u=h?u=r:(u++,a<0&&(a=-a),(o=n[0]-t)<0&&(o=-o),(a+=o)=0&&((a=e-(n=i[p])[1])>=h?p=-1:(p--,a<0&&(a=-a),(o=n[0]-t)<0&&(o=-o),(a+=o)