import { Image, Tag } from 'antd';
import { AudioOutlined, CheckCircleOutlined, ExclamationCircleOutlined, FileTextOutlined, FileUnknownOutlined, FileWordOutlined, InfoCircleOutlined, LinkOutlined, PaperClipOutlined, PictureOutlined, SmileOutlined, VideoCameraOutlined, WarningOutlined, YoutubeOutlined } from '@ant-design/icons'

const EmojiCategory = {
    // 人脸表情
    '微笑': { name: '微笑' },
    '撇嘴': { name: '撇嘴' },
    '色': { name: '色' },
    '发呆': { name: '发呆' },
    '得意': { name: '得意' },
    '流泪': { name: '流泪' },
    '害羞': { name: '害羞' },
    '闭嘴': { name: '闭嘴' },
    '睡': { name: '睡' },
    '大哭': { name: '大哭' },
    '尴尬': { name: '尴尬' },
    '发怒': { name: '发怒' },
    '调皮': { name: '调皮' },
    '呲牙': { name: '呲牙' },
    '惊讶': { name: '惊讶' },
    '难过': { name: '难过' },
    '囧': { name: '囧' },
    '抓狂': { name: '抓狂' },
    '吐': { name: '吐' },
    '偷笑': { name: '偷笑' },
    '愉快': { name: '愉快' },
    '白眼': { name: '白眼' },
    '傲慢': { name: '傲慢' },
    '困': { name: '困' },
    '惊恐': { name: '惊恐' },
    '憨笑': { name: '憨笑' },
    '悠闲': { name: '悠闲' },
    '咒骂': { name: '咒骂' },
    '疑问': { name: '疑问' },
    '嘘': { name: '嘘' },
    '晕': { name: '晕' },
    '衰': { name: '衰' },
    '骷髅': { name: '骷髅' },
    '敲打': { name: '敲打' },
    '再见': { name: '再见' },
    '擦汗': { name: '擦汗' },
    '抠鼻': { name: '抠鼻' },
    '鼓掌': { name: '鼓掌' },
    '坏笑': { name: '坏笑' },
    '右哼哼': { name: '右哼哼' },
    '鄙视': { name: '鄙视' },
    '委屈': { name: '委屈' },
    '快哭了': { name: '快哭了' },
    '阴险': { name: '阴险' },
    '亲亲': { name: '亲亲' },
    '可怜': { name: '可怜' },
    '笑脸': { name: '笑脸' },
    '生病': { name: '生病' },
    '脸红': { name: '脸红' },
    '破涕为笑': { name: '破涕为笑' },
    '恐惧': { name: '恐惧' },
    '失望': { name: '失望' },
    '无语': { name: '无语' },
    '嘿哈': { name: '嘿哈' },
    '捂脸': { name: '捂脸' },
    '机智': { name: '机智' },
    '皱眉': { name: '皱眉' },
    '耶': { name: '耶' },
    '吃瓜': { name: '吃瓜' },
    '加油': { name: '加油' },

    '汗': { name: '汗' },
    '天啊': { name: '天啊' },
    'Emm': { name: 'Emm' },
    '社会社会': { name: '社会社会' },
    '旺柴': { name: '旺柴' },
    '好的': { name: '好的' },
    '打脸': { name: '打脸' },
    '哇': { name: '哇' },
    '翻白眼': { name: '翻白眼' },
    '666': { name: '666' },
    '让我看看': { name: '让我看看' },
    '叹气': { name: '叹气' },
    '苦涩': { name: '苦涩' },
    '裂开': { name: '裂开' },
    '奸笑': { name: '奸笑' },

    // 手势表情
    '握手': { name: '握手' },
    '胜利': { name: '胜利' },
    '抱拳': { name: '抱拳' },
    '勾引': { name: '勾引' },
    '拳头': { name: '拳头' },
    'OK': { name: 'OK' },
    '合十': { name: '合十' },
    '强': { name: '强' },
    '拥抱': { name: '拥抱' },
    '弱': { name: '弱' },


    // 动物表情
    '猪头': { name: '猪头' },
    '跳跳': { name: '跳跳' },
    '发抖': { name: '发抖' },
    '转圈': { name: '转圈' },

    // 祝福表情
    '庆祝': { name: '庆祝' },
    '礼物': { name: '礼物' },
    '红包': { name: '红包' },
    '發': { name: '發' },
    '福': { name: '福' },
    '烟花': { name: '烟花' },
    '爆竹': { name: '爆竹' },

    // 其他表情
    '嘴唇': { name: '嘴唇' },
    '爱心': { name: '爱心' },
    '心碎': { name: '心碎' },
    '啤酒': { name: '啤酒' },
    '咖啡': { name: '咖啡' },
    '蛋糕': { name: '蛋糕' },
    '凋谢': { name: '凋谢' },
    '菜刀': { name: '菜刀' },
    '炸弹': { name: '炸弹' },
    '便便': { name: '便便' },
    '太阳': { name: '太阳' },
    '月亮': { name: '月亮' },
    '玫瑰': { name: '玫瑰' }
};
function replaceEmojis(text) {
    // 修正后的正则表达式，确保匹配中文括号内容
    return text.replace(/\[([\u4e00-\u9fa5a-zA-Z0-9_]+)\]/g, (match, emojiName) => {
        const emoji = EmojiCategory[emojiName];
        return emoji ? `<img src="https://zx-web-dev-01.oss-cn-hangzhou.aliyuncs.com/apk/emo/${emojiName}.png" style="width:20px" alt="${emojiName}" class="emoji" />` : match;
    });
}
export const obj = {
    "text": <div style={{ color: '#059669', backgroundColor: '#d1fae5', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><FileTextOutlined />文本</div>,
    "voice": <div style={{ color: '#0e7490', backgroundColor: '#a5f3fc', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><AudioOutlined />语音</div>,
    "file": <div style={{ color: '#ea580c', backgroundColor: '#fed7aa', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><FileWordOutlined />文件</div>,
    "img": <div style={{ color: '#0891b2', backgroundColor: '#cffafe', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><PictureOutlined />图片</div>,
    "video": <div style={{ color: '#dc2626', backgroundColor: '#fecaca', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><YoutubeOutlined />视频</div>,
    "gif": <div style={{ color: '#701a75', backgroundColor: '#f5d0fe', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><SmileOutlined />动画表情</div>,
    "link": <div style={{ color: '#0284c7', backgroundColor: '#e0f2fe', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><LinkOutlined />图文链接</div>,
    "miniProgram": <div style={{ color: '#4338ca', backgroundColor: '#c7d2fe', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><PaperClipOutlined />小程序</div>,
    "videoApp": <div style={{ color: '#0d9488', backgroundColor: '#ccfbf1', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><VideoCameraOutlined />视频号</div>,
    "Unknown": <div style={{ color: '#4b5563', backgroundColor: '#e5e7eb', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><FileUnknownOutlined />未知</div>,
}
const tableConfig: any = () => {
    let arr: any = [
        {
            title: 'ID',
            dataIndex: 'id',
            key: 'id',
            width: 50,
            align: 'center',
        },
        {
            title: '企微号',
            dataIndex: 'corpUserVO',
            key: 'corpUserVO',
            width: 100,
            align: 'center',
            ellipsis: true,
            render: (a: any) => {
                return a?.name || '--'
            }
        },
        {
            title: '发送人昵称（群成员/私聊用户）',
            align: 'center',
            dataIndex: 'senderName',
            key: 'senderName',
            width: 250,
            ellipsis: true,
            render: (a: any) => {
                return a || "--"
            }
        },
        {
            title: '风险等级',
            dataIndex: 'riskLevel',
            key: 'riskLevel',
            align: 'center',
            width: 100,
            render: (a: any, b: any) => {
                return a ? [
                    <div style={{ color: '#0284c7', backgroundColor: '#e0f2fe', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><CheckCircleOutlined /> 无风险</div>,
                    <div style={{ color: '#16a34a', backgroundColor: '#dcfce7', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><InfoCircleOutlined /> 低风险</div>,
                    <div style={{ color: '#d97706', backgroundColor: '#fef3c7', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><ExclamationCircleOutlined />中风险</div>,
                    <div style={{ color: '#dc2626', backgroundColor: '#fee2e2', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><WarningOutlined /> 高风险</div>
                ][a] : <div style={{ color: '#0284c7', backgroundColor: '#e0f2fe', padding: '1px 6px', fontSize: 12, borderRadius: '15px', display: 'inline-flex', alignItems: 'center', gap: 2 }}><CheckCircleOutlined /> 无风险</div>
            }
        },
        {
            title: '风险提示词',
            dataIndex: 'riskMessage',
            key: 'riskMessage',
            align: 'center',
            width: 100,
            ellipsis: true,
            render: (a: any, b: any) => {
                return a ? <span style={{ color: '#e62929' }}>{a}</span> : "--"
            }
        },
        {
            title: '聊天类型',
            dataIndex: 'chatType',
            key: 'chatType',
            align: 'center',
            ellipsis: true,
            width: 70,
            render: (a: any, b: any) => {
                return a === 1 ? <Tag color="#f50">群聊</Tag> : <Tag color="#108ee9">私聊</Tag>
            }
        },
        {
            title: '消息类型',
            dataIndex: 'msgType',
            key: 'msgType',
            align: 'center',
            width: 100,
            render: (a: any, b: any) => {
                return a? obj[a]:"--"
            }
        },
        {
            title: '消息内容',
            dataIndex: 'messageContent',
            key: 'messageContent',
            ellipsis: true,
            render: (a: any, b: any) => {
                return a && !b.msgType? <div dangerouslySetInnerHTML={{ __html: replaceEmojis(a) }} style={{ display: 'flex', fontWeight: 'bold' }}></div> :b?.msgType === "text" || b?.msgType === "voice" ? <div dangerouslySetInnerHTML={{ __html: replaceEmojis(a) }} style={{ display: 'flex', justifyContent: 'left' }}></div> : <Image src={ b?.imgUrl} height={20}  />
            }
        },
        {
            title: '群名称',
            dataIndex: 'chatName',
            key: 'chatName',
            width: 150,
            ellipsis: true,
            render: (a: any, b: any) => {
                return a || "--"
            }
        },
        {
            title: 'uuid',
            dataIndex: 'uuid',
            key: 'uuid',
            width: 140,
            align: 'center',
            ellipsis: true
        },
        {
            title: '发送时间',
            align: 'center',
            dataIndex: 'messageTime',
            key: 'messageTime',
            ellipsis: true,
            width: 140,
        },


    ]
    return arr
}

export default tableConfig