"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PhaseDataContainer = void 0;
exports.rawPartAsPhaseData = rawPartAsPhaseData;
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
const prompt_tsx_1 = require("@vscode/prompt-tsx");
const endpointTypes_1 = require("./endpointTypes");
/**
 * Helper element to embed phase data into assistant messages
 * as an opaque content part.
 */
class PhaseDataContainer extends prompt_tsx_1.PromptElement {
    render() {
        const { phase } = this.props;
        const container = { type: endpointTypes_1.CustomDataPartMimeTypes.PhaseData, phase };
        return vscpp("opaque", { value: container });
    }
}
exports.PhaseDataContainer = PhaseDataContainer;
/**
 * Attempts to parse a Raw opaque content part into a phase string, if the type matches.
 */
function rawPartAsPhaseData(part) {
    const value = part.value;
    if (!value || typeof value !== 'object') {
        return;
    }
    const data = value;
    if (data.type === endpointTypes_1.CustomDataPartMimeTypes.PhaseData && typeof data.phase === 'string') {
        return data.phase;
    }
    return;
}
//# sourceMappingURL=phaseDataContainer.js.map