export type SeedreamLayerBox = [number, number, number, number]; export type SeedreamLayerSource = "provider" | "upload" | "library" | "seedream-edit"; export type SeedreamCompositionLayer = { id: string; assetId: string; name: string; description?: string; visible: boolean; box: SeedreamLayerBox; rotation: number; source: SeedreamLayerSource; editJobId?: string; originalAssetId?: string; }; export type SeedreamLayerComposition = { jobId: string; baseAssetId: string; baseVisible: boolean; layers: SeedreamCompositionLayer[]; version: number; createdAt: string; updatedAt: string; }; export type SeedreamLayerDraft = Pick; export function hasCompleteSeedreamLayerMetadata(records: unknown[], outputCount: number): boolean { if (!Number.isInteger(outputCount) || outputCount < 2 || records.length !== outputCount) return false; const indices = records.map((value) => { if (!value || typeof value !== "object" || Array.isArray(value)) return undefined; const raw = (value as Record).z_index; const index = typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() ? Number(raw) : Number.NaN; return Number.isInteger(index) && index >= 0 ? index : undefined; }); if (indices.some((index) => index === undefined)) return false; const numericIndices = indices as number[]; return numericIndices.includes(0) && new Set(numericIndices).size === numericIndices.length; }