import { LangiumGrammarAstReflection } from "../languages/generated/ast.js";
import { URI } from "../../../vscode-uri/lib/esm/index.js";
import { createDefaultCoreModule, createDefaultSharedCoreModule } from "../default-module.js";
import { inject } from "../dependency-injection.js";
import { EmptyFileSystem } from "../workspace/file-system-provider.js";
var minimalGrammarModule = {
	Grammar: () => void 0,
	LanguageMetaData: () => ({
		caseInsensitive: !1,
		fileExtensions: [".langium"],
		languageId: "langium"
	})
}, minimalSharedGrammarModule = { AstReflection: () => new LangiumGrammarAstReflection() };
function createMinimalGrammarServices() {
	let e = inject(createDefaultSharedCoreModule(EmptyFileSystem), minimalSharedGrammarModule), s = inject(createDefaultCoreModule({ shared: e }), minimalGrammarModule);
	return e.ServiceRegistry.register(s), s;
}
function loadGrammarFromJson(e) {
	let c = createMinimalGrammarServices(), l = c.serializer.JsonSerializer.deserialize(e);
	return c.shared.workspace.LangiumDocumentFactory.fromModel(l, URI.parse(`memory:/${l.name ?? "grammar"}.langium`)), l;
}
export { loadGrammarFromJson };
