export interface Chat {
    id: number;
    org_id: string;
    uid: string;
    oid: string;
    eid: string;
    type: string;
    title: string;
    app_id: string;
    tag: string;
    msg_id: number;
    ext: string;
    exit_msg_id: number;
    is_exited: boolean;
    dnd: number;
    is_top: boolean;
    label: string;
    join_msg_id: number;
    last_read_msg_id: number;
    biz_id: string;
    last_msg_sender: string;
    last_msg_content: string;
    last_msg_type: string;
    business_data: {
        model_name: string;
        obj_id: string;
        detail_name: string;
    };
    is_finish: boolean;
    is_deleted: boolean;
    is_remove: boolean;
    member_type: number;
    ref_id: number;
    unread_msg_count: number;
    at_me: boolean;
    at_all: boolean;
    last_login_oid: string;
    owner_oid: string;
    owner_eid: string;
    is_act: true;
    last_read_id: number;
    msg_count_after_leave: number;
    create_time: number;
    update_time: number;
    last_msg_ts: number;
    members_updated: number;
    user_updated: number;
    chat_id: number;
}

export interface Message {
    chat_id: number;
    oid: string;
    eid: string;
    id: number;
    ts: number;
    type: string;
    msg: string;
    total_read_count: number;
    read_count: number;
    like_count: number;
    ref_id: number;
    at_id: string;
    is_read: boolean;
    like: boolean;
    create_time: number;
    update_time: number;
    status: number;
    url: string;
    is_open: boolean;
}

export interface NotifyMessage {
    chat_type: string;
    chat_id: number;
    eid: string;
    ts: number;
    msg_type: string;
    msg: string;
}

export interface Member {
    chat_id: number;
    oid: string;
    eid: string;
    type: number;
    is_exited: boolean;
    is_remove: boolean;
    is_top: boolean;
    label: string;
    create_time: number;
    update_time: number;
    nick_name: string;
}

/**
 * 消息类型
 * @param text 文本
 * @param file 文件
 * @param image 图片
 * @param voice 语音
 * @param notify 通知类型
 * @param text.notice 文本消息:公告文本
 * @param video 视频
 * @param url 卡片消息
 * @param forward 转发消息
 * @param quote 引用消息
 * @param comment.forward 转发评论消息
 * @param time 时间行
 */
export type ChatMessageType =
    | "text"
    | "file"
    | "image"
    | "voice"
    | "notify"
    | "text.notice"
    | "video"
    | "url"
    | "forward"
    | "quote"
    | "comment.forward"
    | "time";

export type ChatInputBoxData = { key: string } & (
    | { at_id: string; type: "text"; body: TextMessageBody }
    | { type: "image"; body: ImageMessageBody }
    | { type: "file"; body: FileMessageBody }
    | { type: "video"; body: VideoMessageBody }
    | { at_id: string; type: "quote"; body: QuoteMessageBody }
    | { at_id: string; type: "tm-at-member"; body: TextMessageBody }
);

export type TextMessageBody = {
    text: string;
};

export type FileMessageBody = {
    name: string;
    url: string; // 生消息是本地path,熟消息是文件url_id
    size: number; // number, 可选,文件大小:单位-字节
    remark: string;
    isNeedUploaded?: boolean; // pc客户端自定义属性(只有生消息的消息体才有该属性, 值为false时不需要上传, true和undefined时需要上传)
    source?: {
        source_type: number; // 来源类型(若为团队小站文件,则来源类型为团队小站文件)
        source_id: number; // 来源id(若为团队小站文件,此处为团队工作站id)
        source_name: string; // 来源名称(若为团队小站文件,此处传入团队小站名称)
        source_icon: string; // 来源图标(若为团队小站文件,此处传入团队icon的url)
        extra?: { [prop: string]: any }; // 附加信息
    };
};

export type ImageMessageBody = {
    name: string;
    url: string;
    size: number;
    w: number;
    h: number;
    thumbnail?: string; // 缩略图地址
    preview?: string; // 预览图地址
    remark: string;
};

export type VoiceMessageBody = {
    name: string;
    url: string;
    size: number;
    duration: number; // 语音时间:单位-ms
};

// 第一顺序 default_text 第二顺序 operator_text、receiver_text
export type NotifyMessageBody = {
    operator_id: string;
    receiver_ids: string[];
    default_text: string; // 默认文本
    operator_text: string; // 操作人文本
    receiver_text: string; // 处理人文本
};

export type TextNoticeMessageBody = {
    title: string;
    text: string;
    is_at_all: boolean; // 是否@全部人
};

export type VideoMessageBody = {
    name: string;
    url: string; // 生消息是本地path,熟消息是文件url_id
    size: number;
    cover?: string;
    duration: number;
    w: number;
    h: number;
    isNeedUploaded?: boolean; // pc客户端自定义属性(只有生消息的消息体才有该属性, 值为false时不需要上传, true和undefined时需要上传)
};

export type UrlMessageBody = {
    title: string;
    icon: string;
    url: string;
    desc: string;
    source?: {
        source_type: number; // 来源类型(若为团队小站文件,则来源类型为团队小站文件)
        source_id: number; // 来源id(若为团队小站文件,此处为团队工作站id)
        source_name: string; // 来源名称(若为团队小站文件,此处传入团队小站名称)
        source_icon: string; // 来源图标(若为团队小站文件,此处传入团队icon的url)
        extra?: { [prop: string]: any }; // 附加信息
    };
};

export type ForwardMessageBody = {
    snap: string;
    chat_type: string; // 会话类型
    chat_id: number; // 会话id
    msg_ids: number[]; // 消息id集合
};

export type QuoteMessageBody = {
    text: string;
    quote_text: string; // JSON字符串
    quote_msg_type: string;
    quote_eid: string;
    quote_msg_id: number; // 引用id
};

export type CommentForwardMessageBody = {
    snap: string;
    channel_id: number; // 团队工作站id
    topic_id: number; // 主题id
    comment_ids: number[]; // 评论id集合
};

// export type SpecifiedChatRecordMsg = SpecifiedChatRecord & {
//     message?: Message | undefined | null,
//     messageBody?: {
//         "name"?: string,    // "高达.txt",
//         "url"?: string,    // "9a5bd43db73681f6a90b9e717d8698c2",
//         "size"?: number,    // 4,
//         "remark"?: string,    // "C:\\Users\\Administrator\\Desktop\\高达.txt"
//     }
// };

// 客服
export interface CsUser {
    id: number;
    oid: string;
    eid: string;
    is_deleted: boolean;
    delete_time: number;
    delete_oid: string;
    delete_eid: string;
    service_id: number;
    type: number;
    name: string;
    mobile: string;
    email: string;
    description: string;
    create_time: number;
    update_time: number;
    chat_count: number;
    status: number;
}