"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var interface_package_definition_exports = {};
__export(interface_package_definition_exports, {
  InterfacePackageDefinitionModule: () => InterfacePackageDefinitionModule
});
module.exports = __toCommonJS(interface_package_definition_exports);
var consts = __toESM(require("../../consts"));
var import_generators = require("../../generators");
var import_module = require("../../module");
var import_actions_module = require("./actions-module");
var import_channels_module = require("./channels-module");
var import_entities_module = require("./entities-module");
var import_events_module = require("./events-module");
class InterfacePackageDefinitionModule extends import_module.Module {
  constructor(_interface) {
    super({
      path: consts.INDEX_FILE,
      exportName: consts.DEFAULT_EXPORT_NAME
    });
    this._interface = _interface;
    const actionsModule = new import_actions_module.ActionsModule(_interface.actions ?? {});
    actionsModule.unshift("actions");
    const channelsModule = new import_channels_module.ChannelsModule(_interface.channels ?? {});
    channelsModule.unshift("channels");
    const eventsModule = new import_events_module.EventsModule(_interface.events ?? {});
    eventsModule.unshift("events");
    const entitiesModule = new import_entities_module.EntitiesModule(_interface.entities ?? {});
    entitiesModule.unshift("entities");
    this._dependencies = {
      actionsModule,
      channelsModule,
      eventsModule,
      entitiesModule
    };
    for (const dep of Object.values(this._dependencies)) {
      this.pushDep(dep);
    }
  }
  _dependencies;
  async getContent() {
    let content = "";
    const { actionsModule, channelsModule, eventsModule, entitiesModule } = this._dependencies;
    const actionsImport = actionsModule.import(this);
    const channelsImport = channelsModule.import(this);
    const eventsImport = eventsModule.import(this);
    const entitiesImport = entitiesModule.import(this);
    const interfaceAttributes = this._interface.attributes ? (0, import_generators.stringifySingleLine)(this._interface.attributes) : "{}";
    content += [
      consts.GENERATED_HEADER,
      'import * as sdk from "@botpress/sdk"',
      "",
      `import * as ${actionsModule.name} from "./${actionsImport}"`,
      `import * as ${channelsModule.name} from "./${channelsImport}"`,
      `import * as ${eventsModule.name} from "./${eventsImport}"`,
      `import * as ${entitiesModule.name} from "./${entitiesImport}"`,
      `export * as ${actionsModule.name} from "./${actionsImport}"`,
      `export * as ${channelsModule.name} from "./${channelsImport}"`,
      `export * as ${eventsModule.name} from "./${eventsImport}"`,
      `export * as ${entitiesModule.name} from "./${entitiesImport}"`,
      "",
      "export default {",
      `  name: "${this._interface.name}",`,
      `  version: "${this._interface.version}",`,
      `  attributes: ${interfaceAttributes},`,
      `  actions: ${actionsModule.name}.${actionsModule.exportName},`,
      `  channels: ${channelsModule.name}.${channelsModule.exportName},`,
      `  events: ${eventsModule.name}.${eventsModule.exportName},`,
      `  entities: ${entitiesModule.name}.${entitiesModule.exportName},`,
      '} satisfies sdk.InterfacePackage["definition"]'
    ].join("\n");
    return content;
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  InterfacePackageDefinitionModule
});
//# sourceMappingURL=index.js.map
