// 官方 QZMusic_v3 插件类型系统（支持 PC/Android 原版 webpack bundle 格式）

export interface PluginInfo {
    id: string;
    name: string;
    description?: string;
    version?: string;
    author?: string;
}

export interface PluginQuality {
    id: string;
    name: string;
    ui: string;
}

export interface PluginEnv {
    key: string;
    name: string;
    description?: string;
}

export interface PluginExt {
    name: string;
    description?: string;
    entry?: string;
    type?: string;
}

export interface PluginInfoModule {
    info: PluginInfo;
    quality?: PluginQuality[];
    env?: PluginEnv[];
    ext?: PluginExt[];
    supportFunc?: string[];
}

export interface PluginSearchItem {
    songmid?: string;
    id?: string;
    name?: string;
    singer?: string;
    artist?: string;
    albumName?: string;
    album?: string;
    albumId?: string;
    interval?: number;
    duration?: number;
    img?: string;
    m_img?: string;
    s_img?: string;
    picUrl?: string;
    source?: string;
    types?: { [qualityId: string]: string | number };
    quality?: string[];
    [key: string]: any;
}

export interface PluginSearchResult {
    list: PluginSearchItem[];
    total?: number;
    songCount?: number;
    allPage?: number;
    limit?: number;
    source?: string;
    error?: string;
    [key: string]: any;
}

export interface PluginModule {
    pluginInfo: PluginInfoModule;
    musicSearch?: {
        search: (query: string, page: number, limit: number) => Promise<PluginSearchResult>;
    } | ((query: string, page: number, limit: number) => Promise<PluginSearchResult>);
    getUrl?: (songId: string, quality: string) => Promise<string | { url: string; [k: string]: any } | null>;
    getLyric?: (songId: string) => Promise<string | object | ArrayBuffer | null>;
    songList?: any;
    hotSearch?: any;
    album?: any;
    singer?: any;
    musicInfo?: any;
    musicDetail?: any;
    getPic?: any;
    getPicture?: any;
    leaderboard?: any;
    tipSearch?: any;
    userPlaylist?: any;
    [key: string]: any;
}

export interface PluginFullInfo extends PluginInfo {
    quality?: PluginQuality[];
    env?: PluginEnv[];
    ext?: PluginExt[];
    supportFunc?: string[];
    source?: 'built-in' | 'user' | string;
}

export interface UrlResponse {
    success: boolean;
    url?: string;
    error?: string;
    pluginId?: string;
}
