text: "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var zlib=require("zlib");function _interopDefaultLegacy(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var zlib__default=_interopDefaultLegacy(zlib),PNG=function(){function t(t){var e;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.text={};;){var a=this.readUInt32(),i="";for(e=0;e<4;e++)i+=String.fromCharCode(this.data[this.pos++]);switch(i){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"PLTE":this.palette=this.read(a);break;case"IDAT":for(e=0;e<a;e++)this.imgData.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:this.transparency.indexed=this.read(a);var r=255-this.transparency.indexed.length;if(r>0)for(e=0;e<r;e++)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(a)[0];break;case 2:this.transparency.rgb=this.read(a)}break;case"tEXt":var s=this.read(a),h=s.indexOf(0),o=String.fromCharCode.apply(String,s.slice(0,h));this.text[o]=String.fromCharCode.apply(String,s.slice(h+1));break;case"IEND":switch(this.colorType){case 0:case 3:case 4:this.colors=1;break;case 2:case 6:this.colors=3}this.hasAlphaChannel=[4,6].includes(this.colorType);var n=this.colors+(this.hasAlphaChannel?1:0);switch(this.pixelBitlength=this.bits*n,this.colors){case 1:this.colorSpace="DeviceGray";break;case 3:this.colorSpace="DeviceRGB"}return void(this.imgData=Buffer.from(this.imgData));default:this.pos+=a}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}t.decode=function(t,e){throw new Error("PNG.decode not available in browser build")},t.load=function(t){throw new Error("PNG.load not available in browser build")};var e=t.prototype;return e.read=function(t){for(var e=new Array(t),a=0;a<t;a++)e[a]=this.data[this.pos++];return e},e.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},e.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},e.decodePixels=function(t){var e=this;return zlib__default.default.inflate(this.imgData,function(a,i){if(a)throw a;var r=0,s=e.width,h=e.height,o=e.pixelBitlength/8,n=Buffer.alloc(s*h*o);function c(t,e,a,c,l){void 0===l&&(l=!1);for(var d=Math.ceil((s-t)/a),f=Math.ceil((h-e)/c),p=o*d,u=l?n:Buffer.alloc(p*f),b=0,v=0;b<f&&r<i.length;){var g,y,w,k,m;switch(i[r++]){case 0:for(w=0;w<p;w++)u[v++]=i[r++];break;case 1:for(w=0;w<p;w++)g=i[r++],k=w<o?0:u[v-o],u[v++]=(g+k)%256;break;case 2:for(w=0;w<p;w++)g=i[r++],y=(w-w%o)/o,m=b&&u[(b-1)*p+y*o+w%o],u[v++]=(m+g)%256;break;case 3:for(w=0;w<p;w++)g=i[r++],y=(w-w%o)/o,k=w<o?0:u[v-o],m=b&&u[(b-1)*p+y*o+w%o],u[v++]=(g+Math.floor((k+m)/2))%256;break;case 4:for(w=0;w<p;w++){var D,x;g=i[r++],y=(w-w%o)/o,k=w<o?0:u[v-o],0===b?m=x=0:(m=u[(b-1)*p+y*o+w%o],x=y&&u[(b-1)*p+(y-1)*o+w%o]);var P=k+m-x,I=Math.abs(P-k),M=Math.abs(P-m),_=Math.abs(P-x);D=I<=M&&I<=_?k:M<=_?m:x,u[v++]=(g+D)%256}break;default:throw new Error("Invalid filter algorithm: "+i[r-1])}if(!l){var C=((e+b*c)*s+t)*o,B=b*p;for(w=0;w<d;w++){for(var S=0;S<o;S++)n[C++]=u[B++];C+=(a-1)*o}}b++}}return 1===e.interlaceMethod?(c(0,0,8,8),c(4,0,8,8),c(0,4,4,8),c(2,0,4,4),c(0,2,2,4),c(1,0,2,2),c(0,1,1,2)):c(0,0,1,1,!0),t(n)})},e.decodePalette=function(){for(var t=this.palette,e=t.length,a=this.transparency.indexed||[],i=Buffer.alloc(a.length+e),r=0,s=0,h=0;h<e;h+=3){var o;i[r++]=t[h],i[r++]=t[h+1],i[r++]=t[h+2],i[r++]=null!=(o=a[s++])?o:255}return i},e.copyToImageData=function(t,e){var a,i,r=this.colors,s=null,h=this.hasAlphaChannel;this.palette.length&&(s=this._decodedPalette||(this._decodedPalette=this.decodePalette()),r=4,h=!0);var o=t.data||t,n=o.length,c=s||e,l=a=0;if(1===r)for(;l<n;){i=s?4*e[l/4]:a;var d=c[i++];o[l++]=d,o[l++]=d,o[l++]=d,o[l++]=h?c[i++]:255,a=i}else for(;l<n;)i=s?4*e[l/4]:a,o[l++]=c[i++],o[l++]=c[i++],o[l++]=c[i++],o[l++]=h?c[i++]:255,a=i},e.decode=function(t){var e=this,a=Buffer.alloc(this.width*this.height*4);return this.decodePixels(function(i){return e.copyToImageData(a,i),t(a)})},t}();exports.default=PNG;
  