"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const defaultModule = require("./lib-default-module.cjs");
const dependencyInjection = require("./lib-dependency-injection.cjs");
const ast = require("./lib-languages-generated-ast.cjs");
const fileSystemProvider = require("./lib-workspace-file-system-provider.cjs");
require("./lib-utils-uri-utils.cjs");
const index = require("../vscode-uri/lib-esm-index.cjs");
const minimalGrammarModule = {
  Grammar: () => void 0,
  LanguageMetaData: () => ({
    caseInsensitive: false,
    fileExtensions: [".langium"],
    languageId: "langium"
  })
};
const minimalSharedGrammarModule = {
  AstReflection: () => new ast.LangiumGrammarAstReflection()
};
function createMinimalGrammarServices() {
  const shared = dependencyInjection.inject(defaultModule.createDefaultSharedCoreModule(fileSystemProvider.EmptyFileSystem), minimalSharedGrammarModule);
  const grammar = dependencyInjection.inject(defaultModule.createDefaultCoreModule({ shared }), minimalGrammarModule);
  shared.ServiceRegistry.register(grammar);
  return grammar;
}
function loadGrammarFromJson(json) {
  var _a;
  const services = createMinimalGrammarServices();
  const astNode = services.serializer.JsonSerializer.deserialize(json);
  services.shared.workspace.LangiumDocumentFactory.fromModel(astNode, index.URI.parse(`memory://${(_a = astNode.name) !== null && _a !== void 0 ? _a : "grammar"}.langium`));
  return astNode;
}
exports.loadGrammarFromJson = loadGrammarFromJson;
//# sourceMappingURL=lib-utils-grammar-loader.cjs.map
