'use strict';

var chunkAF3E2D32_cjs = require('./chunk-AF3E2D32.cjs');
var types = require('@storm-software/config-tools/types');

async function buildApplication(log, context, hooks) {
  log(types.LogLevelLabel.TRACE, "Executing build process for the Storm Stack application.");
  await hooks.callHook("build:application", context).catch((error) => {
    log(types.LogLevelLabel.ERROR, `An error occured while building the Storm Stack application: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while building the Storm Stack application", {
      cause: error
    });
  });
}
chunkAF3E2D32_cjs.__name(buildApplication, "buildApplication");
async function buildLibrary(log, context, hooks) {
  log(types.LogLevelLabel.TRACE, "Executing build process for the Storm Stack library.");
  await hooks.callHook("build:library", context).catch((error) => {
    log(types.LogLevelLabel.ERROR, `An error occured while building the Storm Stack library: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while building the Storm Stack library", {
      cause: error
    });
  });
}
chunkAF3E2D32_cjs.__name(buildLibrary, "buildLibrary");

// src/build/index.ts
async function build(log, context, hooks) {
  await hooks.callHook("build:begin", context).catch((error) => {
    log(types.LogLevelLabel.ERROR, `An error occured while starting the build process for the Storm Stack project: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while starting the build process for the Storm Stack project", {
      cause: error
    });
  });
  if (context.options.projectType === "application") {
    await buildApplication(log, context, hooks);
  } else {
    await buildLibrary(log, context, hooks);
  }
  await hooks.callHook("build:complete", context).catch((error) => {
    log(types.LogLevelLabel.ERROR, `An error occured while finishing the build process for the Storm Stack project: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while finishing the build process for the Storm Stack project", {
      cause: error
    });
  });
}
chunkAF3E2D32_cjs.__name(build, "build");

exports.build = build;
//# sourceMappingURL=chunk-LSVMJHR4.cjs.map
//# sourceMappingURL=chunk-LSVMJHR4.cjs.map