function _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = source[key];
    }
    return target;
}
import { extractTextFromContent } from "./mapOpenAIMessages";
/**
 * 将单条 OpenClaw 风格消息转为可与 {@link mapOpenAIMessagesToMessageBubbleData} 兼容的 OpenAI 形状（`toolResult` → `tool`）。
 */ export function normalizeOpenClawMessageToOpenAI(msg) {
    if (msg.role === 'toolResult') {
        var m = msg;
        var content = m.content === undefined || m.content === null ? '' : typeof m.content === 'string' ? m.content : extractTextFromContent(m.content);
        return {
            role: 'tool',
            id: m.id,
            name: m.name,
            content: content,
            tool_call_id: m.tool_call_id
        };
    }
    var _ts = msg.timestamp, rest = _object_without_properties(msg, [
        "timestamp"
    ]);
    return rest;
}
/**
 * 批量将 OpenClaw transcript 消息转为 OpenAI Chat Completions 兼容结构
 */ export function normalizeOpenClawMessagesToOpenAI(messages) {
    return messages.map(normalizeOpenClawMessageToOpenAI);
}
