
import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
import { ReferenceCollection } from '../../../../../../base/common/lifecycle.js';
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
import { CellKind } from '../../../common/notebookCommon.js';
import { URI } from '../../../../../../base/common/uri.js';
import { ILanguageService } from '../../../../../../editor/common/languages/language.service.js';
import { IModelService } from '../../../../../../editor/common/services/model.service.js';

let OriginalNotebookCellModelReferenceCollection = class OriginalNotebookCellModelReferenceCollection extends ReferenceCollection {
    constructor(modelService, _languageService) {
        super();
        this.modelService = modelService;
        this._languageService = _languageService;
    }
    createReferencedObject(_key, uri, cellValue, language, cellKind) {
        const scheme = `${uri.scheme}-chat-edit`;
        const originalCellUri = ( URI.from({
            scheme,
            fragment: uri.fragment,
            path: uri.path
        }));
        const languageSelection = this._languageService.getLanguageIdByLanguageName(language) ? this._languageService.createById(language) : cellKind === CellKind.Markup ? this._languageService.createById("markdown") : null;
        return this.modelService.createModel(cellValue, languageSelection, originalCellUri);
    }
    destroyReferencedObject(_key, model) {
        model.dispose();
    }
};
OriginalNotebookCellModelReferenceCollection = ( __decorate([( __param(0, IModelService)), ( __param(1, ILanguageService))], OriginalNotebookCellModelReferenceCollection));
let OriginalNotebookCellModelFactory = class OriginalNotebookCellModelFactory {
    constructor(instantiationService) {
        this._data = instantiationService.createInstance(OriginalNotebookCellModelReferenceCollection);
    }
    getOrCreate(uri, cellValue, language, cellKind) {
        return this._data.acquire(( uri.toString()), uri, cellValue, language, cellKind);
    }
};
OriginalNotebookCellModelFactory = ( __decorate([( __param(0, IInstantiationService))], OriginalNotebookCellModelFactory));

export { OriginalNotebookCellModelFactory, OriginalNotebookCellModelReferenceCollection };
