const n = new Array(4);
function g(t) {
  for (let o = 0; o < n.length; o++)
    n[o] = 0;
  for (let o = 0; o < t.length; o++)
    n[o % 4] = (n[o % 4] << 5) - n[o % 4] + t.charCodeAt(o);
}
function h() {
  const t = n[0] ^ n[0] << 11;
  return n[0] = n[1], n[1] = n[2], n[2] = n[3], n[3] = n[3] ^ n[3] >> 19 ^ t ^ t >> 8, (n[3] >>> 0) / (1 << 31 >>> 0);
}
function d() {
  const t = Math.floor(h() * 360), o = `${h() * 60 + 40}%`, e = `${(h() + h() + h() + h()) * 25}%`;
  return `hsl(${t},${o},${e})`;
}
function w(t) {
  const o = t, e = t, a = Math.ceil(o / 2), f = o - a, r = [];
  for (let i = 0; i < e; i++) {
    let c = [];
    for (let s = 0; s < a; s++)
      c[s] = Math.floor(h() * 2.3);
    const l = c.slice(0, f);
    l.reverse(), c = c.concat(l);
    for (let s = 0; s < c.length; s++)
      r.push(c[s]);
  }
  return r;
}
function M(t, o, e, a, f) {
  const r = document.createElement("canvas"), i = Math.sqrt(t.length);
  r.width = r.height = i * e;
  const c = r.getContext("2d");
  c.fillStyle = a, c.fillRect(0, 0, r.width, r.height), c.fillStyle = o;
  for (let l = 0; l < t.length; l++) {
    const s = Math.floor(l / i), u = l % i;
    c.fillStyle = t[l] === 1 ? o : f, t[l] && c.fillRect(u * e, s * e, e, e);
  }
  return r;
}
function v(t) {
  t = t || {};
  const o = t.size || 8, e = t.scale || 4, a = t.seed || Math.floor(Math.random() * 10 ** 16).toString(16);
  g(a);
  const f = t.color || d(), r = t.bgcolor || d(), i = t.spotcolor || d(), c = w(o);
  return M(c, f, e, r, i);
}
const y = { createIcon: v };
export {
  y as default
};
