var e=e=>typeof e==`string`?e:e.src,t=({amount:e=3,format:t=`array`,group:n=20,sample:r=10}={})=>({amount:e,format:t,group:n,sample:r}),n=(e,t)=>{var n=e.map(e=>{var n=Array.isArray(e)?e:e.split(`,`).map(Number);return t.format===`hex`?r(n):n});return t.amount===1||n.length===1?n[0]:n},r=e=>`#`+e.map(e=>{var t=e.toString(16);return t.length===1?`0`+t:t}).join(``),i=e=>new Promise((t,n)=>{var r=document.createElement(`canvas`),i=r.getContext(`2d`),a=new Image;a.onload=()=>{r.height=a.height,r.width=a.width,i.drawImage(a,0,0);var e=i.getImageData(0,0,a.width,a.height).data;t(e)},a.onerror=()=>n(Error(`Image loading failed.`)),a.crossOrigin=``,a.src=e}),a=(e,t)=>{for(var r=4*t.sample,i=e.length/r,a={r:0,g:0,b:0},o=0;o<e.length;o+=r)a.r+=e[o],a.g+=e[o+1],a.b+=e[o+2];return n([[Math.round(a.r/i),Math.round(a.g/i),Math.round(a.b/i)]],t)},o=(n,r,a)=>new Promise((o,s)=>i(e(r)).then(e=>o(n(e,t(a)))).catch(e=>s(e))),s=(e,t)=>o(a,e,t);export{s as t};