560 lines
19 KiB
JavaScript
560 lines
19 KiB
JavaScript
/*
|
|
* Extracted from browser-delivered Turbopack chunk: 258d1983af3dc9c8.198b926b86.js
|
|
* Module id: 228949
|
|
* For reading/searching only; this factory depends on the original Turbopack runtime.
|
|
*/
|
|
|
|
const moduleFactory = (e) => {
|
|
"use strict";
|
|
var t,
|
|
r,
|
|
n = e.i(462214),
|
|
a = e.i(358379);
|
|
function o() {
|
|
return (o = Object.assign.bind()).apply(null, arguments);
|
|
}
|
|
let l = function (e) {
|
|
return a.createElement(
|
|
"svg",
|
|
o(
|
|
{
|
|
xmlns: "http://www.w3.org/2000/svg",
|
|
width: 36,
|
|
height: 36,
|
|
fill: "none",
|
|
viewBox: "0 0 36 36",
|
|
},
|
|
e,
|
|
),
|
|
t ||
|
|
(t = a.createElement("path", {
|
|
fill: "#fff",
|
|
fillRule: "evenodd",
|
|
d: "M12.823 4.863h10.353l2.598 4.058H33v22.216H3V8.921h7.226zm1.231 2.25-2.596 4.058H5.25v17.716h25.5V11.171h-6.208l-2.598-4.058z",
|
|
clipRule: "evenodd",
|
|
})),
|
|
r ||
|
|
(r = a.createElement("path", {
|
|
fill: "#fff",
|
|
fillRule: "evenodd",
|
|
d: "M25.766 14.678h2.263v2.25h-2.263zM12.106 19.821a5.893 5.893 0 1 1 5.893 5.893 5.893 5.893 0 0 1-5.893-5.893m5.893-3.643a3.643 3.643 0 1 0-.001 7.286 3.643 3.643 0 0 0 .001-7.286",
|
|
clipRule: "evenodd",
|
|
})),
|
|
);
|
|
};
|
|
e.i(693602);
|
|
var s = e.i(452678),
|
|
c = function (e, t) {
|
|
return e < t ? -1 : +(e > t);
|
|
},
|
|
u = function (e) {
|
|
return e.reduce(function (e, t) {
|
|
return e + t;
|
|
}, 0);
|
|
},
|
|
d = (function () {
|
|
function e(e) {
|
|
this.colors = e;
|
|
}
|
|
var t = e.prototype;
|
|
return (
|
|
(t.palette = function () {
|
|
return this.colors;
|
|
}),
|
|
(t.map = function (e) {
|
|
return e;
|
|
}),
|
|
e
|
|
);
|
|
})(),
|
|
f = (function () {
|
|
function e(e, t, r) {
|
|
return (e << 10) + (t << 5) + r;
|
|
}
|
|
function t(e) {
|
|
var t = [],
|
|
r = !1;
|
|
function n() {
|
|
t.sort(e), (r = !0);
|
|
}
|
|
return {
|
|
push: function (e) {
|
|
t.push(e), (r = !1);
|
|
},
|
|
peek: function (e) {
|
|
return r || n(), void 0 === e && (e = t.length - 1), t[e];
|
|
},
|
|
pop: function () {
|
|
return r || n(), t.pop();
|
|
},
|
|
size: function () {
|
|
return t.length;
|
|
},
|
|
map: function (e) {
|
|
return t.map(e);
|
|
},
|
|
debug: function () {
|
|
return r || n(), t;
|
|
},
|
|
};
|
|
}
|
|
function r(e, t, r, n, a, o, l) {
|
|
(this.r1 = e),
|
|
(this.r2 = t),
|
|
(this.g1 = r),
|
|
(this.g2 = n),
|
|
(this.b1 = a),
|
|
(this.b2 = o),
|
|
(this.histo = l);
|
|
}
|
|
function n() {
|
|
this.vboxes = new t(function (e, t) {
|
|
return c(
|
|
e.vbox.count() * e.vbox.volume(),
|
|
t.vbox.count() * t.vbox.volume(),
|
|
);
|
|
});
|
|
}
|
|
return (
|
|
(r.prototype = {
|
|
volume: function (e) {
|
|
return (
|
|
(this._volume && !e) ||
|
|
(this._volume =
|
|
(this.r2 - this.r1 + 1) *
|
|
(this.g2 - this.g1 + 1) *
|
|
(this.b2 - this.b1 + 1)),
|
|
this._volume
|
|
);
|
|
},
|
|
count: function (t) {
|
|
var r = this.histo;
|
|
if (!this._count_set || t) {
|
|
var n,
|
|
a,
|
|
o,
|
|
l = 0;
|
|
for (n = this.r1; n <= this.r2; n++)
|
|
for (a = this.g1; a <= this.g2; a++)
|
|
for (o = this.b1; o <= this.b2; o++)
|
|
l += r[e(n, a, o)] || 0;
|
|
(this._count = l), (this._count_set = !0);
|
|
}
|
|
return this._count;
|
|
},
|
|
copy: function () {
|
|
return new r(
|
|
this.r1,
|
|
this.r2,
|
|
this.g1,
|
|
this.g2,
|
|
this.b1,
|
|
this.b2,
|
|
this.histo,
|
|
);
|
|
},
|
|
avg: function (t) {
|
|
var r = this.histo;
|
|
if (!this._avg || t) {
|
|
var n,
|
|
a,
|
|
o,
|
|
l,
|
|
s = 0,
|
|
c = 0,
|
|
u = 0,
|
|
d = 0;
|
|
if (
|
|
this.r1 === this.r2 &&
|
|
this.g1 === this.g2 &&
|
|
this.b1 === this.b2
|
|
)
|
|
this._avg = [this.r1 << 3, this.g1 << 3, this.b1 << 3];
|
|
else {
|
|
for (a = this.r1; a <= this.r2; a++)
|
|
for (o = this.g1; o <= this.g2; o++)
|
|
for (l = this.b1; l <= this.b2; l++)
|
|
(s += n = r[e(a, o, l)] || 0),
|
|
(c += n * (a + 0.5) * 8),
|
|
(u += n * (o + 0.5) * 8),
|
|
(d += n * (l + 0.5) * 8);
|
|
this._avg = s
|
|
? [~~(c / s), ~~(u / s), ~~(d / s)]
|
|
: [
|
|
~~((8 * (this.r1 + this.r2 + 1)) / 2),
|
|
~~((8 * (this.g1 + this.g2 + 1)) / 2),
|
|
~~((8 * (this.b1 + this.b2 + 1)) / 2),
|
|
];
|
|
}
|
|
}
|
|
return this._avg;
|
|
},
|
|
contains: function (e) {
|
|
var t = e[0] >> 3;
|
|
return (
|
|
(gval = e[1] >> 3),
|
|
(bval = e[2] >> 3),
|
|
t >= this.r1 &&
|
|
t <= this.r2 &&
|
|
gval >= this.g1 &&
|
|
gval <= this.g2 &&
|
|
bval >= this.b1 &&
|
|
bval <= this.b2
|
|
);
|
|
},
|
|
}),
|
|
(n.prototype = {
|
|
push: function (e) {
|
|
this.vboxes.push({ vbox: e, color: e.avg() });
|
|
},
|
|
palette: function () {
|
|
return this.vboxes.map(function (e) {
|
|
return e.color;
|
|
});
|
|
},
|
|
size: function () {
|
|
return this.vboxes.size();
|
|
},
|
|
map: function (e) {
|
|
for (var t = this.vboxes, r = 0; r < t.size(); r++)
|
|
if (t.peek(r).vbox.contains(e)) return t.peek(r).color;
|
|
return this.nearest(e);
|
|
},
|
|
nearest: function (e) {
|
|
for (var t, r, n, a = this.vboxes, o = 0; o < a.size(); o++)
|
|
((r = Math.sqrt(
|
|
Math.pow(e[0] - a.peek(o).color[0], 2) +
|
|
Math.pow(e[1] - a.peek(o).color[1], 2) +
|
|
Math.pow(e[2] - a.peek(o).color[2], 2),
|
|
)) < t ||
|
|
void 0 === t) &&
|
|
((t = r), (n = a.peek(o).color));
|
|
return n;
|
|
},
|
|
forcebw: function () {
|
|
var e = this.vboxes;
|
|
e.sort(function (e, t) {
|
|
return c(u(e.color), u(t.color));
|
|
});
|
|
var t = e[0].color;
|
|
t[0] < 5 && t[1] < 5 && t[2] < 5 && (e[0].color = [0, 0, 0]);
|
|
var r = e.length - 1,
|
|
n = e[r].color;
|
|
n[0] > 251 &&
|
|
n[1] > 251 &&
|
|
n[2] > 251 &&
|
|
(e[r].color = [255, 255, 255]);
|
|
},
|
|
}),
|
|
{
|
|
quantize: function (a, o) {
|
|
if (!Number.isInteger(o) || o < 1 || o > 256)
|
|
throw Error(
|
|
"Invalid maximum color count. It must be an integer between 1 and 256.",
|
|
);
|
|
if (
|
|
!a.length ||
|
|
o < 2 ||
|
|
o > 256 ||
|
|
!a.length ||
|
|
o < 2 ||
|
|
o > 256
|
|
)
|
|
return !1;
|
|
for (
|
|
var l,
|
|
s,
|
|
u,
|
|
f,
|
|
m,
|
|
h,
|
|
g,
|
|
p,
|
|
b,
|
|
v,
|
|
x,
|
|
y = [],
|
|
w = new Set(),
|
|
C = 0;
|
|
C < a.length;
|
|
C++
|
|
) {
|
|
var j = a[C],
|
|
_ = j.join(",");
|
|
w.has(_) || (w.add(_), y.push(j));
|
|
}
|
|
if (y.length <= o) return new d(y);
|
|
var P =
|
|
((s = Array(32768)),
|
|
a.forEach(function (t) {
|
|
s[(l = e(t[0] >> 3, t[1] >> 3, t[2] >> 3))] = (s[l] || 0) + 1;
|
|
}),
|
|
s);
|
|
P.forEach(function () {});
|
|
var k =
|
|
((h = 1e6),
|
|
(g = 0),
|
|
(p = 1e6),
|
|
(b = 0),
|
|
(v = 1e6),
|
|
(x = 0),
|
|
a.forEach(function (e) {
|
|
(u = e[0] >> 3) < h ? (h = u) : u > g && (g = u),
|
|
(f = e[1] >> 3) < p ? (p = f) : f > b && (b = f),
|
|
(m = e[2] >> 3) < v ? (v = m) : m > x && (x = m);
|
|
}),
|
|
new r(h, g, p, b, v, x, P)),
|
|
O = new t(function (e, t) {
|
|
return c(e.count(), t.count());
|
|
});
|
|
function S(t, r) {
|
|
for (var n, a = t.size(), o = 0; o < 1e3; ) {
|
|
if (a >= r || o++ > 1e3) return;
|
|
if ((n = t.pop()).count()) {
|
|
var l = (function (t, r) {
|
|
if (r.count()) {
|
|
var n = r.r2 - r.r1 + 1,
|
|
a = r.g2 - r.g1 + 1,
|
|
o = Math.max.apply(null, [n, a, r.b2 - r.b1 + 1]);
|
|
if (1 == r.count()) return [r.copy()];
|
|
var l,
|
|
s,
|
|
c,
|
|
u,
|
|
d = 0,
|
|
f = [],
|
|
m = [];
|
|
if (o == n)
|
|
for (l = r.r1; l <= r.r2; l++) {
|
|
for (u = 0, s = r.g1; s <= r.g2; s++)
|
|
for (c = r.b1; c <= r.b2; c++)
|
|
u += t[e(l, s, c)] || 0;
|
|
f[l] = d += u;
|
|
}
|
|
else if (o == a)
|
|
for (l = r.g1; l <= r.g2; l++) {
|
|
for (u = 0, s = r.r1; s <= r.r2; s++)
|
|
for (c = r.b1; c <= r.b2; c++)
|
|
u += t[e(s, l, c)] || 0;
|
|
f[l] = d += u;
|
|
}
|
|
else
|
|
for (l = r.b1; l <= r.b2; l++) {
|
|
for (u = 0, s = r.r1; s <= r.r2; s++)
|
|
for (c = r.g1; c <= r.g2; c++)
|
|
u += t[e(s, c, l)] || 0;
|
|
f[l] = d += u;
|
|
}
|
|
return (
|
|
f.forEach(function (e, t) {
|
|
m[t] = d - e;
|
|
}),
|
|
(function (e) {
|
|
var t,
|
|
n,
|
|
a,
|
|
o,
|
|
s,
|
|
c = e + "1",
|
|
u = e + "2",
|
|
h = 0;
|
|
for (l = r[c]; l <= r[u]; l++)
|
|
if (f[l] > d / 2) {
|
|
for (
|
|
a = r.copy(),
|
|
o = r.copy(),
|
|
s =
|
|
(t = l - r[c]) <= (n = r[u] - l)
|
|
? Math.min(r[u] - 1, ~~(l + n / 2))
|
|
: Math.max(r[c], ~~(l - 1 - t / 2));
|
|
!f[s];
|
|
|
|
)
|
|
s++;
|
|
for (h = m[s]; !h && f[s - 1]; ) h = m[--s];
|
|
return (a[u] = s), (o[c] = a[u] + 1), [a, o];
|
|
}
|
|
})(o == n ? "r" : o == a ? "g" : "b")
|
|
);
|
|
}
|
|
})(P, n),
|
|
s = l[0],
|
|
c = l[1];
|
|
if (!s) return;
|
|
t.push(s), c && (t.push(c), a++);
|
|
} else t.push(n), o++;
|
|
}
|
|
}
|
|
O.push(k), S(O, 0.75 * o);
|
|
for (
|
|
var E = new t(function (e, t) {
|
|
return c(e.count() * e.volume(), t.count() * t.volume());
|
|
});
|
|
O.size();
|
|
|
|
)
|
|
E.push(O.pop());
|
|
S(E, o);
|
|
for (var I = new n(); E.size(); ) I.push(E.pop());
|
|
return I;
|
|
},
|
|
}
|
|
);
|
|
})().quantize,
|
|
m = function (e) {
|
|
(this.canvas = document.createElement("canvas")),
|
|
(this.context = this.canvas.getContext("2d")),
|
|
(this.width = this.canvas.width = e.naturalWidth),
|
|
(this.height = this.canvas.height = e.naturalHeight),
|
|
this.context.drawImage(e, 0, 0, this.width, this.height);
|
|
};
|
|
m.prototype.getImageData = function () {
|
|
return this.context.getImageData(0, 0, this.width, this.height);
|
|
};
|
|
var h = function () {};
|
|
(h.prototype.getColor = function (e, t) {
|
|
return void 0 === t && (t = 10), this.getPalette(e, 5, t)[0];
|
|
}),
|
|
(h.prototype.getPalette = function (e, t, r) {
|
|
var n = (function (e) {
|
|
var t = e.colorCount,
|
|
r = e.quality;
|
|
if (void 0 !== t && Number.isInteger(t)) {
|
|
if (1 === t)
|
|
throw Error(
|
|
"colorCount should be between 2 and 20. To get one color, call getColor() instead of getPalette()",
|
|
);
|
|
t = Math.min((t = Math.max(t, 2)), 20);
|
|
} else t = 10;
|
|
return (
|
|
(void 0 === r || !Number.isInteger(r) || r < 1) && (r = 10),
|
|
{ colorCount: t, quality: r }
|
|
);
|
|
})({ colorCount: t, quality: r }),
|
|
a = new m(e),
|
|
o = f(
|
|
(function (e, t, r) {
|
|
for (var n, a, o, l, s, c = [], u = 0; u < t; u += r)
|
|
(a = e[0 + (n = 4 * u)]),
|
|
(o = e[n + 1]),
|
|
(l = e[n + 2]),
|
|
(void 0 === (s = e[n + 3]) || s >= 125) &&
|
|
((a > 250 && o > 250 && l > 250) || c.push([a, o, l]));
|
|
return c;
|
|
})(a.getImageData().data, a.width * a.height, n.quality),
|
|
n.colorCount,
|
|
);
|
|
return o ? o.palette() : null;
|
|
}),
|
|
(h.prototype.getColorFromUrl = function (e, t, r) {
|
|
var n = this,
|
|
a = document.createElement("img");
|
|
a.addEventListener("load", function () {
|
|
t(n.getPalette(a, 5, r)[0], e);
|
|
}),
|
|
(a.src = e);
|
|
}),
|
|
(h.prototype.getImageData = function (e, t) {
|
|
var r = new XMLHttpRequest();
|
|
r.open("GET", e, !0),
|
|
(r.responseType = "arraybuffer"),
|
|
(r.onload = function () {
|
|
if (200 == this.status) {
|
|
var e = new Uint8Array(this.response);
|
|
i = e.length;
|
|
for (var r = Array(i), n = 0; n < e.length; n++)
|
|
r[n] = String.fromCharCode(e[n]);
|
|
var a = r.join("");
|
|
t("data:image/png;base64," + window.btoa(a));
|
|
}
|
|
}),
|
|
r.send();
|
|
}),
|
|
(h.prototype.getColorAsync = function (e, t, r) {
|
|
var n = this;
|
|
this.getImageData(e, function (e) {
|
|
var a = document.createElement("img");
|
|
a.addEventListener("load", function () {
|
|
t(n.getPalette(a, 5, r)[0], this);
|
|
}),
|
|
(a.src = e);
|
|
});
|
|
}),
|
|
e.s(
|
|
[
|
|
"default",
|
|
0,
|
|
function (e) {
|
|
let {
|
|
avatarUrl: t,
|
|
avatarWidth: r = "80px",
|
|
borderInnerWidth: o = "4px",
|
|
borderOuterWidth: c = "2px",
|
|
className: u = "",
|
|
borderColor: d = "#fff",
|
|
colorCallback: f = () => {},
|
|
onClick: m,
|
|
alt: g = "",
|
|
from: p,
|
|
...b
|
|
} = e,
|
|
[v, x] = (0, a.useState)("#1f6eff"),
|
|
y = `calc(${r} - ${c} - ${c})`;
|
|
(0, a.useEffect)(() => {
|
|
if (!t) return;
|
|
let e = new Image();
|
|
(e.src = `${(0, s.webpImg)(t)}`),
|
|
(e.crossOrigin = ""),
|
|
(e.onload = function () {
|
|
let t = new h().getColor(e),
|
|
r = `rgba(${t.join(",")})`,
|
|
n = `rgba(${t.join(",")}, 0.6)`,
|
|
a = `linear-gradient(to right, ${r}, ${n}`;
|
|
f(a), x(a);
|
|
});
|
|
}, [t]);
|
|
let w = "topbar" === p;
|
|
return (0, n.jsxs)("div", {
|
|
onClick: m || (() => {}),
|
|
style: { backgroundColor: w ? "transparent" : d },
|
|
className: `${u} relative rounded-full p-1 ${m ? "cursor-pointer group" : ""}`,
|
|
...b,
|
|
children: [
|
|
m &&
|
|
(0, n.jsx)("div", {
|
|
className:
|
|
"hidden group-hover:flex absolute inset-0 rounded-full bg-black/60 items-center justify-center z-10",
|
|
children: (0, n.jsx)("img", {
|
|
src: l,
|
|
alt: "",
|
|
className: "w-6 h-6",
|
|
}),
|
|
}),
|
|
(0, n.jsx)("div", {
|
|
className: "flex items-center justify-center rounded-full",
|
|
style: { width: r, height: r, background: v },
|
|
children: (0, n.jsx)("img", {
|
|
src: t
|
|
? (0, s.webpImg)(t)
|
|
: "https://liblibai-online.liblib.cloud/web/1656e2f1b3c74f1ba823b610f1b2cbdf/5b27c87b-4621-4e9e-8776-941b2856b262.jpg",
|
|
alt: g,
|
|
className:
|
|
"flex items-center justify-center rounded-full object-cover border-solid",
|
|
style: {
|
|
width: y,
|
|
height: y,
|
|
borderWidth: o,
|
|
borderColor: w ? "var(--color-background)" : d,
|
|
},
|
|
}),
|
|
}),
|
|
],
|
|
});
|
|
},
|
|
],
|
|
228949,
|
|
);
|
|
};
|
|
|
|
export default moduleFactory;
|