import { mockDelay } from "./mockAi";
import { newId } from "./id";

export type GeneratedImage = {
  id: string;
  url: string;
  prompt: string;
};

/** mock 產圖：用 dicebear 當可顯示縮圖 */
export async function mockGenerateImage(prompt: string): Promise<GeneratedImage> {
  await mockDelay(700);
  const p = prompt.trim() || "threads post visual";
  const seed = encodeURIComponent(p.slice(0, 48) || "harbor");
  return {
    id: newId("img"),
    url: `https://api.dicebear.com/9.x/shapes/svg?seed=${seed}&backgroundColor=20b49c,69d4c5,ff7b73,b6f3e4,ffd5dc`,
    prompt: p,
  };
}
