import type { InferResponseType, InferRequestType } from 'hono/client';
import { fileClient } from '../api/fileClient';

// 文件列表响应类型
export type FileListResponse = InferResponseType<typeof fileClient.index.$get, 200>;

// 单个文件类型
export type FileType = FileListResponse['data'][0];

// 文件上传策略类型
export type UploadPolicyResponse = InferResponseType<typeof fileClient['upload-policy']['$post'], 200>;

// 多部分上传策略类型
export type MultipartUploadPolicyResponse = InferResponseType<typeof fileClient['multipart-policy']['$post'], 200>;

// 更新文件请求类型
export type UpdateFileRequest = InferRequestType<typeof fileClient[':id']['$put']>['json'];

// 文件查询参数
export interface FileQueryParams {
  page?: number;
  pageSize?: number;
  keyword?: string;
}

// 文件上传参数
export interface FileUploadParams {
  path: string;
  name: string;
  type?: string;
  size?: number;
}

// 多部分上传参数
export interface MultipartUploadParams {
  totalSize: number;
  partSize: number;
  fileKey: string;
  type?: string;
  name: string;
}

// 文件操作状态
export interface FileOperationState {
  isLoading: boolean;
  isError: boolean;
  error?: Error;
}

// 文件预览选项
export interface FilePreviewOptions {
  size?: 'small' | 'medium' | 'large';
  showActions?: boolean;
  showInfo?: boolean;
}

// 文件选择器状态
export interface FileSelectorState {
  selectedFiles: FileType[];
  isOpen: boolean;
  searchText: string;
  filterType: string;
}

// 文件管理状态
export interface FileManagementState {
  files: FileType[];
  pagination: {
    current: number;
    pageSize: number;
    total: number;
  };
  searchText: string;
  isLoading: boolean;
  isUploadModalOpen: boolean;
  isEditModalOpen: boolean;
  editingFile: FileType | null;
}