functionJl(e){vart=e.toString(16);return1===t.length?"0"+t:t}functionXl(e){return"#"+e.map(Jl).join("")}functionei(e){returne?(t=e,Array.isArray(t[0])?e:[e]):[];vart}functionti(e,t,n){for(vara=0;a<n.length;a++)if(ni(e,t,n[a]))return!0;return!1}functionni(e,t,n){switch(n.length){case3:if(function(e,t,n){if(255!==e[t+3])return!0;if(e[t]===n[0]&&e[t+1]===n[1]&&e[t+2]===n[2])return!0;return!1}(e,t,n))return!0;break;case4:if(function(e,t,n){if(e[t+3]&&n[3])returne[t]===n[0]&&e[t+1]===n[1]&&e[t+2]===n[2]&&e[t+3]===n[3];returne[t+3]===n[3]}(e,t,n))return!0;break;case5:if(function(e,t,n){vara=n[0],o=n[1],r=n[2],l=n[3],i=n[4],s=e[t+3],c=ai(s,l,i);if(!l)returnc;if(!s&&c)return!0;if(ai(e[t],a,i)&&ai(e[t+1],o,i)&&ai(e[t+2],r,i)&&c)return!0;return!1}(e,t,n))return!0;break;default:return!1}}functionai(e,t,n){returne>=t-n&&e<=t+n}functionoi(e,t,n){for(vara={},o=n.ignoredColor,r=n.step,l=[0,0,0,0,0],i=0;i<t;i+=r){vars=e[i],c=e[i+1],m=e[i+2],u=e[i+3];if(!o||!ti(e,i,o)){varp=Math.round(s/24)+","+Math.round(c/24)+","+Math.round(m/24);a[p]?a[p]=[a[p][0]+s*u,a[p][1]+c*u,a[p][2]+m*u,a[p][3]+u,a[p][4]+1]:a[p]=[s*u,c*u,m*u,u,1],l[4]<a[p][4]&&(l=a[p])}}vard=l[0],g=l[1],h=l[2],b=l[3],_=l[4];returnb?[Math.round(d/b),Math.round(g/b),Math.round(h/b),Math.round(b/_)]:n.defaultColor}functionri(e,t,n){for(vara=0,o=0,r=0,l=0,i=0,s=n.ignoredColor,c=n.step,m=0;m<t;m+=c){varu=e[m+3],p=e[m]*u,d=e[m+1]*u,g=e[m+2]*u;s&&ti(e,m,s)||(a+=p,o+=d,r+=g,l+=u,i++)}returnl?[Math.round(a/l),Math.round(o/l),Math.round(r/l),Math.round(l/i)]:n.defaultColor}functionli(e,t,n){for(vara=0,o=0,r=0,l=0,i=0,s=n.ignoredColor,c=n.step,m=0;m<t;m+=c){varu=e[m],p=e[m+1],d=e[m+2],g=e[m+3];s&&ti(e,m,s)||(a+=u*u*g,o+=p*p*g,r+=d*d*g,l+=g,i++)}returnl?[Math.round(Math.sqrt(a/l)),Math.round(Math.sqrt(o/l)),Math.round(Math.sqrt(r/l)),Math.round(l/i)]:n.defaultColor}functionii(e){returnsi(e,"defaultColor",[0,0,0,0])}functionsi(e,t,n){returnvoid0===e[t]?n:e[t]}functionci(e){if(ui(e)){vart=e.naturalWidth,n=e.naturalHeight;returne.naturalWidth||-1===e.src.search(/\.svg(\?|$)/i)||(t=n=100),{width:t,height:n}}returnfunction(e){return"undefined"!=typeofHTMLVideoElement&&einstanceofHTMLVideoElement}(e)?{width:e.videoWidth,height:e.videoHeight}:{width:e.width,height:e.height}}functionmi(e){returnfunction(e){return"undefined"!=typeofHTMLCanvasElement&&einstanceofHTMLCanvasElement}(e)?"canvas":function(e){returnpi&&einstanceofOffscreenCanvas}(e)?"offscreencanvas":function(e){return"undefined"!=typeofImageBitmap&&einstanceofImageBitmap}(e)?"imagebitmap":e.src}functionui(e){return"undefined"!=typeofHTMLImageElement&&einstanceofHTMLImageElement}varpi="undefined"!=typeofOffscreenCanvas;vardi="undefined"==typeofwindow;functiongi(e){returnError("FastAverageColor: "+e)}functionhi(e,t){t||console.error(e)}varbi=function(){functione(){this.canvas=null,this.ctx=null}returne.prototype.getColorAsync=function(e,t){if(!e)returnPromise.reject(gi("call .getColorAsync() without resource."));if("string"==typeofe){if("undefined"==typeofImage)returnPromise.reject(gi("resource as string is not supported in this environment"));varn=newImage;returnn.crossOrigin=t&&t.crossOrigin||"",n.src=e,this.bindImageEvents(n,t)}if(ui(e)&&!e.complete)returnthis.bindImageEvents(e,t);vara=this.getColor(e,t);returna.error?Promise.reject(a.error):Promise.resolve(a)},e.prototype.getColor=function(e,t){varn=ii(t=t||{});if(!e)returnhi(r=gi("call .getColor(null) without resource"),t.silent),this.prepareResult(n,r);vara=function(e,t){varn,a=si(t,"left",0),o=si(t,"top",0),r=si(t,"width",e.width),l=si(t,"height",e.height),i=r,s=l;return"precision"===t.mode||(r>l?(n=r/l,i=100,s=Math.round(i/n)):(n=l/r,s=100,i=Math.round(s/n)),(i>r||s>l||i<10||s<10)&&(i=r,s=l)),{srcLeft:a,srcTop:o,srcWidth:r,srcHeight:l,destWidth:i,destHeight:s}}(ci(e),t);if(!(a.srcWidth&&a.srcHeight&&a.destWidth&&a.destHeight))returnhi(r=gi('incorrect sizes for resource "'.concat(mi(e),'"')),t.silent),this.prepareResult(n,r);if(!this.canvas&&(this.canvas=di?pi?newOffscreenCanvas(1,1):null:document.