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

743 lines
27 KiB
JavaScript

/*
* Extracted from browser-delivered Turbopack chunk: fd0220e4d10052af.701bdafa2d.js
* Module id: 539839
* For reading/searching only; this factory depends on the original Turbopack runtime.
*/
const moduleFactory = (e) => {
"use strict";
var t = e.i(462214),
n = e.i(358379),
i = e.i(185264),
r = e.i(41671),
a = e.i(711694),
o = e.i(523520),
s = e.i(855847),
c = e.i(234954),
l = e.i(848024),
u = e.i(91134),
h = e.i(493983),
f = e.i(677588),
d = e.i(299750),
p = e.i(216257),
g = e.i(929286),
b = e.i(10036),
m = e.i(292002),
w = e.i(768924),
v = e.i(713118),
x = e.i(182004),
y = e.i(44980),
_ = e.i(174008);
function S({
nodeId: e,
onClose: S,
selectedCount: E,
totalCount: M,
selectedRowIds: T,
onGenerated: k,
}) {
let C = (0, p.useGlobalStore)((e) => e.defaultModel.image),
A = (0, p.useGlobalStore)((e) => e.getModel),
N = (0, i.useUserVipInfo)((e) => e.rateLimitBenefitStatus),
I = (0, p.useCanvasStore)((e) => e.updateNodeData),
P = (0, p.useCanvasStore)((0, g.selectNodeData)(e)),
R = (0, n.useMemo)(
() =>
P?.imageGenConfig ?? { model: C, aspectRatio: "16:9", count: 1 },
[P?.imageGenConfig, C],
),
L = R.model || C,
D = (0, n.useMemo)(() => A("scriptImage", L), [A, L]),
j = (0, p.useGlobalStore)((e) => e.support?.scriptImage ?? null),
O = (0, n.useMemo)(() => {
if (!P?.rows || !T?.size) return 0;
let e = 0;
for (let t of P.rows) {
if (!t.hiddenUuid || !T.has(t.hiddenUuid)) continue;
let n = (t.characters ?? []).filter(
(e) => e.characterImageUrl,
).length;
n > e && (e = n);
}
return e;
}, [P?.rows, T]),
F = (0, n.useMemo)(() => {
if (!j || 0 === O) return new Map();
let e = {
prompt: "",
model: "",
count: 1,
settings: {},
imageList: Array.from({ length: O }, () => ({
nodeId: "",
url: "placeholder",
})),
},
t = new Map();
for (let n of j) {
let i = A("scriptImage", n.modelKey);
(0, h.isImageModelEnabledForMedia)(i, e) ||
t.set(n.modelKey, "该模型不支持当前连入的图片素材");
}
return t;
}, [j, O, A]),
U = (0, n.useMemo)(() => {
let e = D?.properties;
return (
!!e &&
["styles", "lora", "template"].some(
(t) => e[t]?.maxCount && e[t].maxCount > 0,
)
);
}, [D?.properties]);
(0, n.useEffect)(() => {
P?.imageGenConfig ||
I(e, { imageGenConfig: { model: C, aspectRatio: "16:9", count: 1 } });
}, [e, P?.imageGenConfig, C, I]);
let B = (0, n.useCallback)(
(t) => {
I(e, { imageGenConfig: { ...R, ...t } });
},
[e, R, I],
);
(0, n.useEffect)(() => {
if (O > 0 && F.has(L) && j) {
let e = j.find((e) => !F.has(e.modelKey));
e && B({ model: e.modelKey });
}
}, [F, L, j, O, B]);
let H = (0, n.useCallback)(
(e) => {
e !== L && B({ model: e });
},
[L, B],
),
z = (0, n.useMemo)(
() => ({
prompt: "",
model: L,
modeType: "text2image",
count: R.count ?? 1,
settings: R.settings ?? {},
}),
[L, R.count, R.settings],
),
G = (0, n.useCallback)(
(e) => {
void 0 !== e.settings &&
B({ settings: { ...R.settings, ...e.settings } });
},
[R.settings, B],
),
$ = (0, n.useMemo)(() => {
let e = R.cameraControl;
return (
e || (e = (0, u.loadCameraControlStorage)() ?? void 0),
{ prompt: "", model: L, count: 1, settings: {}, cameraControl: e }
);
}, [R.cameraControl, L]),
V = (0, n.useCallback)(
(e) => {
void 0 !== e.cameraControl && B({ cameraControl: e.cameraControl });
},
[B],
),
W = (0, n.useCallback)(
(e, t) => {
B({ fineTuneType: t, fineTuneModels: e });
},
[B],
),
K = (0, p.useCanvasStore)((e) => e.projectId),
[q, X] = (0, n.useState)(null),
Y = (0, n.useRef)(A);
Y.current = A;
let J = (0, n.useMemo)(
() => JSON.stringify(R.settings ?? {}),
[R.settings],
),
Z = (0, n.useMemo)(
() => JSON.stringify(R.fineTuneModels ?? []),
[R.fineTuneModels],
);
(0, n.useEffect)(() => {
let t = !1,
n = setTimeout(() => {
let n = {
prompt: "",
model: L,
modeType: "text2image",
count: 1,
settings: R.settings ?? {},
fineTuneType: R.fineTuneType,
fineTuneModels: R.fineTuneModels,
},
i = (0, b.buildRequestData)(n, "image", e, K ?? "", Y.current);
(0, d.calculatePower)(i)
.then((e) => {
if (!t && e?.code === 0) {
let t = e.data;
X(t?.power ?? 0);
}
})
.catch(() => {
t || X(null);
});
}, 300);
return () => {
(t = !0), clearTimeout(n);
};
}, [L, J, Z, e, K, N]);
let Q = null != q ? q * E : null,
{ batchGenerate: ee } = (function (e) {
let t = (0, p.useCanvasStore)((t) => t.getNode(e)?.data),
i = (0, p.useCanvasStore)((e) => e.updateNodeData),
r = (0, p.useCanvasStore)((e) => e.addNode),
a = (0, p.useCanvasStore)((e) => e.addEdge),
o = (0, p.useCanvasStore)((e) => e.isReadonly),
{ getNode: s, getNodes: c } = (0, w.useReactFlow)();
return {
batchGenerate: (0, n.useCallback)(
(n) => {
if (!t) return "";
let l = t.rows ?? [],
u = t.views,
h = t.activeViewId ?? "default",
f = u?.find((e) => e.id === h) ?? u?.[0],
d = (function (e, t) {
if (!t?.length) return e;
let n = (e) =>
null == e
? ""
: "string" == typeof e ||
"number" == typeof e ||
"boolean" == typeof e
? String(e)
: JSON.stringify(e);
return e.filter((e) =>
t.every((t) => {
let i,
r,
a = e[t.id] ?? "",
o = t.value;
if (
(o && "object" == typeof o && "operator" in o
? ((i = o.operator), (r = o.value))
: ((i = "contains"), (r = n(o))),
!r)
)
return !0;
let s = n(a).toLowerCase(),
c = r.toLowerCase();
switch (i) {
case "contains":
return s.includes(c);
case "equals":
return s === c;
case "gt":
return Number(a) > Number(r);
case "lt":
return Number(a) < Number(r);
default:
return !0;
}
}),
);
})(l, f?.tableConfig?.columnFilters);
if (
(n &&
n.size > 0 &&
(d = d.filter((e) => e.hiddenUuid && n.has(e.hiddenUuid))),
o || 0 === d.length)
)
return "";
let g = s(e);
if (!g) return "";
let b = t.nodeWidth ?? 800,
w = t.name || t.label || "脚本",
_ = t.imageGenConfig,
S = (0, v.extractRatioFromNodeParams)(_),
E = (0, v.computeNodeDimensionsFromRatio)(S),
M = Math.ceil(Math.sqrt(d.length)),
T = 80 + M * E.width + (M - 1) * 40,
k = Math.ceil(d.length / M),
C = 110 + k * E.height + (k - 1) * 40,
A = crypto.randomUUID(),
N = { ..._?.settings },
I = d.map((e, t) => {
let n = Math.floor(t / M),
i = (e.characters ?? [])
.map((e) => e.characterImageUrl)
.filter(Boolean),
r = i.map((e) => ({ nodeId: "", url: e })),
a = {
type: x.NodeType.IMAGE,
name: `分镜 #${e.shotNumber}`,
url: [],
action: x.NodeAction.IMAGE_GENERATE,
scriptRowHiddenUuid: e.hiddenUuid,
taskInfo: { taskId: "", loading: !0, status: 0 },
params: {
prompt:
e.imageGenerationPrompt || e.plotDescription || "",
model: _?.model ?? "",
count: 1,
modeType: r.length > 0 ? "image2image" : "text2image",
settings: N,
imageList: r.length > 0 ? r : void 0,
fineTuneType: _?.fineTuneType,
fineTuneModels: _?.fineTuneModels,
scene: "group-generate",
...(_?.model === "z-image" ? { promptMagic: 1 } : {}),
},
};
return (
i.length > 0 && (a.refImages = i),
{
id: crypto.randomUUID(),
type: x.NodeType.IMAGE,
data: a,
position: {
x: 40 + (t % M) * (E.width + 40),
y: 70 + n * (E.height + 40),
},
parentId: A,
sourcePosition: m.Position.Right,
targetPosition: m.Position.Left,
width: E.width,
height: E.height,
}
);
}),
P = {
type: x.NodeType.GROUP,
name: `分镜图 \xb7 ${w}`,
groupColor: null,
sourceScriptNodeId: e,
storyboardTitle: `分镜图 \xb7 ${w}`,
storyboardGroupType: "image",
};
for (let t of (r({
id: A,
type: x.NodeType.GROUP,
data: P,
position: (0, y.findRightSidePosition)(
g.position,
b,
{ width: T, height: C },
c(),
p.stores.canvas?.edges ?? [],
e,
),
zIndex: -1001,
style: {
background: "var(--canvas-group-bg)",
border: "1px solid var(--canvas-group-border)",
},
width: T,
height: C,
measured: { width: T, height: C },
sourcePosition: m.Position.Right,
targetPosition: m.Position.Left,
}),
I))
r(t, { skipOverlapResolution: !0 });
return (
a({
id: crypto.randomUUID(),
source: e,
sourceHandle: "source",
target: A,
targetHandle: "target",
}),
i(e, { linkedImageGroupId: A }),
p.stores.canvas?.requestImmediateFlush(),
A
);
},
[e, t, o, s, c, r, a, i],
),
};
})(e),
et = (0, n.useCallback)(() => {
(0, f.reportLog)({
e: "libtv.canvas.generator.submit",
var: { generator_type: "分镜生成器", use_slash: !1, use_at: !1 },
});
let e = ee(T);
e && k?.(e);
}, [ee, T, k]);
return (0, t.jsx)(c.PopoverManagerProvider, {
children: (0, t.jsxs)("div", {
className:
"nodrag nopan nowheel flex w-max flex-col items-start gap-1",
style: _.FLOATING_TOOLBAR_STYLE,
children: [
U &&
(0, t.jsx)("div", {
className: "flex items-center gap-2 px-0.5 py-1",
children: (0, t.jsx)(a.default, {
onlyFineTune: !0,
modelSchema: D,
fineTuneModels: R.fineTuneModels,
onFineTuneChange: W,
nodeId: e,
}),
}),
(0, t.jsxs)("div", {
className: "flex items-center justify-center gap-1 px-1 py-1",
children: [
(0, t.jsx)("button", {
type: "button",
onClick: S,
className:
"flex h-8 w-8 min-w-8 shrink-0 items-center justify-center rounded-lg text-neutral-50 transition-colors hover:bg-white/10",
children: (0, t.jsx)(r.Icons.x, { className: "h-3 w-3" }),
}),
(0, t.jsx)("div", {
className: "mx-0.5 h-5",
style: {
width: 0,
borderLeft: "0.5px solid rgba(255, 255, 255, 0.08)",
},
}),
(0, t.jsx)(s.default, {
type: "scriptImage",
value: L,
onChange: H,
disabledModelKeys: F,
}),
(0, t.jsx)("div", {
className: "mx-0.5 h-5",
style: {
width: 0,
borderLeft: "0.5px solid rgba(255, 255, 255, 0.08)",
},
}),
(0, t.jsx)(l.default, {
params: z,
modelSchema: D,
onParamsChange: G,
}),
(0, t.jsx)("div", {
className: "mx-0.5 h-5",
style: {
width: 0,
borderLeft: "0.5px solid rgba(255, 255, 255, 0.08)",
},
}),
(0, t.jsx)(o.default, {
params: $,
modelSchema: D,
onParamsChange: V,
}),
(0, t.jsx)("div", {
className: "mx-0.5 h-5",
style: {
width: 0,
borderLeft: "0.5px solid rgba(255, 255, 255, 0.08)",
},
}),
(0, t.jsxs)("span", {
className:
"whitespace-nowrap px-2 text-[13px] text-neutral-50/70",
children: ["已选", E, "/", M],
}),
(0, t.jsx)("div", {
className: "mx-0.5 h-5",
style: {
width: 0,
borderLeft: "0.5px solid rgba(255, 255, 255, 0.08)",
},
}),
(0, t.jsxs)("button", {
type: "button",
onClick: et,
className:
"bg-btn-invert-bg text-btn-invert-text hover:bg-btn-invert-bg-hover active:bg-btn-invert-bg-active flex h-8 cursor-pointer items-center justify-center gap-0.5 rounded-lg px-3 py-2 transition-all",
children: [
(0, t.jsx)(r.Icons.zap, {
className: "text-btn-invert-text h-[14px] w-[10px]",
}),
(0, t.jsx)("span", {
className:
"text-btn-invert-text min-w-[14px] text-center text-xs font-normal leading-none",
children: null != Q ? Q : "-",
}),
],
}),
],
}),
],
}),
});
}
e.s(["ScriptAggregatedGenerator", () => S], 420510);
var E = e.i(395),
M = e.i(295085);
let T = (0, n.memo)(function ({
row: e,
showSelection: n,
isSelected: i,
onToggle: a,
}) {
var o;
let s = !!e.videoReference?.referenceFrameImage,
c = (o = e.durationSeconds) || 0 === o ? `${o.toFixed(2)}s` : "",
l = [e.shotSize, e.emotion].filter(Boolean).join(" · "),
u = e.characters
?.map((e) => e.characterName)
.filter(Boolean)
.join(", ");
return (0, t.jsxs)("div", {
className: "flex flex-col overflow-hidden rounded-xl",
style: {
background: "rgba(255, 255, 255, 0.04)",
border: "1px solid rgba(255, 255, 255, 0.06)",
},
children: [
(0, t.jsxs)("div", {
className:
"relative aspect-[4/3] w-full overflow-hidden bg-black/20",
children: [
n &&
(0, t.jsx)("div", {
className: "absolute left-2 top-2 z-20",
children: (0, t.jsx)("input", {
type: "checkbox",
checked: !!i,
onChange: a,
className: "nodrag h-4 w-4 cursor-pointer accent-white",
}),
}),
(0, t.jsx)("div", {
className: `absolute ${n ? "left-8" : "left-2"} top-2 z-10 flex h-5 items-center gap-1 rounded-full px-1.5 text-[10px] font-semibold text-white`,
style: { background: "rgba(0, 0, 0, 0.6)" },
children: (0, t.jsx)("span", { children: e.shotNumber }),
}),
c &&
(0, t.jsx)("div", {
className:
"absolute right-2 top-2 z-10 rounded px-1.5 py-0.5 text-[10px] tabular-nums text-white/80",
style: { background: "rgba(0, 0, 0, 0.6)" },
children: c,
}),
s
? (0, t.jsx)(E.default, {
src: (0, M.getFasterImage)(
e.videoReference?.referenceFrameImage,
{ width: 220 },
),
alt: `镜头 ${e.shotNumber}`,
className: "h-full w-full object-cover",
decoding: "async",
})
: (0, t.jsxs)("div", {
className:
"flex h-full w-full flex-col items-center justify-center gap-1.5 text-white/20",
children: [
(0, t.jsx)(r.Icons.ImageS, { width: 32, height: 32 }),
(0, t.jsx)("span", {
className: "text-xs",
children: "暂无图片",
}),
],
}),
],
}),
(0, t.jsxs)("div", {
className: "flex flex-1 flex-col gap-1 px-2.5 pb-2.5 pt-2",
children: [
u &&
(0, t.jsx)("span", {
className:
"inline-flex w-fit truncate rounded bg-white/10 px-1.5 py-0.5 text-[10px] text-white/50",
children: u,
}),
e.plotDescription &&
(0, t.jsx)("p", {
className:
"break-words text-xs leading-relaxed text-white/70",
style: {
display: "-webkit-box",
WebkitLineClamp: 3,
WebkitBoxOrient: "vertical",
overflow: "hidden",
},
title: e.plotDescription,
children: e.plotDescription,
}),
l &&
(0, t.jsx)("p", {
className: "truncate text-[10px] text-white/40",
title: l,
children: l,
}),
(0, t.jsx)("div", {
className: "mt-auto pt-1",
children: (0, t.jsxs)("span", {
className: "text-[10px] text-white/30",
children: ["场景 ", e.shotNumber],
}),
}),
],
}),
],
});
});
function k({
rows: e,
showSelection: n = !1,
selectedRowIds: i,
onSelectionChange: a,
}) {
return 0 === e.length
? (0, t.jsx)("div", {
className: "nodrag flex h-full w-full items-center justify-center",
children: (0, t.jsxs)("div", {
className: "flex flex-col items-center gap-3 text-white/30",
children: [
(0, t.jsx)(r.Icons.layoutGrid, { width: 48, height: 48 }),
(0, t.jsx)("span", {
className: "text-sm",
children: "暂无分镜数据",
}),
],
}),
})
: (0, t.jsx)("div", {
className: "nodrag tiny-scrollbar h-full w-full overflow-auto",
style: { padding: `${v.GRID_PADDING}px` },
children: (0, t.jsx)("div", {
className: "grid",
style: {
gridTemplateColumns: "repeat(auto-fill, 220px)",
gap: `${v.GRID_GAP}px`,
justifyContent: "center",
},
children: e.map((e) =>
(0, t.jsx)(
T,
{
row: e,
showSelection: n,
isSelected: !!e.hiddenUuid && (i?.has(e.hiddenUuid) ?? !1),
onToggle: () => {
if (!e.hiddenUuid || !a || !i) return;
let t = new Set(i);
t.has(e.hiddenUuid)
? t.delete(e.hiddenUuid)
: t.add(e.hiddenUuid),
a(t);
},
},
e.shotNumber,
),
),
}),
});
}
function C({
onRegenerate: e,
onGenerateStoryboard: n,
onExport: i,
disableRegenerate: a = !1,
disableStoryboard: o = !1,
disableExport: s = !1,
}) {
let c = "cursor-not-allowed text-fg-disabled";
return (0, t.jsx)("div", {
className: "flex w-max items-center",
children: (0, t.jsxs)("div", {
className: "flex items-center justify-center gap-1",
style: _.FLOATING_TOOLBAR_STYLE,
children: [
(0, t.jsxs)("button", {
type: "button",
onClick: a ? void 0 : e,
disabled: a,
className: `flex h-8 items-center justify-center gap-1 rounded-lg px-3 py-2 text-[13px] transition-colors ${a ? c : "text-canvas-controls-text hover:bg-canvas-controls-hover"}`,
children: [
(0, t.jsx)(r.Icons.Refresh, { className: "h-4 w-4 shrink-0" }),
(0, t.jsx)("span", {
className: "whitespace-nowrap",
children: "重新生成",
}),
],
}),
(0, t.jsxs)("button", {
type: "button",
onClick: o ? void 0 : n,
disabled: o,
className: `flex h-8 items-center justify-center gap-1 rounded-lg px-3 py-2 text-[13px] transition-colors ${o ? c : "text-canvas-controls-text hover:bg-canvas-controls-hover"}`,
children: [
(0, t.jsx)(r.Icons.Imageset, { className: "h-4 w-4 shrink-0" }),
(0, t.jsx)("span", {
className: "whitespace-nowrap",
children: "生成分镜",
}),
],
}),
(0, t.jsx)("div", {
className: "mx-1 h-5",
style: {
width: 0,
borderLeft: "0.5px solid rgba(255, 255, 255, 0.08)",
},
}),
(0, t.jsx)("button", {
type: "button",
onClick: s ? void 0 : i,
disabled: s,
className: `flex h-8 w-8 min-w-8 shrink-0 items-center justify-center rounded-lg transition-colors ${s ? c : "text-canvas-controls-text hover:bg-canvas-controls-hover"}`,
children: (0, t.jsx)(r.Icons.download, { className: "h-4 w-4" }),
}),
],
}),
});
}
e.s(["default", () => k], 565453),
e.s(["ScriptFloatingToolbar", () => C], 244008);
var A = e.i(41114),
N = e.i(276204);
function I({ taskInfo: e }) {
return (0, t.jsxs)("div", {
className:
"skeleton-shimmer relative flex h-full flex-col overflow-hidden p-3",
children: [
(0, t.jsx)("div", {
className: "flex flex-1 flex-col gap-2",
children: Array.from({ length: 7 }, (e, n) =>
(0, t.jsx)(
"div",
{
className: "flex gap-2",
children: Array.from({ length: 3 }, (e, n) =>
(0, t.jsx)(
"div",
{
className: (0, A.cn)(
"h-6 flex-1 rounded bg-white/10",
"canvas-light:bg-neutral-300",
),
},
`col-${n}`,
),
),
},
`row-${n}`,
),
),
}),
(0, t.jsx)("div", {
className: "mt-3 flex justify-center",
children: (0, t.jsx)(N.default, { taskInfo: e }),
}),
],
});
}
e.s(["default", () => I], 539839);
};
export default moduleFactory;