Your Name 1912bcd25b
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
chore: sync all remaining local workspace changes
2026-05-08 11:26:57 +08:00

443 lines
14 KiB
JavaScript

/*
* Extracted from browser-delivered Turbopack chunk: 024a3642cfddfa89.95b9211528.js
* Module id: 395132
* For reading/searching only; this factory depends on the original Turbopack runtime.
*/
const moduleFactory = (e) => {
"use strict";
var t = e.i(462214),
r = e.i(358379),
s = e.i(41671),
i = e.i(295085),
n = e.i(23741);
let l = "poolKey";
function a(e, t) {
e.dataset[l] = t;
}
let o = (e) =>
((e) => {
if (
e.startsWith("http://") ||
e.startsWith("https://") ||
e.startsWith("blob:")
)
return !0;
if (e.startsWith("data:")) {
let t = e.indexOf(",");
return -1 !== t && (e.length - t - 1) * 0.75 <= 512e3;
}
return !1;
})(e),
c = void 0 !== n.default && !1;
class u {
available = new Map();
totalAvailable = 0;
lruKeys = new Set();
maxPoolSize;
evictScheduled = !1;
_hits = 0;
_misses = 0;
constructor(e = 300) {
this.maxPoolSize = e;
}
acquire(e) {
if (o(e)) {
let t = this.available.get(e);
if (t && t.length > 0) {
c && this._hits++;
let r = t.pop();
if (r)
return (
this.totalAvailable--,
0 === t.length && this.available.delete(e),
a(r, e),
r
);
}
}
c && this._misses++;
let t = document.createElement("img");
return (t.src = e), a(t, e), t;
}
tryAcquire(e) {
if (!o(e)) return null;
let t = this.available.get(e);
if (!t || 0 === t.length) return null;
let r = t.pop() ?? null;
return r
? (this.totalAvailable--,
0 === t.length && this.available.delete(e),
a(r, e),
r)
: null;
}
release(e, t) {
let r = t ?? e.dataset?.[l],
s = r ?? e.currentSrc ?? e.src;
if (!s || !o(s)) {
c &&
console.warn("[imgPool] release skip", {
key: r?.slice?.(0, 80),
src: s?.slice?.(0, 80),
poolable: !!s && o(s),
});
return;
}
(e.onload = null), (e.onerror = null);
let i = this.available.get(s);
i || ((i = []), this.available.set(s, i)),
i.push(e),
this.totalAvailable++,
this.lruKeys.delete(s),
this.lruKeys.add(s),
this.totalAvailable > this.maxPoolSize &&
!this.evictScheduled &&
((this.evictScheduled = !0),
queueMicrotask(() => {
(this.evictScheduled = !1), this.evictExcess();
}));
}
evictExcess() {
for (
;
this.totalAvailable > this.maxPoolSize && this.lruKeys.size > 0;
) {
let e = this.lruKeys.values().next().value,
t = this.available.get(e);
if (!t || 0 === t.length) {
this.lruKeys.delete(e);
continue;
}
let r = t.shift();
r && (r.src = ""),
this.totalAvailable--,
0 === t.length &&
(this.available.delete(e), this.lruKeys.delete(e));
}
}
getStats() {
if (!c) return;
let e = this._hits + this._misses,
t = e > 0 ? ((this._hits / e) * 100).toFixed(1) + "%" : "0%";
return { hits: this._hits, misses: this._misses, hitRate: t };
}
}
let d = new u(
(function () {
if ("u" < typeof navigator) return 300;
let e = navigator.deviceMemory;
return "number" == typeof e && e <= 4
? 200
: "number" == typeof e && e <= 8
? 400
: 600;
})(),
);
function f(e, t) {
(e.alt = t.alt ?? ""),
(e.className = t.className ?? ""),
void 0 !== t.crossOrigin && (e.crossOrigin = t.crossOrigin ?? ""),
void 0 !== t.draggable
? (e.draggable =
"string" == typeof t.draggable
? "false" !== t.draggable
: !!t.draggable)
: (e.draggable = !1),
(e.decoding = t.decoding ?? "async"),
void 0 !== t.srcSet && (e.srcset = t.srcSet),
void 0 !== t.sizes && (e.sizes = t.sizes),
void 0 !== t.width &&
(e.width =
"number" == typeof t.width ? t.width : parseInt(t.width, 10)),
void 0 !== t.height &&
(e.height =
"number" == typeof t.height ? t.height : parseInt(t.height, 10)),
t.loading && (e.loading = t.loading),
t.fetchPriority && e.setAttribute("fetchpriority", t.fetchPriority),
t.style && "object" == typeof t.style
? (e.removeAttribute("style"), Object.assign(e.style, t.style))
: t.style || e.removeAttribute("style"),
(e.onload = t.onLoad ? (e) => t.onLoad(e) : null),
(e.onerror = t.onError ? (e) => t.onError(e) : null),
(e.onclick = t.onClick ? (e) => t.onClick(e) : null),
t.onLoad &&
e.complete &&
e.naturalWidth > 0 &&
t.onLoad({ currentTarget: e });
}
function p(e) {
(e.onload = null),
(e.onerror = null),
(e.onclick = null),
e.parentNode && e.parentNode.removeChild(e),
d.release(e);
}
e.s(["imgPool", 0, d, "setPoolKey", () => a], 168161);
let h = { display: "contents" },
m = (0, r.memo)(function ({
src: e = "",
bustKey: s,
expectedAcquireUrl: n,
...l
}) {
let o = (0, r.useRef)(null),
c = (0, r.useRef)(null),
u = (0, r.useRef)(l),
m = (0, r.useRef)(l);
m.current = l;
let g = (0, r.useRef)(n);
return (
(g.current = n),
(0, r.useLayoutEffect)(
() => () => {
let e = o.current;
if (e) for (; e.firstChild; ) p(e.firstChild);
c.current = null;
},
[],
),
(0, r.useLayoutEffect)(() => {
let t = o.current;
if (!t) return;
if ((0, i.isEmptyImageSrc)(e)) {
let e = c.current;
e && (p(e), (c.current = null));
return;
}
let r = c.current;
if (!r || !r.parentNode || s) {
r?.parentNode && p(r);
let i = g.current || e,
n = s ? document.createElement("img") : d.acquire(i);
s && a(n, i),
(s || n.src !== i) && (n.src = e),
f(n, m.current),
t.appendChild(n),
(c.current = n);
return;
}
let n = g.current || e,
l = d.tryAcquire(n);
l && l.complete && l.naturalWidth > 0
? (t.replaceChild(l, r),
d.release(r),
(c.current = l),
f(l, m.current))
: (l && d.release(l), f(r, m.current), (r.src = e));
}, [e, s]),
(0, r.useLayoutEffect)(() => {
let e = c.current;
e && n && a(e, n);
}, [n]),
(0, r.useLayoutEffect)(() => {
if (!c.current) return;
let e = u.current;
(e.className !== l.className ||
e.alt !== l.alt ||
e.style !== l.style ||
e.srcSet !== l.srcSet ||
e.sizes !== l.sizes ||
e.width !== l.width ||
e.height !== l.height ||
e.onLoad !== l.onLoad ||
e.onError !== l.onError ||
e.onClick !== l.onClick) &&
((u.current = l), f(c.current, l));
}),
(0, t.jsx)("div", { ref: o, style: h })
);
});
e.s(["default", 0, m], 395132);
let g = (e) => !!e && (e.startsWith("blob:") || e.startsWith("data:")),
x = (0, r.memo)(function ({
src: e,
alt: n,
className: l,
iconSize: a = 32,
crossOrigin: o,
retryKey: c,
onLoadError: u,
onLoadSuccess: d,
onCacheCapture: f,
skipBlobTransition: p,
uploaded: h,
srcSet: x,
sizes: v,
fetchPriority: b,
expectedAcquireUrl: y,
...w
}) {
let [C, j] = (0, r.useState)(!1),
[N, k] = (0, r.useState)(),
[S, L] = (0, r.useState)(!1),
[I, E] = (0, r.useState)(!1),
T = (0, r.useRef)(e),
[z, A] = (0, r.useState)(0),
M = (0, r.useRef)(),
R = !p && g(e);
(0, r.useEffect)(() => {
let t = T.current;
(T.current = e),
j(!1),
A(0),
M.current && (clearTimeout(M.current), (M.current = void 0)),
E(!1),
!p && g(t) && e && !g(e) ? k(t) : k(void 0),
L(!1);
}, [e]),
(0, r.useEffect)(
() => () => {
M.current && clearTimeout(M.current);
},
[],
),
(0, r.useEffect)(() => {
if (!S || !N) return;
let e = setTimeout(() => E(!0), 350);
return () => clearTimeout(e);
}, [S, N]),
(0, r.useEffect)(() => {
void 0 !== c &&
c > 0 &&
(M.current && (clearTimeout(M.current), (M.current = void 0)),
A(0),
j(!1));
}, [c]);
let U = (0, r.useCallback)(
(t) => {
if ((L(!0), d?.(), e && f)) {
let r = t.currentTarget;
f(r?.currentSrc || e);
}
},
[d, f, e],
),
P = (0, r.useCallback)(() => {
let t = void 0 !== c || u ? 0 : 1;
if (e && !g(e) && z < t) {
(M.current = setTimeout(
() => {
(M.current = void 0), A((e) => e + 1), j(!1);
},
2e3 * (z + 1),
)),
j(!0);
return;
}
j(!0), u?.();
}, [u, z, e]),
O = (0, r.useCallback)(
(t) => {
if ((d?.(), e && f)) {
let r = t.currentTarget;
f(r?.currentSrc || e);
}
},
[d, f, e],
);
return C || (0, i.isEmptyImageSrc)(e)
? (0, t.jsx)("div", {
className: `flex w-full items-center justify-center bg-[#F5F5F5] dark:bg-[#212121] ${l ?? ""}`,
children: (0, t.jsx)(s.Icons.ImagePlaceholder, {
width: a,
height: a,
className: "text-[#a8a8a8] dark:text-white/15",
}),
})
: N
? (0, t.jsxs)("div", {
className: "relative h-full w-full overflow-hidden",
children: [
(0, t.jsx)("img", {
src: N,
alt: "",
className: l,
style: { filter: "blur(12px)", transform: "scale(1.1)" },
crossOrigin: o,
draggable: w.draggable ?? !1,
}),
(0, t.jsx)("div", {
className:
"bg-bg-overlay pointer-events-none absolute inset-0 flex items-center justify-center",
style: {
opacity: +!S,
transition: "opacity 300ms ease-out",
},
children: (0, t.jsx)("span", {
className:
"border-fg-muted/35 border-t-fg-default size-5 animate-spin rounded-full border-2",
}),
}),
(0, t.jsx)(m, {
src: e,
alt: n ?? "",
className: I
? l
: "absolute inset-0 h-full w-full object-cover",
style: I
? void 0
: { opacity: +!!S, transition: "opacity 300ms ease-out" },
crossOrigin: o,
onLoad: U,
onError: P,
...w,
}),
],
})
: R
? h
? (0, t.jsx)("img", {
src: e,
alt: n ?? "",
className: l,
crossOrigin: o,
draggable: w.draggable ?? !1,
...w,
})
: (0, t.jsxs)("div", {
className: "relative h-full w-full overflow-hidden",
children: [
(0, t.jsx)("img", {
src: e,
alt: n ?? "",
className: l,
style: {
filter: "blur(12px)",
transform: "scale(1.1)",
},
crossOrigin: o,
draggable: w.draggable ?? !1,
...w,
}),
(0, t.jsx)("div", {
className:
"bg-bg-overlay absolute inset-0 flex items-center justify-center",
children: (0, t.jsx)("span", {
className:
"border-fg-muted/35 border-t-fg-default size-5 animate-spin rounded-full border-2",
}),
}),
],
})
: (0, t.jsx)(m, {
bustKey: z,
src: e,
alt: n ?? "",
className: l,
crossOrigin: o,
onError: P,
onLoad: O,
srcSet: x,
sizes: v,
fetchPriority: b,
expectedAcquireUrl: y,
...w,
});
});
e.s(["default", 0, x], 395);
};
export default moduleFactory;