import { messageTypeDetector } from "./message-type-detector.js";
import { Status, Role } from "../types/core.js";
function mapChunkTypeToContentType(chunkType) {
  return messageTypeDetector.mapBackendType(chunkType);
}
function detectMessageContentType(content, language) {
  return messageTypeDetector.detectMessageType(content);
}
function enhanceMessage(message, language) {
  if (message.role !== "assistant" || message.contentType) {
    return message;
  }
  const contentType = detectMessageContentType(message.content);
  return {
    ...message,
    contentType
  };
}
function createEnhancedMessage(message, language) {
  const now = (/* @__PURE__ */ new Date()).toISOString();
  const completeMessage = {
    content: "",
    role: Role.Assistant,
    status: Status.Completed,
    timestamp: now,
    createdAt: now,
    version: 1,
    ...message,
    // 覆盖默认值
    id: message.id
    // 确保 id 总是存在
  };
  if (completeMessage.role === Role.Assistant && !completeMessage.contentType && completeMessage.content) {
    completeMessage.contentType = detectMessageContentType(completeMessage.content);
  }
  return completeMessage;
}
export {
  createEnhancedMessage,
  detectMessageContentType,
  enhanceMessage,
  mapChunkTypeToContentType
};
//# sourceMappingURL=message-utils.js.map
