!function(){"use strict";functiont(t,e){returnn(document.createElement("canvas"),t,e)}functione(t){returnt.getContext("2d")}functionn(t,e,n){returnt.width=e,t.height=n,t}functiono(t){returnnewU(function(e,n){functiono(){u(),e(a)}functionr(){u(),n("Unable to load data of type "+t.type+": "+i)}vari=URL.createObjectURL(t),a=newImage,u=function(){a.removeEventListener("load",o),a.removeEventListener("error",r)};a.addEventListener("load",o),a.addEventListener("error",r),a.src=i,a.complete&&o()})}functionr(t){returnnewU(function(e){varn=newXMLHttpRequest;n.open("GET",t,!0),n.responseType="blob",n.onload=function(){200==this.status&&e(this.response)},n.send()})}functioni(t){vare=t.split(","),n=/data:([^;]+)/.exec(e[0]);if(!n)returnH.none();for(varo=n[1],r=e[1],i=V.atob(r),a=i.length,u=Math.ceil(a/1024),c=newArray(u),l=0;l<u;++l){for(vars=1024*l,f=Math.min(s+1024,a),d=newArray(f-s),h=s,p=0;h<f;++p,++h)d[p]=i[h].charCodeAt(0);c[l]=q(d)}returnH.some(P(c,{type:o}))}functiona(t){returnnewU(function(e,n){i(t).fold(function(){n("uri is not base64: "+t)},e)})}functionu(t){returnnewU(function(e){varn=newW;n.onloadend=function(){e(n.result)},n.readAsDataURL(t)})}functionc(t,e,n){functiono(e,n){returnt.then(function(t){returnN.canvasToDataURL(t,e,n)})}varr=e.type;return{getType:j.constant(r),toBlob:function(){returnU.resolve(e)},toDataURL:function(){returnn},toBase64:function(){returnn.split(",")[1]},toAdjustedBlob:function(e,n){returnt.then(function(t){returnN.canvasToBlob(t,e,n)})},toAdjustedDataURL:o,toAdjustedBase64:function(t,e){returno(t,e).then(function(t){returnt.split(",")[1]})},toCanvas:function(){returnt.then(C.clone)}}}functionl(t){returnN.blobToDataUri(t).then(function(e){returnc(N.blobToCanvas(t),t,e)})}functions(t,e,n){return(t=parseFloat(t))>n?t=n:t<e&&(t=e),t}functionf(t,e){varn,o,r,i,a=[],u=newArray(10);for(n=0;n<5;n++){for(o=0;o<5;o++)a[o]=e[o+5*n];for(o=0;o<5;o++){for(i=0,r=0;r<5;r++)i+=t[o+5*r]*a[r];u[o+5*n]=i}}returnu}functiond(t,e){returne=s(e,0,1),t.map(function(t,n){returnn%6==0?t=1-(1-t)*e:t*=e,s(t,0,1)})}functionh(t,e){returnt.toCanvas().then(function(n){returnfunction(t,e,n){varo,r=C.get2dContext(t);returno=function(t,e){varn,o,r,i,a,u=t.data,c=e[0],l=e[1],s=e[2],f=e[3],d=e[4],h=e[5],p=e[6],m=e[7],g=e[8],v=e[9],y=e[10],b=e[11],w=e[12],x=e[13],R=e[14],I=e[15],T=e[16],k=e[17],C=e[18],B=e[19];for(a=0;a<u.length;a+=4)n=u[a],o=u[a+1],r=u[a+2],i=u[a+3],u[a]=n*c+o*l+r*s+i*f+d,u[a+1]=n*h+o*p+r*m+i*g+v,u[a+2]=n*y+o*b+r*w+i*x+R,u[a+3]=n*I+o*T+r*k+i*C+B;returnt}(r.getImageData(0,0,t.width,t.height),n),r.putImageData(o,0,0),G.fromCanvas(t,e)}(n,t.getType(),e)})}functionp(t,e){returnt.toCanvas().then(function(n){returnfunction(t,e,n){varo,r,i=C.get2dContext(t);returno=i.getImageData(0,0,t.width,t.height),r=i.getImageData(0,0,t.width,t.height),r=function(t,e,n){functiono(t,e,n){returnt>n?t=n:t<e&&(t=e),t}varr,i,a,u,c,l,s,f,d,h,p,m,g,v,y,b,w;for(a=Math.round(Math.sqrt(n.length)),u=Math.floor(a/2),r=t.data,i=e.data,b=t.width,w=t.height,l=0;l<w;l++)for(c=0;c<b;c++){for(s=f=d=0,p=0;p<a;p++)for(h=0;h<a;h++)m=o(c+h-u,0,b-1),g=o(l+p-u,0,w-1),v=4*(g*b+m),y=n[p*a+h],s+=r[v]*y,f+=r[v+1]*y,d+=r[v+2]*y;i[v=4*(l*b+c)]=o(s,0,255),i[v+1]=o(f,0,255),i[v+2]=o(d,0,255)}returne}(o,r,n),i.putImageData(r,0,0),G.fromCanvas(t,e)}(n,t.getType(),e)})}functionm(t){returnfunction(e,n){returne.toCanvas().then(function(o){returnfunction(e,n,o){varr,i,a=C.get2dContext(e),u=newArray(256);for(i=0;i<u.length;i++)u[i]=t(i,o);returnr=function(t,e){varn,o=t.data;for(n=0;n<o.length;n+=4)o[n]=e[o[n]],o[n+1]=e[o[n+1]],o[n+2]=e[o[n+2]];returnt}(a.getImageData(0,0,e.width,e.height),u),a.putImageData(r,0,0),G.fromCanvas(e,n)}(o,e.getType(),n)})}}functiong(t){returnfunction(e,n){returnh(e,t(J.identity(),n))}}functionv(t){returnfunction(e){returnp(e,t)}}functiony(t,e,n){varo=B.getWidth(t),r=B.getHeight(t),i=e/o,a=n/r,u=!1;(i<.5||i>2)&&(i=i<.5?.5:2,u=!0),(a<.5||a>2)&&(a=a<.5?.5:2,u=!0);varc=function(t,e,n){returnnewU(function(o){varr=B.getWidth(t),i=B.getHeight(t),a=Math.flo