import { post } from './request';
import { ApiResponse } from './common';
import { Character } from './video_flow';

// 创建剧集的数据类型
export interface CreateScriptEpisodeRequest {
  title?: string;
  script_id?: number;
  characters?: {
    characters?: Array<{
      name?: string;
      desc?: string;
    }>;
  };
  summary?: string;
  atmosphere?: string;
  scene?: string;
  status?: number;
  task_description?: string;
  creator_name?: string;
  cate_tags?: {
    tags?: string[];
  };
  episode_sort?: number;
}

// 更新剧集的数据类型
export interface UpdateScriptEpisodeRequest {
  id: number;
  title?: string;
  script_id?: number;
  status?: number;
  summary?: string;
  atmosphere?: string;
  scene?: string;
  task_description?: string;
  creator_name?: string;
  cate_tags?: {
    tags?: string[];
  };
  characters?: Character[];
  episode_sort?: number;
  video_url?: string;
}

// 获取剧集详情请求数据类型
export interface detailScriptEpisodeRequest {
  id: number;
}

// 创建剧集响应数据类型
export interface ScriptEpisode {
  id: number;
  title: string;
  script_id: number;
  status: number;
  episode_sort: number;
  creator_name: string;
  created_at: string;
  updated_at?: string;
  video_url?: string;
}

// 新-获取剧集列表
interface ListMovieProjectsParams {
  user_id: string;
  page: number;
  per_page: number;
}

interface MovieProject {
  project_id: string;
  name: string;
  status: string;
  step: string;
  final_video_url: string;
  final_simple_video_url: string;
  last_message: string;
  updated_at: string;
  created_at: string;
}

interface ListMovieProjectsResponse {
  movie_projects: MovieProject[];
  total: number;
  page: number;
  per_page: number;
  total_pages: number;
}

export const getScriptEpisodeListNew = async (params: ListMovieProjectsParams): Promise<ApiResponse<ListMovieProjectsResponse>> => {
  return post<ApiResponse<ListMovieProjectsResponse>>('/movie/list_movie_projects', params);
};

// 获取剧集详情
export const detailScriptEpisode = async (data: detailScriptEpisodeRequest): Promise<ApiResponse<ScriptEpisode>> => {
  return post<ApiResponse<ScriptEpisode>>('/script_episode/detail', data);
}; 