import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
import { localizeWithPath } from '../../../../nls.js';
import { asArray, firstOrDefault } from '../../../../base/common/arrays.js';
import { DeferredPromise } from '../../../../base/common/async.js';
import { Emitter } from '../../../../base/common/event.js';
import { isMarkdownString, MarkdownString } from '../../../../base/common/htmlContent.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { revive } from '../../../../base/common/marshalling.js';
import { equals } from '../../../../base/common/objects.js';
import { isEqual, basename } from '../../../../base/common/resources.js';
import { URI, isUriComponents } from '../../../../base/common/uri.js';
import { generateUuid } from '../../../../base/common/uuid.js';
import { OffsetRange } from '../../../../editor/common/core/offsetRange.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { ILogService } from '../../../../platform/log/common/log.service.js';
import { ChatAgentLocation, reviveSerializedAgent } from './chatAgents.js';
import { IChatAgentService } from './chatAgents.service.js';
import { reviveParsedChatRequest, ChatRequestTextPart, getPromptText } from './chatParserTypes.js';
import { isIUsedContext } from './chatService.js';
var ChatModel_1, ChatWelcomeMessageModel_1;
const _moduleId = "vs/workbench/contrib/chat/common/chatModel";
class ChatRequestModel {
    static { this.nextId = 0; }
    get session() {
        return this._session;
    }
    get username() {
        return this.session.requesterUsername;
    }
    get avatarIconUri() {
        return this.session.requesterAvatarIconUri;
    }
    get attempt() {
        return this._attempt;
    }
    get variableData() {
        return this._variableData;
    }
    set variableData(v) {
        this._variableData = v;
    }
    constructor(_session, message, _variableData, _attempt = 0) {
        this._session = _session;
        this.message = message;
        this._variableData = _variableData;
        this._attempt = _attempt;
        this.id = 'request_' + ChatRequestModel.nextId++;
    }
    adoptTo(session) {
        this._session = session;
    }
}
class Response {
    get onDidChangeValue() {
        return this._onDidChangeValue.event;
    }
    get value() {
        return this._responseParts;
    }
    constructor(value) {
        this._onDidChangeValue = ( (new Emitter()));
        this._responseParts = ( (asArray(value).map((v) => (isMarkdownString(v) ?
            { content: v, kind: 'markdownContent' } :
            'kind' in v ? v : { kind: 'treeData', treeData: v }))));
        this._updateRepr(true);
    }
    asString() {
        return this._responseRepr;
    }
    clear() {
        this._responseParts = [];
        this._updateRepr(true);
    }
    updateContent(progress, quiet) {
        if (progress.kind === 'markdownContent') {
            const responsePartLength = this._responseParts.length - 1;
            const lastResponsePart = this._responseParts[responsePartLength];
            if (!lastResponsePart || lastResponsePart.kind !== 'markdownContent' || !canMergeMarkdownStrings(lastResponsePart.content, progress.content)) {
                this._responseParts.push(progress);
            }
            else {
                lastResponsePart.content = appendMarkdownString(lastResponsePart.content, progress.content);
            }
            this._updateRepr(quiet);
        }
        else if (progress.kind === 'textEdit') {
            if (progress.edits.length > 0) {
                let found = false;
                for (let i = 0; !found && i < this._responseParts.length; i++) {
                    const candidate = this._responseParts[i];
                    if (candidate.kind === 'textEditGroup' && isEqual(candidate.uri, progress.uri)) {
                        candidate.edits.push(progress.edits);
                        found = true;
                    }
                }
                if (!found) {
                    this._responseParts.push({
                        kind: 'textEditGroup',
                        uri: progress.uri,
                        edits: [progress.edits]
                    });
                }
                this._updateRepr(quiet);
            }
        }
        else if (progress.kind === 'progressTask') {
            const responsePosition = this._responseParts.push(progress) - 1;
            this._updateRepr(quiet);
            const disp = progress.onDidAddProgress(() => {
                this._updateRepr(false);
            });
            progress.task?.().then((content) => {
                disp.dispose();
                if (typeof content === 'string') {
                    this._responseParts[responsePosition].content = ( (new MarkdownString(content)));
                }
                this._updateRepr(false);
            });
        }
        else {
            this._responseParts.push(progress);
            this._updateRepr(quiet);
        }
    }
    _updateRepr(quiet) {
        this._responseRepr = ( (this._responseParts.map(part => {
            if (part.kind === 'treeData') {
                return '';
            }
            else if (part.kind === 'inlineReference') {
                return basename('uri' in part.inlineReference ? part.inlineReference.uri : part.inlineReference);
            }
            else if (part.kind === 'command') {
                return part.command.title;
            }
            else if (part.kind === 'textEditGroup') {
                return ( localizeWithPath(_moduleId, 0, "Made changes."));
            }
            else if (part.kind === 'progressMessage') {
                return '';
            }
            else if (part.kind === 'confirmation') {
                return `${part.title}\n${part.message}`;
            }
            else {
                return part.content.value;
            }
        })))
            .filter(s => s.length > 0)
            .join('\n\n');
        if (!quiet) {
            this._onDidChangeValue.fire();
        }
    }
}
class ChatResponseModel extends Disposable {
    static { this.nextId = 0; }
    get session() {
        return this._session;
    }
    get isComplete() {
        return this._isComplete;
    }
    get isCanceled() {
        return this._isCanceled;
    }
    get vote() {
        return this._vote;
    }
    get followups() {
        return this._followups;
    }
    get response() {
        return this._response;
    }
    get result() {
        return this._result;
    }
    get username() {
        return this.session.responderUsername;
    }
    get avatarIcon() {
        return this.session.responderAvatarIcon;
    }
    get agent() {
        return this._agent;
    }
    get slashCommand() {
        return this._slashCommand;
    }
    get agentOrSlashCommandDetected() {
        return this._agentOrSlashCommandDetected ?? false;
    }
    get usedContext() {
        return this._usedContext;
    }
    get contentReferences() {
        return this._contentReferences;
    }
    get progressMessages() {
        return this._progressMessages;
    }
    get isStale() {
        return this._isStale;
    }
    constructor(_response, _session, _agent, _slashCommand, requestId, _isComplete = false, _isCanceled = false, _vote, _result, followups) {
        super();
        this._session = _session;
        this._agent = _agent;
        this._slashCommand = _slashCommand;
        this.requestId = requestId;
        this._isComplete = _isComplete;
        this._isCanceled = _isCanceled;
        this._vote = _vote;
        this._result = _result;
        this._onDidChange = this._register(( (new Emitter())));
        this.onDidChange = this._onDidChange.event;
        this._contentReferences = [];
        this._progressMessages = [];
        this._isStale = false;
        this._isStale = Array.isArray(_response) && (_response.length !== 0 || isMarkdownString(_response) && _response.value.length !== 0);
        this._followups = followups ? [...followups] : undefined;
        this._response = ( (new Response(_response)));
        this._register(this._response.onDidChangeValue(() => this._onDidChange.fire()));
        this.id = 'response_' + ChatResponseModel.nextId++;
    }
    updateContent(responsePart, quiet) {
        this._response.updateContent(responsePart, quiet);
    }
    applyReference(progress) {
        if (progress.kind === 'usedContext') {
            this._usedContext = progress;
        }
        else if (progress.kind === 'reference') {
            this._contentReferences.push(progress);
            this._onDidChange.fire();
        }
    }
    setAgent(agent, slashCommand) {
        this._agent = agent;
        this._slashCommand = slashCommand;
        this._agentOrSlashCommandDetected = true;
        this._onDidChange.fire();
    }
    setResult(result) {
        this._result = result;
        this._onDidChange.fire();
    }
    complete() {
        if (this._result?.errorDetails?.responseIsRedacted) {
            this._response.clear();
        }
        this._isComplete = true;
        this._onDidChange.fire();
    }
    cancel() {
        this._isComplete = true;
        this._isCanceled = true;
        this._onDidChange.fire();
    }
    setFollowups(followups) {
        this._followups = followups;
        this._onDidChange.fire();
    }
    setVote(vote) {
        this._vote = vote;
        this._onDidChange.fire();
    }
    setEditApplied(edit, editCount) {
        if (!this.response.value.includes(edit)) {
            return false;
        }
        if (!edit.state) {
            return false;
        }
        edit.state.applied = editCount;
        this._onDidChange.fire();
        return true;
    }
    adoptTo(session) {
        this._session = session;
        this._onDidChange.fire();
    }
}
function isExportableSessionData(obj) {
    const data = obj;
    return typeof data === 'object' &&
        typeof data.requesterUsername === 'string';
}
function isSerializableSessionData(obj) {
    const data = obj;
    return isExportableSessionData(obj) &&
        typeof data.creationDate === 'number' &&
        typeof data.sessionId === 'string' &&
        obj.requests.every((request) => !request.usedContext  || isIUsedContext(request.usedContext));
}
var ChatRequestRemovalReason;
( ((function(ChatRequestRemovalReason) {
    ChatRequestRemovalReason[ChatRequestRemovalReason["Removal"] = 0] = "Removal";
    ChatRequestRemovalReason[ChatRequestRemovalReason["Resend"] = 1] = "Resend";
    ChatRequestRemovalReason[ChatRequestRemovalReason["Adoption"] = 2] = "Adoption";
})(ChatRequestRemovalReason || (ChatRequestRemovalReason = {}))));
var ChatModelInitState;
( ((function(ChatModelInitState) {
    ChatModelInitState[ChatModelInitState["Created"] = 0] = "Created";
    ChatModelInitState[ChatModelInitState["Initializing"] = 1] = "Initializing";
    ChatModelInitState[ChatModelInitState["Initialized"] = 2] = "Initialized";
})(ChatModelInitState || (ChatModelInitState = {}))));
let ChatModel = ChatModel_1 = class ChatModel extends Disposable {
    static getDefaultTitle(requests) {
        const firstRequestMessage = firstOrDefault(requests)?.message ?? '';
        const message = typeof firstRequestMessage === 'string' ?
            firstRequestMessage :
            firstRequestMessage.text;
        return message.split('\n')[0].substring(0, 50);
    }
    get welcomeMessage() {
        return this._welcomeMessage;
    }
    get sessionId() {
        return this._sessionId;
    }
    get requestInProgress() {
        const lastRequest = this._requests[this._requests.length - 1];
        return !!lastRequest && !!lastRequest.response && !lastRequest.response.isComplete;
    }
    get hasRequests() {
        return this._requests.length > 0;
    }
    get creationDate() {
        return this._creationDate;
    }
    get _defaultAgent() {
        return this.chatAgentService.getDefaultAgent(ChatAgentLocation.Panel);
    }
    get requesterUsername() {
        return (this._defaultAgent ?
            this._defaultAgent.metadata.requester?.name :
            this.initialData?.requesterUsername) ?? '';
    }
    get responderUsername() {
        return (this._defaultAgent ?
            this._defaultAgent.fullName :
            this.initialData?.responderUsername) ?? '';
    }
    get requesterAvatarIconUri() {
        return this._defaultAgent ?
            this._defaultAgent.metadata.requester?.icon :
            this._initialRequesterAvatarIconUri;
    }
    get responderAvatarIcon() {
        return this._defaultAgent ?
            this._defaultAgent?.metadata.themeIcon :
            this._initialResponderAvatarIconUri;
    }
    get initState() {
        return this._initState;
    }
    get isImported() {
        return this._isImported;
    }
    get title() {
        return ChatModel_1.getDefaultTitle(this._requests);
    }
    get initialLocation() {
        return this._initialLocation;
    }
    constructor(initialData, _initialLocation, logService, chatAgentService, instantiationService) {
        super();
        this.initialData = initialData;
        this._initialLocation = _initialLocation;
        this.logService = logService;
        this.chatAgentService = chatAgentService;
        this.instantiationService = instantiationService;
        this._onDidDispose = this._register(( (new Emitter())));
        this.onDidDispose = this._onDidDispose.event;
        this._onDidChange = this._register(( (new Emitter())));
        this.onDidChange = this._onDidChange.event;
        this._initState = ChatModelInitState.Created;
        this._isInitializedDeferred = ( (new DeferredPromise()));
        this._isImported = false;
        this._isImported = (!!initialData && !isSerializableSessionData(initialData)) || (initialData?.isImported ?? false);
        this._sessionId = (isSerializableSessionData(initialData) && initialData.sessionId) || generateUuid();
        this._requests = initialData ? this._deserialize(initialData) : [];
        this._creationDate = (isSerializableSessionData(initialData) && initialData.creationDate) || Date.now();
        this._initialRequesterAvatarIconUri = initialData?.requesterAvatarIconUri && URI.revive(initialData.requesterAvatarIconUri);
        this._initialResponderAvatarIconUri = isUriComponents(initialData?.responderAvatarIconUri) ? URI.revive(initialData.responderAvatarIconUri) : initialData?.responderAvatarIconUri;
    }
    _deserialize(obj) {
        const requests = obj.requests;
        if (!Array.isArray(requests)) {
            this.logService.error(`Ignoring malformed session data: ${JSON.stringify(obj)}`);
            return [];
        }
        if (obj.welcomeMessage) {
            const content = ( (obj.welcomeMessage.map(
                item => typeof item === 'string' ? ( (new MarkdownString(item))) : item
            )));
            this._welcomeMessage = this.instantiationService.createInstance(ChatWelcomeMessageModel, content, []);
        }
        try {
            return (
                 (requests.map((raw) => {
                    const parsedRequest = typeof raw.message === 'string'
                        ? this.getParsedRequestFromString(raw.message)
                        : reviveParsedChatRequest(raw.message);
                    const variableData = this.reviveVariableData(raw.variableData);
                    const request = ( (new ChatRequestModel(this, parsedRequest, variableData)));
                    if (raw.response || raw.result || raw.responseErrorDetails) {
                        const agent = (raw.agent && 'metadata' in raw.agent) ?
                            reviveSerializedAgent(raw.agent) : undefined;
                        const result = 'responseErrorDetails' in raw ?
                            { errorDetails: raw.responseErrorDetails } : raw.result;
                        request.response = ( (new ChatResponseModel(
                            raw.response ?? [( (new MarkdownString(raw.response)))],
                            this,
                            agent,
                            raw.slashCommand,
                            request.id,
                            true,
                            raw.isCanceled,
                            raw.vote,
                            result,
                            raw.followups
                        )));
                        if (raw.usedContext) {
                            request.response.applyReference(revive(raw.usedContext));
                        }
                        if (raw.contentReferences) {
                            raw.contentReferences.forEach(r => request.response.applyReference(revive(r)));
                        }
                    }
                    return request;
                }))
            );
        }
        catch (error) {
            this.logService.error('Failed to parse chat data', error);
            return [];
        }
    }
    reviveVariableData(raw) {
        const variableData = raw && Array.isArray(raw.variables)
            ? raw :
            { variables: [] };
        variableData.variables = ( (variableData.variables.map((v) => {
            if (v && 'values' in v && Array.isArray(v.values)) {
                return {
                    id: v.id ?? '',
                    name: v.name,
                    value: v.values[0]?.value,
                    range: v.range,
                    modelDescription: v.modelDescription,
                    references: v.references
                };
            }
            else {
                return v;
            }
        })));
        return variableData;
    }
    getParsedRequestFromString(message) {
        const parts = [( (new ChatRequestTextPart(
             (new OffsetRange(0, message.length)),
            { startColumn: 1, startLineNumber: 1, endColumn: 1, endLineNumber: 1 },
            message
        )))];
        return {
            text: message,
            parts
        };
    }
    startInitialize() {
        if (this.initState !== ChatModelInitState.Created) {
            throw ( (new Error(
                `ChatModel is in the wrong state for startInitialize: ${ChatModelInitState[this.initState]}`
            )));
        }
        this._initState = ChatModelInitState.Initializing;
    }
    deinitialize() {
        this._initState = ChatModelInitState.Created;
        this._isInitializedDeferred = ( (new DeferredPromise()));
    }
    initialize(welcomeMessage) {
        if (this.initState !== ChatModelInitState.Initializing) {
            throw ( (new Error(
                `ChatModel is in the wrong state for initialize: ${ChatModelInitState[this.initState]}`
            )));
        }
        this._initState = ChatModelInitState.Initialized;
        if (!this._welcomeMessage) {
            this._welcomeMessage = welcomeMessage;
        }
        this._isInitializedDeferred.complete();
        this._onDidChange.fire({ kind: 'initialize' });
    }
    setInitializationError(error) {
        if (this.initState !== ChatModelInitState.Initializing) {
            throw ( (new Error(
                `ChatModel is in the wrong state for setInitializationError: ${ChatModelInitState[this.initState]}`
            )));
        }
        if (!this._isInitializedDeferred.isSettled) {
            this._isInitializedDeferred.error(error);
        }
    }
    waitForInitialization() {
        return this._isInitializedDeferred.p;
    }
    getRequests() {
        return this._requests;
    }
    addRequest(message, variableData, attempt, chatAgent, slashCommand) {
        const request = ( (new ChatRequestModel(this, message, variableData, attempt)));
        request.response = ( (new ChatResponseModel([], this, chatAgent, slashCommand, request.id)));
        this._requests.push(request);
        this._onDidChange.fire({ kind: 'addRequest', request });
        return request;
    }
    adoptRequest(request) {
        const oldOwner = request.session;
        const index = oldOwner._requests.findIndex(candidate => candidate.id === request.id);
        if (index === -1) {
            return;
        }
        oldOwner._requests.splice(index, 1);
        request.adoptTo(this);
        request.response?.adoptTo(this);
        this._requests.push(request);
        oldOwner._onDidChange.fire({ kind: 'removeRequest', requestId: request.id, responseId: request.response?.id, reason: ChatRequestRemovalReason.Adoption });
        this._onDidChange.fire({ kind: 'addRequest', request });
    }
    acceptResponseProgress(request, progress, quiet) {
        if (!request.response) {
            request.response = ( (new ChatResponseModel([], this, undefined, undefined, request.id)));
        }
        if (request.response.isComplete) {
            throw ( (new Error('acceptResponseProgress: Adding progress to a completed response')));
        }
        if (progress.kind === 'markdownContent' ||
            progress.kind === 'treeData' ||
            progress.kind === 'inlineReference' ||
            progress.kind === 'markdownVuln' ||
            progress.kind === 'progressMessage' ||
            progress.kind === 'command' ||
            progress.kind === 'textEdit' ||
            progress.kind === 'warning' ||
            progress.kind === 'progressTask' ||
            progress.kind === 'confirmation') {
            request.response.updateContent(progress, quiet);
        }
        else if (progress.kind === 'usedContext' || progress.kind === 'reference') {
            request.response.applyReference(progress);
        }
        else if (progress.kind === 'agentDetection') {
            const agent = this.chatAgentService.getAgent(progress.agentId);
            if (agent) {
                request.response.setAgent(agent, progress.command);
            }
        }
        else {
            this.logService.error(`Couldn't handle progress: ${JSON.stringify(progress)}`);
        }
    }
    removeRequest(id, reason = ChatRequestRemovalReason.Removal) {
        const index = this._requests.findIndex(request => request.id === id);
        const request = this._requests[index];
        if (index !== -1) {
            this._onDidChange.fire({ kind: 'removeRequest', requestId: request.id, responseId: request.response?.id, reason });
            this._requests.splice(index, 1);
            request.response?.dispose();
        }
    }
    cancelRequest(request) {
        if (request.response) {
            request.response.cancel();
        }
    }
    setResponse(request, result) {
        if (!request.response) {
            request.response = ( (new ChatResponseModel([], this, undefined, undefined, request.id)));
        }
        request.response.setResult(result);
    }
    completeResponse(request) {
        if (!request.response) {
            throw ( (new Error('Call setResponse before completeResponse')));
        }
        request.response.complete();
    }
    setFollowups(request, followups) {
        if (!request.response) {
            return;
        }
        request.response.setFollowups(followups);
    }
    setResponseModel(request, response) {
        request.response = response;
        this._onDidChange.fire({ kind: 'addResponse', response });
    }
    toExport() {
        return {
            requesterUsername: this.requesterUsername,
            requesterAvatarIconUri: this.requesterAvatarIconUri,
            responderUsername: this.responderUsername,
            responderAvatarIconUri: this.responderAvatarIcon,
            initialLocation: this.initialLocation,
            welcomeMessage: this._welcomeMessage?.content.map(c => {
                if (Array.isArray(c)) {
                    return c;
                }
                else {
                    return c.value;
                }
            }),
            requests: ( (this._requests.map((r) => {
                const message = {
                    ...r.message,
                    parts: ( (r.message.parts.map(p => p && 'toJSON' in p ? p.toJSON() : p)))
                };
                return {
                    message,
                    variableData: r.variableData,
                    response: r.response ?
                        ( (r.response.response.value.map(item => {
                            if (item.kind === 'treeData') {
                                return item.treeData;
                            }
                            else if (item.kind === 'markdownContent') {
                                return item.content;
                            }
                            else {
                                return item;
                            }
                        })))
                        : undefined,
                    result: r.response?.result,
                    followups: r.response?.followups,
                    isCanceled: r.response?.isCanceled,
                    vote: r.response?.vote,
                    agent: r.response?.agent ? { ...r.response.agent } : undefined,
                    slashCommand: r.response?.slashCommand,
                    usedContext: r.response?.usedContext,
                    contentReferences: r.response?.contentReferences
                };
            }))),
        };
    }
    toJSON() {
        return {
            ...this.toExport(),
            sessionId: this.sessionId,
            creationDate: this._creationDate,
            isImported: this._isImported
        };
    }
    dispose() {
        this._requests.forEach(r => r.response?.dispose());
        this._onDidDispose.fire();
        super.dispose();
    }
};
ChatModel = ChatModel_1 = ( (__decorate([
    ( (__param(2, ILogService))),
    ( (__param(3, IChatAgentService))),
    ( (__param(4, IInstantiationService)))
], ChatModel)));
let ChatWelcomeMessageModel = class ChatWelcomeMessageModel {
    static { ChatWelcomeMessageModel_1 = this; }
    static { this.nextId = 0; }
    get id() {
        return this._id;
    }
    constructor(content, sampleQuestions, chatAgentService) {
        this.content = content;
        this.sampleQuestions = sampleQuestions;
        this.chatAgentService = chatAgentService;
        this._id = 'welcome_' + ChatWelcomeMessageModel_1.nextId++;
    }
    get username() {
        return this.chatAgentService.getContributedDefaultAgent(ChatAgentLocation.Panel)?.fullName ?? '';
    }
    get avatarIcon() {
        return this.chatAgentService.getDefaultAgent(ChatAgentLocation.Panel)?.metadata.themeIcon;
    }
};
ChatWelcomeMessageModel = ChatWelcomeMessageModel_1 = ( (__decorate([
    ( (__param(2, IChatAgentService)))
], ChatWelcomeMessageModel)));
function getHistoryEntriesFromModel(model, forAgentId) {
    const history = [];
    for (const request of model.getRequests()) {
        if (!request.response) {
            continue;
        }
        if (forAgentId && forAgentId !== request.response.agent?.id) {
            continue;
        }
        const promptTextResult = getPromptText(request.message);
        const historyRequest = {
            sessionId: model.sessionId,
            requestId: request.id,
            agentId: request.response.agent?.id ?? '',
            message: promptTextResult.message,
            command: request.response.slashCommand?.name,
            variables: updateRanges(request.variableData, promptTextResult.diff),
            location: ChatAgentLocation.Panel
        };
        history.push({ request: historyRequest, response: request.response.response.value, result: request.response.result ?? {} });
    }
    return history;
}
function updateRanges(variableData, diff) {
    return {
        variables: ( (variableData.variables.map(v => ({
            ...v,
            range: v.range && {
                start: v.range.start - diff,
                endExclusive: v.range.endExclusive - diff
            }
        }))))
    };
}
function canMergeMarkdownStrings(md1, md2) {
    if (md1.baseUri && md2.baseUri) {
        const baseUriEquals = md1.baseUri.scheme === md2.baseUri.scheme
            && md1.baseUri.authority === md2.baseUri.authority
            && md1.baseUri.path === md2.baseUri.path
            && md1.baseUri.query === md2.baseUri.query
            && md1.baseUri.fragment === md2.baseUri.fragment;
        if (!baseUriEquals) {
            return false;
        }
    }
    else if (md1.baseUri || md2.baseUri) {
        return false;
    }
    return equals(md1.isTrusted, md2.isTrusted) &&
        md1.supportHtml === md2.supportHtml &&
        md1.supportThemeIcons === md2.supportThemeIcons;
}
function appendMarkdownString(md1, md2) {
    const appendedValue = typeof md2 === 'string' ? md2 : md2.value;
    return {
        value: md1.value + appendedValue,
        isTrusted: md1.isTrusted,
        supportThemeIcons: md1.supportThemeIcons,
        supportHtml: md1.supportHtml,
        baseUri: md1.baseUri
    };
}
export { ChatModel, ChatModelInitState, ChatRequestModel, ChatRequestRemovalReason, ChatResponseModel, ChatWelcomeMessageModel, Response, appendMarkdownString, canMergeMarkdownStrings, getHistoryEntriesFromModel, isExportableSessionData, isSerializableSessionData, updateRanges };
