e.exports=function(){"use strict";functione(e,t){for(varn=0;n<t.length;n++){varo=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"ino&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}functiont(e,t){returnfunction(e){if(Array.isArray(e))returne}(e)||function(e,t){varn=[],o=!0,r=!1,a=void0;try{for(varl,c=e[Symbol.iterator]();!(o=(l=c.next()).done)&&(n.push(l.value),!t||n.length!==t);o=!0);}catch(e){r=!0,a=e}finally{try{o||null==c.return||c.return()}finally{if(r)throwa}}returnn}(e,t)||function(){thrownewTypeError("Invalid attempt to destructure non-iterable instance")}()}returnfunction(){functionn(){!function(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}(this,n)}varo,r,a;returno=n,(r=[{key:"getColorAsync",value:function(e,t,n){e.complete?t.call(e,this.getColor(e,n),n&&n.data):this._bindImageEvents(e,t,n)}},{key:"getColor",value:function(e,t){t=t||{};varn=this._getDefaultColor(t),o=this._getOriginalSize(e),r=this._prepareSizeAndPosition(o,t),a=null,l=n;if(!(r.srcWidth&&r.srcHeight&&r.destWidth&&r.destHeight))returnthis._prepareResult(n,newError("FastAverageColor: Incorrect sizes."));if(!this._ctx&&(this._canvas=this._makeCanvas(),this._ctx=this._canvas.getContext&&this._canvas.getContext("2d"),!this._ctx))returnthis._prepareResult(n,newError("FastAverageColor: Canvas Context 2D is not supported in this browser."));this._canvas.width=r.destWidth,this._canvas.height=r.destHeight;try{this._ctx.clearRect(0,0,r.destWidth,r.destHeight),this._ctx.drawImage(e,r.srcLeft,r.srcTop,r.srcWidth,r.srcHeight,0,0,r.destWidth,r.destHeight);varc=this._ctx.getImageData(0,0,r.destWidth,r.destHeight).data;l=this.getColorFromArray4(c,t)}catch(e){a=e}returnthis._prepareResult(l,a)}},{key:"getColorFromArray4",value:function(e,t){t=t||{};varn=e.length;if(n<4)returnthis._getDefaultColor(t);varo=n-n%4,r=4*(t.step||1),a="_"+(t.algorithm||"sqrt")+"Algorithm";if("function"!=typeofthis[a])thrownewError("FastAverageColor: ".concat(t.algorithm," is unknown algorithm."));returnthis[a](e,o,r)}},{key:"destroy",value:function(){deletethis._canvas,deletethis._ctx}},{key:"_getDefaultColor",value:function(e){returnthis._getOption(e,"defaultColor",[255,255,255,255])}},{key:"_getOption",value:function(e,t,n){returnvoid0===e[t]?n:e[t]}},{key:"_prepareSizeAndPosition",value:function(e,t){varn,o=this._getOption(t,"left",0),r=this._getOption(t,"top",0),a=this._getOption(t,"width",e.width),l=this._getOption(t,"height",e.height),c=a,i=l;return"precision"===t.mode||(a>l?(n=a/l,c=100,i=Math.round(c/n)):(n=l/a,i=100,c=Math.round(i/n)),(c>a||i>l||c<10||i<10)&&(c=a,i=l)),{srcLeft:o,srcTop:r,srcWidth:a,srcHeight:l,destWidth:c,destHeight:i}}},{key:"_simpleAlgorithm",value:function(e,t,n){for(varo=0,r=0,a=0,l=0,c=0,i=0;i<t;i+=n){vars=e[i+3];o+=e[i]*s,r+=e[i+1]*s,a+=e[i+2]*s,l+=s,c++}returnl?[Math.round(o/l),Math.round(r/l),Math.round(a/l),Math.round(l/c)]:[0,0,0,0]}},{key:"_sqrtAlgorithm",value:function(e,t,n){for(varo=0,r=0,a=0,l=0,c=0,i=0;i<t;i+=n){vars=e[i],u=e[i+1],m=e[i+2],d=e[i+3];o+=s*s*d,r+=u*u*d,a+=m*m*d,l+=d,c++}returnl?[Math.round(Math.sqrt(o/l)),Math.round(Math.sqrt(r/l)),Math.round(Math.sqrt(a/l)),Math.round(l/c)]:[0,0,0,0]}},{key:"_dominantAlgorithm",value:function(e,n,o){for(varr={},a=0;a<n;a+=o){varl=e[a],c=e[a+1],i=e[a+2],s=e[a+3],u=Math.round(l/24)+","+Math.round(c/24)+","+Math.round(i/24);r[u]?r[u]=[r[u][0]+l*s,r[u][1]+c*s,r[u][2]+i*s,r[u][3]+s,r[u][4]+1]:r[u]=[l*s,c*s,i*s,s,1]}varm=t(Object.keys(r).map((function(e){returnr[e]})).sort((function(e,t){varn=e[4],o=t[4];returnn>o?-1:n===o?0:1}))[0],5),d=m[0],b=m[1],p=m[2],g=m[3],h=m[4];returng?[Math.round(d/g),Math.round(b/g),Math.round(p/g),Math.round(g/h)]:[0,0,0,0]}},{key:"_bindImageEvents",value:function(e,t,n){varo=this,r=(n=n||{})&&n.data,a=this._getDefaultColor(n),l=function(){s(),t.call(e,o.getColor(e,n),r)},c=function(){s(),t.call(e,o._prepareResult(a,newError("Image error")),r)},i=function(){s(),t.call(e,o._prepareResult(a,newError("Image abort")),r)},s=function(){e.removeEventListener("load",l),e.remo