package com.huimv.employment.service.conversation.dto;

import com.huimv.employment.service.conversation.MessageCardConstants;
import org.springframework.util.StringUtils;

/**
 * 解析后的 assistant 回复：展示文本 + 可选卡片元数据。
 */
public class ParsedAssistantReply {

    private final String displayText;
    private final String contentType;
    private final String cardPayload;
    private final String nextAction;
    private final Long relatedDraftId;

    public ParsedAssistantReply(String displayText,
                                String contentType,
                                String cardPayload,
                                String nextAction,
                                Long relatedDraftId) {
        this.displayText = displayText;
        this.contentType = contentType;
        this.cardPayload = cardPayload;
        this.nextAction = nextAction;
        this.relatedDraftId = relatedDraftId;
    }

    public static ParsedAssistantReply textOnly(String displayText) {
        return new ParsedAssistantReply(
                displayText,
                MessageCardConstants.CONTENT_TYPE_TEXT,
                null,
                null,
                null);
    }

    public boolean hasCard() {
        return StringUtils.hasText(contentType)
                && !MessageCardConstants.CONTENT_TYPE_TEXT.equals(contentType);
    }

    public ParsedAssistantReply withCard(String contentType,
                                         String nextAction,
                                         String cardPayload,
                                         Long relatedDraftId) {
        return new ParsedAssistantReply(displayText, contentType, cardPayload, nextAction, relatedDraftId);
    }

    public String getDisplayText() {
        return displayText;
    }

    public String getContentType() {
        return contentType;
    }

    public String getCardPayload() {
        return cardPayload;
    }

    public String getNextAction() {
        return nextAction;
    }

    public Long getRelatedDraftId() {
        return relatedDraftId;
    }
}
