package com.cmvr.test.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum ActionEnum {
    // 平台控制类
    STOPPED("NONE", "STOP", "强制终止"),
    PAUSED("NONE", "PAUSED", "暂停"),
    RESUME("NONE", "RESUME", "继续"),
    START("NONE", "START", "开始"),
    SUB_START("NONE", "SUB_START", "循环开始（子流程开始）"),
    END("NONE", "END", "结束"),
    START_LOOP("NONE", "START_LOOP", "开始循环"),
    STOP_LOOP("NONE", "STOP_LOOP", "结束循环"),
    BRANCH("NONE", "BRANCH", "分支"),
    SUB_END("NONE", "SUB_END", "子流程结束"),
    SLEEP("NONE", "SLEEP", "延迟节点"),
    HTTP("NONE", "HTTP", "HTTP调用"),
    CODE("NONE", "CODE", "代码执行"),
    GET_CURRENT_OBJECT("NONE", "GET_CURRENT_OBJECT", "获取当前循环对象"),
    // AI评估
    AI_EVALUATION_PRE("AE", "AI_EVALUATION_PRE", "AI评估预处理"),
    // AI评估
    AI_EVALUATION_EXECUTE("AE", "AI_EVALUATION_END", "AI评估执行"),

    // 系统行为
    NONE("NONE", "NONE", "无操作"),

    // 设备行为
    // ---------------相机---------------
    CAMERA_START("EDGE", "CAMERA_START", "启动相机"),
    CAMERA_STOP("EDGE", "CAMERA_STOP", "停止相机"),
    CAMERA_GETRGBIMAGE("EDGE", "CAMERA_GETRGBIMAGE", "获取RGB图像"),
    CAMERA_RECORDING_START("EDGE", "CAMERA_RECORDING_START", "开始录像"),
    CAMERA_RECORDING_STOP("EDGE", "CAMERA_RECORDING_STOP", "结束录像"),

    // ---------------麦克风---------------
    MICROPHONE_START("EDGE", "MICROPHONE_START", "启动麦克风"),
    MICROPHONE_STOP("EDGE", "MICROPHONE_STOP", "停止麦克风"),

    // ---------------扬声器（人工嘴）---------------
    // ---------------语料---------------
    VI_CORPUS_WAKE("EDGE", "VI_CORPUS_WAKE", "唤醒语料处理"),
    VI_CORPUS_SINGLE("EDGE", "VI_CORPUS_SINGLE", "测试语料-单次对话语料处理"),
    VI_CORPUS_CONTINUOUS("EDGE", "VI_CORPUS_CONTINUOUS", "测试语料-连续对话语料处理"),
    VI_PLAY_CORPUS("EDGE", "VI_PLAY_CORPUS", "播放语料"),
    // ---------------方案---------------
    VI_SCHEME("EDGE", "VI_SCHEME", "语音交互-方案处理"),

    // ---------------机械臂---------------
    TOUCH("EDGE", "TOUCH", "触控"),

    // --------------- 头部 ---------------
    BIO_HEAD_SPEAK_START("EDGE", "BIO_HEAD_SPEAK_START", "开始说话"),
    BIO_HEAD_SPEAK_STOP("EDGE", "BIO_HEAD_SPEAK_STOP", "停止说话"),
    BIO_HEAD_SPECIAL_EXPRESSION("EDGE", "BIO_HEAD_SPECIAL_EXPRESSION", "表情，1:高兴,2:惊讶,3:疲惫"),

    // 大模型行为
    // ---------------获取触控坐标---------------
    TOUCH_COORDINATES("LLM", "TOUCH_COORDINATES", "获取触控坐标"),
    INTENT_RECOGNITION("LLM", "INTENT_RECOGNITION", "意图识别"),
    GENERATE_ADVANCED_AUDIO("LLM", "GENERATE_ADVANCED_AUDIO", "tts语音合成"),
    AI_AGENT_PLATFORM("LLM", "AI_AGENT_PLATFORM", "商道智能体"),
    AI_TTS("LLM", "AI_TTS", "tts语音播放"),
    GET_CURRENT_PAGE("LLM", "GET_CURRENT_PAGE", "获取当前页面名称"),

    // 触控交互
    TI_PATH_SEARCH("EDGE", "TI_PATH_SEARCH", "路径搜索"),
    TI_TOUCH_COORDINATES("EDGE", "TI_TOUCH_COORDINATES", "获取触控二维坐标")
    ;


    private final String operate;
    private final String action;
    private final String description;

    // 根据action值获取对应的枚举
    public static ActionEnum fromAction(String action) {
        for (ActionEnum actionEnum : values()) {
            if (actionEnum.getAction().equalsIgnoreCase(action)) {
                return actionEnum;
            }
        }
        return null;
    }

    public static List<Map<String, String>> toList() {
        List<Map<String, String>> list = new ArrayList<>();
        for (ActionEnum e : values()) {
            Map<String, String> map = new HashMap<>();
            map.put("action", e.getAction());
            map.put("description", e.getDescription());
            list.add(map);
        }
        return list;
    }
}
