MCPcopy
hub / github.com/DustinBrett/daedalOS / w

Function w

public/System/Hexells/UPNG.min.js:1–1  ·  view source on GitHub ↗
(r,e,t)

Source from the content-addressed store, hash-verified

1var UPNG=function(){var r={nextZero:function(r,e){for(;0!=r[e];)e++;return e},readUshort:function(r,e){return r[e]<<8|r[e+1]},writeUshort:function(r,e,t){r[e]=t>>8&255,r[e+1]=255&t},readUint:function(r,e){return 16777216*r[e]+(r[e+1]<<16|r[e+2]<<8|r[e+3])},writeUint:function(r,e,t){r[e]=t>>24&255,r[e+1]=t>>16&255,r[e+2]=t>>8&255,r[e+3]=255&t},readASCII:function(r,e,t){for(var _="",$=0;$<t;$++)_+=String.fromCharCode(r[e+$]);return _},writeASCII:function(r,e,t){for(var _=0;_<t.length;_++)r[e+_]=t.charCodeAt(_)},readBytes:function(r,e,t){for(var _=[],$=0;$<t;$++)_.push(r[e+$]);return _},pad:function(r){return r.length<2?"0"+r:r},readUTF8:function(e,t,_){for(var $,n="",f=0;f<_;f++)n+="%"+r.pad(e[t+f].toString(16));try{$=decodeURIComponent(n)}catch(a){return r.readASCII(e,t,_)}return $}};function e(e,t,_,$){var f=t*_,a=Math.ceil(t*n($)/8),i=new Uint8Array(4*f),o=new Uint32Array(i.buffer),l=$.ctype,v=$.depth,s=r.readUshort;if(Date.now(),6==l){var u=f<<2;if(8==v)for(var h=0;h<u;h+=4)i[h]=e[h],i[h+1]=e[h+1],i[h+2]=e[h+2],i[h+3]=e[h+3];if(16==v)for(var h=0;h<u;h++)i[h]=e[h<<1]}else if(2==l){var c=$.tabs.tRNS;if(null==c){if(8==v)for(var h=0;h<f;h++){var d=3*h;o[h]=-16777216|e[d+2]<<16|e[d+1]<<8|e[d]}if(16==v)for(var h=0;h<f;h++){var d=6*h;o[h]=-16777216|e[d+4]<<16|e[d+2]<<8|e[d]}}else{var g=c[0],b=c[1],w=c[2];if(8==v)for(var h=0;h<f;h++){var p=h<<2,d=3*h;o[h]=-16777216|e[d+2]<<16|e[d+1]<<8|e[d],e[d]==g&&e[d+1]==b&&e[d+2]==w&&(i[p+3]=0)}if(16==v)for(var h=0;h<f;h++){var p=h<<2,d=6*h;o[h]=-16777216|e[d+4]<<16|e[d+2]<<8|e[d],s(e,d)==g&&s(e,d+2)==b&&s(e,d+4)==w&&(i[p+3]=0)}}}else if(3==l){var m=$.tabs.PLTE,x=$.tabs.tRNS,y=x?x.length:0;if(1==v)for(var U=0;U<_;U++)for(var I=U*a,C=U*t,h=0;h<t;h++){var p=C+h<<2,N=e[I+(h>>3)]>>7-((7&h)<<0)&1,P=3*N;i[p]=m[P],i[p+1]=m[P+1],i[p+2]=m[P+2],i[p+3]=N<y?x[N]:255}if(2==v)for(var U=0;U<_;U++)for(var I=U*a,C=U*t,h=0;h<t;h++){var p=C+h<<2,N=e[I+(h>>2)]>>6-((3&h)<<1)&3,P=3*N;i[p]=m[P],i[p+1]=m[P+1],i[p+2]=m[P+2],i[p+3]=N<y?x[N]:255}if(4==v)for(var U=0;U<_;U++)for(var I=U*a,C=U*t,h=0;h<t;h++){var p=C+h<<2,N=e[I+(h>>1)]>>4-((1&h)<<2)&15,P=3*N;i[p]=m[P],i[p+1]=m[P+1],i[p+2]=m[P+2],i[p+3]=N<y?x[N]:255}if(8==v)for(var h=0;h<f;h++){var p=h<<2,N=e[h],P=3*N;i[p]=m[P],i[p+1]=m[P+1],i[p+2]=m[P+2],i[p+3]=N<y?x[N]:255}}else if(4==l){if(8==v)for(var h=0;h<f;h++){var p=h<<2,T=h<<1,A=e[T];i[p]=A,i[p+1]=A,i[p+2]=A,i[p+3]=e[T+1]}if(16==v)for(var h=0;h<f;h++){var p=h<<2,T=h<<2,A=e[T];i[p]=A,i[p+1]=A,i[p+2]=A,i[p+3]=e[T+2]}}else if(0==l)for(var g=$.tabs.tRNS?$.tabs.tRNS:-1,U=0;U<_;U++){var R=U*a,G=U*t;if(1==v)for(var S=0;S<t;S++){var A=255*(e[R+(S>>>3)]>>>7-(7&S)&1),L=A==255*g?0:255;o[G+S]=L<<24|A<<16|A<<8|A}else if(2==v)for(var S=0;S<t;S++){var A=85*(e[R+(S>>>2)]>>>6-((3&S)<<1)&3),L=A==85*g?0:255;o[G+S]=L<<24|A<<16|A<<8|A}else if(4==v)for(var S=0;S<t;S++){var A=17*(e[R+(S>>>1)]>>>4-((1&S)<<2)&15),L=A==17*g?0:255;o[G+S]=L<<24|A<<16|A<<8|A}else if(8==v)for(var S=0;S<t;S++){var A=e[R+S],L=A==g?0:255;o[G+S]=L<<24|A<<16|A<<8|A}else if(16==v)for(var S=0;S<t;S++){var A=e[R+(S<<1)],L=s(e,R+(S<<1))==g?0:255;o[G+S]=L<<24|A<<16|A<<8|A}}return i}function t(r,e,t,a){Date.now();var i=n(r),o=new Uint8Array((Math.ceil(t*i/8)+1+r.interlace)*a);return e=r.tabs.CgBI?$(e,o):_(e,o),Date.now(),0==r.interlace?e=f(e,r,0,t,a):1==r.interlace&&(e=function r(e,t){for(var _=t.width,$=t.height,a=n(t),i=a>>3,o=Math.ceil(_*a/8),l=new Uint8Array($*o),v=0,s=[0,0,4,0,2,0,1],u=[0,4,0,2,0,1,0],h=[8,8,8,4,4,2,2],c=[8,8,4,4,2,2,1],d=0;d<7;){for(var g=h[d],b=c[d],w=0,p=0,m=s[d];m<$;)m+=g,p++;for(var x=u[d];x<_;)x+=b,w++;var y=Math.ceil(w*a/8);f(e,t,v,w,p);for(var U=0,I=s[d];I<$;){for(var C=u[d],N=v+U*y<<3;C<_;){if(1==a){var P=e[N>>3];P=P>>7-(7&N)&1,l[I*o+(C>>3)]|=P<<7-((7&C)<<0)}if(2==a){var P=e[N>>3];P=P>>6-(7&N)&3,l[I*o+(C>>2)]|=P<<6-((3&C)<<1)}if(4==a){var P=e[N>>3];P=P>>4-(7&N)&15,l[I*o+(C>>1)]|=P<<4-((1&C)<<2)}if(a>=8)for(var T=I*o+C*i,A=0;A<i;A++)l[T+A]=e[(N>>3)+A];N+=a,C+=b}U++,I+=g}w*p!=0&&(v+=p*(1+y)),d+=1}return l}(e,r)),e}function _(r,e){return $(new Uint8Array(r.buffer,2,r.length-6),e)}var $=function(){var r,e,t=(r=Uint16Array,e=Uint32Array,{m:new r(16),v:new r(16),d:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],o:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],z:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],B:new r(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],w:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],h:new e(32),g:new r(512),s:[],A:new r(32),t:[],k:new r(32768),c:[],a:[],n:new r(32768),e:[],C:new r(512),b:[],i:new r(32768),r:new e(286),f:new e(30),l:new e(19),u:new e(15e3),q:new r(65536),j:new r(32768)});function _(r,e){for(var _,$,n,f,a,i=r.length,o=t.v,f=0;f<=e;f++)o[f]=0;for(f=1;f<i;f+=2)o[r[f]]++;var l=t.m;for($=1,_=0,o[0]=0;$<=e;$++)_=_+o[$-1]<<1,l[$]=_;for(n=0;n<i;n+=2)0!=(a=r[n+1])&&(r[n]=l[a],l[a]++)}function $(r,e,_){for(var $=r.length,n=t.i,f=0;f<$;f+=2)if(0!=r[f+1])for(var a=f>>1,i=r[f+1],o=a<<4|i,l=e-i,v=r[f]<<l,s=v+(1<<l);v!=s;)_[n[v]>>>15-e]=o,v++}function n(r,e){for(var _=t.i,$=15-e,n=0;n<r.length;n+=2){var f=r[n]<<e-r[n+1];r[n]=_[f]>>>$}}function f(r,e,t){return(r[e>>>3]|r[(e>>>3)+1]<<8)>>>(7&e)&(1<<t)-1}function a(r,e,t){return(r[e>>>3]|r[(e>>>3)+1]<<8|r[(e>>>3)+2]<<16)>>>(7&e)&(1<<t)-1}function i(r,e){return(r[e>>>3]|r[(e>>>3)+1]<<8|r[(e>>>3)+2]<<16)>>>(7&e)}function o(r,e){return(r[e>>>3]|r[(e>>>3)+1]<<8|r[(e>>>3)+2]<<16|r[(e>>>3)+3]<<24)>>>(7&e)}function l(r,e){var t=r.length;if(e<=t)return r;var _=new Uint8Array(Math.max(t<<1,e));return _.set(r,0),_}function v(r,e,t,_,$,n){for(var a=0;a<t;){var o=r[i(_,$)&e];$+=15&o;var l=o>>>4;if(l<=15)n[a]=l,a++;else{var v=0,s=0;16==l?(s=3+f(_,$,2),$+=2,v=n[a-1]):17==l?(s=3+f(_,$,3),$+=3):18==l&&(s=11+f(_,$,7),$+=7);for(var u=a+s;a<u;)n[a]=v,a++}}return $}function s(r,e,t,_){for(var $=0,n=0,f=_.length>>>1;n<t;){var a=r[n+e];_[n<<1]=0,_[(n<<1)+1]=a,a>$&&($=a),n++}for(;n<f;)_[n<<1]=0,_[(n<<1)+1]=0,n++;return $}return!function(){for(var r=0;r<32768;r++){var e=r;e=(4278255360&(e=(4042322160&(e=(3435973836&(e=(2863311530&e)>>>1|(1431655765&e)<<1))>>>2|(858993459&e)<<2))>>>4|(252645135&e)<<4))>>>8|(16711935&e)<<8,t.i[r]=(e>>>16|e<<16)>>>17}function f(r,e,t){for(;0!=e--;)r.push(0,t)}for(var r=0;r<32;r++)t.B[r]=t.o[r]<<3|t.z[r],t.h[r]=t.p[r]<<4|t.w[r];f(t.s,144,8),f(t.s,112,9),f(t.s,24,7),f(t.s,8,8),_(t.s,9),$(t.s,9,t.g),n(t.s,9),f(t.t,32,5),_(t.t,5),$(t.t,5,t.A),n(t.t,5),f(t.b,19,0),f(t.c,286,0),f(t.e,30,0),f(t.a,320,0)}(),function r(e,n){var o,u,h=Uint8Array,c=0,d=0,g=0,b=0,w=0,p=0,m=0,x=0,y=0;if(3==e[0]&&0==e[1])return n||new h(0);var U=null==n;for(U&&(n=new h(e.length>>>2<<3));0==c;){if(c=a(e,y,1),d=a(e,y+1,2),y+=3,0==d){(7&y)!=0&&(y+=8-(7&y));var I=(y>>>3)+4,C=e[I-4]|e[I-3]<<8;U&&(n=l(n,x+C)),n.set(new h(e.buffer,e.byteOffset+I,C),x),y=I+C<<3,x+=C;continue}if(U&&(n=l(n,x+131072)),1==d&&(o=t.g,u=t.A,p=511,m=31),2==d){g=f(e,y,5)+257,b=f(e,y+5,5)+1,w=f(e,y+10,4)+4;for(var N=y+=14,P=1,T=0;T<38;T+=2)t.b[T]=0,t.b[T+1]=0;for(var T=0;T<w;T++){var A=f(e,y+3*T,3);t.b[(t.d[T]<<1)+1]=A,A>P&&(P=A)}y+=3*w,_(t.b,P),$(t.b,P,t.C),o=t.k,u=t.n,y=v(t.C,(1<<P)-1,g+b,e,y,t.a);var R=s(t.a,0,g,t.c);p=(1<<R)-1;var G=s(t.a,g,b,t.e);m=(1<<G)-1,_(t.c,R),$(t.c,R,o),_(t.e,G),$(t.e,G,u)}for(;;){var S=o[i(e,y)&p];y+=15&S;var L=S>>>4;if(L>>>8==0)n[x++]=L;else if(256==L)break;else{var q=x+L-254;if(L>264){var B=t.B[L-257];q=x+(B>>>3)+f(e,y,7&B),y+=7&B}var H=u[i(e,y)&m];y+=15&H;var k=H>>>4,D=t.h[k],E=(D>>>4)+a(e,y,15&D);for(y+=15&D,U&&(n=l(n,x+131072));x<q;)n[x]=n[x++-E],n[x]=n[x++-E],n[x]=n[x++-E],n[x]=n[x++-E];x=q}}}return n.length==x?n:n.slice(0,x)}}();function n(r){return[1,null,3,1,2,null,4][r.ctype]*r.depth}function f(r,e,t,_,$){var f=n(e),i=Math.ceil(_*f/8);f=Math.ceil(f/8);var o,l,v=r[t],s=0;if(v>1&&(r[t]=[0,0,1][v-2]),3==v)for(s=f;s<i;s++)r[s+1]=r[s+1]+(r[s+1-f]>>>1)&255;for(var u=0;u<$;u++)if(v=r[(l=(o=t+u*i)+u+1)-1],s=0,0==v)for(;s<i;s++)r[o+s]=r[l+s];else if(1==v){for(;s<f;s++)r[o+s]=r[l+s];for(;s<i;s++)r[o+s]=r[l+s]+r[o+s-f]}else if(2==v)for(;s<i;s++)r[o+s]=r[l+s]+r[o+s-i];else if(3==v){for(;s<f;s++)r[o+s]=r[l+s]+(r[o+s-i]>>>1);for(;s<i;s++)r[o+s]=r[l+s]+(r[o+s-i]+r[o+s-f]>>>1)}else{for(;s<f;s++)r[o+s]=r[l+s]+a(0,r[o+s-i],0);for(;s<i;s++)r[o+s]=r[l+s]+a(r[o+s-f],r[o+s-i],r[o+s-f-i])}return r}function a(r,e,t){var _=r+e-t,$=_-r,n=_-e,f=_-t;return $*$<=n*n&&$*$<=f*f?r:n*n<=f*f?e:t}function i(e,t,_){_.width=r.readUint(e,t),t+=4,_.height=r.readUint(e,t),t+=4,_.depth=e[t],t++,_.ctype=e[t],t++,_.compress=e[t],t++,_.filter=e[t],t++,_.interlace=e[t],t++}function o(r,e,t,_,$,n,f,a,i){for(var o=Math.min(e,$),l=Math.min(t,n),v=0,s=0,u=0;u<l;u++)for(var h=0;h<o;h++)if(f>=0&&a>=0?(v=u*e+h<<2,s=(a+u)*$+f+h<<2):(v=(-a+u)*e-f+h<<2,s=u*$+h<<2),0==i)_[s]=r[v],_[s+1]=r[v+1],_[s+2]=r[v+2],_[s+3]=r[v+3];else if(1==i){var c=r[v+3]*(1/255),d=r[v]*c,g=r[v+1]*c,b=r[v+2]*c,w=_[s+3]*(1/255),p=_[s]*w,m=_[s+1]*w,x=_[s+2]*w,y=1-c,U=c+w*y,I=0==U?0:1/U;_[s+3]=255*U,_[s+0]=(d+p*y)*I,_[s+1]=(g+m*y)*I,_[s+2]=(b+x*y)*I}else if(2==i){var c=r[v+3],d=r[v],g=r[v+1],b=r[v+2],w=_[s+3],p=_[s],m=_[s+1],x=_[s+2];c==w&&d==p&&g==m&&b==x?(_[s]=0,_[s+1]=0,_[s+2]=0,_[s+3]=0):(_[s]=d,_[s+1]=g,_[s+2]=b,_[s+3]=c)}else if(3==i){var c=r[v+3],d=r[v],g=r[v+1],b=r[v+2],w=_[s+3],p=_[s],m=_[s+1],x=_[s+2];if(c==w&&d==p&&g==m&&b==x)continue;if(c<220&&w>20)return!1}return!0}return{decode:function e(n){for(var f,a=new Uint8Array(n),o=8,l=r,v=l.readUshort,s=l.readUint,u={tabs:{},frames:[]},h=new Uint8Array(a.length),c=0,d=0,g=[137,80,78,71,13,10,26,10],b=0;b<8;b++)if(a[b]!=g[b])throw"The input is not a PNG file!";for(;o<a.length;){var w=l.readUint(a,o);o+=4;var p=l.readASCII(a,o,4);if(o+=4,"IHDR"==p)i(a,o,u);else if("iCCP"==p){for(var m=o;0!=a[m];)m++;var x=l.readASCII(a,o,m-o);a[m+1];var y=a.slice(m+2,o+w),U=null;try{U=_(y)}catch(I){U=$(y)}u.tabs[p]=U}else if("CgBI"==p)u.tabs[p]=a.slice(o,o+4);else if("IDAT"==p){for(var b=0;b<w;b++)h[c+b]=a[o+b];c+=w}else if("acTL"==p)u.tabs[p]={num_frames:s(a,o),num_plays:s(a,o+4)},f=new Uint8Array(a.length);else if("fcTL"==p){if(0!=d){var C=u.frames[u.frames.length-1];C.data=t(u,f.slice(0,d),C.rect.width,C.rect.height),d=0}var N={x:s(a,o+12),y:s(a,o+16),width:s(a,o+4),height:s(a,o+8)},P=v(a,o+22);P=v(a,o+20)/(0==P?100:P);var T={rect:N,delay:Math.round(1e3*P),dispose:a[o+24],blend:a[o+25]};u.frames.push(T)}else if("fdAT"==p){for(var b=0;b<w-4;b++)f[d+b]=a[o+b+4];d+=w-4}else if("pHYs"==p)u.tabs[p]=[l.readUint(a,o),l.readUint(a,o+4),a[o+8]];else if("cHRM"==p){u.tabs[p]=[];for(var b=0;b<8;b++)u.tabs[p].push(l.readUint(a,o+4*b))}else if("tEXt"==p||"zTXt"==p){null==u.tabs[p]&&(u.tabs[p]={});var A,R=l.nextZero(a,o),G=l.readASCII(a,o,R-o),S=o+w-R-1;if("tEXt"==p)A=l.readASCII(a,R+1,S);else{var L=_(a.slice(R+2,R+2+S));A=l.readUTF8(L,0,L.length)}u.tabs[p][G]=A}else if("iTXt"==p){null==u.tabs[p]&&(u.tabs[p]={});var R=0,m=o;R=l.nextZero(a,m);var G=l.readASCII(a,m,R-m),q=a[m=R+1];a[m+1],m+=2,R=l.nextZero(a,m);var B=l.readASCII(a,m,R-m);m=R+1,R=l.nextZero(a,m);var A,H=l.readUTF8(a,m,R-m),S=w-((m=R+1)-o);if(0==q)A=l.readUTF8(a,m,S);else{var L=_(a.slice(m,m+S));A=l.readUTF8(L,0,L.length)}u.tabs[p][G]=A}else if("PLTE"==p)u.tabs[p]=l.readBytes(a,o,w);else if("hIST"==p){var k=u.tabs.PLTE.length/3;u.tabs[p]=[];for(var b=0;b<k;b++)u.tabs[p].push(v(a,o+2*b))}else if("tRNS"==p)3==u.ctype?u.tabs[p]=l.readBytes(a,o,w):0==u.ctype?u.tabs[p]=v(a,o):2==u.ctype&&(u.tabs[p]=[v(a,o),v(a,o+2),v(a,o+4)]);else if("gAMA"==p)u.tabs[p]=l.readUint(a,o)/1e5;else if("sRGB"==p)u.tabs[p]=a[o];else if("bKGD"==p)0==u.ctype||4==u.ctype?u.tabs[p]=[v(a,o)]:2==u.ctype||6==u.ctype?u.tabs[p]=[v(a,o),v(a,o+2),v(a,o+4)]:3==u.ctype&&(u.tabs[p]=a[o]);else if("IEND"==p)break;o+=w;var D=l.readUint(a,o);o+=4}if(0!=d){var C=u.frames[u.frames.length-1];C.data=t(u,f.slice(0,d),C.rect.width,C.rect.height)}return u.data=t(u,h,u.width,u.height),delete u.compress,delete u.interlace,delete u.filter,u},toRGBA8:function r(t){var _=t.width,$=t.height;if(null==t.tabs.acTL)return[e(t.data,_,$,t).buffer];var n=[];null==t.frames[0].data&&(t.frames[0].data=t.data);for(var f=_*$*4,a=new Uint8Array(f),i=new Uint8Array(f),l=new Uint8Array(f),v=0;v<t.frames.length;v++){var s=t.frames[v],u=s.rect.x,h=s.rect.y,c=s.rect.width,d=s.rect.height,g=e(s.data,c,d,t);if(0!=v)for(var b=0;b<f;b++)l[b]=a[b];if(0==s.blend?o(g,c,d,a,_,$,u,h,0):1==s.blend&&o(g,c,d,a,_,$,u,h,1),n.push(a.buffer.slice(0)),0==s.dispose);else if(1==s.dispose)o(i,c,d,a,_,$,u,h,0);else if(2==s.dispose)for(var b=0;b<f;b++)a[b]=l[b]}return n},_paeth:a,_copyTile:o,_bin:r}}();!function(){var r=UPNG._copyTile,e=UPNG._bin,t=UPNG._paeth,_={table:function(){for(var r=new Uint32Array(256),e=0;e<256;e++){for(var t=e,_=0;_<8;_++)1&t?t=3988292384^t>>>1:t>>>=1;r[e]=t}return r}(),update:function(r,e,t,$){for(var n=0;n<$;n++)r=_.table[(r^e[t+n])&255]^r>>>8;return r},crc:function(r,e,t){return 4294967295^_.update(4294967295,r,e,t)}};function $(r,e,t,_){e[t]+=r[0]*_>>4,e[t+1]+=r[1]*_>>4,e[t+2]+=r[2]*_>>4,e[t+3]+=r[3]*_>>4}function n(r){return Math.max(0,Math.min(255,r))}function f(r,e){var t=r[0]-e[0],_=r[1]-e[1],$=r[2]-e[2],n=r[3]-e[3];return t*t+_*_+$*$+n*n}function a(r,e,t,_,a,i,o){null==o&&(o=1);for(var l=_.length,v=[],s=[],u=0;u<l;u++){var h=_[u];v.push([h>>>0&255,h>>>8&255,h>>>16&255,h>>>24&255])}for(var u=0;u<l;u++){for(var c=4294967295,d=0,g=0;g<l;g++){var b=f(v[u],v[g]);g!=u&&b<c&&(c=b,d=g)}var w=Math.sqrt(c)/2;s[u]=~~(w*w)}for(var p=new Uint32Array(a.buffer),m=new Int16Array(e*t*4),x=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5],u=0;u<x.length;u++)x[u]=255*(-.5+(x[u]+.5)/16);for(var y=0;y<t;y++)for(var U=0;U<e;U++){var I,u=(y*e+U)*4;if(2!=o)I=[n(r[u]+m[u]),n(r[u+1]+m[u+1]),n(r[u+2]+m[u+2]),n(r[u+3]+m[u+3])];else{var b=x[(3&y)*4+(3&U)];I=[n(r[u]+b),n(r[u+1]+b),n(r[u+2]+b),n(r[u+3]+b)]}for(var d=0,C=16777215,g=0;g<l;g++){var N=f(I,v[g]);N<C&&(C=N,d=g)}var P=v[d],T=[I[0]-P[0],I[1]-P[1],I[2]-P[2],I[3]-P[3]];1==o&&(U!=e-1&&$(T,m,u+4,7),y!=t-1&&(0!=U&&$(T,m,u+4*e-4,3),$(T,m,u+4*e,5),U!=e-1&&$(T,m,u+4*e+4,1))),i[u>>2]=d,p[u>>2]=_[d]}}function i(r,t,$,n,f){null==f&&(f={});var a,i=_.crc,o=e.writeUint,l=e.writeUshort,v=e.writeASCII,s=8,u=r.frames.length>1,h=!1,c=33+(u?20:0);if(null!=f.sRGB&&(c+=13),null!=f.pHYs&&(c+=21),null!=f.iCCP&&(c+=21+(a=pako.deflate(f.iCCP)).length+4),3==r.ctype){for(var d=r.plte.length,g=0;g<d;g++)r.plte[g]>>>24!=255&&(h=!0);c+=8+3*d+4+(h?8+1*d+4:0)}for(var b=0;b<r.frames.length;b++){var w=r.frames[b];u&&(c+=38),c+=w.cimg.length+12,0!=b&&(c+=4)}c+=12;for(var p=new Uint8Array(c),m=[137,80,78,71,13,10,26,10],g=0;g<8;g++)p[g]=m[g];if(o(p,s,13),v(p,s+=4,"IHDR"),o(p,s+=4,t),o(p,s+=4,$),p[s+=4]=r.depth,p[++s]=r.ctype,p[++s]=0,p[++s]=0,p[++s]=0,o(p,++s,i(p,s-17,17)),s+=4,null!=f.sRGB&&(o(p,s,1),v(p,s+=4,"sRGB"),p[s+=4]=f.sRGB,o(p,++s,i(p,s-5,5)),s+=4),null!=f.iCCP){var x=13+a.length;o(p,s,x),v(p,s+=4,"iCCP"),v(p,s+=4,"ICC profile"),s+=11,s+=2,p.set(a,s),o(p,s+=a.length,i(p,s-(x+4),x+4)),s+=4}if(null!=f.pHYs&&(o(p,s,9),v(p,s+=4,"pHYs"),o(p,s+=4,f.pHYs[0]),o(p,s+=4,f.pHYs[1]),p[s+=4]=f.pHYs[2],o(p,++s,i(p,s-13,13)),s+=4),u&&(o(p,s,8),v(p,s+=4,"acTL"),o(p,s+=4,r.frames.length),o(p,s+=4,null!=f.loop?f.loop:0),o(p,s+=4,i(p,s-12,12)),s+=4),3==r.ctype){var d=r.plte.length;o(p,s,3*d),v(p,s+=4,"PLTE"),s+=4;for(var g=0;g<d;g++){var y=3*g,U=r.plte[g],I=255&U,C=U>>>8&255,N=U>>>16&255;p[s+y+0]=I,p[s+y+1]=C,p[s+y+2]=N}if(o(p,s+=3*d,i(p,s-3*d-4,3*d+4)),s+=4,h){o(p,s,d),v(p,s+=4,"tRNS"),s+=4;for(var g=0;g<d;g++)p[s+g]=r.plte[g]>>>24&255;o(p,s+=d,i(p,s-d-4,d+4)),s+=4}}for(var P=0,b=0;b<r.frames.length;b++){var w=r.frames[b];u&&(o(p,s,26),v(p,s+=4,"fcTL"),o(p,s+=4,P++),o(p,s+=4,w.rect.width),o(p,s+=4,w.rect.height),o(p,s+=4,w.rect.x),o(p,s+=4,w.rect.y),l(p,s+=4,n[b]),l(p,s+=2,1e3),p[s+=2]=w.dispose,p[++s]=w.blend,o(p,++s,i(p,s-30,30)),s+=4);var T=w.cimg,d=T.length;o(p,s,d+(0==b?0:4));var A=s+=4;v(p,s,0==b?"IDAT":"fdAT"),s+=4,0!=b&&(o(p,s,P++),s+=4),p.set(T,s),o(p,s+=d,i(p,A,s-A)),s+=4}return o(p,s,0),v(p,s+=4,"IEND"),o(p,s+=4,i(p,s-4,4)),s+=4,p.buffer}function o(r,e,t){for(var _=0;_<r.frames.length;_++){var $=r.frames[_],n=($.rect.width,$.rect.height),f=new Uint8Array(n*$.bpl+n);$.cimg=u($.img,n,$.bpp,$.bpl,f,e,t)}}function l(e,t,_,$,n){for(var f=n[0],i=n[1],o=n[2],l=n[3],u=n[4],h=n[5],d=6,g=8,b=255,w=0;w<e.length;w++)for(var p=new Uint8Array(e[w]),m=p.length,x=0;x<m;x+=4)b&=p[x+3];var y=255!=b,U=function e(t,_,$,n,f,a){for(var i=[],o=0;o<t.length;o++){var l,u=new Uint8Array(t[o]),h=new Uint32Array(u.buffer),c=0,d=0,g=_,b=$,w=n?1:0;if(0!=o){for(var p=a||n||1==o||0!=i[o-2].dispose?1:2,m=0,x=1e9,y=0;y<p;y++){for(var U=new Uint8Array(t[o-1-y]),I=new Uint32Array(t[o-1-y]),C=_,N=$,P=-1,T=-1,A=0;A<$;A++)for(var R=0;R<_;R++){var G=A*_+R;h[G]!=I[G]&&(R<C&&(C=R),R>P&&(P=R),A<N&&(N=A),A>T&&(T=A))}-1==P&&(C=N=P=T=0),f&&((1&C)==1&&C--,(1&N)==1&&N--);var S=(P-C+1)*(T-N+1);S<x&&(x=S,m=y,c=C,d=N,g=P-C+1,b=T-N+1)}var U=new Uint8Array(t[o-1-m]);1==m&&(i[o-1].dispose=2),l=new Uint8Array(g*b*4),r(U,_,$,l,g,b,-c,-d,0),1==(w=r(u,_,$,l,g,b,-c,-d,3)?1:0)?s(u,_,$,l,{x:c,y:d,width:g,height:b}):r(u,_,$,l,g,b,-c,-d,0)}else l=u.slice(0);i.push({rect:{x:c,y:d,width:g,height:b},img:l,blend:w,dispose:0})}if(n)for(var o=0;o<i.length;o++){var L=i[o];if(1!=L.blend){var q,B=L.rect,H=i[o-1].rect,k=Math.min(B.x,H.x),D=Math.min(B.y,H.y),E={x:k,y:D,width:Math.max(B.x+B.width,H.x+H.width)-k,height:Math.max(B.y+B.height,H.y+H.height)-D};i[o-1].dispose=1,o-1!=0&&v(t,_,$,i,o-1,E,f),v(t,_,$,i,o,E,f)}}var z=0;if(1!=t.length)for(var G=0;G<i.length;G++){var L=i[G];z+=L.rect.width*L.rect.height}return i}(e,t,_,f,i,o),I={},C=[],N=[];if(0!=$){for(var P=[],x=0;x<U.length;x++)P.push(U[x].img.buffer);for(var T=function r(e){for(var t=0,_=0;_<e.length;_++)t+=e[_].byteLength;for(var $=new Uint8Array(t),n=0,_=0;_<e.length;_++){for(var f=new Uint8Array(e[_]),a=f.length,i=0;i<a;i+=4){var o=f[i],l=f[i+1],v=f[i+2],s=f[i+3];0==s&&(o=l=v=0),$[n+i]=o,$[n+i+1]=l,$[n+i+2]=v,$[n+i+3]=s}n+=a}return $.buffer}(P),A=c(T,$),x=0;x<A.plte.length;x++)C.push(A.plte[x].est.rgba);for(var R=0,x=0;x<U.length;x++){var G=U[x],S=G.img.length,L=new Uint8Array(A.inds.buffer,R>>2,S>>2);N.push(L);var q=new Uint8Array(A.abuf,R,S);h&&a(G.img,G.rect.width,G.rect.height,C,q,L),G.img.set(q),R+=S}}else for(var w=0;w<U.length;w++){var G=U[w],B=new Uint32Array(G.img.buffer),H=G.rect.width,m=B.length,L=new Uint8Array(m);N.push(L);for(var x=0;x<m;x++){var k=B[x];if(0!=x&&k==B[x-1])L[x]=L[x-1];else if(x>H&&k==B[x-H])L[x]=L[x-H];else{var D=I[k];if(null==D&&(I[k]=D=C.length,C.push(k),C.length>=300))break;L[x]=D}}}var E=C.length;E<=256&&!1==u&&(g=Math.max(g=E<=2?1:E<=4?2:E<=16?4:8,l));for(var w=0;w<U.length;w++){var G=U[w],H=(G.rect.x,G.rect.y,G.rect.width),z=G.rect.height,Y=G.img;new Uint32Array(Y.buffer);var Z=4*H,M=4;if(E<=256&&!1==u){Z=Math.ceil(g*H/8);for(var F=new Uint8Array(Z*z),X=N[w],K=0;K<z;K++){var x=K*Z,V=K*H;if(8==g)for(var j=0;j<H;j++)F[x+j]=X[V+j];else if(4==g)for(var j=0;j<H;j++)F[x+(j>>1)]|=X[V+j]<<4-(1&j)*4;else if(2==g)for(var j=0;j<H;j++)F[x+(j>>2)]|=X[V+j]<<6-(3&j)*2;else if(1==g)for(var j=0;j<H;j++)F[x+(j>>3)]|=X[V+j]<<7-(7&j)*1}Y=F,d=3,M=1}else if(!1==y&&1==U.length){for(var F=new Uint8Array(H*z*3),O=H*z,x=0;x<O;x++){var J=3*x,Q=4*x;F[J]=Y[Q],F[J+1]=Y[Q+1],F[J+2]=Y[Q+2]}Y=F,d=2,M=3,Z=3*H}G.img=Y,G.bpl=Z,G.bpp=M}return{ctype:d,depth:g,plte:C,frames:U}}function v(e,t,_,$,n,f,a){for(var i=Uint8Array,o=Uint32Array,l=new i(e[n-1]),v=new o(e[n-1]),u=n+1<e.length?new i(e[n+1]):null,h=new i(e[n]),c=new o(h.buffer),d=t,g=_,b=-1,w=-1,p=0;p<f.height;p++)for(var m=0;m<f.width;m++){var x=f.x+m,y=f.y+p,U=y*t+x,I=c[U];0==I||0==$[n-1].dispose&&v[U]==I&&(null==u||0!=u[4*U+3])||(x<d&&(d=x),x>b&&(b=x),y<g&&(g=y),y>w&&(w=y))}-1==b&&(d=g=b=w=0),a&&((1&d)==1&&d--,(1&g)==1&&g--),f={x:d,y:g,width:b-d+1,height:w-g+1};var C=$[n];C.rect=f,C.blend=1,C.img=new Uint8Array(f.width*f.height*4),0==$[n-1].dispose?(r(l,t,_,C.img,f.width,f.height,-f.x,-f.y,0),s(h,t,_,C.img,f)):r(h,t,_,C.img,f.width,f.height,-f.x,-f.y,0)}function s(e,t,_,$,n){r(e,t,_,$,n.width,n.height,-n.x,-n.y,2)}function u(r,e,t,_,$,n,f){var a=[],i=[0,1,2,3,4];-1!=n?i=[n]:(e*_>5e5||1==t)&&(i=[0]),f&&(s={level:0});var o=$.length>1e7&&null!=window.UZIP?window.UZIP:pako;Date.now();for(var l=0;l<i.length;l++){for(var v=0;v<e;v++)h($,r,v,_,t,i[l]);a.push(o.deflate($,s))}for(var s,u,c=1e9,l=0;l<a.length;l++)a[l].length<c&&(u=l,c=a[l].length);return a[u]}function h(r,e,_,$,n,f){var a=_*$,i=a+_;if(r[i]=f,i++,0==f){if($<500)for(var o=0;o<$;o++)r[i+o]=e[a+o];else r.set(new Uint8Array(e.buffer,a,$),i)}else if(1==f){for(var o=0;o<n;o++)r[i+o]=e[a+o];for(var o=n;o<$;o++)r[i+o]=e[a+o]-e[a+o-n]+256&255}else if(0==_){for(var o=0;o<n;o++)r[i+o]=e[a+o];if(2==f)for(var o=n;o<$;o++)r[i+o]=e[a+o];if(3==f)for(var o=n;o<$;o++)r[i+o]=e[a+o]-(e[a+o-n]>>1)+256&255;if(4==f)for(var o=n;o<$;o++)r[i+o]=e[a+o]-t(e[a+o-n],0,0)+256&255}else{if(2==f)for(var o=0;o<$;o++)r[i+o]=e[a+o]+256-e[a+o-$]&255;if(3==f){for(var o=0;o<n;o++)r[i+o]=e[a+o]+256-(e[a+o-$]>>1)&255;for(var o=n;o<$;o++)r[i+o]=e[a+o]+256-(e[a+o-$]+e[a+o-n]>>1)&255}if(4==f){for(var o=0;o<n;o++)r[i+o]=e[a+o]+256-t(0,e[a+o-$],0)&255;for(var o=n;o<$;o++)r[i+o]=e[a+o]+256-t(e[a+o-n],e[a+o-$],e[a+o-n-$])&255}}}function c(r,e,t){Date.now();for(var _=new Uint8Array(r),$=_.slice(0),n=new Uint32Array($.buffer),f=w($,e),a=f[0],i=f[1],o=i.length,l=new Uint32Array(o),v=new Uint8Array(l.buffer),s=0;s<o;s++)l[s]=i[s].est.rgba;var u,h=_.length,c=new Uint8Array(h>>2);if(o<=60)b(_,c,v),d(c,n,l);else if(_.length<32e6)for(var s=0;s<h;s+=4){var x=_[s]*(1/255),y=_[s+1]*(1/255),U=_[s+2]*(1/255),I=_[s+3]*(1/255);u=p(a,x,y,U,I),c[s>>2]=u.ind,n[s>>2]=u.est.rgba}else for(var s=0;s<h;s+=4){var x=_[s]*(1/255),y=_[s+1]*(1/255),U=_[s+2]*(1/255),I=_[s+3]*(1/255);for(u=a;u.left;)u=0>=m(u.est,x,y,U,I)?u.left:u.right;c[s>>2]=u.ind,n[s>>2]=u.est.rgba}if(t||_.length*o<10*4e6){for(var C=1e9,s=0;s<10;s++){var N=g(_,c,v);if(N/C>.997)break;C=N}for(var s=0;s<o;s++)i[s].est.rgba=l[s];d(c,n,l)}return{abuf:$.buffer,inds:c,plte:i}}function d(r,e,t){for(var _=0;_<r.length;_++)e[_]=t[r[_]]}function g(r,e,t){return function r(e,t,_){for(var $=_.length>>>2,n=new Uint32Array(4*$),f=new Uint32Array($),a=0;a<e.length;a+=4){var i=t[a>>>2],o=4*i;f[i]++,n[o]+=e[a],n[o+1]+=e[a+1],n[o+2]+=e[a+2],n[o+3]+=e[a+3]}for(var a=0;a<_.length;a++)_[a]=Math.round(n[a]/f[a>>>2])}(r,e,t),b(r,e,t)}function b(r,e,t){for(var _=0,$=t.length>>>2,n=[],f=0;f<$;f++){for(var a=4*f,i=t[a],o=t[a+1],l=t[a+2],v=t[a+3],s=0,u=1e9,h=0;h<$;h++)if(f!=h){var c=4*h,d=i-t[c],g=o-t[c+1],b=l-t[c+2],w=v-t[c+3],p=d*d+g*g+b*b+w*w;p<u&&(u=p,s=h)}n[f]=.5*Math.sqrt(u),n[f]=n[f]*n[f]}for(var f=0;f<r.length;f+=4){var i=r[f],o=r[f+1],l=r[f+2],v=r[f+3],s=e[f>>>2],a=4*s,d=i-t[a],g=o-t[a+1],b=l-t[a+2],w=v-t[a+3],u=d*d+g*g+b*b+w*w;if(u>n[s])for(var h=0;h<$;h++){d=i-t[a=4*h],g=o-t[a+1];var p=d*d+g*g+(b=l-t[a+2])*b+(w=v-t[a+3])*w;if(p<u&&(u=p,s=h,u<n[h]))break}e[f>>>2]=s,_+=u}return _/(r.length>>>2)}function w(r,e,t){null==t&&(t=1e-4);var _=new Uint32Array(r.buffer),$={i0:0,i1:r.length,bst:null,est:null,tdst:0,left:null,right:null};$.bst=U(r,$.i0,$.i1),$.est=I($.bst);for(var n=[$];n.length<e;){for(var f=0,a=0,i=0;i<n.length;i++)n[i].est.L>f&&(f=n[i].est.L,a=i);if(f<t)break;var o=n[a],l=x(r,_,o.i0,o.i1,o.est.e,o.est.eMq255);if(o.i0>=l||o.i1<=l){o.est.L=0;continue}var v={i0:o.i0,i1:l,bst:null,est:null,tdst:0,left:null,right:null};v.bst=U(r,v.i0,v.i1),v.est=I(v.bst);var s={i0:l,i1:o.i1,bst:null,est:null,tdst:0,left:null,right:null};s.bst={R:[],m:[],N:o.bst.N-v.bst.N};for(var i=0;i<16;i++)s.bst.R[i]=o.bst.R[i]-v.bst.R[i];for(var i=0;i<4;i++)s.bst.m[i]=o.bst.m[i]-v.bst.m[i];s.est=I(s.bst),o.left=v,o.right=s,n[a]=v,n.push(s)}n.sort(function(r,e){return e.bst.N-r.bst.N});for(var i=0;i<n.length;i++)n[i].ind=i;return[$,n]}function p(r,e,t,_,$){if(null==r.left){var n,f,a,i,o,l,v,s,u;return r.tdst=(n=r.est.q,f=e,a=t,i=_,o=$,l=f-n[0],v=a-n[1],s=i-n[2],u=o-n[3],l*l+v*v+s*s+u*u),r}var h=m(r.est,e,t,_,$),c=r.left,d=r.right;h>0&&(c=r.right,d=r.left);var g=p(c,e,t,_,$);if(g.tdst<=h*h)return g;var b=p(d,e,t,_,$);return b.tdst<g.tdst?b:g}function m(r,e,t,_,$){var n=r.e;return n[0]*e+n[1]*t+n[2]*_+n[3]*$-r.eMq}function x(r,e,t,_,$,n){for(_-=4;t<_;){for(;y(r,t,$)<=n;)t+=4;for(;y(r,_,$)>n;)_-=4;if(t>=_)break;var f=e[t>>2];e[t>>2]=e[_>>2],e[_>>2]=f,t+=4,_-=4}for(;y(r,t,$)>n;)t-=4;return t+4}function y(r,e,t){return r[e]*t[0]+r[e+1]*t[1]+r[e+2]*t[2]+r[e+3]*t[3]}function U(r,e,t){for(var _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],$=[0,0,0,0],n=e;n<t;n+=4){var f=r[n]*(1/255),a=r[n+1]*(1/255),i=r[n+2]*(1/255),o=r[n+3]*(1/255);$[0]+=f,$[1]+=a,$[2]+=i,$[3]+=o,_[0]+=f*f,_[1]+=f*a,_[2]+=f*i,_[3]+=f*o,_[5]+=a*a,_[6]+=a*i,_[7]+=a*o,_[10]+=i*i,_[11]+=i*o,_[15]+=o*o}return _[4]=_[1],_[8]=_[2],_[9]=_[6],_[12]=_[3],_[13]=_[7],_[14]=_[11],{R:_,m:$,N:t-e>>2}}function I(r){var e=r.R,t=r.m,_=r.N,$=t[0],n=t[1],f=t[2],a=t[3],i=0==_?0:1/_,o=[e[0]-$*$*i,e[1]-$*n*i,e[2]-$*f*i,e[3]-$*a*i,e[4]-n*$*i,e[5]-n*n*i,e[6]-n*f*i,e[7]-n*a*i,e[8]-f*$*i,e[9]-f*n*i,e[10]-f*f*i,e[11]-f*a*i,e[12]-a*$*i,e[13]-a*n*i,e[14]-a*f*i,e[15]-a*a*i],l=o,v=C,s=[Math.random(),Math.random(),Math.random(),Math.random()],u=0,h=0;if(0!=_)for(var c=0;c<16&&(s=v.multVec(l,s),h=Math.sqrt(v.dot(s,s)),s=v.sml(1/h,s),!(0!=c&&1e-9>Math.abs(h-u)));c++)u=h;var d=[$*i,n*i,f*i,a*i],g=v.dot(v.sml(255,d),s);return{Cov:o,q:d,e:s,L:u,eMq255:g,eMq:v.dot(s,d),rgba:(Math.round(255*d[3])<<24|Math.round(255*d[2])<<16|Math.round(255*d[1])<<8|Math.round(255*d[0])<<0)>>>0}}var C={multVec:function(r,e){return[r[0]*e[0]+r[1]*e[1]+r[2]*e[2]+r[3]*e[3],r[4]*e[0]+r[5]*e[1]+r[6]*e[2]+r[7]*e[3],r[8]*e[0]+r[9]*e[1]+r[10]*e[2]+r[11]*e[3],r[12]*e[0]+r[13]*e[1]+r[14]*e[2]+r[15]*e[3]]},dot:function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]+r[3]*e[3]},sml:function(r,e){return[r*e[0],r*e[1],r*e[2],r*e[3]]}};UPNG.encode=function r(e,t,_,$,n,f,a){null==$&&($=0),null==a&&(a=!1);var v=l(e,t,_,$,[!1,!1,!1,0,a,!1]);return o(v,-1),i(v,t,_,n,f)},UPNG.encodeLL=function r(e,t,_,$,n,f,a,l){var v={ctype:0+(1==$?0:2)+(0==n?0:4),depth:f,frames:[]};Date.now();for(var s=($+n)*f,u=s*t,h=0;h<e.length;h++)v.frames.push({rect:{x:0,y:0,width:t,height:_},img:new Uint8Array(e[h]),blend:0,dispose:1,bpp:Math.ceil(s/8),bpl:Math.ceil(u/8)});return o(v,0,!0),i(v,t,_,a,l)},UPNG.encode.compress=l,UPNG.encode.dither=a,UPNG.quantize=c,UPNG.quantize.findNearest=b,UPNG.quantize.getKDtree=w,UPNG.quantize.getNearest=p}();

Callers 1

cFunction · 0.70

Calls 5

UFunction · 0.70
IFunction · 0.70
xFunction · 0.70
pushMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected