e.exports=function(){"use strict";functione(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}functiont(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)}}functionn(e,n,o){returnn&&t(e.prototype,n),o&&t(e,o),e}functiono(e,t){returnr(e)||a(e,t)||l()}functionr(e){if(Array.isArray(e))returne}functiona(e,t){varn=[],o=!0,r=!1,a=void0;try{for(varl,i=e[Symbol.iterator]();!(o=(l=i.next()).done)&&(n.push(l.value),!t||n.length!==t);o=!0);}catch(e){r=!0,a=e}finally{try{o||null==i.return||i.return()}finally{if(r)throwa}}returnn}functionl(){thrownewTypeError("Invalid attempt to destructure non-iterable instance")}returnfunction(){functiont(){e(this,t)}returnn(t,[{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);vari=this._ctx.getImageData(0,0,r.destWidth,r.destHeight).data;l=this.getColorFromArray4(i,t)}catch(e){a=e}returnthis._prepareResult(l,a)}},{key:"getColorFromArray4",value:function(e,t){t=t||{};varn=4,o=e.length;if(o<n)returnthis._getDefaultColor(t);varr=o-o%n,a=(t.step||1)*n,l="_"+(t.algorithm||"sqrt")+"Algorithm";if("function"!=typeofthis[l])thrownewError("FastAverageColor: ".concat(t.algorithm," is unknown algorithm."));returnthis[l](e,r,a)}},{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=this._getOption(t,"left",0),o=this._getOption(t,"top",0),r=this._getOption(t,"width",e.width),a=this._getOption(t,"height",e.height),l=r,i=a;if("precision"===t.mode)return{srcLeft:n,srcTop:o,srcWidth:r,srcHeight:a,destWidth:l,destHeight:i};vars,c=100,u=10;returnr>a?(s=r/a,l=c,i=Math.round(l/s)):(s=a/r,i=c,l=Math.round(i/s)),(l>r||i>a||l<u||i<u)&&(l=r,i=a),{srcLeft:n,srcTop:o,srcWidth:r,srcHeight:a,destWidth:l,destHeight:i}}},{key:"_simpleAlgorithm",value:function(e,t,n){for(varo=0,r=0,a=0,l=0,i=0,s=0;s<t;s+=n){varc=e[s+3];o+=e[s]*c,r+=e[s+1]*c,a+=e[s+2]*c,l+=c,i++}returnl?[Math.round(o/l),Math.round(r/l),Math.round(a/l),Math.round(l/i)]:[0,0,0,0]}},{key:"_sqrtAlgorithm",value:function(e,t,n){for(varo=0,r=0,a=0,l=0,i=0,s=0;s<t;s+=n){varc=e[s],u=e[s+1],m=e[s+2],d=e[s+3];o+=c*c*d,r+=u*u*d,a+=m*m*d,l+=d,i++}returnl?[Math.round(Math.sqrt(o/l)),Math.round(Math.sqrt(r/l)),Math.round(Math.sqrt(a/l)),Math.round(l/i)]:[0,0,0,0]}},{key:"_dominantAlgorithm",value:function(e,t,n){for(varr={},a=24,l=0;l<t;l+=n){vari=e[l],s=e[l+1],c=e[l+2],u=e[l+3],m=Math.round(i/a)+","+Math.round(s/a)+","+Math.round(c/a);r[m]?r[m]=[r[m][0]+i*u,r[m][1]+s*u,r[m][2]+c*u,r[m][3]+u,r[m][4]+1]:r[m]=[i*u,s*u,c*u,u,1]}vard=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})),p=o(d[0],5),g=p[0],h=p[1],v=p[2],b=p[3],_=p[4];returnb?[Math.round(g/b),Math.round(h/b),Math.round(v/b),Math.round(b/_)]:[0,0,0,0]}},{key:"_bindImageEvents",value:function(e,t,n){varo=this,r=(n=n||{})&&n.data,a=this._getDefaultColor(n),l=function(){c(),t.call(e,o.getColor(e,n),r)},i=function(){c(),t.call(e,o._prepareResult(a,newEr