372 lines
14 KiB
JavaScript
372 lines
14 KiB
JavaScript
/*
|
|
* Extracted from browser-delivered Turbopack chunk: 36466d3530b7d918.083c839b6e.js
|
|
* Module id: 855847
|
|
* 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),
|
|
a = e.i(111558),
|
|
n = e.i(948390),
|
|
o = e.i(320539),
|
|
i = e.i(963527),
|
|
s = e.i(521527),
|
|
l = e.i(112671),
|
|
c = e.i(844567),
|
|
u = e.i(529833),
|
|
d = e.i(41671),
|
|
p = e.i(722573),
|
|
m = e.i(216257),
|
|
f = e.i(791997),
|
|
h = e.i(41114),
|
|
g = e.i(64560),
|
|
v = e.i(234954);
|
|
let x = {
|
|
backgroundColor: "#141414",
|
|
borderRadius: "8px",
|
|
border: "0.5px solid #363636",
|
|
boxShadow: "0px 2px 6px 0px rgba(0,0,0,0.08)",
|
|
padding: "8px",
|
|
},
|
|
b = (0, r.memo)(function ({
|
|
model: e,
|
|
isSelected: s,
|
|
disabled: l,
|
|
disabledReason: u,
|
|
benefitLabel: p,
|
|
activityBenefitMatch: m,
|
|
onSelect: f,
|
|
}) {
|
|
let v = e.icon,
|
|
b = !!e.description,
|
|
[y, w] = (0, r.useState)({ x: 0, y: 0, visible: !1 }),
|
|
k = (0, r.useCallback)((e) => {
|
|
w({ x: e.clientX, y: e.clientY, visible: !0 });
|
|
}, []),
|
|
S = (0, r.useCallback)((e) => {
|
|
w((t) => (t.visible ? { ...t, x: e.clientX, y: e.clientY } : t));
|
|
}, []),
|
|
C = (0, r.useCallback)(() => w((e) => ({ ...e, visible: !1 })), []),
|
|
P = (0, t.jsxs)("button", {
|
|
type: "button",
|
|
onClick: () => !l && f(e.modelKey),
|
|
"data-selected": s,
|
|
className: (0, h.cn)(
|
|
"group flex h-[52px] w-full items-center gap-1 rounded-xl p-2 text-left transition-colors duration-200",
|
|
l
|
|
? "cursor-not-allowed opacity-50"
|
|
: "data-[selected=true]:hover:bg-canvas-controls-active hover:bg-canvas-controls-hover data-[selected=true]:bg-canvas-controls-active cursor-pointer",
|
|
),
|
|
children: [
|
|
(0, t.jsx)("div", {
|
|
className:
|
|
"bg-bg-surface-secondary flex h-[34px] w-[34px] shrink-0 items-center justify-center rounded-lg",
|
|
children: (0, t.jsx)(g.ModelSelectIcon, {
|
|
icon: v,
|
|
className: "text-fg-muted size-4",
|
|
imageClassName: "size-4",
|
|
}),
|
|
}),
|
|
(0, t.jsx)("div", {
|
|
className: "h-full flex-1 overflow-hidden pr-1",
|
|
children: (0, t.jsxs)("div", {
|
|
className: (0, h.cn)(
|
|
"flex h-full flex-col justify-start transition-transform duration-200",
|
|
b &&
|
|
"translate-y-[8px] group-hover:translate-y-0 group-data-[selected=true]:translate-y-0",
|
|
),
|
|
children: [
|
|
(0, t.jsxs)("div", {
|
|
className:
|
|
"flex w-full min-w-0 items-center justify-between gap-2",
|
|
children: [
|
|
(0, t.jsxs)("div", {
|
|
className: "flex min-w-0 items-center gap-1",
|
|
children: [
|
|
(0, t.jsx)("span", {
|
|
className:
|
|
"text-fg-default truncate text-sm font-medium leading-5",
|
|
children: e.modelName,
|
|
}),
|
|
e.vip &&
|
|
(0, t.jsx)(d.Icons.vipModel, {
|
|
className: "size-3.5 shrink-0 text-[#FFC65D]",
|
|
}),
|
|
e.labels?.map((e) =>
|
|
(0, t.jsx)(
|
|
"span",
|
|
{
|
|
className:
|
|
"text-fg-brand border-fg-brand/20 bg-fg-brand/5 shrink-0 whitespace-nowrap rounded border px-1.5 text-[10px] font-semibold",
|
|
children: e,
|
|
},
|
|
e,
|
|
),
|
|
),
|
|
p && (0, t.jsx)(o.BenefitLabel, { label: p }),
|
|
],
|
|
}),
|
|
e.estimatedTime &&
|
|
(0, t.jsx)("span", {
|
|
className:
|
|
"bg-bg-surface-secondary text-fg-muted shrink-0 rounded px-1.5 text-xs",
|
|
children: e.estimatedTime,
|
|
}),
|
|
],
|
|
}),
|
|
b &&
|
|
(0, t.jsx)("p", {
|
|
className:
|
|
"text-fg-muted line-clamp-2 text-xs leading-4 opacity-0 transition-opacity duration-200 group-hover:opacity-100 group-data-[selected=true]:opacity-100",
|
|
children: e.description,
|
|
}),
|
|
],
|
|
}),
|
|
}),
|
|
],
|
|
}),
|
|
M = (0, r.useCallback)(() => {
|
|
(0, i.openVipModel)({ intent: "purchase_vip" });
|
|
}, []);
|
|
return l
|
|
? (0, t.jsxs)(t.Fragment, {
|
|
children: [
|
|
(0, t.jsx)("span", {
|
|
className: "block w-full",
|
|
onMouseEnter: k,
|
|
onMouseMove: S,
|
|
onMouseLeave: C,
|
|
children: P,
|
|
}),
|
|
y.visible &&
|
|
"u" > typeof document &&
|
|
(0, a.createPortal)(
|
|
(0, t.jsx)("div", {
|
|
role: "tooltip",
|
|
className:
|
|
"pointer-events-none fixed whitespace-nowrap rounded-lg border text-xs leading-normal",
|
|
style: {
|
|
left: y.x + 12,
|
|
top: y.y + 12,
|
|
padding: "4px 8px",
|
|
backgroundColor: "#000000",
|
|
color: "#F7F7F7",
|
|
border: "0.5px solid #363636",
|
|
boxShadow:
|
|
"0px 8px 16px rgba(0,0,0,0.18), 0px 2px 4px rgba(0,0,0,0.2)",
|
|
zIndex: 710,
|
|
},
|
|
children: u || "当前连入的参数不支持该模型",
|
|
}),
|
|
document.body,
|
|
),
|
|
],
|
|
})
|
|
: m
|
|
? (0, t.jsxs)(c.HoverCard, {
|
|
position: "top",
|
|
offset: 2,
|
|
openDelay: 60,
|
|
closeDelay: 500,
|
|
withArrow: !0,
|
|
withinPortal: !0,
|
|
children: [
|
|
(0, t.jsx)(c.HoverCard.Target, {
|
|
children: (0, t.jsx)("span", {
|
|
className: "block w-full",
|
|
children: P,
|
|
}),
|
|
}),
|
|
(0, t.jsx)(c.HoverCard.Dropdown, {
|
|
"data-popover-safe": !0,
|
|
style: x,
|
|
children: (0, t.jsx)(n.ActivityBenefitTooltip, {
|
|
match: m,
|
|
onUpgrade: M,
|
|
}),
|
|
}),
|
|
],
|
|
})
|
|
: P;
|
|
});
|
|
function y({
|
|
type: e,
|
|
value: a,
|
|
onChange: n,
|
|
className: o,
|
|
filterKeys: i,
|
|
disabledModelKeys: c,
|
|
disabled: x,
|
|
disabledReason: y,
|
|
}) {
|
|
let w = (0, f.useCanvasThemeStore)((e) => e.theme),
|
|
[k, S] = (0, r.useState)(!1),
|
|
C = (0, r.useRef)(null),
|
|
P = (0, r.useRef)(null),
|
|
M = (0, v.usePopoverManager)(),
|
|
_ = (0, r.useId)(),
|
|
T = (0, m.useGlobalStore)((t) => t.support?.[e] ?? null),
|
|
I = (0, r.useMemo)(() => {
|
|
if (!T) return null;
|
|
let e = T;
|
|
return (
|
|
i?.length && (e = e.filter((e) => i.includes(e.modelKey))),
|
|
c?.size &&
|
|
(e = [...e].sort(
|
|
(e, t) => !!c.has(e.modelKey) - !!c.has(t.modelKey),
|
|
)),
|
|
e
|
|
);
|
|
}, [T, i, c]),
|
|
j = (0, r.useMemo)(() => I?.map((e) => e.modelKey) ?? null, [I]),
|
|
N = (0, l.useModelBenefitMap)(j),
|
|
B = (0, s.useActivityBenefitMatchMap)(j),
|
|
E = (0, r.useMemo)(
|
|
() => (I && a ? (I.find((e) => e.modelKey === a) ?? null) : null),
|
|
[I, a],
|
|
),
|
|
D = E?.modelName ?? "选择模型",
|
|
A = !!E?.vip,
|
|
R = E?.icon,
|
|
L = (0, r.useMemo)(
|
|
() =>
|
|
"text" === e || "scriptText" === e || "audio" === e
|
|
? "min-w-0 shrink"
|
|
: "video" === e || "storyboardVideo" === e
|
|
? "min-w-[128px] shrink-[2] max-w-[240px]"
|
|
: "min-w-[128px] shrink-[2] max-w-[180px]",
|
|
[e],
|
|
),
|
|
O = (0, r.useRef)(n);
|
|
O.current = n;
|
|
let H = (0, r.useCallback)((e) => {
|
|
O.current?.(e), S(!1);
|
|
}, []);
|
|
return (
|
|
(0, r.useEffect)(() => {
|
|
if (M)
|
|
return M.register({
|
|
id: _,
|
|
targetRef: C,
|
|
dropdownRef: P,
|
|
close: () => S(!1),
|
|
});
|
|
}, [M, _]),
|
|
(0, r.useEffect)(() => {
|
|
x && S(!1);
|
|
}, [x]),
|
|
(0, r.useEffect)(() => {
|
|
if (!k) return;
|
|
let e = requestAnimationFrame(() => {
|
|
let e = P.current;
|
|
if (!e) return;
|
|
let t = e.querySelector('[data-selected="true"]');
|
|
t && t.scrollIntoView({ block: "center", behavior: "auto" });
|
|
});
|
|
return () => cancelAnimationFrame(e);
|
|
}, [k, a, I?.length]),
|
|
(0, t.jsxs)(u.Popover, {
|
|
opened: !x && k,
|
|
onChange: x ? () => void 0 : S,
|
|
position: "bottom-start",
|
|
offset: 0,
|
|
shadow: "md",
|
|
radius: 16,
|
|
withinPortal: !0,
|
|
closeOnClickOutside: !1,
|
|
children: [
|
|
(0, t.jsx)(u.Popover.Target, {
|
|
children: (0, t.jsx)(p.Tooltip, {
|
|
label: y ?? "当前不可切换模型",
|
|
disabled: !x,
|
|
position: "top",
|
|
openDelay: 300,
|
|
children: (0, t.jsxs)("button", {
|
|
type: "button",
|
|
ref: C,
|
|
disabled: x,
|
|
onClick: () => {
|
|
x || (M?.closeAll(_), S((e) => !e));
|
|
},
|
|
className: (0, h.cn)(
|
|
"flex h-8 w-auto items-center justify-between gap-1 rounded-lg bg-transparent px-2 py-1 transition-colors",
|
|
L,
|
|
x
|
|
? "cursor-not-allowed opacity-50"
|
|
: "hover:bg-btn-ghost-hover cursor-pointer",
|
|
!x && k && "bg-btn-ghost-hover",
|
|
o,
|
|
),
|
|
children: [
|
|
(0, t.jsxs)("div", {
|
|
className: "flex min-w-0 items-center gap-1",
|
|
children: [
|
|
(0, t.jsx)(g.ModelSelectIcon, {
|
|
icon: R,
|
|
className: "text-fg-muted size-4",
|
|
imageClassName: "size-4",
|
|
}),
|
|
(0, t.jsx)("span", {
|
|
className: "text-fg-default truncate text-[13px]",
|
|
children: D,
|
|
}),
|
|
A &&
|
|
(0, t.jsx)(d.Icons.vipModel, {
|
|
className: "size-3.5 shrink-0 text-[#FFC65D]",
|
|
}),
|
|
],
|
|
}),
|
|
(0, t.jsx)(d.Icons.lucideChevronDown, {
|
|
className: (0, h.cn)(
|
|
"text-fg-muted size-3.5 shrink-0 transition-transform",
|
|
k && "rotate-180",
|
|
),
|
|
}),
|
|
],
|
|
}),
|
|
}),
|
|
}),
|
|
(0, t.jsx)(u.Popover.Dropdown, {
|
|
ref: P,
|
|
className: `bg-panel-background/95 border-card-border border-hair! p-1! rounded-2xl backdrop-blur-[32px] ${"light" === w ? "canvas-light" : ""}`,
|
|
children: (0, t.jsx)("div", {
|
|
className:
|
|
"tiny-scrollbar max-h-[400px] w-[360px] overflow-y-auto",
|
|
children:
|
|
I && I.length > 0
|
|
? (0, t.jsx)("div", {
|
|
className: "flex flex-col gap-1",
|
|
children: I.map((e) =>
|
|
(0, t.jsx)(
|
|
b,
|
|
{
|
|
model: e,
|
|
isSelected: e.modelKey === a,
|
|
disabled: c?.has(e.modelKey),
|
|
disabledReason: c?.get(e.modelKey),
|
|
benefitLabel: N.get(e.modelKey),
|
|
activityBenefitMatch: B.get(e.modelKey),
|
|
onSelect: H,
|
|
},
|
|
e.modelKey,
|
|
),
|
|
),
|
|
})
|
|
: (0, t.jsx)("div", {
|
|
className:
|
|
"text-fg-muted px-3 py-4 text-center text-sm",
|
|
children: "暂无可用模型",
|
|
}),
|
|
}),
|
|
}),
|
|
],
|
|
})
|
|
);
|
|
}
|
|
e.s(["default", () => y]);
|
|
};
|
|
|
|
export default moduleFactory;
|